From 61999c7685b4f20df739f170469cdec8bb82dbe0 Mon Sep 17 00:00:00 2001 From: rmotitsuki Date: Wed, 29 Nov 2023 16:07:49 -0300 Subject: [PATCH 1/7] Replace global $emit for eventBus --- ui/k-action-menu/search_switch.kytos | 6 +++--- ui/k-info-panel/link_info.kytos | 12 ++++++------ ui/k-info-panel/switch_info.kytos | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ui/k-action-menu/search_switch.kytos b/ui/k-action-menu/search_switch.kytos index 2d087756..3e36b1c4 100644 --- a/ui/k-action-menu/search_switch.kytos +++ b/ui/k-action-menu/search_switch.kytos @@ -25,7 +25,7 @@ module.exports = { "title": "Switch Search", "subtitle": "by kytos/topology" } - this.$kytos.$emit("showInfoPanel", content) + this.$kytos.eventBus.$emit("showInfoPanel", content) }, open_switch(s){ var content = {"component": 'kytos-topology-k-info-panel-switch_info', @@ -33,7 +33,7 @@ module.exports = { "icon": "gear", "title": "Switch Details", "subtitle": s.connection} - this.$kytos.$emit("showInfoPanel", content) + this.$kytos.eventBus.$emit("showInfoPanel", content) }, get_switches () { var endpoint = this.$kytos_server_api + "kytos/topology/v3/switches" @@ -64,7 +64,7 @@ module.exports = { }, mounted() { this.get_switches() - this.$kytos.$emit('addActionMenuItem', this.options) + this.$kytos.eventBus.$emit('addActionMenuItem', this.options) }, computed: { switchesFiltered() { diff --git a/ui/k-info-panel/link_info.kytos b/ui/k-info-panel/link_info.kytos index 3d96cc44..1713d19d 100644 --- a/ui/k-info-panel/link_info.kytos +++ b/ui/k-info-panel/link_info.kytos @@ -126,7 +126,7 @@ this.next_state = this.next_state == 'Enable'? 'Disable' : 'Enable' this.content['enabled'] = this.next_state == 'Enable'? 'false' : 'true' this.details['enabled'] = this.content['enabled'] - this.$kytos.$emit("setNotification", notification) + this.$kytos.eventBus.$emit("setNotification", notification) }, msg_state_failure(data){ let name = this.metadata.link_name !== undefined && this.metadata.link_name.length !== 0? '"' + this.metadata.link_name + '"' : this.details.id @@ -135,7 +135,7 @@ description: data.status + ': ' + data.responseJSON.description + ' The link ' + name + ' was not ' + this.next_state.toLowerCase() + 'd.', icon: 'gear', } - this.$kytos.$emit("setNotification", notification) + this.$kytos.eventBus.$emit("setNotification", notification) }, bt_state_toggle(){ let request = $.ajax({ @@ -164,7 +164,7 @@ title: 'Add metadata: Success', description: '"' + _this.to_add + '" was added to the metadata. Link: ' + name, } - _this.$kytos.$emit("setNotification", notification) + _this.$kytos.eventBus.$emit("setNotification", notification) let temp = JSON.parse(_this.to_add) for (key in temp){ _this.metadata[key] = temp[key] @@ -178,7 +178,7 @@ title: 'Add metadata: Failure', description: data.status + ': ' + data.responseJSON.description + ' "' + _this.to_add + '" was not added to the metadata. Link: ' + name, } - _this.$kytos.$emit("setNotification", notification) + _this.$kytos.eventBus.$emit("setNotification", notification) }); }, bt_rmv_metadata() { @@ -196,7 +196,7 @@ title: 'Delete metadata: Success', description: '"' + _this.to_delete + '" was deleted from the metadata. Link: ' + name, } - _this.$kytos.$emit("setNotification", notification) + _this.$kytos.eventBus.$emit("setNotification", notification) delete _this.metadata[_this.to_delete] delete _this.content.metadata[_this.to_delete] _this.to_delete = '' @@ -207,7 +207,7 @@ title: 'Delete metadata: Failure', description: data.status + ': ' + data.responseJSON.description + ' "' + _this.to_delete + '" was not deleted from the metadata. Link: ' + name, } - _this.$kytos.$emit("setNotification", notification) + _this.$kytos.eventBus.$emit("setNotification", notification) }); }, bt_delete(){ diff --git a/ui/k-info-panel/switch_info.kytos b/ui/k-info-panel/switch_info.kytos index d330060b..87b743a9 100644 --- a/ui/k-info-panel/switch_info.kytos +++ b/ui/k-info-panel/switch_info.kytos @@ -179,7 +179,7 @@ title: 'Could not reach links data (' + data.status + '):', description: data.responseJSON.description, } - this.$kytos.$emit("setNotification", notification); + this.$kytos.eventBus.$emit("setNotification", notification); }, get_links_and_interfaces(){ var self = this @@ -219,7 +219,7 @@ title: 'Add metadata: Success', description: '"' + _this.to_add + '" was added to the metadata. Switch: ' + _this.metadata.id, } - _this.$kytos.$emit("setNotification", notification) + _this.$kytos.eventBus.$emit("setNotification", notification) let temp = JSON.parse(_this.to_add) for (key in temp){ _this.content.metadata[key] = temp[key] @@ -232,7 +232,7 @@ title: 'Add metadata: Failure', description: data.status + ': ' + data.responseJSON.description + ' "' + _this.to_add + '" was not added to the metadata. Switch: ' + _this.metadata.id, } - _this.$kytos.$emit("setNotification", notification) + _this.$kytos.eventBus.$emit("setNotification", notification) }); }, bt_rmv_metadata() { @@ -249,7 +249,7 @@ title: 'Delete metadata: Success', description: '"' + _this.to_delete + '" was deleted from the metadata. Switch: ' + _this.metadata.id, } - _this.$kytos.$emit("setNotification", notification) + _this.$kytos.eventBus.$emit("setNotification", notification) delete _this.content.metadata[_this.to_delete] _this.to_delete = '' }); @@ -259,7 +259,7 @@ title: 'Delete metadata: Failure', description: data.status + ': ' + data.responseJSON.description + ' "' + _this.to_delete + '" was not deleted from the metadata. Switch: ' + _this.metadata.id, } - _this.$kytos.$emit("setNotification", notification) + _this.$kytos.eventBus.$emit("setNotification", notification) }); }, rowClicked (link) { @@ -280,7 +280,7 @@ "subtitle": subtitle, "content": link, } - this.$kytos.$emit("showInfoPanel", content) + this.$kytos.eventBus.$emit("showInfoPanel", content) }, get_enabled_value() { this.next_state = this.metadata.enabled == 'true'? 'Disable' : 'Enable' @@ -294,7 +294,7 @@ this.next_state = this.next_state == 'Enable'? 'Disable' : 'Enable' this.content['enabled'] = this.next_state == 'Enable'? 'false' : 'true' this.metadata['enabled'] = this.content['enabled'] - this.$kytos.$emit("setNotification", notification) + this.$kytos.eventBus.$emit("setNotification", notification) }, msg_state_failure(data){ let notification = { @@ -302,7 +302,7 @@ description: data.status + ': ' + data.responseJSON.description + '. The switch ' + this.metadata.dpid + ' was not ' + this.next_state.toLowerCase() + 'd.', icon: 'gear', } - this.$kytos.$emit("setNotification", notification) + this.$kytos.eventBus.$emit("setNotification", notification) }, bt_state_toggle(){ let request = $.ajax({ @@ -330,7 +330,7 @@ description: 'The interfaces ' + interfaces["interfaces"] + ' is/are ' + _this.chosen_action.toLowerCase() + 'd to send lldp packet', icon: 'gear', } - _this.$kytos.$emit("setNotification", notification) + _this.$kytos.eventBus.$emit("setNotification", notification) }) request.fail(function(data){ let notification = { @@ -338,7 +338,7 @@ description: data.status + ': ' + data.responseJSON.description + ' The interfaces ' + interfaces["interfaces"] + ' is/are not ' + _this.chosen_action.toLowerCase() + 'd to send lldp packet', icon: 'gear', } - _this.$kytos.$emit("setNotification", notification) + _this.$kytos.eventBus.$emit("setNotification", notification) }) }, bt_delete(){ From 59b5adf01c42438988a2fb488aec2e47e5bd406e Mon Sep 17 00:00:00 2001 From: rmotitsuki Date: Wed, 10 Jan 2024 14:03:18 -0300 Subject: [PATCH 2/7] replace :value.sync for v-model:value --- ui/k-action-menu/search_switch.kytos | 2 +- ui/k-info-panel/link_info.kytos | 4 ++-- ui/k-info-panel/switch_info.kytos | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/k-action-menu/search_switch.kytos b/ui/k-action-menu/search_switch.kytos index 3e36b1c4..163b1cd1 100644 --- a/ui/k-action-menu/search_switch.kytos +++ b/ui/k-action-menu/search_switch.kytos @@ -1,6 +1,6 @@