From bb3c0e0082f07b90fb5a53ebdb0e9ecbadb67681 Mon Sep 17 00:00:00 2001 From: Gustavo Coelho Date: Fri, 4 Sep 2020 22:32:20 -0300 Subject: [PATCH 1/4] Edit form Signed-off-by: Gustavo Coelho --- src/App.svelte | 3 +- src/Ips.svelte | 11 +++++-- src/Services.svelte | 3 ++ src/forms/AppForm.svelte | 23 +++++++++++--- src/forms/BasicForm.svelte | 62 +++++++++++++++++++++++++++++++++----- src/store/form.js | 3 ++ 6 files changed, 90 insertions(+), 15 deletions(-) create mode 100644 src/store/form.js diff --git a/src/App.svelte b/src/App.svelte index 3de5c0d..c0cc048 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -36,6 +36,7 @@
+ @@ -89,7 +90,7 @@ { icon: 'apps', value: 'apps', - text: 'Aplications', + text: 'Aplicações', link: '/apps', component: Services }, diff --git a/src/Ips.svelte b/src/Ips.svelte index 6c59a4b..491310d 100644 --- a/src/Ips.svelte +++ b/src/Ips.svelte @@ -96,8 +96,8 @@
-
- +
+
+ \ No newline at end of file diff --git a/src/Services.svelte b/src/Services.svelte index db84e72..c3929a3 100644 --- a/src/Services.svelte +++ b/src/Services.svelte @@ -5,6 +5,7 @@ import IconButton, {Icon} from '@smui/icon-button'; import { navigate } from "svelte-routing"; import { appName } from './store/app.js'; + import { dataId } from './store/form.js'; import api from './api/' let apps = [] let kitchen @@ -46,6 +47,8 @@ navigate(`new/app`) } const editApp = (app) => { + console.log('edit app', app) + dataId.update(t => app) navigate(`edit/app`) } const deployPage = (app) => { diff --git a/src/forms/AppForm.svelte b/src/forms/AppForm.svelte index d3d7581..bc21963 100644 --- a/src/forms/AppForm.svelte +++ b/src/forms/AppForm.svelte @@ -10,8 +10,10 @@ import FloatingLabel from '@smui/floating-label'; import NotchedOutline from '@smui/notched-outline'; import { navigate } from "svelte-routing"; + import { beforeUpdate, afterUpdate } from 'svelte'; import api from '../api/' export let data = {} + export let edit = false let namespace = '' let desc = '' let name = '' @@ -62,10 +64,11 @@ let schemes = ['https', 'http'] console.log('err list Settings', err) } } - + beforeUpdate(() => { + console.log('teste') + }) onMount(() => { - console.log('data', data) - listSettings() + console.log('data on app form on mount', data) if (!Object.keys(data)) { data = { namespace: '', @@ -77,7 +80,19 @@ let schemes = ['https', 'http'] tls: false, level: 1 } + } else { + namespace = data._namespace || data.namespace + desc = data._desc || data.desc + name = data._name || data.name + scrapePath = data._scrapePath || data.scrapePath + ips = data._ips || data.ips + scheme = data._scheme || data.scheme + tls = data._tls || data.tls + level = data._level || data.level } + + listSettings() + console.log('data on app form on mount', data) }) @@ -92,7 +107,7 @@ let schemes = ['https', 'http']
- +