fix: sw버전, 유저 아이디 데이터 수정

main
jschoi 7 months ago
parent 095288e44d
commit 0f48a0d01e

@ -10,9 +10,9 @@ import {
type PackageOption = { label: string; value: string; raw: any };
type MinioRegisterModel = EdgePkgInfoVOModel & {
objectName: string; // props.artifactPath
objectName: string;
type: "type1" | "type2";
localPath: string; // (: downloads/temp)
localPath: string;
};
const props = defineProps<{
@ -34,7 +34,7 @@ const emit = defineEmits<{
const form = ref({
package_id: "",
sw_id: "",
sw_version: "1",
sw_version: "",
software_name: "",
executed: true,
file_type: "bundle" as "bundle" | "single",
@ -79,16 +79,6 @@ const pkgOptions = computed<PackageOption[]>(() =>
/* ========================= 표시/숨김 스위치 ========================= */
const showArtifactPath = computed(() => !!props.artifactPath);
const showUploadFile = computed(() => !showArtifactPath.value);
function getCurrentUserId(): string {
// id ,
try {
const raw = localStorage.getItem("external-auth");
const obj = raw ? JSON.parse(raw) : null;
return obj?.userInfo?.username ?? obj?.userInfo?.id ?? obj?.id ?? "admin";
} catch {
return "admin";
}
}
async function fetchPackages() {
remoteError.value = "";
@ -104,7 +94,13 @@ async function fetchPackages() {
return;
}
const id = getCurrentUserId(); // ex) 'admin'
let id: string;
try {
id = getRequiredExternalAuthId(); // external-auth.id
} catch (e: any) {
remoteError.value = e?.message || "external-auth의 id가 필요합니다.";
return;
}
try {
remoteLoading.value = true;
@ -202,7 +198,23 @@ function onPickPackage() {
else if (form.value.linux_exe_name || form.value.linux_root_path)
form.value.os = "Linux";
}
function getRequiredExternalAuthId(): string {
try {
const raw = localStorage.getItem("external-auth");
const obj = raw ? JSON.parse(raw) : null;
const id = obj?.id;
if (id === undefined || id === null || String(id).trim() === "") {
throw new Error(
"external-auth의 id가 없습니다. 로그인 후 다시 시도하세요.",
);
}
return String(id);
} catch {
throw new Error(
"external-auth의 id를 읽을 수 없습니다. 로그인 후 다시 시도하세요.",
);
}
}
/* ========================= 기타 계산값 ========================= */
const isWin = computed(() => form.value.os === "Windows");
const isLinux = computed(() => form.value.os === "Linux");
@ -211,16 +223,6 @@ const archiveTypeCode = computed(() =>
);
const swTypeCode = computed(() => (sourceType.value === "edge" ? 1 : 0));
function getCurrentUserIdForSubmit(): string {
try {
const raw = localStorage.getItem("external-auth");
const obj = raw ? JSON.parse(raw) : null;
return obj?.userInfo?.username ? String(obj.userInfo.username) : "admin";
} catch {
return "admin";
}
}
const toInt = (v: unknown, fallback = 1) => {
const n = parseInt(String(v ?? "").trim(), 10);
return Number.isFinite(n) ? n : fallback;
@ -238,6 +240,13 @@ async function submit() {
return (errorMsg.value = "설치 위치를 입력하세요.");
if (!props.token) return (errorMsg.value = "토큰이 없습니다.");
if (!selectedRaw.value) return (errorMsg.value = "패키지를 선택하세요.");
let userId: string;
try {
userId = getRequiredExternalAuthId();
} catch (e: any) {
errorMsg.value = e?.message || "external-auth의 id가 필요합니다.";
return;
}
const adSerial =
selectedRaw.value?.ad_pkg_serial ?? selectedRaw.value?.adPkgSerial;
const edSerial =
@ -250,7 +259,7 @@ async function submit() {
pkg_serial: number;
} = {
sw_id: (form.value.sw_id || "").trim(),
sw_version: Number.parseInt(String(form.value.sw_version || "1"), 10) || 1,
sw_version: parseFloat(String(form.value.sw_version)),
sw_name: (form.value.software_name || "").trim(),
authId: props.token,
pkg_serial: pkgSerial,
@ -258,7 +267,7 @@ async function submit() {
execYn: form.value.executed ? 1 : 0,
secretAt: !!form.value.private_only,
downloadLocation: (form.value.install_location || "").trim(),
user_id: getCurrentUserIdForSubmit() || "admin",
user_id: userId,
sw_type: sourceType.value === "edge" ? 1 : 0,
creation_datetime: new Date().toISOString(),
};
@ -433,6 +442,8 @@ onBeforeUnmount(() => window.removeEventListener("keydown", onEsc));
v-model="form.sw_version"
type="number"
min="0"
step="0.01"
inputmode="decimal"
/>
</v-col>
<v-col cols="12"

Loading…
Cancel
Save