debian-mirror-gitlab/app/assets/javascripts/monitoring/monitoring_app.js
2020-08-09 17:44:08 +05:30

32 lines
847 B
JavaScript

import Vue from 'vue';
import { GlToast } from '@gitlab/ui';
import { createStore } from './stores';
import createRouter from './router';
import { stateAndPropsFromDataset } from './utils';
Vue.use(GlToast);
export default (props = {}) => {
const el = document.getElementById('prometheus-graphs');
if (el && el.dataset) {
const { metricsDashboardBasePath, ...dataset } = el.dataset;
const { initState, dataProps } = stateAndPropsFromDataset(dataset);
const store = createStore(initState);
const router = createRouter(metricsDashboardBasePath);
// eslint-disable-next-line no-new
new Vue({
el,
store,
router,
data() {
return {
dashboardProps: { ...dataProps, ...props },
};
},
template: `<router-view :dashboardProps="dashboardProps"/>`,
});
}
};