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