Общие изменения

1 parent 9514aee0
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
......@@ -860,60 +860,32 @@ Ext.define('MyMA.view.Transports', {
store: 'Transports'
}]
});
Ext.define('MyMA.model.Users', {
Ext.define('MyMA.model.Aliases', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'name',
type: 'string'
}, {
name: 'login',
type: 'string'
}, {
name: 'passwd',
type: 'string'
}, {
name: 'uid',
type: 'int',
defaultValue: 8
}, {
name: 'gid',
type: 'int',
defaultValue: 12
}, {
name: 'maildir',
type: 'string'
}, {
name: 'smtp',
type: 'int'
}, {
name: 'imap',
name: 'id',
type: 'int'
}, {
name: 'quota',
type: 'int',
defaultValue: 10000000
}, {
name: 'manager',
type: 'int'
}],
validations: [{
type: 'format',
field: 'maildir',
matcher: /^\/[a-z]\.ru\/[a-z_0-9]\/Maildir\/$/
}],
}, {
name: 'alias',
type: 'string'
}, {
name: 'recipient',
type: 'string'
}, {
name: 'comment',
type: 'string'
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api/user'),
url: Ext.Ajax.getRestUrl('api', 'alias'),
reader: {
type: 'json',
root: 'results'
root: 'results',
totalProperty: 'total'
},
writer: {
type: 'json',
allowSingle: true
type: 'json',
allowSingle: true
}
}
});
......@@ -928,54 +900,82 @@ Ext.define('MyMA.model.Brief', {
}
}
});
Ext.define('MyMA.model.Aliases', {
Ext.define('MyMA.model.Transports', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'alias',
type: 'string'
}, {
name: 'recipient',
name: 'domain',
type: 'string'
}, {
name: 'comment',
name: 'transport',
type: 'string'
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api', 'alias'),
url: Ext.Ajax.getRestUrl('api', 'transport'),
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
},
writer: {
type: 'json',
allowSingle: true
type: 'json',
allowSingle: true
}
}
});
Ext.define('MyMA.model.Transports', {
Ext.define('MyMA.model.Users', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
name: 'id',
type: 'int'
}, {
name: 'name',
type: 'string'
}, {
name: 'login',
type: 'string'
}, {
name: 'passwd',
type: 'string'
}, {
name: 'uid',
type: 'int',
defaultValue: 8
}, {
name: 'gid',
type: 'int',
defaultValue: 12
}, {
name: 'maildir',
type: 'string'
}, {
name: 'smtp',
type: 'int'
}, {
name: 'imap',
type: 'int'
}, {
name: 'domain',
type: 'string'
}, {
name: 'transport',
type: 'string'
}],
}, {
name: 'quota',
type: 'int',
defaultValue: 10000000
}, {
name: 'manager',
type: 'int'
}],
validations: [{
type: 'format',
field: 'maildir',
matcher: /^\/[a-z]\.ru\/[a-z_0-9]\/Maildir\/$/
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api', 'transport'),
url: Ext.Ajax.getRestUrl('api/user'),
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
root: 'results'
},
writer: {
type: 'json',
......@@ -1891,114 +1891,1044 @@ Ext.define('MyMA.store.Choice', {
name: 'Yes'
}]
});
Ext.define('MyMA.controller.Users', {
extend: 'Ext.app.Controller',
stores: ['Users', 'Choice'],
views: ['Users', 'User'],
refs: [{
selector: 'users > grid',
ref: 'usersList'
}, {
selector: 'users',
ref: 'usersWindow'
}],
init: function() {
this.control({
'users > grid > toolbar > #addrecord': {
click: this.showForm
},
'users > grid > toolbar > #search': {
click: this.onSearch
},
'users actioncolumn': {
click: this.onActionColumn
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-edit')) {
var record = scope.store.getAt(rowIndex);
var widget = this.getController('Taskpanel').addProgram({
name: 'user'
});
widget.setTitle('User: ' + record.get('name'));
widget.down('form').getForm().loadRecord(record);
}
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to conform remove action', function(button) {
if (button === 'yes') {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}, {
store: scope.store,
record: record
});
}
},
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* Show form to add new record or edit existing data
* @param {Object} Button
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
showForm: function(Button) {
this.getController('Taskpanel').addProgram({
name: 'user',
title: 'New User'
});
},
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Search action
*/
onSearch: function(Button) {
this.getUsersList().getStore().reload({ params: Button.up('toolbar').getValues() });
}
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.controller.ProgramMenu', {
extend: 'Ext.app.Controller',
init: function() {
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort: false,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
/**
* Conroller: Alias
*
*/
Ext.define('MyMA.controller.Alias', {
extend: 'Ext.app.Controller',
views: ['Alias'],
refs: [{
selector: 'alias',
ref: 'aliasWindow'
}],
init: function() {
this.control({
'programmenu > menu': {
click: this.LaunchProgram
}
});
'alias > toolbar > #savedata': {
click: this.saveData
}
});
},
LaunchProgram: function(menu, item) {
if (item.itemId == 'logout') {
this.getController('Viewport').Logout();
}
else {
this.getController('Taskpanel').addProgram({
name: item.widgetName,
title: item.text
});
}
}
saveData: function(Button) {
var form = this.getAliasWindow().down('form').getForm(),
id = form.getValues().id || null;
if(!form.isValid()) {
return false;
}
form.submit({
url: Ext.Ajax.getRestUrl('api','alias', id),
clientValidation: true,
method: id > 0 ? 'PUT' : 'POST',
scope: {
controller: this,
win: this.getAliasWindow()
},
success: this.onSuccessSubmit,
failure: this.onFailSubmit
});
},
/**
*
*/
onSuccessSubmit: function(form, action) {
this.win.close();
this.controller.getController('Aliases').getStore('Aliases').reload({
params: {
start: 0
}
});
Ext.Msg.showInfo({
msg: 'Data saved'
})
},
/**
*
*/
onFailSubmit: function(form, action) {
try {
var data = Ext.decode(action.response.responseText);
throw(data);
}
catch(e) {
Ext.Msg.showError({
msg: e
});
}
}
});
Ext.define('MyMA.controller.Aliases', {
extend: 'Ext.app.Controller',
stores: ['Aliases'],
views: ['Aliases','Alias'],
refs: [{
selector: 'aliases > grid',
ref: 'aliasesList'
}],
init: function() {
this.control({
'aliases > grid > toolbar > #addrecord': {
click: this.showForm
},
'aliases > grid > toolbar > #search': {
click: this.onSearch
},
'aliases actioncolumn': {
click: this.onActionColumn
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-edit')) {
var record = scope.store.getAt(rowIndex);
var widget = this.getController('Taskpanel').addProgram({
name: 'alias'
});
widget.setTitle('Alias: ' + record.get('alias'));
widget.down('form').getForm().loadRecord(record);
}
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to confirm remove action', function(button) {
if (button === 'yes') {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Show form to add new record or edit existing data
* @param {Object} Button
*/
showForm: function(Button) {
this.getController('Taskpanel').addProgram({
name: 'alias',
title: 'New Alias'
});
},
/**
* Search action
*/
onSearch: function(Button) {
this.getAliasesList().getStore().reload({ params: Button.up('toolbar').getValues() });
}
});
Ext.define('MyMA.controller.Program', {
extend: 'Ext.app.Controller',
......@@ -2115,217 +3045,250 @@ Ext.define('MyMA.controller.Program', {
}
} // end programStop()
});
/**
* Controller: Viewport
*
*/
Ext.define('MyMA.controller.Viewport', {
Ext.define('MyMA.controller.ProgramMenu', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'programmenu > menu': {
click: this.LaunchProgram
}
});
},
LaunchProgram: function(menu, item) {
if (item.itemId == 'logout') {
this.getController('Viewport').Logout();
}
else {
this.getController('Taskpanel').addProgram({
name: item.widgetName,
title: item.text
});
}
}
});
Ext.define('MyMA.controller.Taskpanel', {
extend: 'Ext.app.Controller',
views: ['Viewport', 'Authorize'],
stores: ['Programs'],
refs: [{
selector: 'viewport',
ref: 'appView'
}, {
selector: 'authorize',
ref: 'authPanel'
}, {
selector: 'authorize > form',
ref: 'authForm'
selector: 'taskpanel',
ref: 'taskPanel'
}],
/**
*
*/
isGuest: Ext.undefined,
/**
* A template method that is called when your application boots.
* It is called before the Application's launch function is executed so gives a hook
* point to run any code before your Viewport is created.
*/
init: function(app) {
// Bind Guest to the Ext.data.Connection
Ext.override(Ext.data.Connection, {
/**
* Set guest state to the authorization controller
*/
setGuest: Ext.Function.bind(this.setGuest, this),
/**
* Return isGuest current value
* @return {Boolean}
*/
getGuest: Ext.Function.bind(this.getGuest, this)
});
this.control({
'authorize > form > toolbar > button': {
click: this.Authorize
init: function() {
this.control({
'taskpanel > button': {
toggle: this.programState
}
});
this.Authorize();
},
/**
* Authorize
* if passed main application view, the first step need to query
* @param object, main application view
* Add program to the task panel
* @param data
*/
Authorize: function() {
if (this.getAuthPanel()) {
var form = this.getAuthPanel().down('form').getForm();
if(form.isValid()) {
form.submit({
url: Ext.Ajax.getRestUrl('api','login', 'authorize', 0),
method: 'PUT',
clientValidation: true,
scope: this,
success: this.successLogin
})
addProgram: function(data) {
var data = data || {
name: null
},
store = this.getStore('Programs'),
record, widget;
if(!(record = store.getProccess({
property: 'name',
value: data.name
})))
{
try {
var widget = Ext.widget(data.name),
progId = (store.max('id') || 0) + 1;
}
catch(e) {
return false;
}
var Button = this.getTaskPanel().add({
xtype: 'button',
ui: 'program-button',
height: 28,
text: data.title || widget.title,
enableToggle: true,
pressed: true,
programId: progId
});
record = store.add({
id: progId,
title: data.title || widget.title,
name: data.name,
state: 'show',
item: widget.getId(),
control: Button.getId()
})[0];
this.getController('Program').registerControl(data.name);
widget.animateTarget = Button.getId();
widget.setTitle(data.title);
widget.show();
}
else {
Ext.Ajax.request({
url: Ext.Ajax.getRestUrl('api', 'login'),
scope: this,
callback: function(){
if (!this.isGuest && !this.getAppView()) {
this.setGuest(false);
this.getView('Viewport').create();
}
}
});
this.getTaskPanel().items.get(record.get('control')).toggle(true);
if((widget = Ext.getCmp(record.get('item')))) {
widget.show();
}
}
return widget ? widget : null;
},
/**
* Return isGuest value
* @param state
*/
getGuest: function() {
return this.isGuest;
},
/**
* Set isGuest flag value
* @param object, this controller
* @param boolean, state to set
* Get reference function
* @param {Object} Button
*/
setGuest: function(state) {
this.isGuest = Ext.isBoolean(state) ? state : true;
if(this.isGuest && !this.getAuthPanel()) {
this.getView('Authorize').create();
callRef: function(selector) {
var me = this;
try {
for (var i = 0, ln = this.refs.length; i < ln; i++) {
if (this.refs[i]['selector'] == selector) {
return me['get' + Ext.String.capitalize(this.refs[i]['ref'])]();
}
}
}
catch(e) { }
return null;
},
/**
* private
*/
successLogin: function(form, action) {
this.getAuthPanel().close();
programState: function(Button) {
var store = this.getStore('Programs'),
record, widget;
if(!this.getAppView()) {
this.getView('Viewport').create();
if(!(record = store.getProccess({
property: 'id',
value: Button.programId
})))
{
return false;
}
},
if ((widget = Ext.getCmp(record.get('item')))) {
widget[record.get('state') == 'show' ? 'hide' : 'show']();
}
},
/**
* Logout
* public
* Close all process those are registed in the Programs storage
*/
Logout: function() {
Ext.Ajax.request({
url: Ext.Ajax.getRestUrl('api','login', 'logout', 0),
method: 'PUT',
scope: this,
callback: function() {
if(this.getAppView()) {
this.getController('Taskpanel').closeAll();
this.getAppView().destroy();
}
this.setGuest(this, true);
}
});
closeAll: function() {
this.getStore('Programs').each(function(record){
if ((widget = Ext.getCmp(record.get('item')))) {
widget.hide();
this.getTaskPanel().items.get(record.get('control')).destroy();
}
}, this);
}
});
/**
* Conroller: Alias
*
*/
Ext.define('MyMA.controller.Alias', {
Ext.define('MyMA.controller.Transports', {
extend: 'Ext.app.Controller',
views: ['Alias'],
stores: ['Transports'],
views: ['Transports'],
refs: [{
selector: 'alias',
ref: 'aliasWindow'
selector: 'transports > grid',
ref: 'transportsList'
}],
init: function() {
this.control({
'alias > toolbar > #savedata': {
click: this.saveData
}
});
},
saveData: function(Button) {
var form = this.getAliasWindow().down('form').getForm(),
id = form.getValues().id || null;
if(!form.isValid()) {
return false;
}
form.submit({
url: Ext.Ajax.getRestUrl('api','alias', id),
clientValidation: true,
method: id > 0 ? 'PUT' : 'POST',
scope: {
controller: this,
win: this.getAliasWindow()
'transports > grid > toolbar > #addrecord': {
click: this.addRecord
},
'transports > grid > toolbar > #search': {
click: this.onSearch
},
success: this.onSuccessSubmit,
failure: this.onFailSubmit
});
},
/**
*
*/
onSuccessSubmit: function(form, action) {
this.win.close();
this.controller.getController('Aliases').getStore('Aliases').reload({
params: {
start: 0
'transports actioncolumn': {
click: this.onActionColumn
},
'transports > grid': {
edit: this.onEditAction
}
});
Ext.Msg.showInfo({
msg: 'Data saved'
})
},
/**
*
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onFailSubmit: function(form, action) {
try {
var data = Ext.decode(action.response.responseText);
throw(data);
}
catch(e) {
Ext.Msg.showError({
msg: e
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to confirm remove action', function(button) {
if (button === 'yes') {
if(!this.record.get('id')) {
this.store.remove(this.record);
}
else {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Add record to the store and start editing
*/
addRecord: function(Button) {
this.getTransportsList().getStore().insert(0, this.getTransportsList().getStore().model.create({
id: 0,
domain: null,
transport: 'virtual'
}));
},
/**
* Search action
*/
onSearch: function(Button) {
this.getTransportsList().getStore().reload({ params: Button.up('toolbar').getValues() });
},
/**
* Fires when edit complete and record was updated
* @param {object}, Ext.grid.plugin.Editing
* @param {object}, An edit event
*/
onEditAction: function(editor, e) {
e.record.save({
scope: e,
success: function(record) {
this.store.reload();
}
});
}
});
Ext.define('MyMA.controller.User', {
......@@ -2402,30 +3365,33 @@ Ext.define('MyMA.controller.User', {
}
}
});
Ext.define('MyMA.controller.Aliases', {
Ext.define('MyMA.controller.Users', {
extend: 'Ext.app.Controller',
stores: ['Aliases'],
views: ['Aliases','Alias'],
refs: [{
selector: 'aliases > grid',
ref: 'aliasesList'
}],
stores: ['Users', 'Choice'],
views: ['Users', 'User'],
refs: [{
selector: 'users > grid',
ref: 'usersList'
}, {
selector: 'users',
ref: 'usersWindow'
}],
init: function() {
this.control({
'aliases > grid > toolbar > #addrecord': {
click: this.showForm
this.control({
'users > grid > toolbar > #addrecord': {
click: this.showForm
},
'aliases > grid > toolbar > #search': {
'users > grid > toolbar > #search': {
click: this.onSearch
},
'aliases actioncolumn': {
'users actioncolumn': {
click: this.onActionColumn
}
});
});
},
/**
* Handles action columns click
* @param {Object} grid view
......@@ -2441,273 +3407,189 @@ Ext.define('MyMA.controller.Aliases', {
var record = scope.store.getAt(rowIndex);
var widget = this.getController('Taskpanel').addProgram({
name: 'alias'
name: 'user'
});
widget.setTitle('Alias: ' + record.get('alias'));
widget.setTitle('User: ' + record.get('name'));
widget.down('form').getForm().loadRecord(record);
}
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to confirm remove action', function(button) {
if (button === 'yes') {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Show form to add new record or edit existing data
* @param {Object} Button
*/
showForm: function(Button) {
this.getController('Taskpanel').addProgram({
name: 'alias',
title: 'New Alias'
});
},
/**
* Search action
*/
onSearch: function(Button) {
this.getAliasesList().getStore().reload({ params: Button.up('toolbar').getValues() });
}
});
Ext.define('MyMA.controller.Transports', {
extend: 'Ext.app.Controller',
stores: ['Transports'],
views: ['Transports'],
refs: [{
selector: 'transports > grid',
ref: 'transportsList'
}],
init: function() {
this.control({
'transports > grid > toolbar > #addrecord': {
click: this.addRecord
},
'transports > grid > toolbar > #search': {
click: this.onSearch
},
'transports actioncolumn': {
click: this.onActionColumn
},
'transports > grid': {
edit: this.onEditAction
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to confirm remove action', function(button) {
if (button === 'yes') {
if(!this.record.get('id')) {
this.store.remove(this.record);
}
else {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Add record to the store and start editing
*/
addRecord: function(Button) {
this.getTransportsList().getStore().insert(0, this.getTransportsList().getStore().model.create({
id: 0,
domain: null,
transport: 'virtual'
}));
},
/**
* Search action
*/
onSearch: function(Button) {
this.getTransportsList().getStore().reload({ params: Button.up('toolbar').getValues() });
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to conform remove action', function(button) {
if (button === 'yes') {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Fires when edit complete and record was updated
* @param {object}, Ext.grid.plugin.Editing
* @param {object}, An edit event
*/
onEditAction: function(editor, e) {
e.record.save({
scope: e,
success: function(record) {
this.store.reload();
}
/**
* Show form to add new record or edit existing data
* @param {Object} Button
*/
showForm: function(Button) {
this.getController('Taskpanel').addProgram({
name: 'user',
title: 'New User'
});
}
},
/**
* Search action
*/
onSearch: function(Button) {
this.getUsersList().getStore().reload({ params: Button.up('toolbar').getValues() });
}
});
Ext.define('MyMA.controller.Taskpanel', {
/**
* Controller: Viewport
*
*/
Ext.define('MyMA.controller.Viewport', {
extend: 'Ext.app.Controller',
stores: ['Programs'],
views: ['Viewport', 'Authorize'],
refs: [{
selector: 'taskpanel',
ref: 'taskPanel'
selector: 'viewport',
ref: 'appView'
}, {
selector: 'authorize',
ref: 'authPanel'
}, {
selector: 'authorize > form',
ref: 'authForm'
}],
init: function() {
this.control({
'taskpanel > button': {
toggle: this.programState
/**
*
*/
isGuest: Ext.undefined,
/**
* A template method that is called when your application boots.
* It is called before the Application's launch function is executed so gives a hook
* point to run any code before your Viewport is created.
*/
init: function(app) {
// Bind Guest to the Ext.data.Connection
Ext.override(Ext.data.Connection, {
/**
* Set guest state to the authorization controller
*/
setGuest: Ext.Function.bind(this.setGuest, this),
/**
* Return isGuest current value
* @return {Boolean}
*/
getGuest: Ext.Function.bind(this.getGuest, this)
});
this.control({
'authorize > form > toolbar > button': {
click: this.Authorize
}
});
this.Authorize();
},
/**
* Add program to the task panel
* @param data
* Authorize
* if passed main application view, the first step need to query
* @param object, main application view
*/
addProgram: function(data) {
var data = data || {
name: null
},
store = this.getStore('Programs'),
record, widget;
if(!(record = store.getProccess({
property: 'name',
value: data.name
})))
{
try {
var widget = Ext.widget(data.name),
progId = (store.max('id') || 0) + 1;
}
catch(e) {
return false;
Authorize: function() {
if (this.getAuthPanel()) {
var form = this.getAuthPanel().down('form').getForm();
if(form.isValid()) {
form.submit({
url: Ext.Ajax.getRestUrl('api','login', 'authorize', 0),
method: 'PUT',
clientValidation: true,
scope: this,
success: this.successLogin
})
}
var Button = this.getTaskPanel().add({
xtype: 'button',
ui: 'program-button',
height: 28,
text: data.title || widget.title,
enableToggle: true,
pressed: true,
programId: progId
});
record = store.add({
id: progId,
title: data.title || widget.title,
name: data.name,
state: 'show',
item: widget.getId(),
control: Button.getId()
})[0];
this.getController('Program').registerControl(data.name);
widget.animateTarget = Button.getId();
widget.setTitle(data.title);
widget.show();
}
else {
this.getTaskPanel().items.get(record.get('control')).toggle(true);
if((widget = Ext.getCmp(record.get('item')))) {
widget.show();
}
Ext.Ajax.request({
url: Ext.Ajax.getRestUrl('api', 'login'),
scope: this,
callback: function(){
if (!this.isGuest && !this.getAppView()) {
this.setGuest(false);
this.getView('Viewport').create();
}
}
});
}
return widget ? widget : null;
},
/**
* Return isGuest value
* @param state
*/
getGuest: function() {
return this.isGuest;
},
/**
* Get reference function
* @param {Object} Button
* Set isGuest flag value
* @param object, this controller
* @param boolean, state to set
*/
callRef: function(selector) {
var me = this;
try {
for (var i = 0, ln = this.refs.length; i < ln; i++) {
if (this.refs[i]['selector'] == selector) {
return me['get' + Ext.String.capitalize(this.refs[i]['ref'])]();
}
}
setGuest: function(state) {
this.isGuest = Ext.isBoolean(state) ? state : true;
if(this.isGuest && !this.getAuthPanel()) {
this.getView('Authorize').create();
}
catch(e) { }
return null;
},
programState: function(Button) {
var store = this.getStore('Programs'),
record, widget;
/**
* private
*/
successLogin: function(form, action) {
this.getAuthPanel().close();
if(!(record = store.getProccess({
property: 'id',
value: Button.programId
})))
{
return false;
}
if ((widget = Ext.getCmp(record.get('item')))) {
widget[record.get('state') == 'show' ? 'hide' : 'show']();
if(!this.getAppView()) {
this.getView('Viewport').create();
}
},
},
/**
* Close all process those are registed in the Programs storage
* Logout
* public
*/
closeAll: function() {
this.getStore('Programs').each(function(record){
if ((widget = Ext.getCmp(record.get('item')))) {
widget.hide();
this.getTaskPanel().items.get(record.get('control')).destroy();
}
}, this);
Logout: function() {
Ext.Ajax.request({
url: Ext.Ajax.getRestUrl('api','login', 'logout', 0),
method: 'PUT',
scope: this,
callback: function() {
if(this.getAppView()) {
this.getController('Taskpanel').closeAll();
this.getAppView().destroy();
}
this.setGuest(this, true);
}
});
}
});
/**
......
Ext.override(Ext.Msg,{onShow:function(){this.callParent(arguments);this.center();if(!Ext.isEmpty(Ext.query("div.x-msg-trace"))&&!Ext.isEmpty(Ext.query("div.x-msg-error"))){var a=Ext.get(Ext.query("div.x-msg-error")),b=Ext.get(Ext.query("div.x-msg-trace"));if(b.first().getHeight()+a.first().getHeight()>this.body.getHeight()){b.first().setHeight(this.body.getHeight()-a.first().getHeight())}}},showInfo:function(a){Ext.Msg.show(Ext.apply({autoScroll:true,title:"Info",msg:"",icon:Ext.Msg.INFO,buttons:Ext.Msg.OK},a||{}))},showError:function(a){if(Ext.isObject(a.msg)){if(a.msg.tpl){if(Ext.isArray(a.msg.tpl)||Ext.isString(a.msg.tpl)){a.msg=new Ext.XTemplate(Ext.isArray(a.msg.tpl)?a.msg.tpl.join(""):a.msg.tpl).apply(a.msg.data||{})}else{if(a.msg.tpl.isTemplate){a.msg=a.msg.tpl.apply(a.msg.data||{})}}}else{if(a.msg.error){a.msg=new Ext.XTemplate('<div class="x-msg-error">','<tpl if="code">Error code: {code}<br/></tpl>','<tpl if="type">Error type: {type}<br/></tpl>','Message: <tpl if="message">{message}</tpl><tpl if="!values.message">Unknown error</tpl><br>','<tpl if="file">File: {file}<br/></tpl>','<tpl if="line">Line: {line}<br/></tpl>',"</div>",'<tpl if="traces">','<div class="x-msg-trace"><tpl for="traces">','({line}) {file}: <div class="x-msg-trace-detail">',"<tpl if=\"type == '-&gt;'\">{class}-&gt;{function}()</tpl>",'<tpl if="args && args.length &gt; 0"><div><b>Arguments:</b> {[ Ext.encode(values.args) ]}</div></tpl>',"</div>","</tpl></div>","</tpl>").apply(a.msg.error)}}}Ext.Msg.show(Ext.apply({autoScroll:true,title:"Error",msg:"",icon:Ext.Msg.ERROR,buttons:Ext.Msg.OK},a||{}))}});Ext.override(Ext.data.Connection,{url:".",timeout:380000,setGuest:Ext.emptyFn,getGuest:Ext.emptyFn,getBaseUrl:function(){if(!Ext.isDefined(this.baseUrl)){this.baseUrl=(Ext.query("meta[name=application-url]")[0]||{content:"."}).content;this.baseUrl.replace(/[\/\\]+$/,"");this.url=this.baseUrl}return this.url},getRestUrl:function(){var a=[];Ext.iterate(arguments,function(b){this.push(b)},a);a=a.join("/");a.replace(/^[\/\\]+/,"");return[this.getBaseUrl(),"/index.php/",a].join("")},onComplete:function(f){var d=this,c=f.options,a,i,b;try{a=d.parseStatus(f.xhr.status)}catch(h){a={success:false,isException:false}}i=a.success;if(i){b=d.createResponse(f);d.fireEvent("requestcomplete",d,b,c);Ext.callback(c.success,c.scope,[b,c])}else{if(a.isException||f.aborted||f.timedout){b=d.createException(f)}else{b=d.createResponse(f)}if(Ext.isEmpty(d.getGuest())&&(b.status!=404||b.status!=500)){d.setGuest(true)}else{if(c.proxy&&c.proxy.isProxy){var g=b.responseText?Ext.decode(b.responseText):{};Ext.Msg.showError({title:g.error.title||"Error",msg:{error:g.error},buttons:Ext.Msg.OK})}else{d.fireEvent("requestexception",d,b,c)}Ext.callback(c.failure,c.scope,[b,c])}}if(!Ext.isDefined(d.isGuest)){Ext.callback(c.callback,c.scope,[c,i,b])}delete d.requests[f.id];return b}});Ext.override(Ext.Toolbar,{getValues:function(){var b={},a=this.query("searchfield,textfield,numberfield,checkbox,radio,combo");Ext.each(a,function(c){this[c.name||c.itemId||c.getId()]=c.getValue()},b);return b}});Ext.define("Ext.form.SearchField",{extend:"Ext.form.field.Text",alias:"widget.searchfield",enableKeyEvents:true,handler:null,initComponent:function(){this.callParent();if(!Ext.isEmpty(this.handler)){this.on("specialkey",this.checkEnterKey,this)}},checkEnterKey:function(d,c){var b=this.getValue();if(c.getKey()===c.ENTER){if(Ext.isFunction(this.handler)){this.handler()}else{if(Ext.isString(this.handler)){var a=this.up("toolbar").query("#"+this.handler);if(a.length>0&&a[0].getXType()=="button"){a[0].fireEvent("click",a[0])}}}}}});Ext.define("MyMA.view.ProgramMenu",{extend:"Ext.Button",alias:"widget.programmenu",text:"Menu",height:30,ui:"program-menu",menu:[{text:"Users",widgetName:"users"},{text:"Aliases",widgetName:"aliases"},{text:"Transports",widgetName:"transports"},"-",{text:"Logout",itemId:"logout"}]});Ext.define("MyMA.view.Taskpanel",{extend:"Ext.Toolbar",alias:"widget.taskpanel",ui:"programbar",height:28,style:{border:0,padding:0},autoScroll:true,items:[]});Ext.define("MyMA.view.Aliases",{extend:"Ext.window.Window",alias:"widget.aliases",layout:"fit",minimizable:true,constrainHeader:true,closeAction:"destroy",width:900,listeners:{render:function(a){if(Ext.getBody().getHeight()>500){a.setHeight(Ext.getBody().getHeight()-150)}}},items:[{xtype:"grid",border:false,viewConfig:{plugins:{ptype:"gridviewdragdrop"},listeners:{beforedrop:function(c,e,d,a,b){Ext.each(e.records,function(f){if(f.get("alias")!=this.groupName){f.set("alias",this.groupName);f.save({action:"update",scope:this,failure:function(g){g.store.reload()}})}},{data:e,groupName:this.getFeature("alias-groups").getGroupName(c),model:d})}}},tbar:[{xtype:"button",itemId:"addrecord",iconCls:"x-ibtn-add",text:"New Item"},{xtype:"tbseparator",width:5},{xtype:"searchfield",handler:"search",name:"query"},{xtype:"tbspacer",width:5},{xtype:"button",itemId:"search",text:"Search"}],bbar:{xtype:"pagingtoolbar",displayInfo:true,store:"Aliases"},features:[{ftype:"grouping",id:"alias-groups",groupHeaderTpl:"Group: {name} ({rows.length})",startCollapsed:false}],selModel:{selType:"rowmodel"},columns:[{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-edit x-ibtn-def"}}]},{header:"ID",dataIndex:"id",width:40},{header:"Recipient",dataIndex:"recipient",flex:1},{header:"Alias",hidden:true,dataIndex:"alias"},{header:"Comment",dataIndex:"comment",flex:1},{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-delete x-ibtn-def"}}]}],selType:"rowmodel",multiSelect:true,store:"Aliases"}]});Ext.define("MyMA.view.Alias",{extend:"Ext.window.Window",alias:"widget.alias",layout:"fit",title:"Alias",width:400,constrainHeader:true,closeAction:"destroy",buttons:[{xtype:"button",itemId:"savedata",text:"Save",scope:this}],items:[{xtype:"form",frame:true,monitorValid:true,defaults:{xtype:"textfield",anchor:"100%",allowBlank:false},items:[{xtype:"hidden",name:"id"},{fieldLabel:"Alias",name:"alias",vtype:"email"},{fieldLabel:"Recipient",name:"recipient",vtype:"email"},{fieldLabel:"Comment",xtype:"textarea",name:"comment"}]}]});Ext.define("MyMA.view.Users",{extend:"Ext.window.Window",alias:"widget.users",layout:"fit",minimizable:true,constrainHeader:true,closeAction:"destroy",width:900,listeners:{render:function(a){if(Ext.getBody().getHeight()>500){a.setHeight(Ext.getBody().getHeight()-150)}}},items:[{xtype:"grid",border:false,listeners:{edit:function(a,b){if(b.originalValue==b.value){return}b.record.save({action:"update",scope:b,success:function(){this.record.commit()}})}},tbar:[{xtype:"button",iconCls:"x-ibtn-add",itemId:"addrecord",text:"New Item"},{xtype:"tbseparator",width:5},{xtype:"searchfield",handler:"search",name:"query"},{xtype:"tbspacer",width:5},{xtype:"button",itemId:"search",text:"Search"}],bbar:{xtype:"pagingtoolbar",displayInfo:true,store:"Users"},plugins:[Ext.create("Ext.grid.plugin.CellEditing",{clicksToEdit:1})],selModel:{selType:"cellmodel"},columns:[{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-edit x-ibtn-def"}}]},{header:"ID",dataIndex:"id",width:40},{header:"Name",dataIndex:"name",editor:{xtype:"textfield"},flex:1},{header:"Login",dataIndex:"login",width:120},{header:"Password",hidden:true,dataIndex:"passwd"},{header:"uid",dataIndex:"uid",width:40},{header:"gid",dataIndex:"gid",width:40},{header:"Mail directory",dataIndex:"maildir"},{header:"SMTP",dataIndex:"smtp",editor:{xtype:"combo",valueField:"id",displayField:"name",triggerAction:"all",editable:false,store:"Choice"},renderer:function(a){if(a==1){return"Yes"}return"No"}},{header:"IMAP",dataIndex:"imap",editor:{xtype:"combo",valueField:"id",displayField:"name",triggerAction:"all",editable:false,store:"Choice"},renderer:function(a){if(a==1){return"Yes"}return"No"}},{header:"Quota",dataIndex:"quota",editor:{xtype:"numberfield",allowDecimal:false}},{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-delete x-ibtn-def"}}]}],store:"Users"}]});Ext.define("MyMA.view.User",{extend:"Ext.window.Window",alias:"widget.user",layout:"fit",title:"User",width:400,constrainHeader:true,closeAction:"destroy",buttons:[{xtype:"button",itemId:"savedata",text:"Save",scope:this}],items:[{xtype:"form",frame:true,monitorValid:true,defaults:{xtype:"textfield",anchor:"100%",allowBlank:false},items:[{xtype:"hidden",name:"id"},{xtype:"checkbox",fieldLabel:"Manager",name:"manager",inputValue:1},{xtype:"checkbox",fieldLabel:"SMTP",name:"smtp",inputValue:1},{xtype:"checkbox",fieldLabel:"IMAP",name:"imap",inputValue:1},{fieldLabel:"Name",name:"name"},{fieldLabel:"Login",name:"login",vtype:"email"},{fieldLabel:"Password",name:"passwd"},{xtype:"numberfield",allowDecimal:false,fieldLabel:"UID",name:"uid",anchor:"50%",value:8},{xtype:"numberfield",allowDecimal:false,fieldLabel:"GID",name:"gid",anchor:"50%",value:12},{fieldLabel:"Mail directory",name:"maildir"},{xtype:"numberfield",name:"quota",allowDecimal:false,fieldLabel:"Quota",anchor:"60%",value:100000000}]}]});Ext.define("MyMA.view.Viewport",{extend:"Ext.container.Viewport",requires:["MyMA.view.ProgramMenu","MyMA.view.Taskpanel","MyMA.view.Users","MyMA.view.Aliases"],layout:"fit",statics:{ready:false},items:{xtype:"panel",layout:"fit",border:false,dockedItems:[{dock:"top",xtype:"toolbar",height:30,ui:"programbar-panel",items:[{xtype:"programmenu",width:100},"-",{xtype:"taskpanel",flex:1}]}],items:[{xtype:"panel",border:false,ui:"desk-panel",bodyCls:"x-desk-panel-bg",layout:{type:"fit"}}]}});Ext.define("MyMA.view.Authorize",{extend:"Ext.Window",alias:"widget.authorize",layout:"fit",autoShow:true,layout:"fit",width:350,closable:false,constrain:true,draggable:false,resizable:false,modal:true,cls:"x-window-authbaner",dockedItems:[{dock:"top",xtype:"toolbar",ui:"authform-baner",height:43,html:"{LOGIN @ MAIL . PANEL }"}],items:[{xtype:"form",url:"index.php",monitorValid:true,frame:false,border:false,defaults:{anchor:"100%"},buttons:[{text:"Login"}],items:[{fieldLabel:"Login",xtype:"textfield",allowBlank:false,name:"login"},{fieldLabel:"Password",xtype:"textfield",name:"pass",inputType:"password"}]}]});Ext.define("MyMA.view.Transports",{extend:"Ext.window.Window",alias:"widget.transports",layout:"fit",minimizable:true,constrainHeader:true,closeAction:"destroy",width:900,listeners:{render:function(a){if(Ext.getBody().getHeight()>500){a.setHeight(Ext.getBody().getHeight()-150)}}},items:[{xtype:"grid",border:false,tbar:[{xtype:"button",itemId:"addrecord",iconCls:"x-ibtn-add",text:"New Item"},{xtype:"tbseparator",width:5},{xtype:"searchfield",handler:"search",name:"query"},{xtype:"tbspacer",width:5},{xtype:"button",itemId:"search",text:"Search"}],bbar:{xtype:"pagingtoolbar",displayInfo:true,store:"Transports"},columns:[{header:"ID",dataIndex:"id",width:40},{header:"Domain",dataIndex:"domain",editor:{xtype:"textfield",allowBlank:false},flex:1},{header:"Transport",dataIndex:"transport"},{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-delete x-ibtn-def"}}]}],selType:"rowmodel",plugins:[Ext.create("Ext.grid.plugin.RowEditing",{clicksToEdit:1})],store:"Transports"}]});Ext.define("MyMA.model.Users",{extend:"Ext.data.Model",fields:[{name:"id",type:"int"},{name:"name",type:"string"},{name:"login",type:"string"},{name:"passwd",type:"string"},{name:"uid",type:"int",defaultValue:8},{name:"gid",type:"int",defaultValue:12},{name:"maildir",type:"string"},{name:"smtp",type:"int"},{name:"imap",type:"int"},{name:"quota",type:"int",defaultValue:10000000},{name:"manager",type:"int"}],validations:[{type:"format",field:"maildir",matcher:/^\/[a-z]\.ru\/[a-z_0-9]\/Maildir\/$/}],proxy:{type:"rest",url:Ext.Ajax.getRestUrl("api/user"),reader:{type:"json",root:"results"},writer:{type:"json",allowSingle:true}}});Ext.define("MyMA.model.Brief",{extend:"Ext.data.Model",fields:["id","name"],proxy:{type:"memory",reader:{type:"json",root:"results"}}});Ext.define("MyMA.model.Aliases",{extend:"Ext.data.Model",fields:[{name:"id",type:"int"},{name:"alias",type:"string"},{name:"recipient",type:"string"},{name:"comment",type:"string"}],proxy:{type:"rest",url:Ext.Ajax.getRestUrl("api","alias"),reader:{type:"json",root:"results",totalProperty:"total"},writer:{type:"json",allowSingle:true}}});Ext.define("MyMA.model.Transports",{extend:"Ext.data.Model",fields:[{name:"id",type:"int"},{name:"domain",type:"string"},{name:"transport",type:"string"}],proxy:{type:"rest",url:Ext.Ajax.getRestUrl("api","transport"),reader:{type:"json",root:"results",totalProperty:"total"},writer:{type:"json",allowSingle:true}}});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Transports",{extend:"Ext.data.Store",requires:"MyMA.model.Transports",model:"MyMA.model.Transports",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Transports",{extend:"Ext.data.Store",requires:"MyMA.model.Transports",model:"MyMA.model.Transports",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.controller.Users",{extend:"Ext.app.Controller",stores:["Users","Choice"],views:["Users","User"],refs:[{selector:"users > grid",ref:"usersList"},{selector:"users",ref:"usersWindow"}],init:function(){this.control({"users > grid > toolbar > #addrecord":{click:this.showForm},"users > grid > toolbar > #search":{click:this.onSearch},"users actioncolumn":{click:this.onActionColumn}})},onActionColumn:function(g,a,h,i,f,j,b){if(f.getTarget(".x-ibtn-edit")){var d=j.store.getAt(h);var c=this.getController("Taskpanel").addProgram({name:"user"});c.setTitle("User: "+d.get("name"));c.down("form").getForm().loadRecord(d)}if(f.getTarget(".x-ibtn-delete")){var d=j.store.getAt(h);Ext.Msg.confirm("Info","Press Yes to conform remove action",function(e){if(e==="yes"){this.record.destroy({scope:this,success:function(){this.store.remove(this.record)}})}},{store:j.store,record:d})}},showForm:function(a){this.getController("Taskpanel").addProgram({name:"user",title:"New User"})},onSearch:function(a){this.getUsersList().getStore().reload({params:a.up("toolbar").getValues()})}});Ext.define("MyMA.controller.ProgramMenu",{extend:"Ext.app.Controller",init:function(){this.control({"programmenu > menu":{click:this.LaunchProgram}})},LaunchProgram:function(b,a){if(a.itemId=="logout"){this.getController("Viewport").Logout()}else{this.getController("Taskpanel").addProgram({name:a.widgetName,title:a.text})}}});Ext.define("MyMA.controller.Program",{extend:"Ext.app.Controller",stores:["Programs"],refs:[{selector:"taskpanel",ref:"taskPanel"}],init:function(){var a={};Ext.each(this.refs,function(b){this.control[b.selector]={beforeclose:this.me.programStop,hide:this.me.programState,show:this.me.programState,minimize:this.me.programMinimize}},{control:a,me:this});this.control(a)},registerControl:function(a){var a=a||null,b={};if(!a){return}b[a]={beforeclose:this.programStop,hide:this.programState,show:this.programState,minimize:this.programMinimize};this.control(b)},programMinimize:function(b){var a;if(!(a=this.getStore("Programs").getProccess({property:"item",value:b.getId()}))){return false}this.getTaskPanel().items.get(a.get("control")).toggle(false);b.hide();this.programState(b)},programState:function(c,b){var a;if(!(a=this.getStore("Programs").getProccess({property:"item",value:c.getId()}))){return false}a.set("state",c.isHidden()?"hide":"show")},programStop:function(b,a){var a=a||Ext.undefined;if(!a.data){(a=this.getStore("Programs").getProccess({property:"item",value:b.getId()}))}if(b.animateTarget){b.animateTarget=null}if(a&&a.data){this.getTaskPanel().items.get(a.get("control")).destroy();this.getStore("Programs").remove(a)}}});Ext.define("MyMA.controller.Viewport",{extend:"Ext.app.Controller",views:["Viewport","Authorize"],refs:[{selector:"viewport",ref:"appView"},{selector:"authorize",ref:"authPanel"},{selector:"authorize > form",ref:"authForm"}],isGuest:Ext.undefined,init:function(a){Ext.override(Ext.data.Connection,{setGuest:Ext.Function.bind(this.setGuest,this),getGuest:Ext.Function.bind(this.getGuest,this)});this.control({"authorize > form > toolbar > button":{click:this.Authorize}});this.Authorize()},Authorize:function(){if(this.getAuthPanel()){var a=this.getAuthPanel().down("form").getForm();if(a.isValid()){a.submit({url:Ext.Ajax.getRestUrl("api","login","authorize",0),method:"PUT",clientValidation:true,scope:this,success:this.successLogin})}}else{Ext.Ajax.request({url:Ext.Ajax.getRestUrl("api","login"),scope:this,callback:function(){if(!this.isGuest&&!this.getAppView()){this.setGuest(false);this.getView("Viewport").create()}}})}},getGuest:function(){return this.isGuest},setGuest:function(a){this.isGuest=Ext.isBoolean(a)?a:true;if(this.isGuest&&!this.getAuthPanel()){this.getView("Authorize").create()}},successLogin:function(a,b){this.getAuthPanel().close();if(!this.getAppView()){this.getView("Viewport").create()}},Logout:function(){Ext.Ajax.request({url:Ext.Ajax.getRestUrl("api","login","logout",0),method:"PUT",scope:this,callback:function(){if(this.getAppView()){this.getController("Taskpanel").closeAll();this.getAppView().destroy()}this.setGuest(this,true)}})}});Ext.define("MyMA.controller.Alias",{extend:"Ext.app.Controller",views:["Alias"],refs:[{selector:"alias",ref:"aliasWindow"}],init:function(){this.control({"alias > toolbar > #savedata":{click:this.saveData}})},saveData:function(a){var b=this.getAliasWindow().down("form").getForm(),c=b.getValues().id||null;if(!b.isValid()){return false}b.submit({url:Ext.Ajax.getRestUrl("api","alias",c),clientValidation:true,method:c>0?"PUT":"POST",scope:{controller:this,win:this.getAliasWindow()},success:this.onSuccessSubmit,failure:this.onFailSubmit})},onSuccessSubmit:function(a,b){this.win.close();this.controller.getController("Aliases").getStore("Aliases").reload({params:{start:0}});Ext.Msg.showInfo({msg:"Data saved"})},onFailSubmit:function(a,c){try{var b=Ext.decode(c.response.responseText);throw (b)}catch(d){Ext.Msg.showError({msg:d})}}});Ext.define("MyMA.controller.User",{extend:"Ext.app.Controller",views:["User"],refs:[{selector:"user",ref:"userWindow"}],init:function(){this.control({"user > toolbar > #savedata":{click:this.saveData}})},saveData:function(a){var b=this.getUserWindow().down("form").getForm(),c=b.getValues().id||null;if(!b.isValid()){return false}b.submit({url:Ext.Ajax.getRestUrl("api","user",c),clientValidation:true,method:c>0?"PUT":"POST",params:Ext.applyIf(Ext.copyTo({},b.getValues(),"smtp,imap,manager"),{smtp:0,imap:0,manager:0}),scope:{controller:this,win:this.getUserWindow()},success:this.onSuccessSubmit,failure:this.onFailSubmit})},onSuccessSubmit:function(a,b){this.win.close();this.controller.getController("Users").getStore("Users").reload({params:{start:0}});Ext.Msg.showInfo({msg:"Data saved"})},onFailSubmit:function(a,c){try{var b=Ext.decode(c.response.responseText);throw (b)}catch(d){Ext.Msg.showError({msg:d})}}});Ext.define("MyMA.controller.Aliases",{extend:"Ext.app.Controller",stores:["Aliases"],views:["Aliases","Alias"],refs:[{selector:"aliases > grid",ref:"aliasesList"}],init:function(){this.control({"aliases > grid > toolbar > #addrecord":{click:this.showForm},"aliases > grid > toolbar > #search":{click:this.onSearch},"aliases actioncolumn":{click:this.onActionColumn}})},onActionColumn:function(g,a,h,i,f,j,b){if(f.getTarget(".x-ibtn-edit")){var d=j.store.getAt(h);var c=this.getController("Taskpanel").addProgram({name:"alias"});c.setTitle("Alias: "+d.get("alias"));c.down("form").getForm().loadRecord(d)}if(f.getTarget(".x-ibtn-delete")){var d=j.store.getAt(h);Ext.Msg.confirm("Info","Press Yes to confirm remove action",function(e){if(e==="yes"){this.record.destroy({scope:this,success:function(){this.store.remove(this.record)}})}},{store:j.store,record:d})}},showForm:function(a){this.getController("Taskpanel").addProgram({name:"alias",title:"New Alias"})},onSearch:function(a){this.getAliasesList().getStore().reload({params:a.up("toolbar").getValues()})}});Ext.define("MyMA.controller.Transports",{extend:"Ext.app.Controller",stores:["Transports"],views:["Transports"],refs:[{selector:"transports > grid",ref:"transportsList"}],init:function(){this.control({"transports > grid > toolbar > #addrecord":{click:this.addRecord},"transports > grid > toolbar > #search":{click:this.onSearch},"transports actioncolumn":{click:this.onActionColumn},"transports > grid":{edit:this.onEditAction}})},onActionColumn:function(b,g,i,d,h,f,c){if(h.getTarget(".x-ibtn-delete")){var a=f.store.getAt(i);Ext.Msg.confirm("Info","Press Yes to confirm remove action",function(e){if(e==="yes"){if(!this.record.get("id")){this.store.remove(this.record)}else{this.record.destroy({scope:this,success:function(){this.store.remove(this.record)}})}}},{store:f.store,record:a})}},addRecord:function(a){this.getTransportsList().getStore().insert(0,this.getTransportsList().getStore().model.create({id:0,domain:null,transport:"virtual"}))},onSearch:function(a){this.getTransportsList().getStore().reload({params:a.up("toolbar").getValues()})},onEditAction:function(a,b){b.record.save({scope:b,success:function(c){this.store.reload()}})}});Ext.define("MyMA.controller.Taskpanel",{extend:"Ext.app.Controller",stores:["Programs"],refs:[{selector:"taskpanel",ref:"taskPanel"}],init:function(){this.control({"taskpanel > button":{toggle:this.programState}})},addProgram:function(g){var g=g||{name:null},c=this.getStore("Programs"),b,f;if(!(b=c.getProccess({property:"name",value:g.name}))){try{var f=Ext.widget(g.name),d=(c.max("id")||0)+1}catch(h){return false}var a=this.getTaskPanel().add({xtype:"button",ui:"program-button",height:28,text:g.title||f.title,enableToggle:true,pressed:true,programId:d});b=c.add({id:d,title:g.title||f.title,name:g.name,state:"show",item:f.getId(),control:a.getId()})[0];this.getController("Program").registerControl(g.name);f.animateTarget=a.getId();f.setTitle(g.title);f.show()}else{this.getTaskPanel().items.get(b.get("control")).toggle(true);if((f=Ext.getCmp(b.get("item")))){f.show()}}return f?f:null},callRef:function(a){var d=this;try{for(var b=0,c=this.refs.length;b<c;b++){if(this.refs[b]["selector"]==a){return d["get"+Ext.String.capitalize(this.refs[b]["ref"])]()}}}catch(f){}return null},programState:function(b){var c=this.getStore("Programs"),a,d;if(!(a=c.getProccess({property:"id",value:b.programId}))){return false}if((d=Ext.getCmp(a.get("item")))){d[a.get("state")=="show"?"hide":"show"]()}},closeAll:function(){this.getStore("Programs").each(function(a){if((widget=Ext.getCmp(a.get("item")))){widget.hide();this.getTaskPanel().items.get(a.get("control")).destroy()}},this)}});Ext.application({name:"MyMA",controllers:["Viewport","ProgramMenu","Taskpanel","Program","Users","User","Aliases","Alias","Transports"],enableQuickTips:true});
\ No newline at end of file
Ext.override(Ext.Msg,{onShow:function(){this.callParent(arguments);this.center();if(!Ext.isEmpty(Ext.query("div.x-msg-trace"))&&!Ext.isEmpty(Ext.query("div.x-msg-error"))){var d=Ext.get(Ext.query("div.x-msg-error")),c=Ext.get(Ext.query("div.x-msg-trace"));if(c.first().getHeight()+d.first().getHeight()>this.body.getHeight()){c.first().setHeight(this.body.getHeight()-d.first().getHeight());}}},showInfo:function(b){Ext.Msg.show(Ext.apply({autoScroll:true,title:"Info",msg:"",icon:Ext.Msg.INFO,buttons:Ext.Msg.OK},b||{}));},showError:function(b){if(Ext.isObject(b.msg)){if(b.msg.tpl){if(Ext.isArray(b.msg.tpl)||Ext.isString(b.msg.tpl)){b.msg=new Ext.XTemplate(Ext.isArray(b.msg.tpl)?b.msg.tpl.join(""):b.msg.tpl).apply(b.msg.data||{});}else{if(b.msg.tpl.isTemplate){b.msg=b.msg.tpl.apply(b.msg.data||{});}}}else{if(b.msg.error){b.msg=new Ext.XTemplate('<div class="x-msg-error">','<tpl if="code">Error code: {code}<br/></tpl>','<tpl if="type">Error type: {type}<br/></tpl>','Message: <tpl if="message">{message}</tpl><tpl if="!values.message">Unknown error</tpl><br>','<tpl if="file">File: {file}<br/></tpl>','<tpl if="line">Line: {line}<br/></tpl>',"</div>",'<tpl if="traces">','<div class="x-msg-trace"><tpl for="traces">','({line}) {file}: <div class="x-msg-trace-detail">',"<tpl if=\"type == '-&gt;'\">{class}-&gt;{function}()</tpl>",'<tpl if="args && args.length &gt; 0"><div><b>Arguments:</b> {[ Ext.encode(values.args) ]}</div></tpl>',"</div>","</tpl></div>","</tpl>").apply(b.msg.error);}}}Ext.Msg.show(Ext.apply({autoScroll:true,title:"Error",msg:"",icon:Ext.Msg.ERROR,buttons:Ext.Msg.OK},b||{}));}});Ext.override(Ext.data.Connection,{url:".",timeout:380000,setGuest:Ext.emptyFn,getGuest:Ext.emptyFn,getBaseUrl:function(){if(!Ext.isDefined(this.baseUrl)){this.baseUrl=(Ext.query("meta[name=application-url]")[0]||{content:"."}).content;this.baseUrl.replace(/[\/\\]+$/,"");this.url=this.baseUrl;}return this.url;},getRestUrl:function(){var b=[];Ext.iterate(arguments,function(a){this.push(a);},b);b=b.join("/");b.replace(/^[\/\\]+/,"");return[this.getBaseUrl(),"/index.php/",b].join("");},onComplete:function(k){var l=this,m=k.options,o,p,n;try{o=l.parseStatus(k.xhr.status);}catch(e){o={success:false,isException:false};}p=o.success;if(p){n=l.createResponse(k);l.fireEvent("requestcomplete",l,n,m);Ext.callback(m.success,m.scope,[n,m]);}else{if(o.isException||k.aborted||k.timedout){n=l.createException(k);}else{n=l.createResponse(k);}if(Ext.isEmpty(l.getGuest())&&(n.status!=404||n.status!=500)){l.setGuest(true);}else{if(m.proxy&&m.proxy.isProxy){var j=n.responseText?Ext.decode(n.responseText):{};Ext.Msg.showError({title:j.error.title||"Error",msg:{error:j.error},buttons:Ext.Msg.OK});}else{l.fireEvent("requestexception",l,n,m);}Ext.callback(m.failure,m.scope,[n,m]);}}if(!Ext.isDefined(l.isGuest)){Ext.callback(m.callback,m.scope,[m,p,n]);}delete l.requests[k.id];return n;}});Ext.override(Ext.Toolbar,{getValues:function(){var c={},d=this.query("searchfield,textfield,numberfield,checkbox,radio,combo");Ext.each(d,function(a){this[a.name||a.itemId||a.getId()]=a.getValue();},c);return c;}});Ext.define("Ext.form.SearchField",{extend:"Ext.form.field.Text",alias:"widget.searchfield",enableKeyEvents:true,handler:null,initComponent:function(){this.callParent();if(!Ext.isEmpty(this.handler)){this.on("specialkey",this.checkEnterKey,this);}},checkEnterKey:function(e,f){var g=this.getValue();if(f.getKey()===f.ENTER){if(Ext.isFunction(this.handler)){this.handler();}else{if(Ext.isString(this.handler)){var h=this.up("toolbar").query("#"+this.handler);if(h.length>0&&h[0].getXType()=="button"){h[0].fireEvent("click",h[0]);}}}}}});Ext.define("MyMA.view.ProgramMenu",{extend:"Ext.Button",alias:"widget.programmenu",text:"Menu",height:30,ui:"program-menu",menu:[{text:"Users",widgetName:"users"},{text:"Aliases",widgetName:"aliases"},{text:"Transports",widgetName:"transports"},"-",{text:"Logout",itemId:"logout"}]});Ext.define("MyMA.view.Taskpanel",{extend:"Ext.Toolbar",alias:"widget.taskpanel",ui:"programbar",height:28,style:{border:0,padding:0},autoScroll:true,items:[]});Ext.define("MyMA.view.Aliases",{extend:"Ext.window.Window",alias:"widget.aliases",layout:"fit",minimizable:true,constrainHeader:true,closeAction:"destroy",width:900,listeners:{render:function(b){if(Ext.getBody().getHeight()>500){b.setHeight(Ext.getBody().getHeight()-150);}}},items:[{xtype:"grid",border:false,viewConfig:{plugins:{ptype:"gridviewdragdrop"},listeners:{beforedrop:function(g,j,f,i,h){Ext.each(j.records,function(a){if(a.get("alias")!=this.groupName){a.set("alias",this.groupName);a.save({action:"update",scope:this,failure:function(b){b.store.reload();}});}},{data:j,groupName:this.getFeature("alias-groups").getGroupName(g),model:f});}}},tbar:[{xtype:"button",itemId:"addrecord",iconCls:"x-ibtn-add",text:"New Item"},{xtype:"tbseparator",width:5},{xtype:"searchfield",handler:"search",name:"query"},{xtype:"tbspacer",width:5},{xtype:"button",itemId:"search",text:"Search"}],bbar:{xtype:"pagingtoolbar",displayInfo:true,store:"Aliases"},features:[{ftype:"grouping",id:"alias-groups",groupHeaderTpl:"Group: {name} ({rows.length})",startCollapsed:false}],selModel:{selType:"rowmodel"},columns:[{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-edit x-ibtn-def";}}]},{header:"ID",dataIndex:"id",width:40},{header:"Recipient",dataIndex:"recipient",flex:1},{header:"Alias",hidden:true,dataIndex:"alias"},{header:"Comment",dataIndex:"comment",flex:1},{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-delete x-ibtn-def";}}]}],selType:"rowmodel",multiSelect:true,store:"Aliases"}]});Ext.define("MyMA.view.Alias",{extend:"Ext.window.Window",alias:"widget.alias",layout:"fit",title:"Alias",width:400,constrainHeader:true,closeAction:"destroy",buttons:[{xtype:"button",itemId:"savedata",text:"Save",scope:this}],items:[{xtype:"form",frame:true,monitorValid:true,defaults:{xtype:"textfield",anchor:"100%",allowBlank:false},items:[{xtype:"hidden",name:"id"},{fieldLabel:"Alias",name:"alias",vtype:"email"},{fieldLabel:"Recipient",name:"recipient",vtype:"email"},{fieldLabel:"Comment",xtype:"textarea",name:"comment"}]}]});Ext.define("MyMA.view.Users",{extend:"Ext.window.Window",alias:"widget.users",layout:"fit",minimizable:true,constrainHeader:true,closeAction:"destroy",width:900,listeners:{render:function(b){if(Ext.getBody().getHeight()>500){b.setHeight(Ext.getBody().getHeight()-150);}}},items:[{xtype:"grid",border:false,listeners:{edit:function(d,c){if(c.originalValue==c.value){return;}c.record.save({action:"update",scope:c,success:function(){this.record.commit();}});}},tbar:[{xtype:"button",iconCls:"x-ibtn-add",itemId:"addrecord",text:"New Item"},{xtype:"tbseparator",width:5},{xtype:"searchfield",handler:"search",name:"query"},{xtype:"tbspacer",width:5},{xtype:"button",itemId:"search",text:"Search"}],bbar:{xtype:"pagingtoolbar",displayInfo:true,store:"Users"},plugins:[Ext.create("Ext.grid.plugin.CellEditing",{clicksToEdit:1})],selModel:{selType:"cellmodel"},columns:[{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-edit x-ibtn-def";}}]},{header:"ID",dataIndex:"id",width:40},{header:"Name",dataIndex:"name",editor:{xtype:"textfield"},flex:1},{header:"Login",dataIndex:"login",width:120},{header:"Password",hidden:true,dataIndex:"passwd"},{header:"uid",dataIndex:"uid",width:40},{header:"gid",dataIndex:"gid",width:40},{header:"Mail directory",dataIndex:"maildir"},{header:"SMTP",dataIndex:"smtp",editor:{xtype:"combo",valueField:"id",displayField:"name",triggerAction:"all",editable:false,store:"Choice"},renderer:function(b){if(b==1){return"Yes";}return"No";}},{header:"IMAP",dataIndex:"imap",editor:{xtype:"combo",valueField:"id",displayField:"name",triggerAction:"all",editable:false,store:"Choice"},renderer:function(b){if(b==1){return"Yes";}return"No";}},{header:"Quota",dataIndex:"quota",editor:{xtype:"numberfield",allowDecimal:false}},{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-delete x-ibtn-def";}}]}],store:"Users"}]});Ext.define("MyMA.view.User",{extend:"Ext.window.Window",alias:"widget.user",layout:"fit",title:"User",width:400,constrainHeader:true,closeAction:"destroy",buttons:[{xtype:"button",itemId:"savedata",text:"Save",scope:this}],items:[{xtype:"form",frame:true,monitorValid:true,defaults:{xtype:"textfield",anchor:"100%",allowBlank:false},items:[{xtype:"hidden",name:"id"},{xtype:"checkbox",fieldLabel:"Manager",name:"manager",inputValue:1},{xtype:"checkbox",fieldLabel:"SMTP",name:"smtp",inputValue:1},{xtype:"checkbox",fieldLabel:"IMAP",name:"imap",inputValue:1},{fieldLabel:"Name",name:"name"},{fieldLabel:"Login",name:"login",vtype:"email"},{fieldLabel:"Password",name:"passwd"},{xtype:"numberfield",allowDecimal:false,fieldLabel:"UID",name:"uid",anchor:"50%",value:8},{xtype:"numberfield",allowDecimal:false,fieldLabel:"GID",name:"gid",anchor:"50%",value:12},{fieldLabel:"Mail directory",name:"maildir"},{xtype:"numberfield",name:"quota",allowDecimal:false,fieldLabel:"Quota",anchor:"60%",value:100000000}]}]});Ext.define("MyMA.view.Viewport",{extend:"Ext.container.Viewport",requires:["MyMA.view.ProgramMenu","MyMA.view.Taskpanel","MyMA.view.Users","MyMA.view.Aliases"],layout:"fit",statics:{ready:false},items:{xtype:"panel",layout:"fit",border:false,dockedItems:[{dock:"top",xtype:"toolbar",height:30,ui:"programbar-panel",items:[{xtype:"programmenu",width:100},"-",{xtype:"taskpanel",flex:1}]}],items:[{xtype:"panel",border:false,ui:"desk-panel",bodyCls:"x-desk-panel-bg",layout:{type:"fit"}}]}});Ext.define("MyMA.view.Authorize",{extend:"Ext.Window",alias:"widget.authorize",layout:"fit",autoShow:true,layout:"fit",width:350,closable:false,constrain:true,draggable:false,resizable:false,modal:true,cls:"x-window-authbaner",dockedItems:[{dock:"top",xtype:"toolbar",ui:"authform-baner",height:43,html:"{LOGIN @ MAIL . PANEL }"}],items:[{xtype:"form",url:"index.php",monitorValid:true,frame:false,border:false,defaults:{anchor:"100%"},buttons:[{text:"Login"}],items:[{fieldLabel:"Login",xtype:"textfield",allowBlank:false,name:"login"},{fieldLabel:"Password",xtype:"textfield",name:"pass",inputType:"password"}]}]});Ext.define("MyMA.view.Transports",{extend:"Ext.window.Window",alias:"widget.transports",layout:"fit",minimizable:true,constrainHeader:true,closeAction:"destroy",width:900,listeners:{render:function(b){if(Ext.getBody().getHeight()>500){b.setHeight(Ext.getBody().getHeight()-150);}}},items:[{xtype:"grid",border:false,tbar:[{xtype:"button",itemId:"addrecord",iconCls:"x-ibtn-add",text:"New Item"},{xtype:"tbseparator",width:5},{xtype:"searchfield",handler:"search",name:"query"},{xtype:"tbspacer",width:5},{xtype:"button",itemId:"search",text:"Search"}],bbar:{xtype:"pagingtoolbar",displayInfo:true,store:"Transports"},columns:[{header:"ID",dataIndex:"id",width:40},{header:"Domain",dataIndex:"domain",editor:{xtype:"textfield",allowBlank:false},flex:1},{header:"Transport",dataIndex:"transport"},{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-delete x-ibtn-def";}}]}],selType:"rowmodel",plugins:[Ext.create("Ext.grid.plugin.RowEditing",{clicksToEdit:1})],store:"Transports"}]});Ext.define("MyMA.model.Users",{extend:"Ext.data.Model",fields:[{name:"id",type:"int"},{name:"name",type:"string"},{name:"login",type:"string"},{name:"passwd",type:"string"},{name:"uid",type:"int",defaultValue:8},{name:"gid",type:"int",defaultValue:12},{name:"maildir",type:"string"},{name:"smtp",type:"int"},{name:"imap",type:"int"},{name:"quota",type:"int",defaultValue:10000000},{name:"manager",type:"int"}],validations:[{type:"format",field:"maildir",matcher:/^\/[a-z]\.ru\/[a-z_0-9]\/Maildir\/$/}],proxy:{type:"rest",url:Ext.Ajax.getRestUrl("api/user"),reader:{type:"json",root:"results"},writer:{type:"json",allowSingle:true}}});Ext.define("MyMA.model.Brief",{extend:"Ext.data.Model",fields:["id","name"],proxy:{type:"memory",reader:{type:"json",root:"results"}}});Ext.define("MyMA.model.Aliases",{extend:"Ext.data.Model",fields:[{name:"id",type:"int"},{name:"alias",type:"string"},{name:"recipient",type:"string"},{name:"comment",type:"string"}],proxy:{type:"rest",url:Ext.Ajax.getRestUrl("api","alias"),reader:{type:"json",root:"results",totalProperty:"total"},writer:{type:"json",allowSingle:true}}});Ext.define("MyMA.model.Transports",{extend:"Ext.data.Model",fields:[{name:"id",type:"int"},{name:"domain",type:"string"},{name:"transport",type:"string"}],proxy:{type:"rest",url:Ext.Ajax.getRestUrl("api","transport"),reader:{type:"json",root:"results",totalProperty:"total"},writer:{type:"json",allowSingle:true}}});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Transports",{extend:"Ext.data.Store",requires:"MyMA.model.Transports",model:"MyMA.model.Transports",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(c){var c=c||{property:"id",value:null},d=-1;if((d=this.find(c.property,c.value,0,false,true,true))>-1){return this.getAt(d);}return null;}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Transports",{extend:"Ext.data.Store",requires:"MyMA.model.Transports",model:"MyMA.model.Transports",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.controller.Users",{extend:"Ext.app.Controller",stores:["Users","Choice"],views:["Users","User"],refs:[{selector:"users > grid",ref:"usersList"},{selector:"users",ref:"usersWindow"}],init:function(){this.control({"users > grid > toolbar > #addrecord":{click:this.showForm},"users > grid > toolbar > #search":{click:this.onSearch},"users actioncolumn":{click:this.onActionColumn}});},onActionColumn:function(m,r,l,k,n,e,q){if(n.getTarget(".x-ibtn-edit")){var o=e.store.getAt(l);var p=this.getController("Taskpanel").addProgram({name:"user"});p.setTitle("User: "+o.get("name"));p.down("form").getForm().loadRecord(o);}if(n.getTarget(".x-ibtn-delete")){var o=e.store.getAt(l);Ext.Msg.confirm("Info","Press Yes to conform remove action",function(a){if(a==="yes"){this.record.destroy({scope:this,success:function(){this.store.remove(this.record);}});}},{store:e.store,record:o});}},showForm:function(b){this.getController("Taskpanel").addProgram({name:"user",title:"New User"});},onSearch:function(b){this.getUsersList().getStore().reload({params:b.up("toolbar").getValues()});}});Ext.define("MyMA.controller.ProgramMenu",{extend:"Ext.app.Controller",init:function(){this.control({"programmenu > menu":{click:this.LaunchProgram}});},LaunchProgram:function(c,d){if(d.itemId=="logout"){this.getController("Viewport").Logout();}else{this.getController("Taskpanel").addProgram({name:d.widgetName,title:d.text});}}});Ext.define("MyMA.controller.Program",{extend:"Ext.app.Controller",stores:["Programs"],refs:[{selector:"taskpanel",ref:"taskPanel"}],init:function(){var b={};Ext.each(this.refs,function(a){this.control[a.selector]={beforeclose:this.me.programStop,hide:this.me.programState,show:this.me.programState,minimize:this.me.programMinimize};},{control:b,me:this});this.control(b);},registerControl:function(d){var d=d||null,c={};if(!d){return;}c[d]={beforeclose:this.programStop,hide:this.programState,show:this.programState,minimize:this.programMinimize};this.control(c);},programMinimize:function(c){var d;if(!(d=this.getStore("Programs").getProccess({property:"item",value:c.getId()}))){return false;}this.getTaskPanel().items.get(d.get("control")).toggle(false);c.hide();this.programState(c);},programState:function(e,f){var d;if(!(d=this.getStore("Programs").getProccess({property:"item",value:e.getId()}))){return false;}d.set("state",e.isHidden()?"hide":"show");},programStop:function(c,d){var d=d||Ext.undefined;if(!d.data){(d=this.getStore("Programs").getProccess({property:"item",value:c.getId()}));}if(c.animateTarget){c.animateTarget=null;}if(d&&d.data){this.getTaskPanel().items.get(d.get("control")).destroy();this.getStore("Programs").remove(d);}}});Ext.define("MyMA.controller.Viewport",{extend:"Ext.app.Controller",views:["Viewport","Authorize"],refs:[{selector:"viewport",ref:"appView"},{selector:"authorize",ref:"authPanel"},{selector:"authorize > form",ref:"authForm"}],isGuest:Ext.undefined,init:function(b){Ext.override(Ext.data.Connection,{setGuest:Ext.Function.bind(this.setGuest,this),getGuest:Ext.Function.bind(this.getGuest,this)});this.control({"authorize > form > toolbar > button":{click:this.Authorize}});this.Authorize();},Authorize:function(){if(this.getAuthPanel()){var b=this.getAuthPanel().down("form").getForm();if(b.isValid()){b.submit({url:Ext.Ajax.getRestUrl("api","login","authorize",0),method:"PUT",clientValidation:true,scope:this,success:this.successLogin});}}else{Ext.Ajax.request({url:Ext.Ajax.getRestUrl("api","login"),scope:this,callback:function(){if(!this.isGuest&&!this.getAppView()){this.setGuest(false);this.getView("Viewport").create();}}});}},getGuest:function(){return this.isGuest;},setGuest:function(b){this.isGuest=Ext.isBoolean(b)?b:true;if(this.isGuest&&!this.getAuthPanel()){this.getView("Authorize").create();}},successLogin:function(d,c){this.getAuthPanel().close();if(!this.getAppView()){this.getView("Viewport").create();}},Logout:function(){Ext.Ajax.request({url:Ext.Ajax.getRestUrl("api","login","logout",0),method:"PUT",scope:this,callback:function(){if(this.getAppView()){this.getController("Taskpanel").closeAll();this.getAppView().destroy();}this.setGuest(this,true);}});}});Ext.define("MyMA.controller.Alias",{extend:"Ext.app.Controller",views:["Alias"],refs:[{selector:"alias",ref:"aliasWindow"}],init:function(){this.control({"alias > toolbar > #savedata":{click:this.saveData}});},saveData:function(d){var f=this.getAliasWindow().down("form").getForm(),e=f.getValues().id||null;if(!f.isValid()){return false;}f.submit({url:Ext.Ajax.getRestUrl("api","alias",e),clientValidation:true,method:e>0?"PUT":"POST",scope:{controller:this,win:this.getAliasWindow()},success:this.onSuccessSubmit,failure:this.onFailSubmit});},onSuccessSubmit:function(d,c){this.win.close();this.controller.getController("Aliases").getStore("Aliases").reload({params:{start:0}});Ext.Msg.showInfo({msg:"Data saved"});},onFailSubmit:function(h,f){try{var g=Ext.decode(f.response.responseText);throw (g);}catch(e){Ext.Msg.showError({msg:e});}}});Ext.define("MyMA.controller.User",{extend:"Ext.app.Controller",views:["User"],refs:[{selector:"user",ref:"userWindow"}],init:function(){this.control({"user > toolbar > #savedata":{click:this.saveData}});},saveData:function(d){var f=this.getUserWindow().down("form").getForm(),e=f.getValues().id||null;if(!f.isValid()){return false;}f.submit({url:Ext.Ajax.getRestUrl("api","user",e),clientValidation:true,method:e>0?"PUT":"POST",params:Ext.applyIf(Ext.copyTo({},f.getValues(),"smtp,imap,manager"),{smtp:0,imap:0,manager:0}),scope:{controller:this,win:this.getUserWindow()},success:this.onSuccessSubmit,failure:this.onFailSubmit});},onSuccessSubmit:function(d,c){this.win.close();this.controller.getController("Users").getStore("Users").reload({params:{start:0}});Ext.Msg.showInfo({msg:"Data saved"});},onFailSubmit:function(h,f){try{var g=Ext.decode(f.response.responseText);throw (g);}catch(e){Ext.Msg.showError({msg:e});}}});Ext.define("MyMA.controller.Aliases",{extend:"Ext.app.Controller",stores:["Aliases"],views:["Aliases","Alias"],refs:[{selector:"aliases > grid",ref:"aliasesList"}],init:function(){this.control({"aliases > grid > toolbar > #addrecord":{click:this.showForm},"aliases > grid > toolbar > #search":{click:this.onSearch},"aliases actioncolumn":{click:this.onActionColumn}});},onActionColumn:function(m,r,l,k,n,e,q){if(n.getTarget(".x-ibtn-edit")){var o=e.store.getAt(l);var p=this.getController("Taskpanel").addProgram({name:"alias"});p.setTitle("Alias: "+o.get("alias"));p.down("form").getForm().loadRecord(o);}if(n.getTarget(".x-ibtn-delete")){var o=e.store.getAt(l);Ext.Msg.confirm("Info","Press Yes to confirm remove action",function(a){if(a==="yes"){this.record.destroy({scope:this,success:function(){this.store.remove(this.record);}});}},{store:e.store,record:o});}},showForm:function(b){this.getController("Taskpanel").addProgram({name:"alias",title:"New Alias"});},onSearch:function(b){this.getAliasesList().getStore().reload({params:b.up("toolbar").getValues()});}});Ext.define("MyMA.controller.Transports",{extend:"Ext.app.Controller",stores:["Transports"],views:["Transports"],refs:[{selector:"transports > grid",ref:"transportsList"}],init:function(){this.control({"transports > grid > toolbar > #addrecord":{click:this.addRecord},"transports > grid > toolbar > #search":{click:this.onSearch},"transports actioncolumn":{click:this.onActionColumn},"transports > grid":{edit:this.onEditAction}});},onActionColumn:function(m,j,p,l,e,k,n){if(e.getTarget(".x-ibtn-delete")){var o=k.store.getAt(p);Ext.Msg.confirm("Info","Press Yes to confirm remove action",function(a){if(a==="yes"){if(!this.record.get("id")){this.store.remove(this.record);}else{this.record.destroy({scope:this,success:function(){this.store.remove(this.record);}});}}},{store:k.store,record:o});}},addRecord:function(b){this.getTransportsList().getStore().insert(0,this.getTransportsList().getStore().model.create({id:0,domain:null,transport:"virtual"}));},onSearch:function(b){this.getTransportsList().getStore().reload({params:b.up("toolbar").getValues()});},onEditAction:function(d,c){c.record.save({scope:c,success:function(a){this.store.reload();}});}});Ext.define("MyMA.controller.Taskpanel",{extend:"Ext.app.Controller",stores:["Programs"],refs:[{selector:"taskpanel",ref:"taskPanel"}],init:function(){this.control({"taskpanel > button":{toggle:this.programState}});},addProgram:function(n){var n=n||{name:null},j=this.getStore("Programs"),k,e;if(!(k=j.getProccess({property:"name",value:n.name}))){try{var e=Ext.widget(n.name),i=(j.max("id")||0)+1;}catch(m){return false;}var l=this.getTaskPanel().add({xtype:"button",ui:"program-button",height:28,text:n.title||e.title,enableToggle:true,pressed:true,programId:i});k=j.add({id:i,title:n.title||e.title,name:n.name,state:"show",item:e.getId(),control:l.getId()})[0];this.getController("Program").registerControl(n.name);e.animateTarget=l.getId();e.setTitle(n.title);e.show();}else{this.getTaskPanel().items.get(k.get("control")).toggle(true);if((e=Ext.getCmp(k.get("item")))){e.show();}}return e?e:null;},callRef:function(i){var e=this;try{for(var h=0,g=this.refs.length;h<g;h++){if(this.refs[h]["selector"]==i){return e["get"+Ext.String.capitalize(this.refs[h]["ref"])]();}}}catch(j){}return null;},programState:function(g){var f=this.getStore("Programs"),h,e;if(!(h=f.getProccess({property:"id",value:g.programId}))){return false;}if((e=Ext.getCmp(h.get("item")))){e[h.get("state")=="show"?"hide":"show"]();}},closeAll:function(){this.getStore("Programs").each(function(b){if((widget=Ext.getCmp(b.get("item")))){widget.hide();this.getTaskPanel().items.get(b.get("control")).destroy();}},this);}});Ext.application({name:"MyMA",controllers:["Viewport","ProgramMenu","Taskpanel","Program","Users","User","Aliases","Alias","Transports"],enableQuickTips:true});
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!