blob: c2fee97beb2d177aa79eca72a91ff66ca5bac541 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-35f1b43d"],{2366:function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);function a(e,t){var r=t||0,a=n;return[a[e[r++]],a[e[r++]],a[e[r++]],a[e[r++]],"-",a[e[r++]],a[e[r++]],"-",a[e[r++]],a[e[r++]],"-",a[e[r++]],a[e[r++]],"-",a[e[r++]],a[e[r++]],a[e[r++]],a[e[r++]],a[e[r++]],a[e[r++]]].join("")}e.exports=a},"3fd7":function(e,t,n){"use strict";n.r(t);var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"consumers-wrapper"},[n("el-form",{ref:"form",attrs:{model:e.form,rules:e.rules,"label-width":"80px","show-message":!1}},[n("el-form-item",{attrs:{label:"Desc"}},[n("el-input",{attrs:{placeholder:"Description"},model:{value:e.form.desc,callback:function(t){e.$set(e.form,"desc",t)},expression:"form.desc"}})],1),n("el-form-item",{attrs:{label:"name",prop:"username"}},[n("el-input",{model:{value:e.form.username,callback:function(t){e.$set(e.form,"username",t)},expression:"form.username"}})],1),e._l(e.form.plugins,(function(t,r){return n("el-form-item",{key:r,staticClass:"plugin-item",attrs:{label:"plugin"}},["tempPlugin"!==r?n("el-button",{attrs:{type:"info",plain:""},on:{click:function(t){return e.showPlugin(r)}}},[e._v("\n "+e._s(r)+"\n ")]):e._e(),"tempPlugin"!==r?n("el-button",{attrs:{type:"danger"},on:{click:function(t){return t.preventDefault(),e.removePlugin(r)}}},[e._v("\n "+e._s(e.$t("button.delete"))+"\n ")]):e._e(),"tempPlugin"===r?n("el-select",{staticClass:"plugin-select",attrs:{value:null,placeholder:"Select a Plugin"},on:{change:e.showPlugin}},e._l(e.filteredPluginList,(function(e){return n("el-option",{key:e,attrs:{label:e,value:e}})})),1):e._e()],1)})),n("el-form-item",[n("el-button",{attrs:{disabled:!e.filteredPluginList.length},on:{click:e.addPlugin}},[e._v("\n "+e._s(e.$t("button.add_plugin"))+"\n ")])],1),n("el-form-item",[n("el-button",{attrs:{type:"primary"},on:{click:e.onSubmit}},[e._v("\n "+e._s(e.$t("button.save"))+"\n ")]),n("el-button",{on:{click:e.toPreviousPage}},[e._v("\n "+e._s(e.$t("button.cancel"))+"\n ")])],1)],2),n("PluginDialog",{attrs:{show:e.showPluginDialog,name:e.pluginName,"plugin-data":e.form.plugins[e.pluginName]},on:{hidePlugin:function(t){e.showPluginDialog=!1},save:e.onPluginSave}})],1)},a=[],i=(n("8e6e"),n("456d"),n("7618")),u=n("768b"),o=(n("ffc1"),n("ac6a"),n("bd86")),s=(n("96cf"),n("3b8d")),c=(n("7f7f"),n("d225")),l=n("b0b4"),p=n("308d"),f=n("6bb5"),m=n("4e2b"),d=n("9ab4"),h=n("60a3"),g=n("c738"),b=n("7d98"),v=n("c8f9"),y=n("e741");function O(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?O(n,!0).forEach((function(t){Object(o["a"])(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var j=function(e){function t(){var e;return Object(c["a"])(this,t),e=Object(p["a"])(this,Object(f["a"])(t).apply(this,arguments)),e.isEditMode=!1,e.form={username:"",plugins:{},desc:""},e.rules={username:{required:!0}},e.pluginList=[],e.pluginName="",e.showPluginDialog=!1,e}return Object(m["a"])(t,e),Object(l["a"])(t,[{key:"created",value:function(){this.isEditMode=-1===this.$route.name.indexOf("Create"),this.isEditMode&&this.getConsumerData(),this.getPluginList()}},{key:"getConsumerData",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return t=this.$route.params.username,e.next=3,Object(g["a"])(t);case 3:n=e.sent,this.form={desc:n.node.value.desc,username:t,plugins:n.node.value.plugins};case 5:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},{key:"getPluginList",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,Object(b["a"])();case 2:this.pluginList=e.sent;case 3:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},{key:"addPlugin",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(!this.form.plugins.hasOwnProperty("tempPlugin")){e.next=2;break}return e.abrupt("return");case 2:this.form.plugins=w({},this.form.plugins,{tempPlugin:null});case 3:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},{key:"onSubmit",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:this.$refs["form"].validate(function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(n){var r;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(!n){e.next=13;break}return delete t.form.plugins["tempPlugin"],r=Object.assign({},t.form),Object.entries(r).forEach((function(e){var t=Object(u["a"])(e,2),n=t[0],a=t[1];"object"===Object(i["a"])(r[n])?"plugins"!==n&&0===Object.keys(a).length&&delete r[n]:""===a&&delete r[n]})),e.next=6,Object(g["d"])(Object.assign({},r));case 6:if(t.$message.success("".concat(t.isEditMode?"Update the":"Create a"," consumer successfully!")),!t.isEditMode){e.next=9;break}return e.abrupt("return");case 9:y["a"].delView(t.$route),t.$nextTick((function(){t.$router.push({name:"SchemaConsumersList"})})),e.next=14;break;case 13:return e.abrupt("return",!1);case 14:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());case 1:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},{key:"showPlugin",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:this.pluginName=t,this.showPluginDialog=!0;case 2:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"onPluginSave",value:function(e,t){delete this.form.plugins["tempPlugin"],this.showPluginDialog=!1,this.form.plugins[e]=t}},{key:"toPreviousPage",value:function(){this.$router.go(-1)}},{key:"removePlugin",value:function(e){var t=this;this.$confirm("Do you want to remove ".concat(e," plugin?"),"Warning",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"warning"}).then(Object(s["a"])(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:h["c"].delete(t.form.plugins,e);case 1:case"end":return n.stop()}}),n)})))).catch((function(){}))}},{key:"filteredPluginList",get:function(){var e=this;return this.pluginList.filter((function(t){return!e.form.plugins.hasOwnProperty(t)}))}}]),t}(h["c"]);j=d["a"]([Object(h["a"])({name:"ConsumerEdit",components:{PluginDialog:v["a"]}})],j);var P=j,k=P,x=(n("eec9"),n("2877")),C=Object(x["a"])(k,r,a,!1,null,null,null);t["default"]=C.exports},"504c":function(e,t,n){var r=n("9e1e"),a=n("0d58"),i=n("6821"),u=n("52a7").f;e.exports=function(e){return function(t){var n,o=i(t),s=a(o),c=s.length,l=0,p=[];while(c>l)n=s[l++],r&&!u.call(o,n)||p.push(e?[n,o[n]]:o[n]);return p}}},"63aa":function(e,t,n){e.exports={menuBg:"#304156",menuText:"#bfcbd9",menuActiveText:"#409eff"}},"7d98":function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n("b32d"),a=function(){return Object(r["a"])({url:"/plugins/list",method:"get"})}},"9c3c":function(e,t,n){e.exports={menuBg:"#304156",menuText:"#bfcbd9",menuActiveText:"#409eff"}},b32d:function(e,t,n){"use strict";var r=n("bc3a"),a=n.n(r),i=n("5c96"),u=a.a.create({baseURL:"/apisix/admin/",timeout:5e3});u.interceptors.request.use((function(e){return e}),(function(e){Promise.reject(e)})),u.interceptors.response.use((function(e){return e.data}),(function(e){return Object(i["Message"])({message:e.response.data.error_msg||e.message,type:"error",duration:5e3}),Promise.reject(e)})),t["a"]=u},c437:function(e,t,n){var r,a,i=n("e1f4"),u=n("2366"),o=0,s=0;function c(e,t,n){var c=t&&n||0,l=t||[];e=e||{};var p=e.node||r,f=void 0!==e.clockseq?e.clockseq:a;if(null==p||null==f){var m=i();null==p&&(p=r=[1|m[0],m[1],m[2],m[3],m[4],m[5]]),null==f&&(f=a=16383&(m[6]<<8|m[7]))}var d=void 0!==e.msecs?e.msecs:(new Date).getTime(),h=void 0!==e.nsecs?e.nsecs:s+1,g=d-o+(h-s)/1e4;if(g<0&&void 0===e.clockseq&&(f=f+1&16383),(g<0||d>o)&&void 0===e.nsecs&&(h=0),h>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");o=d,s=h,a=f,d+=122192928e5;var b=(1e4*(268435455&d)+h)%4294967296;l[c++]=b>>>24&255,l[c++]=b>>>16&255,l[c++]=b>>>8&255,l[c++]=255&b;var v=d/4294967296*1e4&268435455;l[c++]=v>>>8&255,l[c++]=255&v,l[c++]=v>>>24&15|16,l[c++]=v>>>16&255,l[c++]=f>>>8|128,l[c++]=255&f;for(var y=0;y<6;++y)l[c+y]=p[y];return t||u(l)}e.exports=c},c738:function(e,t,n){"use strict";n.d(t,"d",(function(){return a})),n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return u})),n.d(t,"c",(function(){return o}));var r=n("b32d"),a=function(e){return Object(r["a"])({url:"/consumers",method:"PUT",data:e})},i=function(){return Object(r["a"])({url:"/consumers",method:"GET"})},u=function(e){return Object(r["a"])({url:"/consumers/".concat(e),method:"GET"})},o=function(e){return Object(r["a"])({url:"/consumers/".concat(e),method:"DELETE"})}},c8f9:function(e,t,n){"use strict";var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"plugin-dialog"},[n("el-dialog",{attrs:{title:"Plugin "+e.name+" Edit",visible:e.show},on:{"update:visible":function(t){e.show=t}}},[n("el-form",{ref:"form",attrs:{model:e.data,rules:e.rules,"show-message":!1}},e._l(e.schema.properties,(function(t,r){return n("el-form-item",{key:r,attrs:{label:r,"label-width":"160px",prop:r}},["integer"===e.schema.properties[r].type||"number"===e.schema.properties[r].type?n("el-input-number",{attrs:{min:e.schema.properties[r].minimum||-99999999999,max:e.schema.properties[r].maximum||99999999999,label:"描述文字"},on:{change:function(t){return e.onPropertyChange(r,t)}},model:{value:e.data[r],callback:function(t){e.$set(e.data,r,t)},expression:"data[key]"}}):e._e(),e.schema.properties[r].hasOwnProperty("enum")?n("el-select",{attrs:{clearable:!0,placeholder:"Select a "+r},on:{change:function(t){return e.onPropertyChange(r,t)}},model:{value:e.data[r],callback:function(t){e.$set(e.data,r,t)},expression:"data[key]"}},e._l(e.schema.properties[r]["enum"],(function(e){return n("el-option",{key:e,attrs:{label:e,value:e}})})),1):e._e(),"string"!==e.schema.properties[r].type||e.schema.properties[r].hasOwnProperty("enum")?e._e():n("el-input",{attrs:{placeholder:r},on:{input:function(t){return e.onPropertyChange(r,t)}},model:{value:e.data[r],callback:function(t){e.$set(e.data,r,t)},expression:"data[key]"}})],1)})),1),n("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[n("el-button",{on:{click:e.onCancel}},[e._v("\n Cancel\n ")]),n("el-button",{attrs:{type:"primary",disabled:!e.isDataChanged},on:{click:e.onSave}},[e._v("\n Confirm\n ")])],1)],1)],1)},a=[],i=(n("8e6e"),n("ac6a"),n("456d"),n("6762"),n("2fdb"),n("bd86")),u=(n("96cf"),n("3b8d")),o=(n("7f7f"),n("d225")),s=n("b0b4"),c=n("308d"),l=n("6bb5"),p=n("4e2b"),f=n("9ab4"),m=n("60a3"),d=n("b32d"),h=function(e){return Object(d["a"])({url:"/schema/plugins/".concat(e),method:"get"})};function g(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?g(n,!0).forEach((function(t){Object(i["a"])(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var v=n("c437"),y=function(e){function t(){var e;return Object(o["a"])(this,t),e=Object(c["a"])(this,Object(l["a"])(t).apply(this,arguments)),e.schema={properties:{}},e.rules={},e.data={},e.isDataChanged=!1,e}return Object(p["a"])(t,e),Object(s["a"])(t,[{key:"onShowChange",value:function(e){this.resetPlugin(),e&&this.getschema(this.name)}},{key:"resetPlugin",value:function(){this.schema={properties:{}},this.rules={},this.data={},this.isDataChanged=!1}},{key:"getschema",value:function(){var e=Object(u["a"])(regeneratorRuntime.mark((function e(t){var n,r,a,i;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,h(t);case 2:if(n=e.sent,n.properties){e.next=6;break}return this.isDataChanged=!0,e.abrupt("return");case 6:for(a in this.schema=Object.assign({},b({},n,{name:this.name})),r=Object.assign({},n.properties),r)i=Object.assign({},r[a]),r[a]={trigger:"blur"},n.required&&(r[a].required=n.required.includes(a)),i.hasOwnProperty("type")&&(r[a]["type"]=i["type"]),i.hasOwnProperty("minimum")&&(r[a]["min"]=i["minimum"]),i.hasOwnProperty("maximum")&&(r[a]["max"]=i["maximum"]),i.hasOwnProperty("enum")&&(r[a]["type"]="enum",r[a]["enum"]=i["enum"]);this.rules=r,this.pluginData&&(this.data=Object.assign({},this.pluginData)),"key-auth"!==this.name||this.pluginData||(this.data={key:v()},this.isDataChanged=!0);case 12:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"onCancel",value:function(){this.$emit("hidePlugin")}},{key:"onSave",value:function(){var e=this;this.$refs.form.validate((function(t){if(!t)return!1;e.$emit("save",e.name,e.data),e.$message.warning("Your data will be saved after you click the Save button")}))}},{key:"onPropertyChange",value:function(e,t){this.data[e]=t,this.isDataChanged=!0}}]),t}(m["c"]);f["a"]([Object(m["b"])({default:!1})],y.prototype,"show",void 0),f["a"]([Object(m["b"])({default:""})],y.prototype,"name",void 0),f["a"]([Object(m["b"])({default:null})],y.prototype,"pluginData",void 0),f["a"]([Object(m["d"])("show")],y.prototype,"onShowChange",null),y=f["a"]([Object(m["a"])({name:"PluginDialog"})],y);var O=y,w=O,j=(n("f02e"),n("2877")),P=Object(j["a"])(w,r,a,!1,null,null,null);t["a"]=P.exports},e1f4:function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var a=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0===(3&t)&&(e=4294967296*Math.random()),a[t]=e>>>((3&t)<<3)&255;return a}}},eec9:function(e,t,n){"use strict";var r=n("9c3c"),a=n.n(r);a.a},f02e:function(e,t,n){"use strict";var r=n("63aa"),a=n.n(r);a.a},ffc1:function(e,t,n){var r=n("5ca1"),a=n("504c")(!0);r(r.S,"Object",{entries:function(e){return a(e)}})}}]);