From b6b7c56157053f1b76f61908a943530dfa52761e Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 10 Jul 2023 18:03:51 +0800 Subject: [PATCH 1/4] DiscoverView searches almost done. Contact fixes ContactAmounts fix quick-nav Cleaning up ProjectView still more to do Hide advanced by default on StatisticsView project.task updated --- project.task.yaml | 8 +- src/db/index.ts | 1 - src/views/AccountViewView.vue | 243 +++++++++++++++++-------------- src/views/ContactAmountsView.vue | 49 +------ src/views/ContactsView.vue | 2 - src/views/DiscoverView.vue | 164 ++++++++++++--------- src/views/ProjectViewView.vue | 41 +++--- src/views/StatisticsView.vue | 1 - 8 files changed, 258 insertions(+), 251 deletions(-) diff --git a/project.task.yaml b/project.task.yaml index 9c5a5cf4..6a8a9545 100644 --- a/project.task.yaml +++ b/project.task.yaml @@ -1,13 +1,11 @@ tasks: -- .5 audit all console.log calls - 01 design ideas for simple gives on the Home page - 01 add list of 'give' records for a project on ProjectView UI -- 02 Discover page - display results (currently in console.log) & link, spin when searching +- 02 Discover page - add infinite search - 08 search by location, endpoint, etc assignee:trent - 01 add a location for a project via map pin (see API by clicking on "Nearby") - 01 remove all the "form" fields (or at least investigate to see if that page refresh is desired) -- .2 change "errorMessage" to "alertMessage" on ProjectViewView.vue - 08 Scan QR code to import into contacts. @@ -22,8 +20,6 @@ tasks: - refactor UI : - .5 Alerts show at the top and can be missed, eg. account data download - - .5 Fix how icons show on top of bottom bar on ContactAmounts page - - .2 Hide "Advanced" section in Account page by default - show pop-up confirming that settings & contacts have been downloaded @@ -44,7 +40,7 @@ tasks: - Discuss whether the remaining tasks are worthwhile before MVP release. - 01 fix images on project page, on discovery page -- .2 fix "Rotary" and static icon to the right on project page +- .2 fix static icon to the right on project page (Matthew: I've made "Rotary" into issuer?) - stats v1 : - 01 show numeric stats diff --git a/src/db/index.ts b/src/db/index.ts index 58bd2317..8091e5c8 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -54,7 +54,6 @@ if (localStorage.getItem("secret") == null) { localStorage.setItem("secret", secret); } -//console.log("IndexedDB Encryption Secret:", secret); encrypted(accountsDB, { secretKey: secret }); accountsDB.version(1).stores(SensitiveSchemas); diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index dfdddafe..524e5c3c 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -158,117 +158,126 @@ -

Advanced

- - - -
- - -
- Checking... -
-
- {{ limitsMessage }} -
-
- Rate Limits -

- You have done {{ limits.doneClaimsThisWeek }} claims out of - {{ limits.maxClaimsPerWeek }} for this week. Your claims counter - resets at {{ readableTime(limits.nextWeekBeginDateTime) }} -

-

- You have done {{ limits.doneRegistrationsThisMonth }} registrations - out of {{ limits.maxRegistrationsPerMonth }} for this month. Your - registrations counter resets at - {{ readableTime(limits.nextMonthBeginDateTime) }} -

-
-
- -
- Claim Server - - - - - -
+ +
+ + + +
+ +
+
+ +
Show amounts given with contacts
+ -
- Switch Identifier - - - - - - -
- -
- + Check Limits + + +
+ Checking... +
+
+ {{ limitsMessage }} +
+
+ Rate Limits +

+ You have done {{ limits.doneClaimsThisWeek }} claims out of + {{ limits.maxClaimsPerWeek }} for this week. Your claims counter + resets at {{ readableTime(limits.nextWeekBeginDateTime) }} +

+

+ You have done {{ limits.doneRegistrationsThisMonth }} registrations + out of {{ limits.maxRegistrationsPerMonth }} for this month. Your + registrations counter resets at + {{ readableTime(limits.nextMonthBeginDateTime) }} +

+
+
+ +
+ Claim Server + + + + + +
+ +
+ Switch Identifier + + + + + + +
+ +
+ +
- - - +

Given with {{ contact?.name }} @@ -134,8 +91,9 @@ import { import * as didJwt from "did-jwt"; import { AxiosError } from "axios"; import AlertMessage from "@/components/AlertMessage"; +import QuickNav from "@/components/QuickNav"; -@Component({ components: { AlertMessage } }) +@Component({ components: { AlertMessage, QuickNav } }) export default class ContactsView extends Vue { activeDid = ""; apiServer = ""; @@ -313,7 +271,6 @@ export default class ContactsView extends Vue { try { const resp = await this.axios.post(url, payload, { headers }); - //console.log("Got resp data:", resp.data); if (resp.data?.success) { record.amountConfirmed = origClaim.object?.amountOfThisGood || 1; } diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 21f352f5..666215e9 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -465,7 +465,6 @@ export default class ContactsView extends Vue { try { const resp = await this.axios.post(url, payload, { headers }); - //console.log("Got resp data:", resp.data); if (resp.data?.success?.embeddedRecordError) { this.alertTitle = "Registration Still Unknown"; let message = "There was some problem with the registration."; @@ -692,7 +691,6 @@ export default class ContactsView extends Vue { try { const resp = await this.axios.post(url, payload, { headers }); - //console.log("Got resp data:", resp.data); if (resp.data?.success?.handleId) { this.alertTitle = "Done"; this.alertMessage = "Successfully logged time to the server."; diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index 2bc861f6..14428ead 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -31,39 +31,48 @@ Nearby 20+{{ localCount }}
  • Remote 13{{ remoteCount }}
  • + +
    + +
    + -

    -
    - {{ errorMessage }} -
    -

    {{ name }}

    - Rotary + + {{ issuer }} {{ timeSince }} @@ -187,11 +186,11 @@ export default class ProjectViewView extends Vue { allContacts: Array = []; apiServer = ""; description = ""; - errorMessage = ""; expanded = false; givesToThis: Array = []; givesByThis: Array = []; name = ""; + issuer = ""; numAccounts = 0; projectId = localStorage.getItem("projectId") || ""; // handle ID timeSince = ""; @@ -280,30 +279,29 @@ export default class ProjectViewView extends Vue { try { const resp = await this.axios.get(url, { headers }); if (resp.status === 200) { - // feel free to remove this; I haven't yet because it's helpful - console.log('Loaded project: ', resp.data); const startTime = resp.data.startTime; if (startTime != null) { const eventDate = new Date(startTime); const now = moment.now(); this.timeSince = moment.utc(now).to(eventDate); } + this.issuer = resp.data.issuer; this.name = resp.data.claim?.name || "(no name)"; this.description = resp.data.claim?.description || "(no description)"; this.truncatedDesc = this.description.slice(0, this.truncateLength); } else if (resp.status === 404) { // actually, axios throws an error so we never get here - this.errorMessage = "That project does not exist."; + this.alertMessage = "That project does not exist."; } } catch (error: unknown) { const serverError = error as AxiosError; if (serverError.response?.status === 404) { - this.errorMessage = "That project does not exist."; + this.alertMessage = "That project does not exist."; } else { - this.errorMessage = + this.alertMessage = "Something went wrong retrieving that project." + " See logs for more info."; - console.error("Error retrieving project:", error); + console.error("Error retrieving project:", serverError.message); } } @@ -316,13 +314,16 @@ export default class ProjectViewView extends Vue { if (resp.status === 200 && resp.data.data) { this.givesToThis = resp.data.data; } else { - this.errorMessage = "Failed to retrieve gives to this project."; + this.alertMessage = "Failed to retrieve gives to this project."; } } catch (error: unknown) { - console.error("Error retrieving gives to this project:", error); const serverError = error as AxiosError; - this.errorMessage = + this.alertMessage = "Something went wrong retrieving gives to this project."; + console.error( + "Error retrieving gives to this project:", + serverError.message, + ); } const givesOutUrl = @@ -334,13 +335,15 @@ export default class ProjectViewView extends Vue { if (resp.status === 200 && resp.data.data) { this.givesByThis = resp.data.data; } else { - this.errorMessage = "Failed to retrieve gives by this project."; + this.alertMessage = "Failed to retrieve gives by this project."; } } catch (error: unknown) { - console.error("Error retrieving gives by this project:", error); const serverError = error as AxiosError; - this.errorMessage = - "Something went wrong retrieving gives by project."; + this.alertMessage = "Something went wrong retrieving gives by project."; + console.error( + "Error retrieving gives by this project:", + serverError.message, + ); } } diff --git a/src/views/StatisticsView.vue b/src/views/StatisticsView.vue index ec66cf79..0dcf2f57 100644 --- a/src/views/StatisticsView.vue +++ b/src/views/StatisticsView.vue @@ -62,7 +62,6 @@ export default class StatisticsView extends Vue { mounted() { try { const container = document.querySelector("#scene-container"); - console.log(container); const newWorld = new World(container, this); newWorld.start(); this.world = newWorld; From fed23a61ee424c23df8bd4e8bbb02c39af71c39f Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 10 Jul 2023 18:20:13 +0800 Subject: [PATCH 2/4] Remove HelloWorld and do sweeping --- src/components/HelloWorld.vue | 146 ---------------------------- src/views/AccountViewView.vue | 6 +- src/views/ContactQRScanShowView.vue | 6 +- src/views/NewEditProjectView.vue | 6 +- 4 files changed, 6 insertions(+), 158 deletions(-) delete mode 100644 src/components/HelloWorld.vue diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue deleted file mode 100644 index ec7d2898..00000000 --- a/src/components/HelloWorld.vue +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 524e5c3c..2d63d4b8 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -343,6 +343,8 @@ export default class AccountViewView extends Vue { showPubCopy = false; showAdvanced = false; + alertMessage = ""; + alertTitle = ""; public async getIdentity(activeDid) { await accountsDB.open(); @@ -560,9 +562,5 @@ export default class AccountViewView extends Vue { setApiServerInput(value) { this.apiServerInput = value; } - - // This same popup code is in many files. - alertMessage = ""; - alertTitle = ""; } diff --git a/src/views/ContactQRScanShowView.vue b/src/views/ContactQRScanShowView.vue index db8715da..acef71f1 100644 --- a/src/views/ContactQRScanShowView.vue +++ b/src/views/ContactQRScanShowView.vue @@ -37,6 +37,8 @@ import QuickNav from "@/components/QuickNav"; // eslint-disable-next-line @typescript-eslint/no-var-requires const Buffer = require("buffer/").Buffer; +alertTitle = ""; +alertMessage = ""; @Component({ components: { @@ -110,9 +112,5 @@ export default class ContactQRScanShow extends Vue { this.qrValue = viewPrefix + vcJwt; } } - - // This same popup code is in many files. - alertTitle = ""; - alertMessage = ""; } diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index 94de7fc2..193899b3 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -102,6 +102,8 @@ export default class NewEditProjectView extends Vue { errorMessage = ""; accounts: AccountsSchema; numAccounts = 0; + alertTitle = ""; + alertMessage = ""; async beforeCreate() { accountsDB.open(); @@ -290,9 +292,5 @@ export default class NewEditProjectView extends Vue { public onCancelClick() { this.$router.back(); } - - // This same popup code is in many files. - alertTitle = ""; - alertMessage = ""; } From cef346e487f28bb48e82beafd8cda510f5a1faaf Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 10 Jul 2023 18:45:50 +0800 Subject: [PATCH 3/4] Move almost all interfaces to endorserServer.ts --- src/libs/endorserServer.ts | 50 ++++++++++++++++++++++++++++++++ src/views/AccountViewView.vue | 15 ---------- src/views/DiscoverView.vue | 22 -------------- src/views/NewEditProjectView.vue | 8 ----- src/views/ProjectsView.vue | 22 -------------- src/views/StatisticsView.vue | 5 ---- 6 files changed, 50 insertions(+), 72 deletions(-) diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 0a8c38cf..fb6e3005 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -197,3 +197,53 @@ export function isNumeric(str: string): boolean { export function numberOrZero(str: string): number { return isNumeric(str) ? +str : 0; } + +export interface ErrorResponse { + error?: { + message?: string; + }; +} + +export interface RateLimits { + doneClaimsThisWeek: string; + doneRegistrationsThisMonth: string; + maxClaimsPerWeek: string; + maxRegistrationsPerMonth: string; + nextMonthBeginDateTime: string; + nextWeekBeginDateTime: string; +} + +/** + * Represents data about a project + **/ +export interface ProjectData { + /** + * Name of the project + **/ + name: string; + /** + * Description of the project + **/ + description: string; + /** + * URL referencing information about the project + **/ + handleId: string; + /** + * The Identier of the project + **/ + rowid: string; +} + +export interface VerifiableCredential { + "@context": string; + "@type": string; + name: string; + description: string; + identifier?: string; +} + +export interface WorldProperties { + startTime?: string; + endTime?: string; +} diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 2d63d4b8..a60c2af7 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -303,21 +303,6 @@ import QuickNav from "@/components/QuickNav"; // eslint-disable-next-line @typescript-eslint/no-var-requires const Buffer = require("buffer/").Buffer; -interface RateLimits { - doneClaimsThisWeek: string; - doneRegistrationsThisMonth: string; - maxClaimsPerWeek: string; - maxRegistrationsPerMonth: string; - nextMonthBeginDateTime: string; - nextWeekBeginDateTime: string; -} - -interface ErrorResponse { - error?: { - message?: string; - }; -} - @Component({ components: { AlertMessage, QuickNav } }) export default class AccountViewView extends Vue { Constants = AppString; diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index 14428ead..d2fab615 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -109,28 +109,6 @@ import { accessToken } from "@/libs/crypto"; import AlertMessage from "@/components/AlertMessage"; import QuickNav from "@/components/QuickNav"; -/** - * Represents data about a project - **/ -interface ProjectData { - /** - * Name of the project - **/ - name: string; - /** - * Description of the project - **/ - description: string; - /** - * URL referencing information about the project - **/ - handleId: string; - /** - * The Identier of the project - **/ - rowid: string; -} - @Component({ components: { AlertMessage, QuickNav }, }) diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index 193899b3..3dc6633c 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -83,14 +83,6 @@ import { useAppStore } from "@/store/app"; import { IIdentifier } from "@veramo/core"; import AlertMessage from "@/components/AlertMessage"; -interface VerifiableCredential { - "@context": string; - "@type": string; - name: string; - description: string; - identifier?: string; -} - @Component({ components: { AlertMessage }, }) diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index cd4a2a26..3c5672ad 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -83,28 +83,6 @@ import InfiniteScroll from "@/components/InfiniteScroll"; import AlertMessage from "@/components/AlertMessage"; import QuickNav from "@/components/QuickNav"; -/** - * Represents data about a project - **/ -interface ProjectData { - /** - * Name of the project - **/ - name: string; - /** - * Description of the project - **/ - description: string; - /** - * URL referencing information about the project - **/ - handleId: string; - /** - * The Identier of the project - **/ - rowid: string; -} - @Component({ components: { InfiniteScroll, AlertMessage, QuickNav }, }) diff --git a/src/views/StatisticsView.vue b/src/views/StatisticsView.vue index 0dcf2f57..d9875533 100644 --- a/src/views/StatisticsView.vue +++ b/src/views/StatisticsView.vue @@ -47,11 +47,6 @@ import { World } from "@/components/World/World.js"; import AlertMessage from "@/components/AlertMessage"; import QuickNav from "@/components/QuickNav"; -interface WorldProperties { - startTime?: string; - endTime?: string; -} - @Component({ components: { AlertMessage, World, QuickNav } }) export default class StatisticsView extends Vue { world: World; From 3f13d3ea3355fc6c1ccdfd6421b66ff30a282533 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 10 Jul 2023 19:03:20 +0800 Subject: [PATCH 4/4] CLeanup header creation --- src/views/ContactAmountsView.vue | 12 ++---------- src/views/ContactsView.vue | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index 641112d0..ca01ea42 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -166,11 +166,7 @@ export default class ContactsView extends Vue { encodeURIComponent(identity.did) + "&recipientDid=" + encodeURIComponent(contact.did); - const token = await accessToken(identity); - const headers = { - "Content-Type": "application/json", - Authorization: "Bearer " + token, - }; + const headers = this.getHeaders(identity); const resp = await this.axios.get(url, { headers }); if (resp.status === 200) { result = resp.data.data; @@ -191,11 +187,7 @@ export default class ContactsView extends Vue { encodeURIComponent(contact.did) + "&recipientDid=" + encodeURIComponent(identity.did); - const token2 = await accessToken(identity); - const headers2 = { - "Content-Type": "application/json", - Authorization: "Bearer " + token2, - }; + const headers2 = await this.getHeaders(identity); const resp2 = await this.axios.get(url2, { headers: headers2 }); if (resp2.status === 200) { result = R.concat(result, resp2.data.data); diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 666215e9..57b69cf0 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -457,11 +457,7 @@ export default class ContactsView extends Vue { // Make the xhr request payload const payload = JSON.stringify({ jwtEncoded: vcJwt }); const url = this.apiServer + "/api/v2/claim"; - const token = await accessToken(identity); - const headers = { - "Content-Type": "application/json", - Authorization: "Bearer " + token, - }; + const headers = await this.getHeaders(identity); try { const resp = await this.axios.post(url, payload, { headers }); @@ -683,11 +679,7 @@ export default class ContactsView extends Vue { const payload = JSON.stringify({ jwtEncoded: vcJwt }); const url = this.apiServer + "/api/v2/claim"; - const token = await accessToken(identity); - const headers = { - "Content-Type": "application/json", - Authorization: "Bearer " + token, - }; + const headers = await this.getHeaders(identity); try { const resp = await this.axios.post(url, payload, { headers });