2016-05-11 10:40:44 +02:00
|
|
|
Ext.namespace('Zarafa.plugins.mdm.settings');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class Zarafa.plugins.mdm.settings.MDMSettingsWidget
|
|
|
|
* @extends Zarafa.settings.ui.SettingsWidget
|
|
|
|
*/
|
|
|
|
Zarafa.plugins.mdm.settings.MDMSettingsWidget = Ext.extend(Zarafa.settings.ui.SettingsWidget, {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} config Configuration object
|
|
|
|
*/
|
|
|
|
constructor : function(config)
|
|
|
|
{
|
|
|
|
config = config || {};
|
|
|
|
|
2016-12-08 15:04:21 +01:00
|
|
|
var store = new Zarafa.plugins.mdm.data.MDMDeviceStore();
|
2016-05-11 10:40:44 +02:00
|
|
|
Ext.applyIf(config, {
|
2016-06-09 11:13:23 +02:00
|
|
|
title : _('Mobile Devices', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
items : [{
|
|
|
|
xtype : 'container',
|
2016-12-08 15:04:21 +01:00
|
|
|
layout: 'fit',
|
2016-05-11 10:40:44 +02:00
|
|
|
items : [{
|
|
|
|
xtype : 'grid',
|
2016-06-09 11:13:23 +02:00
|
|
|
name : _('Devices', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
ref : '../deviceGrid',
|
|
|
|
height : 400,
|
|
|
|
store : store,
|
|
|
|
viewConfig : {
|
|
|
|
forceFit : true,
|
|
|
|
deferEmptyText: false,
|
2016-06-09 11:13:23 +02:00
|
|
|
emptyText: '<div class="emptytext">' + _('No devices connected to your account', 'plugin_mdm') + '</div>'
|
2016-05-11 10:40:44 +02:00
|
|
|
},
|
|
|
|
columns : [{
|
|
|
|
dataIndex : 'devicetype',
|
2016-06-09 11:13:23 +02:00
|
|
|
header : _('Device', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
renderer : Ext.util.Format.htmlEncode
|
|
|
|
},{
|
|
|
|
dataIndex : 'useragent',
|
2016-06-09 11:13:23 +02:00
|
|
|
header : _('User Agent', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
renderer : Ext.util.Format.htmlEncode
|
|
|
|
},{
|
|
|
|
dataIndex : 'wipestatus',
|
2016-06-09 11:13:23 +02:00
|
|
|
header : _('Provisioning Status', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
renderer : Zarafa.plugins.mdm.ui.Renderers.provisioningStatus
|
|
|
|
},{
|
|
|
|
dataIndex : 'lastupdatetime',
|
2016-06-09 11:13:23 +02:00
|
|
|
header : _('Last Update', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
renderer : Ext.util.Format.htmlEncode
|
|
|
|
},{
|
|
|
|
dataIndex : 'entryid',
|
2016-06-09 11:13:23 +02:00
|
|
|
header : _('Device ID', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
renderer : Ext.util.Format.htmlEncode
|
|
|
|
},{
|
|
|
|
dataIndex : 'deviceos',
|
2016-06-09 11:13:23 +02:00
|
|
|
header : _('Device OS', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
hidden : true,
|
|
|
|
renderer : Ext.util.Format.htmlEncode
|
|
|
|
},{
|
|
|
|
dataIndex : 'devicefriendlyname',
|
2016-06-09 11:13:23 +02:00
|
|
|
header : _('Device Info', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
hidden : true,
|
|
|
|
renderer : Ext.util.Format.htmlEncode
|
|
|
|
},{
|
|
|
|
dataIndex : 'firstsynctime',
|
2016-06-09 11:13:23 +02:00
|
|
|
header : _('First Sync time', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
hidden : true,
|
|
|
|
renderer : Ext.util.Format.htmlEncode
|
|
|
|
}],
|
|
|
|
buttons : [{
|
2016-06-09 11:13:23 +02:00
|
|
|
text : _('Wipe Device', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
ref : '../../../wipeBtn',
|
|
|
|
handler : this.onWipeBtn,
|
|
|
|
scope : this
|
|
|
|
},{
|
2016-06-09 11:13:23 +02:00
|
|
|
text : _('Full resync', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
ref : '../../../resyncBtn',
|
|
|
|
handler : this.onFullResync,
|
|
|
|
scope : this
|
|
|
|
},{
|
2016-06-09 11:13:23 +02:00
|
|
|
text : _('Remove device', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
ref : '../../../removeBtn',
|
|
|
|
handler : this.onRemoveDevice,
|
|
|
|
scope : this
|
|
|
|
},{
|
2016-06-09 11:13:23 +02:00
|
|
|
text : _('Refresh', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
ref : '../../../refresh',
|
|
|
|
handler : this.onRefresh,
|
|
|
|
scope : this
|
2016-12-06 06:52:40 +01:00
|
|
|
}],
|
|
|
|
listeners : {
|
|
|
|
rowdblclick: this.onRowDblClick,
|
2017-05-05 12:14:24 +02:00
|
|
|
rowclick: this.onRowClick,
|
|
|
|
scope: this
|
2016-12-06 06:52:40 +01:00
|
|
|
}
|
2016-05-11 10:40:44 +02:00
|
|
|
}]
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
Zarafa.plugins.mdm.settings.MDMSettingsWidget.superclass.constructor.call(this, config);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function which handles the click event on the "Wipe Device" button, displays
|
2016-12-08 15:04:21 +01:00
|
|
|
* a MessageBox for the user to confirm the wipe action. The wipe action is
|
2016-05-11 10:40:44 +02:00
|
|
|
* handled by the onWipeDevice function.
|
|
|
|
*/
|
|
|
|
onWipeBtn : function()
|
|
|
|
{
|
|
|
|
var msgbox = Ext.MessageBox.show({
|
2016-06-09 11:13:23 +02:00
|
|
|
title: _('Kopano WebApp', 'plugin_mdm'),
|
|
|
|
msg: _('Do you really want to wipe your device?\n Enter your password to confirm.', 'plugin_mdm'),
|
2016-05-11 10:40:44 +02:00
|
|
|
inputType :'password',
|
|
|
|
icon: Ext.MessageBox.WARNING,
|
|
|
|
buttons: Ext.MessageBox.YESNO,
|
|
|
|
fn: this.onWipeDevice,
|
|
|
|
prompt: true,
|
|
|
|
scope: this.deviceGrid
|
|
|
|
});
|
|
|
|
|
|
|
|
// ExtJS does not support a password field.
|
|
|
|
msgbox.getDialog().body.child('input').dom.type = 'password';
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function which handles the confirmation button in the "wipe device" messagebox.
|
|
|
|
* Sends an wipe request to PHP for the selected device in the grid.
|
|
|
|
*
|
|
|
|
* @param {Ext.Button} button button from the messagebox
|
|
|
|
* @param {String} password user password
|
|
|
|
*/
|
|
|
|
onWipeDevice : function(button, password)
|
|
|
|
{
|
|
|
|
if (button === 'yes') {
|
|
|
|
var selectionModel = this.getSelectionModel();
|
|
|
|
var record = selectionModel.getSelected();
|
|
|
|
if (record) {
|
|
|
|
container.getRequest().singleRequest(
|
|
|
|
'pluginmdmmodule',
|
|
|
|
'wipe',
|
|
|
|
{ 'deviceid' : record.get('entryid'), 'password': password },
|
|
|
|
new Zarafa.plugins.mdm.data.MDMResponseHandler()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function which handles the click event on the "Full resync" button, sends a
|
|
|
|
* full resync request to PHP.
|
|
|
|
*/
|
|
|
|
onFullResync : function()
|
|
|
|
{
|
|
|
|
var selectionModel = this.deviceGrid.getSelectionModel();
|
|
|
|
var record = selectionModel.getSelected();
|
|
|
|
if(record) {
|
|
|
|
container.getRequest().singleRequest(
|
|
|
|
'pluginmdmmodule',
|
|
|
|
'resync',
|
|
|
|
{ 'deviceid' : record.get('entryid') },
|
|
|
|
new Zarafa.plugins.mdm.data.MDMResponseHandler()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all state data for a device, essentially resyncing it.
|
|
|
|
*/
|
|
|
|
onRemoveDevice : function()
|
|
|
|
{
|
|
|
|
var selectionModel = this.deviceGrid.getSelectionModel();
|
|
|
|
var record = selectionModel.getSelected();
|
|
|
|
if(record) {
|
|
|
|
container.getRequest().singleRequest(
|
|
|
|
'pluginmdmmodule',
|
|
|
|
'remove',
|
|
|
|
{ 'deviceid' : record.get('entryid') },
|
|
|
|
new Zarafa.plugins.mdm.data.MDMResponseHandler({
|
|
|
|
successCallback : this.removeDone.createDelegate(this, [record], true)
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback function triggers when device was successfully removed from the z-push server.
|
|
|
|
* we have to remove that device from {@link Zarafa.plugins.mdm.data.MDMDeviceStore store}.
|
|
|
|
* @param {Zarafa.plugins.mdm.data.MDMDeviceRecord} record {@link Zarafa.core.data.IPMRecord record} object
|
|
|
|
*/
|
|
|
|
removeDone : function(record)
|
|
|
|
{
|
|
|
|
record.getStore().remove(record);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function which refreshes the store records from the server.
|
|
|
|
*/
|
|
|
|
onRefresh : function()
|
|
|
|
{
|
|
|
|
this.deviceGrid.getStore().load();
|
2016-12-06 06:52:40 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function is called if a row in the grid gets double clicked.
|
|
|
|
* Which is use to show a dialog with detail device information
|
|
|
|
* @param {Ext.grid.GridPanel} grid The Grid on which the user double-clicked
|
|
|
|
* @param {Number} rowIndex The Row number on which was double-clicked.
|
|
|
|
*/
|
|
|
|
onRowDblClick : function (grid, rowIndex)
|
|
|
|
{
|
|
|
|
var record = grid.getStore().getAt(rowIndex);
|
2017-02-21 08:12:13 +01:00
|
|
|
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['mdm.dialog.mdmdevicecontentpanel'], undefined, {
|
2016-12-06 06:52:40 +01:00
|
|
|
manager : Ext.WindowMgr,
|
|
|
|
record : record
|
|
|
|
});
|
2017-05-05 12:14:24 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function is called if a row in the grid gets clicked.
|
|
|
|
* Which is use to disabled wipe button if wipe status is not available.
|
|
|
|
* @param {Ext.grid.GridPanel} grid The Grid on which the user clicked
|
|
|
|
* @param {Number} rowIndex The Row number on which was clicked.
|
|
|
|
*/
|
|
|
|
onRowClick : function (grid, rowIndex)
|
|
|
|
{
|
|
|
|
var record = grid.getStore().getAt(rowIndex);
|
|
|
|
this.wipeBtn.setDisabled(!Ext.isDefined(record.get('wipestatus')));
|
2016-05-11 10:40:44 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Ext.reg('Zarafa.plugins.mdm.mdmsettingswidget', Zarafa.plugins.mdm.settings.MDMSettingsWidget);
|