debian-mirror-gitlab/app/assets/javascripts/serverless/serverless_bundle.js

76 lines
2 KiB
JavaScript
Raw Normal View History

2019-02-15 15:39:39 +05:30
import Vue from 'vue';
import Functions from './components/functions.vue';
2019-03-02 22:35:43 +05:30
import FunctionDetails from './components/function_details.vue';
2019-07-07 11:18:12 +05:30
import { createStore } from './store';
2019-02-15 15:39:39 +05:30
export default class Serverless {
constructor() {
2019-03-02 22:35:43 +05:30
if (document.querySelector('.js-serverless-function-details-page') != null) {
const {
serviceName,
serviceDescription,
serviceEnvironment,
serviceUrl,
serviceNamespace,
servicePodcount,
2019-07-07 11:18:12 +05:30
serviceMetricsUrl,
prometheus,
clustersPath,
helpPath,
2019-03-02 22:35:43 +05:30
} = document.querySelector('.js-serverless-function-details-page').dataset;
const el = document.querySelector('#js-serverless-function-details');
2019-02-15 15:39:39 +05:30
2019-03-02 22:35:43 +05:30
const service = {
name: serviceName,
description: serviceDescription,
environment: serviceEnvironment,
url: serviceUrl,
namespace: serviceNamespace,
podcount: servicePodcount,
2019-07-07 11:18:12 +05:30
metricsUrl: serviceMetricsUrl,
2019-03-02 22:35:43 +05:30
};
2019-02-15 15:39:39 +05:30
2019-03-02 22:35:43 +05:30
this.functionDetails = new Vue({
el,
2019-07-07 11:18:12 +05:30
store: createStore(),
2019-03-02 22:35:43 +05:30
render(createElement) {
return createElement(FunctionDetails, {
props: {
2019-07-07 11:18:12 +05:30
func: service,
hasPrometheus: prometheus !== undefined,
clustersPath,
helpPath,
2019-03-02 22:35:43 +05:30
},
});
},
});
} else {
2019-09-04 21:01:54 +05:30
const { statusPath, clustersPath, helpPath } = document.querySelector(
2019-03-02 22:35:43 +05:30
'.js-serverless-functions-page',
).dataset;
2019-07-07 11:18:12 +05:30
const el = document.querySelector('#js-serverless-functions');
this.functions = new Vue({
el,
store: createStore(),
render(createElement) {
return createElement(Functions, {
props: {
clustersPath,
helpPath,
statusPath,
},
});
},
});
2019-05-30 16:15:17 +05:30
}
}
2019-02-15 15:39:39 +05:30
destroy() {
this.destroyed = true;
this.functions.$destroy();
2019-03-02 22:35:43 +05:30
this.functionDetails.$destroy();
2019-02-15 15:39:39 +05:30
}
}