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 | |
Surya V | 603cfbf | 2024-07-11 15:19:46 +0530 | [diff] [blame^] | 8 | import { format } from 'date-fns-tz'; |
Ed Tanous | 9c72979 | 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 | |
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 | |
Ed Tanous | 9c72979 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 55 | const app = createApp({ |
| 56 | router, |
| 57 | store, |
| 58 | render: (h) => h(App), |
| 59 | }); |
| 60 | app.use(i18n); |
| 61 | |
| 62 | app.use(router); |
| 63 | app.use(store); |
Dixsie Wolmers | 97f4187 | 2020-02-23 15:56:16 -0600 | [diff] [blame] | 64 | |
| 65 | // Plugins |
Ed Tanous | 9c72979 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 66 | app.use(BootstrapVue); |
| 67 | app.use(AlertPlugin); |
| 68 | app.use(BadgePlugin); |
| 69 | app.use(ButtonPlugin); |
| 70 | app.use(BVConfigPlugin, { |
Derick Montague | 7f970a1 | 2020-03-02 17:56:09 -0600 | [diff] [blame] | 71 | BFormText: { textVariant: 'secondary' }, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 72 | BTable: { |
| 73 | headVariant: 'light', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 74 | footVariant: 'light', |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 75 | }, |
| 76 | BFormTags: { |
| 77 | tagVariant: 'primary', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 78 | addButtonVariant: 'link-primary', |
Yoshie Muranaka | 82cca54 | 2020-04-07 10:20:37 -0700 | [diff] [blame] | 79 | }, |
| 80 | BBadge: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 81 | variant: 'primary', |
| 82 | }, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 83 | }); |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 84 | |
Ed Tanous | 9c72979 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 85 | app.use(CardPlugin); |
| 86 | app.use(CollapsePlugin); |
| 87 | app.use(DropdownPlugin); |
| 88 | app.use(FormPlugin); |
| 89 | app.use(FormCheckboxPlugin); |
| 90 | app.use(FormDatepickerPlugin); |
| 91 | app.use(FormFilePlugin); |
| 92 | app.use(FormGroupPlugin); |
| 93 | app.use(FormInputPlugin); |
| 94 | app.use(FormRadioPlugin); |
| 95 | app.use(FormSelectPlugin); |
| 96 | app.use(FormTagsPlugin); |
| 97 | app.use(InputGroupPlugin); |
| 98 | app.use(LayoutPlugin); |
| 99 | app.use(LayoutPlugin); |
| 100 | app.use(LinkPlugin); |
| 101 | app.use(ListGroupPlugin); |
| 102 | app.use(ModalPlugin); |
| 103 | app.use(NavbarPlugin); |
| 104 | app.use(NavPlugin); |
| 105 | app.use(PaginationPlugin); |
| 106 | app.use(ProgressPlugin); |
| 107 | app.use(TablePlugin); |
| 108 | app.use(TabsPlugin); |
| 109 | app.use(ToastPlugin); |
| 110 | app.use(TooltipPlugin); |
| 111 | |
| 112 | app.mount('#app'); |
| 113 | app.prototype.$eventBus = eventBus; |
Surya V | 603cfbf | 2024-07-11 15:19:46 +0530 | [diff] [blame^] | 114 | //Filters |
| 115 | const filter = { |
| 116 | formatDate(value) { |
| 117 | const isUtcDisplay = store.getters['global/isUtcDisplay']; |
| 118 | |
| 119 | if (value instanceof Date) { |
| 120 | if (isUtcDisplay) { |
| 121 | return value.toISOString().substring(0, 10); |
| 122 | } |
| 123 | const pattern = `yyyy-MM-dd`; |
| 124 | const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; |
| 125 | return format(value, pattern, { timezone }); |
| 126 | } |
| 127 | }, |
| 128 | formatTime(value) { |
| 129 | const isUtcDisplay = store.getters['global/isUtcDisplay']; |
| 130 | |
| 131 | if (value instanceof Date) { |
| 132 | if (isUtcDisplay) { |
| 133 | let timeOptions = { |
| 134 | timeZone: 'UTC', |
| 135 | hourCycle: 'h23', |
| 136 | }; |
| 137 | return `${value.toLocaleTimeString('default', timeOptions)} UTC`; |
| 138 | } |
| 139 | const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; |
| 140 | const shortTz = this.shortTimeZone(value); |
| 141 | const pattern = `HH:mm:ss ('${shortTz}' O)`; |
| 142 | return format(value, pattern, { timezone }).replace('GMT', 'UTC'); |
| 143 | } |
| 144 | }, |
| 145 | shortTimeZone(value) { |
| 146 | const longTZ = value |
| 147 | .toString() |
| 148 | .match(/\((.*)\)/) |
| 149 | .pop(); |
| 150 | const regexNotUpper = /[*a-z ]/g; |
| 151 | return longTZ.replace(regexNotUpper, ''); |
| 152 | }, |
| 153 | }; |
| 154 | app.config.globalProperties.$filters = filter; |