diff --git a/.gitignore b/.gitignore index 62392df..315ec5a 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ !/front/pages/install/vynil/InstallEdit.vue !/front/pages/install/vynil/InstallNew.vue !/front/pages/install/vynil/installDashboard.vue +!/front/pages/config/k8s/SecretView.vue +!/front/pages/config/k8s/SecretEdit.vue diff --git a/front/components/core/OpenApiEdit.vue b/front/components/core/OpenApiEdit.vue index 4467550..f0c2ec7 100644 --- a/front/components/core/OpenApiEdit.vue +++ b/front/components/core/OpenApiEdit.vue @@ -1,6 +1,7 @@ - + diff --git a/front/components/core/OpenApiEditNumber.vue b/front/components/core/OpenApiEditNumber.vue index 4d0ce3d..d14c884 100644 --- a/front/components/core/OpenApiEditNumber.vue +++ b/front/components/core/OpenApiEditNumber.vue @@ -18,7 +18,7 @@ const isDefault=computed(() => value.value == props.defaultdata || (props.defaul - + @@ -27,8 +27,8 @@ const isDefault=computed(() => value.value == props.defaultdata || (props.defaul - - + + diff --git a/front/components/core/OpenApiEditString.vue b/front/components/core/OpenApiEditString.vue index c546f59..7600790 100644 --- a/front/components/core/OpenApiEditString.vue +++ b/front/components/core/OpenApiEditString.vue @@ -5,30 +5,38 @@ const props = withDefaults(defineProps<{ name: string data: string|null defaultdata?: string, - readOnly?: boolean + readOnly?: boolean, + useDelete?: boolean }>(), { - readOnly: false + readOnly: false, + useDelete: false, }); const value=ref(props.data) -const emit = defineEmits(['update:data']) +const emit = defineEmits(['update:data', 'delete']) watch(value,(newValue) => emit('update:data', newValue)) const isDefault=computed(() => value.value == props.defaultdata || (props.defaultdata ==undefined && value.value == null)) - + - {{ value }} + {{ value }} + {{ value }} - - - + + + + + Delete + diff --git a/front/components/core/OpenApiEditUndefObject.vue b/front/components/core/OpenApiEditUndefObject.vue new file mode 100644 index 0000000..76b9db7 --- /dev/null +++ b/front/components/core/OpenApiEditUndefObject.vue @@ -0,0 +1,71 @@ + + + + + + New property name + + + + + + + + + + + + + + {{name}} + + + + add + + + + + + {out[k]=undefined;console.log(k,out[k])}" /> + + + + diff --git a/front/components/core/OpenApiNamedIcon.vue b/front/components/core/OpenApiNamedIcon.vue index 66f6d51..31e7645 100644 --- a/front/components/core/OpenApiNamedIcon.vue +++ b/front/components/core/OpenApiNamedIcon.vue @@ -6,18 +6,20 @@ defineProps<{ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/front/libs/core/openapiSetup.ts b/front/libs/core/openapiSetup.ts index b27121b..7b083a0 100644 --- a/front/libs/core/openapiSetup.ts +++ b/front/libs/core/openapiSetup.ts @@ -1,7 +1,9 @@ import { OpenAPIV3 } from "openapi-types"; -export function getProperties(val) { - if (val != undefined && val['properties'] != undefined) +export function getProperties(val, filter=undefined) { + if (val != undefined && val['properties'] != undefined && filter == undefined) return new Map(Object.entries(val.properties)); + if (val != undefined && val['properties'] != undefined && filter != undefined) + return new Map(Object.entries(val.properties).filter(filter)); return new Map() } export function getItems(val) { diff --git a/front/pages/config/k8s/SecretEdit.vue b/front/pages/config/k8s/SecretEdit.vue new file mode 100644 index 0000000..04a5582 --- /dev/null +++ b/front/pages/config/k8s/SecretEdit.vue @@ -0,0 +1,77 @@ + + + + + + + + + + + + diff --git a/front/pages/config/k8s/SecretView.vue b/front/pages/config/k8s/SecretView.vue new file mode 100644 index 0000000..8ccccfa --- /dev/null +++ b/front/pages/config/k8s/SecretView.vue @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {actionDelete(deletor, meta)}" + /> + + + + + diff --git a/package.json b/package.json index fb608b4..c3e9e26 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gramo", - "version": "0.1.0", + "version": "0.1.1", "description": "A Kubernetes front-end", "main": "index.js", "scripts": { diff --git a/utils/generator/back/tmpl.patch.resolver.ts.hbs b/utils/generator/back/tmpl.patch.resolver.ts.hbs index cdfdc42..742f2fa 100644 --- a/utils/generator/back/tmpl.patch.resolver.ts.hbs +++ b/utils/generator/back/tmpl.patch.resolver.ts.hbs @@ -26,7 +26,7 @@ {{/if}} {{else}} {{#if namespaced}} - const resGet = await k8sApi.readNamespaced{{ short }}(args['namespace'], args['name']) + const resGet = await k8sApi.readNamespaced{{ short }}(args['name'], args['namespace']) {{else}} const resGet = await k8sApi.read{{ short }}(args['name']) {{/if}} @@ -41,7 +41,7 @@ {{/if}} {{else}} {{#if namespaced}} - const res = await k8sApi.patchNamespaced{{ short }}(args['namespace'], args['name'], payload, undefined, undefined, undefined, undefined, undefined, options) + const res = await k8sApi.patchNamespaced{{ short }}(args['name'], args['namespace'], payload, undefined, undefined, undefined, undefined, undefined, options) {{else}} const res = await k8sApi.patch{{ short }}(args['name'], payload, undefined, undefined, undefined, undefined, undefined, options) {{/if}} diff --git a/utils/generator/front/obj.components.edit.vue.hbs b/utils/generator/front/obj.components.edit.vue.hbs index 20ba84b..49ad258 100644 --- a/utils/generator/front/obj.components.edit.vue.hbs +++ b/utils/generator/front/obj.components.edit.vue.hbs @@ -5,9 +5,9 @@ import MonacoEditor from '@/components/core/MonacoEditor.vue'; import { use{{ short }}, sanitizeData, getProperties, {{ short }}Definition } from '../../libs/{{ group }}/{{ short }}.js' import { color{{ short }}, icon{{ short }} } from '../../libs/{{ group }}/custom.js' {{#if namespaced}} -const { onlyWriteProperties, editor, setNamespacedItemFromRoute } = use{{ short }}();setNamespacedItemFromRoute(); +const { writeProperties, onlyWriteProperties, editor, setNamespacedItemFromRoute } = use{{ short }}();setNamespacedItemFromRoute(); {{else}} -const { onlyWriteProperties, editor, setItemFromRoute } = use{{ short }}();setItemFromRoute(); +const { writeProperties, onlyWriteProperties, editor, setItemFromRoute } = use{{ short }}();setItemFromRoute(); {{/if}} const emit = defineEmits(['on-submit']) const props = defineProps<{model: object}>(); @@ -15,11 +15,7 @@ onMounted(() => { editor.value.updateFromQuery(onlyWriteProperties(props.model)); }) function onSubmit() { - emit('on-submit', { -{{#each writeProperties}} - "{{this}}": sanitizeData(editor.value.obj.{{this}}), -{{/each}} - }); + emit('on-submit', sanitizeData(editor.value.obj)); } const setkey = (key:string, v) => editor.value.setKey(key, v) const setYaml = (v) => editor.value.setYaml(v) @@ -38,27 +34,23 @@ const setYaml = (v) => editor.value.setYaml(v) -{{#each writeProperties}} - {{#if (isJsonObject this ../gqlDefs)}} setkey('{{this}}', {...model['{{this}}'],options:sanitizeData(v)})" - :in="editor.obj['{{this}}']['options']" +{{#if (and (eq group 'vynil') (eq short 'Install'))}} + @update:out="(v)=>setkey('spec', {...model['spec'],options:sanitizeData(v)})" + :in="editor.obj['spec']['options']" :properties="new Map(Object.entries(model.consumePackage.options))" {{else}} - @update:out="(v)=>setkey('{{this}}', sanitizeData(v))" - :in="editor.obj['{{this}}']" - :properties="getProperties({{ ../short }}Definition.properties.{{this}})" + @update:out="(v)=>setkey(null, sanitizeData(v))" + :in="editor.obj" + :properties="getProperties({{ short }}Definition,([k])=>writeProperties.includes(k))" {{/if}} /> - {{/if}} -{{/each}} setYaml(v)" -{{#if (and (eq ../group 'vynil') (eq ../short 'Install'))}} +{{#if (and (eq group 'vynil') (eq short 'Install'))}} :properties="getProperties({properties: model.consumePackage.options})" {{else}} :properties="getProperties({properties: Object.fromEntries(Object.entries({{ short }}Definition).filter(([n])=>!['metadata','status'].includes(n)))})" diff --git a/utils/generator/front/obj.components.view.vue.hbs b/utils/generator/front/obj.components.view.vue.hbs index 0d1e19c..fb6e8db 100644 --- a/utils/generator/front/obj.components.view.vue.hbs +++ b/utils/generator/front/obj.components.view.vue.hbs @@ -6,9 +6,9 @@ import MonacoViewer from '@/components/core/MonacoViewer.vue'; import { use{{ short }}, getProperties, {{ short }}Definition } from '../../libs/{{ group }}/{{ short }}.js' import { color{{ short }}, icon{{ short }} } from '../../libs/{{ group }}/custom.js' {{#if namespaced}} -const { onlyReadProperties, toParentView, viewer, viewerUpdate, toEdit, actionDelete, setNamespacedItemFromRoute } = use{{ short }}();setNamespacedItemFromRoute(); +const { writeProperties, onlyReadProperties, toParentView, viewer, viewerUpdate, toEdit, actionDelete, setNamespacedItemFromRoute } = use{{ short }}();setNamespacedItemFromRoute(); {{else}} -const { onlyReadProperties, toParentView, viewer, viewerUpdate, toEdit, actionDelete, setItemFromRoute } = use{{ short }}();setItemFromRoute(); +const { writeProperties, onlyReadProperties, toParentView, viewer, viewerUpdate, toEdit, actionDelete, setItemFromRoute } = use{{ short }}();setItemFromRoute(); {{/if}} defineEmits(['on-delete']); const showLink = false; @@ -60,21 +60,17 @@ onMounted(() => { -{{#each writeProperties}} - {{#if (isJsonObject this ../gqlDefs)}} - {{/if}} -{{/each}} {{#each writeProperties}} {{#if (isJsonObject this ../gqlDefs)}} diff --git a/utils/generator/front/obj.lib.ts.hbs b/utils/generator/front/obj.lib.ts.hbs index 7b4036e..192491d 100644 --- a/utils/generator/front/obj.lib.ts.hbs +++ b/utils/generator/front/obj.lib.ts.hbs @@ -49,7 +49,14 @@ export function use{{ short }}() { tab: 'simple', yaml: '', obj: ref({}), - setKey: (key:string, o) => {editor.value.obj[key] = o;editor.value.yaml = stringify(editor.value.obj)}, + setKey: (key:string, o:object) => { + if (key!=null) { + editor.value.obj[key] = o;editor.value.yaml = stringify(editor.value.obj) + } else { + Object.keys(o).forEach(key=>{editor.value.obj[key] = o[key]}) + editor.value.yaml = stringify(editor.value.obj) + } + }, ready: false, setYaml: (y) => {editor.value.yaml = y;const tmp = parse(y);Object.keys(tmp).forEach(k=>editor.value.obj[k]=tmp[k]);}, updateFromQuery: (obj: object) => { @@ -66,6 +73,8 @@ export function use{{ short }}() { viewer.value.props["{{this}}"]=gqlDataToYaml({"{{this}}": obj["{{this}}"]}) {{/each}} }, + readProperties: {{toJson readProperties}}, + writeProperties: {{toJson writeProperties}}, navigation: useNavigationStoreRef(), {{#if namespaced}} isNamespaced, setNamespaceFromRoute, setNamespacedItemFromRoute, diff --git a/utils/generator/front/obj.pages.edit.vue.hbs b/utils/generator/front/obj.pages.edit.vue.hbs index 5f24bc6..27cdcfe 100644 --- a/utils/generator/front/obj.pages.edit.vue.hbs +++ b/utils/generator/front/obj.pages.edit.vue.hbs @@ -38,11 +38,11 @@ const { mutate: patch{{ short }}, onDone: onPatch{{ short }}, onError: onPatchEr function onSubmit(obj:object) { notifyWorking('Update in progress'); patch{{ short }}({ + ...obj, "name": result.value{{#if namespaced}}.k8sNamespace[0]{{/if}}.{{ group }}{{ short }}[0].metadata.name, {{#if namespaced}} "namespace": result.value{{#if namespaced}}.k8sNamespace[0]{{/if}}.{{ group }}{{ short }}[0].metadata.namespace, {{/if}} - ...obj }); } onError(onErrorHandler);onResult(onNot{{ short }}Found);onPatch{{ short }}(patchDone);onPatchError(patchError);
{{ value }}