v2board/public/p__admin__server.async.js

1 line
16 KiB
JavaScript
Raw Normal View History

2019-11-18 19:35:13 +08:00
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([[6],{"6G7H":function(e,t,a){"use strict";a.r(t);var n=a("jehZ"),s=a.n(n),i=(a("2qtc"),a("kLXV")),r=(a("OaEy"),a("2fM7")),l=(a("5NDa"),a("5rEg")),c=(a("g9YV"),a("wCAj")),m=(a("/zsF"),a("PArb")),o=(a("BoS7"),a("Sdc0")),d=(a("+BJd"),a("mr32")),h=(a("Awhp"),a("KrTs")),p=(a("5Dmo"),a("3S7+")),u=(a("Pwec"),a("CtXQ")),v=a("p0pE"),g=a.n(v),b=a("q1tI"),E=a.n(b),f=a("Bl7J"),N=a("/MKj"),w=a("t3Un");class y extends E.a.Component{constructor(){super(...arguments),this.state={server:[],group:[],visible:!1,submit:{tls:0,rate:1,tags:[]},loading:!0}}componentDidMount(){this.fetchData()}fetchData(){Object(w["a"])("/admin/server",{group_id:this.props.location.query.group_id}).then(e=>{200===e.code&&this.setState({server:e.data,loading:!1})}),Object(w["a"])("/admin/server/group").then(e=>{200===e.code&&this.setState({group:e.data})})}modalVisible(){this.setState({visible:!this.state.visible}),this.state.visible&&this.setState({submit:{tls:0,rate:1}})}submit(){Object(w["b"])("/admin/server/save",this.state.submit).then(e=>{200===e.code&&(this.modalVisible(),this.fetchData())})}drop(e){Object(w["b"])("/admin/server/drop",{id:e}).then(e=>{this.fetchData()})}update(e,t,a){this.setState({[e+t+"_loading"]:!0},()=>{Object(w["b"])("/admin/server/update",{id:e,[t]:a}).then(a=>{200===a.code&&(this.fetchData(),this.setState({[e+t+"_loading"]:!1}))})})}edit(e){this.setState({submit:g()({},this.state.server[e]),visible:!0})}render(){var e=[{title:"\u8282\u70b9ID",dataIndex:"id",key:"id"},{title:E.a.createElement("span",null,"\u5728\u7ebf ",E.a.createElement(p["a"],{placement:"top",title:"\u4e94\u5206\u949f\u5185\u8282\u70b9\u5728\u7ebf\u60c5\u51b5"},E.a.createElement(u["a"],{type:"question-circle"}))),dataIndex:"last_check_at",key:"last_check_at",align:"center",render:e=>{return E.a.createElement(h["a"],{status:(new Date).getTime()/1e3-300>e?"error":"processing"})}},{title:"\u6743\u9650\u7ec4",dataIndex:"group_id",key:"group_id",render:(e,t)=>{var a=t.group_id,n=[];return a.map(e=>{this.state.group.map(t=>{if(t.id===parseInt(e))return n.push(E.a.createElement(d["a"],null,t.name))})}),n}},{title:"\u8282\u70b9\u540d\u79f0",dataIndex:"name",key:"name"},{title:"\u5730\u5740",dataIndex:"host",key:"host",render:(e,t)=>{return t.host+":"+t.port}},{title:"TLS",dataIndex:"tls",key:"tls",render:e=>{return 0===e?"\u4e0d\u652f\u6301":"\u652f\u6301"}},{title:"\u500d\u7387",dataIndex:"rate",key:"rate",render:e=>{return e+" x"}},{title:"\u663e\u9690",dataIndex:"show",key:"show",align:"center",render:(e,t)=>{return E.a.createElement(o["a"],{loading:this.state[t.id+"show_loading"],size:"small",checked:parseInt(e),onClick:()=>this.update(t.id,"show",parseInt(e)?0:1)})}},{title:"\u64cd\u4f5c",dataIndex:"action",key:"action",align:"right",render:(e,t,a)=>{return E.a.createElement("div",null,E.a.createElement("a",{href:"javascript:;",onClick:()=>this.edit(a)},"\u7f16\u8f91"),E.a.createElement(m["a"],{type:"vertical"}),E.a.createElement("a",{href:"javascript:;",onClick:()=>this.drop(t.id)},"\u5220\u9664"))}}];return E.a.createElement(f["a"],s()({},this.props,{loading:this.state.loading}),E.a.createElement("main",{id:"main-container"},E.a.createElement("div",{className:"content content-full"},E.a.createElement("div",{className:"d-flex justify-content-between align-items-center"},E.a.createElement("h2",{className:"font-w300 mt-4 mb-3"},"\u8282\u70b9\u7ba1\u7406"),E.a.createElement("button",{type:"button",className:"btn btn-primary btn-sm btn-primary btn-rounded px-3",onClick:()=>this.modalVisible()},"\u6dfb\u52a0\u8282\u70b9")),E.a.createElement("div",{className:"bg-white"},E.a.createElement(c["a"],{dataSource:this.state.server,columns:e,pagination:!1,scroll:{x:1e3}})))),E.a.createElement(i["a"],{title:"\u65b0\u5efa\u8282\u70b9",visible:this.state.visible,onCancel:()=>this.modalVisible(),onOk:()=>this.submit()},E.a.createElement("div",null,E.a.createElement("div",{className:"row"},E.a.createElement("div",{className:"form-group col-8"},E.a.createElement("label",{for:"example-text-input-alt"},"\u8282\u70b9\u540d\u79f0"),