Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • smradius/smradius
  • centiva-shail/smradius
  • nkukard/smradius
3 results
Show changes
Showing
with 5050 additions and 1103 deletions
/*
Admin Client Attributes
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminClientAttributesWindow(clientID) {
var AdminClientAttributesWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Attributes",
iconCls: 'silk-table',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add attribute',
iconCls:'silk-table_add',
handler: function() {
showAdminClientAttributeAddEditWindow(AdminClientAttributesWindow,clientID);
}
},
'-',
{
text:'Edit',
tooltip:'Edit attribute',
iconCls:'silk-table_edit',
handler: function() {
var selectedItem = Ext.getCmp(AdminClientAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminClientAttributeAddEditWindow(AdminClientAttributesWindow,clientID,selectedItem.data.ID);
} else {
AdminClientAttributesWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No attribute selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminClientAttributesWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Remove',
tooltip:'Remove attribute',
iconCls:'silk-table_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminClientAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminClientAttributeRemoveWindow(AdminClientAttributesWindow,selectedItem.data.ID);
} else {
AdminClientAttributesWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No attribute selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminClientAttributesWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Name",
sortable: true,
dataIndex: 'Name'
},
{
header: "Operator",
sortable: true,
dataIndex: 'Operator'
},
{
header: "Value",
sortable: true,
dataIndex: 'Value'
},
{
header: "Disabled",
sortable: true,
dataIndex: 'Disabled'
}
]),
autoExpandColumn: 'Name'
},
// Store config
{
baseParams: {
ID: clientID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminClientAttributes',
SOAPFunction: 'getAdminClientAttributes',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'},
{type: 'string', dataIndex: 'Operator'},
{type: 'string', dataIndex: 'Value'},
{type: 'boolean', dataIndex: 'Disabled'}
]
}
);
AdminClientAttributesWindow.show();
}
// Display edit/add form
function showAdminClientAttributeAddEditWindow(AdminClientAttributesWindow,clientID,attrID) {
var submitAjaxConfig;
var icon;
// We doing an update
if (attrID) {
icon = 'silk-table_edit';
submitAjaxConfig = {
params: {
ID: attrID,
SOAPFunction: 'updateAdminClientAttribute',
SOAPParams:
'0:ID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
},
onSuccess: function() {
var store = Ext.getCmp(AdminClientAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-table_add';
submitAjaxConfig = {
params: {
ClientID: clientID,
SOAPFunction: 'addAdminClientAttribute',
SOAPParams:
'0:ClientID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
},
onSuccess: function() {
var store = Ext.getCmp(AdminClientAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
// Create window
var adminClientAttributesFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "Attribute Information",
iconCls: icon,
width: 310,
height: 200,
minWidth: 310,
minHeight: 200
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminClientAttributes'
},
items: [
{
fieldLabel: 'Name',
name: 'Name',
allowBlank: false
},
{
xtype: 'combo',
fieldLabel: 'Operator',
name: 'Operator',
allowBlank: false,
width: 157,
store: [
[ '=', '=' ],
[ ':=', ':=' ],
[ '==', '==' ],
[ '+=', '+=' ],
[ '!=', '!=' ],
[ '<', '<' ],
[ '>', '>' ],
[ '<=', '<=' ],
[ '>=', '>=' ],
[ '=~', '=~' ],
[ '!~', '!~' ],
[ '=*', '=*' ],
[ '!*', '!*' ],
[ '||==', '||==' ]
],
displayField: 'Operator',
valueField: 'Operator',
hiddenName: 'Operator',
forceSelection: false,
triggerAction: 'all',
editable: true
},
{
fieldLabel: "Value",
name: "Value",
allowBlank: false
},
{
xtype: 'checkbox',
fieldLabel: 'Disabled',
name: 'Disabled'
}
]
},
// Submit button config
submitAjaxConfig
);
adminClientAttributesFormWindow.show();
if (attrID) {
Ext.getCmp(adminClientAttributesFormWindow.formPanelID).load({
params: {
ID: attrID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminClientAttributes',
SOAPFunction: 'getAdminClientAttribute',
SOAPParams: 'ID'
}
});
}
}
// Display remove form
function showAdminClientAttributeRemoveWindow(AdminClientAttributesWindow,id) {
// Mask AdminClientAttributesWindow window
AdminClientAttributesWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this attribute?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(AdminClientAttributesWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminClientAttributes',
SOAPFunction: 'removeAdminClientAttribute',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminClientAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
AdminClientAttributesWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
Admin Client Realms
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminClientRealmsWindow(clientID) {
var AdminClientRealmsWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Realms",
iconCls: 'silk-world',
width: 400,
height: 335,
minWidth: 400,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add realm',
iconCls: 'silk-world_add',
handler: function() {
showAdminClientRealmAddWindow(AdminClientRealmsWindow,clientID);
}
},
'-',
{
text:'Remove',
tooltip:'Remove realm',
iconCls: 'silk-world_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminClientRealmsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminClientRealmRemoveWindow(AdminClientRealmsWindow,selectedItem.data.ID);
} else {
AdminClientRealmsWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No realm selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminClientRealmsWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Name",
sortable: true,
dataIndex: 'Name'
}
]),
autoExpandColumn: 'Name'
},
// Store config
{
baseParams: {
ID: clientID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminClientRealms',
SOAPFunction: 'getAdminClientRealms',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'}
]
}
);
AdminClientRealmsWindow.show();
}
// Display edit/add form
function showAdminClientRealmAddWindow(AdminClientRealmsWindow,clientID,id) {
var submitAjaxConfig;
var icon;
// We doing an update
if (id) {
icon = 'silk-world_edit',
submitAjaxConfig = {
params: {
ID: id,
SOAPFunction: 'updateAdminRealm',
SOAPParams:
'0:ID,'+
'0:RealmID'
},
onSuccess: function() {
var store = Ext.getCmp(AdminClientRealmsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-world_add',
submitAjaxConfig = {
params: {
ClientID: clientID,
SOAPFunction: 'addAdminClientRealm',
SOAPParams:
'0:ClientID,'+
'0:RealmID'
},
onSuccess: function() {
var store = Ext.getCmp(AdminClientRealmsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
// Create window
var adminRealmFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "Realm Information",
iconCls: icon,
width: 310,
height: 113,
minWidth: 310,
minHeight: 113
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealms'
},
items: [
{
xtype: 'combo',
//id: 'combo',
fieldLabel: 'Realm',
name: 'Realm',
allowBlank: false,
width: 160,
store: new Ext.ux.JsonStore({
sortInfo: { field: "Name", direction: "ASC" },
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminClientRealms',
SOAPFunction: 'getAdminRealms',
SOAPParams: '__null,__search'
}
}),
displayField: 'Name',
valueField: 'ID',
hiddenName: 'RealmID',
forceSelection: true,
triggerAction: 'all',
editable: false
}
]
},
// Submit button config
submitAjaxConfig
);
adminRealmFormWindow.show();
if (id) {
Ext.getCmp(adminRealmFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealms',
SOAPFunction: 'getAdminRealm',
SOAPParams: 'ID'
}
});
}
}
// Display remove form
function showAdminClientRealmRemoveWindow(AdminClientRealmsWindow,id) {
// Mask AdminClientRealmsWindow window
AdminClientRealmsWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to unlink this realm?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(AdminClientRealmsWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminClientRealms',
SOAPFunction: 'removeAdminClientRealm',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminClientRealmsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
AdminClientRealmsWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
Admin Clients
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminClientWindow() {
var AdminClientWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Clients",
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add client',
iconCls:'silk-server_add',
handler: function() {
showAdminClientAddEditWindow(AdminClientWindow);
}
},
'-',
{
text:'Edit',
tooltip:'Edit client',
iconCls:'silk-server_edit',
handler: function() {
var selectedItem = Ext.getCmp(AdminClientWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminClientAddEditWindow(AdminClientWindow,selectedItem.data.ID);
} else {
AdminClientWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No client selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminClientWindow.getEl().unmask();
}
});
}
}
},
{
text:'Remove',
tooltip:'Remove client',
iconCls:'silk-server_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminClientWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminClientRemoveWindow(AdminClientWindow,selectedItem.data.ID);
} else {
AdminClientWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No client selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminClientWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Attributes',
tooltip:'Client attributes',
iconCls:'silk-table',
handler: function() {
var selectedItem = Ext.getCmp(AdminClientWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminClientAttributesWindow(selectedItem.data.ID);
} else {
AdminClientWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No client selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminClientWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Realms',
tooltip:'Realms',
iconCls:'silk-world',
handler: function() {
var selectedItem = Ext.getCmp(AdminClientWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminClientRealmsWindow(selectedItem.data.ID);
} else {
AdminClientWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No client selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminClientWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Name",
sortable: true,
dataIndex: 'Name'
},
{
header: "AccessList",
sortable: true,
dataIndex: 'AccessList'
}
]),
autoExpandColumn: 'Name'
},
// Store config
{
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminClients',
SOAPFunction: 'getAdminClients',
SOAPParams: '__null,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'},
{type: 'string', dataIndex: 'AccessList'}
]
}
);
AdminClientWindow.show();
}
// Display edit/add form
function showAdminClientAddEditWindow(AdminClientWindow,id) {
var submitAjaxConfig;
var icon;
// We doing an update
if (id) {
icon = 'silk-server_edit';
submitAjaxConfig = {
params: {
ID: id,
SOAPFunction: 'updateAdminClient',
SOAPParams:
'0:ID,'+
'0:Name,'+
'0:AccessList'
},
onSuccess: function() {
var store = Ext.getCmp(AdminClientWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-server_add';
submitAjaxConfig = {
params: {
SOAPFunction: 'createAdminClient',
SOAPParams:
'0:Name,'+
'0:AccessList'
},
onSuccess: function() {
var store = Ext.getCmp(AdminClientWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
// Create window
var adminClientFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "Client Information",
iconCls: icon,
width: 310,
height: 143,
minWidth: 310,
minHeight: 143
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminClients'
},
items: [
{
fieldLabel: 'Name',
name: 'Name',
allowBlank: false
},
{
fieldLabel: 'AccessList',
name: 'AccessList',
allowBlank: true
}
]
},
// Submit button config
submitAjaxConfig
);
adminClientFormWindow.show();
if (id) {
Ext.getCmp(adminClientFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminClients',
SOAPFunction: 'getAdminClient',
SOAPParams: 'ID'
}
});
}
}
// Display remove form
function showAdminClientRemoveWindow(AdminClientWindow,id) {
// Mask AdminClientWindow window
AdminClientWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this client?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(AdminClientWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminClients',
SOAPFunction: 'removeAdminClient',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminClientWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
AdminClientWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
Admin Group Attributes
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminGroupAttributesWindow(groupID) {
var AdminGroupAttributesWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Attributes",
iconCls: 'silk-table',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add attribute',
iconCls:'silk-table_add',
handler: function() {
showAdminGroupAttributeAddEditWindow(AdminGroupAttributesWindow,groupID);
}
},
'-',
{
text:'Edit',
tooltip:'Edit attribute',
iconCls:'silk-table_edit',
handler: function() {
var selectedItem = Ext.getCmp(AdminGroupAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminGroupAttributeAddEditWindow(AdminGroupAttributesWindow,groupID,selectedItem.data.ID);
} else {
AdminGroupAttributesWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No attribute selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminGroupAttributesWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Remove',
tooltip:'Remove attribute',
iconCls:'silk-table_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminGroupAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminGroupAttributeRemoveWindow(AdminGroupAttributesWindow,selectedItem.data.ID);
} else {
AdminGroupAttributesWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No attribute selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminGroupAttributesWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Name",
sortable: true,
dataIndex: 'Name'
},
{
header: "Operator",
sortable: true,
dataIndex: 'Operator'
},
{
header: "Value",
sortable: true,
dataIndex: 'Value'
},
{
header: "Disabled",
sortable: true,
dataIndex: 'Disabled'
}
]),
autoExpandColumn: 'Name'
},
// Store config
{
baseParams: {
ID: groupID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroupAttributes',
SOAPFunction: 'getAdminGroupAttributes',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'},
{type: 'string', dataIndex: 'Operator'},
{type: 'string', dataIndex: 'Value'},
{type: 'boolean', dataIndex: 'Disabled'}
]
}
);
AdminGroupAttributesWindow.show();
}
// Display edit/add form
function showAdminGroupAttributeAddEditWindow(AdminGroupAttributesWindow,groupID,attrID) {
var submitAjaxConfig;
var icon;
// We doing an update
if (attrID) {
icon = 'silk-table_edit';
submitAjaxConfig = {
params: {
ID: attrID,
SOAPFunction: 'updateAdminGroupAttribute',
SOAPParams:
'0:ID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
},
onSuccess: function() {
var store = Ext.getCmp(AdminGroupAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-table_add';
submitAjaxConfig = {
params: {
GroupID: groupID,
SOAPFunction: 'addAdminGroupAttribute',
SOAPParams:
'0:GroupID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
},
onSuccess: function() {
var store = Ext.getCmp(AdminGroupAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
// Create window
var adminGroupAttributesFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "Attribute Information",
iconCls: icon,
width: 310,
height: 200,
minWidth: 310,
minHeight: 200
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroupAttributes'
},
items: [
{
fieldLabel: 'Name',
name: 'Name',
allowBlank: false
},
{
xtype: 'combo',
fieldLabel: 'Operator',
name: 'Operator',
allowBlank: false,
width: 157,
store: [
[ '=', '=' ],
[ ':=', ':=' ],
[ '==', '==' ],
[ '+=', '+=' ],
[ '!=', '!=' ],
[ '<', '<' ],
[ '>', '>' ],
[ '<=', '<=' ],
[ '>=', '>=' ],
[ '=~', '=~' ],
[ '!~', '!~' ],
[ '=*', '=*' ],
[ '!*', '!*' ],
[ '||==', '||==' ]
],
displayField: 'Operator',
valueField: 'Operator',
hiddenName: 'Operator',
forceSelection: false,
triggerAction: 'all',
editable: true
},
{
fieldLabel: "Value",
name: "Value",
allowBlank: false
},
{
xtype: 'checkbox',
fieldLabel: 'Disabled',
name: 'Disabled'
}
]
},
// Submit button config
submitAjaxConfig
);
adminGroupAttributesFormWindow.show();
if (attrID) {
Ext.getCmp(adminGroupAttributesFormWindow.formPanelID).load({
params: {
ID: attrID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroupAttributes',
SOAPFunction: 'getAdminGroupAttribute',
SOAPParams: 'ID'
}
});
}
}
// Display remove form
function showAdminGroupAttributeRemoveWindow(AdminGroupAttributesWindow,id) {
// Mask AdminGroupAttributesWindow window
AdminGroupAttributesWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this attribute?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(AdminGroupAttributesWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroupAttributes',
SOAPFunction: 'removeAdminGroupAttribute',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminGroupAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
AdminGroupAttributesWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
Admin Group Members
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminGroupMembersWindow(groupID) {
var AdminGroupMembersWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Members",
iconCls: 'silk-user',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Remove',
tooltip:'Remove member',
iconCls:'silk-user_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminGroupMembersWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminGroupMemberRemoveWindow(AdminGroupMembersWindow,selectedItem.data.ID);
} else {
AdminGroupMembersWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No member selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminGroupMembersWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Username",
sortable: true,
dataIndex: 'Username'
},
{
header: "Disabled",
sortable: true,
dataIndex: 'Disabled'
}
]),
autoExpandColumn: 'Username'
},
// Store config
{
baseParams: {
ID: groupID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroupMembers',
SOAPFunction: 'getAdminGroupMembers',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Username'},
{type: 'boolean', dataIndex: 'Disabled'}
]
}
);
AdminGroupMembersWindow.show();
}
// Display remove form
function showAdminGroupMemberRemoveWindow(AdminGroupMembersWindow,id) {
// Mask AdminGroupMembersWindow window
AdminGroupMembersWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this member?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(AdminGroupMembersWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroupMembers',
SOAPFunction: 'removeAdminGroupMember',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminGroupMembersWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
AdminGroupMembersWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
Admin Groups
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminGroupWindow() { function showAdminGroupWindow() {
...@@ -6,12 +24,13 @@ function showAdminGroupWindow() { ...@@ -6,12 +24,13 @@ function showAdminGroupWindow() {
// Window config // Window config
{ {
title: "Groups", title: "Groups",
iconCls: 'silk-group',
width: 600, width: 600,
height: 335, height: 335,
minWidth: 600, minWidth: 600,
minHeight: 335, minHeight: 335
}, },
// Grid config // Grid config
{ {
...@@ -20,22 +39,50 @@ function showAdminGroupWindow() { ...@@ -20,22 +39,50 @@ function showAdminGroupWindow() {
{ {
text:'Add', text:'Add',
tooltip:'Add group', tooltip:'Add group',
iconCls:'add', iconCls:'silk-group_add',
handler: function() { handler: function() {
showAdminGroupEditWindow(); showAdminGroupAddEditWindow(AdminGroupWindow);
} }
}, },
'-', '-',
{
text:'Edit',
tooltip:'Edit group',
iconCls:'silk-group_edit',
handler: function() {
var selectedItem = Ext.getCmp(AdminGroupWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminGroupAddEditWindow(AdminGroupWindow,selectedItem.data.ID);
} else {
AdminGroupWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No group selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminGroupWindow.getEl().unmask();
}
});
}
}
},
'-',
{ {
text:'Remove', text:'Remove',
tooltip:'Remove group', tooltip:'Remove group',
iconCls:'remove', iconCls:'silk-group_delete',
handler: function() { handler: function() {
var selectedItem = AdminGroupWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(AdminGroupWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
showAdminGroupRemoveWindow(WiSPUserWindow,selectedItem.data.ID); showAdminGroupRemoveWindow(AdminGroupWindow,selectedItem.data.ID);
} else { } else {
AdminGroupWindow.getEl().mask(); AdminGroupWindow.getEl().mask();
...@@ -57,9 +104,9 @@ function showAdminGroupWindow() { ...@@ -57,9 +104,9 @@ function showAdminGroupWindow() {
{ {
text:'Attributes', text:'Attributes',
tooltip:'Group attributes', tooltip:'Group attributes',
iconCls:'logs', iconCls:'silk-table',
handler: function() { handler: function() {
var selectedItem = AdminGroupWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(AdminGroupWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -85,9 +132,9 @@ function showAdminGroupWindow() { ...@@ -85,9 +132,9 @@ function showAdminGroupWindow() {
{ {
text:'Members', text:'Members',
tooltip:'Group members', tooltip:'Group members',
iconCls:'topups', iconCls:'silk-group',
handler: function() { handler: function() {
var selectedItem = AdminGroupWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(AdminGroupWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -169,224 +216,99 @@ function showAdminGroupWindow() { ...@@ -169,224 +216,99 @@ function showAdminGroupWindow() {
// Display edit/add form // Display edit/add form
function showAdminGroupEditWindow(id) { function showAdminGroupAddEditWindow(AdminGroupWindow,id) {
var submitAjaxConfig; var submitAjaxConfig;
var editMode; var icon;
// We doing an update // We doing an update
if (id) { if (id) {
icon = 'silk-group_edit';
submitAjaxConfig = { submitAjaxConfig = {
ID: id, params: {
SOAPFunction: 'updateAdminGroup', ID: id,
SOAPParams: SOAPFunction: 'updateAdminGroup',
'0:ID,'+ SOAPParams:
'0:UsageCap,'+ '0:ID,'+
'0:AgentRef,'+ '0:Name'
'0:AgentDisabled:boolean' },
onSuccess: function() {
var store = Ext.getCmp(AdminGroupWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
}; };
editMode = true;
// We doing an Add // We doing an Add
} else { } else {
icon = 'silk-group_add';
submitAjaxConfig = { submitAjaxConfig = {
SOAPFunction: 'createAdminGroup', params: {
SOAPParams: SOAPFunction: 'createAdminGroup',
'0:AgentID,'+ SOAPParams:
'0:GroupName,'+ '0:Name'
'0:UsageCap,'+ },
'0:AgentRef,'+ onSuccess: function() {
'0:AgentDisabled:boolean' var store = Ext.getCmp(AdminGroupWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
}; };
editMode = false;
} }
// Service store
var serviceStore = new Ext.ux.JsonStore({
ID: id,
sortInfo: { field: "Name", direction: "ASC" },
baseParams: {
SOAPGroupname: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroups',
SOAPFunction: 'getClasses',
AgentID: 1,
SOAPParams: '0:AgentID,__search'
}
});
// Create window // Create window
var wispGroupFormWindow = new Ext.ux.GenericFormWindow( var adminGroupFormWindow = new Ext.ux.GenericFormWindow(
// Window config // Window config
{ {
title: "Group Information", title: "Group Information",
iconCls: icon,
width: 475, width: 310,
height: 260, height: 113,
minWidth: 475, minWidth: 310,
minHeight: 260 minHeight: 113
}, },
// Form panel config // Form panel config
{ {
labelWidth: 85, labelWidth: 85,
baseParams: { baseParams: {
SOAPGroupname: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroups' SOAPModule: 'AdminGroups'
}, },
items: [ items: [
{ {
fieldLabel: 'Groupname', fieldLabel: 'Name',
name: 'Groupname', name: 'Name',
vtype: 'usernamePart', allowBlank: false
maskRe: usernamePartRe, }
allowBlank: false, ]
disabled: editMode
},
{
xtype: 'combo',
// We use an ID so we can get the box later
id: 'agent_combobox',
fieldLabel: 'Agent',
name: 'Agent',
allowBlank: false,
width: 225,
store: new Ext.ux.JsonStore({
ID: id,
sortInfo: { field: "Name", direction: "ASC" },
baseParams: {
SOAPGroupname: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'Agents',
SOAPFunction: 'getAgents',
SOAPParams: '__search'
}
}),
displayField: 'Name',
valueField: 'ID',
hiddenName: 'AgentID',
forceSelection: false,
triggerAction: 'all',
editable: false,
disabled: editMode
},
{
xtype: 'combo',
// We use an ID so we can get the box later
id: 'service_combobox',
fieldLabel: 'Service',
name: 'Service',
allowBlank: false,
width: 340,
store: serviceStore,
displayField: 'Service',
valueField: 'ID',
hiddenName: 'ClassID',
forceSelection: false,
triggerAction: 'all',
editable: false,
disabled: true
},
{
fieldLabel: 'Usage Cap',
name: 'UsageCap',
},
{
fieldLabel: 'Agent Ref',
name: 'AgentRef'
},
{
xtype: 'checkbox',
fieldLabel: 'Disabled',
name: 'AgentDisabled'
}/*,
{
xtype: 'tabpanel',
plain: 'true',
deferredRender: false, // Load all panels!
activeTab: 0,
height: 100,
defaults: {
layout: 'form',
bodyStyle: 'padding: 10px;'
},
items: [
{
title: 'Policy Settings',
layout: 'form',
defaultType: 'textfield',
items: [
{
fieldLabel: 'Transport Policy',
name: 'Policy',
vtype: 'number',
value: '1'
}
]
}
]
}*/
],
}, },
// Submit button config // Submit button config
submitAjaxConfig submitAjaxConfig
); );
// Events adminGroupFormWindow.show();
if (!id) {
wispGroupFormWindow.findById('agent_combobox').on({
select: {
fn: function() {
var tb = this.ownerCt.findById('service_combobox');
if (this.getValue()) {
tb.reset();
serviceStore.baseParams.AgentID = this.getValue();
serviceStore.reload();
tb.enable();
} else {
tb.reset();
tb.disable();
}
}
},
});
}
wispGroupFormWindow.show();
if (id) { if (id) {
wispGroupFormWindow.getComponent('formpanel').load({ Ext.getCmp(adminGroupFormWindow.formPanelID).load({
params: { params: {
id: id, ID: id,
SOAPGroupname: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroups', SOAPModule: 'AdminGroups',
SOAPFunction: 'getAdminGroups', SOAPFunction: 'getAdminGroup',
SOAPParams: 'id' SOAPParams: 'ID'
} }
}); });
} }
...@@ -395,15 +317,15 @@ function showAdminGroupEditWindow(id) { ...@@ -395,15 +317,15 @@ function showAdminGroupEditWindow(id) {
// Display edit/add form // Display remove form
function showAdminGroupRemoveWindow(parent,id) { function showAdminGroupRemoveWindow(AdminGroupWindow,id) {
// Mask parent window // Mask AdminGroupWindow window
parent.getEl().mask(); AdminGroupWindow.getEl().mask();
// Display remove confirm window // Display remove confirm window
Ext.Msg.show({ Ext.Msg.show({
title: "Confirm removal", title: "Confirm removal",
msg: "Are you very sure you wish to remove this user?", msg: "Are you very sure you wish to remove this group?",
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO, buttons: Ext.Msg.YESNO,
modal: false, modal: false,
...@@ -412,33 +334,34 @@ function showAdminGroupRemoveWindow(parent,id) { ...@@ -412,33 +334,34 @@ function showAdminGroupRemoveWindow(parent,id) {
if (buttonId == 'yes') { if (buttonId == 'yes') {
// Do ajax request // Do ajax request
uxAjaxRequest(parent,{ uxAjaxRequest(AdminGroupWindow,{
params: { params: {
id: id, ID: id,
SOAPGroupname: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroups', SOAPModule: 'AdminGroups',
SOAPFunction: 'removeAdminGroup', SOAPFunction: 'removeAdminGroup',
SOAPParams: 'id' SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminGroupWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
} }
}); });
// Unmask if user answered no // Unmask if user answered no
} else { } else {
parent.getEl().unmask(); AdminGroupWindow.getEl().unmask();
} }
} }
}); });
} }
// vim: ts=4
/*
Admin Realm Attributes
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminRealmAttributesWindow(realmID) {
var AdminRealmAttributesWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Attributes",
iconCls: 'silk-table',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add attribute',
iconCls:'silk-table_add',
handler: function() {
showAdminRealmAttributeAddEditWindow(AdminRealmAttributesWindow,realmID);
}
},
'-',
{
text:'Edit',
tooltip:'Edit attribute',
iconCls:'silk-table_edit',
handler: function() {
var selectedItem = Ext.getCmp(AdminRealmAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminRealmAttributeAddEditWindow(AdminRealmAttributesWindow,realmID,selectedItem.data.ID);
} else {
AdminRealmAttributesWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No attribute selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminRealmAttributesWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Remove',
tooltip:'Remove attribute',
iconCls:'silk-table_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminRealmAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminRealmAttributeRemoveWindow(AdminRealmAttributesWindow,selectedItem.data.ID);
} else {
AdminRealmAttributesWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No attribute selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminRealmAttributesWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Name",
sortable: true,
dataIndex: 'Name'
},
{
header: "Operator",
sortable: true,
dataIndex: 'Operator'
},
{
header: "Value",
sortable: true,
dataIndex: 'Value'
},
{
header: "Disabled",
sortable: true,
dataIndex: 'Disabled'
}
]),
autoExpandColumn: 'Name'
},
// Store config
{
baseParams: {
ID: realmID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealmAttributes',
SOAPFunction: 'getAdminRealmAttributes',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'},
{type: 'string', dataIndex: 'Operator'},
{type: 'string', dataIndex: 'Value'},
{type: 'boolean', dataIndex: 'Disabled'}
]
}
);
AdminRealmAttributesWindow.show();
}
// Display edit/add form
function showAdminRealmAttributeAddEditWindow(AdminRealmAttributesWindow,realmID,attrID) {
var submitAjaxConfig;
var icon;
// We doing an update
if (attrID) {
icon = 'silk-table_edit';
submitAjaxConfig = {
params: {
ID: attrID,
SOAPFunction: 'updateAdminRealmAttribute',
SOAPParams:
'0:ID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
},
onSuccess: function() {
var store = Ext.getCmp(AdminRealmAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-table_add';
submitAjaxConfig = {
params: {
RealmID: realmID,
SOAPFunction: 'addAdminRealmAttribute',
SOAPParams:
'0:RealmID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
},
onSuccess: function() {
var store = Ext.getCmp(AdminRealmAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
// Create window
var adminRealmAttributesFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "Attribute Information",
iconCls: icon,
width: 310,
height: 200,
minWidth: 310,
minHeight: 200
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealmAttributes'
},
items: [
{
fieldLabel: 'Name',
name: 'Name',
allowBlank: false
},
{
xtype: 'combo',
fieldLabel: 'Operator',
name: 'Operator',
allowBlank: false,
width: 157,
store: [
[ '=', '=' ],
[ ':=', ':=' ],
[ '==', '==' ],
[ '+=', '+=' ],
[ '!=', '!=' ],
[ '<', '<' ],
[ '>', '>' ],
[ '<=', '<=' ],
[ '>=', '>=' ],
[ '=~', '=~' ],
[ '!~', '!~' ],
[ '=*', '=*' ],
[ '!*', '!*' ],
[ '||==', '||==' ]
],
displayField: 'Operator',
valueField: 'Operator',
hiddenName: 'Operator',
forceSelection: false,
triggerAction: 'all',
editable: true
},
{
fieldLabel: "Value",
name: "Value",
allowBlank: false
},
{
xtype: 'checkbox',
fieldLabel: 'Disabled',
name: 'Disabled'
}
]
},
// Submit button config
submitAjaxConfig
);
adminRealmAttributesFormWindow.show();
if (attrID) {
Ext.getCmp(adminRealmAttributesFormWindow.formPanelID).load({
params: {
ID: attrID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealmAttributes',
SOAPFunction: 'getAdminRealmAttribute',
SOAPParams: 'ID'
}
});
}
}
// Display remove form
function showAdminRealmAttributeRemoveWindow(AdminRealmAttributesWindow,id) {
// Mask AdminRealmAttributesWindow window
AdminRealmAttributesWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this attribute?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(AdminRealmAttributesWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealmAttributes',
SOAPFunction: 'removeAdminRealmAttribute',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminRealmAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
AdminRealmAttributesWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
Admin Realm Members
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminRealmMembersWindow(realmID) {
var AdminRealmMembersWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Members",
iconCls: 'silk-server',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Remove',
tooltip:'Remove member',
iconCls:'silk-server_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminRealmMembersWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminRealmMemberRemoveWindow(AdminRealmMembersWindow,selectedItem.data.ID);
} else {
AdminRealmMembersWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No member selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminRealmMembersWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Name",
sortable: true,
dataIndex: 'Name'
}
]),
autoExpandColumn: 'Name'
},
// Store config
{
baseParams: {
ID: realmID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealmMembers',
SOAPFunction: 'getAdminRealmMembers',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'}
]
}
);
AdminRealmMembersWindow.show();
}
// Display remove form
function showAdminRealmMemberRemoveWindow(AdminRealmMembersWindow,id) {
// Mask AdminRealmMembersWindow window
AdminRealmMembersWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this member?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(AdminRealmMembersWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealmMembers',
SOAPFunction: 'removeAdminRealmMember',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminRealmMembersWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
AdminRealmMembersWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
Admin Realms
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminRealmWindow() { function showAdminRealmWindow() {
...@@ -6,12 +24,13 @@ function showAdminRealmWindow() { ...@@ -6,12 +24,13 @@ function showAdminRealmWindow() {
// Window config // Window config
{ {
title: "Realms", title: "Realms",
iconCls: 'silk-world',
width: 600, width: 600,
height: 335, height: 335,
minWidth: 600, minWidth: 600,
minHeight: 335, minHeight: 335
}, },
// Grid config // Grid config
{ {
...@@ -20,18 +39,46 @@ function showAdminRealmWindow() { ...@@ -20,18 +39,46 @@ function showAdminRealmWindow() {
{ {
text:'Add', text:'Add',
tooltip:'Add realm', tooltip:'Add realm',
iconCls:'add', iconCls:'silk-world_add',
handler: function() { handler: function() {
showAdminRealmAddWindow(); showAdminRealmAddEditWindow(AdminRealmWindow);
} }
}, },
'-', '-',
{
text:'Edit',
tooltip:'Edit realm',
iconCls:'silk-world_edit',
handler: function() {
var selectedItem = Ext.getCmp(AdminRealmWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminRealmAddEditWindow(AdminRealmWindow,selectedItem.data.ID);
} else {
AdminRealmWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No realm selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminRealmWindow.getEl().unmask();
}
});
}
}
},
'-',
{ {
text:'Remove', text:'Remove',
tooltip:'Remove realm', tooltip:'Remove realm',
iconCls:'remove', iconCls:'silk-world_delete',
handler: function() { handler: function() {
var selectedItem = AdminRealmWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(AdminRealmWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -54,12 +101,40 @@ function showAdminRealmWindow() { ...@@ -54,12 +101,40 @@ function showAdminRealmWindow() {
} }
}, },
'-', '-',
{
text:'Attributes',
tooltip:'Realm attributes',
iconCls:'silk-table',
handler: function() {
var selectedItem = Ext.getCmp(AdminRealmWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminRealmAttributesWindow(selectedItem.data.ID);
} else {
AdminRealmWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No realm selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminRealmWindow.getEl().unmask();
}
});
}
}
},
'-',
{ {
text:'Members', text:'Members',
tooltip:'Realm members', tooltip:'Realm members',
iconCls:'logs', iconCls:'silk-server',
handler: function() { handler: function() {
var selectedItem = AdminRealmWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(AdminRealmWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -101,7 +176,7 @@ function showAdminRealmWindow() { ...@@ -101,7 +176,7 @@ function showAdminRealmWindow() {
dataIndex: 'Disabled' dataIndex: 'Disabled'
} }
]), ]),
autoExpandColumn: 'Service' autoExpandColumn: 'Name'
}, },
// Store config // Store config
{ {
...@@ -118,7 +193,7 @@ function showAdminRealmWindow() { ...@@ -118,7 +193,7 @@ function showAdminRealmWindow() {
{ {
filters: [ filters: [
{type: 'numeric', dataIndex: 'ID'}, {type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Realmname'}, {type: 'string', dataIndex: 'Name'},
{type: 'boolean', dataIndex: 'Disabled'} {type: 'boolean', dataIndex: 'Disabled'}
] ]
} }
...@@ -129,65 +204,65 @@ function showAdminRealmWindow() { ...@@ -129,65 +204,65 @@ function showAdminRealmWindow() {
// Display edit/add form // Display edit/add form
function showAdminRealmEditWindow(id) { function showAdminRealmAddEditWindow(AdminRealmWindow,id) {
var submitAjaxConfig; var submitAjaxConfig;
var editMode; var icon;
// We doing an update // We doing an update
if (id) { if (id) {
icon = 'silk-world_edit';
submitAjaxConfig = { submitAjaxConfig = {
ID: id, params: {
SOAPFunction: 'updateAdminRealm', ID: id,
SOAPParams: SOAPFunction: 'updateAdminRealm',
'0:ID,'+ SOAPParams:
'0:UsageCap,'+ '0:ID,'+
'0:AgentRef,'+ '0:Name'
'0:AgentDisabled:boolean' },
onSuccess: function() {
var store = Ext.getCmp(AdminRealmWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
}; };
editMode = true;
// We doing an Add // We doing an Add
} else { } else {
icon = 'silk-world_add';
submitAjaxConfig = { submitAjaxConfig = {
SOAPFunction: 'createAdminRealm', params: {
SOAPParams: SOAPFunction: 'createAdminRealm',
'0:AgentID,'+ SOAPParams:
'0:RealmName,'+ '0:Name'
'0:UsageCap,'+ },
'0:AgentRef,'+ onSuccess: function() {
'0:AgentDisabled:boolean' var store = Ext.getCmp(AdminRealmWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
}; };
editMode = false;
} }
// Service store
var serviceStore = new Ext.ux.JsonStore({
ID: id,
sortInfo: { field: "Name", direction: "ASC" },
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealms',
SOAPFunction: 'getClasses',
AgentID: 1,
SOAPParams: '0:AgentID,__search'
}
});
// Create window // Create window
var adminRealmFormWindow = new Ext.ux.GenericFormWindow( var adminRealmFormWindow = new Ext.ux.GenericFormWindow(
// Window config // Window config
{ {
title: "Realm Information", title: "Realm Information",
iconCls: icon,
width: 475, width: 310,
height: 260, height: 113,
minWidth: 475, minWidth: 310,
minHeight: 260 minHeight: 113
}, },
// Form panel config // Form panel config
{ {
...@@ -200,153 +275,28 @@ function showAdminRealmEditWindow(id) { ...@@ -200,153 +275,28 @@ function showAdminRealmEditWindow(id) {
}, },
items: [ items: [
{ {
fieldLabel: 'Realmname', fieldLabel: 'Name',
name: 'Realmname', name: 'Name',
vtype: 'usernamePart', allowBlank: false
maskRe: usernamePartRe, }
allowBlank: false, ]
disabled: editMode
},
{
xtype: 'combo',
// We use an ID so we can get the box later
id: 'agent_combobox',
fieldLabel: 'Agent',
name: 'Agent',
allowBlank: false,
width: 225,
store: new Ext.ux.JsonStore({
ID: id,
sortInfo: { field: "Name", direction: "ASC" },
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'Agents',
SOAPFunction: 'getAgents',
SOAPParams: '__search'
}
}),
displayField: 'Name',
valueField: 'ID',
hiddenName: 'AgentID',
forceSelection: false,
triggerAction: 'all',
editable: false,
disabled: editMode
},
{
xtype: 'combo',
// We use an ID so we can get the box later
id: 'service_combobox',
fieldLabel: 'Service',
name: 'Service',
allowBlank: false,
width: 340,
store: serviceStore,
displayField: 'Service',
valueField: 'ID',
hiddenName: 'ClassID',
forceSelection: false,
triggerAction: 'all',
editable: false,
disabled: true
},
{
fieldLabel: 'Usage Cap',
name: 'UsageCap',
},
{
fieldLabel: 'Agent Ref',
name: 'AgentRef'
},
{
xtype: 'checkbox',
fieldLabel: 'Disabled',
name: 'AgentDisabled'
}/*,
{
xtype: 'tabpanel',
plain: 'true',
deferredRender: false, // Load all panels!
activeTab: 0,
height: 100,
defaults: {
layout: 'form',
bodyStyle: 'padding: 10px;'
},
items: [
{
title: 'Policy Settings',
layout: 'form',
defaultType: 'textfield',
items: [
{
fieldLabel: 'Transport Policy',
name: 'Policy',
vtype: 'number',
value: '1'
}
]
}
]
}*/
],
}, },
// Submit button config // Submit button config
submitAjaxConfig submitAjaxConfig
); );
// Events
if (!id) {
adminRealmFormWindow.findById('agent_combobox').on({
select: {
fn: function() {
var tb = this.ownerCt.findById('service_combobox');
if (this.getValue()) {
tb.reset();
serviceStore.baseParams.AgentID = this.getValue();
serviceStore.reload();
tb.enable();
} else {
tb.reset();
tb.disable();
}
}
},
});
}
adminRealmFormWindow.show(); adminRealmFormWindow.show();
if (id) { if (id) {
adminRealmFormWindow.getComponent('formpanel').load({ Ext.getCmp(adminRealmFormWindow.formPanelID).load({
params: { params: {
id: id, ID: id,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealms', SOAPModule: 'AdminRealms',
SOAPFunction: 'getAdminRealm', SOAPFunction: 'getAdminRealm',
SOAPParams: 'id' SOAPParams: 'ID'
} }
}); });
} }
...@@ -355,15 +305,15 @@ function showAdminRealmEditWindow(id) { ...@@ -355,15 +305,15 @@ function showAdminRealmEditWindow(id) {
// Display edit/add form // Display remove form
function showAdminRealmRemoveWindow(parent,id) { function showAdminRealmRemoveWindow(AdminRealmWindow,id) {
// Mask parent window // Mask AdminRealmWindow window
parent.getEl().mask(); AdminRealmWindow.getEl().mask();
// Display remove confirm window // Display remove confirm window
Ext.Msg.show({ Ext.Msg.show({
title: "Confirm removal", title: "Confirm removal",
msg: "Are you very sure you wish to remove this user?", msg: "Are you very sure you wish to remove this realm?",
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO, buttons: Ext.Msg.YESNO,
modal: false, modal: false,
...@@ -372,22 +322,30 @@ function showAdminRealmRemoveWindow(parent,id) { ...@@ -372,22 +322,30 @@ function showAdminRealmRemoveWindow(parent,id) {
if (buttonId == 'yes') { if (buttonId == 'yes') {
// Do ajax request // Do ajax request
uxAjaxRequest(parent,{ uxAjaxRequest(AdminRealmWindow,{
params: { params: {
id: id, ID: id,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealms', SOAPModule: 'AdminRealms',
SOAPFunction: 'removeAdminRealm', SOAPFunction: 'removeAdminRealm',
SOAPParams: 'id' SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminRealmWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
} }
}); });
// Unmask if user answered no // Unmask if user answered no
} else { } else {
parent.getEl().unmask(); AdminRealmWindow.getEl().unmask();
} }
} }
}); });
...@@ -402,3 +360,5 @@ function showAdminRealmRemoveWindow(parent,id) { ...@@ -402,3 +360,5 @@ function showAdminRealmRemoveWindow(parent,id) {
// vim: ts=4
/*
Admin User Attributes
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminUserAttributesWindow(userID) {
var AdminUserAttributesWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Attributes",
iconCls: 'silk-table',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add attribute',
iconCls:'silk-table_add',
handler: function() {
showAdminUserAttributeAddEditWindow(AdminUserAttributesWindow,userID);
}
},
'-',
{
text:'Edit',
tooltip:'Edit attribute',
iconCls:'silk-table_edit',
handler: function() {
var selectedItem = Ext.getCmp(AdminUserAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserAttributeAddEditWindow(AdminUserAttributesWindow,userID,selectedItem.data.ID);
} else {
AdminUserAttributesWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No attribute selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminUserAttributesWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Remove',
tooltip:'Remove attribute',
iconCls:'silk-table_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminUserAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserAttributeRemoveWindow(AdminUserAttributesWindow,selectedItem.data.ID);
} else {
AdminUserAttributesWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No attribute selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminUserAttributesWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Name",
sortable: true,
dataIndex: 'Name'
},
{
header: "Operator",
sortable: true,
dataIndex: 'Operator'
},
{
header: "Value",
sortable: true,
dataIndex: 'Value'
},
{
header: "Disabled",
sortable: true,
dataIndex: 'Disabled'
}
]),
autoExpandColumn: 'Name'
},
// Store config
{
baseParams: {
ID: userID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUserAttributes',
SOAPFunction: 'getAdminUserAttributes',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'},
{type: 'string', dataIndex: 'Operator'},
{type: 'string', dataIndex: 'Value'},
{type: 'boolean', dataIndex: 'Disabled'}
]
}
);
AdminUserAttributesWindow.show();
}
// Display edit/add form
function showAdminUserAttributeAddEditWindow(AdminUserAttributesWindow,userID,attrID) {
var submitAjaxConfig;
var icon;
// We doing an update
if (attrID) {
icon = 'silk-table_edit';
submitAjaxConfig = {
params: {
ID: attrID,
SOAPFunction: 'updateAdminUserAttribute',
SOAPParams:
'0:ID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
},
onSuccess: function() {
var store = Ext.getCmp(AdminUserAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-table_add';
submitAjaxConfig = {
params: {
UserID: userID,
SOAPFunction: 'addAdminUserAttribute',
SOAPParams:
'0:UserID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
},
onSuccess: function() {
var store = Ext.getCmp(AdminUserAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
// Create window
var adminGroupFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "Attribute Information",
iconCls: icon,
width: 310,
height: 200,
minWidth: 310,
minHeight: 200
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUserAttributes'
},
items: [
{
fieldLabel: 'Name',
name: 'Name',
//vtype: 'usernamePart',
//maskRe: usernamePartRe,
allowBlank: false
},
{
xtype: 'combo',
fieldLabel: 'Operator',
name: 'Operator',
allowBlank: false,
width: 157,
store: [
[ '=', '=' ],
[ ':=', ':=' ],
[ '==', '==' ],
[ '+=', '+=' ],
[ '!=', '!=' ],
[ '<', '<' ],
[ '>', '>' ],
[ '<=', '<=' ],
[ '>=', '>=' ],
[ '=~', '=~' ],
[ '!~', '!~' ],
[ '=*', '=*' ],
[ '!*', '!*' ],
[ '||==', '||==' ]
],
displayField: 'Operator',
valueField: 'Operator',
hiddenName: 'Operator',
forceSelection: false,
triggerAction: 'all',
editable: true
},
{
fieldLabel: "Value",
name: "Value",
allowBlank: false
},
{
xtype: 'checkbox',
fieldLabel: 'Disabled',
name: 'Disabled'
}
]
},
// Submit button config
submitAjaxConfig
);
adminGroupFormWindow.show();
if (attrID) {
Ext.getCmp(adminGroupFormWindow.formPanelID).load({
params: {
ID: attrID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUserAttributes',
SOAPFunction: 'getAdminUserAttribute',
SOAPParams: 'ID'
}
});
}
}
// Display remove form
function showAdminUserAttributeRemoveWindow(AdminUserAttributesWindow,id) {
// Mask AdminUserAttributesWindow window
AdminUserAttributesWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this attribute?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(AdminUserAttributesWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUserAttributes',
SOAPFunction: 'removeAdminUserAttribute',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminUserAttributesWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
AdminUserAttributesWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
Admin User Groups
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminUserGroupsWindow(userID) {
var AdminUserGroupsWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Groups",
iconCls: 'silk-group',
width: 400,
height: 335,
minWidth: 400,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add group',
iconCls:'silk-group_add',
handler: function() {
showAdminUserGroupAddWindow(AdminUserGroupsWindow,userID);
}
},
'-',
{
text:'Remove',
tooltip:'Remove group',
iconCls:'silk-group_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminUserGroupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserGroupRemoveWindow(AdminUserGroupsWindow,selectedItem.data.ID);
} else {
AdminUserGroupsWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No group selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminUserGroupsWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Name",
sortable: true,
dataIndex: 'Name'
}
]),
autoExpandColumn: 'Name'
},
// Store config
{
baseParams: {
ID: userID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUserGroups',
SOAPFunction: 'getAdminUserGroups',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'}
]
}
);
AdminUserGroupsWindow.show();
}
// Display edit/add form
function showAdminUserGroupAddWindow(AdminUserGroupsWindow,userID,id) {
var submitAjaxConfig;
var icon;
// We doing an update
if (id) {
icon = 'silk-group_edit';
submitAjaxConfig = {
params: {
ID: id,
SOAPFunction: 'updateAdminGroup',
SOAPParams:
'0:ID,'+
'0:GroupID'
},
onSuccess: function() {
var store = Ext.getCmp(AdminUserGroupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-group_add';
submitAjaxConfig = {
params: {
UserID: userID,
SOAPFunction: 'addAdminUserGroup',
SOAPParams:
'0:UserID,'+
'0:GroupID'
},
onSuccess: function() {
var store = Ext.getCmp(AdminUserGroupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
// Create window
var adminGroupFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "Group Information",
iconCls: icon,
width: 310,
height: 113,
minWidth: 310,
minHeight: 113
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroups'
},
items: [
{
xtype: 'combo',
//id: 'combo',
fieldLabel: 'Group',
name: 'Group',
allowBlank: false,
width: 160,
store: new Ext.ux.JsonStore({
sortInfo: { field: "Name", direction: "ASC" },
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUserGroups',
SOAPFunction: 'getAdminGroups',
SOAPParams: '__null,__search'
}
}),
displayField: 'Name',
valueField: 'ID',
hiddenName: 'GroupID',
forceSelection: true,
triggerAction: 'all',
editable: false
}
]
},
// Submit button config
submitAjaxConfig
);
adminGroupFormWindow.show();
if (id) {
Ext.getCmp(adminGroupFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroups',
SOAPFunction: 'getAdminGroup',
SOAPParams: 'ID'
}
});
}
}
// Display edit/add form
function showAdminUserGroupRemoveWindow(AdminUserGroupsWindow,id) {
// Mask AdminUserGroupsWindow window
AdminUserGroupsWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to unlink this group?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(AdminUserGroupsWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUserGroups',
SOAPFunction: 'removeAdminUserGroup',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminUserGroupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
AdminUserGroupsWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
Admin User Logs
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
function showWiSPUserLogsWindow(wispUserID) { This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminUserLogsWindow(id) {
// Calculate dates we going to need // Calculate dates we going to need
var today = new Date(); var today = new Date();
var firstOfMonth = today.getFirstDateOfMonth(); var firstOfMonth = today.getFirstDateOfMonth();
var firstOfNext = today.getLastDateOfMonth().add(Date.DAY, 1); var firstOfNext = today.getLastDateOfMonth().add(Date.DAY, 1);
var wispUserLogsWindow = new Ext.ux.GenericGridWindow( var formID = Ext.id();
var formPeriodKeyID = Ext.id();
var formSearchButtonID = Ext.id();
var summaryFormID = Ext.id();
var summaryTotalID = Ext.id();
var currentPeriod = today.format('Y-m');
var adminUserLogsWindow = new Ext.ux.GenericGridWindow(
// Window config // Window config
{ {
title: 'User Logs', title: 'Logs',
iconCls: 'silk-page_white_text',
layout:'border', layout:'border',
height: 480, height: 480,
width: 700, width: 700,
...@@ -20,66 +48,60 @@ function showWiSPUserLogsWindow(wispUserID) { ...@@ -20,66 +48,60 @@ function showWiSPUserLogsWindow(wispUserID) {
uxItems: [ uxItems: [
{ {
xtype: 'form', xtype: 'form',
id: 'search-form', id: formID,
title: 'Search', title: 'Search',
region: 'west', region: 'west',
border: true, border: true,
frame: true, frame: true,
defaultType: 'datefield',
height: 180, height: 180,
width: 300, width: 320,
labelWidth: 100, labelWidth: 100,
items: [ items: [
{ {
id: 'after', id: formPeriodKeyID,
name: 'after', xtype: 'textfield',
width: 180, name: 'periodkey',
fieldLabel: 'From', regex: /^\d{4}\-(0[1-9]|1(0|1|2))$/,
vtype: 'daterange', regexText: 'Please enter month in the format: YYYY-MM',
format: 'Y-m-d', height: 25,
value: firstOfMonth, width: 100,
endDateField: 'before', fieldLabel: 'Period',
}, value: currentPeriod
{
id: 'before',
name: 'before',
width: 180,
fieldLabel: 'To',
vtype: 'daterange',
format: 'Y-m-d',
value: firstOfNext,
startDateField: 'after'
} }
], ],
buttons: [ buttons: [
{ {
text: 'Search', text: 'Search',
id: 'formbtn', id: formSearchButtonID,
handler: function() { handler: function() {
// Pull in window, grid & form // Pull in window, grid & form
var mainWindow = this.ownerCt.ownerCt; var grid = Ext.getCmp(adminUserLogsWindow.gridPanelID);
var grid = mainWindow.getComponent('gridpanel');
var form = mainWindow.getComponent('search-form');
// Grab store // Grab store
var store = grid.getStore(); var store = grid.getStore();
// Grab timestamp filter // Grab timestamp filter
var gridFilters = grid.filters; var gridFilters = grid.filters;
var timestampFilter = gridFilters.getFilter('Timestamp'); var timestampFilter = gridFilters.getFilter('EventTimestamp');
// Grab form field
var periodKeyField = Ext.getCmp(formPeriodKeyID);
if (periodKeyField.isValid()) {
var periodKeyValue = periodKeyField.getValue();
// Grab form fields // Convert our periodKey into DateTime values
var afterField = form.getForm().findField('after'); var dtSearchStart = Date.parseDate(periodKeyValue+'-01','Y-m-d');
var beforeField = form.getForm().findField('before'); var dtSearchEnd = dtSearchStart.add(Date.MONTH,1);
// Set filter values from form // Set filter values from form
timestampFilter.setValue({ timestampFilter.setValue({
after: afterField.getValue(), after: dtSearchStart,
before: beforeField.getValue() before: dtSearchEnd
}); });
// Trigger store reload // Trigger store reload
store.reload(); store.reload();
}
} }
} }
], ],
...@@ -87,23 +109,24 @@ function showWiSPUserLogsWindow(wispUserID) { ...@@ -87,23 +109,24 @@ function showWiSPUserLogsWindow(wispUserID) {
}, },
{ {
xtype: 'form', xtype: 'form',
id: 'summary-form', id: summaryFormID,
region: 'center', region: 'center',
split: true, split: true,
border: true, border: false,
autoScroll: true, autoScroll: true,
defaultType: 'textarea', defaultType: 'textarea',
height: 180, height: 300,
width: 400, width: 400,
labelWidth: 80, labelWidth: 0,
items: [ items: [
{ {
id: 'summaryTotal', id: summaryTotalID,
name: 'summaryTotal', name: 'summaryTotal',
readOnly: true, readOnly: true,
height: 135, height: 300,
width: 200, width: 400,
fieldLabel: 'Summary', fieldLabel: 'Summary',
hideLabel: true,
fieldClass: 'font-family: monospace; font-size: 10px;', fieldClass: 'font-family: monospace; font-size: 10px;',
value: '' value: ''
} }
...@@ -116,78 +139,53 @@ function showWiSPUserLogsWindow(wispUserID) { ...@@ -116,78 +139,53 @@ function showWiSPUserLogsWindow(wispUserID) {
region: 'south', region: 'south',
width: 700, width: 700,
border: true, border: true,
tbar: [
{
text: 'Add Port Lock',
tooltip: 'Add port lock',
iconCls: 'add'
}
],
// Column model // Column model
colModel: new Ext.grid.ColumnModel([ colModel: new Ext.grid.ColumnModel([
{ {
id: 'ID',
header: "ID", header: "ID",
hidden: true, hidden: true,
dataIndex: 'ID' dataIndex: 'ID'
}, },
{ {
header: "Username", header: "Timestamp",
hidden: true, sortable: true,
dataIndex: 'Username' dataIndex: 'EventTimestamp'
}, },
{ {
header: "Status", header: "Status",
sortable: true, sortable: true,
hidden: true, hidden: true,
dataIndex: 'Status' dataIndex: 'AcctStatusType'
}, },
{ {
header: "Timestamp", header: "Service Type",
sortable: true, sortable: true,
dataIndex: 'Timestamp' dataIndex: 'ServiceType'
},
{
header: "Session ID",
hidden: true,
dataIndex: 'AcctSessionID'
}, },
{ {
header: "Session Time", header: "Framed Protocol",
dataIndex: 'AcctSessionTime' sortable: true,
}, dataIndex: 'FramedProtocol'
{
header: "NAS IP",
hidden: true,
dataIndex: 'NASIPAddress'
}, },
{ {
header: "Port Type", header: "NAS Port Type",
hidden: true, hidden: true,
dataIndex: 'NASPortType' dataIndex: 'NASPortType'
}, },
{
header: "NAS Port",
dataIndex: 'NASPort'
},
{
header: "Called Station",
hidden: true,
dataIndex: 'CalledStationID'
},
{ {
header: "Calling Station", header: "Calling Station",
sortable: true, sortable: true,
dataIndex: 'CallingStationID' dataIndex: 'CallingStationID'
}, },
{ {
header: "NAS Xmit Rate", header: "Called Station",
dataIndex: 'NASTransmitRate' hidden: true,
dataIndex: 'CalledStationID'
}, },
{ {
header: "NAS Recv Rate", header: "Session ID",
hidden: true, hidden: true,
dataIndex: 'NASReceiveRate' dataIndex: 'AcctSessionID'
}, },
{ {
header: "IP Address", header: "IP Address",
...@@ -196,16 +194,17 @@ function showWiSPUserLogsWindow(wispUserID) { ...@@ -196,16 +194,17 @@ function showWiSPUserLogsWindow(wispUserID) {
}, },
{ {
header: "Input Mbyte", header: "Input Mbyte",
dataIndex: 'AcctInputMbyte' dataIndex: 'AcctInput',
renderer: renderUsageFloat
}, },
{ {
header: "Output Mbyte", header: "Output Mbyte",
dataIndex: 'AcctOutputMbyte' dataIndex: 'AcctOutput',
renderer: renderUsageFloat
}, },
{ {
header: "Last Update", header: "Session Uptime",
hidden: true, dataIndex: 'AcctSessionTime'
dataIndex: 'LastAcctUpdate'
}, },
{ {
header: "Term. Reason", header: "Term. Reason",
...@@ -216,72 +215,171 @@ function showWiSPUserLogsWindow(wispUserID) { ...@@ -216,72 +215,171 @@ function showWiSPUserLogsWindow(wispUserID) {
// Store config // Store config
{ {
baseParams: { baseParams: {
ID: id,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers', SOAPModule: 'AdminUserLogs',
SOAPFunction: 'getWiSPUserLogs', SOAPFunction: 'getAdminUserLogs',
SOAPParams: '0:UserID,__search', SOAPParams: 'ID,__search'
UserID: wispUserID
} }
}, },
// Filter config // Filter config
{ {
filters: [ filters: [
{type: 'numeric', dataIndex: 'ID'}, {type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Username'},
{type: 'numeric', dataIndex: 'Status'},
{ {
type: 'date', type: 'date',
dataIndex: 'Timestamp', format: 'Y-m-d H:i:s',
dataIndex: 'EventTimestamp',
value: { value: {
after: firstOfMonth, after: firstOfMonth,
before: firstOfNext before: firstOfNext
} }
}, },
{type: 'numeric', dataIndex: 'AcctStatusType'},
{type: 'string', dataIndex: 'AcctSessionID'}, {type: 'numeric', dataIndex: 'ServiceType'},
{type: 'numeric', dataIndex: 'AcctSessionTime'}, {type: 'numeric', dataIndex: 'FramedProtocol'},
{type: 'numeric', dataIndex: 'NASPortType'},
{type: 'string', dataIndex: 'NASIPAddress'}, {type: 'string', dataIndex: 'NASPortID'},
{type: 'string', dataIndex: 'NASPortType'},
{type: 'string', dataIndex: 'NASPort'},
{type: 'string', dataIndex: 'CalledStationID'},
{type: 'string', dataIndex: 'CallingStationID'}, {type: 'string', dataIndex: 'CallingStationID'},
{type: 'string', dataIndex: 'CalledStationID'},
{type: 'string', dataIndex: 'NASTransmitRate'}, {type: 'string', dataIndex: 'AcctSessionID'},
{type: 'string', dataIndex: 'NASReceiveRate'},
{type: 'string', dataIndex: 'FramedIPAddress'}, {type: 'string', dataIndex: 'FramedIPAddress'},
{type: 'numeric', dataIndex: 'AcctInput'},
{type: 'date', dataIndex: 'LastAcctUpdate'}, {type: 'numeric', dataIndex: 'AcctOutput'},
{type: 'numeric', dataIndex: 'AcctSessionTime'},
{type: 'string', dataIndex: 'ConnectTermReason'} {type: 'string', dataIndex: 'ConnectTermReason'}
] ]
} }
); );
// Grab store // Grab store
var store = wispUserLogsWindow.getComponent('gridpanel').getStore(); var store = Ext.getCmp(adminUserLogsWindow.gridPanelID).getStore();
store.on('load',function() { store.on('load',function() {
var inputTotal = store.sum('AcctInputMbyte');
var outputTotal = store.sum('AcctOutputMbyte');
var userCap = 3000; // Fetch periodKey from form
var userTopups = 1000; var periodKeyField = (Ext.getCmp(formPeriodKeyID)).getValue();
// Total up into this ... // Mask parent window
adminUserLogsWindow.getEl().mask();
var userTotalAllowed = userCap + userTopups;
var userUsage = inputTotal + outputTotal; uxAjaxRequest(
var userLeft = userTotalAllowed - userUsage; adminUserLogsWindow,
{
params: {
PeriodKey: periodKeyField,
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUserLogs',
SOAPFunction: 'getAdminUserLogsSummary',
SOAPParams: '0:ID,0:PeriodKey'
},
customSuccess: function (result) {
response = Ext.decode(result.responseText);
// Caps
var trafficCap = response.data.trafficCap; // value of -1: prepaid
var uptimeCap = response.data.uptimeCap; // value of -1: prepaid
// Usage
var trafficUsage = response.data.trafficUsage;
var uptimeUsage = response.data.uptimeUsage;
// Topups
var trafficTopups = response.data.trafficTopups;
var uptimeTopups = response.data.uptimeTopups;
var totalTrafficTopups = response.data.TotalTrafficTopups;
var totalUptimeTopups = response.data.TotalUptimeTopups;
// Format string before printing
var trafficString = '';
// Prepaid traffic
if (trafficCap == -1) {
trafficCap = 'Prepaid';
trafficString += sprintf('Traffic:\nCap: %s \nTopup balance for current month: %d MB\nTotal Topups: %d MB\nUsage: %d/%d MB\n',
trafficCap,trafficTopups,totalTrafficTopups,trafficUsage,trafficTopups);
trafficString += '---\n';
// Uncapped traffic
} else if (trafficCap == 0) {
trafficString += sprintf('Traffic:\nCap: Uncapped\nUsage: %d MB\n',
trafficUsage);
trafficString += '---\n';
// Capped traffic
} else {
var combinedTrafficCap = trafficCap + trafficTopups;
trafficString += sprintf('Traffic:\nCap: %d MB\nTopup balance for current month: %d MB\nTotal Topups: %d MB\n'+
'Usage: %d/%d MB\n',
trafficCap,trafficTopups,totalTrafficTopups,trafficUsage,combinedTrafficCap);
trafficString += '---\n';
}
// Format string before printing
var uptimeString = '';
// Prepaid uptime
if (uptimeCap == -1) {
uptimeCap = 'Prepaid';
uptimeString += sprintf('Uptime:\nCap: %s \nTopup balance for current month: %d Min\nTotal Topups: %d Min\n'+
'Usage: %d/%d Min\n',
uptimeCap,uptimeTopups,totalUptimeTopups,uptimeUsage,uptimeTopups);
uptimeString += '---\n';
// Uncapped uptime
} else if (uptimeCap == 0) {
uptimeString += sprintf('Uptime:\nCap: Uncapped\nUsage: %d Min\n',
uptimeUsage);
uptimeString += '---\n';
// Capped uptime
} else {
var combinedUptimeCap = uptimeCap + uptimeTopups;
uptimeString += sprintf('Uptime:\nCap: %d Min\nTopup balance for current month: %d Min\nTotal Topups: %d Min\n'+
'Usage: %d/%d Min\n',
uptimeCap,uptimeTopups,totalUptimeTopups,uptimeUsage,combinedUptimeCap);
uptimeString += '---\n';
}
// Topup breakdown
var tTopups = response.data.AllTrafficTopups;
var uTopups = response.data.AllUptimeTopups;
var form = wispUserLogsWindow.getComponent('summary-form'); // Format topups string
var summaryTotal = form.getForm().findField('summaryTotal'); var topupString = '';
if (tTopups.length > 0) {
topupString += 'Valid Traffic Topups:';
}
for (var i = 0; i < tTopups.length; i++) {
var id = tTopups[i].ID;
var used = tTopups[i].Used;
var cap = tTopups[i].Cap;
var validTo = tTopups[i].ValidTo;
topupString += sprintf('\nID: %s\nUsage: %d/%d MB\nValid Until: %s\n--',id,used,cap,validTo);
}
if (uTopups.length > 0) {
topupString += 'Valid Uptime Topups:';
}
for (var i = 0; i < uTopups.length; i++) {
var id = uTopups[i].ID;
var used = uTopups[i].Used;
var cap = uTopups[i].Cap;
var validTo = uTopups[i].ValidTo;
topupString += sprintf('\nID: %s\nUsage: %d/%d MB\nValid Until: %s\n--',id,used,cap,validTo);
}
summaryTotal.setValue( // Get summary field
sprintf('Cap Total: %6d\nTopups : %6d\n-----------------\n %6d\n-----------------\nUsage : %6d\n=================\nAvailable: %6d',userCap,userTopups,userTotalAllowed,userUsage,userLeft) var form = Ext.getCmp(summaryFormID);
var summaryField = Ext.getCmp(summaryTotalID);
summaryField.setValue(trafficString+uptimeString+topupString);
},
failure: function (result) {
Ext.MessageBox.alert('Failed', 'Couldn\'t fetch data: '+result.date);
}
}
); );
}); });
wispUserLogsWindow.show(); adminUserLogsWindow.show();
} }
// vim: ts=4
/*
Admin User Topups
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminUserTopupsWindow(userID) {
var adminUserTopupsWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "User Topups",
iconCls: 'silk-chart_bar',
width: 500,
height: 335,
minWidth: 500,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add topup',
iconCls:'silk-chart_bar_add',
handler: function() {
showAdminUserTopupAddEditWindow(adminUserTopupsWindow,userID,0);
}
},
'-',
{
text:'Edit',
tooltip:'Edit topup',
iconCls:'silk-chart_bar_edit',
handler: function() {
var selectedItem = Ext.getCmp(adminUserTopupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserTopupAddEditWindow(adminUserTopupsWindow,userID,selectedItem.data.ID);
} else {
adminUserTopupsWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No topup selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
adminUserTopupsWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Remove',
tooltip:'Remove topup',
iconCls:'silk-chart_bar_delete',
handler: function() {
var selectedItem = Ext.getCmp(adminUserTopupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserTopupRemoveWindow(adminUserTopupsWindow,selectedItem.data.ID);
} else {
adminUserTopupsWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No topup selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
adminUserTopupsWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
hidden: true,
dataIndex: 'ID'
},
{
header: "Type",
sortable: true,
dataIndex: 'Type'
},
{
header: "Value",
sortable: true,
dataIndex: 'Value'
},
{
header: "Timestamp",
sortable: true,
hidden: true,
dataIndex: 'Timestamp'
},
{
header: "ValidFrom",
sortable: true,
dataIndex: 'ValidFrom'
},
{
header: "ValidTo",
sortable: true,
dataIndex: 'ValidTo'
}
])
},
// Store config
{
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUsers',
SOAPFunction: 'getAdminUserTopups',
SOAPParams: '0:UserID,__search',
UserID: userID
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'date', dataIndex: 'Timestamp'},
{type: 'numeric', dataIndex: 'Value'},
{type: 'date', dataIndex: 'ValidFrom'},
{type: 'date', dataIndex: 'ValidTo'}
]
}
);
adminUserTopupsWindow.show();
}
// Display edit/add form
function showAdminUserTopupAddEditWindow(adminUserTopupsWindow,userID,topupID) {
var today = new Date();
var firstOfMonth = today.getFirstDateOfMonth();
var firstOfNext = today.getLastDateOfMonth().add(Date.DAY, 1);
var submitAjaxConfig;
var icon;
// We doing an update
if (topupID) {
icon = 'silk-chart_bar_edit';
submitAjaxConfig = {
params: {
ID: topupID,
SOAPFunction: 'updateAdminUserTopup',
SOAPParams:
'0:ID,0:Value,0:Type,'+
'0:ValidFrom,0:ValidTo'
},
onSuccess: function() {
var store = Ext.getCmp(adminUserTopupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-chart_bar_add';
submitAjaxConfig = {
params: {
UserID: userID,
SOAPFunction: 'createAdminUserTopup',
SOAPParams:
'0:UserID,0:Value,0:Type,'+
'0:ValidFrom,0:ValidTo'
},
onSuccess: function() {
var store = Ext.getCmp(adminUserTopupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
// Create window
var adminUserTopupFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "Topup Information",
iconCls: icon,
width: 400,
height: 200,
minWidth: 400,
minHeight: 200
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUsers'
},
items: [
{
xtype: 'combo',
fieldLabel: 'Type',
name: 'Type',
allowBlank: false,
width: 157,
store: [
[ '1', 'Traffic' ],
[ '2', 'Uptime' ]
],
displayField: 'Type',
valueField: 'Type',
hiddenName: 'Type',
forceSelection: true,
triggerAction: 'all',
editable: false
},
{
xtype: 'numberfield',
fieldLabel: 'Value',
name: 'Value',
minValue: 1,
allowBlank: false
},
{
xtype: 'datefield',
fieldLabel: 'ValidFrom',
name: 'ValidFrom',
id: 'ValidFrom',
vtype: 'daterange',
disabledDates: ["(0(2|3|4|5|6|7|8|9)|1[0-9]|2[0-9]|3[0-1])$"],
value: firstOfMonth,
format: 'Y-m-d',
endDateField: 'ValidTo'
},
{
xtype: 'datefield',
fieldLabel: 'ValidTo',
name: 'ValidTo',
id: 'ValidTo',
vtype: 'daterange',
disabledDates: ["(0(2|3|4|5|6|7|8|9)|1[0-9]|2[0-9]|3[0-1])$"],
value: firstOfNext,
format: 'Y-m-d',
startDateField: 'ValidFrom'
}
]
},
// Submit button config
submitAjaxConfig
);
adminUserTopupFormWindow.show();
if (topupID) {
Ext.getCmp(adminUserTopupFormWindow.formPanelID).load({
params: {
id: topupID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUsers',
SOAPFunction: 'getAdminUserTopup',
SOAPParams: 'id'
}
});
}
}
// Display edit/add form
function showAdminUserTopupRemoveWindow(adminUserTopupsWindow,id) {
// Mask adminUserTopupsWindow window
adminUserTopupsWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this topup?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(adminUserTopupsWindow,{
params: {
id: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUsers',
SOAPFunction: 'removeAdminUserTopup',
SOAPParams: 'id'
},
customSuccess: function() {
var store = Ext.getCmp(adminUserTopupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
adminUserTopupsWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
Admin Users
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showAdminUserWindow() { function showAdminUserWindow() {
...@@ -6,12 +24,13 @@ function showAdminUserWindow() { ...@@ -6,12 +24,13 @@ function showAdminUserWindow() {
// Window config // Window config
{ {
title: "Users", title: "Users",
iconCls: 'silk-user',
width: 600, width: 600,
height: 335, height: 335,
minWidth: 600, minWidth: 600,
minHeight: 335, minHeight: 335
}, },
// Grid config // Grid config
{ {
...@@ -20,22 +39,22 @@ function showAdminUserWindow() { ...@@ -20,22 +39,22 @@ function showAdminUserWindow() {
{ {
text:'Add', text:'Add',
tooltip:'Add user', tooltip:'Add user',
iconCls:'add', iconCls:'silk-user_add',
handler: function() { handler: function() {
showAdminUserEditWindow(); showAdminUserAddEditWindow(AdminUserWindow);
} }
}, },
'-', '-',
{ {
text:'Edit', text:'Edit',
tooltip:'Edit user', tooltip:'Edit user',
iconCls:'option', iconCls:'silk-user_edit',
handler: function() { handler: function() {
var selectedItem = AdminUserWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
showAdminUserEditWindow(selectedItem.data.ID); showAdminUserAddEditWindow(AdminUserWindow,selectedItem.data.ID);
} else { } else {
AdminUserWindow.getEl().mask(); AdminUserWindow.getEl().mask();
...@@ -57,9 +76,9 @@ function showAdminUserWindow() { ...@@ -57,9 +76,9 @@ function showAdminUserWindow() {
{ {
text:'Remove', text:'Remove',
tooltip:'Remove user', tooltip:'Remove user',
iconCls:'remove', iconCls:'silk-user_delete',
handler: function() { handler: function() {
var selectedItem = AdminUserWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -82,12 +101,40 @@ function showAdminUserWindow() { ...@@ -82,12 +101,40 @@ function showAdminUserWindow() {
} }
}, },
'-', '-',
{
text:'Attributes',
tooltip:'User attributes',
iconCls:'silk-table',
handler: function() {
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserAttributesWindow(selectedItem.data.ID);
} else {
AdminUserWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No user selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminUserWindow.getEl().unmask();
}
});
}
}
},
'-',
{ {
text:'Logs', text:'Logs',
tooltip:'User logs', tooltip:'User logs',
iconCls:'logs', iconCls: 'silk-page_white_text',
handler: function() { handler: function() {
var selectedItem = AdminUserWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -113,9 +160,9 @@ function showAdminUserWindow() { ...@@ -113,9 +160,9 @@ function showAdminUserWindow() {
{ {
text:'Groups', text:'Groups',
tooltip:'User groups', tooltip:'User groups',
iconCls:'topups', iconCls:'silk-group',
handler: function() { handler: function() {
var selectedItem = AdminUserWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -123,6 +170,34 @@ function showAdminUserWindow() { ...@@ -123,6 +170,34 @@ function showAdminUserWindow() {
} else { } else {
AdminUserWindow.getEl().mask(); AdminUserWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No user selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminUserWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Topups',
tooltip:'User topups',
iconCls:'silk-chart_bar',
handler: function() {
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserTopupsWindow(selectedItem.data.ID);
} else {
AdminUserWindow.getEl().mask();
// Display error // Display error
Ext.Msg.show({ Ext.Msg.show({
title: "Nothing selected", title: "Nothing selected",
...@@ -153,11 +228,11 @@ function showAdminUserWindow() { ...@@ -153,11 +228,11 @@ function showAdminUserWindow() {
}, },
{ {
header: "Disabled", header: "Disabled",
sortable: false, sortable: true,
dataIndex: 'Disabled' dataIndex: 'Disabled'
} }
]), ]),
autoExpandColumn: 'Service' autoExpandColumn: 'Username'
}, },
// Store config // Store config
{ {
...@@ -185,65 +260,66 @@ function showAdminUserWindow() { ...@@ -185,65 +260,66 @@ function showAdminUserWindow() {
// Display edit/add form // Display edit/add form
function showAdminUserEditWindow(id) { function showAdminUserAddEditWindow(AdminUserWindow,id) {
var submitAjaxConfig; var submitAjaxConfig;
var editMode; var icon;
// We doing an update // We doing an update
if (id) { if (id) {
icon = 'silk-user_edit';
submitAjaxConfig = { submitAjaxConfig = {
ID: id, params: {
SOAPFunction: 'updateAdminUser', ID: id,
SOAPParams: SOAPFunction: 'updateAdminUser',
'0:ID,'+ SOAPParams:
'0:UsageCap,'+ '0:ID,'+
'0:AgentRef,'+ '0:Username,'+
'0:AgentDisabled:boolean' '0:Disabled'
},
onSuccess: function() {
var store = Ext.getCmp(AdminUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
}; };
editMode = true;
// We doing an Add // We doing an Add
} else { } else {
icon = 'silk-user_add';
submitAjaxConfig = { submitAjaxConfig = {
SOAPFunction: 'createAdminUser', params: {
SOAPParams: SOAPFunction: 'createAdminUser',
'0:AgentID,'+ SOAPParams:
'0:UserName,'+ '0:Username,'+
'0:UsageCap,'+ '0:Disabled'
'0:AgentRef,'+ },
'0:AgentDisabled:boolean' onSuccess: function() {
var store = Ext.getCmp(AdminUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
}; };
editMode = false;
} }
// Service store
var serviceStore = new Ext.ux.JsonStore({
ID: id,
sortInfo: { field: "Name", direction: "ASC" },
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUsers',
SOAPFunction: 'getClasses',
AgentID: 1,
SOAPParams: '0:AgentID,__search'
}
});
// Create window // Create window
var adminUserFormWindow = new Ext.ux.GenericFormWindow( var adminUserFormWindow = new Ext.ux.GenericFormWindow(
// Window config // Window config
{ {
title: "User Information", title: "User Information",
iconCls: icon,
width: 475, width: 310,
height: 260, height: 133,
minWidth: 475, minWidth: 310,
minHeight: 260 minHeight: 133
}, },
// Form panel config // Form panel config
{ {
...@@ -258,151 +334,34 @@ function showAdminUserEditWindow(id) { ...@@ -258,151 +334,34 @@ function showAdminUserEditWindow(id) {
{ {
fieldLabel: 'Username', fieldLabel: 'Username',
name: 'Username', name: 'Username',
vtype: 'usernamePart', vtype: 'usernameRadius',
maskRe: usernamePartRe, maskRe: usernameRadiusPartRe,
allowBlank: false, allowBlank: false
disabled: editMode
},
{
xtype: 'combo',
// We use an ID so we can get the box later
id: 'agent_combobox',
fieldLabel: 'Agent',
name: 'Agent',
allowBlank: false,
width: 225,
store: new Ext.ux.JsonStore({
ID: id,
sortInfo: { field: "Name", direction: "ASC" },
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'Agents',
SOAPFunction: 'getAgents',
SOAPParams: '__search'
}
}),
displayField: 'Name',
valueField: 'ID',
hiddenName: 'AgentID',
forceSelection: false,
triggerAction: 'all',
editable: false,
disabled: editMode
},
{
xtype: 'combo',
// We use an ID so we can get the box later
id: 'service_combobox',
fieldLabel: 'Service',
name: 'Service',
allowBlank: false,
width: 340,
store: serviceStore,
displayField: 'Service',
valueField: 'ID',
hiddenName: 'ClassID',
forceSelection: false,
triggerAction: 'all',
editable: false,
disabled: true
},
{
fieldLabel: 'Usage Cap',
name: 'UsageCap',
},
{
fieldLabel: 'Agent Ref',
name: 'AgentRef'
}, },
{ {
xtype: 'checkbox',
fieldLabel: 'Disabled', fieldLabel: 'Disabled',
name: 'AgentDisabled' name: 'Disabled',
}/*, xtype: 'checkbox',
{ inputValue: '1'
xtype: 'tabpanel', }
plain: 'true', ]
deferredRender: false, // Load all panels!
activeTab: 0,
height: 100,
defaults: {
layout: 'form',
bodyStyle: 'padding: 10px;'
},
items: [
{
title: 'Policy Settings',
layout: 'form',
defaultType: 'textfield',
items: [
{
fieldLabel: 'Transport Policy',
name: 'Policy',
vtype: 'number',
value: '1'
}
]
}
]
}*/
],
}, },
// Submit button config // Submit button config
submitAjaxConfig submitAjaxConfig
); );
// Events
if (!id) {
adminUserFormWindow.findById('agent_combobox').on({
select: {
fn: function() {
var tb = this.ownerCt.findById('service_combobox');
if (this.getValue()) {
tb.reset();
serviceStore.baseParams.AgentID = this.getValue();
serviceStore.reload();
tb.enable();
} else {
tb.reset();
tb.disable();
}
}
},
});
}
adminUserFormWindow.show(); adminUserFormWindow.show();
if (id) { if (id) {
adminUserFormWindow.getComponent('formpanel').load({ Ext.getCmp(adminUserFormWindow.formPanelID).load({
params: { params: {
id: id, ID: id,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUsers', SOAPModule: 'AdminUsers',
SOAPFunction: 'getAdminUser', SOAPFunction: 'getAdminUser',
SOAPParams: 'id' SOAPParams: 'ID'
} }
}); });
} }
...@@ -412,9 +371,9 @@ function showAdminUserEditWindow(id) { ...@@ -412,9 +371,9 @@ function showAdminUserEditWindow(id) {
// Display edit/add form // Display edit/add form
function showAdminUserRemoveWindow(parent,id) { function showAdminUserRemoveWindow(AdminUserWindow,id) {
// Mask parent window // Mask AdminUserWindow window
parent.getEl().mask(); AdminUserWindow.getEl().mask();
// Display remove confirm window // Display remove confirm window
Ext.Msg.show({ Ext.Msg.show({
...@@ -428,22 +387,30 @@ function showAdminUserRemoveWindow(parent,id) { ...@@ -428,22 +387,30 @@ function showAdminUserRemoveWindow(parent,id) {
if (buttonId == 'yes') { if (buttonId == 'yes') {
// Do ajax request // Do ajax request
uxAjaxRequest(parent,{ uxAjaxRequest(AdminUserWindow,{
params: { params: {
id: id, ID: id,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUsers', SOAPModule: 'AdminUsers',
SOAPFunction: 'removeAdminUser', SOAPFunction: 'removeAdminUser',
SOAPParams: 'id' SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
} }
}); });
// Unmask if user answered no // Unmask if user answered no
} else { } else {
parent.getEl().unmask(); AdminUserWindow.getEl().unmask();
} }
} }
}); });
...@@ -458,3 +425,5 @@ function showAdminUserRemoveWindow(parent,id) { ...@@ -458,3 +425,5 @@ function showAdminUserRemoveWindow(parent,id) {
// vim: ts=4
/*
WiSP Location Members
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showWiSPLocationMembersWindow(locationID) {
var WiSPLocationMembersWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Members",
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Remove',
tooltip:'Remove member',
iconCls:'remove',
handler: function() {
var selectedItem = Ext.getCmp(WiSPLocationMembersWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPLocationMemberRemoveWindow(WiSPLocationMembersWindow,selectedItem.data.ID);
} else {
WiSPLocationMembersWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No member selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
WiSPLocationMembersWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Username",
sortable: true,
dataIndex: 'Username'
}
]),
autoExpandColumn: 'Username'
},
// Store config
{
baseParams: {
ID: locationID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPLocationMembers',
SOAPFunction: 'getWiSPLocationMembers',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Username'}
]
}
);
WiSPLocationMembersWindow.show();
}
// Display remove form
function showWiSPLocationMemberRemoveWindow(WiSPLocationMembersWindow,id) {
// Mask WiSPLocationMembersWindow window
WiSPLocationMembersWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this member?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(WiSPLocationMembersWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPLocationMembers',
SOAPFunction: 'removeWiSPLocationMember',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(WiSPLocationMembersWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
WiSPLocationMembersWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
WiSP Locations
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showWiSPLocationWindow() { function showWiSPLocationWindow() {
...@@ -6,12 +24,13 @@ function showWiSPLocationWindow() { ...@@ -6,12 +24,13 @@ function showWiSPLocationWindow() {
// Window config // Window config
{ {
title: "Locations", title: "Locations",
iconCls: 'silk-map',
width: 600, width: 600,
height: 335, height: 335,
minWidth: 600, minWidth: 600,
minHeight: 335, minHeight: 335
}, },
// Grid config // Grid config
{ {
...@@ -20,18 +39,46 @@ function showWiSPLocationWindow() { ...@@ -20,18 +39,46 @@ function showWiSPLocationWindow() {
{ {
text:'Add', text:'Add',
tooltip:'Add location', tooltip:'Add location',
iconCls:'add', iconCls:'silk-map_add',
handler: function() { handler: function() {
showWiSPLocationEditWindow(); showWiSPLocationAddEditWindow(WiSPLocationWindow);
} }
}, },
'-', '-',
{
text:'Edit',
tooltip:'Edit location',
iconCls:'silk-map_edit',
handler: function() {
var selectedItem = Ext.getCmp(WiSPLocationWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPLocationAddEditWindow(WiSPLocationWindow,selectedItem.data.ID);
} else {
WiSPLocationWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No location selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
WiSPLocationWindow.getEl().unmask();
}
});
}
}
},
'-',
{ {
text:'Remove', text:'Remove',
tooltip:'Remove location', tooltip:'Remove location',
iconCls:'remove', iconCls:'silk-map_delete',
handler: function() { handler: function() {
var selectedItem = WiSPLocationWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(WiSPLocationWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -57,20 +104,20 @@ function showWiSPLocationWindow() { ...@@ -57,20 +104,20 @@ function showWiSPLocationWindow() {
{ {
text:'Members', text:'Members',
tooltip:'List members', tooltip:'List members',
iconCls:'remove', iconCls:'silk-user',
handler: function() { handler: function() {
var selectedItem = WiSPLocationWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(WiSPLocationWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
showWiSPLocationMembersWindow(WiSPLocationWindow,selectedItem.data.ID); showWiSPLocationMembersWindow(selectedItem.data.ID);
} else { } else {
WiSPLocationWindow.getEl().mask(); WiSPLocationWindow.getEl().mask();
// Display error // Display error
Ext.Msg.show({ Ext.Msg.show({
title: "Nothing selected", title: "Nothing selected",
msg: "No user selected", msg: "No location selected",
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL, buttons: Ext.Msg.CANCEL,
modal: false, modal: false,
...@@ -105,7 +152,7 @@ function showWiSPLocationWindow() { ...@@ -105,7 +152,7 @@ function showWiSPLocationWindow() {
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPLocations', SOAPModule: 'WiSPLocations',
SOAPFunction: 'getLocations', SOAPFunction: 'getWiSPLocations',
SOAPParams: '__null,__search' SOAPParams: '__null,__search'
} }
}, },
...@@ -122,19 +169,114 @@ function showWiSPLocationWindow() { ...@@ -122,19 +169,114 @@ function showWiSPLocationWindow() {
} }
// Display edit/add form
function showWiSPLocationAddEditWindow(WiSPLocationWindow,id) {
var submitAjaxConfig;
var icon;
// We doing an update
if (id) {
icon = 'silk-map_edit';
submitAjaxConfig = {
params: {
ID: id,
SOAPFunction: 'updateWiSPLocation',
SOAPParams:
'0:ID,'+
'0:Name'
},
onSuccess: function() {
var store = Ext.getCmp(WiSPLocationWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-map_add';
submitAjaxConfig = {
params: {
SOAPFunction: 'createWiSPLocation',
SOAPParams:
'0:Name'
},
onSuccess: function() {
var store = Ext.getCmp(WiSPLocationWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
// Create window
var wispLocationFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "Location Information",
iconCls: icon,
width: 310,
height: 113,
minWidth: 310,
minHeight: 113
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPLocations'
},
items: [
{
fieldLabel: 'Name',
name: 'Name',
allowBlank: false
}
]
},
// Submit button config
submitAjaxConfig
);
wispLocationFormWindow.show();
if (id) {
Ext.getCmp(wispLocationFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPLocations',
SOAPFunction: 'getWiSPLocation',
SOAPParams: 'ID'
}
});
}
}
// Display remove form // Display remove form
function showWiSPLocationRemoveWindow(parent,id) { function showWiSPLocationRemoveWindow(WiSPLocationWindow,id) {
// Mask parent window // Mask WiSPLocationWindow window
parent.getEl().mask(); WiSPLocationWindow.getEl().mask();
// Display remove confirm window // Display remove confirm window
Ext.Msg.show({ Ext.Msg.show({
title: "Confirm removal", title: "Confirm removal",
msg: "Are you very sure you wish to remove this user?", msg: "Are you very sure you wish to remove this location?",
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO, buttons: Ext.Msg.YESNO,
modal: false, modal: false,
...@@ -143,33 +285,34 @@ function showWiSPLocationRemoveWindow(parent,id) { ...@@ -143,33 +285,34 @@ function showWiSPLocationRemoveWindow(parent,id) {
if (buttonId == 'yes') { if (buttonId == 'yes') {
// Do ajax request // Do ajax request
uxAjaxRequest(parent,{ uxAjaxRequest(WiSPLocationWindow,{
params: { params: {
id: id, id: id,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers', SOAPModule: 'WiSPLocations',
SOAPFunction: 'removeWiSPUser', SOAPFunction: 'removeWiSPLocation',
SOAPParams: 'id' SOAPParams: 'id'
},
customSuccess: function() {
var store = Ext.getCmp(WiSPLocationWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
} }
}); });
// Unmask if user answered no // Unmask if user answered no
} else { } else {
parent.getEl().unmask(); WiSPLocationWindow.getEl().unmask();
} }
} }
}); });
} }
// vim: ts=4
/*
WiSP Resellers
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showWiSPResellersWindow() { function showWiSPResellersWindow() {
...@@ -8,10 +26,10 @@ function showWiSPResellersWindow() { ...@@ -8,10 +26,10 @@ function showWiSPResellersWindow() {
title: "Resellers", title: "Resellers",
width: 400, width: 400,
height: 325, height: 335,
minWidth: 400, minWidth: 400,
minHeight: 325, minHeight: 335
}, },
// Grid config // Grid config
{ {
...@@ -31,7 +49,7 @@ function showWiSPResellersWindow() { ...@@ -31,7 +49,7 @@ function showWiSPResellersWindow() {
tooltip:'Edit Reseller', tooltip:'Edit Reseller',
iconCls:'option', iconCls:'option',
handler: function() { handler: function() {
var selectedItem = WiSPResellerWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(WiSPResellerWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -59,7 +77,7 @@ function showWiSPResellersWindow() { ...@@ -59,7 +77,7 @@ function showWiSPResellersWindow() {
tooltip:'Remove Reseller', tooltip:'Remove Reseller',
iconCls:'remove', iconCls:'remove',
handler: function() { handler: function() {
var selectedItem = WiSPResellerWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(WiSPResellerWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -157,10 +175,10 @@ function showWiSPResellerEditWindow(id) { ...@@ -157,10 +175,10 @@ function showWiSPResellerEditWindow(id) {
title: "Reseller Information", title: "Reseller Information",
width: 300, width: 300,
height: 325, height: 348,
minWidth: 300, minWidth: 300,
minHeight: 325 minHeight: 348
}, },
// Form panel config // Form panel config
{ {
...@@ -254,7 +272,7 @@ function showWiSPResellerEditWindow(id) { ...@@ -254,7 +272,7 @@ function showWiSPResellerEditWindow(id) {
} }
] ]
} }
], ]
}, },
// Submit button config // Submit button config
submitAjaxConfig submitAjaxConfig
...@@ -263,7 +281,7 @@ function showWiSPResellerEditWindow(id) { ...@@ -263,7 +281,7 @@ function showWiSPResellerEditWindow(id) {
WiSPResellerFormWindow.show(); WiSPResellerFormWindow.show();
if (id) { if (id) {
WiSPResellerFormWindow.getComponent('formpanel').load({ Ext.getCmp(WiSPResellerFormWindow.formPanelID).load({
params: { params: {
id: id, id: id,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
...@@ -327,3 +345,5 @@ function showWiSPResellerRemoveWindow(parent,id) { ...@@ -327,3 +345,5 @@ function showWiSPResellerRemoveWindow(parent,id) {
// vim: ts=4
/*
WiSP User Logs
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showWiSPUserLogsWindow(wispUserID) { function showWiSPUserLogsWindow(id) {
// Calculate dates we going to need // Calculate dates we going to need
/*
var today = new Date(); var today = new Date();
var firstOfMonth = today.getFirstDateOfMonth(); var firstOfMonth = today.getFirstDateOfMonth();
var firstOfNext = today.getLastDateOfMonth().add(Date.DAY, 1); var firstOfNext = today.getLastDateOfMonth().add(Date.DAY, 1);
*/
var formID = Ext.id();
var formPeriodKeyID = Ext.id();
var formSearchButtonID = Ext.id();
var summaryFormID = Ext.id();
var summaryTotalID = Ext.id();
var currentPeriod = today.format('Y-m');
var wispUserLogsWindow = new Ext.ux.GenericGridWindow( var wispUserLogsWindow = new Ext.ux.GenericGridWindow(
// Window config // Window config
{ {
title: 'User Logs', title: 'Logs',
iconCls: 'silk-page_white_text',
layout:'border', layout:'border',
height: 480, height: 480,
width: 700, width: 700,
...@@ -22,91 +48,85 @@ function showWiSPUserLogsWindow(wispUserID) { ...@@ -22,91 +48,85 @@ function showWiSPUserLogsWindow(wispUserID) {
uxItems: [ uxItems: [
{ {
xtype: 'form', xtype: 'form',
id: 'search-form', id: formID,
title: 'Search', title: 'Search',
region: 'west', region: 'west',
border: true, border: true,
frame: true, frame: true,
defaultType: 'datefield',
height: 180, height: 180,
width: 300, width: 320,
labelWidth: 100, labelWidth: 100,
items: [ items: [
{ {
id: 'after', id: formPeriodKeyID,
name: 'after', xtype: 'textfield',
width: 180, name: 'periodkey',
fieldLabel: 'From', regex: /^\d{4}\-(0[1-9]|1(0|1|2))$/,
// vtype: 'daterange', regexText: 'Please enter month in the format: YYYY-MM',
format: 'Y-m-d', height: 25,
// value: firstOfMonth, width: 100,
// endDateField: 'before', fieldLabel: 'Period',
}, value: currentPeriod
{
id: 'before',
name: 'before',
width: 180,
fieldLabel: 'To',
// vtype: 'daterange',
format: 'Y-m-d',
// value: firstOfNext,
// startDateField: 'after'
} }
], ],
buttons: [ buttons: [
{ {
text: 'Search', text: 'Search',
id: 'formbtn', id: formSearchButtonID,
handler: function() { handler: function() {
// Pull in window, grid & form // Pull in window, grid & form
var mainWindow = this.ownerCt.ownerCt; var grid = Ext.getCmp(wispUserLogsWindow.gridPanelID);
var grid = mainWindow.getComponent('gridpanel');
var form = mainWindow.getComponent('search-form');
// Grab store // Grab store
var store = grid.getStore(); var store = grid.getStore();
// Grab timestamp filter // Grab timestamp filter
var gridFilters = grid.filters; var gridFilters = grid.filters;
var timestampFilter = gridFilters.getFilter('Timestamp'); var timestampFilter = gridFilters.getFilter('EventTimestamp');
// Grab form field
var periodKeyField = Ext.getCmp(formPeriodKeyID);
if (periodKeyField.isValid()) {
var periodKeyValue = periodKeyField.getValue();
// Grab form fields // Convert our periodKey into DateTime values
var afterField = form.getForm().findField('after'); var dtSearchStart = Date.parseDate(periodKeyValue+'-01','Y-m-d');
var beforeField = form.getForm().findField('before'); var dtSearchEnd = dtSearchStart.add(Date.MONTH,1);
// Set filter values from form // Set filter values from form
timestampFilter.setValue({ timestampFilter.setValue({
after: afterField.getValue(), after: dtSearchStart,
before: beforeField.getValue() before: dtSearchEnd
}); });
// Trigger store reload // Trigger store reload
store.reload(); store.reload();
}
} }
} }
], ],
buttonAlign: 'center' buttonAlign: 'center'
}, },
{ {
xtype: 'form', xtype: 'form',
id: 'summary-form', id: summaryFormID,
region: 'center', region: 'center',
split: true, split: true,
border: true, border: false,
autoScroll: true, autoScroll: true,
defaultType: 'textarea', defaultType: 'textarea',
height: 180, height: 300,
width: 400, width: 400,
labelWidth: 80, labelWidth: 0,
items: [ items: [
{ {
id: 'summaryTotal', id: summaryTotalID,
name: 'summaryTotal', name: 'summaryTotal',
readOnly: true, readOnly: true,
height: 135, height: 300,
width: 200, width: 400,
fieldLabel: 'Summary', fieldLabel: 'Summary',
hideLabel: true,
fieldClass: 'font-family: monospace; font-size: 10px;', fieldClass: 'font-family: monospace; font-size: 10px;',
value: '' value: ''
} }
...@@ -119,78 +139,53 @@ function showWiSPUserLogsWindow(wispUserID) { ...@@ -119,78 +139,53 @@ function showWiSPUserLogsWindow(wispUserID) {
region: 'south', region: 'south',
width: 700, width: 700,
border: true, border: true,
tbar: [
{
text: 'Add Port Lock',
tooltip: 'Add port lock',
iconCls: 'add'
}
],
// Column model // Column model
colModel: new Ext.grid.ColumnModel([ colModel: new Ext.grid.ColumnModel([
{ {
id: 'ID',
header: "ID", header: "ID",
hidden: true, hidden: true,
dataIndex: 'ID' dataIndex: 'ID'
}, },
{ {
header: "Username", header: "Timestamp",
hidden: true, sortable: true,
dataIndex: 'Username' dataIndex: 'EventTimestamp'
}, },
{ {
header: "Status", header: "Status",
sortable: true, sortable: true,
hidden: true, hidden: true,
dataIndex: 'Status' dataIndex: 'AcctStatusType'
}, },
{ {
header: "Timestamp", header: "Service Type",
sortable: true, sortable: true,
dataIndex: 'Timestamp' dataIndex: 'ServiceType'
},
{
header: "Session ID",
hidden: true,
dataIndex: 'AcctSessionID'
}, },
{ {
header: "Session Time", header: "Framed Protocol",
dataIndex: 'AcctSessionTime' sortable: true,
}, dataIndex: 'FramedProtocol'
{
header: "NAS IP",
hidden: true,
dataIndex: 'NASIPAddress'
}, },
{ {
header: "Port Type", header: "NAS Port Type",
hidden: true, hidden: true,
dataIndex: 'NASPortType' dataIndex: 'NASPortType'
}, },
{
header: "NAS Port",
dataIndex: 'NASPort'
},
{
header: "Called Station",
hidden: true,
dataIndex: 'CalledStationID'
},
{ {
header: "Calling Station", header: "Calling Station",
sortable: true, sortable: true,
dataIndex: 'CallingStationID' dataIndex: 'CallingStationID'
}, },
{ {
header: "NAS Xmit Rate", header: "Called Station",
dataIndex: 'NASTransmitRate' hidden: true,
dataIndex: 'CalledStationID'
}, },
{ {
header: "NAS Recv Rate", header: "Session ID",
hidden: true, hidden: true,
dataIndex: 'NASReceiveRate' dataIndex: 'AcctSessionID'
}, },
{ {
header: "IP Address", header: "IP Address",
...@@ -199,16 +194,17 @@ function showWiSPUserLogsWindow(wispUserID) { ...@@ -199,16 +194,17 @@ function showWiSPUserLogsWindow(wispUserID) {
}, },
{ {
header: "Input Mbyte", header: "Input Mbyte",
dataIndex: 'AcctInputMbyte' dataIndex: 'AcctInput',
renderer: renderUsageFloat
}, },
{ {
header: "Output Mbyte", header: "Output Mbyte",
dataIndex: 'AcctOutputMbyte' dataIndex: 'AcctOutput',
renderer: renderUsageFloat
}, },
{ {
header: "Last Update", header: "Session Uptime",
hidden: true, dataIndex: 'AcctSessionTime'
dataIndex: 'LastAcctUpdate'
}, },
{ {
header: "Term. Reason", header: "Term. Reason",
...@@ -219,73 +215,171 @@ function showWiSPUserLogsWindow(wispUserID) { ...@@ -219,73 +215,171 @@ function showWiSPUserLogsWindow(wispUserID) {
// Store config // Store config
{ {
baseParams: { baseParams: {
ID: id,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers', SOAPModule: 'WiSPUserLogs',
SOAPFunction: 'getWiSPUserLogs', SOAPFunction: 'getWiSPUserLogs',
SOAPParams: '0:UserID,__search', SOAPParams: 'ID,__search'
UserID: wispUserID
} }
}, },
// Filter config // Filter config
{ {
filters: [ filters: [
{type: 'numeric', dataIndex: 'ID'}, {type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Username'},
{type: 'numeric', dataIndex: 'Status'},
/*
{ {
type: 'date', type: 'date',
dataIndex: 'Timestamp', format: 'Y-m-d H:i:s',
dataIndex: 'EventTimestamp',
value: { value: {
after: firstOfMonth, after: firstOfMonth,
before: firstOfNext before: firstOfNext
} }
}, },
*/ {type: 'numeric', dataIndex: 'AcctStatusType'},
{type: 'string', dataIndex: 'AcctSessionID'}, {type: 'numeric', dataIndex: 'ServiceType'},
{type: 'numeric', dataIndex: 'AcctSessionTime'}, {type: 'numeric', dataIndex: 'FramedProtocol'},
{type: 'numeric', dataIndex: 'NASPortType'},
{type: 'string', dataIndex: 'NASIPAddress'}, {type: 'string', dataIndex: 'NASPortID'},
{type: 'string', dataIndex: 'NASPortType'},
{type: 'string', dataIndex: 'NASPort'},
{type: 'string', dataIndex: 'CalledStationID'},
{type: 'string', dataIndex: 'CallingStationID'}, {type: 'string', dataIndex: 'CallingStationID'},
{type: 'string', dataIndex: 'CalledStationID'},
{type: 'string', dataIndex: 'NASTransmitRate'}, {type: 'string', dataIndex: 'AcctSessionID'},
{type: 'string', dataIndex: 'NASReceiveRate'},
{type: 'string', dataIndex: 'FramedIPAddress'}, {type: 'string', dataIndex: 'FramedIPAddress'},
{type: 'numeric', dataIndex: 'AcctInput'},
{type: 'date', dataIndex: 'LastAcctUpdate'}, {type: 'numeric', dataIndex: 'AcctOutput'},
{type: 'numeric', dataIndex: 'AcctSessionTime'},
{type: 'string', dataIndex: 'ConnectTermReason'} {type: 'string', dataIndex: 'ConnectTermReason'}
] ]
} }
); );
// Grab store // Grab store
var store = wispUserLogsWindow.getComponent('gridpanel').getStore(); var store = Ext.getCmp(wispUserLogsWindow.gridPanelID).getStore();
store.on('load',function() { store.on('load',function() {
var inputTotal = store.sum('AcctInputMbyte');
var outputTotal = store.sum('AcctOutputMbyte');
var userCap = 3000; // Fetch periodKey from form
var userTopups = 1000; var periodKeyField = (Ext.getCmp(formPeriodKeyID)).getValue();
// Total up into this ...
var userTotalAllowed = userCap + userTopups;
var userUsage = inputTotal + outputTotal;
var userLeft = userTotalAllowed - userUsage;
var form = wispUserLogsWindow.getComponent('summary-form'); // Mask parent window
var summaryTotal = form.getForm().findField('summaryTotal'); wispUserLogsWindow.getEl().mask();
summaryTotal.setValue( uxAjaxRequest(
sprintf('Cap Total: %6d\nTopups : %6d\n-----------------\n %6d\n-----------------\nUsage : %6d\n=================\nAvailable: %6d',userCap,userTopups,userTotalAllowed,userUsage,userLeft) wispUserLogsWindow,
{
params: {
PeriodKey: periodKeyField,
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUserLogs',
SOAPFunction: 'getWiSPUserLogsSummary',
SOAPParams: '0:ID,0:PeriodKey'
},
customSuccess: function (result) {
response = Ext.decode(result.responseText);
// Caps
var trafficCap = response.data.trafficCap; // value of -1: prepaid
var uptimeCap = response.data.uptimeCap; // value of -1: prepaid
// Usage
var trafficUsage = response.data.trafficUsage;
var uptimeUsage = response.data.uptimeUsage;
// Topups
var trafficTopups = response.data.trafficTopups;
var uptimeTopups = response.data.uptimeTopups;
var totalTrafficTopups = response.data.TotalTrafficTopups;
var totalUptimeTopups = response.data.TotalUptimeTopups;
// Format string before printing
var trafficString = '';
// Prepaid traffic
if (trafficCap == -1) {
trafficCap = 'Prepaid';
trafficString += sprintf('Traffic:\nCap: %s \nTopup balance for current month: %d MB\nTotal Topups: %d MB\nUsage: %d/%d MB\n',
trafficCap,trafficTopups,totalTrafficTopups,trafficUsage,trafficTopups);
trafficString += '---\n';
// Uncapped traffic
} else if (trafficCap == 0) {
trafficString += sprintf('Traffic:\nCap: Uncapped\nUsage: %d MB\n',
trafficUsage);
trafficString += '---\n';
// Capped traffic
} else {
var combinedTrafficCap = trafficCap + trafficTopups;
trafficString += sprintf('Traffic:\nCap: %d MB\nTopup balance for current month: %d MB\nTotal Topups: %d MB\n'+
'Usage: %d/%d MB\n',
trafficCap,trafficTopups,totalTrafficTopups,trafficUsage,combinedTrafficCap);
trafficString += '---\n';
}
// Format string before printing
var uptimeString = '';
// Prepaid uptime
if (uptimeCap == -1) {
uptimeCap = 'Prepaid';
uptimeString += sprintf('Uptime:\nCap: %s \nTopup balance for current month: %d Min\nTotal Topups: %d Min\n'+
'Usage: %d/%d Min\n',
uptimeCap,uptimeTopups,totalUptimeTopups,uptimeUsage,uptimeTopups);
uptimeString += '---\n';
// Uncapped uptime
} else if (uptimeCap == 0) {
uptimeString += sprintf('Uptime:\nCap: Uncapped\nUsage: %d Min\n',
uptimeUsage);
uptimeString += '---\n';
// Capped uptime
} else {
var combinedUptimeCap = uptimeCap + uptimeTopups;
uptimeString += sprintf('Uptime:\nCap: %d Min\nTopup balance for current month: %d Min\nTotal Topups: %d Min\n'+
'Usage: %d/%d Min\n',
uptimeCap,uptimeTopups,totalUptimeTopups,uptimeUsage,combinedUptimeCap);
uptimeString += '---\n';
}
// Topup breakdown
var tTopups = response.data.AllTrafficTopups;
var uTopups = response.data.AllUptimeTopups;
// Format topups string
var topupString = '';
if (tTopups.length > 0) {
topupString += 'Valid Traffic Topups:';
}
for (var i = 0; i < tTopups.length; i++) {
var id = tTopups[i].ID;
var used = tTopups[i].Used;
var cap = tTopups[i].Cap;
var validTo = tTopups[i].ValidTo;
topupString += sprintf('\nID: %s\nUsage: %d/%d MB\nValid Until: %s\n--',id,used,cap,validTo);
}
if (uTopups.length > 0) {
topupString += 'Valid Uptime Topups:';
}
for (var i = 0; i < uTopups.length; i++) {
var id = uTopups[i].ID;
var used = uTopups[i].Used;
var cap = uTopups[i].Cap;
var validTo = uTopups[i].ValidTo;
topupString += sprintf('\nID: %s\nUsage: %d/%d MB\nValid Until: %s\n--',id,used,cap,validTo);
}
// Get summary field
var form = Ext.getCmp(summaryFormID);
var summaryField = Ext.getCmp(summaryTotalID);
summaryField.setValue(trafficString+uptimeString+topupString);
},
failure: function (result) {
Ext.MessageBox.alert('Failed', 'Couldn\'t fetch data: '+result.date);
}
}
); );
}); });
wispUserLogsWindow.show(); wispUserLogsWindow.show();
} }
// vim: ts=4
/*
WiSP User Topups
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showWiSPUserTopupsWindow(userID) { function showWiSPUserTopupsWindow(userID) {
...@@ -6,11 +24,12 @@ function showWiSPUserTopupsWindow(userID) { ...@@ -6,11 +24,12 @@ function showWiSPUserTopupsWindow(userID) {
// Window config // Window config
{ {
title: "User Topups", title: "User Topups",
iconCls: 'silk-chart_bar',
width: 500, width: 500,
height: 335, height: 335,
minWidth: 500, minWidth: 500,
minHeight: 335, minHeight: 335
}, },
// Grid config // Grid config
{ {
...@@ -19,22 +38,22 @@ function showWiSPUserTopupsWindow(userID) { ...@@ -19,22 +38,22 @@ function showWiSPUserTopupsWindow(userID) {
{ {
text:'Add', text:'Add',
tooltip:'Add topup', tooltip:'Add topup',
iconCls:'add', iconCls:'silk-chart_bar_add',
handler: function() { handler: function() {
showWiSPUserTopupEditWindow(userID,0); showWiSPUserTopupAddEditWindow(wispUserTopupsWindow,userID,0);
} }
}, },
'-', '-',
{ {
text:'Edit', text:'Edit',
tooltip:'Edit topup', tooltip:'Edit topup',
iconCls:'option', iconCls:'silk-chart_bar_edit',
handler: function() { handler: function() {
var selectedItem = wispUserTopupsWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(wispUserTopupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
showWiSPUserTopupEditWindow(userID,selectedItem.data.ID); showWiSPUserTopupAddEditWindow(wispUserTopupsWindow,userID,selectedItem.data.ID);
} else { } else {
wispUserTopupsWindow.getEl().mask(); wispUserTopupsWindow.getEl().mask();
...@@ -56,9 +75,9 @@ function showWiSPUserTopupsWindow(userID) { ...@@ -56,9 +75,9 @@ function showWiSPUserTopupsWindow(userID) {
{ {
text:'Remove', text:'Remove',
tooltip:'Remove topup', tooltip:'Remove topup',
iconCls:'remove', iconCls:'silk-chart_bar_delete',
handler: function() { handler: function() {
var selectedItem = wispUserTopupsWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(wispUserTopupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -91,9 +110,14 @@ function showWiSPUserTopupsWindow(userID) { ...@@ -91,9 +110,14 @@ function showWiSPUserTopupsWindow(userID) {
dataIndex: 'ID' dataIndex: 'ID'
}, },
{ {
header: "Bandwidth", header: "Type",
sortable: true, sortable: true,
dataIndex: 'Bandwidth' dataIndex: 'Type'
},
{
header: "Value",
sortable: true,
dataIndex: 'Value'
}, },
{ {
header: "Timestamp", header: "Timestamp",
...@@ -110,13 +134,8 @@ function showWiSPUserTopupsWindow(userID) { ...@@ -110,13 +134,8 @@ function showWiSPUserTopupsWindow(userID) {
header: "ValidTo", header: "ValidTo",
sortable: true, sortable: true,
dataIndex: 'ValidTo' dataIndex: 'ValidTo'
},
{
header: "AgentRef",
sortable: true,
dataIndex: 'AgentRef'
} }
]), ])
}, },
// Store config // Store config
{ {
...@@ -134,11 +153,10 @@ function showWiSPUserTopupsWindow(userID) { ...@@ -134,11 +153,10 @@ function showWiSPUserTopupsWindow(userID) {
{ {
filters: [ filters: [
{type: 'numeric', dataIndex: 'ID'}, {type: 'numeric', dataIndex: 'ID'},
{type: 'numeric', dataIndex: 'Bandwidth'},
{type: 'date', dataIndex: 'Timestamp'}, {type: 'date', dataIndex: 'Timestamp'},
{type: 'numeric', dataIndex: 'Value'},
{type: 'date', dataIndex: 'ValidFrom'}, {type: 'date', dataIndex: 'ValidFrom'},
{type: 'date', dataIndex: 'ValidTo'}, {type: 'date', dataIndex: 'ValidTo'}
{type: 'string', dataIndex: 'AgentRef'}
] ]
} }
); );
...@@ -148,30 +166,53 @@ function showWiSPUserTopupsWindow(userID) { ...@@ -148,30 +166,53 @@ function showWiSPUserTopupsWindow(userID) {
// Display edit/add form // Display edit/add form
function showWiSPUserTopupEditWindow(userID,topupID) { function showWiSPUserTopupAddEditWindow(wispUserTopupsWindow,userID,topupID) {
var today = new Date(); var today = new Date();
var firstOfMonth = today.getFirstDateOfMonth(); var firstOfMonth = today.getFirstDateOfMonth();
var firstOfNext = today.getLastDateOfMonth().add(Date.DAY, 1); var firstOfNext = today.getLastDateOfMonth().add(Date.DAY, 1);
var submitAjaxConfig; var submitAjaxConfig;
var icon;
// We doing an update // We doing an update
if (topupID) { if (topupID) {
icon = 'silk-chart_bar_edit';
submitAjaxConfig = { submitAjaxConfig = {
ID: topupID, params: {
SOAPFunction: 'updateWiSPUserTopup', ID: topupID,
SOAPParams: SOAPFunction: 'updateWiSPUserTopup',
'0:ID,0:Bandwidth,'+ SOAPParams:
'0:Timestamp,0:ValidFrom,0:ValidTo,0:AgentRef' '0:ID,0:Value,0:Type,'+
'0:ValidFrom,0:ValidTo'
},
onSuccess: function() {
var store = Ext.getCmp(wispUserTopupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
}; };
// We doing an Add // We doing an Add
} else { } else {
icon = 'silk-chart_bar_add';
submitAjaxConfig = { submitAjaxConfig = {
UserID: userID, params: {
SOAPFunction: 'createWiSPUserTopup', UserID: userID,
SOAPParams: SOAPFunction: 'createWiSPUserTopup',
'0:UserID,0:Bandwidth,'+ SOAPParams:
'0:Timestamp,0:ValidFrom,0:ValidTo,0:AgentRef' '0:UserID,0:Value,0:Type,'+
'0:ValidFrom,0:ValidTo'
},
onSuccess: function() {
var store = Ext.getCmp(wispUserTopupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
}; };
} }
...@@ -180,6 +221,7 @@ function showWiSPUserTopupEditWindow(userID,topupID) { ...@@ -180,6 +221,7 @@ function showWiSPUserTopupEditWindow(userID,topupID) {
// Window config // Window config
{ {
title: "Topup Information", title: "Topup Information",
iconCls: icon,
width: 400, width: 400,
height: 200, height: 200,
...@@ -196,23 +238,40 @@ function showWiSPUserTopupEditWindow(userID,topupID) { ...@@ -196,23 +238,40 @@ function showWiSPUserTopupEditWindow(userID,topupID) {
SOAPModule: 'WiSPUsers' SOAPModule: 'WiSPUsers'
}, },
items: [ items: [
{
xtype: 'combo',
fieldLabel: 'Type',
name: 'Type',
allowBlank: false,
width: 157,
store: [
[ '1', 'Traffic' ],
[ '2', 'Uptime' ]
],
displayField: 'Type',
valueField: 'Type',
hiddenName: 'Type',
forceSelection: true,
triggerAction: 'all',
editable: false
},
{ {
xtype: 'numberfield', xtype: 'numberfield',
fieldLabel: 'Bandwidth', fieldLabel: 'Value',
name: 'Bandwidth', name: 'Value',
minValue: 1, minValue: 1,
allowBlank: false allowBlank: false
}, },
{ {
xtype: 'datefield', xtype: 'datefield',
fieldLabel: 'ValidFrom', fieldLabel: 'ValidFrom',
name: 'ValidFrom', name: 'ValidFrom',
id: 'ValidFrom', id: 'ValidFrom',
vtype: 'daterange', vtype: 'daterange',
disabledDates: ["(0(2|3|4|5|6|7|8|9)|1[0-9]|2[0-9]|3[0-1])$"],
value: firstOfMonth, value: firstOfMonth,
format: 'Y-m-d', format: 'Y-m-d',
endDateField: 'ValidTo' endDateField: 'ValidTo'
}, },
{ {
xtype: 'datefield', xtype: 'datefield',
...@@ -220,15 +279,12 @@ function showWiSPUserTopupEditWindow(userID,topupID) { ...@@ -220,15 +279,12 @@ function showWiSPUserTopupEditWindow(userID,topupID) {
name: 'ValidTo', name: 'ValidTo',
id: 'ValidTo', id: 'ValidTo',
vtype: 'daterange', vtype: 'daterange',
disabledDates: ["(0(2|3|4|5|6|7|8|9)|1[0-9]|2[0-9]|3[0-1])$"],
value: firstOfNext, value: firstOfNext,
format: 'Y-m-d', format: 'Y-m-d',
startDateField: 'ValidFrom' startDateField: 'ValidFrom'
},
{
fieldLabel: 'AgentRef',
name: 'AgentRef'
} }
], ]
}, },
// Submit button config // Submit button config
submitAjaxConfig submitAjaxConfig
...@@ -237,7 +293,7 @@ function showWiSPUserTopupEditWindow(userID,topupID) { ...@@ -237,7 +293,7 @@ function showWiSPUserTopupEditWindow(userID,topupID) {
wispUserTopupFormWindow.show(); wispUserTopupFormWindow.show();
if (topupID) { if (topupID) {
wispUserTopupFormWindow.getComponent('formpanel').load({ Ext.getCmp(wispUserTopupFormWindow.formPanelID).load({
params: { params: {
id: topupID, id: topupID,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
...@@ -254,10 +310,10 @@ function showWiSPUserTopupEditWindow(userID,topupID) { ...@@ -254,10 +310,10 @@ function showWiSPUserTopupEditWindow(userID,topupID) {
// Display edit/add form // Display remove form
function showWiSPUserTopupRemoveWindow(parent,id) { function showWiSPUserTopupRemoveWindow(wispUserTopupsWindow,id) {
// Mask parent window // Mask wispUserTopupsWindow window
parent.getEl().mask(); wispUserTopupsWindow.getEl().mask();
// Display remove confirm window // Display remove confirm window
Ext.Msg.show({ Ext.Msg.show({
...@@ -271,7 +327,7 @@ function showWiSPUserTopupRemoveWindow(parent,id) { ...@@ -271,7 +327,7 @@ function showWiSPUserTopupRemoveWindow(parent,id) {
if (buttonId == 'yes') { if (buttonId == 'yes') {
// Do ajax request // Do ajax request
uxAjaxRequest(parent,{ uxAjaxRequest(wispUserTopupsWindow,{
params: { params: {
id: id, id: id,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
...@@ -280,15 +336,25 @@ function showWiSPUserTopupRemoveWindow(parent,id) { ...@@ -280,15 +336,25 @@ function showWiSPUserTopupRemoveWindow(parent,id) {
SOAPModule: 'WiSPUsers', SOAPModule: 'WiSPUsers',
SOAPFunction: 'removeWiSPUserTopup', SOAPFunction: 'removeWiSPUserTopup',
SOAPParams: 'id' SOAPParams: 'id'
},
customSuccess: function() {
var store = Ext.getCmp(wispUserTopupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
} }
}); });
// Unmask if user answered no // Unmask if user answered no
} else { } else {
parent.getEl().unmask(); wispUserTopupsWindow.getEl().unmask();
} }
} }
}); });
} }
// vim: ts=4
/*
WiSP Users
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showWiSPUserWindow() { function showWiSPUserWindow() {
...@@ -6,12 +24,13 @@ function showWiSPUserWindow() { ...@@ -6,12 +24,13 @@ function showWiSPUserWindow() {
// Window config // Window config
{ {
title: "Users", title: "Users",
iconCls: 'silk-user',
width: 600, width: 600,
height: 335, height: 335,
minWidth: 600, minWidth: 600,
minHeight: 335, minHeight: 335
}, },
// Grid config // Grid config
{ {
...@@ -20,22 +39,22 @@ function showWiSPUserWindow() { ...@@ -20,22 +39,22 @@ function showWiSPUserWindow() {
{ {
text:'Add', text:'Add',
tooltip:'Add user', tooltip:'Add user',
iconCls:'add', iconCls:'silk-user_add',
handler: function() { handler: function() {
showWiSPUserEditWindow(); showWiSPUserAddEditWindow(WiSPUserWindow);
} }
}, },
'-', '-',
{ {
text:'Edit', text:'Edit',
tooltip:'Edit user', tooltip:'Edit user',
iconCls:'option', iconCls:'silk-user_edit',
handler: function() { handler: function() {
var selectedItem = WiSPUserWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
showWiSPUserEditWindow(selectedItem.data.ID); showWiSPUserAddEditWindow(WiSPUserWindow,selectedItem.data.ID);
} else { } else {
WiSPUserWindow.getEl().mask(); WiSPUserWindow.getEl().mask();
...@@ -57,9 +76,9 @@ function showWiSPUserWindow() { ...@@ -57,9 +76,9 @@ function showWiSPUserWindow() {
{ {
text:'Remove', text:'Remove',
tooltip:'Remove user', tooltip:'Remove user',
iconCls:'remove', iconCls:'silk-user_delete',
handler: function() { handler: function() {
var selectedItem = WiSPUserWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -85,9 +104,9 @@ function showWiSPUserWindow() { ...@@ -85,9 +104,9 @@ function showWiSPUserWindow() {
{ {
text:'Logs', text:'Logs',
tooltip:'User logs', tooltip:'User logs',
iconCls:'logs', iconCls: 'silk-page_white_text',
handler: function() { handler: function() {
var selectedItem = WiSPUserWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -113,9 +132,9 @@ function showWiSPUserWindow() { ...@@ -113,9 +132,9 @@ function showWiSPUserWindow() {
{ {
text:'Topups', text:'Topups',
tooltip:'User topups', tooltip:'User topups',
iconCls:'topups', iconCls:'silk-chart_bar',
handler: function() { handler: function() {
var selectedItem = WiSPUserWindow.getComponent('gridpanel').getSelectionModel().getSelected(); var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
...@@ -142,42 +161,42 @@ function showWiSPUserWindow() { ...@@ -142,42 +161,42 @@ function showWiSPUserWindow() {
colModel: new Ext.grid.ColumnModel([ colModel: new Ext.grid.ColumnModel([
{ {
id: 'ID', id: 'ID',
header: "ID", header: "UserID",
sortable: true, sortable: true,
dataIndex: 'ID' dataIndex: 'ID'
}, },
{ {
header: "AgentName", header: "Username",
sortable: true, sortable: true,
dataIndex: 'AgentName' dataIndex: 'Username'
}, },
{ {
header: "Username", header: "First Name",
sortable: true, sortable: true,
dataIndex: 'Username' dataIndex: 'Firstname'
}, },
{ {
header: "Service", header: "Last Name",
sortable: true, sortable: true,
dataIndex: 'Service' dataIndex: 'Lastname'
}, },
{ {
header: "Usage Cap", header: "Email",
sortable: true, sortable: true,
dataIndex: 'UsageCap' dataIndex: 'Email'
}, },
{ {
header: "Agent Ref", header: "Phone",
sortable: true, sortable: true,
dataIndex: 'AgentRef' dataIndex: 'Phone'
}, },
{ {
header: "Disabled", header: "Disabled",
sortable: false, sortable: true,
dataIndex: 'Disabled' dataIndex: 'Disabled'
} }
]), ]),
autoExpandColumn: 'Service' autoExpandColumn: 'Username'
}, },
// Store config // Store config
{ {
...@@ -194,11 +213,12 @@ function showWiSPUserWindow() { ...@@ -194,11 +213,12 @@ function showWiSPUserWindow() {
{ {
filters: [ filters: [
{type: 'numeric', dataIndex: 'ID'}, {type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'AgentName'},
{type: 'string', dataIndex: 'Username'}, {type: 'string', dataIndex: 'Username'},
{type: 'string', dataIndex: 'Service'}, {type: 'boolean', dataIndex: 'Disabled'},
{type: 'numeric', dataIndex: 'UsageCap'}, {type: 'string', dataIndex: 'Firstname'},
{type: 'string', dataIndex: 'AgentRef'} {type: 'string', dataIndex: 'Lastname'},
{type: 'string', dataIndex: 'Email'},
{type: 'string', dataIndex: 'Phone'}
] ]
} }
); );
...@@ -208,65 +228,520 @@ function showWiSPUserWindow() { ...@@ -208,65 +228,520 @@ function showWiSPUserWindow() {
// Display edit/add form // Display edit/add form
function showWiSPUserEditWindow(id) { function showWiSPUserAddEditWindow(WiSPUserWindow,id) {
var submitAjaxConfig; var submitAjaxConfig;
var editMode; var editMode;
var icon;
// Arrays for removed items
var RemovedAttributes = new Array();
var RemovedGroups = new Array();
// To identify newly inserted rows
var attributeInsertID = -1;
var groupInsertID = -1;
// Attribute record that can be added to below store
var attributeRecord = Ext.data.Record.create([
{name: 'ID'},
{name: 'Name'},
{name: 'Operator'},
{name: 'Value'},
{name: 'Modifier'}
]);
// Attribute store
var attributeStore;
// If this is an update we need to pull in record
if (id) {
attributeStore = new Ext.ux.JsonStore({
pruneModifiedRecords: true,
baseParams: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers',
SOAPFunction: 'getWiSPUserAttributes',
SOAPParams: 'ID'
}
});
} else {
attributeStore = new Ext.data.SimpleStore({
pruneModifiedRecords: true,
fields: ['ID', 'Name', 'Operator', 'Value', 'Modifer']
});
}
// Group record that can be added to below store
var groupRecord = Ext.data.Record.create([
{name: 'Name'}
]);
// Group store
var groupStore;
// If this is an update we need to pull in record
if (id) {
groupStore = new Ext.ux.JsonStore({
pruneModifiedRecords: true,
baseParams: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers',
SOAPFunction: 'getWiSPUserGroups',
SOAPParams: 'ID'
}
});
} else {
groupStore = new Ext.data.SimpleStore({
pruneModifiedRecords: true,
fields: [
'Name'
]
});
}
// We doing an update // We doing an update
if (id) { if (id) {
icon = 'silk-user_edit';
submitAjaxConfig = { submitAjaxConfig = {
ID: id, params: {
SOAPFunction: 'updateWiSPUser', ID: id,
SOAPParams: SOAPFunction: 'updateWiSPUser',
'0:ID,'+ SOAPParams:
'0:UsageCap,'+ '0:ID,'+
'0:AgentRef,'+ '0:Username,'+
'0:AgentDisabled:boolean' '0:Password,'+
}; '0:Disabled,'+
editMode = true; '0:Firstname,'+
'0:Lastname,'+
'0:Phone,'+
'0:LocationID,'+
'0:Attributes,'+
'0:Groups,'+
'0:Email,'+
'0:RGroups,'+
'0:RAttributes'
},
onSuccess: function() {
var store = Ext.getCmp(WiSPUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
},
hook: function() {
// Get modified attribute records
var attributes = attributeStore.getModifiedRecords();
// Get modified group records
var groups = groupStore.getModifiedRecords();
var ret = { };
// Set attributes we will be adding
for (var i = 0, len = attributes.length; i < len; i++) {
var attribute = attributes[i];
// Safe to add this attribute
ret['Attributes['+i+'][ID]'] = attribute.get('ID');
ret['Attributes['+i+'][Name]'] = attribute.get('Name');
ret['Attributes['+i+'][Operator]'] = attribute.get('Operator');
ret['Attributes['+i+'][Value]'] = attribute.get('Value');
ret['Attributes['+i+'][Modifier]'] = attribute.get('Modifier');
}
// Set groups we will be adding
for (var i = 0, len = groups.length; i < len; i++) {
var group = groups[i];
// Safe to add this attribute
ret['Groups['+i+'][Name]'] = group.get('Name');
}
// Add removed attributes
if ((id) && (RemovedAttributes.length > 0)) {
var c = 0;
var len = RemovedAttributes.length;
for (var i = 0; i < len; i++) {
// If this is a new add then the user has no attributes
if (RemovedAttributes[i] >= 0) {
ret['RAttributes['+c+']'] = RemovedAttributes[i];
c++;
}
}
}
// Add removed groups
if ((id) && (RemovedGroups.length > 0)) {
var c = 0;
var len = RemovedGroups.length;
for (var i = 0; i < len; i++) {
// If this is a new add then the user has no attributes
if (RemovedGroups[i] >= 0) {
ret['RGroups['+c+']'] = RemovedGroups[i];
c++;
}
}
}
return ret;
}
};
// We doing an Add // We doing an Add
} else { } else {
icon = 'silk-user_add';
submitAjaxConfig = { submitAjaxConfig = {
SOAPFunction: 'createWiSPUser', params: {
SOAPParams: SOAPFunction: 'createWiSPUser',
'0:AgentID,'+ SOAPParams:
'0:UserName,'+ '0:Username,'+
'0:UsageCap,'+ '0:Disabled,'+
'0:AgentRef,'+ '0:Password,'+
'0:AgentDisabled:boolean' '0:Firstname,'+
'0:Lastname,'+
'0:Phone,'+
'0:Email,'+
'0:LocationID,'+
'0:Attributes,'+
'0:Groups,'+
'0:Number,'+
'0:Prefix'
},
onSuccess: function() {
var store = Ext.getCmp(WiSPUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
},
hook: function() {
// Get modified attribute records
var attributes = attributeStore.getModifiedRecords();
// Get modified group records
var groups = groupStore.getModifiedRecords();
var ret = { };
// Set attributes we will be adding
for (var i = 0, len = attributes.length; i < len; i++) {
var attribute = attributes[i];
// Safe to add this attribute
ret['Attributes['+i+'][ID]'] = attribute.get('ID');
ret['Attributes['+i+'][Name]'] = attribute.get('Name');
ret['Attributes['+i+'][Operator]'] = attribute.get('Operator');
ret['Attributes['+i+'][Value]'] = attribute.get('Value');
ret['Attributes['+i+'][Modifier]'] = attribute.get('Modifier');
}
// Set groups we will be adding
for (var i = 0, len = groups.length; i < len; i++) {
var group = groups[i];
// Safe to add this attribute
ret['Groups['+i+'][Name]'] = group.get('Name');
}
return ret;
}
}; };
editMode = false;
} }
// Service store
var serviceStore = new Ext.ux.JsonStore({ // Build the attribute editor grid
ID: id, var attributeEditor = new Ext.grid.EditorGridPanel({
plain: true,
autoHeight: true,
// Set row selection model
selModel: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add attribute',
iconCls:'silk-table_add',
handler: function() {
var newAttrStoreRecord = new attributeRecord({
ID: attributeInsertID,
Name: '',
Operator: '',
Value: '',
Modifier: ''
});
attributeStore.insert(0,newAttrStoreRecord);
attributeInsertID -= 1;
}
},
'-',
{
text:'Remove',
tooltip:'Remove attribute',
iconCls:'silk-table_delete',
handler: function() {
var selectedItem = attributeEditor.getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// Get selected item value
var attributeID = selectedItem.get('ID');
// Remove selected
attributeStore.remove(selectedItem);
// Add to list of removed attributes
RemovedAttributes.push(attributeID);
} else {
wispUserFormWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No attribute selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
wispUserFormWindow.getEl().unmask();
}
});
}
}
}
],
cm: new Ext.grid.ColumnModel([
{
id: 'ID',
header: 'ID',
dataIndex: 'ID',
hidden: true,
width: 30
},
{
id: 'Name',
header: 'Name',
dataIndex: 'Name',
width: 150,
editor: new Ext.form.ComboBox({
allowBlank: false,
mode: 'local',
store: [
[ 'SMRadius-Capping-Traffic-Limit', 'Traffic Limit' ],
[ 'SMRadius-Capping-Uptime-Limit', 'Uptime Limit' ],
[ 'Framed-IP-Address', 'IP Address' ],
[ 'Calling-Station-Id', 'MAC Address' ]
],
triggerAction: 'all',
editable: false
})
},
{
id: 'Operator',
header: 'Operator',
dataIndex: 'Operator',
width: 300,
editor: new Ext.form.ComboBox({
allowBlank: false,
mode: 'local',
store: [
[ '=', 'Add as reply if unique' ],
[ ':=', 'Set configuration value' ],
[ '==', 'Match value in request' ],
[ '+=', 'Add reply and set configuration' ],
[ '!=', 'Inverse match value in request' ],
[ '<', 'Match less-than value in request' ],
[ '>', 'Match greater-than value in request' ],
[ '<=', 'Match less-than or equal value in request' ],
[ '>=', 'Match greater-than or equal value in request' ],
[ '=~', 'Match string containing regex in request' ],
[ '!~', 'Match string not containing regex in request' ],
[ '=*', 'Match if attribute is defined in request' ],
[ '!*', 'Match if attribute is not defined in request' ],
[ '||==', 'Match any of these values in request' ]
],
triggerAction: 'all',
editable: true
})
},
{
id: 'Value',
header: 'Value',
dataIndex: 'Value',
width: 100,
editor: new Ext.form.TextField({
allowBlank: false
})
},
{
id: 'Modifier',
header: 'Modifier',
dataIndex: 'Modifier',
width: 80,
editor: new Ext.form.ComboBox({
allowBlank: false,
mode: 'local',
store: [
[ 'Seconds', 'Seconds' ],
[ 'Minutes', 'Minutes' ],
[ 'Hours', 'Hours' ],
[ 'Days', 'Days' ],
[ 'Weeks', 'Weeks' ],
[ 'Months', 'Months' ],
[ 'MBytes', 'MBytes' ],
[ 'GBytes', 'GBytes' ],
[ 'TBytes', 'TBytes' ]
],
triggerAction: 'all',
editable: true
})
}
]),
store: attributeStore
});
// Editor combobox ID
var editorComboBoxID = Ext.id();
// Render display value
editorComboBoxRenderer = function(editorComboBoxID) {
var combo = Ext.getCmp(editorComboBoxID);
return function(value){
var record = combo.findRecord(combo.valueField, value);
return record ? record.get(combo.displayField) : value;
}
}
// Build the group editor grid
var groupEditor = new Ext.grid.EditorGridPanel({
plain: true,
autoHeight: true,
// Set row selection model
selModel: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add group',
iconCls:'silk-group_add',
handler: function() {
var newGroupStoreRecord = new groupRecord({
ID: groupInsertID,
Name: ''
});
groupStore.insert(0,newGroupStoreRecord);
groupInsertID -= 1;
}
},
'-',
{
text:'Remove',
tooltip:'Remove group',
iconCls:'silk-group_delete',
handler: function() {
var selectedItem = groupEditor.getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// Get selected item value
var groupID = selectedItem.get('ID');
// Remove selected
groupStore.remove(selectedItem);
// Add to our removed groups hash
RemovedGroups.push(groupID);
} else {
wispUserFormWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No group selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
wispUserFormWindow.getEl().unmask();
}
});
}
}
}
],
cm: new Ext.grid.ColumnModel([
{
id: 'ID',
header: 'ID',
dataIndex: 'ID',
hidden: true,
width: 30
},
{
id: 'Name',
header: 'Name',
dataIndex: 'Name',
width: 150,
editor: new Ext.form.ComboBox({
id: editorComboBoxID,
allowBlank: false,
store: new Ext.ux.JsonStore({
sortInfo: { field: "Name", direction: "ASC" },
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUserGroups',
SOAPFunction: 'getAdminGroups',
SOAPParams: '__null,__search'
}
}),
displayField: 'Name',
valueField: 'ID',
forceSelection: true,
triggerAction: 'all',
editable: false
}),
renderer: editorComboBoxRenderer(editorComboBoxID)
}
]),
store: groupStore
});
var locationStore = new Ext.ux.JsonStore({
sortInfo: { field: "Name", direction: "ASC" }, sortInfo: { field: "Name", direction: "ASC" },
baseParams: { baseParams: {
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers', SOAPModule: 'WiSPUsers',
SOAPFunction: 'getClasses', SOAPFunction: 'getWiSPLocations',
AgentID: 1, SOAPParams: '__null,__search'
SOAPParams: '0:AgentID,__search'
} }
}); })
// Create window // Create window
var wispUserFormWindow = new Ext.ux.GenericFormWindow( var wispUserFormWindow = new Ext.ux.GenericFormWindow(
// Window config // Window config
{ {
title: "User Information", title: "User Information",
iconCls: icon,
width: 475, width: 700,
height: 260, height: 362,
minWidth: 475, minWidth: 700,
minHeight: 260 minHeight: 362
}, },
// Form panel config // Form panel config
{ {
...@@ -281,163 +756,151 @@ function showWiSPUserEditWindow(id) { ...@@ -281,163 +756,151 @@ function showWiSPUserEditWindow(id) {
{ {
fieldLabel: 'Username', fieldLabel: 'Username',
name: 'Username', name: 'Username',
vtype: 'usernamePart', vtype: 'usernameRadius',
maskRe: usernamePartRe, maskRe: usernameRadiusPartRe,
allowBlank: false, allowBlank: true
disabled: editMode
},
{
xtype: 'combo',
// We use an ID so we can get the box later
id: 'agent_combobox',
fieldLabel: 'Agent',
name: 'Agent',
allowBlank: false,
width: 225,
store: new Ext.ux.JsonStore({
ID: id,
sortInfo: { field: "Name", direction: "ASC" },
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'Agents',
SOAPFunction: 'getAgents',
SOAPParams: '__search'
}
}),
displayField: 'Name',
valueField: 'ID',
hiddenName: 'AgentID',
forceSelection: false,
triggerAction: 'all',
editable: false,
disabled: editMode
},
{
xtype: 'combo',
// We use an ID so we can get the box later
id: 'service_combobox',
fieldLabel: 'Service',
name: 'Service',
allowBlank: false,
width: 340,
store: serviceStore,
displayField: 'Service',
valueField: 'ID',
hiddenName: 'ClassID',
forceSelection: false,
triggerAction: 'all',
editable: false,
disabled: true
}, },
{ {
fieldLabel: 'Usage Cap', fieldLabel: 'Password',
name: 'UsageCap', name: 'Password',
allowBlank: true
}, },
{ {
fieldLabel: 'Agent Ref',
name: 'AgentRef'
},
{
xtype: 'checkbox',
fieldLabel: 'Disabled', fieldLabel: 'Disabled',
name: 'AgentDisabled' name: 'Disabled',
}/*, xtype: 'checkbox',
inputValue: '1'
},
{ {
xtype: 'tabpanel', xtype: 'tabpanel',
plain: 'true', plain: 'true',
deferredRender: false, // Load all panels! deferredRender: false, // Load all panels!
activeTab: 0, activeTab: 0,
height: 100, height: 200,
maxHeight: 200,
defaults: { defaults: {
layout: 'form', layout: 'form',
bodyStyle: 'padding: 10px;' bodyStyle: 'padding: 10px;'
}, },
items: [ items: [
{ {
title: 'Policy Settings', title: 'Personal',
iconCls: 'silk-user_comment',
layout: 'form', layout: 'form',
defaultType: 'textfield', defaultType: 'textfield',
items: [ items: [
{ {
fieldLabel: 'Transport Policy', fieldLabel: 'First Name',
name: 'Policy', name: 'Firstname',
allowBlank: true
},
{
fieldLabel: 'Last Name',
name: 'Lastname',
allowBlank: true
},
{
fieldLabel: 'Phone',
name: 'Phone',
vtype: 'number', vtype: 'number',
value: '1' allowBlank: true
},
{
fieldLabel: 'Email',
name: 'Email',
allowBlank: true
},
{
xtype: 'combo',
fieldLabel: 'Location',
name: 'Location',
allowBlank: true,
width: 140,
store: locationStore,
displayField: 'Name',
valueField: 'ID',
hiddenName: 'LocationID',
forceSelection: true,
triggerAction: 'all',
editable: false
}
]
},
{
title: 'Groups',
iconCls: 'silk-group',
layout: 'form',
autoScroll: true,
defaultType: 'textfield',
items: [
groupEditor
]
},
{
title: 'Attributes',
iconCls: 'silk-table',
layout: 'form',
autoScroll: true,
defaultType: 'textfield',
items: [
attributeEditor
]
},
{
title: 'Add Many',
iconCls: 'silk-user_suit',
layout: 'form',
defaultType: 'textfield',
items: [
{
fieldLabel: 'Prefix',
name: 'Prefix',
allowBlank: true
},
{
fieldLabel: 'Number',
name: 'Number',
vtype: 'number',
allowBlank: true
} }
] ]
} }
] ]
}*/ }
], ]
}, },
// Submit button config // Submit button config
submitAjaxConfig submitAjaxConfig
); );
// Events
if (!id) {
wispUserFormWindow.findById('agent_combobox').on({
select: {
fn: function() {
var tb = this.ownerCt.findById('service_combobox');
if (this.getValue()) {
tb.reset();
serviceStore.baseParams.AgentID = this.getValue();
serviceStore.reload();
tb.enable();
} else {
tb.reset();
tb.disable();
}
}
},
});
}
wispUserFormWindow.show(); wispUserFormWindow.show();
if (id) { if (id) {
wispUserFormWindow.getComponent('formpanel').load({ Ext.getCmp(wispUserFormWindow.formPanelID).load({
params: { params: {
id: id, ID: id,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers', SOAPModule: 'WiSPUsers',
SOAPFunction: 'getWiSPUser', SOAPFunction: 'getWiSPUser',
SOAPParams: 'id' SOAPParams: 'ID'
} }
}); });
locationStore.load();
attributeStore.load();
groupStore.load();
} }
} }
// Display edit/add form // Display remove form
function showWiSPUserRemoveWindow(parent,id) { function showWiSPUserRemoveWindow(WiSPUserWindow,id) {
// Mask parent window // Mask WiSPUserWindow window
parent.getEl().mask(); WiSPUserWindow.getEl().mask();
// Display remove confirm window // Display remove confirm window
Ext.Msg.show({ Ext.Msg.show({
...@@ -451,22 +914,30 @@ function showWiSPUserRemoveWindow(parent,id) { ...@@ -451,22 +914,30 @@ function showWiSPUserRemoveWindow(parent,id) {
if (buttonId == 'yes') { if (buttonId == 'yes') {
// Do ajax request // Do ajax request
uxAjaxRequest(parent,{ uxAjaxRequest(WiSPUserWindow,{
params: { params: {
id: id, ID: id,
SOAPUsername: globalConfig.soap.username, SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password, SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype, SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers', SOAPModule: 'WiSPUsers',
SOAPFunction: 'removeWiSPUser', SOAPFunction: 'removeWiSPUser',
SOAPParams: 'id' SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(WiSPUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
} }
}); });
// Unmask if user answered no // Unmask if user answered no
} else { } else {
parent.getEl().unmask(); WiSPUserWindow.getEl().unmask();
} }
} }
}); });
...@@ -481,3 +952,5 @@ function showWiSPUserRemoveWindow(parent,id) { ...@@ -481,3 +952,5 @@ function showWiSPUserRemoveWindow(parent,id) {
// vim: ts=4