summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/serverless/serverless_bundle.js
blob: ed3b633d7668015dbf1f5010f10443449fb95a1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import Vue from 'vue';
import Functions from './components/functions.vue';
import FunctionDetails from './components/function_details.vue';
import { createStore } from './store';

export default class Serverless {
  constructor() {
    if (document.querySelector('.js-serverless-function-details-page') != null) {
      const {
        serviceName,
        serviceDescription,
        serviceEnvironment,
        serviceUrl,
        serviceNamespace,
        servicePodcount,
        serviceMetricsUrl,
        prometheus,
        clustersPath,
        helpPath,
      } = document.querySelector('.js-serverless-function-details-page').dataset;
      const el = document.querySelector('#js-serverless-function-details');

      const service = {
        name: serviceName,
        description: serviceDescription,
        environment: serviceEnvironment,
        url: serviceUrl,
        namespace: serviceNamespace,
        podcount: servicePodcount,
        metricsUrl: serviceMetricsUrl,
      };

      this.functionDetails = new Vue({
        el,
        store: createStore(),
        render(createElement) {
          return createElement(FunctionDetails, {
            props: {
              func: service,
              hasPrometheus: prometheus !== undefined,
              clustersPath,
              helpPath,
            },
          });
        },
      });
    } else {
      const { statusPath, clustersPath, helpPath } = document.querySelector(
        '.js-serverless-functions-page',
      ).dataset;

      const el = document.querySelector('#js-serverless-functions');
      this.functions = new Vue({
        el,
        store: createStore(),
        render(createElement) {
          return createElement(Functions, {
            props: {
              clustersPath,
              helpPath,
              statusPath,
            },
          });
        },
      });
    }
  }

  destroy() {
    this.destroyed = true;

    this.functions.$destroy();
    this.functionDetails.$destroy();
  }
}