|
|
@ -66,6 +66,10 @@ |
|
|
|
: "Unconfirmed" |
|
|
|
}} |
|
|
|
</button> |
|
|
|
<br /> |
|
|
|
(Only hours shown) |
|
|
|
<br /> |
|
|
|
(Only recent shown) |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
@ -140,7 +144,10 @@ |
|
|
|
<fa icon="trash-can" class="fa-fw" /> |
|
|
|
</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 |
|
|
|
class="text-sm bg-blue-600 text-white px-2 py-1.5 rounded-l-md" |
|
|
|
@click="onClickAddGive(activeDid, contact.did)" |
|
|
@ -300,20 +307,27 @@ export default class ContactsView extends Vue { |
|
|
|
} |
|
|
|
|
|
|
|
async loadGives() { |
|
|
|
const handleResponse = (resp, descriptions, confirmed, unconfirmed) => { |
|
|
|
const handleResponse = ( |
|
|
|
resp, |
|
|
|
descriptions, |
|
|
|
confirmed, |
|
|
|
unconfirmed, |
|
|
|
useRecipient, |
|
|
|
) => { |
|
|
|
if (resp.status === 200) { |
|
|
|
const allData = resp.data.data; |
|
|
|
for (const give of allData) { |
|
|
|
const otherDid = useRecipient ? give.recipientDid : give.agentDid; |
|
|
|
if (give.unit === "HUR") { |
|
|
|
if (give.amountConfirmed) { |
|
|
|
const prevAmount = confirmed[give.agentDid] || 0; |
|
|
|
confirmed[give.agentDid] = prevAmount + give.amount; |
|
|
|
const prevAmount = confirmed[otherDid] || 0; |
|
|
|
confirmed[otherDid] = prevAmount + give.amount; |
|
|
|
} else { |
|
|
|
const prevAmount = unconfirmed[give.agentDid] || 0; |
|
|
|
unconfirmed[give.agentDid] = prevAmount + give.amount; |
|
|
|
const prevAmount = unconfirmed[otherDid] || 0; |
|
|
|
unconfirmed[otherDid] = prevAmount + give.amount; |
|
|
|
} |
|
|
|
if (!descriptions[give.agentDid] && give.description) { |
|
|
|
descriptions[give.agentDid] = give.description; |
|
|
|
if (!descriptions[otherDid] && give.description) { |
|
|
|
descriptions[otherDid] = give.description; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -323,27 +337,32 @@ export default class ContactsView extends Vue { |
|
|
|
resp.status, |
|
|
|
resp.data, |
|
|
|
); |
|
|
|
this.alertTitle = "Error With Server"; |
|
|
|
this.alertMessage = |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error With Server", |
|
|
|
text: |
|
|
|
"Got an error retrieving your " + |
|
|
|
resp.config.url.includes("recipientDid") |
|
|
|
? "received" |
|
|
|
: "given" + " time from the server."; |
|
|
|
: "given" + " time from the server.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
try { |
|
|
|
const { headers, identity } = await this.getHeadersAndIdentity( |
|
|
|
this.activeDid, |
|
|
|
); |
|
|
|
const { headers } = await this.getHeadersAndIdentity(this.activeDid); |
|
|
|
const givenByUrl = |
|
|
|
this.apiServer + |
|
|
|
"/api/v2/report/gives?agentDid=" + |
|
|
|
encodeURIComponent(identity.did); |
|
|
|
encodeURIComponent(this.activeDid); |
|
|
|
const givenToUrl = |
|
|
|
this.apiServer + |
|
|
|
"/api/v2/report/gives?recipientDid=" + |
|
|
|
encodeURIComponent(identity.did); |
|
|
|
encodeURIComponent(this.activeDid); |
|
|
|
|
|
|
|
const [givenByMeResp, givenToMeResp] = await Promise.all([ |
|
|
|
this.axios.get(givenByUrl, { headers }), |
|
|
@ -358,6 +377,7 @@ export default class ContactsView extends Vue { |
|
|
|
givenByMeDescriptions, |
|
|
|
givenByMeConfirmed, |
|
|
|
givenByMeUnconfirmed, |
|
|
|
true, |
|
|
|
); |
|
|
|
this.givenByMeDescriptions = givenByMeDescriptions; |
|
|
|
this.givenByMeConfirmed = givenByMeConfirmed; |
|
|
@ -371,13 +391,21 @@ export default class ContactsView extends Vue { |
|
|
|
givenToMeDescriptions, |
|
|
|
givenToMeConfirmed, |
|
|
|
givenToMeUnconfirmed, |
|
|
|
false, |
|
|
|
); |
|
|
|
this.givenToMeDescriptions = givenToMeDescriptions; |
|
|
|
this.givenToMeConfirmed = givenToMeConfirmed; |
|
|
|
this.givenToMeUnconfirmed = givenToMeUnconfirmed; |
|
|
|
} catch (error) { |
|
|
|
this.alertTitle = "Error With Server"; |
|
|
|
this.alertMessage = error as string; |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error With Server", |
|
|
|
text: error as string, |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -470,18 +498,32 @@ export default class ContactsView extends Vue { |
|
|
|
try { |
|
|
|
const resp = await this.axios.post(url, payload, { headers }); |
|
|
|
if (resp.data?.success?.embeddedRecordError) { |
|
|
|
this.alertTitle = "Registration Still Unknown"; |
|
|
|
let message = "There was some problem with the registration."; |
|
|
|
if (typeof resp.data.success.embeddedRecordError == "string") { |
|
|
|
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) { |
|
|
|
contact.registered = true; |
|
|
|
db.contacts.update(contact.did, { registered: true }); |
|
|
|
|
|
|
|
this.alertTitle = "Registration Success"; |
|
|
|
this.alertMessage = contact.name + " has been registered."; |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "info", |
|
|
|
title: "Registration Success", |
|
|
|
text: contact.name + " has been registered.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
let userMessage = "There was an error. See logs for more info."; |
|
|
@ -496,8 +538,15 @@ export default class ContactsView extends Vue { |
|
|
|
userMessage = error as string; |
|
|
|
} |
|
|
|
// Now set that error for the user to see. |
|
|
|
this.alertTitle = "Error With Server"; |
|
|
|
this.alertMessage = userMessage; |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error With Server", |
|
|
|
text: userMessage, |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -518,17 +567,39 @@ export default class ContactsView extends Vue { |
|
|
|
contact.seesMe = visibility; |
|
|
|
db.contacts.update(contact.did, { seesMe: visibility }); |
|
|
|
} else { |
|
|
|
this.alertTitle = "Error With Server"; |
|
|
|
console.error("Bad response setting visibility: ", resp.data); |
|
|
|
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 { |
|
|
|
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) { |
|
|
|
this.alertTitle = "Error With Server"; |
|
|
|
this.alertMessage = err as string; |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error With Server", |
|
|
|
text: err as string, |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -545,23 +616,52 @@ export default class ContactsView extends Vue { |
|
|
|
contact.seesMe = visibility; |
|
|
|
db.contacts.update(contact.did, { seesMe: visibility }); |
|
|
|
|
|
|
|
this.alertTitle = "Refreshed"; |
|
|
|
this.alertMessage = |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "toast", |
|
|
|
title: "Refreshed", |
|
|
|
text: |
|
|
|
this.nameForContact(contact, true) + |
|
|
|
" can " + |
|
|
|
(visibility ? "" : "not ") + |
|
|
|
"see your activity."; |
|
|
|
"see your activity.", |
|
|
|
}, |
|
|
|
5000, |
|
|
|
); |
|
|
|
} else { |
|
|
|
this.alertTitle = "Error With Server"; |
|
|
|
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 { |
|
|
|
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) { |
|
|
|
this.alertTitle = "Error With Server"; |
|
|
|
this.alertMessage = err as string; |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error With Server", |
|
|
|
text: err as string, |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -600,15 +700,35 @@ export default class ContactsView extends Vue { |
|
|
|
} |
|
|
|
} |
|
|
|
if (!this.isNumeric(this.hourInput)) { |
|
|
|
this.alertTitle = "Input Error"; |
|
|
|
this.alertMessage = |
|
|
|
"This is not a valid number of hours: " + this.hourInput; |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Input Error", |
|
|
|
text: "This is not a valid number of hours: " + this.hourInput, |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} else if (!parseFloat(this.hourInput)) { |
|
|
|
this.alertTitle = "Input Error"; |
|
|
|
this.alertMessage = "Giving 0 hours does nothing."; |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Input Error", |
|
|
|
text: "Giving 0 hours does nothing.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} else if (!identity) { |
|
|
|
this.alertTitle = "Status Error"; |
|
|
|
this.alertMessage = "No identity is available."; |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Status Error", |
|
|
|
text: "No identity is available.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} else { |
|
|
|
// ask to confirm amount |
|
|
|
let toFrom; |
|
|
@ -692,8 +812,15 @@ export default class ContactsView extends Vue { |
|
|
|
try { |
|
|
|
const resp = await this.axios.post(url, payload, { headers }); |
|
|
|
if (resp.data?.success?.handleId) { |
|
|
|
this.alertTitle = "Done"; |
|
|
|
this.alertMessage = "Successfully logged time to the server."; |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "success", |
|
|
|
title: "Done", |
|
|
|
text: "Successfully logged time to the server.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
|
|
|
|
if (fromDid === identity.did) { |
|
|
|
const newList = R.clone(this.givenByMeUnconfirmed); |
|
|
@ -718,8 +845,15 @@ export default class ContactsView extends Vue { |
|
|
|
userMessage = error as string; |
|
|
|
} |
|
|
|
// Now set that error for the user to see. |
|
|
|
this.alertTitle = "Error With Server"; |
|
|
|
this.alertMessage = userMessage; |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error With Server", |
|
|
|
text: userMessage, |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|