blob: 8c72580e538cb3cb21cebe48ddb47cbd106e4400 [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,
Yoshie Muranaka1be6b412020-04-16 12:03:38 -070037 ToastPlugin,
Derick Montague602e98a2020-10-21 16:20:00 -050038 TooltipPlugin,
Derick Montaguefded0d12019-12-11 06:16:40 -060039} from 'bootstrap-vue';
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080040import Vuelidate from 'vuelidate';
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060041import i18n from './i18n';
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053042import { format } from 'date-fns-tz';
Derick Montaguea2988f42020-01-17 13:46:30 -060043
Dixsie Wolmers97f41872020-02-23 15:56:16 -060044// Filters
Derick Montague602e98a2020-10-21 16:20:00 -050045Vue.filter('shortTimeZone', function (value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053046 const longTZ = value
47 .toString()
48 .match(/\((.*)\)/)
49 .pop();
50 const regexNotUpper = /[*a-z ]/g;
51 return longTZ.replace(regexNotUpper, '');
52});
53
Derick Montague602e98a2020-10-21 16:20:00 -050054Vue.filter('formatDate', function (value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053055 const isUtcDisplay = store.getters['global/isUtcDisplay'];
56
Dixsie Wolmers97f41872020-02-23 15:56:16 -060057 if (value instanceof Date) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053058 if (isUtcDisplay) {
59 return value.toISOString().substring(0, 10);
60 }
61 const pattern = `yyyy-MM-dd`;
62 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
63 return format(value, pattern, { timezone });
Dixsie Wolmers97f41872020-02-23 15:56:16 -060064 }
65});
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060066
Derick Montague602e98a2020-10-21 16:20:00 -050067Vue.filter('formatTime', function (value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053068 const isUtcDisplay = store.getters['global/isUtcDisplay'];
69
Dixsie Wolmers97f41872020-02-23 15:56:16 -060070 if (value instanceof Date) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053071 if (isUtcDisplay) {
72 let timeOptions = {
73 timeZone: 'UTC',
Derick Montague602e98a2020-10-21 16:20:00 -050074 hour12: false,
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053075 };
76 return `${value.toLocaleTimeString('default', timeOptions)} UTC`;
77 }
78 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
79 const shortTz = Vue.filter('shortTimeZone')(value);
80 const pattern = `HH:mm:ss ('${shortTz}' O)`;
81 return format(value, pattern, { timezone }).replace('GMT', 'UTC');
Dixsie Wolmers97f41872020-02-23 15:56:16 -060082 }
83});
84
85// Plugins
Derick Montague676f2fc2019-12-23 20:53:49 -060086Vue.use(AlertPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060087Vue.use(BadgePlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -060088Vue.use(ButtonPlugin);
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080089Vue.use(BVConfigPlugin, {
Derick Montague7f970a12020-03-02 17:56:09 -060090 BFormText: { textVariant: 'secondary' },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080091 BTable: {
92 headVariant: 'light',
Derick Montague602e98a2020-10-21 16:20:00 -050093 footVariant: 'light',
Yoshie Muranaka532a4b02020-03-27 11:00:50 -070094 },
95 BFormTags: {
96 tagVariant: 'primary',
Derick Montague602e98a2020-10-21 16:20:00 -050097 addButtonVariant: 'link-primary',
Yoshie Muranaka82cca542020-04-07 10:20:37 -070098 },
99 BBadge: {
Derick Montague602e98a2020-10-21 16:20:00 -0500100 variant: 'primary',
101 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800102});
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700103Vue.use(CardPlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -0600104Vue.use(CollapsePlugin);
Yoshie Muranaka82cca542020-04-07 10:20:37 -0700105Vue.use(DropdownPlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600106Vue.use(FormPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600107Vue.use(FormCheckboxPlugin);
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700108Vue.use(FormDatepickerPlugin);
Yoshie Muranaka37393812020-03-24 15:25:24 -0700109Vue.use(FormFilePlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600110Vue.use(FormGroupPlugin);
111Vue.use(FormInputPlugin);
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800112Vue.use(FormRadioPlugin);
113Vue.use(FormSelectPlugin);
Yoshie Muranaka532a4b02020-03-27 11:00:50 -0700114Vue.use(FormTagsPlugin);
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -0700115Vue.use(InputGroupPlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600116Vue.use(LayoutPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600117Vue.use(LayoutPlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -0600118Vue.use(LinkPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600119Vue.use(ListGroupPlugin);
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600120Vue.use(ModalPlugin);
Derick Montague42c19892020-01-17 16:10:34 -0600121Vue.use(NavbarPlugin);
122Vue.use(NavPlugin);
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700123Vue.use(PaginationPlugin);
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700124Vue.use(ProgressPlugin);
Derick Montague42c19892020-01-17 16:10:34 -0600125Vue.use(TablePlugin);
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800126Vue.use(ToastPlugin);
Yoshie Muranaka1be6b412020-04-16 12:03:38 -0700127Vue.use(TooltipPlugin);
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800128Vue.use(Vuelidate);
Derick Montaguea2988f42020-01-17 13:46:30 -0600129
Derick Montaguea2988f42020-01-17 13:46:30 -0600130new Vue({
131 router,
132 store,
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -0600133 i18n,
Derick Montague602e98a2020-10-21 16:20:00 -0500134 render: (h) => h(App),
Derick Montaguefded0d12019-12-11 06:16:40 -0600135}).$mount('#app');