diff --git a/console/ui/index.html b/console/ui/index.html index 6ea1629..ec331b5 100644 --- a/console/ui/index.html +++ b/console/ui/index.html @@ -22,6 +22,7 @@ +
diff --git a/console/ui/js/app.js b/console/ui/js/app.js new file mode 100644 index 0000000..300fbd7 --- /dev/null +++ b/console/ui/js/app.js @@ -0,0 +1,70 @@ +/* app.js — основная логика: загрузка данных, таблица функций */ + +async function reloadAll() { + try { + const [envs, pkgs, fns, http, times] = await Promise.all([ + getJSON(API_BASE + '/environments'), + getJSON(API_BASE + '/packages'), + getJSON(API_BASE + '/functions'), + getJSON(API_BASE + '/httptriggers'), + getJSON(API_BASE + '/timetriggers') + ]); + + S.envs = envs || []; + S.fns = fns || []; + S.httpTriggers = http || []; + S.timeTriggers = times || []; + + setText('env-count', envs.length || 0); + setText('pkg-count', pkgs.length || 0); + setText('fn-count', fns.length || 0); + setText('http-count', http.length || 0); + setText('cron-count', new Set((times || []).map(function (t) { + return t && t.spec && t.spec.functionref && t.spec.functionref.name; + }).filter(Boolean)).size); + + const rows = (fns || []).map(function (f) { + const spec = f.spec || {}; + const meta = f.metadata || {}; + const ann = meta.annotations || {}; + const env = (spec.environment && spec.environment.name) || '-'; + const pkg = (spec.package && spec.package.packageref && spec.package.packageref.name) || '-'; + const name = (f.metadata && f.metadata.name) || '-'; + const trig = httpTriggerByFn(name) || {}; + const timeTrig = timeTriggerByFn(name) || {}; + const route = (trig.spec && trig.spec.relativeurl) || '-'; + const methods = (trig.spec && trig.spec.methods) || []; + const chips = methods.map(function (m) { return '' + h(m) + ''; }).join(''); + const cron = (timeTrig.spec && timeTrig.spec.cron) || ''; + const cronCell = cron ? '' + h(cron) + '' : '—'; + const createdAt = ann['fission-console/created-at'] || meta.creationTimestamp || '-'; + const updatedAt = ann['fission-console/updated-at'] || createdAt; + var isGo = /go[-_]env/.test(env); + var isTf = /^tf-/.test(name); + var tfBadge = (isGo || isTf) ? 'TF ' : ''; + var actions = tfBadge + + ' ' + + ' ' + + ''; + return '