Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 1 | import { createApp } from 'vue'; |
| 2 | |
Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 3 | import App from './App.vue'; |
Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 4 | import i18n from './i18n'; |
| 5 | |
Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 6 | import router from './router'; |
Yoshie Muranaka | 8263d85 | 2020-10-16 07:58:06 -0700 | [diff] [blame] | 7 | |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 8 | import { format } from 'date-fns-tz'; |
Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 9 | |
Yoshie Muranaka | 8263d85 | 2020-10-16 07:58:06 -0700 | [diff] [blame] | 10 | //Do not change store import. |
| 11 | //Exact match alias set to support |
| 12 | //dotenv customizations. |
Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 13 | import store from './store'; |
Konstantin | fb6c6de | 2023-06-14 17:23:14 +0300 | [diff] [blame] | 14 | import eventBus from './eventBus'; |
Yoshie Muranaka | 8263d85 | 2020-10-16 07:58:06 -0700 | [diff] [blame] | 15 | |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 16 | import { |
Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 17 | BootstrapVue, |
Derick Montague | 676f2fc | 2019-12-23 20:53:49 -0600 | [diff] [blame] | 18 | AlertPlugin, |
Dixsie Wolmers | 97d86b3 | 2019-12-02 05:07:57 -0600 | [diff] [blame] | 19 | BadgePlugin, |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 20 | ButtonPlugin, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 21 | BVConfigPlugin, |
Yoshie Muranaka | 92a0a4a | 2020-07-15 10:30:31 -0700 | [diff] [blame] | 22 | CardPlugin, |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 23 | CollapsePlugin, |
Yoshie Muranaka | 82cca54 | 2020-04-07 10:20:37 -0700 | [diff] [blame] | 24 | DropdownPlugin, |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 25 | FormPlugin, |
Dixsie Wolmers | 97d86b3 | 2019-12-02 05:07:57 -0600 | [diff] [blame] | 26 | FormCheckboxPlugin, |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 27 | FormDatepickerPlugin, |
Yoshie Muranaka | 3739381 | 2020-03-24 15:25:24 -0700 | [diff] [blame] | 28 | FormFilePlugin, |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 29 | FormGroupPlugin, |
| 30 | FormInputPlugin, |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 31 | FormRadioPlugin, |
| 32 | FormSelectPlugin, |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 33 | FormTagsPlugin, |
Yoshie Muranaka | c4e38ab | 2020-04-09 12:41:27 -0700 | [diff] [blame] | 34 | InputGroupPlugin, |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 35 | LayoutPlugin, |
Derick Montague | 42c1989 | 2020-01-17 16:10:34 -0600 | [diff] [blame] | 36 | LinkPlugin, |
Dixsie Wolmers | 97d86b3 | 2019-12-02 05:07:57 -0600 | [diff] [blame] | 37 | ListGroupPlugin, |
Derick Montague | 42c1989 | 2020-01-17 16:10:34 -0600 | [diff] [blame] | 38 | ModalPlugin, |
| 39 | NavbarPlugin, |
| 40 | NavPlugin, |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 41 | PaginationPlugin, |
Yoshie Muranaka | 3be801a | 2020-04-21 11:34:56 -0700 | [diff] [blame] | 42 | ProgressPlugin, |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 43 | TablePlugin, |
Dixsie Wolmers | c4b8757 | 2021-10-07 16:15:50 -0500 | [diff] [blame] | 44 | TabsPlugin, |
Yoshie Muranaka | 1be6b41 | 2020-04-16 12:03:38 -0700 | [diff] [blame] | 45 | ToastPlugin, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 46 | TooltipPlugin, |
Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 47 | } from 'bootstrap-vue'; |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 48 | |
Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 49 | const app = createApp({ |
| 50 | router, |
| 51 | store, |
| 52 | render: (h) => h(App), |
| 53 | }); |
| 54 | app.use(i18n); |
| 55 | |
| 56 | app.use(router); |
| 57 | app.use(store); |
Dixsie Wolmers | 97f4187 | 2020-02-23 15:56:16 -0600 | [diff] [blame] | 58 | |
| 59 | // Plugins |
Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 60 | app.use(BootstrapVue); |
| 61 | app.use(AlertPlugin); |
| 62 | app.use(BadgePlugin); |
| 63 | app.use(ButtonPlugin); |
| 64 | app.use(BVConfigPlugin, { |
Derick Montague | 7f970a1 | 2020-03-02 17:56:09 -0600 | [diff] [blame] | 65 | BFormText: { textVariant: 'secondary' }, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 66 | BTable: { |
| 67 | headVariant: 'light', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 68 | footVariant: 'light', |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 69 | }, |
| 70 | BFormTags: { |
| 71 | tagVariant: 'primary', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 72 | addButtonVariant: 'link-primary', |
Yoshie Muranaka | 82cca54 | 2020-04-07 10:20:37 -0700 | [diff] [blame] | 73 | }, |
| 74 | BBadge: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 75 | variant: 'primary', |
| 76 | }, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 77 | }); |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 78 | |
Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 79 | app.use(CardPlugin); |
| 80 | app.use(CollapsePlugin); |
| 81 | app.use(DropdownPlugin); |
| 82 | app.use(FormPlugin); |
| 83 | app.use(FormCheckboxPlugin); |
| 84 | app.use(FormDatepickerPlugin); |
| 85 | app.use(FormFilePlugin); |
| 86 | app.use(FormGroupPlugin); |
| 87 | app.use(FormInputPlugin); |
| 88 | app.use(FormRadioPlugin); |
| 89 | app.use(FormSelectPlugin); |
| 90 | app.use(FormTagsPlugin); |
| 91 | app.use(InputGroupPlugin); |
| 92 | app.use(LayoutPlugin); |
| 93 | app.use(LayoutPlugin); |
| 94 | app.use(LinkPlugin); |
| 95 | app.use(ListGroupPlugin); |
| 96 | app.use(ModalPlugin); |
| 97 | app.use(NavbarPlugin); |
| 98 | app.use(NavPlugin); |
| 99 | app.use(PaginationPlugin); |
| 100 | app.use(ProgressPlugin); |
| 101 | app.use(TablePlugin); |
| 102 | app.use(TabsPlugin); |
| 103 | app.use(ToastPlugin); |
| 104 | app.use(TooltipPlugin); |
| 105 | |
| 106 | app.mount('#app'); |
| 107 | app.prototype.$eventBus = eventBus; |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 108 | //Filters |
| 109 | const filter = { |
| 110 | formatDate(value) { |
| 111 | const isUtcDisplay = store.getters['global/isUtcDisplay']; |
| 112 | |
| 113 | if (value instanceof Date) { |
| 114 | if (isUtcDisplay) { |
| 115 | return value.toISOString().substring(0, 10); |
| 116 | } |
| 117 | const pattern = `yyyy-MM-dd`; |
| 118 | const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; |
| 119 | return format(value, pattern, { timezone }); |
| 120 | } |
| 121 | }, |
| 122 | formatTime(value) { |
| 123 | const isUtcDisplay = store.getters['global/isUtcDisplay']; |
| 124 | |
| 125 | if (value instanceof Date) { |
| 126 | if (isUtcDisplay) { |
| 127 | let timeOptions = { |
| 128 | timeZone: 'UTC', |
| 129 | hourCycle: 'h23', |
| 130 | }; |
| 131 | return `${value.toLocaleTimeString('default', timeOptions)} UTC`; |
| 132 | } |
| 133 | const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; |
| 134 | const shortTz = this.shortTimeZone(value); |
| 135 | const pattern = `HH:mm:ss ('${shortTz}' O)`; |
| 136 | return format(value, pattern, { timezone }).replace('GMT', 'UTC'); |
| 137 | } |
| 138 | }, |
| 139 | shortTimeZone(value) { |
| 140 | const longTZ = value |
| 141 | .toString() |
| 142 | .match(/\((.*)\)/) |
| 143 | .pop(); |
| 144 | const regexNotUpper = /[*a-z ]/g; |
| 145 | return longTZ.replace(regexNotUpper, ''); |
| 146 | }, |
| 147 | }; |
| 148 | app.config.globalProperties.$filters = filter; |