blob: 497c751c605b99482099b6b4ed7d7ac6a9f33240 [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,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070010 CardPlugin,
Derick Montaguea2988f42020-01-17 13:46:30 -060011 CollapsePlugin,
Yoshie Muranaka82cca542020-04-07 10:20:37 -070012 DropdownPlugin,
Derick Montaguee080a1a2019-12-04 16:30:08 -060013 FormPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060014 FormCheckboxPlugin,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -070015 FormDatepickerPlugin,
Yoshie Muranaka37393812020-03-24 15:25:24 -070016 FormFilePlugin,
Derick Montaguee080a1a2019-12-04 16:30:08 -060017 FormGroupPlugin,
18 FormInputPlugin,
Yoshie Muranaka463a5702019-12-04 09:09:36 -080019 FormRadioPlugin,
20 FormSelectPlugin,
Yoshie Muranaka532a4b02020-03-27 11:00:50 -070021 FormTagsPlugin,
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -070022 InputGroupPlugin,
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060023 LayoutPlugin,
Derick Montague42c19892020-01-17 16:10:34 -060024 LinkPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060025 ListGroupPlugin,
Derick Montague42c19892020-01-17 16:10:34 -060026 ModalPlugin,
27 NavbarPlugin,
28 NavPlugin,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -070029 PaginationPlugin,
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070030 ProgressPlugin,
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -080031 TablePlugin,
Yoshie Muranaka1be6b412020-04-16 12:03:38 -070032 ToastPlugin,
33 TooltipPlugin
Derick Montaguefded0d12019-12-11 06:16:40 -060034} from 'bootstrap-vue';
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080035import Vuelidate from 'vuelidate';
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060036import i18n from './i18n';
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053037import { format } from 'date-fns-tz';
Derick Montaguea2988f42020-01-17 13:46:30 -060038
Dixsie Wolmers97f41872020-02-23 15:56:16 -060039// Filters
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053040Vue.filter('shortTimeZone', function(value) {
41 const longTZ = value
42 .toString()
43 .match(/\((.*)\)/)
44 .pop();
45 const regexNotUpper = /[*a-z ]/g;
46 return longTZ.replace(regexNotUpper, '');
47});
48
Dixsie Wolmers97f41872020-02-23 15:56:16 -060049Vue.filter('formatDate', function(value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053050 const isUtcDisplay = store.getters['global/isUtcDisplay'];
51
Dixsie Wolmers97f41872020-02-23 15:56:16 -060052 if (value instanceof Date) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053053 if (isUtcDisplay) {
54 return value.toISOString().substring(0, 10);
55 }
56 const pattern = `yyyy-MM-dd`;
57 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
58 return format(value, pattern, { timezone });
Dixsie Wolmers97f41872020-02-23 15:56:16 -060059 }
60});
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060061
Dixsie Wolmers97f41872020-02-23 15:56:16 -060062Vue.filter('formatTime', function(value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053063 const isUtcDisplay = store.getters['global/isUtcDisplay'];
64
Dixsie Wolmers97f41872020-02-23 15:56:16 -060065 if (value instanceof Date) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053066 if (isUtcDisplay) {
67 let timeOptions = {
68 timeZone: 'UTC',
69 hour12: false
70 };
71 return `${value.toLocaleTimeString('default', timeOptions)} UTC`;
72 }
73 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
74 const shortTz = Vue.filter('shortTimeZone')(value);
75 const pattern = `HH:mm:ss ('${shortTz}' O)`;
76 return format(value, pattern, { timezone }).replace('GMT', 'UTC');
Dixsie Wolmers97f41872020-02-23 15:56:16 -060077 }
78});
79
80// Plugins
Derick Montague676f2fc2019-12-23 20:53:49 -060081Vue.use(AlertPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060082Vue.use(BadgePlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -060083Vue.use(ButtonPlugin);
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080084Vue.use(BVConfigPlugin, {
Derick Montague7f970a12020-03-02 17:56:09 -060085 BFormText: { textVariant: 'secondary' },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080086 BTable: {
87 headVariant: 'light',
88 footVariant: 'light'
Yoshie Muranaka532a4b02020-03-27 11:00:50 -070089 },
90 BFormTags: {
91 tagVariant: 'primary',
92 addButtonVariant: 'link-primary'
Yoshie Muranaka82cca542020-04-07 10:20:37 -070093 },
94 BBadge: {
95 variant: 'primary'
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080096 }
97});
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070098Vue.use(CardPlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -060099Vue.use(CollapsePlugin);
Yoshie Muranaka82cca542020-04-07 10:20:37 -0700100Vue.use(DropdownPlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600101Vue.use(FormPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600102Vue.use(FormCheckboxPlugin);
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700103Vue.use(FormDatepickerPlugin);
Yoshie Muranaka37393812020-03-24 15:25:24 -0700104Vue.use(FormFilePlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600105Vue.use(FormGroupPlugin);
106Vue.use(FormInputPlugin);
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800107Vue.use(FormRadioPlugin);
108Vue.use(FormSelectPlugin);
Yoshie Muranaka532a4b02020-03-27 11:00:50 -0700109Vue.use(FormTagsPlugin);
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -0700110Vue.use(InputGroupPlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600111Vue.use(LayoutPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600112Vue.use(LayoutPlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -0600113Vue.use(LinkPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600114Vue.use(ListGroupPlugin);
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600115Vue.use(ModalPlugin);
Derick Montague42c19892020-01-17 16:10:34 -0600116Vue.use(NavbarPlugin);
117Vue.use(NavPlugin);
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700118Vue.use(PaginationPlugin);
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700119Vue.use(ProgressPlugin);
Derick Montague42c19892020-01-17 16:10:34 -0600120Vue.use(TablePlugin);
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800121Vue.use(ToastPlugin);
Yoshie Muranaka1be6b412020-04-16 12:03:38 -0700122Vue.use(TooltipPlugin);
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800123Vue.use(Vuelidate);
Derick Montaguea2988f42020-01-17 13:46:30 -0600124
Derick Montaguea2988f42020-01-17 13:46:30 -0600125new Vue({
126 router,
127 store,
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -0600128 i18n,
Derick Montaguea2988f42020-01-17 13:46:30 -0600129 render: h => h(App)
Derick Montaguefded0d12019-12-11 06:16:40 -0600130}).$mount('#app');