(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-c167c9c4"],{"19c7":function(e,t,a){},"5e1a9":function(e,t,a){"use strict";a("19c7")},"6d5e":function(e,t,a){"use strict";a.r(t);var j=a("7a23"),O={class:"new-route"},m={class:"list"},v={class:"list__col"},y={class:"list__label"},k={class:"actions"},$={key:1},w={class:"add-tags__input"},M={class:"add-tags__label"},R={class:"add-tags__input"},V={class:"add-tags__label"},C={class:"tags-container"};function o(a,e,t,o,c,n){var s=Object(j["resolveComponent"])("a-input"),i=Object(j["resolveComponent"])("a-button"),l=Object(j["resolveComponent"])("tooltip-button"),r=Object(j["resolveComponent"])("a-spin"),d=Object(j["resolveComponent"])("a-form-item"),u=Object(j["resolveComponent"])("a-form"),g=Object(j["resolveComponent"])("a-divider"),b=Object(j["resolveComponent"])("a-tag"),f=Object(j["resolveComponent"])("a-modal"),h=Object(j["resolveDirective"])("focus"),p=Object(j["resolveDirective"])("ctrl-enter");return Object(j["openBlock"])(),Object(j["createBlock"])(r,{spinning:c.componentLoading},{default:Object(j["withCtx"])(function(){return[Object(j["withDirectives"])((Object(j["openBlock"])(),Object(j["createElementBlock"])("div",O,[Object(j["withDirectives"])(Object(j["createVNode"])(s,{value:c.newRoute,"onUpdate:value":e[0]||(e[0]=function(e){return c.newRoute=e}),placeholder:a.$t("label.cidr.destination.network")},null,8,["value","placeholder"]),[[h,!0]]),Object(j["createVNode"])(i,{type:"primary",disabled:!("createStaticRoute"in a.$store.getters.apis),onClick:n.handleAdd},{default:Object(j["withCtx"])(function(){return[Object(j["createTextVNode"])(Object(j["toDisplayString"])(a.$t("label.add.route")),1)]}),_:1},8,["disabled","onClick"])])),[[p,n.handleAdd]]),Object(j["createElementVNode"])("div",m,[(Object(j["openBlock"])(!0),Object(j["createElementBlock"])(j["Fragment"],null,Object(j["renderList"])(c.routes,function(e,t){return Object(j["openBlock"])(),Object(j["createElementBlock"])("div",{key:t,class:"list__item"},[Object(j["createElementVNode"])("div",v,[Object(j["createElementVNode"])("div",y,Object(j["toDisplayString"])(a.$t("label.cidr.destination.network")),1),Object(j["createElementVNode"])("div",null,Object(j["toDisplayString"])(e.cidr),1)]),Object(j["createElementVNode"])("div",k,[Object(j["createVNode"])(l,{tooltip:a.$t("label.edit.tags"),icon:"tag-outlined",onOnClick:function(){return n.openTagsModal(e)}},null,8,["tooltip","onOnClick"]),Object(j["createVNode"])(l,{tooltip:a.$t("label.delete"),disabled:!("deleteStaticRoute"in a.$store.getters.apis),icon:"delete-outlined",type:"primary",danger:!0,onOnClick:function(){return n.handleDelete(e)}},null,8,["tooltip","disabled","onOnClick"])])])}),128))]),Object(j["createVNode"])(f,{title:a.$t("label.edit.tags"),visible:c.tagsModalVisible,footer:null,closable:!0,maskClosable:!1,onCancel:e[4]||(e[4]=function(e){return c.tagsModalVisible=!1})},{default:Object(j["withCtx"])(function(){return[c.tagsLoading?(Object(j["openBlock"])(),Object(j["createBlock"])(r,{key:0})):Object(j["withDirectives"])((Object(j["openBlock"])(),Object(j["createElementBlock"])("div",$,[Object(j["createVNode"])(u,{ref:a.formRef,model:a.form,rules:a.rules,class:"add-tags"},{default:Object(j["withCtx"])(function(){return[Object(j["createElementVNode"])("div",w,[Object(j["createElementVNode"])("p",M,Object(j["toDisplayString"])(a.$t("label.key")),1),Object(j["createVNode"])(d,{name:"key",ref:"key"},{default:Object(j["withCtx"])(function(){return[Object(j["withDirectives"])(Object(j["createVNode"])(s,{value:a.form.key,"onUpdate:value":e[1]||(e[1]=function(e){return a.form.key=e})},null,8,["value"]),[[h,!0]])]}),_:1},512)]),Object(j["createElementVNode"])("div",R,[Object(j["createElementVNode"])("p",V,Object(j["toDisplayString"])(a.$t("label.value")),1),Object(j["createVNode"])(d,{name:"value",ref:"value"},{default:Object(j["withCtx"])(function(){return[Object(j["createVNode"])(s,{value:a.form.value,"onUpdate:value":e[2]||(e[2]=function(e){return a.form.value=e})},null,8,["value"])]}),_:1},512)]),Object(j["createVNode"])(i,{type:"primary",disabled:!("createTags"in a.$store.getters.apis),onClick:n.handleAddTag},{default:Object(j["withCtx"])(function(){return[Object(j["createTextVNode"])(Object(j["toDisplayString"])(a.$t("label.add")),1)]}),_:1},8,["disabled","onClick"])]}),_:1},8,["model","rules"]),Object(j["createVNode"])(g,{style:{"margin-top":"0"}}),Object(j["createElementVNode"])("div",C,[(Object(j["openBlock"])(!0),Object(j["createElementBlock"])(j["Fragment"],null,Object(j["renderList"])(c.tags,function(e,t){return Object(j["openBlock"])(),Object(j["createElementBlock"])("div",{class:"tags",key:t},[(Object(j["openBlock"])(),Object(j["createBlock"])(b,{key:t,closable:"deleteTags"in a.$store.getters.apis,onClose:function(){return n.handleDeleteTag(e)}},{default:Object(j["withCtx"])(function(){return[Object(j["createTextVNode"])(Object(j["toDisplayString"])(e.key)+" = "+Object(j["toDisplayString"])(e.value),1)]}),_:2},1032,["closable","onClose"]))])}),128))]),Object(j["createVNode"])(i,{class:"add-tags-done",onClick:e[3]||(e[3]=function(e){return c.tagsModalVisible=!1}),type:"primary"},{default:Object(j["withCtx"])(function(){return[Object(j["createTextVNode"])(Object(j["toDisplayString"])(a.$t("label.ok")),1)]}),_:1})])),[[p,n.handleAddTag]])]}),_:1},8,["title","visible"])]}),_:1},8,["spinning"])}a("d3b7"),a("b0c0");var c=a("365c"),n=a("9fb3"),s={name:"StaticRoutesTab",components:{TooltipButton:n["a"]},props:{resource:{type:Object,required:!0},loading:{type:Boolean,default:!1}},data:function(){return{routes:[],componentLoading:!1,selectedRule:null,tagsModalVisible:!1,tags:[],tagsLoading:!1,newRoute:null}},created:function(){this.initForm(),this.fetchData()},watch:{loading:function(e,t){!e&&this.resource.id&&this.fetchData()}},methods:{initForm:function(){this.formRef=Object(j["ref"])(),this.form=Object(j["reactive"])({start:!0}),this.rules=Object(j["reactive"])({key:[{required:!0,message:this.$t("message.specify.tag.key")}],value:[{required:!0,message:this.$t("message.specify.tag.value")}]})},fetchData:function(){var t=this;this.componentLoading=!0,Object(c["a"])("listStaticRoutes",{gatewayid:this.resource.id,listall:!0}).then(function(e){t.routes=e.liststaticroutesresponse.staticroute}).catch(function(e){t.$notifyError(e)}).finally(function(){t.componentLoading=!1})},handleAdd:function(){var t=this;this.componentLoading||this.newRoute&&(this.componentLoading=!0,Object(c["a"])("createStaticRoute",{cidr:this.newRoute,gatewayid:this.resource.id}).then(function(e){t.$pollJob({jobId:e.createstaticrouteresponse.jobid,title:t.$t("message.success.add.static.route"),description:t.newRoute,successMethod:function(){t.fetchData(),t.componentLoading=!1,t.newRoute=null},errorMessage:t.$t("message.add.static.route.failed"),errorMethod:function(){t.fetchData(),t.componentLoading=!1},loadingMessage:t.$t("message.add.static.route.processing"),catchMessage:t.$t("error.fetching.async.job.result"),catchMethod:function(){t.fetchData(),t.componentLoading=!1}})}).catch(function(e){t.$notifyError(e),t.fetchData(),t.componentLoading=!1}))},handleDelete:function(t){var a=this;this.componentLoading=!0,Object(c["a"])("deleteStaticRoute",{id:t.id}).then(function(e){a.$pollJob({jobId:e.deletestaticrouteresponse.jobid,title:a.$t("message.success.delete.static.route"),description:t.id,successMethod:function(){a.fetchData(),a.componentLoading=!1},errorMessage:a.$t("message.delete.static.route.failed"),errorMethod:function(){a.fetchData(),a.componentLoading=!1},loadingMessage:a.$t("message.delete.static.route.processing"),catchMessage:a.$t("error.fetching.async.job.result"),catchMethod:function(){a.fetchData(),a.componentLoading=!1}})}).catch(function(e){a.$notifyError(e),a.fetchData(),a.componentLoading=!1})},fetchTags:function(e){var t=this;Object(c["a"])("listTags",{resourceId:e.id,resourceType:"StaticRoute",listAll:!0}).then(function(e){t.tags=e.listtagsresponse.tag}).catch(function(e){t.$notifyError(e)})},handleDeleteTag:function(e){var t=this;this.tagsLoading=!0,Object(c["a"])("deleteTags",{"tags[0].key":e.key,"tags[0].value":e.value,resourceIds:this.selectedRule.id,resourceType:"StaticRoute"}).then(function(e){t.$pollJob({jobId:e.deletetagsresponse.jobid,successMessage:t.$t("message.success.delete.tag"),successMethod:function(){t.fetchTags(t.selectedRule),t.tagsLoading=!1},errorMessage:t.$t("message.delete.tag.failed"),errorMethod:function(){t.fetchTags(t.selectedRule),t.tagsLoading=!1},loadingMessage:t.$t("message.delete.tag.processing"),catchMessage:t.$t("error.fetching.async.job.result"),catchMethod:function(){t.fetchTags(t.selectedRule),t.tagsLoading=!1}})}).catch(function(e){t.$notifyError(e),t.tagsLoading=!1})},handleAddTag:function(e){var t=this;this.tagsLoading||(this.tagsLoading=!0,this.formRef.value.validate().then(function(){var e=Object(j["toRaw"])(t.form);Object(c["a"])("createTags",{"tags[0].key":e.key,"tags[0].value":e.value,resourceIds:t.selectedRule.id,resourceType:"StaticRoute"}).then(function(e){t.$pollJob({jobId:e.createtagsresponse.jobid,successMessage:t.$t("message.success.add.tag"),successMethod:function(){t.fetchTags(t.selectedRule),t.tagsLoading=!1},errorMessage:t.$t("message.add.tag.failed"),errorMethod:function(){t.fetchTags(t.selectedRule),t.tagsLoading=!1},loadingMessage:t.$t("message.add.tag.processing"),catchMessage:t.$t("error.fetching.async.job.result"),catchMethod:function(){t.fetchTags(t.selectedRule),t.tagsLoading=!1}})}).catch(function(e){t.$notifyError(e),t.tagsLoading=!1}).finally(function(){t.tagsLoading=!1})}).catch(function(e){t.formRef.value.scrollToField(e.errorFields[0].name)}))},openTagsModal:function(e){this.selectedRule=e,this.rulesRef.value.resetFields(),this.fetchTags(this.selectedRule),this.tagsModalVisible=!0}}},i=(a("5e1a9"),a("d959")),l=a.n(i);const r=l()(s,[["render",o],["__scopeId","data-v-2c15dd27"]]);t["default"]=r}}]);
//# sourceMappingURL=chunk-c167c9c4.388e982b.js.map