From 8ee610c1bcb65434e680e656931af50db7a013f7 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Tue, 29 Aug 2023 20:47:22 -0600 Subject: [PATCH 01/16] start the assignment of boundaries for a local search --- project.task.yaml | 1 + src/db/tables/settings.ts | 8 +++++ src/views/DiscoverView.vue | 74 ++++++++++++++++++++++++++++++++------ 3 files changed, 73 insertions(+), 10 deletions(-) diff --git a/project.task.yaml b/project.task.yaml index e2d52d7..e793ecd 100644 --- a/project.task.yaml +++ b/project.task.yaml @@ -6,6 +6,7 @@ tasks: - push, where we trigger a ServiceWorker(?) in the app to reach out and check for new data assignee:matthew - 01 add my bounding box(es) of interest for searches on Nearby part of Discovery page +- .5 fix the look-and-feel of the map on the Discovery page assignee-group:ui - .5 search by a bounding box(s) of interest for local projects (see API by clicking on "Nearby") - 01 Replace Gifted/Give in ContactsView with GiftedDialog assignee:matthew diff --git a/src/db/tables/settings.ts b/src/db/tables/settings.ts index 02f7ba7..e0eee3e 100644 --- a/src/db/tables/settings.ts +++ b/src/db/tables/settings.ts @@ -1,3 +1,10 @@ +export type BoundingBox = { + maxLat: number; + maxLong: number; + minLat: number; + minLong: number; +}; + // a singleton export type Settings = { id: number; // there's only one entry: MASTER_SETTINGS_KEY @@ -7,6 +14,7 @@ export type Settings = { firstName?: string; lastName?: string; lastViewedClaimId?: string; + searchBoxes?: Array; showContactGivesInline?: boolean; }; diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index dba8066..cdaf2f1 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -9,7 +9,7 @@ -
+
- @@ -303,15 +299,23 @@ import { db, accountsDB } from "@/db"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { accessToken } from "@/libs/crypto"; import { AxiosError } from "axios/index"; -import AlertMessage from "@/components/AlertMessage"; import QuickNav from "@/components/QuickNav"; import { IIdentifier } from "@veramo/core"; // eslint-disable-next-line @typescript-eslint/no-var-requires const Buffer = require("buffer/").Buffer; -@Component({ components: { AlertMessage, QuickNav } }) +interface Notification { + group: string; + type: string; + title: string; + text: string; +} + +@Component({ components: { QuickNav } }) export default class AccountViewView extends Vue { + $notify!: (notification: Notification, timeout?: number) => void; + Constants = AppString; activeDid = ""; diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index c3a5606..f974cd4 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -90,10 +90,6 @@ - @@ -113,17 +109,23 @@ import { } from "@/libs/endorserServer"; import * as didJwt from "did-jwt"; import { AxiosError } from "axios"; -import AlertMessage from "@/components/AlertMessage"; import QuickNav from "@/components/QuickNav"; -@Component({ components: { AlertMessage, QuickNav } }) +interface Notification { + group: string; + type: string; + title: string; + text: string; +} + +@Component({ components: { QuickNav } }) export default class ContactsView extends Vue { + $notify!: (notification: Notification, timeout?: number) => void; + activeDid = ""; apiServer = ""; contact: Contact | null = null; giveRecords: Array = []; - alertTitle = ""; - alertMessage = ""; numAccounts = 0; async beforeCreate() { diff --git a/src/views/ContactGiftingView.vue b/src/views/ContactGiftingView.vue index 0f2a5e3..f3af3ff 100644 --- a/src/views/ContactGiftingView.vue +++ b/src/views/ContactGiftingView.vue @@ -76,10 +76,6 @@ message="Received from" > - @@ -93,21 +89,27 @@ import { accessToken } from "@/libs/crypto"; import { createAndSubmitGive } from "@/libs/endorserServer"; import { Account } from "@/db/tables/accounts"; import { Contact } from "@/db/tables/contacts"; -import AlertMessage from "@/components/AlertMessage"; import QuickNav from "@/components/QuickNav"; import EntityIcon from "@/components/EntityIcon"; +interface Notification { + group: string; + type: string; + title: string; + text: string; +} + @Component({ - components: { GiftedDialog, AlertMessage, QuickNav, EntityIcon }, + components: { GiftedDialog, QuickNav, EntityIcon }, }) export default class HomeView extends Vue { + $notify!: (notification: Notification, timeout?: number) => void; + activeDid = ""; allAccounts: Array = []; allContacts: Array = []; apiServer = ""; isHiddenSpinner = true; - alertTitle = ""; - alertMessage = ""; accounts: AccountsSchema; numAccounts = 0; @@ -289,11 +291,6 @@ export default class HomeView extends Vue { } } - private setAlert(title, message) { - this.alertTitle = title; - this.alertMessage = message; - } - // Helper functions for readability isGiveCreationError(result) { diff --git a/src/views/ContactQRScanShowView.vue b/src/views/ContactQRScanShowView.vue index c932a49..cdcb9f6 100644 --- a/src/views/ContactQRScanShowView.vue +++ b/src/views/ContactQRScanShowView.vue @@ -34,6 +34,13 @@ import { Account } from "@/db/tables/accounts"; // eslint-disable-next-line @typescript-eslint/no-var-requires const Buffer = require("buffer/").Buffer; +interface Notification { + group: string; + type: string; + title: string; + text: string; +} + @Component({ components: { QRCodeVue3, @@ -41,6 +48,8 @@ const Buffer = require("buffer/").Buffer; }, }) export default class ContactQRScanShow extends Vue { + $notify!: (notification: Notification, timeout?: number) => void; + activeDid = ""; apiServer = ""; qrValue = ""; diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 740ad88..56dd757 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -202,10 +202,6 @@

This identity has no contacts.

- @@ -224,17 +220,25 @@ import { SERVICE_ID, } from "@/libs/endorserServer"; import { Component, Vue } from "vue-facing-decorator"; -import AlertMessage from "@/components/AlertMessage"; import QuickNav from "@/components/QuickNav"; import EntityIcon from "@/components/EntityIcon"; // eslint-disable-next-line @typescript-eslint/no-var-requires const Buffer = require("buffer/").Buffer; +interface Notification { + group: string; + type: string; + title: string; + text: string; +} + @Component({ - components: { AlertMessage, QuickNav, EntityIcon }, + components: { QuickNav, EntityIcon }, }) export default class ContactsView extends Vue { + $notify!: (notification: Notification, timeout?: number) => void; + activeDid = ""; apiServer = ""; contacts: Array = []; @@ -256,8 +260,6 @@ export default class ContactsView extends Vue { showGiveNumbers = false; showGiveTotals = true; showGiveConfirmed = true; - alertTitle = ""; - alertMessage = ""; async created() { await db.open(); diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index 525a926..a893ffe 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -181,8 +181,6 @@ /> - - @@ -201,7 +199,6 @@ import { Contact } from "@/db/tables/contacts"; import { BoundingBox, MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { accessToken } from "@/libs/crypto"; import { didInfo, ProjectData } from "@/libs/endorserServer"; -import AlertMessage from "@/components/AlertMessage"; import QuickNav from "@/components/QuickNav"; import InfiniteScroll from "@/components/InfiniteScroll"; import EntityIcon from "@/components/EntityIcon"; @@ -210,10 +207,16 @@ const DEFAULT_LAT_LONG_DIFF = 0.01; const WORLD_ZOOM = 2; const DEFAULT_ZOOM = 2; +interface Notification { + group: string; + type: string; + title: string; + text: string; +} + @Component({ components: { LRectangle, - AlertMessage, QuickNav, InfiniteScroll, EntityIcon, @@ -223,13 +226,13 @@ const DEFAULT_ZOOM = 2; }, }) export default class DiscoverView extends Vue { + $notify!: (notification: Notification, timeout?: number) => void; + activeDid = ""; allContacts: Array = []; allMyDids: Array = []; apiServer = ""; searchTerms = ""; - alertMessage = ""; - alertTitle = ""; projects: ProjectData[] = []; isChoosingSearchBox = false; isLocalActive = true; diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 6031e0b..4c238ba 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -196,10 +196,6 @@ - @@ -211,14 +207,22 @@ import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { accessToken } from "@/libs/crypto"; import { createAndSubmitGive, didInfo } from "@/libs/endorserServer"; import { Contact } from "@/db/tables/contacts"; -import AlertMessage from "@/components/AlertMessage"; import QuickNav from "@/components/QuickNav"; import EntityIcon from "@/components/EntityIcon"; +interface Notification { + group: string; + type: string; + title: string; + text: string; +} + @Component({ - components: { GiftedDialog, AlertMessage, QuickNav, EntityIcon }, + components: { GiftedDialog, QuickNav, EntityIcon }, }) export default class HomeView extends Vue { + $notify!: (notification: Notification, timeout?: number) => void; + activeDid = ""; allContacts: Array = []; allMyDids: Array = []; @@ -228,8 +232,6 @@ export default class HomeView extends Vue { feedPreviousOldestId = null; feedLastViewedId = null; isHiddenSpinner = true; - alertTitle = ""; - alertMessage = ""; numAccounts = 0; async beforeCreate() { @@ -509,11 +511,6 @@ export default class HomeView extends Vue { } } - private setAlert(title, message) { - this.alertTitle = title; - this.alertMessage = message; - } - // Helper functions for readability isGiveCreationError(result) { diff --git a/src/views/IdentitySwitcherView.vue b/src/views/IdentitySwitcherView.vue index 41fdfef..a21d1ac 100644 --- a/src/views/IdentitySwitcherView.vue +++ b/src/views/IdentitySwitcherView.vue @@ -62,11 +62,6 @@ > No Identity - - diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index 442704f..392cc95 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -337,6 +337,7 @@ export default class DiscoverView extends Vue { } else { throw JSON.stringify(results); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (e: any) { console.log("Error with feed load:", e); this.$notify( @@ -415,6 +416,7 @@ export default class DiscoverView extends Vue { } else { throw JSON.stringify(results); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (e: any) { console.log("Error with feed load:", e); this.$notify( diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index e7a12db..98a4d49 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -284,6 +284,7 @@ export default class HomeView extends Vue { this.allContacts = await db.contacts.toArray(); this.feedLastViewedId = settings?.lastViewedClaimId; this.updateAllFeed(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (err: any) { this.$notify( { @@ -384,12 +385,11 @@ export default class HomeView extends Vue { } giveDescription(giveRecord: GiveServerRecord) { - let claim = giveRecord.fullClaim; - if ((claim as any).claim) { - // can happen for some claims wrapped in a Verifiable Credential - claim = (claim as any).claim; - } + // claim.claim happen for some claims wrapped in a Verifiable Credential + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const claim = (giveRecord.fullClaim as any).claim || giveRecord.fullClaim; // agent.did is for legacy data, before March 2023 + // eslint-disable-next-line @typescript-eslint/no-explicit-any const giverDid = claim.agent?.identifier || (claim.agent as any)?.did; const giverInfo = didInfo( giverDid, @@ -402,6 +402,7 @@ export default class HomeView extends Vue { : claim.description || "something unknown"; // recipient.did is for legacy data, before March 2023 const gaveRecipientId = + // eslint-disable-next-line @typescript-eslint/no-explicit-any claim.recipient?.identifier || (claim.recipient as any)?.did; const gaveRecipientInfo = gaveRecipientId ? " to " + @@ -515,16 +516,19 @@ export default class HomeView extends Vue { -1, ); } - } catch (error) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } catch (error: any) { console.log("Error with give caught:", error); + const message = + error.userMessage || + error.response?.data?.error?.message || + "There was an error recording the give."; this.$notify( { group: "alert", type: "danger", title: "Error", - text: - this.getGiveErrorMessage(error) || - "There was an error recording the give.", + text: message, }, -1, ); @@ -533,16 +537,14 @@ export default class HomeView extends Vue { // Helper functions for readability + // eslint-disable-next-line @typescript-eslint/no-explicit-any isGiveCreationError(result: any) { return result.status !== 201 || result.data?.error; } + // eslint-disable-next-line @typescript-eslint/no-explicit-any getGiveCreationErrorMessage(result: any) { return result.data?.error?.message; } - - getGiveErrorMessage(error: any) { - return error.userMessage || error.response?.data?.error?.message; - } } diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index 7ccbcf4..48bcd0f 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -112,6 +112,7 @@ import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { accessToken, SimpleSigner } from "@/libs/crypto"; import { useAppStore } from "@/store/app"; import { IIdentifier } from "@veramo/core"; +import { PlanVerifiableCredential } from "@/libs/endorserServer"; interface Notification { group: string; @@ -217,7 +218,7 @@ export default class NewEditProjectView extends Vue { private async SaveProject(identity: IIdentifier) { // Make a claim - const vcClaim: any = { + const vcClaim: PlanVerifiableCredential = { "@context": "https://schema.org", "@type": "PlanAction", name: this.projectName, diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index 76f8ea0..8c6b679 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -220,6 +220,7 @@ import { GiverInputInfo, GiverOutputInfo, GiveServerRecord, + ResultWithType, } from "@/libs/endorserServer"; import QuickNav from "@/components/QuickNav.vue"; import EntityIcon from "@/components/EntityIcon.vue"; @@ -547,22 +548,26 @@ export default class ProjectViewView extends Vue { }, -1, ); - } else if (result.type == "error") { - console.log("Error with give result:", result); - if ("data" in result) { - const data: any = result.data; - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: - data?.error?.message || - "There was an error recording the give.", - }, - -1, + } else { + console.log("Error with give creation:", result); + if (result.type != "error") { + console.log( + "... and it has an unexpected result type of", + (result as ResultWithType).type, ); } + const message = + result?.error?.userMessage || + "There was an error recording the Give."; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: message, + }, + -1, + ); } } } diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index 5051b3e..d54b94d 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -129,16 +129,26 @@ export default class ProjectsView extends Vue { } } else { console.log("Bad server response & data:", resp.status, resp.data); - throw Error("Failed to get projects from the server."); + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: "Failed to get projects from the server. Try again later.", + }, + -1, + ); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { console.error("Got error loading projects:", error.message); + const additional = error.message ? " " + error.message : ""; this.$notify( { group: "alert", type: "danger", title: "Error", - text: "Got an error loading projects: " + error.message, + text: "Got an error loading projects." + additional, }, -1, ); From 52a6451a2ddc349a0918a9329049f6e4cb1193cd Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Mon, 4 Sep 2023 15:37:39 -0600 Subject: [PATCH 14/16] remove technical details from user-facing messages --- src/views/DiscoverView.vue | 6 ++++-- src/views/ProjectsView.vue | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index 392cc95..689fd28 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -312,12 +312,13 @@ export default class DiscoverView extends Vue { if (response.status !== 200) { const details = await response.text(); + console.log("Problem with full search:", details); this.$notify( { group: "alert", type: "danger", title: "Error", - text: `There was a problem accessing the server. Please try again later. (${details})`, + text: `There was a problem accessing the server. Try again later.`, }, -1, ); @@ -386,12 +387,13 @@ export default class DiscoverView extends Vue { if (response.status !== 200) { const details = await response.text(); + console.log("Problem with nearby search:", details); this.$notify( { group: "alert", type: "danger", title: "Error", - text: `There was a problem accessing the server. Please try again later. (${details})`, + text: "There was a problem accessing the server. Try again later.", }, -1, ); diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index d54b94d..1d87548 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -141,14 +141,13 @@ export default class ProjectsView extends Vue { } // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { - console.error("Got error loading projects:", error.message); - const additional = error.message ? " " + error.message : ""; + console.error("Got error loading projects:", error.message || error); this.$notify( { group: "alert", type: "danger", title: "Error", - text: "Got an error loading projects." + additional, + text: "Got an error loading projects.", }, -1, ); From 6a8b9d36a7d64a9cd363ab44e0dd8fb666f11c1c Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Mon, 4 Sep 2023 19:03:45 -0600 Subject: [PATCH 15/16] move limit checks out of "advanced" section, and always allow registration (for tests) --- src/views/AccountViewView.vue | 57 +++++++++++++++++------------------ src/views/ContactsView.vue | 23 ++++++++------ 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index f46b846..c17be54 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -170,6 +170,33 @@ +
+ + +
+ 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) }} +

+
+
+

Show amounts given with contacts -
- - -
- 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) }} -

-
-
-
-