@ -219,13 +219,17 @@
{ { claim . issuedAt . substring ( 0 , 10 ) } }
{ { claim . issuedAt . substring ( 0 , 10 ) } }
< / span >
< / span >
< span class = "col-span-2" >
< span class = "col-span-2" >
{ { capitalizeAndInsertSpacesBeforeCaps ( claim . claimType ) } }
{ {
capitalizeAndInsertSpacesBeforeCaps (
claim . claimType ? ? "Unknown" ,
)
} }
< / span >
< / span >
< span class = "col-span-2" >
< span class = "col-span-2" >
{ { claimAmount ( claim ) } }
{ { claimAmount ( claim . claim ) } }
< / span >
< / span >
< span class = "col-span-5" >
< span class = "col-span-5" >
{ { claimDescription ( claim ) } }
{ { claimDescription ( claim . claim ) } }
< / span >
< / span >
< span class = "col-span-1" >
< span class = "col-span-1" >
< a class = "cursor-pointer" @click ="onClickLoadClaim(claim.id)" >
< a class = "cursor-pointer" @click ="onClickLoadClaim(claim.id)" >
@ -263,7 +267,12 @@ import { NotificationIface } from "../constants/app";
import { Contact } from "../db/tables/contacts" ;
import { Contact } from "../db/tables/contacts" ;
import { BoundingBox } from "../db/tables/settings" ;
import { BoundingBox } from "../db/tables/settings" ;
import * as databaseUtil from "../db/databaseUtil" ;
import * as databaseUtil from "../db/databaseUtil" ;
import { GenericCredWrapper , GenericVerifiableCredential } from "../interfaces" ;
import {
GenericCredWrapper ,
GenericVerifiableCredential ,
GiveActionClaim ,
OfferClaim ,
} from "../interfaces" ;
import {
import {
capitalizeAndInsertSpacesBeforeCaps ,
capitalizeAndInsertSpacesBeforeCaps ,
didInfoForContact ,
didInfoForContact ,
@ -274,7 +283,7 @@ import {
import * as libsUtil from "../libs/util" ;
import * as libsUtil from "../libs/util" ;
import EntityIcon from "../components/EntityIcon.vue" ;
import EntityIcon from "../components/EntityIcon.vue" ;
import { logger } from "../utils/logger" ;
import { logger } from "../utils/logger" ;
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory " ;
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin " ;
/ * *
/ * *
* DIDView Component
* DIDView Component
@ -294,6 +303,7 @@ import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
QuickNav ,
QuickNav ,
TopMessage ,
TopMessage ,
} ,
} ,
mixins : [ PlatformServiceMixin ] ,
} )
} )
export default class DIDView extends Vue {
export default class DIDView extends Vue {
$notify ! : ( notification : NotificationIface , timeout ? : number ) => void ;
$notify ! : ( notification : NotificationIface , timeout ? : number ) => void ;
@ -392,8 +402,7 @@ export default class DIDView extends Vue {
private async loadContactInformation ( ) {
private async loadContactInformation ( ) {
if ( ! this . viewingDid ) return ;
if ( ! this . viewingDid ) return ;
const platformService = PlatformServiceFactory . getInstance ( ) ;
const dbContacts = await this . $dbQuery (
const dbContacts = await platformService . dbQuery (
"SELECT * FROM contacts WHERE did = ?" ,
"SELECT * FROM contacts WHERE did = ?" ,
[ this . viewingDid ] ,
[ this . viewingDid ] ,
) ;
) ;
@ -462,10 +471,7 @@ export default class DIDView extends Vue {
* @ param contact - Contact object to be deleted
* @ param contact - Contact object to be deleted
* /
* /
async deleteContact ( contact : Contact ) {
async deleteContact ( contact : Contact ) {
const platformService = PlatformServiceFactory . getInstance ( ) ;
await this . $dbExec ( "DELETE FROM contacts WHERE did = ?" , [ contact . did ] ) ;
await platformService . dbExec ( "DELETE FROM contacts WHERE did = ?" , [
contact . did ,
] ) ;
this . $notify (
this . $notify (
{
{
group : "alert" ,
group : "alert" ,
@ -523,11 +529,10 @@ export default class DIDView extends Vue {
) ;
) ;
if ( regResult . success ) {
if ( regResult . success ) {
contact . registered = true ;
contact . registered = true ;
const platformService = PlatformServiceFactory . getInstance ( ) ;
await this . $dbExec ( "UPDATE contacts SET registered = ? WHERE did = ?" , [
await platformService . dbExec (
true ,
"UPDATE contacts SET registered = ? WHERE did = ?" ,
contact . did ,
[ true , contact . did ] ,
] ) ;
) ;
this . $notify (
this . $notify (
{
{
@ -557,8 +562,11 @@ export default class DIDView extends Vue {
let userMessage = "There was an error." ;
let userMessage = "There was an error." ;
const serverError = error as AxiosError ;
const serverError = error as AxiosError ;
if ( serverError ) {
if ( serverError ) {
if ( serverError . response ? . data ? . error ? . message ) {
const errorData = serverError . response ? . data as {
userMessage = serverError . response . data . error . message ;
error ? : { message ? : string } ;
} ;
if ( errorData ? . error ? . message ) {
userMessage = errorData . error . message ;
} else if ( serverError . message ) {
} else if ( serverError . message ) {
userMessage = serverError . message ; / / I n f o f o r t h e u s e r
userMessage = serverError . message ; / / I n f o f o r t h e u s e r
} else {
} else {
@ -625,16 +633,15 @@ export default class DIDView extends Vue {
const results = await response . json ( ) ;
const results = await response . json ( ) ;
this . claims = this . claims . concat ( results . data ) ;
this . claims = this . claims . concat ( results . data ) ;
this . hitEnd = ! results . hitLimit ;
this . hitEnd = ! results . hitLimit ;
} catch ( e : unknown ) {
/ / e s l i n t - d i s a b l e - n e x t - l i n e @ t y p e s c r i p t - e s l i n t / n o - e x p l i c i t - a n y
} catch ( e : any ) {
logger . error ( "Error with feed load:" , e ) ;
logger . error ( "Error with feed load:" , e ) ;
const error = e as { userMessage ? : string } ;
this . $notify (
this . $notify (
{
{
group : "alert" ,
group : "alert" ,
type : "danger" ,
type : "danger" ,
title : "Error" ,
title : "Error" ,
text : e . userMessage || "There was a problem retrieving claims." ,
text : error . userMessage || "There was a problem retrieving claims." ,
} ,
} ,
3000 ,
3000 ,
) ;
) ;
@ -698,7 +705,8 @@ export default class DIDView extends Vue {
* @ returns Description string or empty string
* @ returns Description string or empty string
* /
* /
claimDescription ( claim : GenericVerifiableCredential ) {
claimDescription ( claim : GenericVerifiableCredential ) {
return claim . claim . name || claim . claim . description || "" ;
const claimData = claim . claim as { name ? : string ; description ? : string } ;
return claimData . name || claimData . description || "" ;
}
}
/ * *
/ * *
@ -741,17 +749,13 @@ export default class DIDView extends Vue {
visibility : boolean ,
visibility : boolean ,
showSuccessAlert : boolean ,
showSuccessAlert : boolean ,
) {
) {
const result = await setVisibilityUtil (
/ / T O D O : I m p l e m e n t p r o p e r v i s i b i l i t y s e t t i n g u s i n g m i x i n m e t h o d s
this . activeDid ,
/ / F o r n o w , j u s t u p d a t e l o c a l d a t a b a s e
this . apiServer ,
await this . $dbExec ( "UPDATE contacts SET seesMe = ? WHERE did = ?" , [
this . axios ,
db ,
contact ,
visibility ,
visibility ,
) ;
contact . did ,
if ( result . success ) {
] ) ;
/ / c o n t a c t . s e e s M e = v i s i b i l i t y ; / / w h y d o e s n ' t i t a f f e c t t h e U I f r o m h e r e ?
/ / c o n s o l e . l o g ( " S e t r e s u l t & s e e s M e " , r e s u l t , c o n t a c t . s e e s M e , c o n t a c t . d i d ) ;
if ( showSuccessAlert ) {
if ( showSuccessAlert ) {
this . $notify (
this . $notify (
{
{
@ -768,21 +772,6 @@ export default class DIDView extends Vue {
) ;
) ;
}
}
return true ;
return true ;
} else {
logger . error ( "Got strange result from setting visibility:" , result ) ;
const message =
( result . error as string ) || "Could not set visibility on the server." ;
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : "Error Setting Visibility" ,
text : message ,
} ,
5000 ,
) ;
return false ;
}
}
}
/ * *
/ * *
@ -816,11 +805,10 @@ export default class DIDView extends Vue {
const visibility = resp . data ;
const visibility = resp . data ;
contact . seesMe = visibility ;
contact . seesMe = visibility ;
/ / c o n s o l e . l o g ( " V i s i c h e c k : " , v i s i b i l i t y , c o n t a c t . s e e s M e , c o n t a c t . d i d ) ;
/ / c o n s o l e . l o g ( " V i s i c h e c k : " , v i s i b i l i t y , c o n t a c t . s e e s M e , c o n t a c t . d i d ) ;
const platformService = PlatformServiceFactory . getInstance ( ) ;
await this . $dbExec ( "UPDATE contacts SET seesMe = ? WHERE did = ?" , [
await platformService . dbExec (
visibility ,
"UPDATE contacts SET seesMe = ? WHERE did = ?" ,
contact . did ,
[ visibility , contact . did ] ,
] ) ;
) ;
this . $notify (
this . $notify (
{
{
@ -897,11 +885,10 @@ export default class DIDView extends Vue {
* @ returns Boolean indicating success
* @ returns Boolean indicating success
* /
* /
async setViewContent ( contact : Contact , visibility : boolean ) {
async setViewContent ( contact : Contact , visibility : boolean ) {
const platformService = PlatformServiceFactory . getInstance ( ) ;
await this . $dbExec ( "UPDATE contacts SET iViewContent = ? WHERE did = ?" , [
await platformService . dbExec (
visibility ,
"UPDATE contacts SET iViewContent = ? WHERE did = ?" ,
contact . did ,
[ visibility , contact . did ] ,
] ) ;
) ;
this . $notify (
this . $notify (
{
{
group : "alert" ,
group : "alert" ,