Fix: Tag Interface Delete Button #104256

Manually merged
Sybren A. Stüvel merged 39 commits from Evelinealy/flamenco:tag-interface into main 2023-11-02 16:13:14 +01:00
Showing only changes of commit 7ecf89e94b - Show all commits

View File

@ -3,12 +3,19 @@
<h2 class="column-title">Tag Details</h2>
<div class="action-buttons">
<button @click="createTag">Create Tag</button>
<button @click="fetchTags">Refresh</button>
<button @click="deleteTag" :disabled="tags.length === 0">
Delete Tag
</button>
</div>
<div class="action-buttons">
<form @submit="createTag">
<input type="text" name="newtagname" v-model="newTagName" placeholder="New Tag Name">
<button type="submit">Create Tag</button>
</form>
</div>
<!-- Table to display tags -->
<table v-if="tags.length > 0" class="tag-table">
<thead>
@ -98,6 +105,9 @@
<script>
import { useWorkers } from "@/stores/workers";
import { useNotifs } from "@/stores/notifications";
import { WorkerMgtApi } from '@/manager-api';
import { WorkerTag } from '@/manager-api';
import { getAPIClient } from "@/api-client";
import TabItem from "@/components/TabItem.vue";
import TabsWrapper from "@/components/TabsWrapper.vue";
@ -110,19 +120,23 @@ export default {
return {
tags: [],
selectedTag: null,
newTagName: "",
workers: useWorkers(),
};
},
mounted() {
this.fetchTags();
const api = new WorkerMgtApi(getAPIClient());
window.api = api;
},
methods: {
fetchTags() {
useWorkers()
.refreshTags()
this.workers.refreshTags()
dr.sybren marked this conversation as resolved Outdated

Add this column to the end, so that it has the same layout as the job blocklist (there the is on the right as well).

Add this column to the end, so that it has the same layout as the job blocklist (there the ❌ is on the right as well).
.then(() => {
this.tags = useWorkers().tags;
this.tags = this.workers.tags;
})
.catch((error) => {
const errorMsg = JSON.stringify(error);
@ -130,9 +144,18 @@ export default {
});
},
createTag() {
const newTag = { name: "name", description: "this is a test field" };
this.tags.push(newTag);
createTag(event) {
event.preventDefault();
const api = new WorkerMgtApi(getAPIClient());
const newTag = new WorkerTag(this.newTagName);
api.createWorkerTag(newTag)
.then(this.fetchTags)
.catch((error) => {
const errorMsg = JSON.stringify(error);
useNotifs().add(`Error: ${errorMsg}`);
});
},
deleteTag() {