@ecip/auth
Version:
2 lines • 15.1 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@ecip/shared"),require("@delon/theme"),require("util"),require("@angular/core"),require("ng-zorro-antd"),require("rxjs/operators"),require("@ecip/service"),require("@angular/router")):"function"==typeof define&&define.amd?define("@ecip/auth",["exports","@ecip/shared","@delon/theme","util","@angular/core","ng-zorro-antd","rxjs/operators","@ecip/service","@angular/router"],t):t((e.ecip=e.ecip||{},e.ecip.auth={}),e[1][0]["0-rc"][5],e.theme,e.util,e.ng.core,e.ngZorroAntd,e.rxjs.operators,e[1][0]["0-rc"][5],e.ng.router)}(this,function(e,t,r,s,i,n,a,o,c){"use strict";function u(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function d(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,s=r.call(e),o=[];try{for(;(void 0===t||0<t--)&&!(i=s.next()).done;)o.push(i.value)}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=s["return"])&&r.call(s)}finally{if(n)throw n.error}}return o}var l=function(){function e(e,t,r,i){var n=this;this.modal=e,this.dataSourceService=t,this.messageService=r,this.dictService=i,this.title="编辑数据源",this.schema={properties:{dsName:{type:"string",title:"数据源名称",ui:{validator:function(t){return n.dataSourceService.existsDsName(t).pipe(a.map(function(e){return e&&(n.isNew||n.record.dsName!=t)?[{keyword:"required",message:"数据源名已存在"}]:[]}))}}},dbType:{type:"string",title:"数据库类型","default":"",ui:{widget:"select"}},dbName:{type:"string",title:"数据库名"},url:{type:"string",title:"协议(URL前缀)"},ip:{type:"string",title:"主机(IP或域名)"},port:{type:"number",title:"端口号",ui:{widget:"string"}},username:{type:"string",title:"用户名"},password:{type:"string",title:"密码",ui:{widget:"string",type:"password"}}},required:["dsName","dbType","dbName","url","ip","port","username","password"]},this.ui={"*":{grid:{span:18,offset:2}}}}return e.prototype.ngOnInit=function(){!0===this.isNew&&(this.title="新建数据源")},e.prototype.ngAfterViewInit=function(){var t=this;this.dictService.getTypeList("dbType").subscribe(function(e){t.sf.schema.properties.dbType["enum"]=[{value:"",label:"请选择"}].concat(e),t.sf.refreshSchema()})},e.prototype.submit=function(e){!0===this.isNew?this.create(e):this.update(e)},e.prototype.create=function(e){var t=this;this.dataSourceService.post(e).subscribe(function(){t.modal.close(!0)})},e.prototype.update=function(e){var t=this;this.dataSourceService.put(this.record.id,e).subscribe(function(){t.modal.close(!0)})},e.prototype.testConnection=function(e){var t=this;this.dataSourceService.testConnection(e).subscribe(function(e){!0===e.body?t.messageService.success("连接成功"):t.messageService.error("连接失败")})},e.prototype.close=function(){this.modal.destroy()},e.decorators=[{type:i.Component,args:[{selector:"app-auth-ds-edit",template:'<div class="modal-header">\r\n <div class="modal-title">{{title}}</div>\r\n</div>\r\n<nz-spin *ngIf="!isNew&&!record"></nz-spin>\r\n<sf #sf mode="default" [schema]="schema" [ui]="ui" [formData]="record" button="none">\r\n <div class="modal-footer">\r\n <button nz-button type="button" nzType="primary" (click)="testConnection(sf.value)" [disabled]="!sf.valid" [nzLoading]="dataSourceService.http.loading">测试连接</button>\r\n <button nz-button type="submit" nzType="primary" (click)="submit(sf.value)" [disabled]="!sf.valid" [nzLoading]="dataSourceService.http.loading">保存</button>\r\n <button nz-button type="button" (click)="close()">取消</button>\r\n </div>\r\n</sf>\r\n'}]}],e.ctorParameters=function(){return[{type:n.NzModalRef},{type:o.DataSourceService},{type:n.NzMessageService},{type:o.DictService}]},e.propDecorators={sf:[{type:i.ViewChild,args:["sf"]}],record:[{type:i.Input}],isNew:[{type:i.Input}]},e}(),p=function(){function e(e,t,r,i){var a=this;this.modalHelper=e,this.messageService=t,this.dataSourceService=r,this.dictService=i,this.url="api/v1/sysrDS",this.selectedIds=[],this.pageTitle="数据源管理",this.params={},this.schema={properties:{dsName:{type:"string",title:"数据源名称"},dbType:{type:"string",title:"数据库类型",ui:{widget:"select",width:260,notFoundContent:"没有数据",dropdownMatchSelectWidth:!1,asyncData:function(){return a.dictService.getTypeList("dbType")}}},ip:{type:"string",title:"主机名"},dbName:{type:"string",title:"数据库名"}}},this.columns=[{title:"编号",type:"checkbox",index:"id",fixed:"left",width:"2%"},{title:"数据源名称",index:"dsName",fixed:"left",width:"10%"},{title:"数据库类型",index:"dbType",fixed:"left",width:"6%",format:function(e){var t,r;try{for(var i=u(a.dbTypeList),n=i.next();!n.done;n=i.next()){var s=n.value;if(e.dbType==s.value)return s.label}}catch(o){t={error:o}}finally{try{n&&!n.done&&(r=i["return"])&&r.call(i)}finally{if(t)throw t.error}}return e.dbType}},{title:"数据库名",index:"dbName",fixed:"left",width:"8%"},{title:"URL",index:"url"},{title:"主机名",index:"ip"},{title:"端口号",index:"port"},{title:"用户名",index:"username"},{title:"操作",fixed:"right",width:"9%",buttons:[{text:"编辑",icon:"edit",type:"static",component:l,click:function(e,t){a.messageService.success("编辑成功"),a.st.load(-1,a.params)},acl:{ability:["datasource:edit"]}},{text:"删除",icon:"delete",type:"del",click:function(e,t,r){a.dataSourceService.deleteById(e.id).subscribe(function(){a.messageService.success("删除成功"),r.load(-1,a.params)})},acl:{ability:["datasource:remove"]}}]}]}return e.prototype.ngOnInit=function(){var t=this;this.dictService.getTypeList("dbType").subscribe(function(e){t.dbTypeList=e})},e.prototype.checkboxChange=function(e){var t,r;this.selectedIds=[];try{for(var i=u(e),n=i.next();!n.done;n=i.next()){var s=n.value;this.selectedIds.push(s.id)}}catch(o){t={error:o}}finally{try{n&&!n.done&&(r=i["return"])&&r.call(i)}finally{if(t)throw t.error}}},e.prototype.formBind=function(){this.params=this.sf.value},e.prototype.multiDelete=function(){var e=this;0==this.selectedIds.length?this.messageService.warning("未选择任何记录"):this.dataSourceService.multiDelete(this.selectedIds).subscribe(function(){e.messageService.success("删除成功"),e.st.load(-1,e.params)})},e.prototype.create=function(){var e=this;this.modalHelper.createStatic(l,{isNew:!0}).subscribe(function(){e.messageService.success("创建成功"),e.st.load(-1,e.params)})},e.decorators=[{type:i.Component,args:[{selector:"app-auth-ds",template:'<page-header [action]="phPhAction">\r\n <ng-template #phPhAction>\r\n <button acl [acl-ability]="\'datasource:add\'" nz-button nzType="primary" (click)="create()">新建</button>\r\n \x3c!--<button nz-button (click)="multiDelete()">删除</button>--\x3e\r\n </ng-template>\r\n</page-header>\r\n<nz-card>\r\n <sf #sf mode="search" [schema]="schema" (formSubmit)="formBind();st.load(1, params);" (formReset)="formBind();st.reset(params)"></sf>\r\n <st #st [data]="url" [columns]="columns" [scroll]="{x:\'150%\'}" (change)="checkboxChange($event)" [req]="{params: params}" [page]="{front: false}"></st>\r\n</nz-card>\r\n'}]}],e.ctorParameters=function(){return[{type:r.ModalHelper},{type:n.NzMessageService},{type:o.DataSourceService},{type:o.DictService}]},e.propDecorators={st:[{type:i.ViewChild,args:["st"]}],sf:[{type:i.ViewChild,args:["sf"]}]},e}(),h=function(){function e(e,t,r,i){var n=this;this.modalHelper=e,this.messageService=t,this.ruleService=r,this.dataSourceService=i,this.url="api/v1/sysrRule",this.selectedIds=[],this.params={},this.schema={properties:{ruleName:{type:"string",title:"规则名称"},srcDs:{type:"string",title:"源数据源",ui:{widget:"select",width:260,notFoundContent:"没有数据",dropdownMatchSelectWidth:!1,asyncData:function(){return n.dataSourceService.getVoList()}}}}},this.columns=[{title:"编号",type:"checkbox",index:"id"},{title:"规则名称",index:"ruleName"},{title:"源数据源",index:"srcDsName"},{title:"同步类型",index:"syncType",format:function(e){switch(e.syncType){case"user":return"同步用户";case"dept":return"同步组织";case"other":return"自定义(表名:"+e.destTable+")"}}},{title:"Cron表达式",index:"cron",format:function(e){return s.isNullOrUndefined(e.cron)||""==e.cron?"(无)":e.cron}},{title:"操作",buttons:[{text:"编辑",icon:"edit",type:"link",click:function(e){return"/auth/rule/edit/"+e.id},acl:{ability:["rule:edit"]}},{text:"删除",icon:"delete",type:"del",click:function(e,t,r){n.ruleService.deleteById(e.id).subscribe(function(){n.messageService.success("删除成功"),r.load(-1,n.params)})},acl:{ability:["rule:remove"]}}]}]}return e.prototype.checkboxChange=function(e){var t,r;this.selectedIds=[];try{for(var i=u(e),n=i.next();!n.done;n=i.next()){var s=n.value;this.selectedIds.push(s.id)}}catch(o){t={error:o}}finally{try{n&&!n.done&&(r=i["return"])&&r.call(i)}finally{if(t)throw t.error}}},e.prototype.formBind=function(){this.params=this.sf.value},e.prototype.multiDelete=function(){var e=this;0==this.selectedIds.length?this.messageService.warning("未选择任何记录"):this.ruleService.multiDelete(this.selectedIds).subscribe(function(){e.messageService.success("删除成功"),e.st.load(-1,e.params)})},e.decorators=[{type:i.Component,args:[{selector:"app-auth-ds",template:'<page-header [action]="phPhAction">\r\n <ng-template #phPhAction>\r\n <button acl [acl-ability]="\'rule:add\'" nz-button nzType="primary" routerLink="/auth/rule/edit">新建</button>\r\n \x3c!--<button nz-button (click)="multiDelete()">删除</button>--\x3e\r\n </ng-template>\r\n</page-header>\r\n<nz-card>\r\n <sf #sf mode="search" [schema]="schema" (formSubmit)="formBind();st.load(1, params);" (formReset)="formBind();st.reset(params)"></sf>\r\n <st #st [data]="url" [columns]="columns" (change)="checkboxChange($event)" [req]="{params: params}" [page]="{front: false}"></st>\r\n</nz-card>\r\n'}]}],e.ctorParameters=function(){return[{type:r.ModalHelper},{type:n.NzMessageService},{type:o.RuleService},{type:o.DataSourceService}]},e.propDecorators={st:[{type:i.ViewChild,args:["st"]}],sf:[{type:i.ViewChild,args:["sf"]}]},e}(),y=function(){function e(e,t,r,i,n,s){var o=this;this.ruleService=e,this.messageService=t,this.dataSourceService=r,this.dictService=i,this.activeRoute=n,this.router=s,this.schema={properties:{ruleName:{type:"string",title:"规则名称",ui:{validator:function(t){return o.ruleService.existsRuleName(t).pipe(a.map(function(e){return e&&(o.isNew||o.record.ruleName!=t)?[{keyword:"required",message:"规则名称已存在"}]:[]}))}}},appId:{type:"number",title:"源应用",ui:{widget:"select",notFoundContent:"没有数据",asyncData:function(){return o.ruleService.appListVL()}}},srcDs:{type:"string",title:"源数据源",ui:{widget:"select",notFoundContent:"没有数据",asyncData:function(){return o.dataSourceService.getVoList()}}},srcSql:{type:"string",title:"源SQL",ui:{widget:"textarea",autosize:{minRows:3}}},cron:{type:"string",title:"Cron表达式",ui:{placeholder:"Cron为空时将立即执行同步"}},syncType:{type:"string",title:"同步类型",ui:{widget:"radio",asyncData:function(){return o.dictService.getTypeList("syncType")}}},destTable:{type:"string",title:"表名称",ui:{visibleIf:{syncType:["other"]}}},idType:{type:"string",title:"新增主键策略",ui:{widget:"radio",asyncData:function(){return o.dictService.getTypeList("syncIdType")},validator:function(e){return"auto"===e&&"ID"===o.sf.value.uniqConstraint.trim().toUpperCase()?[{keyword:"format",message:"唯一约束字段为'ID'时新增主键策略不能为自动生成"}]:[]}}},uniqConstraint:{type:"string",title:"唯一约束字段",ui:{placeholder:"唯一约束字段为'ID'时不可选择自动生成新主键",validator:function(e){return"ID"===e.trim().toUpperCase()&&"auto"===o.sf.value.idType?[{keyword:"format",message:"唯一约束字段为'ID'时新增主键策略不能为自动生成"}]:[]}}},fieldMappings:{type:"array",title:"字段映射",minItems:1,uniqueItems:!0,items:{type:"object",properties:{srcField:{type:"string",title:"源字段"},destField:{type:"string",title:"目标字段"}},required:["srcField","destField"]},ui:{grid:{arraySpan:12},addTitle:"添加字段"}}},required:["ruleName","srcDs","syncType","srcSql","uniqConstraint","appId","idType"]}}return e.prototype.ngOnInit=function(){var t=this;if(this.isNew=this.activeRoute.snapshot.data.isNew,this.title=this.activeRoute.snapshot.data.title,!1===this.isNew){var e=this.activeRoute.snapshot.params.id;null!=e&&this.ruleService.getById(e).subscribe(function(e){null==e?t.router.navigateByUrl("404"):t.record=e})}},e.prototype.submit=function(e){!0===this.isNew?(this.create(e),this.router.navigateByUrl("/auth/rule")):this.update(e)},e.prototype.create=function(e){var t=this;this.ruleService.post(e).subscribe(function(){t.messageService.success("已保存")})},e.prototype.update=function(e){var t=this;this.ruleService.put(this.record.id,e).subscribe(function(){t.messageService.success("已保存")})},e.prototype.close=function(){},e.prototype.testSync=function(e){var t=this;this.ruleService.testSync(e).subscribe(function(e){!0===e.body?t.messageService.success("同步测试成功"):t.messageService.error("同步测试失败")})},e.decorators=[{type:i.Component,args:[{selector:"app-auth-rule-edit",template:'<page-header [title]="title"></page-header>\r\n<nz-card>\r\n <sf #sf mode="edit" [schema]="schema" [formData]="record" button="none">\r\n <div class="modal-footer">\r\n <button nz-button type="button" nzType="primary" (click)="testSync(sf.value)" [disabled]="!sf.valid" [nzLoading]="ruleService.http.loading">同步测试</button>\r\n <button nz-button type="submit" nzType="primary" (click)="submit(sf.value)" [disabled]="!sf.valid" [nzLoading]="ruleService.http.loading">保存</button>\r\n <button nz-button type="button" routerLink="/auth/rule">关闭</button>\r\n </div>\r\n </sf>\r\n</nz-card>'}]}],e.ctorParameters=function(){return[{type:o.RuleService},{type:n.NzMessageService},{type:o.DataSourceService},{type:o.DictService},{type:c.ActivatedRoute},{type:c.Router}]},e.propDecorators={sf:[{type:i.ViewChild,args:["sf"]}]},e}(),f=[{path:"ds",component:p},{path:"rule",component:h},{path:"rule/edit",component:y,data:{isNew:!0,title:"新建同步策略"}},{path:"rule/edit/:id",component:y,data:{isNew:!1,title:"编辑同步策略"}}],m=function(){function e(){}return e.decorators=[{type:i.NgModule,args:[{imports:[c.RouterModule.forChild(f)],exports:[c.RouterModule]}]}],e}(),v=[p,h,y],g=[l],b=function(){function e(){}return e.decorators=[{type:i.NgModule,args:[{imports:[t.SharedModule,m],declarations:function r(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(d(arguments[t]));return e}(v,g),entryComponents:g}]}],e}();e.AuthModule=b,e.AuthRoutingModule=m,e.AuthDataSourceComponent=p,e.AuthDataSourceEditComponent=l,e.AuthRuleComponent=h,e.AuthRuleEditComponent=y,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=auth.umd.min.js.map