2 lines
8.5 KiB
JavaScript
2 lines
8.5 KiB
JavaScript
import{e as T,f as S,g as $,c as n,a as e,t as a,i as t,F as A,r as F,j as x,x as j,y as P,z as W,A as E,d as M,l as d,h as J,o as l,k as D,m as I}from"./BIbQr1Hg.js";import{_ as L}from"./DlAUqK2U.js";const O={class:"mb-8"},U={class:"text-2xl font-bold text-white"},R={class:"text-slate-400 mt-1"},q={key:0,class:"flex items-center justify-center py-20"},G={class:"text-slate-400 flex items-center gap-3"},K={key:1,class:"bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8"},Q={class:"text-rose-400"},X={key:2,class:"bg-slate-800 rounded-xl border border-slate-700 overflow-hidden"},Y={class:"w-full"},Z={class:"border-b border-slate-700"},ee={class:"text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},te={class:"text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},se={class:"text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},ae={class:"text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},oe={class:"text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},ie={class:"text-right px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},ne={class:"divide-y divide-slate-700/50"},le={class:"px-6 py-4"},re={class:"text-sm font-mono text-amber-300 bg-amber-500/10 px-2 py-0.5 rounded"},ce={class:"px-6 py-4"},de=["title"],ue={class:"px-6 py-4"},me={class:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-slate-500/10 text-slate-400"},pe={class:"px-6 py-4"},xe={class:"px-6 py-4 text-sm text-slate-400"},fe={class:"px-6 py-4 text-right"},he=["onClick","title"],_e={key:0},ge={colspan:"6",class:"px-6 py-12 text-center text-sm text-slate-500"},ve={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 w-full max-w-lg mx-4 shadow-2xl"},be={class:"text-lg font-semibold text-white mb-2"},ye={class:"text-sm text-slate-400 mb-6"},ke={class:"text-amber-300 font-mono text-xs"},we={class:"block text-sm font-medium text-slate-300 mb-1"},Ce=["placeholder"],je={key:0,class:"mt-1 text-xs text-emerald-400"},Me={key:1,class:"mt-1 text-xs text-slate-500"},Be={key:0,class:"bg-rose-500/10 border border-rose-500/30 rounded-lg p-3"},Ve={class:"text-sm text-rose-400"},ze={class:"flex justify-end gap-3 pt-2"},Ne=["disabled"],He={key:0,class:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Te={key:4,class:"fixed bottom-6 right-6 z-50 bg-emerald-600 text-white px-4 py-3 rounded-lg shadow-lg text-sm flex items-center gap-2 animate-slide-up"},Se=T({__name:"parameters",setup($e){const{t:o}=S(),h=d(!0),_=d(!1),m=d(!1),g=d([]),v=d(!1),p=d(null),c=d(""),u=d(""),f=d(""),w=I(()=>{if(!c.value)return!1;const s=c.value.trim();return s.startsWith("{")&&s.endsWith("}")||s.startsWith("[")&&s.endsWith("]")});function C(){const i=J("access_token").value;return i?{Authorization:`Bearer ${i}`,"Content-Type":"application/json"}:{"Content-Type":"application/json"}}function B(s){f.value=s,setTimeout(()=>{f.value=""},3e3)}function b(s){if(s==null)return"—";if(typeof s=="object")try{return JSON.stringify(s)}catch{return String(s)}return String(s)}function V(s,i){return s.length<=i?s:s.substring(0,i)+"..."}function z(s){switch(s?.toLowerCase()){case"global":return"bg-emerald-500/10 text-emerald-400";case"country":return"bg-blue-500/10 text-blue-400";case"region":return"bg-violet-500/10 text-violet-400";case"user":return"bg-amber-500/10 text-amber-400";default:return"bg-slate-500/10 text-slate-400"}}function N(s){p.value=s,c.value=b(s.value),u.value="",v.value=!0}function y(){v.value=!1,p.value=null,c.value="",u.value=""}async function k(){h.value=!0,_.value=!1;try{const s=await $fetch("/api/v1/admin/gamification/system-params",{headers:C()});g.value=s}catch(s){console.error("Failed to fetch system params:",s),_.value=!0}finally{h.value=!1}}async function H(){if(!p.value)return;m.value=!0,u.value="";let s;try{if(w.value)s=JSON.parse(c.value);else{const i=Number(c.value);s=isNaN(i)?c.value:i}}catch(i){u.value=o("gamification.params.invalid_json")+" "+(i.message||""),m.value=!1;return}try{await $fetch(`/api/v1/admin/gamification/system-params/${p.value.key}`,{method:"PUT",headers:C(),body:{value:s}}),B(o("gamification.params.updated",{key:p.value.key})),y(),await k()}catch(i){u.value=o("gamification.params.save_error"),console.error("Failed to save system param:",i)}finally{m.value=!1}}return $(()=>{k()}),(s,i)=>(l(),n("div",null,[e("div",O,[e("h1",U,a(t(o)("gamification.params.title")),1),e("p",R,a(t(o)("gamification.params.subtitle")),1)]),t(h)?(l(),n("div",q,[e("div",G,[i[1]||(i[1]=e("svg",{class:"w-5 h-5 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})],-1)),e("span",null,a(t(o)("gamification.params.loading")),1)])])):t(_)?(l(),n("div",K,[e("p",Q,a(t(o)("gamification.params.load_error")),1),e("button",{onClick:k,class:"mt-3 text-sm text-rose-300 hover:text-rose-200 underline"},a(t(o)("gamification.params.retry")),1)])):(l(),n("div",X,[e("table",Y,[e("thead",null,[e("tr",Z,[e("th",ee,a(t(o)("gamification.params.col_key")),1),e("th",te,a(t(o)("gamification.params.col_value")),1),e("th",se,a(t(o)("gamification.params.col_category")),1),e("th",ae,a(t(o)("gamification.params.col_scope")),1),e("th",oe,a(t(o)("gamification.params.col_scope_id")),1),e("th",ie,a(t(o)("gamification.params.col_actions")),1)])]),e("tbody",ne,[(l(!0),n(A,null,F(t(g),r=>(l(),n("tr",{key:r.key,class:"hover:bg-slate-700/30 transition"},[e("td",le,[e("code",re,a(r.key),1)]),e("td",ce,[e("span",{class:"text-sm text-slate-300 max-w-xs truncate block font-mono",title:b(r.value)},a(V(b(r.value),60)),9,de)]),e("td",ue,[e("span",me,a(r.category||"—"),1)]),e("td",pe,[e("span",{class:D(["inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",z(r.scope_level)])},a(r.scope_level),3)]),e("td",xe,a(r.scope_id||"—"),1),e("td",fe,[e("button",{onClick:Ae=>N(r),class:"p-1.5 rounded-lg text-slate-400 hover:text-white hover:bg-slate-700 transition",title:t(o)("gamification.params.edit")},[...i[2]||(i[2]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)])],8,he)])]))),128)),t(g).length===0?(l(),n("tr",_e,[e("td",ge,a(t(o)("gamification.params.empty")),1)])):x("",!0)])])])),t(v)?(l(),n("div",{key:3,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:j(y,["self"])},[e("div",ve,[e("h2",be,a(t(o)("gamification.params.edit_title")),1),e("p",ye,[e("code",ke,a(t(p)?.key),1)]),e("form",{onSubmit:j(H,["prevent"]),class:"space-y-4"},[e("div",null,[e("label",we,a(t(o)("gamification.params.value_label")),1),P(e("textarea",{"onUpdate:modelValue":i[0]||(i[0]=r=>E(c)?c.value=r:null),rows:"6",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white font-mono text-sm placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-amber-500/50 focus:border-amber-500 resize-none",spellcheck:"false",placeholder:t(o)("gamification.params.value_placeholder")},null,8,Ce),[[W,t(c)]]),t(w)?(l(),n("p",je,a(t(o)("gamification.params.json_detected")),1)):(l(),n("p",Me,a(t(o)("gamification.params.text_value")),1))]),t(u)?(l(),n("div",Be,[e("p",Ve,a(t(u)),1)])):x("",!0),e("div",ze,[e("button",{type:"button",onClick:y,class:"px-4 py-2 text-sm text-slate-400 hover:text-white transition"},a(t(o)("gamification.params.cancel")),1),e("button",{type:"submit",disabled:t(m),class:"px-4 py-2 bg-amber-600 hover:bg-amber-500 disabled:bg-amber-600/50 text-white rounded-lg text-sm font-medium transition flex items-center gap-2"},[t(m)?(l(),n("svg",He,[...i[3]||(i[3]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},null,-1)])])):x("",!0),M(" "+a(t(m)?t(o)("gamification.params.saving"):t(o)("gamification.params.save")),1)],8,Ne)])],32)])])):x("",!0),t(f)?(l(),n("div",Te,[i[4]||(i[4]=e("svg",{class:"w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),M(" "+a(t(f)),1)])):x("",!0)]))}}),We=L(Se,[["__scopeId","data-v-8222d5f7"]]);export{We as default};
|