From 1bedbe17c04992d6d23367f93dbfd33614d74bd3 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Mon, 23 Jan 2023 22:14:46 -0700 Subject: [PATCH 1/3] feat: adjust to the new endpoints for editable plan records --- README.md | 4 +- project.yaml | 27 +++++++++++--- src/constants/app.ts | 2 +- src/views/NewEditProjectView.vue | 64 ++++++++++++++++++++------------ src/views/ProjectViewView.vue | 17 ++++----- src/views/ProjectsView.vue | 3 +- 6 files changed, 74 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 0c8c0d1..31291bc 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,9 @@ New users require registration. This can be done with a claim payload like this }; ``` -On the test server, the user starting 0x000 has rights to register others, so you can start playing one of two ways: +On the test server, User #0 has rights to register others, so you can start playing one of two ways: -- Import the keys for that test User #0 by importing this seed phrase: `seminar accuse mystery assist delay law thing deal image undo guard initial shallow wrestle list fragile borrow velvet tomorrow awake explain test offer control` +- Import the keys for that test User `did:ethr:0x000Ee5654b9742f6Fe18ea970e32b97ee2247B51` by importing this seed phrase: `seminar accuse mystery assist delay law thing deal image undo guard initial shallow wrestle list fragile borrow velvet tomorrow awake explain test offer control` - Register someone else under User #0 on the `/account` page: diff --git a/project.yaml b/project.yaml index a188687..447889d 100644 --- a/project.yaml +++ b/project.yaml @@ -1,18 +1,33 @@ -- top screens from img/screens.pdf : +- top screens from img/screens.pdf milestone:2 : + - new + - make sure to save with plan identifier if it isn't already + - edit + - make sure to save with plan identifier if it isn't already - view all : - also extract plan identifier (instead of claim ID) assignee:trent - search bar isn't highlighted & icon on right doesn't show - no tab bar across bottom - view one - change lookup to pull from new /api/ext/plan with plan identifier assignee:trent - - edit - - make sure to save with plan identifier if it isn't already - - new - - make sure to save with plan identifier if it isn't already + - image blocks: ref:https://raw.githubusercontent.com/trentlarson/lives-of-gifts/master/project.yaml#kickstarter%20for%20time -- replace user-affecting console.logs with error messages +- replace user-affecting console.logs with error messages (eg. catches) + +- contacts - commit screen - discover screen + +- backup all data + +- Next Viable Product afterward + +- Connect with phone contacts + +- Multiple identities + +- Peer DID + +- DIDComm diff --git a/src/constants/app.ts b/src/constants/app.ts index 8446a59..719735b 100644 --- a/src/constants/app.ts +++ b/src/constants/app.ts @@ -5,5 +5,5 @@ export enum AppString { APP_NAME = "Kickstart for time", VERSION = "0.1", DEFAULT_ENDORSER_API_SERVER = "https://test.endorser.ch:8000", - DEFAULT_ENDORSER_VIEW_SERVER = "https://test.endorser.ch", + //DEFAULT_ENDORSER_API_SERVER = "http://localhost:3000", } diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index 47e7188..5299823 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -17,6 +17,10 @@ +
+ {{ errorMessage }} +
+ Date: Wed, 25 Jan 2023 09:10:16 -0700 Subject: [PATCH 2/3] chore: update to match latest API for retrieving plans --- project.yaml | 7 ++++-- src/views/NewEditProjectView.vue | 20 +++++++++++++---- src/views/ProjectViewView.vue | 37 +++++++++++++++++++++++--------- src/views/ProjectsView.vue | 27 ++++++++++------------- 4 files changed, 59 insertions(+), 32 deletions(-) diff --git a/project.yaml b/project.yaml index 447889d..4a54171 100644 --- a/project.yaml +++ b/project.yaml @@ -1,12 +1,15 @@ - top screens from img/screens.pdf milestone:2 : - new - - make sure to save with plan identifier if it isn't already + - make sure to save with plan identifier if it isn't already assignee:trent + - feedback to show saving - edit - - make sure to save with plan identifier if it isn't already + - make sure to save with plan identifier if it isn't already assignee:trent + - feedback to show saved - view all : - also extract plan identifier (instead of claim ID) assignee:trent - search bar isn't highlighted & icon on right doesn't show - no tab bar across bottom + - add spinner - view one - change lookup to pull from new /api/ext/plan with plan identifier assignee:trent - image diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index 5299823..708027a 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -10,7 +10,7 @@ class="text-lg text-center px-2 py-1 absolute -left-2 -top-1" > - [New/Edit] Project + [New/Edit] Plan @@ -65,6 +65,14 @@ import * as didJwt from "did-jwt"; import { IIdentifier } from "@veramo/core"; import { useAppStore } from "@/store/app"; +interface VerifiableCredential { + "@context": string; + "@type": string; + name: string; + description: string; + identifier?: string; +} + @Options({ components: {}, }) @@ -93,8 +101,8 @@ export default class NewEditProjectView extends Vue { async LoadProject(identity: IIdentifier) { const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER; - const url = - endorserApiServer + "/api/plan/" + encodeURIComponent(this.projectId); + // eslint-disable-next-line prettier/prettier + const url = endorserApiServer + "/api/claim/byHandle/" + encodeURIComponent(this.projectId); const token = await accessToken(identity); const headers = { "Content-Type": "application/json", @@ -116,12 +124,16 @@ export default class NewEditProjectView extends Vue { private async SaveProject(identity: IIdentifier) { // Make a claim - const vcClaim = { + const vcClaim: VerifiableCredential = { "@context": "https://schema.org", "@type": "PlanAction", name: this.projectName, description: this.description, + identifier: this.projectId || undefined, }; + if (this.projectId) { + vcClaim.identifier = this.projectId; + } // Make a payload for the claim const vcPayload = { sub: "PlanAction", diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index e102202..e13031d 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -60,10 +60,14 @@ > - View Project + View Plan +
+ {{ errorMessage }} +
+
@@ -158,6 +162,7 @@ export default class ProjectViewView extends Vue { truncateLength = 40; timeSince = ""; projectId = localStorage.getItem("projectId") || ""; + errorMessage = ""; onEditClick() { localStorage.setItem("projectId", this.projectId as string); @@ -178,8 +183,8 @@ export default class ProjectViewView extends Vue { async LoadProject(identity: IIdentifier) { const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER; - const url = - endorserApiServer + "/api/plan/" + encodeURIComponent(this.projectId); + // eslint-disable-next-line prettier/prettier + const url = endorserApiServer + "/api/claim/byHandle/" + encodeURIComponent(this.projectId); const token = await accessToken(identity); const headers = { "Content-Type": "application/json", @@ -191,15 +196,27 @@ export default class ProjectViewView extends Vue { console.log(resp.status, resp.data); if (resp.status === 200) { const startTime = resp.data.startTime; - const eventDate = new Date(startTime); - const now = moment.now(); - this.timeSince = moment.utc(now).to(eventDate); - this.name = resp.data.name; - this.description = resp.data.description; + if (startTime != null) { + const eventDate = new Date(startTime); + const now = moment.now(); + this.timeSince = moment.utc(now).to(eventDate); + } + 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."; + } + } catch (error: any) { + if (error?.response?.status === 404) { + this.errorMessage = "That project does not exist."; + } else { + this.errorMessage = + "Something went wrong retrieving that project." + + " See logs for more info."; + console.log("Error retrieving project:", error); } - } catch (error) { - console.log(error); } } diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index bf5637b..96b3869 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -2,7 +2,7 @@

- My Projects + My Plans

@@ -32,10 +32,10 @@
  • @@ -68,7 +68,7 @@ import { AppString } from "@/constants/app"; components: {}, }) export default class ProjectsView extends Vue { - projects: { id: string; name: string; description: string }[] = []; + projects: { handleId: string; name: string; description: string }[] = []; onClickLoadProject(id: string) { console.log("projectId", id); @@ -82,10 +82,7 @@ export default class ProjectsView extends Vue { async LoadProjects(identity: IIdentifier) { const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER; - const url = - endorserApiServer + - "/api/claim/?claimType=PlanAction&issuer=" + - identity.did; + const url = endorserApiServer + "/api/v2/report/plansByIssuer"; const token = await accessToken(identity); const headers = { "Content-Type": "application/json", @@ -95,15 +92,13 @@ export default class ProjectsView extends Vue { try { const resp = await this.axios.get(url, { headers }); if (resp.status === 200) { - const claims = resp.data; - console.log("All claims:", claims); - for (let i = 0; i < claims.length; i++) { - const claim = claims[i].claim; + const plans = resp.data.data; + for (let i = 0; i < plans.length; i++) { + const plan = plans[i]; const data = { - id: claims[i].id, - name: claim.name, - description: claim.description, - identifier: claim.identifier, + name: plan.name, + description: plan.description, + handleId: plan.fullIri, }; this.projects.push(data); } -- 2.30.2 From 83a9dc332ca5cb9daa60e6d60abbc52caa9d478f Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Wed, 25 Jan 2023 16:32:19 -0700 Subject: [PATCH 3/3] chore: understandable debugging --- src/views/ProjectViewView.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index e13031d..323c2dc 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -193,7 +193,7 @@ export default class ProjectViewView extends Vue { try { const resp = await this.axios.get(url, { headers }); - console.log(resp.status, resp.data); + console.log("resp.status, resp.data", resp.status, resp.data); if (resp.status === 200) { const startTime = resp.data.startTime; if (startTime != null) { -- 2.30.2