From d1ad775f3695be90c2b7852ce2168f5799105e38 Mon Sep 17 00:00:00 2001 From: rmotitsuki Date: Thu, 2 Sep 2021 12:36:49 -0300 Subject: [PATCH] New input autocomplete for DPID --- ui/k-toolbar/main.kytos | 58 +++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/ui/k-toolbar/main.kytos b/ui/k-toolbar/main.kytos index 4da5d7f4..592687ce 100644 --- a/ui/k-toolbar/main.kytos +++ b/ui/k-toolbar/main.kytos @@ -6,17 +6,27 @@ title="Circuit Name:" tooltip="Circuit name" placeholder="Circuit Name" icon="pencil"> - + placeholder="First endpoint" icon="arrow-right" + :candidates="dpids" + @focus="fetchDpids" + v-if="compexists" + > + - - @@ -24,14 +34,24 @@ + placeholder="Last endpoint" icon="arrow-left" + :candidates="dpids" + @focus="fetchDpids" + v-if="compexists"> + + - - @@ -59,7 +79,9 @@ module.exports = { tag_value_a: "", endpoint_z: "", tag_type_z: "", - tag_value_z: "" + tag_value_z: "", + dpids: [""], + hasAutoComplete:false } }, methods: { @@ -119,7 +141,27 @@ module.exports = { circuit_request.done(this.post_success) circuit_request.fail(this.post_error) + }, + fetchDpids: function() { + var self = this // create a closure to access component in the callback below + dataUrl = "/api/kytos/topology/v3/interfaces" + // Autocomplete usage example. + fetch(dataUrl).then(response => response.json()) + .then(data => { + dpids = [] + for ( const [key,value] of Object.entries( data.interfaces ) ) { + dpids.push(key) + } + self.dpids = dpids + }) } + }, + mounted() { // when the Vue app is booted up, this is run automatically. + this.fetchDpids(); + compexists = this.$root.$options.components['k-input-auto'] != null; + }, + created() { + compexists = this.$root.$options.components['k-input-auto'] != null; } }