Web Interface for Tags #104244
@ -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 {
|
||||
Sybren A. Stüvel
commented
I think it's also nice to clear the input field once the tag has been succesfully created. I think it's also nice to clear the input field once the tag has been succesfully created.
|
||||
tags: [],
|
||||
selectedTag: null,
|
||||
newTagName: "",
|
||||
workers: useWorkers(),
|
||||
};
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.fetchTags();
|
||||
|
||||
const api = new WorkerMgtApi(getAPIClient());
|
||||
window.api = api;
|
||||
},
|
||||
|
||||
methods: {
|
||||
fetchTags() {
|
||||
useWorkers()
|
||||
.refreshTags()
|
||||
this.workers.refreshTags()
|
||||
Sybren A. Stüvel
commented
Instead of trying to find the just-deleted tag, just call This is all temporary code, and that it should be removed once the SocketIO broadcasting of tag changes is implemented. Instead of trying to find the just-deleted tag, just call `this.fetchTags()`.
This is all temporary code, and that it should be removed once the SocketIO broadcasting of tag changes is implemented.
|
||||
.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}`);
|
||||
});
|
||||
Sybren A. Stüvel
commented
Not sure why this is implemented in a separate function, it could just all be part of the Not sure why this is implemented in a separate function, it could just all be part of the `onRowClick` event handler.
|
||||
},
|
||||
|
||||
deleteTag() {
|
||||
Sybren A. Stüvel
commented
This alone is not enough to update all the rows in the table. When I click one tag, and then another, both appear as if they're selected. You probably need to force a redraw of the table somehow (there's a Tabulator API call for this). This alone is not enough to update all the rows in the table. When I click one tag, and then another, both appear as if they're selected. You probably need to force a redraw of the table somehow (there's a Tabulator API call for this).
|
||||
|
Loading…
Reference in New Issue
Block a user
For a followup PR, I think it would be nicer to remove this button, and have a little ❌ icon behind each tag (just like in
Blocklist.vue
for removing blocklist entries).Since selection of tags is only used for deleting them, this little change would remove the entire need to select tags. It also clears up the double semantics of clicking on a tag name: it currently both selects the tag and allows renaming it.