2020-06-23 00:09:42 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import { GlToast } from '@gitlab/ui';
|
|
|
|
import { createStore } from './stores';
|
|
|
|
import createRouter from './router';
|
2020-07-28 23:09:34 +05:30
|
|
|
import { stateAndPropsFromDataset } from './utils';
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
Vue.use(GlToast);
|
|
|
|
|
|
|
|
export default (props = {}) => {
|
|
|
|
const el = document.getElementById('prometheus-graphs');
|
|
|
|
|
|
|
|
if (el && el.dataset) {
|
2020-07-28 23:09:34 +05:30
|
|
|
const { metricsDashboardBasePath, ...dataset } = el.dataset;
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
const { initState, dataProps } = stateAndPropsFromDataset(dataset);
|
|
|
|
const store = createStore(initState);
|
2020-06-23 00:09:42 +05:30
|
|
|
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"/>`,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|