diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 60ca56c..77b7975 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -46,7 +46,7 @@

- My Contacts + Your Contacts

@@ -137,20 +137,30 @@
- to: {{ givenByMeTotals[contact.did] || 0 }} - - by: {{ givenToMeTotals[contact.did] || 0 }} - +
+ to: {{ givenByMeTotals[contact.did] || 0 }} + {{ + givenByMeDescriptions[contact.did] + }} + +
+
+ by: {{ givenToMeTotals[contact.did] || 0 }} + + {{ givenByMeDescriptions[contact.did] }} + + +
@@ -187,6 +197,17 @@ const Buffer = require("buffer/").Buffer; const SERVICE_ID = "endorser.ch"; +export interface GiveServerRecord { + agentDid: string; + amount: number; + confirmed: number; + description: string; + fullClaim: GiveVerifiableCredential; + handleId: string; + recipientDid: string; + unit: string; +} + export interface GiveVerifiableCredential { "@context": string; "@type": string; @@ -210,8 +231,12 @@ export interface RegisterVerifiableCredential { export default class ContactsView extends Vue { contacts: Array = []; contactInput = ""; + // { "did:...": concatenated-descriptions } entry for each contact + givenByMeDescriptions: Record = {}; // { "did:...": amount } entry for each contact givenByMeTotals: Record = {}; + // { "did:...": concatenated-descriptions } entry for each contact + givenToMeDescriptions: Record = {}; // { "did:...": amount } entry for each contact givenToMeTotals: Record = {}; hourDescriptionInput = ""; @@ -287,17 +312,23 @@ export default class ContactsView extends Vue { Authorization: "Bearer " + token, }; const resp = await this.axios.get(url, { headers }); - //console.log("Server response", resp.status, resp.data); + console.log("All your gifts:", resp.data); if (resp.status === 200) { + const contactDescriptions: Record = {}; const contactTotals: Record = {}; - for (const give of resp.data.data) { + const allData: Array = resp.data.data; + for (const give of allData) { if (give.unit == "HUR") { const recipDid: string = give.recipientDid; const prevAmount = contactTotals[recipDid] || 0; contactTotals[recipDid] = prevAmount + give.amount; + const prevDesc = contactDescriptions[recipDid] || ""; + // Since many make the tooltip too big, we'll just use the latest; + contactDescriptions[recipDid] = give.description || prevDesc; } } //console.log("Done retrieving gives", contactTotals); + this.givenByMeDescriptions = contactDescriptions; this.givenByMeTotals = contactTotals; } } catch (error) { @@ -318,16 +349,22 @@ export default class ContactsView extends Vue { Authorization: "Bearer " + token, }; const resp = await this.axios.get(url, { headers }); - //console.log("Server response", resp.status, resp.data); + console.log("All gifts you've recieved:", resp.data); if (resp.status === 200) { + const contactDescriptions: Record = {}; const contactTotals: Record = {}; - for (const give of resp.data.data) { + const allData: Array = resp.data.data; + for (const give of allData) { if (give.unit == "HUR") { const prevAmount = contactTotals[give.agentDid] || 0; contactTotals[give.agentDid] = prevAmount + give.amount; + const prevDesc = contactDescriptions[give.agentDid] || ""; + // Since many make the tooltip too big, we'll just use the latest; + contactDescriptions[give.agentDid] = give.description || prevDesc; } } //console.log("Done retrieving receipts", contactTotals); + this.givenToMeDescriptions = contactDescriptions; this.givenToMeTotals = contactTotals; } } catch (error) { @@ -700,6 +737,7 @@ export default class ContactsView extends Vue { diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index 90490cd..13d4e1b 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -45,7 +45,7 @@

- My Plans + Your Plans