|
|
|
<template>
|
|
|
|
<!-- QUICK NAV -->
|
|
|
|
<nav id="QuickNav" class="fixed bottom-0 left-0 right-0 bg-slate-200">
|
|
|
|
<ul class="flex text-2xl p-2 gap-2">
|
|
|
|
<!-- Home Feed -->
|
|
|
|
<li class="basis-1/5 rounded-md text-slate-500">
|
|
|
|
<router-link :to="{ name: 'home' }" class="block text-center py-3 px-1"
|
|
|
|
><fa icon="house-chimney" class="fa-fw"></fa
|
|
|
|
></router-link>
|
|
|
|
</li>
|
|
|
|
<!-- Search -->
|
|
|
|
<li class="basis-1/5 rounded-md bg-slate-400 text-white">
|
|
|
|
<router-link
|
|
|
|
:to="{ name: 'discover' }"
|
|
|
|
class="block text-center py-3 px-1"
|
|
|
|
><fa icon="magnifying-glass" class="fa-fw"></fa
|
|
|
|
></router-link>
|
|
|
|
</li>
|
|
|
|
<!-- Projects -->
|
|
|
|
<li class="basis-1/5 rounded-md text-slate-500">
|
|
|
|
<router-link
|
|
|
|
:to="{ name: 'projects' }"
|
|
|
|
class="block text-center py-3 px-1"
|
|
|
|
><fa icon="folder-open" class="fa-fw"></fa
|
|
|
|
></router-link>
|
|
|
|
</li>
|
|
|
|
<!-- Commitments -->
|
|
|
|
<li class="basis-1/5 rounded-md text-slate-500">
|
|
|
|
<router-link :to="{ name: '' }" class="block text-center py-3 px-1"
|
|
|
|
><fa icon="hand" class="fa-fw"></fa
|
|
|
|
></router-link>
|
|
|
|
</li>
|
|
|
|
<!-- Profile -->
|
|
|
|
<li class="basis-1/5 rounded-md text-slate-500">
|
|
|
|
<router-link
|
|
|
|
:to="{ name: 'account' }"
|
|
|
|
class="block text-center py-3 px-1"
|
|
|
|
><fa icon="circle-user" class="fa-fw"></fa
|
|
|
|
></router-link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<section id="Content" class="p-6 pb-24">
|
|
|
|
<!-- Heading -->
|
|
|
|
<h1 id="ViewHeading" class="text-4xl text-center font-light pt-4 mb-8">
|
|
|
|
My Plans
|
|
|
|
</h1>
|
|
|
|
|
|
|
|
<!-- Quick Search -->
|
|
|
|
<form id="QuickSearch" class="mb-4 flex">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
placeholder="Search…"
|
|
|
|
class="block w-full rounded-l border border-r-0 border-slate-400 px-3 py-2"
|
|
|
|
/>
|
|
|
|
<button
|
|
|
|
class="px-4 rounded-r bg-slate-200 border border-l-0 border-slate-400"
|
|
|
|
>
|
|
|
|
<fa icon="magnifying-glass" class="fa-fw"></fa>
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- New Project -->
|
|
|
|
<button
|
|
|
|
class="fixed right-6 bottom-24 text-center text-4xl leading-none bg-blue-600 text-white w-14 py-2.5 rounded-full"
|
|
|
|
@click="onClickNewProject()"
|
|
|
|
>
|
|
|
|
<fa icon="plus" class="fa-fw"></fa>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<!-- Results List -->
|
|
|
|
<ul class="">
|
|
|
|
<li
|
|
|
|
class="border-b border-slate-300"
|
|
|
|
v-for="project in projects"
|
|
|
|
:key="project.handleId"
|
|
|
|
>
|
|
|
|
<a
|
|
|
|
@click="onClickLoadProject(project.handleId)"
|
|
|
|
class="block py-4 flex gap-4"
|
|
|
|
>
|
|
|
|
<div class="flex-none w-12">
|
|
|
|
<img
|
|
|
|
src="https://picsum.photos/200/200?random=1"
|
|
|
|
class="w-full rounded"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grow overflow-hidden">
|
|
|
|
<h2 class="text-base font-semibold">{{ project.name }}</h2>
|
|
|
|
<div class="text-sm truncate">
|
|
|
|
{{ project.description }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { Options, Vue } from "vue-class-component";
|
|
|
|
import { accessToken } from "@/libs/crypto";
|
|
|
|
import { db } from "../db";
|
|
|
|
import { IIdentifier } from "@veramo/core";
|
|
|
|
import { AppString } from "@/constants/app";
|
|
|
|
|
|
|
|
@Options({
|
|
|
|
components: {},
|
|
|
|
})
|
|
|
|
export default class ProjectsView extends Vue {
|
|
|
|
projects: { handleId: string; name: string; description: string }[] = [];
|
|
|
|
|
|
|
|
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 url = endorserApiServer + "/api/v2/report/plansByIssuer";
|
|
|
|
const token = await accessToken(identity);
|
|
|
|
const headers = {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
Authorization: "Bearer " + token,
|
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
|
|
|
const resp = await this.axios.get(url, { headers });
|
|
|
|
if (resp.status === 200) {
|
|
|
|
const plans = resp.data.data;
|
|
|
|
for (let i = 0; i < plans.length; i++) {
|
|
|
|
const plan = plans[i];
|
|
|
|
const data = {
|
|
|
|
name: plan.name,
|
|
|
|
description: plan.description,
|
|
|
|
handleId: plan.fullIri,
|
|
|
|
};
|
|
|
|
this.projects.push(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.LoadProjects(identity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onClickNewProject(): void {
|
|
|
|
localStorage.removeItem("projectId");
|
|
|
|
const route = {
|
|
|
|
name: "new-edit-project",
|
|
|
|
};
|
|
|
|
console.log(route);
|
|
|
|
this.$router.push(route);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|