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