blob: 43d09b8c017545f9ea901da0badb7e70c78f5976 [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';
Konstantinfb6c6de2023-06-14 17:23:14 +03009import eventBus from './eventBus';
Yoshie Muranaka8263d852020-10-16 07:58:06 -070010
Derick Montaguea2988f42020-01-17 13:46:30 -060011import {
Derick Montague676f2fc2019-12-23 20:53:49 -060012 AlertPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060013 BadgePlugin,
Derick Montaguea2988f42020-01-17 13:46:30 -060014 ButtonPlugin,
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080015 BVConfigPlugin,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070016 CardPlugin,
Derick Montaguea2988f42020-01-17 13:46:30 -060017 CollapsePlugin,
Yoshie Muranaka82cca542020-04-07 10:20:37 -070018 DropdownPlugin,
Derick Montaguee080a1a2019-12-04 16:30:08 -060019 FormPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060020 FormCheckboxPlugin,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -070021 FormDatepickerPlugin,
Yoshie Muranaka37393812020-03-24 15:25:24 -070022 FormFilePlugin,
Derick Montaguee080a1a2019-12-04 16:30:08 -060023 FormGroupPlugin,
24 FormInputPlugin,
Yoshie Muranaka463a5702019-12-04 09:09:36 -080025 FormRadioPlugin,
26 FormSelectPlugin,
Yoshie Muranaka532a4b02020-03-27 11:00:50 -070027 FormTagsPlugin,
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -070028 InputGroupPlugin,
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060029 LayoutPlugin,
Derick Montague42c19892020-01-17 16:10:34 -060030 LinkPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060031 ListGroupPlugin,
Derick Montague42c19892020-01-17 16:10:34 -060032 ModalPlugin,
33 NavbarPlugin,
34 NavPlugin,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -070035 PaginationPlugin,
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070036 ProgressPlugin,
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -080037 TablePlugin,
Dixsie Wolmersc4b87572021-10-07 16:15:50 -050038 TabsPlugin,
Yoshie Muranaka1be6b412020-04-16 12:03:38 -070039 ToastPlugin,
Derick Montague602e98a2020-10-21 16:20:00 -050040 TooltipPlugin,
Derick Montaguefded0d12019-12-11 06:16:40 -060041} from 'bootstrap-vue';
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080042import Vuelidate from 'vuelidate';
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060043import i18n from './i18n';
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053044import { format } from 'date-fns-tz';
Derick Montaguea2988f42020-01-17 13:46:30 -060045
Dixsie Wolmers97f41872020-02-23 15:56:16 -060046// Filters
Derick Montague602e98a2020-10-21 16:20:00 -050047Vue.filter('shortTimeZone', function (value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053048 const longTZ = value
49 .toString()
50 .match(/\((.*)\)/)
51 .pop();
52 const regexNotUpper = /[*a-z ]/g;
53 return longTZ.replace(regexNotUpper, '');
54});
55
Derick Montague602e98a2020-10-21 16:20:00 -050056Vue.filter('formatDate', function (value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053057 const isUtcDisplay = store.getters['global/isUtcDisplay'];
58
Dixsie Wolmers97f41872020-02-23 15:56:16 -060059 if (value instanceof Date) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053060 if (isUtcDisplay) {
61 return value.toISOString().substring(0, 10);
62 }
63 const pattern = `yyyy-MM-dd`;
64 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
65 return format(value, pattern, { timezone });
Dixsie Wolmers97f41872020-02-23 15:56:16 -060066 }
67});
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060068
Derick Montague602e98a2020-10-21 16:20:00 -050069Vue.filter('formatTime', function (value) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053070 const isUtcDisplay = store.getters['global/isUtcDisplay'];
71
Dixsie Wolmers97f41872020-02-23 15:56:16 -060072 if (value instanceof Date) {
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053073 if (isUtcDisplay) {
74 let timeOptions = {
75 timeZone: 'UTC',
Derick Montague07b85ef2021-07-09 20:00:35 -050076 hourCycle: 'h23',
Sukanya Pandeyfc16f3c2020-06-23 22:54:27 +053077 };
78 return `${value.toLocaleTimeString('default', timeOptions)} UTC`;
79 }
80 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
81 const shortTz = Vue.filter('shortTimeZone')(value);
82 const pattern = `HH:mm:ss ('${shortTz}' O)`;
83 return format(value, pattern, { timezone }).replace('GMT', 'UTC');
Dixsie Wolmers97f41872020-02-23 15:56:16 -060084 }
85});
86
87// Plugins
Derick Montague676f2fc2019-12-23 20:53:49 -060088Vue.use(AlertPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060089Vue.use(BadgePlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -060090Vue.use(ButtonPlugin);
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080091Vue.use(BVConfigPlugin, {
Derick Montague7f970a12020-03-02 17:56:09 -060092 BFormText: { textVariant: 'secondary' },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080093 BTable: {
94 headVariant: 'light',
Derick Montague602e98a2020-10-21 16:20:00 -050095 footVariant: 'light',
Yoshie Muranaka532a4b02020-03-27 11:00:50 -070096 },
97 BFormTags: {
98 tagVariant: 'primary',
Derick Montague602e98a2020-10-21 16:20:00 -050099 addButtonVariant: 'link-primary',
Yoshie Muranaka82cca542020-04-07 10:20:37 -0700100 },
101 BBadge: {
Derick Montague602e98a2020-10-21 16:20:00 -0500102 variant: 'primary',
103 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800104});
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700105Vue.use(CardPlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -0600106Vue.use(CollapsePlugin);
Yoshie Muranaka82cca542020-04-07 10:20:37 -0700107Vue.use(DropdownPlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600108Vue.use(FormPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600109Vue.use(FormCheckboxPlugin);
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700110Vue.use(FormDatepickerPlugin);
Yoshie Muranaka37393812020-03-24 15:25:24 -0700111Vue.use(FormFilePlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600112Vue.use(FormGroupPlugin);
113Vue.use(FormInputPlugin);
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800114Vue.use(FormRadioPlugin);
115Vue.use(FormSelectPlugin);
Yoshie Muranaka532a4b02020-03-27 11:00:50 -0700116Vue.use(FormTagsPlugin);
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -0700117Vue.use(InputGroupPlugin);
Derick Montaguee080a1a2019-12-04 16:30:08 -0600118Vue.use(LayoutPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600119Vue.use(LayoutPlugin);
Derick Montaguea2988f42020-01-17 13:46:30 -0600120Vue.use(LinkPlugin);
Dixsie Wolmers97d86b32019-12-02 05:07:57 -0600121Vue.use(ListGroupPlugin);
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600122Vue.use(ModalPlugin);
Derick Montague42c19892020-01-17 16:10:34 -0600123Vue.use(NavbarPlugin);
124Vue.use(NavPlugin);
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700125Vue.use(PaginationPlugin);
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700126Vue.use(ProgressPlugin);
Derick Montague42c19892020-01-17 16:10:34 -0600127Vue.use(TablePlugin);
Dixsie Wolmersc4b87572021-10-07 16:15:50 -0500128Vue.use(TabsPlugin);
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800129Vue.use(ToastPlugin);
Yoshie Muranaka1be6b412020-04-16 12:03:38 -0700130Vue.use(TooltipPlugin);
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800131Vue.use(Vuelidate);
Derick Montaguea2988f42020-01-17 13:46:30 -0600132
Derick Montaguea2988f42020-01-17 13:46:30 -0600133new Vue({
134 router,
135 store,
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -0600136 i18n,
Derick Montague602e98a2020-10-21 16:20:00 -0500137 render: (h) => h(App),
Derick Montaguefded0d12019-12-11 06:16:40 -0600138}).$mount('#app');
Konstantinfb6c6de2023-06-14 17:23:14 +0300139Vue.prototype.$eventBus = eventBus;