blob: 92c5c903e44f9d39855d90de6fb8749a574ef010 [file] [log] [blame]
Ed Tanous9c729792024-03-23 14:56:34 -07001import { createApp } from 'vue';
2
Derick Montaguefded0d12019-12-11 06:16:40 -06003import App from './App.vue';
Ed Tanous9c729792024-03-23 14:56:34 -07004import i18n from './i18n';
5
Derick Montaguefded0d12019-12-11 06:16:40 -06006import router from './router';
Yoshie Muranaka8263d852020-10-16 07:58:06 -07007
Surya V603cfbf2024-07-11 15:19:46 +05308import { format } from 'date-fns-tz';
Ed Tanous9c729792024-03-23 14:56:34 -07009
Yoshie Muranaka8263d852020-10-16 07:58:06 -070010//Do not change store import.
11//Exact match alias set to support
12//dotenv customizations.
Derick Montaguefded0d12019-12-11 06:16:40 -060013import store from './store';
Konstantinfb6c6de2023-06-14 17:23:14 +030014import eventBus from './eventBus';
Yoshie Muranaka8263d852020-10-16 07:58:06 -070015
Ed Tanous9c729792024-03-23 14:56:34 -070016import './assets/styles/bmc/helpers/_index.scss';
17import './assets/styles/bootstrap/_helpers.scss';
18
19import 'bootstrap/dist/css/bootstrap.css';
20import 'bootstrap-vue/dist/bootstrap-vue.css';
21
Derick Montaguea2988f42020-01-17 13:46:30 -060022import {
Ed Tanous9c729792024-03-23 14:56:34 -070023 BootstrapVue,
Derick Montague676f2fc2019-12-23 20:53:49 -060024 AlertPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060025 BadgePlugin,
Derick Montaguea2988f42020-01-17 13:46:30 -060026 ButtonPlugin,
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080027 BVConfigPlugin,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070028 CardPlugin,
Derick Montaguea2988f42020-01-17 13:46:30 -060029 CollapsePlugin,
Yoshie Muranaka82cca542020-04-07 10:20:37 -070030 DropdownPlugin,
Derick Montaguee080a1a2019-12-04 16:30:08 -060031 FormPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060032 FormCheckboxPlugin,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -070033 FormDatepickerPlugin,
Yoshie Muranaka37393812020-03-24 15:25:24 -070034 FormFilePlugin,
Derick Montaguee080a1a2019-12-04 16:30:08 -060035 FormGroupPlugin,
36 FormInputPlugin,
Yoshie Muranaka463a5702019-12-04 09:09:36 -080037 FormRadioPlugin,
38 FormSelectPlugin,
Yoshie Muranaka532a4b02020-03-27 11:00:50 -070039 FormTagsPlugin,
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -070040 InputGroupPlugin,
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060041 LayoutPlugin,
Derick Montague42c19892020-01-17 16:10:34 -060042 LinkPlugin,
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060043 ListGroupPlugin,
Derick Montague42c19892020-01-17 16:10:34 -060044 ModalPlugin,
45 NavbarPlugin,
46 NavPlugin,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -070047 PaginationPlugin,
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070048 ProgressPlugin,
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -080049 TablePlugin,
Dixsie Wolmersc4b87572021-10-07 16:15:50 -050050 TabsPlugin,
Yoshie Muranaka1be6b412020-04-16 12:03:38 -070051 ToastPlugin,
Derick Montague602e98a2020-10-21 16:20:00 -050052 TooltipPlugin,
Derick Montaguefded0d12019-12-11 06:16:40 -060053} from 'bootstrap-vue';
Derick Montaguea2988f42020-01-17 13:46:30 -060054
Ed Tanous9c729792024-03-23 14:56:34 -070055const app = createApp({
56 router,
57 store,
58 render: (h) => h(App),
59});
60app.use(i18n);
61
62app.use(router);
63app.use(store);
Dixsie Wolmers97f41872020-02-23 15:56:16 -060064
65// Plugins
Ed Tanous9c729792024-03-23 14:56:34 -070066app.use(BootstrapVue);
67app.use(AlertPlugin);
68app.use(BadgePlugin);
69app.use(ButtonPlugin);
70app.use(BVConfigPlugin, {
Derick Montague7f970a12020-03-02 17:56:09 -060071 BFormText: { textVariant: 'secondary' },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080072 BTable: {
73 headVariant: 'light',
Derick Montague602e98a2020-10-21 16:20:00 -050074 footVariant: 'light',
Yoshie Muranaka532a4b02020-03-27 11:00:50 -070075 },
76 BFormTags: {
77 tagVariant: 'primary',
Derick Montague602e98a2020-10-21 16:20:00 -050078 addButtonVariant: 'link-primary',
Yoshie Muranaka82cca542020-04-07 10:20:37 -070079 },
80 BBadge: {
Derick Montague602e98a2020-10-21 16:20:00 -050081 variant: 'primary',
82 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080083});
Derick Montaguea2988f42020-01-17 13:46:30 -060084
Ed Tanous9c729792024-03-23 14:56:34 -070085app.use(CardPlugin);
86app.use(CollapsePlugin);
87app.use(DropdownPlugin);
88app.use(FormPlugin);
89app.use(FormCheckboxPlugin);
90app.use(FormDatepickerPlugin);
91app.use(FormFilePlugin);
92app.use(FormGroupPlugin);
93app.use(FormInputPlugin);
94app.use(FormRadioPlugin);
95app.use(FormSelectPlugin);
96app.use(FormTagsPlugin);
97app.use(InputGroupPlugin);
98app.use(LayoutPlugin);
99app.use(LayoutPlugin);
100app.use(LinkPlugin);
101app.use(ListGroupPlugin);
102app.use(ModalPlugin);
103app.use(NavbarPlugin);
104app.use(NavPlugin);
105app.use(PaginationPlugin);
106app.use(ProgressPlugin);
107app.use(TablePlugin);
108app.use(TabsPlugin);
109app.use(ToastPlugin);
110app.use(TooltipPlugin);
111
112app.mount('#app');
113app.prototype.$eventBus = eventBus;
Surya V603cfbf2024-07-11 15:19:46 +0530114//Filters
115const 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};
154app.config.globalProperties.$filters = filter;