blob: 91dc8ecac6d2c0e2765e7f7481767b529f258fda [file] [log] [blame]
Ed Tanous7d6b44c2024-03-23 14:56:34 -07001import { createApp } from 'vue';
2
Derick Montaguefded0d12019-12-11 06:16:40 -06003import App from './App.vue';
Ed Tanous7d6b44c2024-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 Vde23ea22024-07-11 15:19:46 +05308import { format } from 'date-fns-tz';
Ed Tanous7d6b44c2024-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';
jason westoverd36ac8a2025-11-03 20:58:59 -060015import { ToastPlugin } from './plugins/toast';
Yoshie Muranaka8263d852020-10-16 07:58:06 -070016
Derick Montaguea2988f42020-01-17 13:46:30 -060017import {
jason westoverd36ac8a2025-11-03 20:58:59 -060018 BButton,
19 BContainer,
20 BForm,
21 BFormGroup,
22 BFormInput,
23 BFormCheckboxGroup,
24 BInputGroup,
25 BInputGroupText,
26 BFormSelect,
27 BFormSelectOption,
28 BFormFile,
29 BFormCheckbox,
30 BFormRadioGroup,
31 BFormRadio,
32 BFormText,
33 BFormTextarea,
34 BFormTags,
35 BFormInvalidFeedback,
36 BTable,
37 BToast,
38 BModal,
39 BCloseButton,
40 BAlert,
41 BCard,
42 BCardHeader,
43 BCardBody,
44 BCardFooter,
45 BCardGroup,
46 BRow,
47 BCol,
48 BBadge,
49 BSpinner,
50 BDropdown,
51 BDropdownItem,
52 BNav,
53 BNavbar,
54 BNavbarBrand,
55 BNavbarNav,
56 BNavItem,
57 BNavbarToggle,
58 BCollapse,
59 BPagination,
60 BTooltip,
61 BPopover,
62 BProgress,
63 BProgressBar,
64 BOverlay,
65 BListGroup,
66 BListGroupItem,
67 BTabs,
68 BTab,
69 BLink,
70 BOrchestrator,
71 createBootstrap,
72 vBToggle,
73 vBTooltip,
74 vBPopover,
75 vBModal,
76} from 'bootstrap-vue-next';
Derick Montaguea2988f42020-01-17 13:46:30 -060077
jason westoverd36ac8a2025-11-03 20:58:59 -060078const app = createApp(App);
79
80// Note: We register only the components/directives we need
81
82// Use createBootstrap for all bootstrap-vue-next plugins in 0.40.7+
83app.use(createBootstrap());
84
85app.component('BButton', BButton);
86app.component('BBtn', BButton);
87app.component('BContainer', BContainer);
88app.component('BForm', BForm);
89app.component('BFormGroup', BFormGroup);
90app.component('BFormInput', BFormInput);
91app.component('BFormCheckboxGroup', BFormCheckboxGroup);
92app.component('BInputGroup', BInputGroup);
93app.component('BInputGroupText', BInputGroupText);
94app.component('BFormSelect', BFormSelect);
95app.component('BFormSelectOption', BFormSelectOption);
96app.component('BFormFile', BFormFile);
97app.component('BFormCheckbox', BFormCheckbox);
98app.component('BFormRadioGroup', BFormRadioGroup);
99app.component('BFormRadio', BFormRadio);
100app.component('BFormText', BFormText);
101app.component('BFormTextarea', BFormTextarea);
102app.component('BFormTags', BFormTags);
103app.component('BFormInvalidFeedback', BFormInvalidFeedback);
104app.component('BTable', BTable);
105app.component('BToast', BToast);
106app.component('BModal', BModal);
107app.component('BCloseButton', BCloseButton);
108app.component('BAlert', BAlert);
109app.component('BCard', BCard);
110app.component('BCardHeader', BCardHeader);
111app.component('BCardBody', BCardBody);
112app.component('BCardFooter', BCardFooter);
113app.component('BCardGroup', BCardGroup);
114app.component('BRow', BRow);
115app.component('BCol', BCol);
116app.component('BBadge', BBadge);
117app.component('BSpinner', BSpinner);
118app.component('BDropdown', BDropdown);
119app.component('BDropdownItem', BDropdownItem);
120app.component('BNav', BNav);
121app.component('BNavbar', BNavbar);
122app.component('BNavbarBrand', BNavbarBrand);
123app.component('BNavbarNav', BNavbarNav);
124app.component('BNavItem', BNavItem);
125app.component('BNavbarToggle', BNavbarToggle);
126app.component('BCollapse', BCollapse);
127app.component('BPagination', BPagination);
128app.component('BTooltip', BTooltip);
129app.component('BPopover', BPopover);
130app.component('BProgress', BProgress);
131app.component('BProgressBar', BProgressBar);
132app.component('BOverlay', BOverlay);
133app.component('BListGroup', BListGroup);
134app.component('BListGroupItem', BListGroupItem);
135app.component('BTabs', BTabs);
136app.component('BTab', BTab);
137app.component('BLink', BLink);
138app.component('BOrchestrator', BOrchestrator);
139
140// Register BootstrapVue Next directives used in templates
141app.directive('b-toggle', vBToggle);
142app.directive('b-tooltip', vBTooltip);
143app.directive('b-popover', vBPopover);
144app.directive('b-modal', vBModal);
145
Ed Tanous7d6b44c2024-03-23 14:56:34 -0700146app.use(i18n);
Ed Tanous7d6b44c2024-03-23 14:56:34 -0700147app.use(router);
148app.use(store);
Ed Tanous7d6b44c2024-03-23 14:56:34 -0700149app.use(ToastPlugin);
Ed Tanous7d6b44c2024-03-23 14:56:34 -0700150
jason westoverd36ac8a2025-11-03 20:58:59 -0600151app.config.globalProperties.$eventBus = eventBus;
152app.config.globalProperties.$confirm = (messageOrOptions) => {
153 return new Promise((resolve) => {
154 eventBus.$emit('confirm:open', {
155 ...(typeof messageOrOptions === 'string'
156 ? { message: messageOrOptions }
157 : messageOrOptions),
158 resolve,
159 });
160 });
161};
162
Surya Vde23ea22024-07-11 15:19:46 +0530163//Filters
164const filter = {
165 formatDate(value) {
166 const isUtcDisplay = store.getters['global/isUtcDisplay'];
167
168 if (value instanceof Date) {
169 if (isUtcDisplay) {
170 return value.toISOString().substring(0, 10);
171 }
172 const pattern = `yyyy-MM-dd`;
173 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
174 return format(value, pattern, { timezone });
175 }
176 },
177 formatTime(value) {
178 const isUtcDisplay = store.getters['global/isUtcDisplay'];
179
180 if (value instanceof Date) {
181 if (isUtcDisplay) {
182 let timeOptions = {
183 timeZone: 'UTC',
184 hourCycle: 'h23',
185 };
186 return `${value.toLocaleTimeString('default', timeOptions)} UTC`;
187 }
188 const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
189 const shortTz = this.shortTimeZone(value);
190 const pattern = `HH:mm:ss ('${shortTz}' O)`;
191 return format(value, pattern, { timezone }).replace('GMT', 'UTC');
192 }
193 },
194 shortTimeZone(value) {
195 const longTZ = value
196 .toString()
197 .match(/\((.*)\)/)
198 .pop();
199 const regexNotUpper = /[*a-z ]/g;
200 return longTZ.replace(regexNotUpper, '');
201 },
202};
203app.config.globalProperties.$filters = filter;
jason westoverd36ac8a2025-11-03 20:58:59 -0600204
205app.mount('#app');