|
|
@ -139,6 +139,7 @@ export default {
|
|
|
|
VueMultiselect,
|
|
|
|
VueMultiselect,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
props: {
|
|
|
|
|
|
|
|
/** Array of tags to be pre-selected */
|
|
|
|
preSelectedTags: {
|
|
|
|
preSelectedTags: {
|
|
|
|
type: Array,
|
|
|
|
type: Array,
|
|
|
|
default: () => [],
|
|
|
|
default: () => [],
|
|
|
@ -241,9 +242,11 @@ export default {
|
|
|
|
this.getExistingTags();
|
|
|
|
this.getExistingTags();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
|
|
|
|
/** Show the add tag dialog */
|
|
|
|
showAddDialog() {
|
|
|
|
showAddDialog() {
|
|
|
|
this.modal.show();
|
|
|
|
this.modal.show();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/** Get all existing tags */
|
|
|
|
getExistingTags() {
|
|
|
|
getExistingTags() {
|
|
|
|
this.$root.getSocket().emit("getTags", (res) => {
|
|
|
|
this.$root.getSocket().emit("getTags", (res) => {
|
|
|
|
if (res.ok) {
|
|
|
|
if (res.ok) {
|
|
|
@ -253,6 +256,10 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Delete the specified tag
|
|
|
|
|
|
|
|
* @param {Object} tag Object representing tag to delete
|
|
|
|
|
|
|
|
*/
|
|
|
|
deleteTag(item) {
|
|
|
|
deleteTag(item) {
|
|
|
|
if (item.new) {
|
|
|
|
if (item.new) {
|
|
|
|
// Undo Adding a new Tag
|
|
|
|
// Undo Adding a new Tag
|
|
|
@ -262,6 +269,13 @@ export default {
|
|
|
|
this.deleteTags.push(item);
|
|
|
|
this.deleteTags.push(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Set colour of text
|
|
|
|
|
|
|
|
* @param {Object} option Object representing color choice. If
|
|
|
|
|
|
|
|
* option.color is set, the text color will be white, else it
|
|
|
|
|
|
|
|
* be chosen based upon application theme
|
|
|
|
|
|
|
|
* @returns string
|
|
|
|
|
|
|
|
*/
|
|
|
|
textColor(option) {
|
|
|
|
textColor(option) {
|
|
|
|
if (option.color) {
|
|
|
|
if (option.color) {
|
|
|
|
return "white";
|
|
|
|
return "white";
|
|
|
@ -269,6 +283,7 @@ export default {
|
|
|
|
return this.$root.theme === "light" ? "var(--bs-body-color)" : "inherit";
|
|
|
|
return this.$root.theme === "light" ? "var(--bs-body-color)" : "inherit";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/** Add a draft tag */
|
|
|
|
addDraftTag() {
|
|
|
|
addDraftTag() {
|
|
|
|
console.log("Adding Draft Tag: ", this.newDraftTag);
|
|
|
|
console.log("Adding Draft Tag: ", this.newDraftTag);
|
|
|
|
if (this.newDraftTag.select != null) {
|
|
|
|
if (this.newDraftTag.select != null) {
|
|
|
@ -296,6 +311,7 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.clearDraftTag();
|
|
|
|
this.clearDraftTag();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/** Remove a draft tag */
|
|
|
|
clearDraftTag() {
|
|
|
|
clearDraftTag() {
|
|
|
|
this.newDraftTag = {
|
|
|
|
this.newDraftTag = {
|
|
|
|
name: null,
|
|
|
|
name: null,
|
|
|
@ -307,26 +323,51 @@ export default {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.modal.hide();
|
|
|
|
this.modal.hide();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Add a tag asynchronously
|
|
|
|
|
|
|
|
* @param {Object} newTag Object representing new tag to add
|
|
|
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
|
|
|
*/
|
|
|
|
addTagAsync(newTag) {
|
|
|
|
addTagAsync(newTag) {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
this.$root.getSocket().emit("addTag", newTag, resolve);
|
|
|
|
this.$root.getSocket().emit("addTag", newTag, resolve);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Add a tag to a monitor asynchronously
|
|
|
|
|
|
|
|
* @param {number} tagId ID of tag to add
|
|
|
|
|
|
|
|
* @param {number} monitorId ID of monitor to add tag to
|
|
|
|
|
|
|
|
* @param {string} value Value of tag
|
|
|
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
|
|
|
*/
|
|
|
|
addMonitorTagAsync(tagId, monitorId, value) {
|
|
|
|
addMonitorTagAsync(tagId, monitorId, value) {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
this.$root.getSocket().emit("addMonitorTag", tagId, monitorId, value, resolve);
|
|
|
|
this.$root.getSocket().emit("addMonitorTag", tagId, monitorId, value, resolve);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Delete a tag from a monitor asynchronously
|
|
|
|
|
|
|
|
* @param {number} tagId ID of tag to remove
|
|
|
|
|
|
|
|
* @param {number} monitorId ID of monitor to remove tag from
|
|
|
|
|
|
|
|
* @param {string} value Value of tag
|
|
|
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
|
|
|
*/
|
|
|
|
deleteMonitorTagAsync(tagId, monitorId, value) {
|
|
|
|
deleteMonitorTagAsync(tagId, monitorId, value) {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
this.$root.getSocket().emit("deleteMonitorTag", tagId, monitorId, value, resolve);
|
|
|
|
this.$root.getSocket().emit("deleteMonitorTag", tagId, monitorId, value, resolve);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/** Called as user types input */
|
|
|
|
onEnter() {
|
|
|
|
onEnter() {
|
|
|
|
if (!this.validateDraftTag.invalid) {
|
|
|
|
if (!this.validateDraftTag.invalid) {
|
|
|
|
this.addDraftTag();
|
|
|
|
this.addDraftTag();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Submit the form data
|
|
|
|
|
|
|
|
* @param {number} monitorId ID of monitor this change affects
|
|
|
|
|
|
|
|
* @returns {void}
|
|
|
|
|
|
|
|
*/
|
|
|
|
async submit(monitorId) {
|
|
|
|
async submit(monitorId) {
|
|
|
|
console.log(`Submitting tag changes for monitor ${monitorId}...`);
|
|
|
|
console.log(`Submitting tag changes for monitor ${monitorId}...`);
|
|
|
|
this.processing = true;
|
|
|
|
this.processing = true;
|
|
|
|