Skip to content

Commit c2a42a6

Browse files
committed
WIP: Buttons for uninstall
1 parent 8341030 commit c2a42a6

File tree

6 files changed

+90
-51
lines changed

6 files changed

+90
-51
lines changed

src/api/api.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class MinkApi {
282282
const response = await this.axios.put<MinkResponse<ResourceInfoOneData>>(
283283
"install-korp",
284284
null,
285-
{ params: { corpus_id: corpusId } },
285+
{ params: { resource_id: corpusId } },
286286
);
287287
return response.data;
288288
}
@@ -292,11 +292,27 @@ class MinkApi {
292292
const response = await this.axios.put<MinkResponse<ResourceInfoOneData>>(
293293
"install-strix",
294294
null,
295-
{ params: { corpus_id: corpusId } },
295+
{ params: { resource_id: corpusId } },
296296
);
297297
return response.data;
298298
}
299299

300+
/** @see https://ws.spraakbanken.gu.se/docs/mink#tag/Process-Corpus/operation/uninstallinKorp */
301+
async uninstallKorp(corpusId: string) {
302+
const response = await this.axios.delete<MinkResponse>("uninstall-korp", {
303+
params: { resource_id: corpusId },
304+
});
305+
return response.data;
306+
}
307+
308+
/** @see https://ws.spraakbanken.gu.se/docs/mink#tag/Process-Corpus/operation/uninstallinStrix */
309+
async uninstallStrix(corpusId: string) {
310+
const response = await this.axios.delete<MinkResponse>("uninstall-strix", {
311+
params: { resource_id: corpusId },
312+
});
313+
return response.data;
314+
}
315+
300316
/** @see https://ws.spraakbanken.gu.se/docs/mink#tag/Admin-Mode/operation/adminmodestatus */
301317
async adminModeStatus() {
302318
const response =

src/corpus/explore/ExplorePanel.vue

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const props = defineProps<{
1313
}>();
1414
1515
const { isPending } = useSpin();
16-
const { installKorp, installStrix } = useCorpusStore();
16+
const { installKorp, installStrix, uninstallKorp, uninstallStrix } =
17+
useCorpusStore();
1718
const { isJobRunning, jobState } = useCorpus(props.corpusId);
1819
const { locale3 } = useLocale();
1920
@@ -26,29 +27,22 @@ const canInstall = computed(
2627
jobState.value?.sparv == "done" &&
2728
!isPending(`corpus/${props.corpusId}/job`),
2829
);
29-
30-
async function korpInstall() {
31-
await installKorp(props.corpusId);
32-
}
33-
34-
async function strixInstall() {
35-
await installStrix(props.corpusId);
36-
}
3730
</script>
3831

3932
<template>
4033
<p>{{ $t("exports.tools.help") }}</p>
41-
<div class="grid xl:grid-cols-2 gap-4 mt-4">
34+
<div class="grid gap-4 mt-4">
4235
<PendingContent :on="`corpus/${corpusId}/job/install/korp`">
4336
<ToolPanel
4437
name="Korp"
4538
:info="$t('exports.tools.help.korp')"
4639
:link-url="$t('exports.tools.help.korp.manual.url')"
4740
:link-text="$t('exports.tools.help.korp.manual.text')"
48-
:can-install="canInstall"
41+
:can-install
4942
:is-installed="jobState?.korp == 'done'"
5043
:show-url="`${korpUrl}?mode=mink#?corpus=${corpusId}&lang=${locale3}`"
51-
@install="korpInstall()"
44+
@install="installKorp(corpusId)"
45+
@uninstall="uninstallKorp(corpusId)"
5246
/>
5347
</PendingContent>
5448

@@ -58,10 +52,11 @@ async function strixInstall() {
5852
:info="$t('exports.tools.help.strix')"
5953
:link-url="$t('exports.tools.help.strix.manual.url')"
6054
:link-text="$t('exports.tools.help.strix.manual.text')"
61-
:can-install="canInstall"
55+
:can-install
6256
:is-installed="jobState?.strix == 'done'"
6357
:show-url="`${strixUrl}?mode=mink&corpora=${corpusId}`"
64-
@install="strixInstall()"
58+
@install="installStrix(corpusId)"
59+
@uninstall="uninstallStrix(corpusId)"
6560
/>
6661
</PendingContent>
6762
</div>

src/corpus/explore/ToolPanel.vue

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { PhArrowSquareOut, PhGearFine } from "@phosphor-icons/vue";
2+
import { PhArrowSquareOut, PhGearFine, PhTrash } from "@phosphor-icons/vue";
33
import ActionButton from "@/components/ActionButton.vue";
44
import UrlButton from "@/components/UrlButton.vue";
55
@@ -14,48 +14,54 @@ defineProps<{
1414
}>();
1515
defineEmits<{
1616
(e: "install"): void;
17+
(e: "uninstall"): void;
1718
}>();
1819
</script>
1920

2021
<template>
21-
<div class="flex flex-col gap-2">
22-
<div class="flex flex-wrap gap-2 justify-between items-baseline">
22+
<div class="flex gap-3 items-center">
23+
<div class="flex-1 self-start">
2324
<h3 class="font-semibold">{{ name }}</h3>
24-
25-
<div class="flex gap-2 justify-end items-baseline">
26-
<ActionButton
27-
:disabled="!canInstall"
28-
class="whitespace-nowrap"
29-
:class="{ 'button-primary': canInstall && !isInstalled }"
30-
@click="$emit('install')"
31-
>
32-
<PhGearFine weight="bold" class="inline mb-1 mr-1" />
33-
{{
34-
$t(
35-
!isInstalled
36-
? "exports.tools.install"
37-
: "exports.tools.reinstall",
38-
)
39-
}}
40-
</ActionButton>
41-
42-
<UrlButton
43-
v-if="isInstalled"
44-
:href="showUrl"
45-
target="_blank"
46-
class="button-primary"
47-
>
48-
<PhArrowSquareOut weight="bold" class="inline mb-1 mr-1" />
49-
{{ $t("exports.tools.view") }}
50-
</UrlButton>
25+
<div class="text-sm text-gray-500 dark:text-gray-400">
26+
<div>{{ info }}</div>
27+
<a v-if="linkUrl && linkText" :href="linkUrl" target="_blank">
28+
{{ linkText }}
29+
</a>
5130
</div>
5231
</div>
5332

54-
<div class="text-sm text-gray-500 dark:text-gray-400">
55-
<div>{{ info }}</div>
56-
<a v-if="linkUrl && linkText" :href="linkUrl" target="_blank">
57-
{{ linkText }}
58-
</a>
33+
<div class="flex flex-col gap-2 items-end">
34+
<UrlButton
35+
v-if="isInstalled"
36+
:href="showUrl"
37+
target="_blank"
38+
class="button-primary"
39+
>
40+
<PhArrowSquareOut weight="bold" class="inline mb-1 mr-1" />
41+
{{ $t("exports.tools.view") }}
42+
</UrlButton>
43+
44+
<ActionButton
45+
:disabled="!canInstall"
46+
class="whitespace-nowrap"
47+
:class="{ 'button-primary': canInstall && !isInstalled }"
48+
@click="$emit('install')"
49+
>
50+
<PhGearFine weight="bold" class="inline mb-1 mr-1" />
51+
{{
52+
$t(!isInstalled ? "exports.tools.install" : "exports.tools.reinstall")
53+
}}
54+
</ActionButton>
55+
56+
<ActionButton
57+
v-if="isInstalled"
58+
:disabled="!canInstall"
59+
class="whitespace-nowrap button-mute"
60+
@click="$emit('uninstall')"
61+
>
62+
<PhTrash weight="bold" class="inline mb-1 mr-1" />
63+
{{ $t("exports.tools.uninstall") }}
64+
</ActionButton>
5965
</div>
6066
</div>
6167
</template>

src/i18n/locales/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ exports.tools.help.strix.manual.url: https://spraakbanken.gu.se/strix/docs/
105105
exports.tools.help.strix.manual.text: Documentation
106106
exports.tools.install: Install
107107
exports.tools.reinstall: Reinstall
108+
exports.tools.uninstall: Uninstall
108109
exports.tools.view: Open
109110
exports.download.help: Results can be downloaded as machine-readable files for processing in scripts or other specialized software.
110111
exports.download.placeholder: Downloads will be available here after successful analysis.

src/i18n/locales/sv.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ exports.tools.help.strix.manual.url: https://spraakbanken.gu.se/strix/docs/
106106
exports.tools.help.strix.manual.text: Dokumentation
107107
exports.tools.install: Installera
108108
exports.tools.reinstall: Installera om
109+
exports.tools.uninstall: Avinstallera
109110
exports.tools.view: Öppna
110111
exports.download.help: Resultatet kan laddas ner som maskinläsbara filer för bearbetning i script eller speciella program.
111112
exports.download.placeholder: Nedladdningar finns här efter slutförd annotering.

src/store/corpus.store.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,24 @@ export const useCorpusStore = defineStore("corpus", () => {
122122
corpora.value[corpusId]!.job = info.job;
123123
}
124124

125+
async function uninstallKorp(corpusId: string) {
126+
matomo?.trackEvent("Corpus", "Tool uninstall", "Korp");
127+
const info = await spin(
128+
api.uninstallKorp(corpusId).catch(alertError),
129+
`corpus/${corpusId}/job/uninstall/korp`,
130+
);
131+
if (!info) return;
132+
}
133+
134+
async function uninstallStrix(corpusId: string) {
135+
matomo?.trackEvent("Corpus", "Tool uninstall", "Strix");
136+
const info = await spin(
137+
api.uninstallStrix(corpusId).catch(alertError),
138+
`corpus/${corpusId}/job/uninstall/strix`,
139+
);
140+
if (!info) return;
141+
}
142+
125143
async function abortJob(corpusId: string) {
126144
matomo?.trackEvent("Corpus", "Annotation", "Abort");
127145
await spin(
@@ -179,6 +197,8 @@ export const useCorpusStore = defineStore("corpus", () => {
179197
abortJob,
180198
installKorp,
181199
installStrix,
200+
uninstallKorp,
201+
uninstallStrix,
182202
loadExports,
183203
};
184204
});

0 commit comments

Comments
 (0)