allinssl/frontend/static/js/index-BkMDfHPX.js

2 lines
13 KiB
JavaScript

import{d as e,J as t,S as a,r as l,K as o,c as n,o as r,a as i,m as s,s as c,$ as d,e as u,z as p,t as f,L as y,M as m,k as _,I as h,B as w,E as v,j as g,f as k,O as x,h as b,w as C,p as W,q as S,P as j,Q as T,v as O,x as E,G as z,H as P,R as L,i as D,T as H,C as R}from"./main-DVBEmEFd.js";import{g as q,a as A,u as F,e as V,b as N,d as B,c as M,f as U}from"./useStore-BwTk8hfc.js";import{u as $,N as I,a as J}from"./index-sztGZ9nB.js";import{B as K}from"./index-CB_F3NQ0.js";import{N as G}from"./text-BBOsWGWM.js";import{S as Q,P as X}from"./Search-B0uWYj_J.js";const Y=e({name:"Scrollbar",props:Object.assign(Object.assign({},o.props),{trigger:String,xScrollable:Boolean,onScroll:Function,contentClass:String,contentStyle:[Object,String],size:Number,yPlacement:{type:String,default:"right"},xPlacement:{type:String,default:"bottom"}}),setup(){const e=l(null),t={scrollTo:(...t)=>{var a;null===(a=e.value)||void 0===a||a.scrollTo(t[0],t[1])},scrollBy:(...t)=>{var a;null===(a=e.value)||void 0===a||a.scrollBy(t[0],t[1])}};return Object.assign(Object.assign({},t),{scrollbarInstRef:e})},render(){return t(a,Object.assign({ref:"scrollbarInstRef"},this.$props),this.$slots)}}),Z={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},ee=e({name:"DownloadOutline",render:function(e,t){return r(),n("svg",Z,t[0]||(t[0]=[i("path",{d:"M336 176h40a40 40 0 0 1 40 40v208a40 40 0 0 1-40 40H136a40 40 0 0 1-40-40V216a40 40 0 0 1 40-40h40",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32"},null,-1),i("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M176 272l80 80l80-80"},null,-1),i("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M256 48v288"},null,-1)]))}}),{handleError:te}=$(),ae=s("workflow-store",(()=>({isEditWorkFlow:l(!1),workflowFormData:l({name:"",templateType:"quick"}),workflowTemplateOptions:l([{label:"快速部署模板",value:"quick",description:"快速上线应用,简化流程"},{label:"高级自定义模板",value:"advanced",description:"完全自定义的部署流程"}]),fetchWorkflowList:async({p:e,limit:t,search:a})=>{try{const{data:l,count:o}=await q({p:e,limit:t,search:a}).fetch();return{list:l||[],total:o}}catch(l){return te(l),{list:[],total:0}}},fetchWorkflowHistory:async({id:e,p:t,limit:a})=>{try{const l=await A({id:e,p:t,limit:a}).fetch();return{list:l.data||[],total:l.count}}catch(l){return te(l),{list:[],total:0}}},deleteExistingWorkflow:async e=>{try{const{message:t,fetch:a}=B({id:e.toString()});t.value=!0,await a()}catch(t){te(t).defalut(d("t_14_1745457488092"))}},executeExistingWorkflow:async e=>{try{const{message:t,fetch:a}=N({id:e});t.value=!0,await a()}catch(t){te(t).defalut(d("t_13_1745457487555"))}},setWorkflowActive:async({id:e,active:t})=>{try{const{message:a,fetch:l}=V({id:e,active:t});a.value=!0,await l()}catch(a){te(a).defalut(d("t_12_1745457489076"))}},setWorkflowExecType:async({id:e,exec_type:t})=>{try{const{message:a,fetch:l}=F({id:e,exec_type:t});a.value=!0,await l()}catch(a){te(a).defalut(d("t_11_1745457488256"))}}}))),le=()=>{const e=ae();return{...e,...c(e)}};const oe=e({name:"AddWorkflowModal",setup(){const{workflowTemplateOptions:e,workflowFormData:t}=le(),{AddWorkflowForm:a}=Te();return()=>u(y,{bordered:!1,class:"shadow-none","content-class":"!p-[10px]"},{default:()=>[u(a,{labelPlacement:"top",labelWidth:100},{template:()=>{let a;return u(p,{label:d("t_0_1745474945127"),required:!0},{default:()=>{return[u(f,{vertical:!0,class:"flex !flex-row "},(l=a=e.value.map((e=>u("div",{key:e.value,class:"cursor-pointer transition-all duration-300 ",onClick:()=>{t.value.templateType=e.value}},[u(y,{class:"rounded-lg border-1 "+(t.value.templateType===e.value?"border-primary-500":""),hoverable:!0},{default:()=>[u(f,{align:"center",justify:"space-between"},{default:()=>[u("div",null,[u("div",{class:"font-medium text-[14px]"},[e.label]),u("div",{class:"text-gray-500 text-[12px] mt-1"},[e.description])]),u(m,{checked:t.value.templateType===e.value},null)]})]})]))),"function"==typeof l||"[object Object]"===Object.prototype.toString.call(l)&&!_(l)?a:{default:()=>[a]}))];var l}})}})]})}});const ne=e({name:"HistoryModal",props:{id:{type:String,required:!0}},setup(e){const{WorkflowHistoryTable:t,WorkflowHistoryTablePage:a,fetch:l}=Oe(e.id);return h((()=>{l()})),()=>u("div",{class:"flex w-full"},[u(K,null,{header:()=>{let e;return u("div",{class:"flex items-center justify-between"},[u(w,{type:"primary",onClick:()=>l()},(t=e=d("t_9_1746667589516"),"function"==typeof t||"[object Object]"===Object.prototype.toString.call(t)&&!_(t)?e:{default:()=>[e]}))]);var t},content:()=>u(t,null,null),footerRight:()=>u(a,null,null)})])}}),re="_logViewerCard_eyu1d_1",ie="_logActions_eyu1d_5",se="_logContainer_eyu1d_11",ce="_logContent_eyu1d_16",de=e({name:"LogViewer",props:{content:{type:String,default:""},loading:{type:Boolean,default:!1},enableDownload:{type:Boolean,default:!0},downloadFileName:{type:String,default:"logs.txt"},title:{type:String,default:"日志详情"},fetchLogs:{type:Function,default:()=>Promise.resolve("")}},setup(e){const t=l(e.content||""),a=l(e.loading),o=l(null);v((()=>e.content),(e=>{t.value=e,i()})),v((()=>e.loading),(e=>{a.value=e})),v((()=>e.fetchLogs),(e=>{})),h((()=>{n(),i()}));const n=async()=>{if(e.fetchLogs){a.value=!0;try{const a=await e.fetchLogs();t.value=a,i()}catch(l){}finally{a.value=!1}}},r=()=>{if(!t.value)return;const a=new Blob([t.value],{type:"text/plain"}),l=URL.createObjectURL(a),o=document.createElement("a");o.href=l,o.download=e.downloadFileName,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(l)},i=()=>{setTimeout((()=>{if(o.value){const e=o.value.querySelector(".n-scrollbar-container");e&&(e.scrollTop=e.scrollHeight)}}),100)},s=()=>{n()};return()=>u(y,{bordered:!1,class:re,contentClass:"!pb-0 !px-0"},{default:()=>[u(I,{show:a.value},{default:()=>[u("div",{class:ie},[u(f,null,{default:()=>[u(w,{onClick:s,size:"small"},{default:()=>[g("刷新")]}),e.enableDownload&&u(w,{onClick:r,size:"small"},{default:()=>[u(k,null,{default:()=>[u(ee,null,null)]}),u("span",null,[g("下载日志")])]})]})]),u("div",{class:se,ref:o},[u(Y,{style:"max-height: 500px;"},{default:()=>[u(G,{class:ce},{default:()=>[t.value?t.value:"暂无日志信息"]})]})])]})]})}}),ue=e({name:"HistoryLogsModal",props:{id:{type:[String],required:!0}},setup(e){const t=l(!1),a=l(""),o=async()=>{t.value=!0;try{const{data:t}=await M({id:e.id}).fetch();return a.value=t||"没有日志数据",a.value}catch(l){return"获取日志失败: "+(l instanceof Error?l.message:String(l))}finally{t.value=!1}};return h((()=>{o()})),()=>u(de,{title:`工作流执行日志 (ID: ${e.id})`,loading:t.value,content:a.value,fetchLogs:o},null)}});function pe(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!_(e)}const{fetchWorkflowList:fe,fetchWorkflowHistory:ye,workflowFormData:me,deleteExistingWorkflow:_e,executeExistingWorkflow:he,setWorkflowActive:we,setWorkflowExecType:ve}=le(),{isEdit:ge,workDefalutNodeData:ke,resetWorkflowData:xe,workflowData:be,detectionRefresh:Ce}=U(),{handleError:We}=$(),{useFormSlot:Se}=E(),je=(e,t)=>({title:t,key:e,width:100,render:t=>{const a={success:{type:"success",text:d("t_8_1745227838023")},fail:{type:"error",text:d("t_9_1745227838305")},running:{type:"warning",text:d("t_0_1746519384035")}}[t[e]]||{type:"default",text:d("t_11_1745227838422")};return u(T,{type:a.type,size:"small",bordered:!1},{default:()=>[a.text]})}}),Te=()=>{const{confirm:e}=P(),t=C((()=>[Se("template")])),{component:a,data:l}=z({config:t,rules:{},defaultValue:me});return e((async e=>{try{e(),xe(),L.push(`/auto-deploy/workflow-view?type=${l.value.templateType}`)}catch(t){We(t)}})),{AddWorkflowForm:a}},Oe=e=>{const{component:t,loading:a,param:l,data:o,total:n,fetch:r}=W({config:[{title:d("t_4_1745227838558"),key:"create_time",width:230,render:e=>e.create_time?e.create_time:"-"},{title:d("t_5_1745227839906"),key:"end_time",width:230,render:e=>e.end_time?e.end_time:"-"},{title:d("t_6_1745227838798"),key:"exec_type",width:110,render:e=>u(T,{type:"auto"===e.exec_type?"info":"default",size:"small",bordered:!1},{default:()=>["auto"===e.exec_type?d("t_2_1745215915397"):d("t_3_1745215914237")]})},je("status",d("t_7_1745227838093")),{title:d("t_8_1745215914610"),key:"actions",fixed:"right",align:"right",width:80,render:e=>{let t;return u(f,{justify:"end"},{default:()=>[u(w,{size:"tiny",strong:!0,secondary:!0,type:"primary",onClick:()=>(async e=>{O({title:d("t_0_1746579648713"),component:ue,area:730,componentProps:{id:e}})})(e.id.toString())},pe(t=d("t_12_1745227838814"))?t:{default:()=>[t]})]})}}],request:ye,defaultValue:{id:e,p:1,limit:10},watchValue:["p","limit"]}),{component:i}=S({param:l,total:n,alias:{page:"p",pageSize:"limit"}});return{WorkflowHistoryTable:t,WorkflowHistoryTablePage:i,loading:a,param:l,data:o,total:n,fetch:r}},Ee=e({name:"WorkflowManager",setup(){const{WorkflowTable:e,WorkflowTablePage:t,isDetectionAddWorkflow:a,handleAddWorkflow:l,hasChildRoutes:o,handleSearchClear:n,param:r,fetch:i,data:s}=(()=>{const e=x(),t=b(),a=C((()=>"/auto-deploy"!==e.path)),{component:l,loading:o,param:n,data:r,total:i,fetch:s}=W({config:[{title:d("t_0_1745215914686"),key:"name",width:200,ellipsis:{tooltip:!0}},{title:d("t_1_1746590060448"),key:"type",width:100,render:e=>u(f,null,{default:()=>[u(j,{size:"small",value:e.exec_type,"onUpdate:value":[t=>e.exec_type=t,()=>{_(e)}],checkedValue:"auto",uncheckedValue:"manual"},null),u("span",null,["auto"===e.exec_type?d("t_2_1745215915397"):d("t_3_1745215914237")])]})},{title:d("t_7_1745215914189"),key:"created_at",width:180,render:e=>e.create_time||"-"},je("last_run_status",d("t_0_1746677882486")),{title:d("t_8_1745215914610"),key:"actions",fixed:"right",align:"right",width:220,render:e=>{let t,a,l,o;return u(f,{justify:"end"},{default:()=>[u(w,{style:{"--n-text-color":"var(--text-color-3)"},size:"tiny",strong:!0,secondary:!0,onClick:()=>y(e)},pe(t=d("t_9_1745215914666"))?t:{default:()=>[t]}),u(w,{size:"tiny",strong:!0,secondary:!0,type:"info",onClick:()=>m(e)},pe(a=d("t_10_1745215914342"))?a:{default:()=>[a]}),u(w,{size:"tiny",strong:!0,secondary:!0,type:"primary",onClick:()=>h(e)},pe(l=d("t_11_1745215915429"))?l:{default:()=>[l]}),u(w,{size:"tiny",strong:!0,secondary:!0,type:"error",onClick:()=>v(e)},pe(o=d("t_12_1745215914312"))?o:{default:()=>[o]})]})}}],request:fe,defaultValue:{p:1,limit:10,search:""},watchValue:["p","limit"]}),{component:c}=S({param:n,total:i,alias:{page:"p",pageSize:"limit"}}),p=()=>{Ce.value=!0,O({title:d("t_5_1746667590676"),component:oe,footer:!0,area:500,onUpdateShow(e){e||s()}})},y=async e=>{O({title:e?`${e.name} - ${d("t_9_1745215914666")}`:d("t_9_1745215914666"),component:ne,area:800,componentProps:{id:e.id}})},m=async({name:e,id:t})=>{J({title:d("t_13_1745215915455"),content:d("t_2_1745227839794",{name:e}),onPositiveClick:async()=>{await he(t),await s()}})},_=({id:e,exec_type:t})=>{J({title:d("manual"===t?"t_2_1745457488661":"t_3_1745457486983"),content:d("manual"===t?"t_4_1745457497303":"t_5_1745457494695"),onPositiveClick:()=>ve({id:e,exec_type:t}),onNegativeClick:s,onClose:s})},h=e=>{const a=JSON.parse(e.content);ge.value=!0,be.value={id:e.id,name:e.name,content:a,exec_type:e.exec_type,active:e.active},ke.value={id:e.id,name:e.name,childNode:a},Ce.value=!0,t.push("/auto-deploy/workflow-view?isEdit=true")},v=e=>{J({title:d("t_16_1745215915209"),content:d("t_3_1745227841567",{name:e.name}),onPositiveClick:async()=>{await _e(e.id),await s()}})};return{WorkflowTable:l,WorkflowTablePage:c,isDetectionAddWorkflow:()=>{const{type:a}=e.query;(null==a?void 0:a.includes("create"))&&(p(),t.push({query:{}}))},handleViewHistory:y,handleAddWorkflow:p,handleSearchClear:()=>{n.value.search="",s()},handleChangeActive:({id:e,active:t})=>{J({title:d(t?"t_7_1745457487185":"t_6_1745457487560"),content:d(t?"t_9_1745457500045":"t_8_1745457496621"),onPositiveClick:()=>we({id:e,active:t}),onNegativeClick:s,onClose:s})},handleSetWorkflowExecType:_,handleExecuteWorkflow:m,handleEditWorkflow:h,handleDeleteWorkflow:v,hasChildRoutes:a,fetch:s,data:r,loading:o,param:n}})(),c=b(),p=D(["contentPadding","borderColor","headerHeight","iconColorHover"]);return v((()=>c.currentRoute.value.path),(e=>{"/auto-deploy"===e&&i()})),h((()=>{a(),i()})),()=>u("div",{class:"h-full flex flex-col",style:p.value},[u("div",{class:"mx-auto max-w-[1600px] w-full p-6"},[o.value?u(H,null,null):u(K,null,{headerLeft:()=>u(w,{type:"primary",size:"large",class:"px-5",onClick:l},{default:()=>[u(X,{class:"text-[var(--text-color-3)] w-[1.6rem]"},null),u("span",{class:"px-2"},[d("t_0_1745227838699")])]}),headerRight:()=>u(R,{value:r.value.search,"onUpdate:value":e=>r.value.search=e,onKeydown:e=>{"Enter"===e.key&&i()},onClear:n,placeholder:d("t_1_1745227838776"),clearable:!0,size:"large",class:"min-w-[300px]"},{suffix:()=>u("div",{class:"flex items-center",onClick:i},[u(Q,{class:"text-[var(--text-color-3)] w-[1.6rem] cursor-pointer font-bold"},null)])}),content:()=>u("div",{class:"rounded-lg bg-white"},[u(e,{size:"medium",style:{"--n-th-text-color":"#6b7280","--n-td-text-color":"#6b7280"}},null)]),footerRight:()=>u("div",{class:"mt-4 flex justify-end"},[u(t,null,{prefix:()=>u("span",null,[g("共 "),s.value.total,g(" 条")])})])})])])}});export{Ee as default};