Ext.define("KSWN.meta.taskScheduler.view.RemoteConnectLoginWindow",{extend:"Ext.window.Window",defaultListenerScope:!0,xtype:"ks-meta-taskscheduler-view-removeconnectloginwin",defaultType:"textfield",layout:"fit",minHeight:180,minWidth:360,title:KSWN.Locale.danniedlyapodklyucheniya,hostCacheKey:"ks-meta-taskscheduler-view-removeconnectloginwin__host",loginCacheKey:"ks-meta-taskscheduler-view-removeconnectloginwin__login",modal:!0,items:{xtype:"form",layout:"form",itemId:"form",defaultType:"textfield",items:[{fieldLabel:KSWN.Locale.host,name:"host",allowBlank:!1},{fieldLabel:KSWN.Locale.login,name:"login",allowBlank:!1},{fieldLabel:KSWN.Locale.parol,name:"password",inputType:"password"}]},fbar:[{text:KSWN.Locale.ok,handler:"onConfirm"},{text:KSWN.Locale.otmena,handler:"onCancel"}],initComponent:function(){this.callParent(),this.formPanel=this.down("form"),this.restoreCachedValues()},restoreCachedValues:function(){const values=this.getCachedValues();this.formPanel.form.setValues(values)},onConfirm:function(){const{formPanel:formPanel}=this;if(formPanel.isValid()){const values=formPanel.getValues();this.fireEvent("confirm",this,values),this.cacheValues(values),this.close()}},onCancel:function(){this.close()},getCachedValues:function(){const cacheProvider=Ext.state.Manager;return{host:cacheProvider.get(this.hostCacheKey,""),login:cacheProvider.get(this.loginCacheKey,"")}},cacheValues:function(_ref){let{host:host,login:login}=_ref;const cacheProvider=Ext.state.Manager;cacheProvider.set(this.hostCacheKey,host),cacheProvider.set(this.loginCacheKey,login)}}),Ext.define("KSWN.meta.taskScheduler.RemoteTaskSchedulerProvider",{connectionParams:void 0,constructor:function(){this.initConfig(),this.xmlParser=new X2JS},loadTasks:async function(){const connectionParams=await this.requestConnectionParams();if(!connectionParams)return null;this.connectionParams=connectionParams;const xml=await this.fetchTasks();if(!xml)return null;this.parseXML(xml);return null},fetchTasks:function(){return Ajax({url:"RemoteTaskSchedulerProvider/LoadTaskScheduler",params:{...this.connectionParams}})},parseXML:function(xml){this.xmlParser.xml_str2json(xml)},requestConnectionParams:async function(){return new Promise(resolve=>{let resolved=!1;new KSWN.meta.taskScheduler.view.RemoteConnectLoginWindow({listeners:{confirm:(win,values)=>{resolved=!0,resolve(values)},close:()=>!resolved&&resolve(!1)}}).show()})}});