From 606a75f8f5354501a022e9841c42b406117fee58 Mon Sep 17 00:00:00 2001 From: Martijn Voordouw Date: Fri, 6 Sep 2024 15:37:40 +0200 Subject: [PATCH 1/4] created link to most recent version Add package now grabs most recent version if no version was specified, if the version has already been added you are redirected to that version. --- src/api/dlt/api.ts | 8 +- src/api/dlt/interface.ts | 4 +- src/api/dlt/mock.ts | 6 +- src/components/AddPackageComponent.vue | 110 +++++++++++++++++-------- 4 files changed, 92 insertions(+), 36 deletions(-) diff --git a/src/api/dlt/api.ts b/src/api/dlt/api.ts index afd935c..6247e0a 100644 --- a/src/api/dlt/api.ts +++ b/src/api/dlt/api.ts @@ -128,6 +128,12 @@ export default class DltApi extends DltInterface { return data; } + async getMostRecentVersion(pack: Package) { + const { data } = await axios.post(this.#getLink('get-most-recent-version'), pack); + console.log(data); + return data; + } + async getMetrics() { const { data } = await axios.get(this.#getLink('metrics')); return parseMetrics(data); @@ -144,4 +150,4 @@ export default class DltApi extends DltInterface { } /* This program has been developed by students from the bachelor Computer Science at Utrecht University within the Software Project course. -© Copyright Utrecht University (Department of Information and Computing Sciences) */ \ No newline at end of file +© Copyright Utrecht University (Department of Information and Computing Sciences) */ diff --git a/src/api/dlt/interface.ts b/src/api/dlt/interface.ts index 53d297a..4635172 100644 --- a/src/api/dlt/interface.ts +++ b/src/api/dlt/interface.ts @@ -47,6 +47,8 @@ export abstract class DltInterface { abstract addPackage(pack: AddPackageForm): Promise; + abstract getMostRecentVersion(pack: Package): Promise; + abstract getMetrics(): Promise; abstract getTrustScore(name: string, version: string): Promise; @@ -79,4 +81,4 @@ export const defaultMetrics: Metrics = { }; /* This program has been developed by students from the bachelor Computer Science at Utrecht University within the Software Project course. -© Copyright Utrecht University (Department of Information and Computing Sciences) */ \ No newline at end of file +© Copyright Utrecht University (Department of Information and Computing Sciences) */ diff --git a/src/api/dlt/mock.ts b/src/api/dlt/mock.ts index 980232f..ca3f4fe 100644 --- a/src/api/dlt/mock.ts +++ b/src/api/dlt/mock.ts @@ -59,6 +59,10 @@ export default class DltMock extends DltInterface { return 'Success'; } + async getMostRecentVersion(pack: Package): Promise { + return "v7.8.9"; + } + async getMetrics() { await fakeDelay(); return { @@ -73,4 +77,4 @@ export default class DltMock extends DltInterface { } /* This program has been developed by students from the bachelor Computer Science at Utrecht University within the Software Project course. -© Copyright Utrecht University (Department of Information and Computing Sciences) */ \ No newline at end of file +© Copyright Utrecht University (Department of Information and Computing Sciences) */ diff --git a/src/components/AddPackageComponent.vue b/src/components/AddPackageComponent.vue index df483a9..edd723b 100644 --- a/src/components/AddPackageComponent.vue +++ b/src/components/AddPackageComponent.vue @@ -1,42 +1,60 @@