|
@ -66,18 +66,27 @@ |
|
|
: "Unconfirmed" |
|
|
: "Unconfirmed" |
|
|
}} |
|
|
}} |
|
|
</button> |
|
|
</button> |
|
|
|
|
|
<br /> |
|
|
|
|
|
(Only hours shown) |
|
|
|
|
|
<br /> |
|
|
|
|
|
(Only recent shown) |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<!-- Results List --> |
|
|
<!-- Results List --> |
|
|
<ul v-if="contacts.length > 0" class="border-t border-slate-300"> |
|
|
<ul v-if="contacts.length > 0" class="border-t border-slate-300"> |
|
|
<li |
|
|
<li |
|
|
class="border-b border-slate-300 py-4" |
|
|
class="border-b border-slate-300 pt-2.5 pb-4" |
|
|
v-for="contact in contacts" |
|
|
v-for="contact in contacts" |
|
|
:key="contact.did" |
|
|
:key="contact.did" |
|
|
> |
|
|
> |
|
|
<div class="grow overflow-hidden"> |
|
|
<div class="grow overflow-hidden"> |
|
|
<h2 class="text-base font-semibold"> |
|
|
<h2 class="text-base font-semibold"> |
|
|
|
|
|
<EntityIcon |
|
|
|
|
|
:entityId="contact.did" |
|
|
|
|
|
:iconSize="24" |
|
|
|
|
|
class="inline-block align-text-bottom border border-slate-300 rounded" |
|
|
|
|
|
></EntityIcon> |
|
|
{{ contact.name || "(no name)" }} |
|
|
{{ contact.name || "(no name)" }} |
|
|
</h2> |
|
|
</h2> |
|
|
<div class="text-sm truncate">{{ contact.did }}</div> |
|
|
<div class="text-sm truncate">{{ contact.did }}</div> |
|
@ -135,9 +144,12 @@ |
|
|
<fa icon="trash-can" class="fa-fw" /> |
|
|
<fa icon="trash-can" class="fa-fw" /> |
|
|
</button> |
|
|
</button> |
|
|
|
|
|
|
|
|
<div v-if="!showGiveNumbers" class="ml-auto flex gap-1.5"> |
|
|
<div |
|
|
|
|
|
v-if="showGiveNumbers && contact.did != activeDid" |
|
|
|
|
|
class="ml-auto flex gap-1.5" |
|
|
|
|
|
> |
|
|
<button |
|
|
<button |
|
|
class="text-sm uppercase bg-blue-600 text-white px-2 py-1.5 rounded-md" |
|
|
class="text-sm bg-blue-600 text-white px-2 py-1.5 rounded-l-md" |
|
|
@click="onClickAddGive(activeDid, contact.did)" |
|
|
@click="onClickAddGive(activeDid, contact.did)" |
|
|
title="givenByMeDescriptions[contact.did]" |
|
|
title="givenByMeDescriptions[contact.did]" |
|
|
> |
|
|
> |
|
@ -152,11 +164,11 @@ |
|
|
: (givenByMeUnconfirmed[contact.did] || 0) |
|
|
: (givenByMeUnconfirmed[contact.did] || 0) |
|
|
/* eslint-enable prettier/prettier */ |
|
|
/* eslint-enable prettier/prettier */ |
|
|
}} |
|
|
}} |
|
|
<fa icon="plus" class="fa-fw" /> |
|
|
<fa icon="plus" /> |
|
|
</button> |
|
|
</button> |
|
|
|
|
|
|
|
|
<button |
|
|
<button |
|
|
class="text-sm uppercase bg-blue-600 text-white px-2 py-1.5 rounded-md" |
|
|
class="text-sm bg-blue-600 text-white px-2 py-1.5 rounded-r-md -ml-1.5 border-l border-blue-400" |
|
|
@click="onClickAddGive(contact.did, activeDid)" |
|
|
@click="onClickAddGive(contact.did, activeDid)" |
|
|
title="givenToMeDescriptions[contact.did]" |
|
|
title="givenToMeDescriptions[contact.did]" |
|
|
> |
|
|
> |
|
@ -171,7 +183,7 @@ |
|
|
: (givenToMeUnconfirmed[contact.did] || 0) |
|
|
: (givenToMeUnconfirmed[contact.did] || 0) |
|
|
/* eslint-enable prettier/prettier */ |
|
|
/* eslint-enable prettier/prettier */ |
|
|
}} |
|
|
}} |
|
|
<fa icon="plus" class="fa-fw" /> |
|
|
<fa icon="plus" /> |
|
|
</button> |
|
|
</button> |
|
|
|
|
|
|
|
|
<router-link |
|
|
<router-link |
|
@ -214,12 +226,13 @@ import { |
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
import AlertMessage from "@/components/AlertMessage"; |
|
|
import AlertMessage from "@/components/AlertMessage"; |
|
|
import QuickNav from "@/components/QuickNav"; |
|
|
import QuickNav from "@/components/QuickNav"; |
|
|
|
|
|
import EntityIcon from "@/components/EntityIcon"; |
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires |
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires |
|
|
const Buffer = require("buffer/").Buffer; |
|
|
const Buffer = require("buffer/").Buffer; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
components: { AlertMessage, QuickNav }, |
|
|
components: { AlertMessage, QuickNav, EntityIcon }, |
|
|
}) |
|
|
}) |
|
|
export default class ContactsView extends Vue { |
|
|
export default class ContactsView extends Vue { |
|
|
activeDid = ""; |
|
|
activeDid = ""; |
|
@ -294,20 +307,27 @@ export default class ContactsView extends Vue { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async loadGives() { |
|
|
async loadGives() { |
|
|
const handleResponse = (resp, descriptions, confirmed, unconfirmed) => { |
|
|
const handleResponse = ( |
|
|
|
|
|
resp, |
|
|
|
|
|
descriptions, |
|
|
|
|
|
confirmed, |
|
|
|
|
|
unconfirmed, |
|
|
|
|
|
useRecipient, |
|
|
|
|
|
) => { |
|
|
if (resp.status === 200) { |
|
|
if (resp.status === 200) { |
|
|
const allData = resp.data.data; |
|
|
const allData = resp.data.data; |
|
|
for (const give of allData) { |
|
|
for (const give of allData) { |
|
|
|
|
|
const otherDid = useRecipient ? give.recipientDid : give.agentDid; |
|
|
if (give.unit === "HUR") { |
|
|
if (give.unit === "HUR") { |
|
|
if (give.amountConfirmed) { |
|
|
if (give.amountConfirmed) { |
|
|
const prevAmount = confirmed[give.agentDid] || 0; |
|
|
const prevAmount = confirmed[otherDid] || 0; |
|
|
confirmed[give.agentDid] = prevAmount + give.amount; |
|
|
confirmed[otherDid] = prevAmount + give.amount; |
|
|
} else { |
|
|
} else { |
|
|
const prevAmount = unconfirmed[give.agentDid] || 0; |
|
|
const prevAmount = unconfirmed[otherDid] || 0; |
|
|
unconfirmed[give.agentDid] = prevAmount + give.amount; |
|
|
unconfirmed[otherDid] = prevAmount + give.amount; |
|
|
} |
|
|
} |
|
|
if (!descriptions[give.agentDid] && give.description) { |
|
|
if (!descriptions[otherDid] && give.description) { |
|
|
descriptions[give.agentDid] = give.description; |
|
|
descriptions[otherDid] = give.description; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -317,27 +337,32 @@ export default class ContactsView extends Vue { |
|
|
resp.status, |
|
|
resp.status, |
|
|
resp.data, |
|
|
resp.data, |
|
|
); |
|
|
); |
|
|
this.alertTitle = "Error With Server"; |
|
|
this.$notify( |
|
|
this.alertMessage = |
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Error With Server", |
|
|
|
|
|
text: |
|
|
"Got an error retrieving your " + |
|
|
"Got an error retrieving your " + |
|
|
resp.config.url.includes("recipientDid") |
|
|
resp.config.url.includes("recipientDid") |
|
|
? "received" |
|
|
? "received" |
|
|
: "given" + " time from the server."; |
|
|
: "given" + " time from the server.", |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
const { headers, identity } = await this.getHeadersAndIdentity( |
|
|
const { headers } = await this.getHeadersAndIdentity(this.activeDid); |
|
|
this.activeDid, |
|
|
|
|
|
); |
|
|
|
|
|
const givenByUrl = |
|
|
const givenByUrl = |
|
|
this.apiServer + |
|
|
this.apiServer + |
|
|
"/api/v2/report/gives?agentDid=" + |
|
|
"/api/v2/report/gives?agentDid=" + |
|
|
encodeURIComponent(identity.did); |
|
|
encodeURIComponent(this.activeDid); |
|
|
const givenToUrl = |
|
|
const givenToUrl = |
|
|
this.apiServer + |
|
|
this.apiServer + |
|
|
"/api/v2/report/gives?recipientDid=" + |
|
|
"/api/v2/report/gives?recipientDid=" + |
|
|
encodeURIComponent(identity.did); |
|
|
encodeURIComponent(this.activeDid); |
|
|
|
|
|
|
|
|
const [givenByMeResp, givenToMeResp] = await Promise.all([ |
|
|
const [givenByMeResp, givenToMeResp] = await Promise.all([ |
|
|
this.axios.get(givenByUrl, { headers }), |
|
|
this.axios.get(givenByUrl, { headers }), |
|
@ -352,6 +377,7 @@ export default class ContactsView extends Vue { |
|
|
givenByMeDescriptions, |
|
|
givenByMeDescriptions, |
|
|
givenByMeConfirmed, |
|
|
givenByMeConfirmed, |
|
|
givenByMeUnconfirmed, |
|
|
givenByMeUnconfirmed, |
|
|
|
|
|
true, |
|
|
); |
|
|
); |
|
|
this.givenByMeDescriptions = givenByMeDescriptions; |
|
|
this.givenByMeDescriptions = givenByMeDescriptions; |
|
|
this.givenByMeConfirmed = givenByMeConfirmed; |
|
|
this.givenByMeConfirmed = givenByMeConfirmed; |
|
@ -365,13 +391,21 @@ export default class ContactsView extends Vue { |
|
|
givenToMeDescriptions, |
|
|
givenToMeDescriptions, |
|
|
givenToMeConfirmed, |
|
|
givenToMeConfirmed, |
|
|
givenToMeUnconfirmed, |
|
|
givenToMeUnconfirmed, |
|
|
|
|
|
false, |
|
|
); |
|
|
); |
|
|
this.givenToMeDescriptions = givenToMeDescriptions; |
|
|
this.givenToMeDescriptions = givenToMeDescriptions; |
|
|
this.givenToMeConfirmed = givenToMeConfirmed; |
|
|
this.givenToMeConfirmed = givenToMeConfirmed; |
|
|
this.givenToMeUnconfirmed = givenToMeUnconfirmed; |
|
|
this.givenToMeUnconfirmed = givenToMeUnconfirmed; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
this.alertTitle = "Error With Server"; |
|
|
this.$notify( |
|
|
this.alertMessage = error as string; |
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Error With Server", |
|
|
|
|
|
text: error as string, |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -464,18 +498,32 @@ export default class ContactsView extends Vue { |
|
|
try { |
|
|
try { |
|
|
const resp = await this.axios.post(url, payload, { headers }); |
|
|
const resp = await this.axios.post(url, payload, { headers }); |
|
|
if (resp.data?.success?.embeddedRecordError) { |
|
|
if (resp.data?.success?.embeddedRecordError) { |
|
|
this.alertTitle = "Registration Still Unknown"; |
|
|
|
|
|
let message = "There was some problem with the registration."; |
|
|
let message = "There was some problem with the registration."; |
|
|
if (typeof resp.data.success.embeddedRecordError == "string") { |
|
|
if (typeof resp.data.success.embeddedRecordError == "string") { |
|
|
message += " " + resp.data.success.embeddedRecordError; |
|
|
message += " " + resp.data.success.embeddedRecordError; |
|
|
} |
|
|
} |
|
|
this.alertMessage = message; |
|
|
this.$notify( |
|
|
|
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Registration Still Unknown", |
|
|
|
|
|
text: message, |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} else if (resp.data?.success?.handleId) { |
|
|
} else if (resp.data?.success?.handleId) { |
|
|
contact.registered = true; |
|
|
contact.registered = true; |
|
|
db.contacts.update(contact.did, { registered: true }); |
|
|
db.contacts.update(contact.did, { registered: true }); |
|
|
|
|
|
|
|
|
this.alertTitle = "Registration Success"; |
|
|
this.$notify( |
|
|
this.alertMessage = contact.name + " has been registered."; |
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "info", |
|
|
|
|
|
title: "Registration Success", |
|
|
|
|
|
text: contact.name + " has been registered.", |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
let userMessage = "There was an error. See logs for more info."; |
|
|
let userMessage = "There was an error. See logs for more info."; |
|
@ -490,8 +538,15 @@ export default class ContactsView extends Vue { |
|
|
userMessage = error as string; |
|
|
userMessage = error as string; |
|
|
} |
|
|
} |
|
|
// Now set that error for the user to see. |
|
|
// Now set that error for the user to see. |
|
|
this.alertTitle = "Error With Server"; |
|
|
this.$notify( |
|
|
this.alertMessage = userMessage; |
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Error With Server", |
|
|
|
|
|
text: userMessage, |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -512,17 +567,39 @@ export default class ContactsView extends Vue { |
|
|
contact.seesMe = visibility; |
|
|
contact.seesMe = visibility; |
|
|
db.contacts.update(contact.did, { seesMe: visibility }); |
|
|
db.contacts.update(contact.did, { seesMe: visibility }); |
|
|
} else { |
|
|
} else { |
|
|
this.alertTitle = "Error With Server"; |
|
|
|
|
|
console.error("Bad response setting visibility: ", resp.data); |
|
|
console.error("Bad response setting visibility: ", resp.data); |
|
|
if (resp.data.error?.message) { |
|
|
if (resp.data.error?.message) { |
|
|
this.alertMessage = resp.data.error?.message; |
|
|
this.$notify( |
|
|
|
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Error With Server", |
|
|
|
|
|
text: resp.data.error?.message, |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
this.alertMessage = "Bad server response of " + resp.status; |
|
|
this.$notify( |
|
|
|
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Error With Server", |
|
|
|
|
|
text: "Bad server response of " + resp.status, |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
this.alertTitle = "Error With Server"; |
|
|
this.$notify( |
|
|
this.alertMessage = err as string; |
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Error With Server", |
|
|
|
|
|
text: err as string, |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -539,23 +616,52 @@ export default class ContactsView extends Vue { |
|
|
contact.seesMe = visibility; |
|
|
contact.seesMe = visibility; |
|
|
db.contacts.update(contact.did, { seesMe: visibility }); |
|
|
db.contacts.update(contact.did, { seesMe: visibility }); |
|
|
|
|
|
|
|
|
this.alertTitle = "Refreshed"; |
|
|
this.$notify( |
|
|
this.alertMessage = |
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "toast", |
|
|
|
|
|
title: "Refreshed", |
|
|
|
|
|
text: |
|
|
this.nameForContact(contact, true) + |
|
|
this.nameForContact(contact, true) + |
|
|
" can " + |
|
|
" can " + |
|
|
(visibility ? "" : "not ") + |
|
|
(visibility ? "" : "not ") + |
|
|
"see your activity."; |
|
|
"see your activity.", |
|
|
|
|
|
}, |
|
|
|
|
|
5000, |
|
|
|
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
this.alertTitle = "Error With Server"; |
|
|
|
|
|
if (resp.data.error?.message) { |
|
|
if (resp.data.error?.message) { |
|
|
this.alertMessage = resp.data.error?.message; |
|
|
this.$notify( |
|
|
|
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Error With Server", |
|
|
|
|
|
text: resp.data.error?.message, |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
this.alertMessage = "Bad server response of " + resp.status; |
|
|
this.$notify( |
|
|
|
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Error With Server", |
|
|
|
|
|
text: "Bad server response of " + resp.status, |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
this.alertTitle = "Error With Server"; |
|
|
this.$notify( |
|
|
this.alertMessage = err as string; |
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Error With Server", |
|
|
|
|
|
text: err as string, |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -594,15 +700,35 @@ export default class ContactsView extends Vue { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (!this.isNumeric(this.hourInput)) { |
|
|
if (!this.isNumeric(this.hourInput)) { |
|
|
this.alertTitle = "Input Error"; |
|
|
this.$notify( |
|
|
this.alertMessage = |
|
|
{ |
|
|
"This is not a valid number of hours: " + this.hourInput; |
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Input Error", |
|
|
|
|
|
text: "This is not a valid number of hours: " + this.hourInput, |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} else if (!parseFloat(this.hourInput)) { |
|
|
} else if (!parseFloat(this.hourInput)) { |
|
|
this.alertTitle = "Input Error"; |
|
|
this.$notify( |
|
|
this.alertMessage = "Giving 0 hours does nothing."; |
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Input Error", |
|
|
|
|
|
text: "Giving 0 hours does nothing.", |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} else if (!identity) { |
|
|
} else if (!identity) { |
|
|
this.alertTitle = "Status Error"; |
|
|
this.$notify( |
|
|
this.alertMessage = "No identity is available."; |
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Status Error", |
|
|
|
|
|
text: "No identity is available.", |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
// ask to confirm amount |
|
|
// ask to confirm amount |
|
|
let toFrom; |
|
|
let toFrom; |
|
@ -686,8 +812,15 @@ export default class ContactsView extends Vue { |
|
|
try { |
|
|
try { |
|
|
const resp = await this.axios.post(url, payload, { headers }); |
|
|
const resp = await this.axios.post(url, payload, { headers }); |
|
|
if (resp.data?.success?.handleId) { |
|
|
if (resp.data?.success?.handleId) { |
|
|
this.alertTitle = "Done"; |
|
|
this.$notify( |
|
|
this.alertMessage = "Successfully logged time to the server."; |
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "success", |
|
|
|
|
|
title: "Done", |
|
|
|
|
|
text: "Successfully logged time to the server.", |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
if (fromDid === identity.did) { |
|
|
if (fromDid === identity.did) { |
|
|
const newList = R.clone(this.givenByMeUnconfirmed); |
|
|
const newList = R.clone(this.givenByMeUnconfirmed); |
|
@ -712,8 +845,15 @@ export default class ContactsView extends Vue { |
|
|
userMessage = error as string; |
|
|
userMessage = error as string; |
|
|
} |
|
|
} |
|
|
// Now set that error for the user to see. |
|
|
// Now set that error for the user to see. |
|
|
this.alertTitle = "Error With Server"; |
|
|
this.$notify( |
|
|
this.alertMessage = userMessage; |
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Error With Server", |
|
|
|
|
|
text: userMessage, |
|
|
|
|
|
}, |
|
|
|
|
|
-1, |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|