????
Current Path : C:/inetpub/vhost/dbadm.gdtsolutions.vn/web/js/ |
Current File : C:/inetpub/vhost/dbadm.gdtsolutions.vn/web/js/plugin-connection-template-73cc503961eba251e3e3.js |
/*! For license information please see ../license.txt */ "use strict";(self.webpackChunk_cloudbeaver_product_default=self.webpackChunk_cloudbeaver_product_default||[]).push([[98546],{16853:(e,t,n)=>{n.r(t),n.d(t,{ConnectionDialog:()=>Q});var o=n(41773),i=n(7838),c=n(64928),s=n(17675),r=n(35025),a=n(56138),l=n(90447),d=n(51477),p=n(62204),u=n(92659),h=n(7167),m=n(84972),v=n(9428),g=n(20272),C=n(37549);const S={submittingForm:"submittingForm___RCD51",center:"center___aaIPd",connectionAuthenticationFormLoader:"connectionAuthenticationFormLoader___O7Vj9",errorMessage:"errorMessage___BrNKG theme-background-secondary theme-text-on-secondary"};var f=n(89232);const j={controls:"controls___Dqadp",fill:"fill___VU5hf"},_=(0,i.PA)((function ConnectionDialogFooter({isConnecting:e,onConnect:t,onBack:n}){const i=(0,c.d)(j),r=(0,s.W)();return(0,o.jsxs)("div",{className:i.controls,children:[(0,o.jsx)("div",{className:i.fill}),(0,o.jsx)(f.$,{type:"button",mod:["outlined"],disabled:e,onClick:n,children:r("ui_stepper_back")}),(0,o.jsx)(f.$,{type:"button",mod:["unelevated"],disabled:e,onClick:t,children:r(e?"basicConnection_connectionDialog_connecting":"connections_connection_connect")})]})}));var w;!function(e){e[e.ConnectionTemplateSelect=0]="ConnectionTemplateSelect",e[e.Connection=1]="Connection"}(w||(w={}));var P=n(15993),b=n(84383),I=n(16953),T=n(23089),x=n(74749),k=n(18699),D=n(10392),y=n(40813),R=n(71830),A=n(50011),H=n(10041),N=n(44880),M=n(7994),F=n(60233),L=n(66079);const E={staticImage:"staticImage___pViAR"},O=(0,i.PA)((function TemplateConnectionItem({template:e,dbDriver:t,onSelect:n}){const i=(0,P.useCallback)((()=>n(e.id)),[e]),s=(0,c.d)(E);return(0,o.jsxs)(H.c,{onClick:i,children:[(0,o.jsx)(N.L,{children:(0,o.jsx)(M.i,{className:(0,h.s)(s,{staticImage:!0}),icon:t?.icon})}),(0,o.jsx)(F.z,{children:e.name}),(0,o.jsx)(L.U,{title:e.description,children:e.description})]})})),q=(0,i.PA)((function TemplateConnectionSelector({className:e,onSelect:t}){(0,b.q)(TemplateConnectionSelector,D.ProjectInfoResource,y.fZ,{forceSuspense:!0}),(0,b.q)(TemplateConnectionSelector,R.TemplateConnectionsResource,void 0,{forceSuspense:!0});const n=(0,b.q)(TemplateConnectionSelector,x.DBDriverResource,y.fZ),i=(0,k.h)(A.TemplateConnectionsService).projectTemplates,[c,s]=(0,P.useState)(""),r=(0,P.useMemo)((()=>c?i.filter((e=>e.name.toUpperCase().includes(c.toUpperCase()))):i),[c,i]);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(I.o,{onChange:s}),(0,o.jsx)(T.k,{className:e,children:r.map((e=>(0,o.jsx)(O,{template:e,dbDriver:n.resource.get(e.driverId),onSelect:t},e.id)))})]})}));var B=n(94866),z=n(56826),U=n(28347),V=n(49690),W=n(86990),X=n(14452),Z=n(62151),G=n(43974),K=n(14509);const Q=(0,i.PA)((function ConnectionDialog({rejectDialog:e}){const t=(0,c.d)(S),n=(0,s.W)(),[i]=(0,r.i)({focusFirstChild:!0}),{credentialsSavingEnabled:f}=(0,a.J)(),j=function useConnectionDialog(e){const t=(0,k.h)(X.NotificationService),n=(0,k.h)(V.ConnectionInfoResource),o=(0,k.h)(A.TemplateConnectionsService),i=(0,k.h)(Z.ProjectsService),c=(0,k.h)(z.AuthProviderService),s=(0,k.h)(x.DBDriverResource);return(0,U.G)((()=>({get networkHandlers(){return this.template?.networkHandlersConfig?.filter((e=>e.enabled&&!e.savePassword)).map((e=>e.id))||[]},get authModelId(){return!1===this.template?.authNeeded||!0===this.driver?.anonymousAccess?null:this.template?.authModel||this.driver?.defaultAuthModel||null},step:w.ConnectionTemplateSelect,template:null,driver:null,processing:!1,connectException:null,config:{credentials:{},networkHandlersConfig:[],saveCredentials:!1},async connect(){if(!this.processing&&this.template&&this.projectsService.userProject)try{this.connectException=null,this.processing=!0;const e=(await this.connectionInfoResource.load((0,V.ConnectionInfoProjectKey)(this.projectsService.userProject.id))).map((e=>e.name)),t=(0,K.l)(this.template.name||"Template connection",e),n=await this.connectionInfoResource.createFromTemplate(this.template.projectId,this.template.id,t);if(n.requiredAuth&&!await this.authProviderService.requireProvider(n.requiredAuth))return this.setStep(w.ConnectionTemplateSelect),void await this.connectionInfoResource.deleteConnection((0,V.createConnectionParam)(n));try{await this.connectionInfoResource.init(this.getConfig(n.projectId,n.id)),this.notificationService.logSuccess({title:"plugin_connection_template_connect_success",message:n.name}),this.onConnect?.()}catch(e){this.connectException=e,await this.connectionInfoResource.deleteConnection((0,V.createConnectionParam)(n))}}catch(e){this.connectException=e}finally{this.processing=!1}},getConfig(e,t){const n={projectId:e,connectionId:t};return this.authModelId&&(Object.keys(this.config.credentials).length>0&&(n.credentials=this.config.credentials),n.saveCredentials=this.config.saveCredentials),this.config.networkHandlersConfig.length>0&&(n.networkCredentials=this.config.networkHandlersConfig),n},async selectTemplate(e){if(this.template=this.templateConnectionsService.projectTemplates.find((t=>t.id===e)),this.driver=await this.dbDriverResource.load(this.template.driverId),this.config={credentials:{},networkHandlersConfig:[],saveCredentials:!1},this.template.authNeeded){const e=this.template.authProperties?.find((e=>e.id===W.w));e?.value&&(this.config.credentials[W.w]=e.value)}for(const e of this.networkHandlers){const t=this.template.networkHandlersConfig?.find((t=>t.id===e));t&&(t.userName||t.authType!==G.f$w.Password)&&this.config.networkHandlersConfig.push({id:t.id,authType:t.authType,userName:t.userName,password:t.password,savePassword:t.savePassword})}this.setStep(w.Connection),this.authModelId||this.connect()},setStep(e){this.step=e,this.connectException=null,e===w.ConnectionTemplateSelect&&(this.template=null,this.driver=null)}})),{step:B.sH.ref,config:B.sH,template:B.sH.ref,driver:B.sH.ref,processing:B.sH.ref,connectException:B.sH.ref,networkHandlers:B.EW,authModelId:B.EW,connect:B.XI.bound,selectTemplate:B.XI.bound,setStep:B.XI.bound},{templateConnectionsService:o,projectsService:i,notificationService:t,authProviderService:c,connectionInfoResource:n,dbDriverResource:s,onConnect:e})}(e),P=(0,l.s)(j.connectException),b=j.step===w.Connection?j.template?.name:void 0;return(0,o.jsxs)(d.n,{size:"large",fixedSize:j.step===w.ConnectionTemplateSelect,children:[(0,o.jsx)(p.D,{title:"basicConnection_connectionDialog_newConnection",subTitle:b,icon:j.driver?.icon,onReject:e}),(0,o.jsxs)(u.a,{noBodyPadding:j.step===w.ConnectionTemplateSelect,noOverflow:!0,children:[j.step===w.ConnectionTemplateSelect&&(0,o.jsx)(q,{onSelect:j.selectTemplate}),j.step===w.Connection&&(j.authModelId?(0,o.jsx)(m.l,{ref:i,className:(0,h.s)(t,{submittingForm:!0}),onSubmit:j.connect,children:(0,o.jsx)(C.A,{config:j.config,authModelId:j.authModelId,networkHandlers:j.networkHandlers,formId:j.template?.id,allowSaveCredentials:f,disabled:j.processing,hideFeatures:["nonSecuredProperty"],className:(0,h.s)(t,{connectionAuthenticationFormLoader:!0})})}):(0,o.jsx)("center",{className:(0,h.s)(t,{center:!0}),children:j.processing&&n("basicConnection_connectionDialog_connecting_message")}))]}),j.step===w.Connection&&(0,o.jsxs)(v.Z,{children:[j.connectException&&(0,o.jsx)(g.K,{text:P.message??n("core_blocks_exception_message_error_message"),hasDetails:P.hasDetails,className:(0,h.s)(t,{errorMessage:!0}),onShowDetails:P.open}),(0,o.jsx)(_,{isConnecting:j.processing,onBack:()=>j.setStep(w.ConnectionTemplateSelect),onConnect:j.connect})]})]})}))},92708:(e,t,n)=>{n.r(t),n.d(t,{LocaleService:()=>r});var o=n(1118),i=n(82103),c=n(5576),s=n(34227);let r=class LocaleService extends i.j{constructor(e){super(),this.localizationService=e}register(){this.localizationService.addProvider(this.provider.bind(this))}load(){}async provider(e){switch(e){case"ru":return(await Promise.all([n.e(92436),n.e(8782)]).then(n.bind(n,91400))).default;case"it":return(await Promise.all([n.e(32756),n.e(1056)]).then(n.bind(n,25320))).default;case"zh":return(await Promise.all([n.e(52041),n.e(78675)]).then(n.bind(n,78555))).default;case"fr":return(await Promise.all([n.e(29671),n.e(56294)]).then(n.bind(n,80265))).default;default:return(await Promise.all([n.e(41114),n.e(33913)]).then(n.bind(n,74166))).default}}};r=(0,o.Cg)([(0,c._)(),(0,o.Sn)("design:paramtypes",[s.LocalizationService])],r)},86546:(e,t,n)=>{n.r(t),n.d(t,{TemplateConnectionPluginBootstrap:()=>j});var o=n(1118),i=n(56078),c=n(50420),s=n(82103),r=n(5576),a=n(71635),l=n(10392),d=n(62151),p=n(40813),u=n(20839),h=n(72877),m=n(79023),v=n(13429);const g=(0,n(19102).V)("connection-template",{label:"plugin_connection_template_action_connection_template_label"});var C=n(71830),S=n(50011);const f=(0,c.j)((()=>Promise.all([n.e(11502),n.e(7542),n.e(67557),n.e(89814),n.e(11450),n.e(98546),n.e(62570),n.e(95860),n.e(11532)]).then(n.bind(n,16853)).then((e=>e.ConnectionDialog))));let j=class TemplateConnectionPluginBootstrap extends s.j{constructor(e,t,n,o,i,c,s,r){super(),this.appAuthService=e,this.menuService=t,this.actionService=n,this.projectInfoResource=o,this.templateConnectionsResource=i,this.commonDialogService=c,this.templateConnectionsService=s,this.projectsService=r}register(){this.menuService.addCreator({menus:[v.y],getItems:(e,t)=>[...t,g]}),this.actionService.addHandler({id:"connection-template",actions:[g],isHidden:()=>!this.appAuthService.authenticated||!this.projectsService.userProject?.canEditDataSources||!this.templateConnectionsService.projectTemplates.length,getLoader:()=>[...this.appAuthService.loaders,(0,p.pd)(this.projectInfoResource,(()=>p.fZ)),(0,u.X)(this.templateConnectionsResource,(()=>{}),(()=>{}))],handler:async(e,t)=>{if(t===g)await this.openConnectionsDialog()}})}async openConnectionsDialog(){await this.commonDialogService.open(f,null)}};j=(0,o.Cg)([(0,r._)(),(0,o.Sn)("design:paramtypes",[i.AppAuthService,h.MenuService,m.ActionService,l.ProjectInfoResource,C.TemplateConnectionsResource,a.CommonDialogService,S.TemplateConnectionsService,d.ProjectsService])],j)},71830:(e,t,n)=>{n.r(t),n.d(t,{TemplateConnectionsResource:()=>p});var o=n(1118),i=n(56078),c=n(49690),s=n(5576),r=n(20839),a=n(85213),l=n(98076),d=n(83336);let p=class TemplateConnectionsResource extends r.V{constructor(e,t,n,o){super((()=>[])),this.graphQLService=e,this.sync(n),o.requireAuthentication(this),t.onConnectionCreate.addHandler((e=>{e.template&&this.markOutdated()})),t.onDataOutdated.addHandler((e=>{const n=t.get(e);(Array.isArray(n)?n:[n]).some((e=>e?.template))&&this.markOutdated()})),t.onItemUpdate.addHandler((e=>{t.get(a.F.toList(e)).some((e=>e?.template))&&this.markOutdated()})),t.onItemDelete.addHandler((e=>{t.get(a.F.toList(e)).some((e=>e?.template))&&this.markOutdated()}))}async loader(){const{connections:e}=await this.graphQLService.sdk.getTemplateConnections({includeNetworkHandlersConfig:!0,customIncludeOriginDetails:!1,includeAuthProperties:!0,includeOrigin:!1,includeAuthNeeded:!0,includeCredentialsSaved:!1,includeProperties:!1,includeProviderProperties:!1,includeSharedSecrets:!1,customIncludeOptions:!1});return e}};p=(0,o.Cg)([(0,s._)(),(0,o.Sn)("design:paramtypes",[d.GraphQLService,c.ConnectionInfoResource,l.SessionDataResource,i.AppAuthService])],p)},50011:(e,t,n)=>{n.r(t),n.d(t,{TemplateConnectionsService:()=>r});var o=n(1118),i=n(5576),c=n(62151),s=n(71830);let r=class TemplateConnectionsService{get projectTemplates(){return this.projectsService.userProject&&this.projectsService.activeProjects.includes(this.projectsService.userProject)?this.templateConnectionsResource.data:[]}constructor(e,t){this.templateConnectionsResource=e,this.projectsService=t}};r=(0,o.Cg)([(0,i._)(),(0,o.Sn)("design:paramtypes",[s.TemplateConnectionsResource,c.ProjectsService])],r)}}]);