From 1ea1288a4b266290872931936cc012c82f9e4ca1 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Fri, 15 Feb 2019 14:55:06 +0000 Subject: [PATCH] Added rudimentary host saving --- src/components/paneConnect.vue | 80 +++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 7 deletions(-) diff --git a/src/components/paneConnect.vue b/src/components/paneConnect.vue index 107a4052..dedd577b 100644 --- a/src/components/paneConnect.vue +++ b/src/components/paneConnect.vue @@ -1,12 +1,14 @@ @@ -46,6 +64,26 @@ export default { name: 'paneConnect', + data: function () { + return { + hostname: "localhost", + port: 5000, + selectedHost: "", + savedHosts: [ + { + name: "local", + hostname: "localhost", + port: 80 + }, + { + name: "test", + hostname: "192.168.1.126", + port: 5000 + } + ] + } + }, + methods: { handleSubmit: function(event) { if (this.hostname.includes(':')) { @@ -59,14 +97,31 @@ export default { ]); // Try to get config and state JSON from the newly submitted host this.$store.dispatch('firstConnect') - } - }, + }, + + autofillHost: function (host) { + this.hostname = host.hostname; + this.port = host.port + }, + + delSavedHost: function (host) { + console.log(host) + var index = this.savedHosts.indexOf(host); + if (index > -1) { + this.savedHosts.splice(index, 1); + } + }, + + saveHost: function() { + this.savedHosts.push( + { + name: this.$store.state.apiConfig.name, + hostname: this.$store.state.host, + port: this.$store.state.port + } + ) + }, - data: function () { - return { - hostname: "localhost", - port: 5000 - } }, computed: { @@ -94,6 +149,17 @@ export default { this.hostname = this.hostname.split(':')[0] + ":" + this.port } } + }, + + computedSelectedHost: { + get: function() { + return this.selectedHost + }, + set: function(host) { + this.selectedHost = host; + this.hostname = host.hostname; + this.port = host.port; + } } }