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 6816 additions and 0 deletions
/*
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() {
var AdminGroupWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Groups",
iconCls: 'silk-group',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add group',
iconCls:'silk-group_add',
handler: function() {
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',
tooltip:'Remove group',
iconCls:'silk-group_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminGroupWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminGroupRemoveWindow(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:'Attributes',
tooltip:'Group attributes',
iconCls:'silk-table',
handler: function() {
var selectedItem = Ext.getCmp(AdminGroupWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminGroupAttributesWindow(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:'Members',
tooltip:'Group members',
iconCls:'silk-group',
handler: function() {
var selectedItem = Ext.getCmp(AdminGroupWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminGroupMembersWindow(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();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Name",
sortable: true,
dataIndex: 'Name'
},
{
header: "Priority",
sortable: true,
dataIndex: 'Priority'
},
{
header: "Disabled",
sortable: true,
dataIndex: 'Disabled'
},
{
header: "Comment",
sortable: true,
dataIndex: 'Comment'
}
]),
autoExpandColumn: 'Name'
},
// Store config
{
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroups',
SOAPFunction: 'getAdminGroups',
SOAPParams: '__null,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'},
{type: 'numeric', dataIndex: 'Priority'},
{type: 'boolean', dataIndex: 'Disabled'},
{type: 'string', dataIndex: 'Comment'}
]
}
);
AdminGroupWindow.show();
}
// Display edit/add form
function showAdminGroupAddEditWindow(AdminGroupWindow,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:Name'
},
onSuccess: function() {
var store = Ext.getCmp(AdminGroupWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-group_add';
submitAjaxConfig = {
params: {
SOAPFunction: 'createAdminGroup',
SOAPParams:
'0:Name'
},
onSuccess: function() {
var store = Ext.getCmp(AdminGroupWindow.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: [
{
fieldLabel: 'Name',
name: 'Name',
allowBlank: 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 remove form
function showAdminGroupRemoveWindow(AdminGroupWindow,id) {
// Mask AdminGroupWindow window
AdminGroupWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove 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(AdminGroupWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroups',
SOAPFunction: 'removeAdminGroup',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminGroupWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
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() {
var AdminRealmWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Realms",
iconCls: 'silk-world',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add realm',
iconCls:'silk-world_add',
handler: function() {
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',
tooltip:'Remove realm',
iconCls:'silk-world_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminRealmWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminRealmRemoveWindow(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:'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',
tooltip:'Realm members',
iconCls:'silk-server',
handler: function() {
var selectedItem = Ext.getCmp(AdminRealmWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminRealmMembersWindow(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();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Name",
sortable: true,
dataIndex: 'Name'
},
{
header: "Disabled",
sortable: false,
dataIndex: 'Disabled'
}
]),
autoExpandColumn: 'Name'
},
// Store config
{
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealms',
SOAPFunction: 'getAdminRealms',
SOAPParams: '__null,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'},
{type: 'boolean', dataIndex: 'Disabled'}
]
}
);
AdminRealmWindow.show();
}
// Display edit/add form
function showAdminRealmAddEditWindow(AdminRealmWindow,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:Name'
},
onSuccess: function() {
var store = Ext.getCmp(AdminRealmWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-world_add';
submitAjaxConfig = {
params: {
SOAPFunction: 'createAdminRealm',
SOAPParams:
'0:Name'
},
onSuccess: function() {
var store = Ext.getCmp(AdminRealmWindow.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: [
{
fieldLabel: 'Name',
name: 'Name',
allowBlank: 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 showAdminRealmRemoveWindow(AdminRealmWindow,id) {
// Mask AdminRealmWindow window
AdminRealmWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove 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(AdminRealmWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealms',
SOAPFunction: 'removeAdminRealm',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminRealmWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
AdminRealmWindow.getEl().unmask();
}
}
});
}
// 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.
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
var today = new Date();
var firstOfMonth = today.getFirstDateOfMonth();
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 adminUserLogsWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: 'Logs',
iconCls: 'silk-page_white_text',
layout:'border',
height: 480,
width: 700,
minHeight: 480,
minWidth: 700,
closable: true,
plain: true,
uxItems: [
{
xtype: 'form',
id: formID,
title: 'Search',
region: 'west',
border: true,
frame: true,
height: 180,
width: 320,
labelWidth: 100,
items: [
{
id: formPeriodKeyID,
xtype: 'textfield',
name: 'periodkey',
regex: /^\d{4}\-(0[1-9]|1(0|1|2))$/,
regexText: 'Please enter month in the format: YYYY-MM',
height: 25,
width: 100,
fieldLabel: 'Period',
value: currentPeriod
}
],
buttons: [
{
text: 'Search',
id: formSearchButtonID,
handler: function() {
// Pull in window, grid & form
var grid = Ext.getCmp(adminUserLogsWindow.gridPanelID);
// Grab store
var store = grid.getStore();
// Grab timestamp filter
var gridFilters = grid.filters;
var timestampFilter = gridFilters.getFilter('EventTimestamp');
// Grab form field
var periodKeyField = Ext.getCmp(formPeriodKeyID);
if (periodKeyField.isValid()) {
var periodKeyValue = periodKeyField.getValue();
// Convert our periodKey into DateTime values
var dtSearchStart = Date.parseDate(periodKeyValue+'-01','Y-m-d');
var dtSearchEnd = dtSearchStart.add(Date.MONTH,1);
// Set filter values from form
timestampFilter.setValue({
after: dtSearchStart,
before: dtSearchEnd
});
// Trigger store reload
store.reload();
}
}
}
],
buttonAlign: 'center'
},
{
xtype: 'form',
id: summaryFormID,
region: 'center',
split: true,
border: false,
autoScroll: true,
defaultType: 'textarea',
height: 300,
width: 400,
labelWidth: 0,
items: [
{
id: summaryTotalID,
name: 'summaryTotal',
readOnly: true,
height: 300,
width: 400,
fieldLabel: 'Summary',
hideLabel: true,
fieldClass: 'font-family: monospace; font-size: 10px;',
value: ''
}
]
}
]
},
// Grid config
{
region: 'south',
width: 700,
border: true,
// Column model
colModel: new Ext.grid.ColumnModel([
{
header: "ID",
hidden: true,
dataIndex: 'ID'
},
{
header: "Timestamp",
sortable: true,
dataIndex: 'EventTimestamp'
},
{
header: "Status",
sortable: true,
hidden: true,
dataIndex: 'AcctStatusType'
},
{
header: "Service Type",
sortable: true,
dataIndex: 'ServiceType'
},
{
header: "Framed Protocol",
sortable: true,
dataIndex: 'FramedProtocol'
},
{
header: "NAS Port Type",
hidden: true,
dataIndex: 'NASPortType'
},
{
header: "Calling Station",
sortable: true,
dataIndex: 'CallingStationID'
},
{
header: "Called Station",
hidden: true,
dataIndex: 'CalledStationID'
},
{
header: "Session ID",
hidden: true,
dataIndex: 'AcctSessionID'
},
{
header: "IP Address",
hidden: true,
dataIndex: 'FramedIPAddress'
},
{
header: "Input Mbyte",
dataIndex: 'AcctInput',
renderer: renderUsageFloat
},
{
header: "Output Mbyte",
dataIndex: 'AcctOutput',
renderer: renderUsageFloat
},
{
header: "Session Uptime",
dataIndex: 'AcctSessionTime'
},
{
header: "Term. Reason",
dataIndex: 'ConnectTermReason'
}
])
},
// Store config
{
baseParams: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUserLogs',
SOAPFunction: 'getAdminUserLogs',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{
type: 'date',
format: 'Y-m-d H:i:s',
dataIndex: 'EventTimestamp',
value: {
after: firstOfMonth,
before: firstOfNext
}
},
{type: 'numeric', dataIndex: 'AcctStatusType'},
{type: 'numeric', dataIndex: 'ServiceType'},
{type: 'numeric', dataIndex: 'FramedProtocol'},
{type: 'numeric', dataIndex: 'NASPortType'},
{type: 'string', dataIndex: 'NASPortID'},
{type: 'string', dataIndex: 'CallingStationID'},
{type: 'string', dataIndex: 'CalledStationID'},
{type: 'string', dataIndex: 'AcctSessionID'},
{type: 'string', dataIndex: 'FramedIPAddress'},
{type: 'numeric', dataIndex: 'AcctInput'},
{type: 'numeric', dataIndex: 'AcctOutput'},
{type: 'numeric', dataIndex: 'AcctSessionTime'},
{type: 'string', dataIndex: 'ConnectTermReason'}
]
}
);
// Grab store
var store = Ext.getCmp(adminUserLogsWindow.gridPanelID).getStore();
store.on('load',function() {
// Fetch periodKey from form
var periodKeyField = (Ext.getCmp(formPeriodKeyID)).getValue();
// Mask parent window
adminUserLogsWindow.getEl().mask();
uxAjaxRequest(
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;
// 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);
}
}
);
});
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() {
var AdminUserWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Users",
iconCls: 'silk-user',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add user',
iconCls:'silk-user_add',
handler: function() {
showAdminUserAddEditWindow(AdminUserWindow);
}
},
'-',
{
text:'Edit',
tooltip:'Edit user',
iconCls:'silk-user_edit',
handler: function() {
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserAddEditWindow(AdminUserWindow,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:'Remove',
tooltip:'Remove user',
iconCls:'silk-user_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserRemoveWindow(AdminUserWindow,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:'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',
tooltip:'User logs',
iconCls: 'silk-page_white_text',
handler: function() {
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserLogsWindow(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:'Groups',
tooltip:'User groups',
iconCls:'silk-group',
handler: function() {
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserGroupsWindow(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:'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
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();
}
});
}
}
}
],
// 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: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUsers',
SOAPFunction: 'getAdminUsers',
SOAPParams: '__null,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Username'},
{type: 'boolean', dataIndex: 'Disabled'}
]
}
);
AdminUserWindow.show();
}
// Display edit/add form
function showAdminUserAddEditWindow(AdminUserWindow,id) {
var submitAjaxConfig;
var icon;
// We doing an update
if (id) {
icon = 'silk-user_edit';
submitAjaxConfig = {
params: {
ID: id,
SOAPFunction: 'updateAdminUser',
SOAPParams:
'0:ID,'+
'0:Username,'+
'0:Disabled'
},
onSuccess: function() {
var store = Ext.getCmp(AdminUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
// We doing an Add
} else {
icon = 'silk-user_add';
submitAjaxConfig = {
params: {
SOAPFunction: 'createAdminUser',
SOAPParams:
'0:Username,'+
'0:Disabled'
},
onSuccess: function() {
var store = Ext.getCmp(AdminUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
// Create window
var adminUserFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "User Information",
iconCls: icon,
width: 310,
height: 133,
minWidth: 310,
minHeight: 133
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUsers'
},
items: [
{
fieldLabel: 'Username',
name: 'Username',
vtype: 'usernameRadius',
maskRe: usernameRadiusPartRe,
allowBlank: false
},
{
fieldLabel: 'Disabled',
name: 'Disabled',
xtype: 'checkbox',
inputValue: '1'
}
]
},
// Submit button config
submitAjaxConfig
);
adminUserFormWindow.show();
if (id) {
Ext.getCmp(adminUserFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUsers',
SOAPFunction: 'getAdminUser',
SOAPParams: 'ID'
}
});
}
}
// Display edit/add form
function showAdminUserRemoveWindow(AdminUserWindow,id) {
// Mask AdminUserWindow window
AdminUserWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this user?",
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(AdminUserWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUsers',
SOAPFunction: 'removeAdminUser',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(AdminUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
AdminUserWindow.getEl().unmask();
}
}
});
}
// 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() {
var WiSPLocationWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Locations",
iconCls: 'silk-map',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add location',
iconCls:'silk-map_add',
handler: function() {
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',
tooltip:'Remove location',
iconCls:'silk-map_delete',
handler: function() {
var selectedItem = Ext.getCmp(WiSPLocationWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPLocationRemoveWindow(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:'Members',
tooltip:'List members',
iconCls:'silk-user',
handler: function() {
var selectedItem = Ext.getCmp(WiSPLocationWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPLocationMembersWindow(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();
}
});
}
}
}
],
// 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: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPLocations',
SOAPFunction: 'getWiSPLocations',
SOAPParams: '__null,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'}
]
}
);
WiSPLocationWindow.show();
}
// 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
function showWiSPLocationRemoveWindow(WiSPLocationWindow,id) {
// Mask WiSPLocationWindow window
WiSPLocationWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this location?",
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(WiSPLocationWindow,{
params: {
id: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPLocations',
SOAPFunction: 'removeWiSPLocation',
SOAPParams: 'id'
},
customSuccess: function() {
var store = Ext.getCmp(WiSPLocationWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
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() {
var WiSPResellerWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Resellers",
width: 400,
height: 335,
minWidth: 400,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add Reseller',
iconCls:'add',
handler: function() {
showWiSPResellerEditWindow();
}
},
'-',
{
text:'Edit',
tooltip:'Edit Reseller',
iconCls:'option',
handler: function() {
var selectedItem = Ext.getCmp(WiSPResellerWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPResellerEditWindow(selectedItem.data.ID);
} else {
WiSPResellerWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No Reseller selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
WiSPResellerWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Remove',
tooltip:'Remove Reseller',
iconCls:'remove',
handler: function() {
var selectedItem = Ext.getCmp(WiSPResellerWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPResellerRemoveWindow(WiSPResellerWindow,selectedItem.data.ID);
} else {
WiSPResellerWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No Reseller selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
WiSPResellerWindow.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: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPResellers',
SOAPFunction: 'getWiSPResellers',
SOAPParams: '__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'}
]
}
);
WiSPResellerWindow.show();
}
// Display edit/add form
function showWiSPResellerEditWindow(id) {
var submitAjaxConfig;
// We doing an update
if (id) {
submitAjaxConfig = {
ID: id,
SOAPFunction: 'updateWiSPReseller',
SOAPParams:
'0:ID,0:Name,'+
'0:ContactPerson,0:ContactTel1,0:ContactTel2,0:ContactEmail,'+
'0:SiteQuota,0:MinSiteSize,'+
'0:MailboxQuota,0:MinMailboxSize'
};
// We doing an Add
} else {
submitAjaxConfig = {
SOAPFunction: 'createWiSPReseller',
SOAPParams:
'0:Name,'+
'0:ContactPerson,0:ContactTel1,0:ContactTel2,0:ContactEmail,'+
'0:SiteQuota,0:MinSiteSize,'+
'0:MailboxQuota,0:MinMailboxSize'
};
}
// Create window
var WiSPResellerFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "Reseller Information",
width: 300,
height: 348,
minWidth: 300,
minHeight: 348
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'Admin'
},
items: [
{
fieldLabel: 'Name',
name: 'Name',
allowBlank: false
},
{
fieldLabel: 'Contact Person',
name: 'ContactPerson',
allowBlank: false
},
{
fieldLabel: 'Contact Tel 1',
name: 'ContactTel1',
allowBlank: false
},
{
fieldLabel: 'Contact Tel 2',
name: 'ContactTel2'
},
{
fieldLabel: 'Contact Email',
name: 'ContactEmail',
vtype: 'email',
allowBlank: false
},
{
xtype: 'tabpanel',
plain: 'true',
deferredRender: false, // Load all panels!
activeTab: 0,
height: 100,
defaults: {
layout: 'form',
bodyStyle: 'padding: 10px;'
},
items: [
{
title: 'Web Hosting',
layout: 'form',
defaultType: 'textfield',
items: [
{
fieldLabel: 'Site Quota',
name: 'SiteQuota',
allowBlank: false,
vtype: 'number',
value: '0'
},
{
fieldLabel: 'Min Site Size',
name: 'MinSiteSize',
allowBlank: false,
vtype: 'number',
value: '5'
}
]
},
{
title: 'Mail Hosting',
layout: 'form',
defaultType: 'textfield',
items: [
{
fieldLabel: 'Mail Quota',
name: 'MailboxQuota',
allowBlank: false,
vtype: 'number',
value: '0'
},
{
fieldLabel: 'Min Mailbox Size',
name: 'MinMailboxSize',
allowBlank: false,
vtype: 'number',
value: '1'
}
]
}
]
}
]
},
// Submit button config
submitAjaxConfig
);
WiSPResellerFormWindow.show();
if (id) {
Ext.getCmp(WiSPResellerFormWindow.formPanelID).load({
params: {
id: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPResellers',
SOAPFunction: 'getWiSPReseller',
SOAPParams: 'id'
}
});
}
}
// Display edit/add form
function showWiSPResellerRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this WiSPReseller?",
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(parent,{
params: {
id: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPResellers',
SOAPFunction: 'removeWiSPReseller',
SOAPParams: 'id'
}
});
// Unmask if user answered no
} else {
parent.getEl().unmask();
}
}
});
}
// 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(id) {
// Calculate dates we going to need
var today = new Date();
var firstOfMonth = today.getFirstDateOfMonth();
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(
// Window config
{
title: 'Logs',
iconCls: 'silk-page_white_text',
layout:'border',
height: 480,
width: 700,
minHeight: 480,
minWidth: 700,
closable: true,
plain: true,
uxItems: [
{
xtype: 'form',
id: formID,
title: 'Search',
region: 'west',
border: true,
frame: true,
height: 180,
width: 320,
labelWidth: 100,
items: [
{
id: formPeriodKeyID,
xtype: 'textfield',
name: 'periodkey',
regex: /^\d{4}\-(0[1-9]|1(0|1|2))$/,
regexText: 'Please enter month in the format: YYYY-MM',
height: 25,
width: 100,
fieldLabel: 'Period',
value: currentPeriod
}
],
buttons: [
{
text: 'Search',
id: formSearchButtonID,
handler: function() {
// Pull in window, grid & form
var grid = Ext.getCmp(wispUserLogsWindow.gridPanelID);
// Grab store
var store = grid.getStore();
// Grab timestamp filter
var gridFilters = grid.filters;
var timestampFilter = gridFilters.getFilter('EventTimestamp');
// Grab form field
var periodKeyField = Ext.getCmp(formPeriodKeyID);
if (periodKeyField.isValid()) {
var periodKeyValue = periodKeyField.getValue();
// Convert our periodKey into DateTime values
var dtSearchStart = Date.parseDate(periodKeyValue+'-01','Y-m-d');
var dtSearchEnd = dtSearchStart.add(Date.MONTH,1);
// Set filter values from form
timestampFilter.setValue({
after: dtSearchStart,
before: dtSearchEnd
});
// Trigger store reload
store.reload();
}
}
}
],
buttonAlign: 'center'
},
{
xtype: 'form',
id: summaryFormID,
region: 'center',
split: true,
border: false,
autoScroll: true,
defaultType: 'textarea',
height: 300,
width: 400,
labelWidth: 0,
items: [
{
id: summaryTotalID,
name: 'summaryTotal',
readOnly: true,
height: 300,
width: 400,
fieldLabel: 'Summary',
hideLabel: true,
fieldClass: 'font-family: monospace; font-size: 10px;',
value: ''
}
]
}
]
},
// Grid config
{
region: 'south',
width: 700,
border: true,
// Column model
colModel: new Ext.grid.ColumnModel([
{
header: "ID",
hidden: true,
dataIndex: 'ID'
},
{
header: "Timestamp",
sortable: true,
dataIndex: 'EventTimestamp'
},
{
header: "Status",
sortable: true,
hidden: true,
dataIndex: 'AcctStatusType'
},
{
header: "Service Type",
sortable: true,
dataIndex: 'ServiceType'
},
{
header: "Framed Protocol",
sortable: true,
dataIndex: 'FramedProtocol'
},
{
header: "NAS Port Type",
hidden: true,
dataIndex: 'NASPortType'
},
{
header: "Calling Station",
sortable: true,
dataIndex: 'CallingStationID'
},
{
header: "Called Station",
hidden: true,
dataIndex: 'CalledStationID'
},
{
header: "Session ID",
hidden: true,
dataIndex: 'AcctSessionID'
},
{
header: "IP Address",
hidden: true,
dataIndex: 'FramedIPAddress'
},
{
header: "Input Mbyte",
dataIndex: 'AcctInput',
renderer: renderUsageFloat
},
{
header: "Output Mbyte",
dataIndex: 'AcctOutput',
renderer: renderUsageFloat
},
{
header: "Session Uptime",
dataIndex: 'AcctSessionTime'
},
{
header: "Term. Reason",
dataIndex: 'ConnectTermReason'
}
])
},
// Store config
{
baseParams: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUserLogs',
SOAPFunction: 'getWiSPUserLogs',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{
type: 'date',
format: 'Y-m-d H:i:s',
dataIndex: 'EventTimestamp',
value: {
after: firstOfMonth,
before: firstOfNext
}
},
{type: 'numeric', dataIndex: 'AcctStatusType'},
{type: 'numeric', dataIndex: 'ServiceType'},
{type: 'numeric', dataIndex: 'FramedProtocol'},
{type: 'numeric', dataIndex: 'NASPortType'},
{type: 'string', dataIndex: 'NASPortID'},
{type: 'string', dataIndex: 'CallingStationID'},
{type: 'string', dataIndex: 'CalledStationID'},
{type: 'string', dataIndex: 'AcctSessionID'},
{type: 'string', dataIndex: 'FramedIPAddress'},
{type: 'numeric', dataIndex: 'AcctInput'},
{type: 'numeric', dataIndex: 'AcctOutput'},
{type: 'numeric', dataIndex: 'AcctSessionTime'},
{type: 'string', dataIndex: 'ConnectTermReason'}
]
}
);
// Grab store
var store = Ext.getCmp(wispUserLogsWindow.gridPanelID).getStore();
store.on('load',function() {
// Fetch periodKey from form
var periodKeyField = (Ext.getCmp(formPeriodKeyID)).getValue();
// Mask parent window
wispUserLogsWindow.getEl().mask();
uxAjaxRequest(
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();
}
// 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) {
var wispUserTopupsWindow = 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() {
showWiSPUserTopupAddEditWindow(wispUserTopupsWindow,userID,0);
}
},
'-',
{
text:'Edit',
tooltip:'Edit topup',
iconCls:'silk-chart_bar_edit',
handler: function() {
var selectedItem = Ext.getCmp(wispUserTopupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPUserTopupAddEditWindow(wispUserTopupsWindow,userID,selectedItem.data.ID);
} else {
wispUserTopupsWindow.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() {
wispUserTopupsWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Remove',
tooltip:'Remove topup',
iconCls:'silk-chart_bar_delete',
handler: function() {
var selectedItem = Ext.getCmp(wispUserTopupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPUserTopupRemoveWindow(wispUserTopupsWindow,selectedItem.data.ID);
} else {
wispUserTopupsWindow.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() {
wispUserTopupsWindow.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: 'WiSPUsers',
SOAPFunction: 'getWiSPUserTopups',
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'}
]
}
);
wispUserTopupsWindow.show();
}
// Display edit/add form
function showWiSPUserTopupAddEditWindow(wispUserTopupsWindow,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: 'updateWiSPUserTopup',
SOAPParams:
'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
} else {
icon = 'silk-chart_bar_add';
submitAjaxConfig = {
params: {
UserID: userID,
SOAPFunction: 'createWiSPUserTopup',
SOAPParams:
'0:UserID,0:Value,0:Type,'+
'0:ValidFrom,0:ValidTo'
},
onSuccess: function() {
var store = Ext.getCmp(wispUserTopupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
// Create window
var wispUserTopupFormWindow = 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: 'WiSPUsers'
},
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
);
wispUserTopupFormWindow.show();
if (topupID) {
Ext.getCmp(wispUserTopupFormWindow.formPanelID).load({
params: {
id: topupID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers',
SOAPFunction: 'getWiSPUserTopup',
SOAPParams: 'id'
}
});
}
}
// Display remove form
function showWiSPUserTopupRemoveWindow(wispUserTopupsWindow,id) {
// Mask wispUserTopupsWindow window
wispUserTopupsWindow.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(wispUserTopupsWindow,{
params: {
id: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers',
SOAPFunction: 'removeWiSPUserTopup',
SOAPParams: 'id'
},
customSuccess: function() {
var store = Ext.getCmp(wispUserTopupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
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() {
var WiSPUserWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Users",
iconCls: 'silk-user',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add user',
iconCls:'silk-user_add',
handler: function() {
showWiSPUserAddEditWindow(WiSPUserWindow);
}
},
'-',
{
text:'Edit',
tooltip:'Edit user',
iconCls:'silk-user_edit',
handler: function() {
var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPUserAddEditWindow(WiSPUserWindow,selectedItem.data.ID);
} else {
WiSPUserWindow.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() {
WiSPUserWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Remove',
tooltip:'Remove user',
iconCls:'silk-user_delete',
handler: function() {
var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPUserRemoveWindow(WiSPUserWindow,selectedItem.data.ID);
} else {
WiSPUserWindow.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() {
WiSPUserWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Logs',
tooltip:'User logs',
iconCls: 'silk-page_white_text',
handler: function() {
var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPUserLogsWindow(selectedItem.data.ID);
} else {
WiSPUserWindow.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() {
WiSPUserWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Topups',
tooltip:'User topups',
iconCls:'silk-chart_bar',
handler: function() {
var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPUserTopupsWindow(selectedItem.data.ID);
} else {
WiSPUserWindow.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() {
WiSPUserWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "UserID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Username",
sortable: true,
dataIndex: 'Username'
},
{
header: "First Name",
sortable: true,
dataIndex: 'Firstname'
},
{
header: "Last Name",
sortable: true,
dataIndex: 'Lastname'
},
{
header: "Email",
sortable: true,
dataIndex: 'Email'
},
{
header: "Phone",
sortable: true,
dataIndex: 'Phone'
},
{
header: "Disabled",
sortable: true,
dataIndex: 'Disabled'
}
]),
autoExpandColumn: 'Username'
},
// Store config
{
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers',
SOAPFunction: 'getWiSPUsers',
SOAPParams: '__null,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Username'},
{type: 'boolean', dataIndex: 'Disabled'},
{type: 'string', dataIndex: 'Firstname'},
{type: 'string', dataIndex: 'Lastname'},
{type: 'string', dataIndex: 'Email'},
{type: 'string', dataIndex: 'Phone'}
]
}
);
WiSPUserWindow.show();
}
// Display edit/add form
function showWiSPUserAddEditWindow(WiSPUserWindow,id) {
var submitAjaxConfig;
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
if (id) {
icon = 'silk-user_edit';
submitAjaxConfig = {
params: {
ID: id,
SOAPFunction: 'updateWiSPUser',
SOAPParams:
'0:ID,'+
'0:Username,'+
'0:Password,'+
'0:Disabled,'+
'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
} else {
icon = 'silk-user_add';
submitAjaxConfig = {
params: {
SOAPFunction: 'createWiSPUser',
SOAPParams:
'0:Username,'+
'0:Disabled,'+
'0:Password,'+
'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;
}
};
}
// Build the attribute editor grid
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" },
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers',
SOAPFunction: 'getWiSPLocations',
SOAPParams: '__null,__search'
}
})
// Create window
var wispUserFormWindow = new Ext.ux.GenericFormWindow(
// Window config
{
title: "User Information",
iconCls: icon,
width: 700,
height: 362,
minWidth: 700,
minHeight: 362
},
// Form panel config
{
labelWidth: 85,
baseParams: {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers'
},
items: [
{
fieldLabel: 'Username',
name: 'Username',
vtype: 'usernameRadius',
maskRe: usernameRadiusPartRe,
allowBlank: true
},
{
fieldLabel: 'Password',
name: 'Password',
allowBlank: true
},
{
fieldLabel: 'Disabled',
name: 'Disabled',
xtype: 'checkbox',
inputValue: '1'
},
{
xtype: 'tabpanel',
plain: 'true',
deferredRender: false, // Load all panels!
activeTab: 0,
height: 200,
maxHeight: 200,
defaults: {
layout: 'form',
bodyStyle: 'padding: 10px;'
},
items: [
{
title: 'Personal',
iconCls: 'silk-user_comment',
layout: 'form',
defaultType: 'textfield',
items: [
{
fieldLabel: 'First Name',
name: 'Firstname',
allowBlank: true
},
{
fieldLabel: 'Last Name',
name: 'Lastname',
allowBlank: true
},
{
fieldLabel: 'Phone',
name: 'Phone',
vtype: 'number',
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
submitAjaxConfig
);
wispUserFormWindow.show();
if (id) {
Ext.getCmp(wispUserFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers',
SOAPFunction: 'getWiSPUser',
SOAPParams: 'ID'
}
});
locationStore.load();
attributeStore.load();
groupStore.load();
}
}
// Display remove form
function showWiSPUserRemoveWindow(WiSPUserWindow,id) {
// Mask WiSPUserWindow window
WiSPUserWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this user?",
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(WiSPUserWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUsers',
SOAPFunction: 'removeWiSPUser',
SOAPParams: 'ID'
},
customSuccess: function() {
var store = Ext.getCmp(WiSPUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
});
// Unmask if user answered no
} else {
WiSPUserWindow.getEl().unmask();
}
}
});
}
// vim: ts=4
/*
* Ext JS Library 2.1
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/
#grid-example .x-grid-col-1 {
text-align: right;
}
#grid-example .x-grid-col-2{
text-align: right;
}
#grid-example .x-grid-col-3 {
text-align: right;
}
#grid-example .x-grid-col-4 {
text-align: right;
}
#grid-example.x-grid-mso{
border: 1px solid #6593cf;
}
#grid-example.x-grid-vista{
border: 1px solid #b3bcc0;
}
#xml-grid-example{
border: 1px solid #cbc7b8;
left: 0;
position: relative;
top: 0;
}
#editor-grid .x-grid-col-2{
text-align:right;
}
.x-grid3-td-topic b {
font-family:tahoma, verdana;
display:block;
}
.x-grid3-td-topic b i {
font-weight:normal;
font-style: normal;
color:#000;
}
.x-grid3-td-topic .x-grid3-cell-inner {
white-space:normal;
}
.x-grid3-td-topic a {
color: #385F95;
text-decoration:none;
}
.x-grid3-td-topic a:hover {
text-decoration:underline;
}
.details .x-btn-text {
background-image: url(details.gif);
}
.x-resizable-pinned .x-resizable-handle-south{
background:url(awitef/resources/extjs/images/default/sizer/s-handle-dark.gif);
background-position: top;
}