blob: 0aae716f32586a52885eab3dfb10aad1e0c8702b [file] [log] [blame]
Derick Montaguefded0d12019-12-11 06:16:40 -06001import Vue from 'vue';
2import App from './App.vue';
3import router from './router';
Yoshie Muranaka8263d852020-10-16 07:58:06 -07004
5//Do not change store import.
6//Exact match alias set to support
7//dotenv customizations.
Derick Montaguefded0d12019-12-11 06:16:40 -06008import store from './store';
Yoshie Muranaka8263d852020-10-16 07:58:06 -07009
Derick Montaguea2988f42020-01-17 13:46:30 -060010import {
Derick Montague676f2fc2019-12-23 20:53:49 -060011 AlertPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060012 BadgePlugin,
Derick Montaguea2988f42020-01-17 13:46:30 -060013 ButtonPlugin,
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080014 BVConfigPlugin,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070015 CardPlugin,
Derick Montaguea2988f42020-01-17 13:46:30 -060016 CollapsePlugin,
Yoshie Muranaka82cca542020-04-07 10:20:37 -070017 DropdownPlugin,
Derick Montaguee080a1a2019-12-04 16:30:08 -060018 FormPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060019 FormCheckboxPlugin,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -070020 FormDatepickerPlugin,
Yoshie Muranaka37393812020-03-24 15:25:24 -070021 FormFilePlugin,
Derick Montaguee080a1a2019-12-04 16:30:08 -060022 FormGroupPlugin,
23 FormInputPlugin,
Yoshie Muranaka463a5702019-12-04 09:09:36 -080024 FormRadioPlugin,
25 FormSelectPlugin,
Yoshie Muranaka532a4b02020-03-27 11:00:50 -070026 FormTagsPlugin,
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -070027 InputGroupPlugin,
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060028 LayoutPlugin,
Derick Montague42c19892020-01-17 16:10:34 -060029 LinkPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060030 ListGroupPlugin,
Derick Montague42c19892020-01-17 16:10:34 -060031 ModalPlugin,
32 NavbarPlugin,
33 NavPlugin,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -070034 PaginationPlugin,
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070035 ProgressPlugin,
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -080036 TablePlugin,
Dixsie Wolmersc4b87572021-10-07 16:15:50 -050037 TabsPlugin,
Yoshie Muranaka1be6b412020-04-16 12:03:38 -070038 ToastPlugin,
Derick Montague602e98a2020-10-21 16:20:00 -050039 TooltipPlugin,
Derick Montaguefded0d12019-12-11 06:16:40 -060040} from 'bootstrap-vue';
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080041import Vuelidate from 'vuelidate';
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060042import i18n from './i18n';
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053043import { format } from 'date-fns-tz';
Derick Montaguea2988f42020-01-17 13:46:30 -060044
Dixsie Wolmers97f41872020-02-23 15:56:16 -060045// Filters
Derick Montague602e98a2020-10-21 16:20:00 -050046Vue.filter('shortTimeZone', function (value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053047 const longTZ = value
48 .toString()
49 .match(/\((.*)\)/)
50 .pop();
51 const regexNotUpper = /[*a-z ]/g;
52 return longTZ.replace(regexNotUpper, '');
53});
54
Derick Montague602e98a2020-10-21 16:20:00 -050055Vue.filter('formatDate', function (value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053056 const isUtcDisplay = store.getters['global/isUtcDisplay'];
57
Dixsie Wolmers97f41872020-02-23 15:56:16 -060058 if (value instanceof Date) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053059 if (isUtcDisplay) {
60 return value.toISOString().substring(0, 10);
61 }
62 const pattern = `yyyy-MM-dd`;
63 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
64 return format(value, pattern, { timezone });
Dixsie Wolmers97f41872020-02-23 15:56:16 -060065 }
66});
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060067
Derick Montague602e98a2020-10-21 16:20:00 -050068Vue.filter('formatTime', function (value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053069 const isUtcDisplay = store.getters['global/isUtcDisplay'];
70
Dixsie Wolmers97f41872020-02-23 15:56:16 -060071 if (value instanceof Date) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053072 if (isUtcDisplay) {
73 let timeOptions = {
74 timeZone: 'UTC',
Derick Montague07b85ef2021-07-09 20:00:35 -050075 hourCycle: 'h23',
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053076 };
77 return `${value.toLocaleTimeString('default', timeOptions)} UTC`;
78 }
79 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
80 const shortTz = Vue.filter('shortTimeZone')(value);
81 const pattern = `HH:mm:ss ('${shortTz}' O)`;
82 return format(value, pattern, { timezone }).replace('GMT', 'UTC');
Dixsie Wolmers97f41872020-02-23 15:56:16 -060083 }
84});
85
86// Plugins
Derick Montague676f2fc2019-12-23 20:53:49 -060087Vue.use(AlertPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060088Vue.use(BadgePlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -060089Vue.use(ButtonPlugin);
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080090Vue.use(BVConfigPlugin, {
Derick Montague7f970a12020-03-02 17:56:09 -060091 BFormText: { textVariant: 'secondary' },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080092 BTable: {
93 headVariant: 'light',
Derick Montague602e98a2020-10-21 16:20:00 -050094 footVariant: 'light',
Yoshie Muranaka532a4b02020-03-27 11:00:50 -070095 },
96 BFormTags: {
97 tagVariant: 'primary',
Derick Montague602e98a2020-10-21 16:20:00 -050098 addButtonVariant: 'link-primary',
Yoshie Muranaka82cca542020-04-07 10:20:37 -070099 },
100 BBadge: {
Derick Montague602e98a2020-10-21 16:20:00 -0500101 variant: 'primary',
102 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800103});
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700104Vue.use(CardPlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -0600105Vue.use(CollapsePlugin);
Yoshie Muranaka82cca542020-04-07 10:20:37 -0700106Vue.use(DropdownPlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600107Vue.use(FormPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600108Vue.use(FormCheckboxPlugin);
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700109Vue.use(FormDatepickerPlugin);
Yoshie Muranaka37393812020-03-24 15:25:24 -0700110Vue.use(FormFilePlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600111Vue.use(FormGroupPlugin);
112Vue.use(FormInputPlugin);
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800113Vue.use(FormRadioPlugin);
114Vue.use(FormSelectPlugin);
Yoshie Muranaka532a4b02020-03-27 11:00:50 -0700115Vue.use(FormTagsPlugin);
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -0700116Vue.use(InputGroupPlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600117Vue.use(LayoutPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600118Vue.use(LayoutPlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -0600119Vue.use(LinkPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600120Vue.use(ListGroupPlugin);
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600121Vue.use(ModalPlugin);
Derick Montague42c19892020-01-17 16:10:34 -0600122Vue.use(NavbarPlugin);
123Vue.use(NavPlugin);
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700124Vue.use(PaginationPlugin);
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700125Vue.use(ProgressPlugin);
Derick Montague42c19892020-01-17 16:10:34 -0600126Vue.use(TablePlugin);
Dixsie Wolmersc4b87572021-10-07 16:15:50 -0500127Vue.use(TabsPlugin);
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800128Vue.use(ToastPlugin);
Yoshie Muranaka1be6b412020-04-16 12:03:38 -0700129Vue.use(TooltipPlugin);
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800130Vue.use(Vuelidate);
Derick Montaguea2988f42020-01-17 13:46:30 -0600131
Derick Montaguea2988f42020-01-17 13:46:30 -0600132new Vue({
133 router,
134 store,
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -0600135 i18n,
Derick Montague602e98a2020-10-21 16:20:00 -0500136 render: (h) => h(App),
Derick Montaguefded0d12019-12-11 06:16:40 -0600137}).$mount('#app');