Browse Source

Added the flow from New Project to View Project

kb/add-usage-guide
Matthew Aaron Raymer 2 years ago
parent
commit
c84e597047
  1. 2
      src/store/app.ts
  2. 10
      src/views/NewEditProjectView.vue
  3. 41
      src/views/ProjectViewView.vue

2
src/store/app.ts

@ -28,7 +28,7 @@ export const useAppStore = defineStore({
setCondition(newCondition: string) { setCondition(newCondition: string) {
localStorage.setItem("condition", newCondition); localStorage.setItem("condition", newCondition);
}, },
setProjectId(newProjectId: string) { async setProjectId(newProjectId: string) {
localStorage.setItem("projectId", newProjectId); localStorage.setItem("projectId", newProjectId);
}, },
}, },

10
src/views/NewEditProjectView.vue

@ -135,11 +135,19 @@ export default class NewEditProjectView extends Vue {
const resp = await this.axios.post(url, payload, { headers }); const resp = await this.axios.post(url, payload, { headers });
console.log(resp.status, resp.data); console.log(resp.status, resp.data);
useAppStore().setProjectId(resp.data); useAppStore().setProjectId(resp.data);
console.log("TEST", useAppStore().projectId);
setTimeout(
function (that: Vue) {
console.log("THAT:", localStorage.getItem("projectId"));
const route = { const route = {
name: "project", name: "project",
}; };
console.log(route); console.log(route);
this.$router.push(route); that.$router.push(route);
},
2000,
this
);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }

41
src/views/ProjectViewView.vue

@ -126,16 +126,47 @@
<script lang="ts"> <script lang="ts">
import { Options, Vue } from "vue-class-component"; import { Options, Vue } from "vue-class-component";
import { useAppStore } from "@/store/app"; import { accessToken } from "@/libs/crypto";
import { db } from "../db";
import { IIdentifier } from "@veramo/core";
import { AppString } from "@/constants/app";
@Options({ @Options({
components: {}, components: {},
}) })
export default class ProjectViewView extends Vue { export default class ProjectViewView extends Vue {
projectId = ""; projectId =
created(): void { localStorage.getItem("projectId") === null
this.projectId = useAppStore().projectId; ? ""
console.log(this.projectId); : localStorage.getItem("projectId");
async LoadProject(identity: IIdentifier) {
console.log("LoadProject", this.projectId);
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
const url = endorserApiServer + "/api/claim/" + this.projectId;
const token = await accessToken(identity);
const headers = {
"Content-Type": "application/json",
Authorization: "Bearer " + token,
};
try {
const resp = await this.axios.get(url, { headers });
console.log(resp.status, resp.data);
} catch (error) {
console.log(error);
}
}
async created() {
await db.open();
const num_accounts = await db.accounts.count();
if (num_accounts === 0) {
console.log("Problem! Should have a profile!");
} else {
const accounts = await db.accounts.toArray();
const identity = JSON.parse(accounts[0].identity);
this.LoadProject(identity);
}
} }
} }
</script> </script>

Loading…
Cancel
Save