Ext.namespace("Zarafa.plugins.mdm");
Zarafa.plugins.mdm.MDM=Ext.extend(Zarafa.core.Plugin,{constructor:function(a){a=a||{};Zarafa.plugins.mdm.MDM.superclass.constructor.call(this,a);Zarafa.core.ModuleNames["IPM.MDM"]={list:"pluginmdmmodule",item:"pluginmdmmodule"}},initPlugin:function(){this.registerInsertionPoint("context.settings.categories",this.createSettingCategory,this);Zarafa.core.data.SharedComponentType.addProperty("mdm.dialog.mdmdevicecontentpanel");Zarafa.core.data.SharedComponentType.addProperty("mdm.dialog.mdmmanagesharedfoldercontentpanel");Zarafa.plugins.mdm.MDM.superclass.initPlugin.apply(this,
arguments)},bidSharedComponent:function(a,b){b=-1;switch(a){case Zarafa.core.data.SharedComponentType["mdm.dialog.mdmdevicecontentpanel"]:case Zarafa.core.data.SharedComponentType["mdm.dialog.mdmmanagesharedfoldercontentpanel"]:b=1}return b},getSharedComponent:function(a,b){switch(a){case Zarafa.core.data.SharedComponentType["mdm.dialog.mdmdevicecontentpanel"]:var c=Zarafa.plugins.mdm.dialogs.MDMDeviceContentPanel;break;case Zarafa.core.data.SharedComponentType["mdm.dialog.mdmmanagesharedfoldercontentpanel"]:c=
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel}return c},createSettingCategory:function(){return[{xtype:"Zarafa.plugins.mdm.mdmsettingscategory"}]},createVersionInfo:function(){var a=container.getSettingsModel().get("zarafa/v1/plugins/mdm/zpush-server-version",!0);return{fieldLabel:_("grommunio-sync"),value:a}}});Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"mdm",displayName:_("Mobile device management"),pluginConstructor:Zarafa.plugins.mdm.MDM}))});
Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMDeviceFolderStore=Ext.extend(Zarafa.core.data.MAPISubStore,{constructor:function(a){a=a||{};Ext.applyIf(a,{autoLoad:!0,remoteSort:!1,reader:new Zarafa.plugins.mdm.data.JsonDeviceFolderReader({customObjectType:Zarafa.core.data.RecordCustomObjectType.MDM_Device_Folder}),writer:new Zarafa.plugins.mdm.data.MDMDeviceFolderWriter,proxy:new Zarafa.core.data.IPMProxy({listModuleName:"pluginmdmmodule",itemModuleName:"pluginmdmmodule"})});Zarafa.plugins.mdm.data.MDMDeviceFolderStore.superclass.constructor.call(this,
a)},addFolder:function(a){a=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.MDM_Device_Folder,{entryid:a.get("entryid")});this.add(a)},removeFolder:function(a){var b=this.findBy(function(c){return Zarafa.core.EntryId.compareEntryIds(c.get("entryid"),a.get("entryid"))});0<=b&&this.removeAt(b)}});Ext.reg("mdm.devicefolderstore",Zarafa.plugins.mdm.data.MDMDeviceFolderStore);Ext.namespace("Zarafa.plugins.mdm");
Zarafa.plugins.mdm.data.MDMDeviceFolderRecordFields=[{name:"store",type:"string"},{name:"folderid",type:"string"},{name:"name",type:"string"},{name:"type",type:"int"},{name:"flags",type:"int"},{name:"entryid",type:"string"}];Zarafa.core.data.RecordCustomObjectType.addProperty("MDM_Device_Folder");Zarafa.core.data.RecordFactory.addFieldToCustomType(Zarafa.core.data.RecordCustomObjectType.MDM_Device_Folder,Zarafa.plugins.mdm.data.MDMDeviceFolderRecordFields);
Zarafa.core.data.RecordFactory.setBaseClassToCustomType(Zarafa.core.data.RecordCustomObjectType.MDM_Device_Folder,Zarafa.core.data.MAPIRecord);Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.JsonDeviceFolderReader=Ext.extend(Zarafa.core.data.JsonReader,{constructor:function(a,b){a=Ext.applyIf(a||{},{id:"folderid",idProperty:"folderid",dynamicRecord:!1});Ext.isDefined(b)||(b=Zarafa.core.data.RecordFactory.getRecordClassByCustomType(a.customObjectType));Zarafa.plugins.mdm.data.JsonDeviceFolderReader.superclass.constructor.call(this,a,b)}});Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMResponseHandler=Ext.extend(Zarafa.core.data.AbstractResponseHandler,{successCallback:Ext.emptyFn,failureCallback:Ext.emptyFn,doInfo:function(a){this.successCallback(a)},doAuthenticate:function(a){this.processAuthResponse(a,this.successCallback,"authenticate")},doRemove:function(a){a.remove?this.successCallback():this.processAuthResponse(a,this.failureCallback,"remove")},doWipe:function(a){!0===a.wipe?container.getNotifier().notify("info.mdm",_("Mobile Device Manager"),_("Wiping device")):
a.wipe?this.processAuthResponse(a,this.failureCallback,"wipe"):container.getNotifier().notify("info.mdm",_("Mobile Device Manager"),_("Password incorrect"))},doResync:function(a){!0===a.resync?container.getNotifier().notify("info.mdm",_("Mobile Device Manager"),_("Full resync in progress")):this.processAuthResponse(a,this.failureCallback,"resync")},processAuthResponse:function(a,b,c){if(a=a.authenticationInfo)b.call(this.mdmWidgetScope,a.authentication),"authenticate"===c&&!1===a.authentication&&
container.getNotifier().notify("info.mdm",_("Mobile Device Manager"),_("Username or password incorrect"))}});Ext.reg("mdm.responsehandler",Zarafa.plugins.mdm.data.MDMResponseHandler);Ext.namespace("Zarafa.plugins.mdm");
Zarafa.plugins.mdm.data.MDMDeviceRecordFields=[{name:"entryid",type:"string"},{name:"devicetype",type:"string"},{name:"deviceos",type:"string"},{name:"devicefriendlyname",type:"string"},{name:"useragent",type:"string"},{name:"asversion",type:"string"},{name:"firstsynctime",type:"date",dateFormat:"timestamp"},{name:"lastsynctime",type:"date",dateFormat:"timestamp"},{name:"lastupdatetime",type:"date",dateFormat:"timestamp"},{name:"wipestatus",type:"string"},{name:"policyname",type:"string"},{name:"sharedfolders",
type:"string"},{name:"shortfolderids",type:"string"},{name:"synchronizedfolders",type:"string",defaultValue:"0"},{name:"emailsfolder",type:"string",defaultValue:"0"},{name:"contactsfolder",type:"string",defaultValue:"0"},{name:"tasksfolder",type:"string",defaultValue:"0"},{name:"calendarsfolder",type:"string",defaultValue:"0"},{name:"notesfolder",type:"string",defaultValue:"0"},{name:"koeversion",type:"string"},{name:"koebuild",type:"string"},{name:"koebuilddate",type:"date",dateFormat:"timestamp"},
{name:"message_class",type:"string",defaultValue:"IPM.MDM"}];Zarafa.plugins.mdm.data.MDMDeviceRecord=Ext.extend(Zarafa.core.data.IPMRecord,{});Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.MDM",Zarafa.plugins.mdm.data.MDMDeviceRecordFields);Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.MDM",Zarafa.plugins.mdm.data.MDMDeviceRecord);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.MDM","sharedfolders",Zarafa.plugins.mdm.data.MDMDeviceFolderStore);Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.JsonCertificateReader=Ext.extend(Zarafa.core.data.JsonReader,{constructor:function(a,b){a=Ext.applyIf(a||{},{dynamicRecord:!1});b=Zarafa.core.data.RecordFactory.getRecordClassByMessageClass("IPM.MDM");Zarafa.plugins.mdm.data.JsonCertificateReader.superclass.constructor.call(this,a,b)}});Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMDeviceFolderWriter=Ext.extend(Zarafa.core.data.JsonWriter,{toPropHash:function(a){var b=a.getSubStore("sharedfolders");a={};if(!Ext.isDefined(b))return a;var c=b.getModifiedRecords();b=b.getRemovedRecords();c.length&&(a.sharedfolders={},a.sharedfolders.add=c.map(function(d){return d.data}));b.length&&(a.sharedfolders=a.sharedfolders||{},a.sharedfolders.remove=b.map(function(d){return d.data}));return a}});Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMDeviceStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(a){a=a||{};Ext.applyIf(a,{remoteSort:!1,reader:new Zarafa.plugins.mdm.data.JsonCertificateReader,writer:new Zarafa.core.data.JsonWriter,proxy:new Zarafa.plugins.mdm.data.MDMDeviceProxy});this.addEvents("beforeloadrecord");Zarafa.plugins.mdm.data.MDMDeviceStore.superclass.constructor.call(this,a)},loadRecords:function(a,b,c,d){d&&d.authenticationInfo&&this.fireEvent("beforeloadrecord",d.authenticationInfo.authentication);
Zarafa.plugins.mdm.data.MDMDeviceStore.superclass.loadRecords.apply(this,arguments)}});Ext.reg("mdm.devicestore",Zarafa.plugins.mdm.data.MDMDeviceStore);Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.ProvisioningStatus=Zarafa.core.Enum.create({NOT_APPLICABLE:0,OK:1,WIPE_PENDING:2,WIPE_REQUESTED:4,WIPE_EXECUTED:8,getDisplayName:function(a){switch(a){case Zarafa.plugins.mdm.data.ProvisioningStatus.NOT_APPLICABLE:return _("Not Applicable");case Zarafa.plugins.mdm.data.ProvisioningStatus.OK:return _("Ok");case Zarafa.plugins.mdm.data.ProvisioningStatus.WIPE_PENDING:return _("Wipe Pending");case Zarafa.plugins.mdm.data.ProvisioningStatus.WIPE_REQUESTED:return _("Wipe Requested");
case Zarafa.plugins.mdm.data.ProvisioningStatus.WIPE_EXECUTED:return _("Wipe Executed");default:return _("Not Available")}}});Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMDeviceProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{constructor:function(a){a=a||{};Ext.applyIf(a,{listModuleName:"pluginmdmmodule",itemModuleName:"pluginmdmmodule"});Zarafa.plugins.mdm.data.MDMDeviceProxy.superclass.constructor.call(this,a)},getResponseHandlerForRequest:function(a,b,c,d,f,k,g,e,h){return new Zarafa.plugins.mdm.data.MDMDeviceResponseHandler({proxy:this,action:c,reader:k,sendRecords:d,options:h,callback:g,scope:e})}});Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMDeviceResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{doOpen:function(a){this.receivedRecords=this.readRecordsFromResponse(a,"item")},doList:function(a){a.authenticationInfo&&(this.metaData.authenticationInfo=Ext.apply({},a.authenticationInfo));this.receivedRecords=this.readRecordsFromResponse(a,"item")}});Ext.namespace("Zarafa.hierarchy.data");
Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader=Ext.extend(Zarafa.hierarchy.data.HierarchyTreeLoader,{constructor:function(a){Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader.superclass.constructor.call(this,a)},createNode:function(a){var b=a.folder;b&&("rootfolder"===a.nodeType&&(a.extendedDisplayName=this.tree.hasFilter()),a.leaf=!b.get("has_subfolder"),a.uiProvider=Zarafa.plugins.mdm.ui.MDMFolderNodeUI,a.expanded=this.tree.isFolderOpened(b),a.allowDrag=!b.isDefaultFolder());return Zarafa.hierarchy.data.HierarchyTreeLoader.superclass.createNode.apply(this,
arguments)}});Ext.namespace("Zarafa.plugins.mdm.settings");
Zarafa.plugins.mdm.settings.MDMSettingsWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};var b=new Zarafa.plugins.mdm.data.MDMDeviceStore;Ext.applyIf(a,{title:_("Mobile Devices"),items:[{xtype:"panel",layout:"fit",tbar:{layout:"fit",height:"30",items:[{xtype:"button",name:"authErrorBtn",hidden:!0,cls:"mdm-autherror-bar",ref:"../../authErrorBtn",text:String.format(_("Unable to connect to the grommunio-sync server. Click {0} to enter your credentials"),"here".bold()),
listeners:{scope:this,click:this.onAuthErrorClickHandler}}]},items:[{xtype:"grid",name:_("Devices"),ref:"../deviceGrid",height:400,loadMask:!0,store:b,viewConfig:{forceFit:!0,deferEmptyText:!1,emptyText:'<div class="emptytext">'+_("No devices connected to your account")+"</div>"},columns:[{dataIndex:"devicetype",header:_("Device"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"useragent",header:_("User Agent"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"wipestatus",header:_("Provisioning Status"),
renderer:Zarafa.plugins.mdm.ui.Renderers.provisioningStatus},{dataIndex:"lastupdatetime",header:_("Last Update"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"entryid",header:_("Device ID"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"deviceos",header:_("Device OS"),hidden:!0,renderer:Ext.util.Format.htmlEncode},{dataIndex:"devicefriendlyname",header:_("Device Info"),hidden:!0,renderer:Ext.util.Format.htmlEncode},{dataIndex:"firstsynctime",header:_("First Sync time"),hidden:!0,renderer:Ext.util.Format.htmlEncode}],
buttons:[{text:_("Wipe Device"),ref:"../../../wipeBtn",handler:this.onWipeBtn,scope:this},{text:_("Full resync"),ref:"../../../resyncBtn",handler:this.onFullResync,scope:this},{text:_("Remove device"),ref:"../../../removeBtn",handler:this.onRemoveBtn,scope:this},{text:_("Refresh"),ref:"../../../refresh",handler:this.onRefresh,scope:this}],listeners:{rowdblclick:this.onRowDblClick,rowclick:this.onRowClick,render:this.onGridRender,scope:this}}]}]});Zarafa.plugins.mdm.settings.MDMSettingsWidget.superclass.constructor.call(this,
a)},initEvents:function(){this.deviceGrid.mon(this.deviceGrid.getStore(),"beforeloadrecord",this.checkAuthentication,this,{buffer:50});Zarafa.plugins.mdm.settings.MDMSettingsWidget.superclass.initEvents.apply(this,arguments)},onGridRender:function(){this.deviceGrid.getStore().load()},checkAuthentication:function(a){this.authErrorBtn.setVisible(!a);a&&this.deviceGrid.getStore().load()},onAuthErrorClickHandler:function(){this.showPasswordMessageBox(_("Please enter your username and password"),this.onPasswordSubmit,
"authenticate")},showPasswordMessageBox:function(a,b,c){c=this.getCustomItemsAndButtons(c);new Zarafa.common.dialogs.CustomMessageBox({title:_("Mobile Device Manager"),msg:a,buttonAlign:"left",cls:"k-show-more-details",width:320,customItems:[{xtype:"form",border:!1,ref:"../inputForm",style:"margin-top: 15px",items:c.customItems}],customButtons:c.customButtons,fn:b,mdmWidgetScope:this})},getCustomItemsAndButtons:function(a){var b={};a="authenticate"===a;b.customButtons=[{name:a?"ok":"yes",cls:"zarafa-action",
text:a?_("Ok"):_("Yes"),keepOpenWindow:!0},{name:a?"cancel":"no",text:a?_("Close"):_("No")}];let c=[{xtype:"textfield",allowBlank:!1,inputType:"password",boxLabel:"",hideLabel:!0,emptyText:_("Password"),name:"passwordField",ref:"passwordField"}];a&&c.unshift({xtype:"textfield",allowBlank:!1,emptyText:_("Username"),boxLabel:"",hideLabel:!0,name:"userNameField",ref:"userNameField"});b.customItems=c;return b},onPasswordSubmit:function(a){"ok"===a.name&&(a=this.dlgItemContainer.inputForm.getForm(),a.isValid()&&
(a=a.getValues(),container.getRequest().singleRequest("pluginmdmmodule","authenticate",{username:a.userNameField,password:a.passwordField},new Zarafa.plugins.mdm.data.MDMResponseHandler({successCallback:this.mdmWidgetScope.checkAuthentication,mdmWidgetScope:this.mdmWidgetScope})),this.close()))},onWipeBtn:function(){var a=_("Do you really want to wipe your device?\n Enter your password to confirm.");this.showPasswordMessageBox(a,this.onWipeDevice,"wipe")},onWipeDevice:function(a){if("yes"===a.name&&
(a=this.dlgItemContainer.inputForm.getForm(),a.isValid())){a=a.getValues();var b=this.mdmWidgetScope,c=b.deviceGrid.getSelectionModel().getSelected();c&&container.getRequest().singleRequest("pluginmdmmodule","wipe",{deviceid:c.get("entryid"),password:a.passwordField},new Zarafa.plugins.mdm.data.MDMResponseHandler({failureCallback:b.checkAuthentication,mdmWidgetScope:b}));this.close()}},onFullResync:function(){var a=this.deviceGrid.getSelectionModel().getSelected();a&&container.getRequest().singleRequest("pluginmdmmodule",
"resync",{deviceid:a.get("entryid")},new Zarafa.plugins.mdm.data.MDMResponseHandler({failureCallback:this.checkAuthentication,mdmWidgetScope:this}))},onRemoveBtn:function(){var a=_("Do you really want to remove your device?\n Enter your password to confirm.");this.showPasswordMessageBox(a,this.onRemoveDevice,"remove")},onRemoveDevice:function(a){if("yes"===a.name&&(a=this.dlgItemContainer.inputForm.getForm(),a.isValid())){a=a.getValues();var b=this.mdmWidgetScope,c=b.deviceGrid.getSelectionModel().getSelected();
c&&container.getRequest().singleRequest("pluginmdmmodule","remove",{deviceid:c.get("entryid"),password:a.passwordField},new Zarafa.plugins.mdm.data.MDMResponseHandler({successCallback:b.removeDone.createDelegate(this,[c],!0),failureCallback:b.checkAuthentication,mdmWidgetScope:b}));this.close()}},removeDone:function(a){a.getStore().remove(a)},onRefresh:function(){this.deviceGrid.getStore().load()},onRowDblClick:function(a,b){a=a.getStore().getAt(b);a.opened=!1;Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["mdm.dialog.mdmdevicecontentpanel"],
void 0,{manager:Ext.WindowMgr,record:a})},onRowClick:function(a,b){a=a.getStore().getAt(b);this.wipeBtn.setDisabled(!Ext.isDefined(a.get("wipestatus")))}});Ext.reg("Zarafa.plugins.mdm.mdmsettingswidget",Zarafa.plugins.mdm.settings.MDMSettingsWidget);Ext.namespace("Zarafa.plugins.mdm.settings");
Zarafa.plugins.mdm.settings.MDMSettingsCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("Mobile Devices"),iconCls:"icon_mdm_settings",items:[{xtype:"Zarafa.plugins.mdm.mdmsettingswidget"}]});Zarafa.plugins.mdm.settings.MDMSettingsCategory.superclass.constructor.call(this,a)}});Ext.reg("Zarafa.plugins.mdm.mdmsettingscategory",Zarafa.plugins.mdm.settings.MDMSettingsCategory);Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMDeviceContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};var b=a.record&&a.record.get("koeversion")?!0:!1;Ext.applyIf(a,{xtype:"mdmplugin.devicecontentpanel",modal:!0,showModalWithoutParent:!0,title:_(a.record.get("devicetype")),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:!0,useShadowStore:!0}),layout:"fit",stateful:!1,showInfoMask:!1,showLoadMask:!1,width:b?440:405,height:b?450:420,items:[{xtype:"mdmplugin.mdmdevicepanel",
record:a.record,isKoe:b,buttons:[{text:_("Ok"),handler:this.onOk,scope:this}]}]});Zarafa.plugins.mdm.dialogs.MDMDeviceContentPanel.superclass.constructor.call(this,a)},onOk:function(){this.close()}});Ext.reg("mdmplugin.devicecontentpanel",Zarafa.plugins.mdm.dialogs.MDMDeviceContentPanel);Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMDeviceGeneralTab=Ext.extend(Ext.form.FormPanel,{isKoe:!1,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"mdmplugin.mdmdevicegeneraltab",cls:"tab-general",border:!1,labelAlign:"left",defaults:{border:!1,xtype:"panel",layout:"form",labelWidth:150,cls:"mdm-device-panel"},plugins:["zarafa.recordcomponentupdaterplugin"],items:[this.createDeviceInfoPanel(a),this.createFolderInfoPanel()]});Zarafa.plugins.mdm.dialogs.MDMDeviceGeneralTab.superclass.constructor.call(this,
a)},createDeviceInfoPanel:function(a){return{cls:"mdm-device-panel",defaultType:"displayfield",defaults:{disabled:!0},items:[{cls:"mdm-display-name",value:_(a.record.get("devicetype")),htmlEncode:!0,disabled:!1,hideLabel:!0},{fieldLabel:_("Connected since"),value:String.format("{0}",(new Date(a.record.get("firstsynctime"))).format(_("d F Y")))},{fieldLabel:_("Last updated"),value:String.format(_("{0}"),(new Date(a.record.get("lastupdatetime"))).format(_("d F Y, H:i")))},{fieldLabel:_("Status"),hidden:a.isKoe,
listeners:{afterrender:this.onAfterRenderStatus,scope:this}}]}},createFolderInfoPanel:function(){return{cls:"mdm-device-panel mdm-field-sep",defaultType:"displayfield",items:[{cls:"mdm-display-name",value:_("Synchronize"),htmlEncode:!0,hideLabel:!0},{fieldLabel:_("Folders"),disabled:!0,name:"synchronizedfolders"},{xtype:"fieldset",layout:"form",labelWidth:140,cls:"mdm-synchronize-panel",defaultType:"displayfield",defaults:{labelSeparator:"",value:"0",disabled:!0},items:[{fieldLabel:_("Email"),name:"emailsfolder"},
{fieldLabel:_("Calendar"),name:"calendarsfolder"},{fieldLabel:_("Contacts"),name:"contactsfolder"},{fieldLabel:_("Notes"),name:"notesfolder"},{fieldLabel:_("Tasks"),name:"tasksfolder"}]}]}},createSharedFolderInfoPanel:function(){return{xtype:"panel",border:!1,cls:"mdm-synchronize-shared-panel",height:50,disabled:!1,layout:{type:"hbox",align:"stretch",pack:"start"},items:[{layout:"form",border:!1,items:[{xtype:"displayfield",fieldLabel:"Shared Folders",disabled:!0,name:"sharedfolders"}],flex:1},{xtype:"button",
text:_("Manage Shared Folders"),cls:"mdm-managesharedfolder-button",listeners:{click:this.onClickManageSharedFolder,scope:this}}]}},update:function(a,b){this.getForm().loadRecord(a)},onAfterRenderStatus:function(a){var b=parseInt(this.record.get("wipestatus"));a.setValue(Zarafa.plugins.mdm.data.ProvisioningStatus.getDisplayName(b))},onClickManageSharedFolder:function(){this.dialog.record.opened=!1;Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["mdm.dialog.mdmmanagesharedfoldercontentpanel"],
void 0,{manager:Ext.WindowMgr,record:this.dialog.record})}});Ext.reg("mdmplugin.mdmdevicegeneraltab",Zarafa.plugins.mdm.dialogs.MDMDeviceGeneralTab);Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMDevicePanel=Ext.extend(Ext.Panel,{isKoe:!1,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"mdmplugin.mdmdevicepanel",cls:"mdm-devicepanel tabpanel-container",border:!1,deferredRender:!1,items:[{xtype:"tabpanel",border:!1,activeTab:0,layoutOnTabChange:!0,items:[{xtype:"mdmplugin.mdmdevicegeneraltab",record:a.record,title:_("General"),isKoe:a.isKoe},{xtype:"mdmplugin.mdmdevicedetailstab",record:a.record,title:_("Details"),isKoe:a.isKoe}]}]});Zarafa.plugins.mdm.dialogs.MDMDevicePanel.superclass.constructor.call(this,
a)}});Ext.reg("mdmplugin.mdmdevicepanel",Zarafa.plugins.mdm.dialogs.MDMDevicePanel);Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMDeviceDetailsTab=Ext.extend(Ext.form.FormPanel,{isKoe:!1,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"mdmplugin.mdmdevicedetailstab",cls:"tab-device",border:!1,labelAlign:"left",defaults:{border:!1,xtype:"panel",layout:"form",labelWidth:150},plugins:["zarafa.recordcomponentupdaterplugin"],items:[this.createDeviceInfoPanel(a.isKoe),this.createVersionInfoPanel(a.isKoe)]});a.isKoe&&a.items.push(this.createKOEInfoPanel(a.record));Zarafa.plugins.mdm.dialogs.MDMDeviceDetailsTab.superclass.constructor.call(this,
a)},createDeviceInfoPanel:function(a){return{cls:"mdm-device-panel",defaultType:"displayfield",defaults:{disabled:!0},items:[{cls:"mdm-display-name",value:_("Device"),hideLabel:!0,disabled:!1},{fieldLabel:_("Type"),name:"devicetype"},{fieldLabel:_("Operating System"),hidden:a,name:"deviceos"},{fieldLabel:_("ID"),name:"entryid"},{fieldLabel:_("User Agent"),name:"useragent"}]}},createVersionInfoPanel:function(a){return{defaultType:"displayfield",defaults:{disabled:!0},cls:"mdm-device-panel mdm-field-sep",
items:[{cls:"mdm-display-name",value:_("MDM Plugin"),htmlEncode:!0,hideLabel:!0,disabled:!1},{fieldLabel:_("Active Sync Version"),name:"asversion"},{fieldLabel:_("grommunio-sync Version"),value:container.getSettingsModel().get("zarafa/v1/plugins/mdm/zpush-server-version",!0)},{fieldLabel:_("Policy name"),name:"policyname"}]}},createKOEInfoPanel:function(a){return{cls:"mdm-device-panel mdm-field-sep",defaults:{disabled:!0},defaultType:"displayfield",items:[{cls:"mdm-display-name",value:_("Outlook Extension"),
htmlEncode:!0,hideLabel:!0,disabled:!1},{fieldLabel:_("Version"),name:"koeversion"},{fieldLabel:_("Build"),name:"koebuild"},{fieldLabel:_("Last updated"),value:String.format("{0}",(new Date(a.get("koebuilddate"))).format(_("d F Y, H:i")))}]}},update:function(a,b){this.getForm().loadRecord(a)}});Ext.reg("mdmplugin.mdmdevicedetailstab",Zarafa.plugins.mdm.dialogs.MDMDeviceDetailsTab);Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"mdm.managesharedfoldercontentpanel",layout:"fit",title:_("Manage Shared Folders"),modal:!0,stateful:!1,showInfoMask:!1,showLoadMask:!1,closeOnSave:!0,width:300,height:350,items:[{xtype:"mdm.managesharedfolderpanel"}]});Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel.superclass.constructor.call(this,a)}});
Ext.reg("mdm.managesharedfoldercontentpanel",Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel);Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel=Ext.extend(Ext.Panel,{sharedFoldersStore:void 0,record:null,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"mdm.managesharedfolderpanel",layout:{type:"fit",align:"stretch"},border:!1,header:!1,items:[this.createTreePanel()],buttonAlign:"right",plugins:["zarafa.recordcomponentupdaterplugin"],buttons:[{text:_("Apply"),handler:this.onApply,cls:"zarafa-action",scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]});Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel.superclass.constructor.call(this,
a)},createTreePanel:function(){return{xtype:"panel",layout:"form",defaults:{cls:"mdm-create-tree-panel-item"},border:!1,flex:1,items:[{xtype:"displayfield",hideLabel:!0,value:_("Select folders to sync to your device from the list below. To add additional mailboxes to the list, open them in grommunio Web first.")},{xtype:"mdm.hierarchytree",autoScroll:!0,hideOwnTree:!0,nodeConfig:{checked:!1},multiSelect:!0,hideShowAllFolders:!0,border:!0,treeSorter:!0,bbarConfig:{hidden:!0},enableDD:!1,anchor:"100% 90%",
ref:"../hierarchyTree"}]}},initEvents:function(){Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel.superclass.initEvents.apply(this,arguments);this.mon(this.hierarchyTree,{expandnode:this.onTreeNodeExpand,checkchange:this.onTreeNodeCheckChange,click:this.onTreeNodeClick,scope:this})},onTreeNodeExpand:function(){if(!this.record.isOpened())return!1;this.updateHierarchy()},update:function(a,b){this.record=a;this.sharedFoldersStore=a.getSubStore("sharedfolders");this.updateHierarchy()},updateHierarchy:function(){this.sharedFoldersStore.getRange().forEach(function(a){a=
this.hierarchyTree.getNodeById(a.get("entryid"));Ext.isDefined(a)&&(a.hasChildNodes()&&a.expand(),a.isNodeSelected=!0,a.getUI().toggleCheck(!0))},this)},onTreeNodeClick:function(a){var b=a.getUI();if(b.checkbox.checked&&a.isNodeSelected)return b.toggleCheck(!1),!1;a.isNodeSelected=!0;this.sharedFoldersStore.addFolder(a.getFolder());b.toggleCheck(!0)},onTreeNodeCheckChange:function(a,b){if(!b)a.isNodeSelected=!1,this.sharedFoldersStore.removeFolder(a.getFolder());else if(b&&!a.isNodeSelected)this.onTreeNodeClick(a)},
onApply:function(){this.record.dirty?this.record.save():this.dialog.close()},onCancel:function(){this.dialog.close()}});Ext.reg("mdm.managesharedfolderpanel",Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel);Ext.namespace("Zarafa.plugins.mdm.ui");Zarafa.plugins.mdm.ui.Renderers={provisioningStatus:function(a,b,c){return Zarafa.plugins.mdm.data.ProvisioningStatus.getDisplayName(parseInt(a))}};Ext.namespace("Zarafa.plugins.mdm.ui");
Zarafa.plugins.mdm.ui.MDMFolderNodeUI=Ext.extend(Zarafa.hierarchy.ui.FolderNodeUI,{renderElements:function(a,b,c,d){this.indentMarkup=a.parentNode?a.parentNode.ui.getChildIndent():"";var f=Ext.isBoolean(b.checked)&&!(a instanceof Zarafa.hierarchy.ui.RootFolderNode),k=b.folder.isCalendarFolder(),g="";if(k){var e=a.getOwnerTree().model;e||(e=container.getContextByName("calendar").getModel(),a.getOwnerTree().model=e);(e=e.getColorScheme(b.folder.get("entryid")))&&e.base&&(g='<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="15" height="13" viewBox="0 0 15 13" style="color:'+
e.base+'; position:relative; top:2px;"><g><g class="icbg" style="fill:currentColor;stroke:none"><rect width="15" height="12" x="0" y="1" /><rect width="1" height="1" x="2" y="0" /><rect width="1" height="1" x="7" y="0" /><rect width="1" height="1" x="12" y="0" /></g><path class="icgr" d="M 2.5,6.5 h 10 v 4 h -10 v -4.5 M 4.5,6.5 v 4 M 6.5,6.5 v 4 M 8.5,6.5 v 4 M 10.5,6.5 v 4 M 2.5,8.5 h 9.5" style="fill:currentColor;stroke:#ffffff;stroke-width:1;stroke-linejoin=miter" /></g></svg>')}e='<img src="'+
(b.icon||this.emptyIcon)+'" class="x-tree-node-icon" unselectable="on" />';var h;g='<li class="x-tree-node"><div ext:tree-node-id="'+a.id+'" class="x-tree-node-el x-tree-node-leaf x-unselectable zarafa-hierarchy-node" unselectable="on"><span class="x-tree-node-indent">'+this.indentMarkup+'</span><img src="'+this.emptyIcon+'" class="x-tree-ec-icon x-tree-elbow" />'+(f?'<input class="x-tree-node-cb zarafa-hierarchy-node-cb" type="checkbox" '+(b.checked?'checked="checked" />':"/>"):"")+(k?g:e)+'<a hidefocus="on" class="x-tree-node-anchor zarafa-hierarchy-node-anchor" href="'+
(b.href?b.href:Ext.isGecko?"":"#")+'" tabIndex="1" '+(b.hrefTarget?' target="'+b.hrefTarget+'"':"")+'><span unselectable="on">'+(a.tpl?a.tpl.apply(b):a.text)+'</span><span class="zarafa-hierarchy-node-counter" unselectable="on"></span><span class="zarafa-hierarchy-node-owner" unselectable="on"></span></a></div><ul class="x-tree-node-ct" style="display:none;"></ul></li>';!0!==d&&a.nextSibling&&(h=a.nextSibling.ui.getEl())?this.wrap=Ext.DomHelper.insertHtml("beforeBegin",h,g):this.wrap=Ext.DomHelper.insertHtml("beforeEnd",
c,g);this.elNode=this.wrap.childNodes[0];this.ctNode=this.wrap.childNodes[1];c=this.elNode.childNodes;this.indentNode=c[0];this.ecNode=c[1];this.iconNode=c[2];d=3;f&&(this.checkbox=c[2],this.iconNode=c[3],f=this.iconNode.childNodes[0],Ext.isDefined(f)&&(this.calendarSVGIconChilds=[f.childNodes[0].childNodes[0],f.childNodes[1]]),d++);this.anchor=c[d];this.textNode=c[d].firstChild;this.counterNode=c[d].firstChild.nextSibling;this.folderOwnerNode=this.counterNode.nextSibling;f=Ext.get(this.elNode);c=
Ext.get(this.iconNode);d=Ext.get(this.wrap);h=Ext.get(this.textNode);k&&h.addClass("zarafa-hierarchy-node-color");Ext.isEmpty(b.cls)||f.addClass(b.cls);b.icon&&c.addClass("x-tree-node-inline-icon");b.iconCls&&c.addClass(b.iconCls);Ext.isEmpty(b.containerCls)||d.addClass(b.containerCls);this.updateCounter(a);this.showFolderOwner(a)}});Ext.namespace("Zarafa.plugins.mdm.ui");
Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel=Ext.extend(Zarafa.hierarchy.ui.Tree,{constructor:function(a){Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel.superclass.constructor.call(this,a)},initComponent:function(){this.loader||(this.loader=new Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader({tree:this,store:this.store,nodeConfig:this.nodeConfig,deferredLoading:this.deferredLoading}));Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel.superclass.initComponent.apply(this,arguments)},nodeFilter:function(a){var b=
Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel.superclass.nodeFilter.apply(this,arguments);b&&this.hideOwnTree&&(b=!a.getMAPIStore().isDefaultStore());return b}});Ext.reg("mdm.hierarchytree",Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel);//# sourceMappingURL=mdm.js.map
