Skip to content

Commit d9fd63b

Browse files
added missing funcions
Signed-off-by: Sourav Roy <souravroy@appscode.com>
1 parent 68ff4f9 commit d9fd63b

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

charts/kubedbcom-milvus-editor/ui/functions.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,38 @@ export const useFunc = (model) => {
332332
return discriminatorValue === value
333333
}
334334

335+
function isValueExistInModel(path) {
336+
const modelValue = getValue(model, path) || null
337+
return !!modelValue
338+
}
339+
340+
function getOpsRequestUrl(reqType) {
341+
const cluster = storeGet('/route/params/cluster')
342+
const domain = storeGet('/domain') || ''
343+
const owner = storeGet('/route/params/user')
344+
const dbname = getValue(model, '/metadata/release/name')
345+
const group = getValue(model, '/metadata/resource/group')
346+
const kind = getValue(model, '/metadata/resource/kind')
347+
const namespace = getValue(model, '/metadata/release/namespace')
348+
const resource = getValue(model, '/metadata/resource/name')
349+
const version = getValue(model, '/metadata/resource/version')
350+
const routeRootPath = storeGet('/route/path')
351+
const pathPrefix = `${domain}/db${routeRootPath}`
352+
const pathSplit = pathPrefix.split('/').slice(0, -1).join('/')
353+
const pathConstructedForKubedb = pathSplit + `/${reqType.toLowerCase()}?namespace=${namespace}`
354+
const isKube = !!storeGet('/route/params/actions')
355+
if (isKube) return pathConstructedForKubedb
356+
else
357+
return `${domain}/console/${owner}/kubernetes/${cluster}/ops.kubedb.com/v1alpha1/milvusopsrequests/create?name=${dbname}&namespace=${namespace}&group=${group}&version=${version}&resource=${resource}&kind=${kind}&page=operations&requestType=VerticalScaling`
358+
}
359+
360+
function initMonitoring() {
361+
const exporter = getValue(model, '/resources/kubedbComMilvus/spec/monitor/prometheus/exporter')
362+
if (!exporter) {
363+
setDiscriminatorValue('/customizeExporter', false)
364+
}
365+
}
366+
335367
async function resourceNames(group, version, resource) {
336368
const owner = storeGet('/route/params/user')
337369
const cluster = storeGet('/route/params/cluster')
@@ -408,6 +440,9 @@ export const useFunc = (model) => {
408440
disableLableChecker,
409441
isEqualToModelPathValue,
410442
isEqualToDiscriminatorPath,
443+
isValueExistInModel,
444+
getOpsRequestUrl,
445+
initMonitoring,
411446
getCreateAuthSecret,
412447
onCreateAuthSecretChange,
413448
showExistingSecretSection,

0 commit comments

Comments
 (0)