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