blob: 8336cb3d7e0f8753ba90ffe87aa3dcc631e468da [file] [log] [blame]
Derick Montaguefded0d12019-12-11 06:16:40 -06001import Vue from 'vue';
2import App from './App.vue';
3import router from './router';
4import store from './store';
Derick Montaguea2988f42020-01-17 13:46:30 -06005import {
Derick Montague676f2fc2019-12-23 20:53:49 -06006 AlertPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -06007 BadgePlugin,
Derick Montaguea2988f42020-01-17 13:46:30 -06008 ButtonPlugin,
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -08009 BVConfigPlugin,
Derick Montaguea2988f42020-01-17 13:46:30 -060010 CollapsePlugin,
Yoshie Muranaka82cca542020-04-07 10:20:37 -070011 DropdownPlugin,
Derick Montaguee080a1a2019-12-04 16:30:08 -060012 FormPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060013 FormCheckboxPlugin,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -070014 FormDatepickerPlugin,
Yoshie Muranaka37393812020-03-24 15:25:24 -070015 FormFilePlugin,
Derick Montaguee080a1a2019-12-04 16:30:08 -060016 FormGroupPlugin,
17 FormInputPlugin,
Yoshie Muranaka463a5702019-12-04 09:09:36 -080018 FormRadioPlugin,
19 FormSelectPlugin,
Yoshie Muranaka532a4b02020-03-27 11:00:50 -070020 FormTagsPlugin,
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -070021 InputGroupPlugin,
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060022 LayoutPlugin,
Derick Montague42c19892020-01-17 16:10:34 -060023 LinkPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060024 ListGroupPlugin,
Derick Montague42c19892020-01-17 16:10:34 -060025 ModalPlugin,
26 NavbarPlugin,
27 NavPlugin,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -070028 PaginationPlugin,
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070029 ProgressPlugin,
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -080030 TablePlugin,
Yoshie Muranaka1be6b412020-04-16 12:03:38 -070031 ToastPlugin,
32 TooltipPlugin
Derick Montaguefded0d12019-12-11 06:16:40 -060033} from 'bootstrap-vue';
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080034import Vuelidate from 'vuelidate';
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060035import i18n from './i18n';
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053036import { format } from 'date-fns-tz';
Derick Montaguea2988f42020-01-17 13:46:30 -060037
Dixsie Wolmers97f41872020-02-23 15:56:16 -060038// Filters
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053039Vue.filter('shortTimeZone', function(value) {
40 const longTZ = value
41 .toString()
42 .match(/\((.*)\)/)
43 .pop();
44 const regexNotUpper = /[*a-z ]/g;
45 return longTZ.replace(regexNotUpper, '');
46});
47
Dixsie Wolmers97f41872020-02-23 15:56:16 -060048Vue.filter('formatDate', function(value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053049 const isUtcDisplay = store.getters['global/isUtcDisplay'];
50
Dixsie Wolmers97f41872020-02-23 15:56:16 -060051 if (value instanceof Date) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053052 if (isUtcDisplay) {
53 return value.toISOString().substring(0, 10);
54 }
55 const pattern = `yyyy-MM-dd`;
56 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
57 return format(value, pattern, { timezone });
Dixsie Wolmers97f41872020-02-23 15:56:16 -060058 }
59});
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060060
Dixsie Wolmers97f41872020-02-23 15:56:16 -060061Vue.filter('formatTime', function(value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053062 const isUtcDisplay = store.getters['global/isUtcDisplay'];
63
Dixsie Wolmers97f41872020-02-23 15:56:16 -060064 if (value instanceof Date) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053065 if (isUtcDisplay) {
66 let timeOptions = {
67 timeZone: 'UTC',
68 hour12: false
69 };
70 return `${value.toLocaleTimeString('default', timeOptions)} UTC`;
71 }
72 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
73 const shortTz = Vue.filter('shortTimeZone')(value);
74 const pattern = `HH:mm:ss ('${shortTz}' O)`;
75 return format(value, pattern, { timezone }).replace('GMT', 'UTC');
Dixsie Wolmers97f41872020-02-23 15:56:16 -060076 }
77});
78
79// Plugins
Derick Montague676f2fc2019-12-23 20:53:49 -060080Vue.use(AlertPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060081Vue.use(BadgePlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -060082Vue.use(ButtonPlugin);
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080083Vue.use(BVConfigPlugin, {
Derick Montague7f970a12020-03-02 17:56:09 -060084 BFormText: { textVariant: 'secondary' },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080085 BTable: {
86 headVariant: 'light',
87 footVariant: 'light'
Yoshie Muranaka532a4b02020-03-27 11:00:50 -070088 },
89 BFormTags: {
90 tagVariant: 'primary',
91 addButtonVariant: 'link-primary'
Yoshie Muranaka82cca542020-04-07 10:20:37 -070092 },
93 BBadge: {
94 variant: 'primary'
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080095 }
96});
Derick Montaguea2988f42020-01-17 13:46:30 -060097Vue.use(CollapsePlugin);
Yoshie Muranaka82cca542020-04-07 10:20:37 -070098Vue.use(DropdownPlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -060099Vue.use(FormPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600100Vue.use(FormCheckboxPlugin);
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700101Vue.use(FormDatepickerPlugin);
Yoshie Muranaka37393812020-03-24 15:25:24 -0700102Vue.use(FormFilePlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600103Vue.use(FormGroupPlugin);
104Vue.use(FormInputPlugin);
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800105Vue.use(FormRadioPlugin);
106Vue.use(FormSelectPlugin);
Yoshie Muranaka532a4b02020-03-27 11:00:50 -0700107Vue.use(FormTagsPlugin);
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -0700108Vue.use(InputGroupPlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600109Vue.use(LayoutPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600110Vue.use(LayoutPlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -0600111Vue.use(LinkPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600112Vue.use(ListGroupPlugin);
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600113Vue.use(ModalPlugin);
Derick Montague42c19892020-01-17 16:10:34 -0600114Vue.use(NavbarPlugin);
115Vue.use(NavPlugin);
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700116Vue.use(PaginationPlugin);
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700117Vue.use(ProgressPlugin);
Derick Montague42c19892020-01-17 16:10:34 -0600118Vue.use(TablePlugin);
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800119Vue.use(ToastPlugin);
Yoshie Muranaka1be6b412020-04-16 12:03:38 -0700120Vue.use(TooltipPlugin);
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800121Vue.use(Vuelidate);
Derick Montaguea2988f42020-01-17 13:46:30 -0600122
Derick Montaguea2988f42020-01-17 13:46:30 -0600123new Vue({
124 router,
125 store,
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -0600126 i18n,
Derick Montaguea2988f42020-01-17 13:46:30 -0600127 render: h => h(App)
Derick Montaguefded0d12019-12-11 06:16:40 -0600128}).$mount('#app');