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