-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
445 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<script setup lang="ts"> | ||
import OpenApiEditObject from './OpenApiEditObject.vue'; | ||
import OpenApiEditArray from './OpenApiEditArray.vue'; | ||
import OpenApiEditBoolean from './OpenApiEditBoolean.vue'; | ||
import OpenApiEditString from './OpenApiEditString.vue'; | ||
import OpenApiEditNumber from './OpenApiEditNumber.vue'; | ||
import { ref, watch } from 'vue' | ||
import {getProperties,getItems,getType, getFullData} from '../../libs/core/openapiSetup'; | ||
import { OpenAPIV3 } from "openapi-types"; | ||
const prompt = ref(false); | ||
const newName = ref(''); | ||
const props = withDefaults(defineProps<{ | ||
name: string | ||
data: object | ||
defaultdata?: object | ||
properties: Map<string, OpenAPIV3.SchemaObject> | ||
readOnly?: boolean | ||
showDefault?: boolean | ||
}>(), { | ||
readOnly: false, | ||
showDefault: true | ||
}); | ||
const out_handler= props.data; | ||
getFullData(props.properties,out_handler,props.data); | ||
const out = ref(out_handler) | ||
const emit = defineEmits(['update:data']) | ||
watch(out,(newValue) => emit('update:data', newValue),{ deep: true }) | ||
function handleAdd(evt) { | ||
prompt.value = true; | ||
evt.preventDefault(); | ||
evt.stopPropagation(); | ||
} | ||
function onAdd() { | ||
out.value[newName.value] = ''; | ||
} | ||
</script> | ||
<template> | ||
<q-dialog v-model="prompt" persistent> | ||
<q-card style="min-width: 350px"> | ||
<q-card-section> | ||
<div class="text-subtitle">New property name</div> | ||
</q-card-section> | ||
<q-card-section class="q-pt-none"> | ||
<q-input dense v-model="newName" autofocus @keyup.enter="prompt = false" /> | ||
</q-card-section> | ||
<q-card-actions align="right" class="text-primary"> | ||
<q-btn flat label="Cancel" v-close-popup /> | ||
<q-btn flat label="Add" v-close-popup @click="onAdd" /> | ||
</q-card-actions> | ||
</q-card> | ||
</q-dialog> | ||
<q-expansion-item :label="name" :default-opened="name=='stringData' && !readOnly"> | ||
<template v-slot:header="{expanded}"> | ||
<q-item-section> | ||
{{name}} | ||
</q-item-section> | ||
<q-item-section v-if="expanded && !readOnly" side> | ||
<q-btn icon="add" flat @click="handleAdd"> | ||
<q-tooltip>add</q-tooltip> | ||
</q-btn> | ||
</q-item-section> | ||
</template> | ||
<div class="q-gutter-md column q-ml-sm" :key="`${Object.keys(out)}`"> | ||
<div v-for="[key, value] in new Map(Object.entries(out))" v-bind:key="key" | ||
:style="getType(value)=='string'?key=='name'?'order: 1':'order: 2':['number','integer'].includes(getType(value))?'order: 3':getType(value)=='boolean'?'order: 1':getType(value)=='array'?'order: 5':'order: 4'"> | ||
<OpenApiEditString v-if="out[key]!=undefined" v-model:data="out[key]" :name="key" :read-only="readOnly" :use-delete="!readOnly" @delete="(k)=>{out[k]=undefined;console.log(k,out[k])}" /> | ||
</div> | ||
</div> | ||
</q-expansion-item> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<script setup lang="ts"> | ||
// noGramoGenerator | ||
import k8sSecretQuery from '@/queries/k8s/Secret.read.graphql' | ||
import SecretEdit from '@/queries/k8s/Secret.patch.graphql' | ||
import k8sSecretMeta from '@/components/k8s/SecretMeta.vue'; | ||
import k8sSecretEdit from '@/components/k8s/SecretEdit.vue'; | ||
import { ref, useQuery, sanitizeData, useMutation, useSecret, SecretSimpleExcludes } from '../../../libs/k8s/Secret.js' | ||
const { onErrorHandler, patchDone, patchError, notifyWorking, onNotSecretFound, navigation, setNamespacedItemFromRoute } = useSecret();setNamespacedItemFromRoute(); | ||
const { result, loading, onResult, onError } = useQuery(k8sSecretQuery, { | ||
"obj": { | ||
"filters": [ | ||
{ | ||
"op": "eq", | ||
"path": "metadata/name", | ||
"value": navigation.currentItem | ||
} | ||
], "excludes": SecretSimpleExcludes | ||
}, | ||
"namespace": { | ||
"filters": [ | ||
{ | ||
"op": "eq", | ||
"path": "metadata/name", | ||
"value": navigation.currentNamespace | ||
} | ||
] | ||
} | ||
}); | ||
const { mutate: patchSecret, onDone: onPatchSecret, onError: onPatchError } = useMutation(SecretEdit); | ||
function onSubmit(obj:object) { | ||
notifyWorking('Update in progress'); | ||
patchSecret({ | ||
"name": result.value.k8sNamespace[0].k8sSecret[0].metadata.name, | ||
"namespace": result.value.k8sNamespace[0].k8sSecret[0].metadata.namespace, | ||
...obj | ||
}); | ||
} | ||
onError(onErrorHandler); | ||
const secret = ref({stringData:{}}) | ||
onResult(res => { | ||
onNotSecretFound(res); | ||
if ( !res.loading ) { | ||
if (Array.isArray(res.data.k8sNamespace) && res.data.k8sNamespace.map(ns=>ns['k8sSecret']).flat().length>0) { | ||
secret.value = {...secret.value, ...res.data.k8sNamespace.map(ns=>ns['k8sSecret']).flat()[0], data: JSON.parse(JSON.stringify(res.data.k8sNamespace.map(ns=>ns['k8sSecret']).flat()[0]['data']))}; | ||
console.log(secret.value, secret.value['data']) | ||
secret.value['stringData'] = secret.value['stringData']==undefined?{}:secret.value['stringData']; | ||
if (typeof secret.value['data'] === 'object') Object.keys(secret.value['data']).forEach(key=>{ | ||
try { | ||
secret.value['stringData'][key] = atob(secret.value['data'][key]) | ||
secret.value['data'][key] = undefined | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}) | ||
} | ||
} | ||
}); | ||
onPatchSecret(patchDone);onPatchError(patchError); | ||
</script> | ||
<template> | ||
<div class="row q-mb-sm q-ml-sm"> | ||
<div class="col-md-12"> | ||
<k8sSecretMeta :useActions="false" :showStatus="false" | ||
v-if="!loading && result!=undefined && Array.isArray(result.k8sNamespace) && result.k8sNamespace[0].k8sSecret[0]!=undefined && result.k8sNamespace[0].k8sSecret[0]!=null" | ||
:model="result.k8sNamespace[0].k8sSecret[0]" | ||
/> | ||
</div> | ||
<div class="col-md-12"> | ||
<k8sSecretEdit | ||
v-if="!loading && secret['metadata']!=null" | ||
:model="sanitizeData(secret)" | ||
@on-submit="onSubmit" | ||
/> | ||
</div> | ||
</div> | ||
</template> | ||
|
Oops, something went wrong.