hrms-mgt/src/main.ts

113 lines
2.7 KiB
TypeScript
Raw Normal View History

2023-06-01 12:54:58 +07:00
import { createApp, defineAsyncComponent } from "vue";
import App from "./App.vue";
import router from "./router";
2023-06-06 20:33:39 +07:00
import { Dialog, Notify, Quasar, Loading } from "quasar";
import "./quasar-user-options";
2024-07-26 12:52:47 +07:00
import keycloak, { getToken } from "@/plugins/keycloak";
2024-07-23 16:33:59 +07:00
import qDraggableTable from "quasar-ui-q-draggable-table";
import "quasar-ui-q-draggable-table/dist/index.css";
2023-06-01 12:54:58 +07:00
import "quasar/src/css/index.sass";
import th from "quasar/lang/th";
import "@vuepic/vue-datepicker/dist/main.css";
import http from "./plugins/http";
import { createPinia } from "pinia";
// organization
// position
// positionEmployee
//calendar
// insignia
// import './assets/main.css'
// Import GlobalFilters
2023-06-09 11:39:54 +07:00
import filters from "./plugins/filters";
2023-06-01 12:54:58 +07:00
const app = createApp(App);
const pinia = createPinia();
// เพิ่ม Global Filters ลงใน App
app.config.globalProperties.$filters = filters;
app.use(router);
app.use(pinia);
app.use(qDraggableTable);
2023-06-01 12:54:58 +07:00
app.use(
Quasar,
{
plugins: {
Notify,
Dialog,
2023-06-06 20:33:39 +07:00
Loading,
2023-06-01 12:54:58 +07:00
}, // import Quasar plugins and add here
config: {
notify: {
/* look at QuasarConfOptions from the API card */
},
2023-06-06 20:33:39 +07:00
loading: {
/* look at QuasarConfOptions from the API card */
},
2023-06-01 12:54:58 +07:00
},
lang: th,
}
// quasarUserOptions // build ไม่ผ่านหลัง install code org&structure chart เลยต้องคอมเม้นไว้ก่อน เทสแล้วยังรันได้หลังคอมเม้น
);
//** Global Components */
app.component(
"data-table",
2023-06-09 11:39:54 +07:00
defineAsyncComponent(() => import("@/components/TableView.vue"))
2023-06-01 12:54:58 +07:00
);
app.component(
"datepicker",
defineAsyncComponent(() => import("@vuepic/vue-datepicker"))
);
app.component(
"full-loader",
2023-06-09 11:39:54 +07:00
defineAsyncComponent(() => import("@/components/FullLoader.vue"))
2023-06-01 12:54:58 +07:00
);
app.component(
"selector",
2023-06-09 11:39:54 +07:00
defineAsyncComponent(() => import("@/components/Selector.vue"))
2023-06-01 12:54:58 +07:00
);
app.component(
"d-table",
defineAsyncComponent(() => import("@/components/Table.vue"))
);
2023-06-01 12:54:58 +07:00
app.config.globalProperties.$http = http;
2024-07-23 16:33:59 +07:00
// authen with keycloak client
2024-07-26 12:52:47 +07:00
const auth = await getToken();
2024-07-23 16:33:59 +07:00
2024-07-26 12:52:47 +07:00
if (auth.token && auth.refresh_token) {
2024-07-25 12:58:04 +07:00
keycloak.init({
checkLoginIframe: false,
2024-07-26 12:52:47 +07:00
token: auth.token,
refreshToken: auth.refresh_token,
2024-07-25 12:58:04 +07:00
});
// .then((authenticated) => {
// console.log("authenticated", authenticated);
// if (!authenticated) {
// window.location.reload();
// } else {
// console.log("Authenticated");
// }
// })
// .catch((err) => {
// console.error("Keycloak initialization failed:", err);
// });
2024-07-23 16:33:59 +07:00
}
2024-07-31 09:48:33 +07:00
app.config.globalProperties.$checkPermission = function () {
console.log("This is a checkPermission");
return true;
};
2023-06-01 12:54:58 +07:00
app.mount("#app");