← Back
Editing: add-compose-template-legacy.js
!function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */e=function(){return n};var r,n={},o=Object.prototype,a=o.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",s=c.asyncIterator||"@@asyncIterator",l=c.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(r){f=function(t,e,r){return t[e]=r}}function p(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,a=Object.create(o.prototype),c=new T(n||[]);return i(a,"_invoke",{value:S(t,r,c)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}n.wrap=p;var v="suspendedStart",m="suspendedYield",d="executing",y="completed",g={};function w(){}function b(){}function x(){}var L={};f(L,u,(function(){return this}));var k=Object.getPrototypeOf,E=k&&k(k(F([])));E&&E!==o&&a.call(E,u)&&(L=E);var _=x.prototype=w.prototype=Object.create(L);function j(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function O(e,r){function n(o,i,c,u){var s=h(e[o],e,i);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==t(f)&&a.call(f,"__await")?r.resolve(f.__await).then((function(t){n("next",t,c,u)}),(function(t){n("throw",t,c,u)})):r.resolve(f).then((function(t){l.value=t,c(l)}),(function(t){return n("throw",t,c,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,e){function a(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(a,a):a()}})}function S(t,e,n){var o=v;return function(a,i){if(o===d)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:r,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=N(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===v)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=h(t,e,n);if("normal"===s.type){if(o=n.done?y:m,s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function N(t,e){var n=e.method,o=t.iterator[n];if(o===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=r,N(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=h(o,t.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,g;var i=a.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,g):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function G(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function F(e){if(e||""===e){var n=e[u];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function t(){for(;++o<e.length;)if(a.call(e,o))return t.value=e[o],t.done=!1,t;return t.value=r,t.done=!0,t};return i.next=i}}throw new TypeError(t(e)+" is not iterable")}return b.prototype=x,i(_,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:b,configurable:!0}),b.displayName=f(x,l,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,f(t,l,"GeneratorFunction")),t.prototype=Object.create(_),t},n.awrap=function(t){return{__await:t}},j(O.prototype),f(O.prototype,s,(function(){return this})),n.AsyncIterator=O,n.async=function(t,e,r,o,a){void 0===a&&(a=Promise);var i=new O(p(t,e,r,o),a);return n.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},j(_),f(_,l,"Generator"),f(_,u,(function(){return this})),f(_,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},n.values=F,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(G),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,o){return c.type="throw",c.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),s=a.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),G(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;G(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:F(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),g}},n}function r(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function n(t){return function(){var e=this,n=arguments;return new Promise((function(o,a){var i=t.apply(e,n);function c(t){r(i,o,a,c,u,"next",t)}function u(t){r(i,o,a,c,u,"throw",t)}c(void 0)}))}}System.register(["./utils-lib-legacy.js?v=VERSION_NUMBER","./base-lib-legacy.js?v=VERSION_NUMBER","./form-item-legacy.js?v=VERSION_NUMBER","./validator-legacy.js?v=VERSION_NUMBER","./index-legacy140.js?v=VERSION_NUMBER","./__commonjsHelpers__-legacy.js?v=VERSION_NUMBER","./index-legacy104.js?v=VERSION_NUMBER","./column-legacy.js?v=VERSION_NUMBER","./ace-legacy.js?v=VERSION_NUMBER"],(function(r,o){"use strict";var a,i,c,u,s,l,f,p,h,v,m,d,y,g,w,b,x,L,k,E,_,j,O,S,N,P,G;return{setters:[function(t){a=t.ay,i=t.G,c=t.K,u=t.gP,s=t.gQ,l=t.b,f=t.gR,p=t.gx,h=t.e},function(t){v=t.c,m=t.r,d=t.g,y=t.aB,g=t.e,w=t.p,b=t.G,x=t.H,L=t.x,k=t.q,E=t.v},function(t){_=t.b,j=t.d,O=t.l,S=t.g,N=t.h},function(t){P=t.f},function(t){G=t.B},null,null,null,null],execute:function(){var o={class:"flex flex-col lib-box p-2rem"},T=v({__name:"add-compose-template",props:{compData:{default:function(){return{}}}},emits:["close","complate"],setup:function(r,h){var v,T,F=h.expose,D=h.emit,W=l(),q=a().refs.isRefreshTemplateList,C=r,I=D,V=m(!1),A=function(){var t=n(e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(r={name:"",remark:"",data:"",env:""}).name=C.compData.row.name,r.remark=C.compData.row.remark,t.next=5,c({request:f({data:JSON.stringify({template_id:C.compData.row.id})}),loading:V});case 5:return(n=t.sent).status?(r.data=n.data.compose_data,r.env=n.data.env_data):W.error(n.msg),t.abrupt("return",r);case 8:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),B={mode:"ace/mode/nginx",theme:"ace/theme/chrome",wrap:!0,showInvisibles:!1,showFoldWidgets:!1,useSoftTabs:!0,tabSize:2,showPrintMargin:!1,readOnly:!1,fontSize:"12px"},J=i({data:(T=n(e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null===(r=C.compData.row)||void 0===r||!r.id){t.next=2;break}return t.abrupt("return",A());case 2:return t.abrupt("return",{name:"",remark:"",data:"",env:"",path:"",envpath:""});case 3:case"end":return t.stop()}}),t)}))),function(){return T.apply(this,arguments)}),options:function(t){return d((function(){return[_("创建模板","name",{attrs:{class:"!w-[35rem]",placeholder:"请输入模板名"},rules:[{required:!0,message:"请输入模板名",trigger:"blur"}]}),_("备注","remark",{attrs:{class:"!w-[35rem]",placeholder:"备注"}}),j([O(" ","path",{attrs:{class:"!w-[30rem]",placeholder:"请选择compose文件"}},(function(){return H(t,"compose")})),S("本地上传",{attrs:{class:"!ml-[1rem]",onClick:function(){Y(t,"compose")}}})]),N("compose内容",(function(){return y(G,{id:"templateEditor",class:"max-h-[30rem] h-[30rem] !w-[43rem]",modelValue:t.value.data,"onUpdate:modelValue":function(e){return t.value.data=e},editorOption:B})}),"data",{rules:[{required:!0,message:"请输入内容",trigger:"blur"}]}),j([O(" ","envpath",{attrs:{class:"!w-[30rem]",placeholder:"请选择.env文件"}},(function(){return H(t,"env")})),S("本地上传",{attrs:{class:"!ml-[1rem]",onClick:function(){Y(t,"env")}}})]),N(".env内容",(function(){return g(G,{key:"editer2",class:"w-full h-[10rem]",modelValue:t.value.env,"onUpdate:modelValue":function(e){return t.value.env=e},editorOption:B},null)}),"data")]}))},submit:(v=n(e().mark((function t(r,n,o){var a;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n();case 2:c({request:null!==(a=C.compData.row)&&void 0!==a&&a.id?u({data:JSON.stringify({id:C.compData.row.id,name:r.value.name,remark:r.value.remark,data:r.value.data,env:r.value.env})}):s({data:JSON.stringify({name:r.value.name,remark:r.value.remark,data:r.value.data,env:r.value.env})}),loading:"提交中...",message:!0,success:function(t){t.status&&(I("complate",t),q.value=!0,I("close"))}});case 3:case"end":return t.stop()}}),t)}))),function(t,e,r){return v.apply(this,arguments)})}),R=J.BtForm,z=J.submit,H=function(t,e){P({type:"file",change:function(r){r&&("compose"==e&&(t.value.path=r),"env"==e&&(t.value.envpath=r),r.endsWith(".yml")||r.endsWith(".yaml")||"compose"!=e?r.endsWith(".env")||"env"!=e?U(r,t,e):W.error("请选择.env文件"):W.error("请选择compose文件"))}})},U=function(){var r=n(e().mark((function r(n,o,a){var i,c;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,p({path:n});case 3:i=e.sent,"object"===t(c=i.data)&&("compose"==a&&(o.value.data=c.data||""),"env"==a&&(o.value.env=c.data||"")),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0);case 11:case"end":return e.stop()}}),r,null,[[0,8]])})));return function(t,e,n){return r.apply(this,arguments)}}(),Y=function(t,e){var r=document.createElement("input");r.type="file",r.style.display="none","compose"===e&&(r.accept=".yml,.yaml"),r.addEventListener("change",(function(r){var n,o=null===(n=r.target.files)||void 0===n?void 0:n[0];if(o)if("compose"!==e||o.name.endsWith(".yml")||o.name.endsWith(".yaml"))if("env"!==e||o.name.endsWith("env")){var a=new FileReader;a.onload=function(r){var n,a=null===(n=r.target)||void 0===n?void 0:n.result;"compose"===e?(t.value.path=o.name,t.value.data=a):"env"===e&&(t.value.envpath=o.name,t.value.env=a)},a.onerror=function(){W.error("读取文件内容失败")},a.readAsText(o)}else W.error("请选择env文件");else W.error("请选择compose文件")})),document.body.appendChild(r),r.click(),setTimeout((function(){document.body.removeChild(r)}),0)};return w(n(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)})))),F({onConfirm:z}),function(t,e){var r=b("bt-loading");return x((k(),E("div",o,[g(L(R))])),[[r,L(V)],[r,"正在获取模板消息,请稍候...","title"]])}}});r("default",h(T,[["__scopeId","data-v-e3d9726b"]]))}}}))}();
Save File
Cancel