From 6393a20e7e5868491360067a654c9a6c142146e0 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 26 Jun 2023 20:45:13 +0800 Subject: [PATCH] Documentation added --- src/views/ProjectsView.vue | 41 +++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index 89ab68e..dafad40 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -112,10 +112,25 @@ import { accessToken } from "@/libs/crypto"; import { IIdentifier } from "@veramo/core"; import InfiniteScroll from "@/components/InfiniteScroll"; +/** +* Represents data about a project +**/ interface ProjectData { + /** + * Name of the project + **/ name: string; + /** + * Description of the project + **/ description: string; + /** + * URL referencing information about the project + **/ handleId: string; + /** + * The Identier of the project + **/ jwtId: string; } @@ -132,6 +147,11 @@ export default class ProjectsView extends Vue { }[] = []; current: IIdentifier; + /** + * Core project data loader + * @param url the url used to fetch the data + * @param token Authorization token + **/ async dataLoader(url: string, token: string) { const headers: { [key: string]: string } = { "Content-Type": "application/json", @@ -152,9 +172,11 @@ export default class ProjectsView extends Vue { } } + /** + * Data loader used by infinite scroller + * @param payload is the flag from the InfiniteScroll indicating if it should load + **/ async loadMoreData(payload: boolean) { - console.log("loadMoreData"); - console.log(payload); if (this.projects.length > 0) { const latestProject = this.projects[this.projects.length - 1]; const url = `${this.apiServer}/api/v2/report/plansByIssuer?beforeId=${latestProject.jwtId}`; @@ -163,6 +185,10 @@ export default class ProjectsView extends Vue { } } + /** + * Handle clicking on a project entry found in the list + * @param id of the project + **? onClickLoadProject(id: string) { localStorage.setItem("projectId", id); const route = { @@ -171,6 +197,10 @@ export default class ProjectsView extends Vue { this.$router.push(route); } + /** + * Load projects initially + * @param identity of the user + **/ async LoadProjects(identity: IIdentifier) { console.log("LoadProjects"); const url = `${this.apiServer}/api/v2/report/plansByIssuer`; @@ -178,7 +208,9 @@ export default class ProjectsView extends Vue { await this.dataLoader(url, token); } - // 'created' hook runs when the Vue instance is first created + /** + * 'created' hook runs when the Vue instance is first created + **/ async created() { await db.open(); const settings = await db.settings.get(MASTER_SETTINGS_KEY); @@ -198,6 +230,9 @@ export default class ProjectsView extends Vue { } } + /** + * Handling clicking on the new project button + **/ onClickNewProject(): void { localStorage.removeItem("projectId"); const route = {