1import { createApp } from 'vue'; 2 3import App from './App.vue'; 4import i18n from './i18n'; 5 6import router from './router'; 7 8import { format } from 'date-fns-tz'; 9 10//Do not change store import. 11//Exact match alias set to support 12//dotenv customizations. 13import store from './store'; 14import eventBus from './eventBus'; 15import { ToastPlugin } from './plugins/toast'; 16 17import { 18 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'; 77 78const 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 146app.use(i18n); 147app.use(router); 148app.use(store); 149app.use(ToastPlugin); 150 151app.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 163//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; 204 205app.mount('#app'); 206