xref: /openbmc/webui-vue/src/main.js (revision 7f970a1f)
1import Vue from 'vue';
2import App from './App.vue';
3import router from './router';
4import store from './store';
5import {
6  AlertPlugin,
7  BadgePlugin,
8  ButtonPlugin,
9  BVConfigPlugin,
10  CollapsePlugin,
11  FormPlugin,
12  FormCheckboxPlugin,
13  FormGroupPlugin,
14  FormInputPlugin,
15  FormRadioPlugin,
16  FormSelectPlugin,
17  LayoutPlugin,
18  LinkPlugin,
19  ListGroupPlugin,
20  ModalPlugin,
21  NavbarPlugin,
22  NavPlugin,
23  TablePlugin,
24  ToastPlugin
25} from 'bootstrap-vue';
26import Vuelidate from 'vuelidate';
27import i18n from './i18n';
28
29// Filters
30Vue.filter('formatDate', function(value) {
31  const dateOptions = {
32    year: 'numeric',
33    month: 'short',
34    day: 'numeric'
35  };
36  if (value instanceof Date) {
37    return value.toLocaleDateString(i18n.locale, dateOptions);
38  }
39});
40
41Vue.filter('formatTime', function(value) {
42  const timeOptions = {
43    hour: 'numeric',
44    minute: 'numeric',
45    second: 'numeric',
46    timeZoneName: 'short'
47  };
48  if (value instanceof Date) {
49    return value.toLocaleTimeString('default', timeOptions);
50  }
51});
52
53// Plugins
54Vue.use(AlertPlugin);
55Vue.use(BadgePlugin);
56Vue.use(ButtonPlugin);
57Vue.use(BVConfigPlugin, {
58  BFormText: { textVariant: 'secondary' },
59  BTable: {
60    headVariant: 'light',
61    footVariant: 'light'
62  }
63});
64Vue.use(CollapsePlugin);
65Vue.use(FormPlugin);
66Vue.use(FormCheckboxPlugin);
67Vue.use(FormGroupPlugin);
68Vue.use(FormInputPlugin);
69Vue.use(FormRadioPlugin);
70Vue.use(FormSelectPlugin);
71Vue.use(LayoutPlugin);
72Vue.use(LayoutPlugin);
73Vue.use(LinkPlugin);
74Vue.use(ListGroupPlugin);
75Vue.use(ModalPlugin);
76Vue.use(NavbarPlugin);
77Vue.use(NavPlugin);
78Vue.use(TablePlugin);
79Vue.use(ToastPlugin);
80Vue.use(Vuelidate);
81
82new Vue({
83  router,
84  store,
85  i18n,
86  render: h => h(App)
87}).$mount('#app');
88