2018-12-06 13:08:49 -05:00
|
|
|
import Vue from 'vue';
|
2018-12-17 02:31:38 -05:00
|
|
|
import FunctionDetails from './components/function_details.vue';
|
2021-02-14 13:09:20 -05:00
|
|
|
import Functions from './components/functions.vue';
|
2019-04-05 22:02:39 -04:00
|
|
|
import { createStore } from './store';
|
2018-12-06 13:08:49 -05:00
|
|
|
|
|
|
|
export default class Serverless {
|
|
|
|
constructor() {
|
2018-12-17 02:31:38 -05:00
|
|
|
if (document.querySelector('.js-serverless-function-details-page') != null) {
|
2020-07-21 11:09:40 -04:00
|
|
|
const entryPointData = document.querySelector('.js-serverless-function-details-page').dataset;
|
|
|
|
const store = createStore(entryPointData);
|
|
|
|
|
2018-12-17 02:31:38 -05:00
|
|
|
const {
|
|
|
|
serviceName,
|
|
|
|
serviceDescription,
|
|
|
|
serviceEnvironment,
|
|
|
|
serviceUrl,
|
|
|
|
serviceNamespace,
|
|
|
|
servicePodcount,
|
2019-04-05 22:02:39 -04:00
|
|
|
serviceMetricsUrl,
|
|
|
|
prometheus,
|
2020-07-21 11:09:40 -04:00
|
|
|
} = entryPointData;
|
2018-12-17 02:31:38 -05:00
|
|
|
const el = document.querySelector('#js-serverless-function-details');
|
2018-12-06 13:08:49 -05:00
|
|
|
|
2018-12-17 02:31:38 -05:00
|
|
|
const service = {
|
|
|
|
name: serviceName,
|
|
|
|
description: serviceDescription,
|
|
|
|
environment: serviceEnvironment,
|
|
|
|
url: serviceUrl,
|
|
|
|
namespace: serviceNamespace,
|
|
|
|
podcount: servicePodcount,
|
2019-04-05 22:02:39 -04:00
|
|
|
metricsUrl: serviceMetricsUrl,
|
2018-12-17 02:31:38 -05:00
|
|
|
};
|
2018-12-06 13:08:49 -05:00
|
|
|
|
2018-12-17 02:31:38 -05:00
|
|
|
this.functionDetails = new Vue({
|
|
|
|
el,
|
2020-07-21 11:09:40 -04:00
|
|
|
store,
|
2018-12-17 02:31:38 -05:00
|
|
|
render(createElement) {
|
|
|
|
return createElement(FunctionDetails, {
|
|
|
|
props: {
|
2019-04-05 22:02:39 -04:00
|
|
|
func: service,
|
|
|
|
hasPrometheus: prometheus !== undefined,
|
2018-12-17 02:31:38 -05:00
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else {
|
2020-07-21 11:09:40 -04:00
|
|
|
const entryPointData = document.querySelector('.js-serverless-functions-page').dataset;
|
|
|
|
const store = createStore(entryPointData);
|
2018-12-17 02:31:38 -05:00
|
|
|
|
2019-04-05 22:02:39 -04:00
|
|
|
const el = document.querySelector('#js-serverless-functions');
|
|
|
|
this.functions = new Vue({
|
|
|
|
el,
|
2020-07-21 11:09:40 -04:00
|
|
|
store,
|
2019-04-05 22:02:39 -04:00
|
|
|
render(createElement) {
|
2020-07-21 11:09:40 -04:00
|
|
|
return createElement(Functions);
|
2019-04-05 22:02:39 -04:00
|
|
|
},
|
|
|
|
});
|
2018-12-06 13:08:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
destroy() {
|
|
|
|
this.destroyed = true;
|
|
|
|
|
|
|
|
this.functions.$destroy();
|
2018-12-17 02:31:38 -05:00
|
|
|
this.functionDetails.$destroy();
|
2018-12-06 13:08:49 -05:00
|
|
|
}
|
|
|
|
}
|