Merge branch 'main' of github.com:Frappet/hrms-landing
* 'main' of github.com:Frappet/hrms-landing: api # Conflicts: # src/api/index.ts
This commit is contained in:
commit
146dcb9028
3 changed files with 48 additions and 11 deletions
|
|
@ -1,7 +1,17 @@
|
|||
import env from "./index";
|
||||
const sso = `${env.API_SSO}`;
|
||||
// const log = `${env.API_URI}/log`;
|
||||
// const log = `${env.URI}/log`;
|
||||
const URL_ADMIN = `${env.URL_ADMIN}`;
|
||||
const URL_USER = `${env.URL_USER}`;
|
||||
const URL_MGT = `${env.URL_MGT}`;
|
||||
const URL_CHECKIN = `${env.URL_CHECKIN}`;
|
||||
const URL_SSO = `${env.URL_SSO}`;
|
||||
|
||||
export default {
|
||||
sso,
|
||||
URL_ADMIN,
|
||||
URL_USER,
|
||||
URL_MGT,
|
||||
URL_CHECKIN,
|
||||
URL_SSO,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ import { ref } from "vue";
|
|||
const env = ref<string>(process.env.NODE_ENV || "development");
|
||||
export const apiUrlConfig = import.meta.env.VITE_API_URI_CONFIG;
|
||||
export const apiUrlSsoConfig = import.meta.env.VITE_API_SSO;
|
||||
export const urlAdmin = import.meta.env.VITE_URL_ADMIN;
|
||||
export const urlUser = import.meta.env.VITE_URL_USER;
|
||||
export const urlMgt = import.meta.env.VITE_URL_MGT;
|
||||
export const urlCheckin = import.meta.env.VITE_URL_CHECKIN;
|
||||
export const urlSSO = import.meta.env.VITE_URL_SSO;
|
||||
|
||||
// if (process.env.VUE_APP_TEST) {
|
||||
// env = "test";
|
||||
// }
|
||||
|
|
@ -13,6 +19,11 @@ const config = ref<any>({
|
|||
// API_URI: "https://localhost:7260/api",
|
||||
API_URI: "https://bma-ehr.frappet.synology.me/api/v1",
|
||||
API_SSO: "https://localhost:3001/api/v1",
|
||||
URL_ADMIN: urlAdmin,
|
||||
URL_USER: urlUser,
|
||||
URL_MGT: urlMgt,
|
||||
URL_CHECKIN: urlCheckin,
|
||||
URL_SSO: urlSSO,
|
||||
},
|
||||
test: {
|
||||
API_URI: "http://localhost:5010/api/v1",
|
||||
|
|
@ -20,15 +31,31 @@ const config = ref<any>({
|
|||
production: {
|
||||
API_URI: apiUrlConfig,
|
||||
API_SSO: apiUrlSsoConfig,
|
||||
URL_ADMIN: urlAdmin,
|
||||
URL_USER: urlUser,
|
||||
URL_MGT: urlMgt,
|
||||
URL_CHECKIN: urlCheckin,
|
||||
URL_SSO: urlSSO,
|
||||
},
|
||||
});
|
||||
|
||||
const API_URI = ref<string>(config.value[env.value].API_URI);
|
||||
const API_SSO = ref<string>(config.value[env.value].API_SSO);
|
||||
|
||||
const URL_ADMIN = ref<string>(config.value[env.value].URL_ADMIN);
|
||||
const URL_USER = ref<string>(config.value[env.value].URL_USER);
|
||||
const URL_MGT = ref<string>(config.value[env.value].URL_MGT);
|
||||
const URL_CHECKIN = ref<string>(config.value[env.value].URL_CHECKIN);
|
||||
const URL_SSO = ref<string>(config.value[env.value].URL_SSO);
|
||||
|
||||
export default {
|
||||
env: env.value,
|
||||
config: config.value,
|
||||
API_URI: API_URI.value,
|
||||
API_SSO: API_SSO.value,
|
||||
URL_ADMIN: URL_ADMIN.value,
|
||||
URL_USER: URL_USER.value,
|
||||
URL_MGT: URL_MGT.value,
|
||||
URL_CHECKIN: URL_CHECKIN.value,
|
||||
URL_SSO: URL_SSO.value,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ import type { DateCards } from "@/interface/index/Main";
|
|||
|
||||
const $q = useQuasar();
|
||||
|
||||
const urlAdmin = import.meta.env.VITE_URL_ADMIN ?? "";
|
||||
const urlUser = import.meta.env.VITE_URL_USER ?? "";
|
||||
const urlMgt = import.meta.env.VITE_URL_MGT ?? "";
|
||||
const urlCheckin = import.meta.env.VITE_URL_CHECKIN ?? "";
|
||||
const urlAdmin = config.API.URL_ADMIN;
|
||||
const urlUser = config.API.URL_USER;
|
||||
const urlMgt = config.API.URL_MGT;
|
||||
const urlCheckin = config.API.URL_CHECKIN;
|
||||
|
||||
const cards = ref<DateCards[]>([
|
||||
{
|
||||
|
|
@ -83,8 +83,8 @@ async function goPage(sys: string, url: string) {
|
|||
requiredRole = ["ADMIN", "SUPER_ADMIN"];
|
||||
}
|
||||
|
||||
console.log("requiredRole===>", requiredRole);
|
||||
console.log("decoded===>", JSON.parse(decoded).realm_access.roles);
|
||||
// console.log("requiredRole===>", requiredRole);
|
||||
// console.log("decoded===>", JSON.parse(decoded).realm_access.roles);
|
||||
|
||||
// ตรวจสอบว่า payload.role มีค่าหรือไม่ และว่ามี role ที่ต้องการหรือไม่
|
||||
if (
|
||||
|
|
@ -112,7 +112,8 @@ async function logout() {
|
|||
await deleteCookie("BMAHRIS_KEYCLOAK_IDENTITY");
|
||||
await deleteCookie("BMAHRIS_KEYCLOAK_REFRESH");
|
||||
|
||||
window.location.href = `${import.meta.env.VITE_URL_SSO}`;
|
||||
// ยิง logout เข้าระบบ
|
||||
window.location.href = `${config.API.URL_SSO}`;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
|
|
@ -138,11 +139,10 @@ onMounted(async () => {
|
|||
}
|
||||
)
|
||||
.then((res: any) => {
|
||||
console.log("res===>", res);
|
||||
|
||||
if (res.status === 200) {
|
||||
setCookie("BMAHRIS_KEYCLOAK_IDENTITY", res.data.access_token, 1);
|
||||
setCookie("BMAHRIS_KEYCLOAK_REFRESH", res.data.refresh_token, 1);
|
||||
// ยิง log เข้าระบบ
|
||||
}
|
||||
})
|
||||
.catch((err: any) => {
|
||||
|
|
@ -207,7 +207,7 @@ onMounted(async () => {
|
|||
class="q-mt-xl"
|
||||
:class="!$q.screen.gt.md ? 'row justify-center' : ''"
|
||||
>
|
||||
<div class="q-col-gutter-md" :class="$q.screen.gt.md ? 'row' : ''">
|
||||
<div class="q-col-gutter-lg" :class="$q.screen.gt.md ? 'row' : ''">
|
||||
<div class="col" v-for="(card, index) in cards" :key="index">
|
||||
<q-card
|
||||
:style="!$q.screen.gt.md ? 'width: 300px' : ''"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue