Browse Source

Documentation added

world-fix
Matthew Raymer 1 year ago
parent
commit
6393a20e7e
  1. 41
      src/views/ProjectsView.vue

41
src/views/ProjectsView.vue

@ -112,10 +112,25 @@ import { accessToken } from "@/libs/crypto";
import { IIdentifier } from "@veramo/core"; import { IIdentifier } from "@veramo/core";
import InfiniteScroll from "@/components/InfiniteScroll"; import InfiniteScroll from "@/components/InfiniteScroll";
/**
* Represents data about a project
**/
interface ProjectData { interface ProjectData {
/**
* Name of the project
**/
name: string; name: string;
/**
* Description of the project
**/
description: string; description: string;
/**
* URL referencing information about the project
**/
handleId: string; handleId: string;
/**
* The Identier of the project
**/
jwtId: string; jwtId: string;
} }
@ -132,6 +147,11 @@ export default class ProjectsView extends Vue {
}[] = []; }[] = [];
current: IIdentifier; 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) { async dataLoader(url: string, token: string) {
const headers: { [key: string]: string } = { const headers: { [key: string]: string } = {
"Content-Type": "application/json", "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) { async loadMoreData(payload: boolean) {
console.log("loadMoreData");
console.log(payload);
if (this.projects.length > 0) { if (this.projects.length > 0) {
const latestProject = this.projects[this.projects.length - 1]; const latestProject = this.projects[this.projects.length - 1];
const url = `${this.apiServer}/api/v2/report/plansByIssuer?beforeId=${latestProject.jwtId}`; 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) { onClickLoadProject(id: string) {
localStorage.setItem("projectId", id); localStorage.setItem("projectId", id);
const route = { const route = {
@ -171,6 +197,10 @@ export default class ProjectsView extends Vue {
this.$router.push(route); this.$router.push(route);
} }
/**
* Load projects initially
* @param identity of the user
**/
async LoadProjects(identity: IIdentifier) { async LoadProjects(identity: IIdentifier) {
console.log("LoadProjects"); console.log("LoadProjects");
const url = `${this.apiServer}/api/v2/report/plansByIssuer`; const url = `${this.apiServer}/api/v2/report/plansByIssuer`;
@ -178,7 +208,9 @@ export default class ProjectsView extends Vue {
await this.dataLoader(url, token); 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() { async created() {
await db.open(); await db.open();
const settings = await db.settings.get(MASTER_SETTINGS_KEY); 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 { onClickNewProject(): void {
localStorage.removeItem("projectId"); localStorage.removeItem("projectId");
const route = { const route = {

Loading…
Cancel
Save