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