Add flow from project list to view
This commit is contained in:
@@ -116,9 +116,7 @@ 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 });
|
||||||
console.log(resp.status, resp.data);
|
|
||||||
useAppStore().setProjectId(resp.data);
|
useAppStore().setProjectId(resp.data);
|
||||||
console.log("TEST", useAppStore().projectId);
|
|
||||||
setTimeout(
|
setTimeout(
|
||||||
function (that: Vue) {
|
function (that: Vue) {
|
||||||
console.log("THAT:", localStorage.getItem("projectId"));
|
console.log("THAT:", localStorage.getItem("projectId"));
|
||||||
|
|||||||
@@ -34,7 +34,10 @@
|
|||||||
v-for="project in projects"
|
v-for="project in projects"
|
||||||
:key="project.id"
|
:key="project.id"
|
||||||
>
|
>
|
||||||
<a href="project-view.html" class="block py-4 flex gap-4">
|
<a
|
||||||
|
@click="onClickLoadProject(project.id)"
|
||||||
|
class="block py-4 flex gap-4"
|
||||||
|
>
|
||||||
<div class="flex-none w-12">
|
<div class="flex-none w-12">
|
||||||
<img
|
<img
|
||||||
src="https://picsum.photos/200/200?random=1"
|
src="https://picsum.photos/200/200?random=1"
|
||||||
@@ -66,7 +69,18 @@ import { AppString } from "@/constants/app";
|
|||||||
})
|
})
|
||||||
export default class ProjectsView extends Vue {
|
export default class ProjectsView extends Vue {
|
||||||
projects: { id: string; name: string; description: string }[] = [];
|
projects: { id: string; name: string; description: string }[] = [];
|
||||||
async LoadProject(identity: IIdentifier) {
|
|
||||||
|
onClickLoadProject(id: string) {
|
||||||
|
console.log("projectId", id);
|
||||||
|
localStorage.setItem("projectId", id);
|
||||||
|
const route = {
|
||||||
|
name: "project",
|
||||||
|
};
|
||||||
|
console.log(route);
|
||||||
|
this.$router.push(route);
|
||||||
|
}
|
||||||
|
|
||||||
|
async LoadProjects(identity: IIdentifier) {
|
||||||
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
|
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
|
||||||
const url = endorserApiServer + "/api/claim/?claimContents=" + identity.did;
|
const url = endorserApiServer + "/api/claim/?claimContents=" + identity.did;
|
||||||
const token = await accessToken(identity);
|
const token = await accessToken(identity);
|
||||||
@@ -77,16 +91,17 @@ export default class ProjectsView extends Vue {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await this.axios.get(url, { headers });
|
const resp = await this.axios.get(url, { headers });
|
||||||
console.log(resp.status, resp.data);
|
|
||||||
if (resp.status === 200) {
|
if (resp.status === 200) {
|
||||||
const claims = resp.data;
|
const claims = resp.data;
|
||||||
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;
|
||||||
this.projects.push({
|
const data = {
|
||||||
id: claim.id,
|
id: claims[i].id,
|
||||||
name: claim.name,
|
name: claim.name,
|
||||||
description: claim.description,
|
description: claim.description,
|
||||||
});
|
};
|
||||||
|
this.projects.push(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -102,7 +117,7 @@ export default class ProjectsView extends Vue {
|
|||||||
} else {
|
} else {
|
||||||
const accounts = await db.accounts.toArray();
|
const accounts = await db.accounts.toArray();
|
||||||
const identity = JSON.parse(accounts[0].identity);
|
const identity = JSON.parse(accounts[0].identity);
|
||||||
this.LoadProject(identity);
|
this.LoadProjects(identity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user