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 || {};
|
|
|
|
|
|
|
|
var store = new Zarafa.plugins.mdm.data.MDMDeviceStore();
|
|
|
|
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',
|
|
|
|
layout : 'column',
|
|
|
|
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
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
Zarafa.plugins.mdm.settings.MDMSettingsWidget.superclass.constructor.call(this, config);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function which handles the click event on the "Wipe Device" button, displays
|
|
|
|
* a MessageBox for the user to confirm the wipe action. The wipe action is
|
|
|
|
* 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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Ext.reg('Zarafa.plugins.mdm.mdmsettingswidget', Zarafa.plugins.mdm.settings.MDMSettingsWidget);
|