Browse Source

feat: adjust to the new endpoints for editable plan records

pull/7/head
Trent Larson 2 years ago
parent
commit
1bedbe17c0
  1. 4
      README.md
  2. 27
      project.yaml
  3. 2
      src/constants/app.ts
  4. 64
      src/views/NewEditProjectView.vue
  5. 17
      src/views/ProjectViewView.vue
  6. 3
      src/views/ProjectsView.vue

4
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: - Register someone else under User #0 on the `/account` page:

27
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 : - view all :
- also extract plan identifier (instead of claim ID) assignee:trent - also extract plan identifier (instead of claim ID) assignee:trent
- search bar isn't highlighted & icon on right doesn't show - search bar isn't highlighted & icon on right doesn't show
- no tab bar across bottom - no tab bar across bottom
- view one - view one
- change lookup to pull from new /api/ext/plan with plan identifier assignee:trent - change lookup to pull from new /api/ext/plan with plan identifier assignee:trent
- edit - image
- 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
blocks: ref:https://raw.githubusercontent.com/trentlarson/lives-of-gifts/master/project.yaml#kickstarter%20for%20time 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 - commit screen
- discover screen - discover screen
- backup all data
- Next Viable Product afterward
- Connect with phone contacts
- Multiple identities
- Peer DID
- DIDComm

2
src/constants/app.ts

@ -5,5 +5,5 @@ export enum AppString {
APP_NAME = "Kickstart for time", APP_NAME = "Kickstart for time",
VERSION = "0.1", VERSION = "0.1",
DEFAULT_ENDORSER_API_SERVER = "https://test.endorser.ch:8000", DEFAULT_ENDORSER_API_SERVER = "https://test.endorser.ch:8000",
DEFAULT_ENDORSER_VIEW_SERVER = "https://test.endorser.ch", //DEFAULT_ENDORSER_API_SERVER = "http://localhost:3000",
} }

64
src/views/NewEditProjectView.vue

@ -17,6 +17,10 @@
<!-- Project Details --> <!-- Project Details -->
<!-- Image - (see design model) Empty --> <!-- Image - (see design model) Empty -->
<div>
{{ errorMessage }}
</div>
<input <input
type="text" type="text"
placeholder="Project Name" placeholder="Project Name"
@ -67,10 +71,9 @@ import { useAppStore } from "@/store/app";
export default class NewEditProjectView extends Vue { export default class NewEditProjectView extends Vue {
projectName = ""; projectName = "";
description = ""; description = "";
projectId = errorMessage = "";
localStorage.getItem("projectId") === null
? "" projectId = localStorage.getItem("projectId") || "";
: localStorage.getItem("projectId");
async created() { async created() {
if (this.projectId === "") { if (this.projectId === "") {
@ -90,7 +93,8 @@ export default class NewEditProjectView extends Vue {
async LoadProject(identity: IIdentifier) { async LoadProject(identity: IIdentifier) {
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER; const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
const url = endorserApiServer + "/api/claim/" + this.projectId; const url =
endorserApiServer + "/api/plan/" + encodeURIComponent(this.projectId);
const token = await accessToken(identity); const token = await accessToken(identity);
const headers = { const headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -111,12 +115,10 @@ export default class NewEditProjectView extends Vue {
} }
private async SaveProject(identity: IIdentifier) { private async SaveProject(identity: IIdentifier) {
const address = identity.did;
// Make a claim // Make a claim
const vcClaim = { const vcClaim = {
"@context": "https://schema.org", "@context": "https://schema.org",
"@type": "PlanAction", "@type": "PlanAction",
identifier: address,
name: this.projectName, name: this.projectName,
description: this.description, description: this.description,
}; };
@ -149,7 +151,7 @@ export default class NewEditProjectView extends Vue {
const payload = JSON.stringify({ jwtEncoded: vcJwt }); const payload = JSON.stringify({ jwtEncoded: vcJwt });
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER; const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
const url = endorserApiServer + "/api/claim"; const url = endorserApiServer + "/api/v2/claim";
const token = await accessToken(identity); const token = await accessToken(identity);
const headers = { const headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -158,21 +160,37 @@ export default class NewEditProjectView extends Vue {
try { try {
const resp = await this.axios.post(url, payload, { headers }); const resp = await this.axios.post(url, payload, { headers });
useAppStore().setProjectId(resp.data); console.log("Got resp data:", resp.data);
setTimeout( if (resp.data?.success?.fullIri) {
function (that: Vue) { this.errorMessage = "";
console.log("THAT:", localStorage.getItem("projectId")); useAppStore().setProjectId(resp.data.success.fullIri);
const route = { setTimeout(
name: "project", function (that: Vue) {
}; console.log("THAT:", localStorage.getItem("projectId"));
console.log(route); const route = {
that.$router.push(route); name: "project",
}, };
2000, console.log(route);
this that.$router.push(route);
); },
} catch (error) { 2000,
console.log(error); this
);
}
} catch (error: any) {
let userMessage = "There was an error. See logs for more info.";
const serverError = error.response?.data?.error;
if (serverError) {
if (serverError.message) {
userMessage = serverError.message; // This is info for the user.
} else {
console.log("Server gave an error:", serverError);
}
} else {
console.log("Here's the full error trying to save the claim:", error);
}
// Now set that error for the user to see.
this.errorMessage = userMessage;
} }
} }
} }

17
src/views/ProjectViewView.vue

@ -157,10 +157,7 @@ export default class ProjectViewView extends Vue {
truncatedDesc = ""; truncatedDesc = "";
truncateLength = 40; truncateLength = 40;
timeSince = ""; timeSince = "";
projectId = projectId = localStorage.getItem("projectId") || "";
localStorage.getItem("projectId") === null
? ""
: localStorage.getItem("projectId");
onEditClick() { onEditClick() {
localStorage.setItem("projectId", this.projectId as string); localStorage.setItem("projectId", this.projectId as string);
@ -181,7 +178,8 @@ export default class ProjectViewView extends Vue {
async LoadProject(identity: IIdentifier) { async LoadProject(identity: IIdentifier) {
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER; const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
const url = endorserApiServer + "/api/claim/" + this.projectId; const url =
endorserApiServer + "/api/plan/" + encodeURIComponent(this.projectId);
const token = await accessToken(identity); const token = await accessToken(identity);
const headers = { const headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -192,13 +190,12 @@ export default class ProjectViewView extends Vue {
const resp = await this.axios.get(url, { headers }); const resp = await this.axios.get(url, { headers });
console.log(resp.status, resp.data); console.log(resp.status, resp.data);
if (resp.status === 200) { if (resp.status === 200) {
const claim = resp.data.claim; const startTime = resp.data.startTime;
const issuedAt = resp.data.issuedAt; const eventDate = new Date(startTime);
const eventDate = new Date(issuedAt);
const now = moment.now(); const now = moment.now();
this.timeSince = moment.utc(now).to(eventDate); this.timeSince = moment.utc(now).to(eventDate);
this.name = claim.name; this.name = resp.data.name;
this.description = claim.description; this.description = resp.data.description;
this.truncatedDesc = this.description.slice(0, this.truncateLength); this.truncatedDesc = this.description.slice(0, this.truncateLength);
} }
} catch (error) { } catch (error) {

3
src/views/ProjectsView.vue

@ -96,13 +96,14 @@ export default class ProjectsView extends Vue {
const resp = await this.axios.get(url, { headers }); const resp = await this.axios.get(url, { headers });
if (resp.status === 200) { if (resp.status === 200) {
const claims = resp.data; const claims = resp.data;
console.log("All claims:", claims);
for (let i = 0; i < claims.length; i++) { for (let i = 0; i < claims.length; i++) {
console.log(claims[i]);
const claim = claims[i].claim; const claim = claims[i].claim;
const data = { const data = {
id: claims[i].id, id: claims[i].id,
name: claim.name, name: claim.name,
description: claim.description, description: claim.description,
identifier: claim.identifier,
}; };
this.projects.push(data); this.projects.push(data);
} }

Loading…
Cancel
Save