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 1746 additions and 727 deletions
/*
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) {
......@@ -6,12 +24,13 @@ function showAdminGroupAttributesWindow(groupID) {
// Window config
{
title: "Attributes",
iconCls: 'silk-table',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -20,22 +39,22 @@ function showAdminGroupAttributesWindow(groupID) {
{
text:'Add',
tooltip:'Add attribute',
iconCls:'add',
iconCls:'silk-table_add',
handler: function() {
showAdminGroupAttributeAddEditWindow(groupID);
showAdminGroupAttributeAddEditWindow(AdminGroupAttributesWindow,groupID);
}
},
'-',
{
text:'Edit',
tooltip:'Edit attribute',
iconCls:'edit',
iconCls:'silk-table_edit',
handler: function() {
var selectedItem = AdminGroupAttributesWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminGroupAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminGroupAttributeAddEditWindow(groupID,selectedItem.data.ID);
showAdminGroupAttributeAddEditWindow(AdminGroupAttributesWindow,groupID,selectedItem.data.ID);
} else {
AdminGroupAttributesWindow.getEl().mask();
......@@ -57,9 +76,9 @@ function showAdminGroupAttributesWindow(groupID) {
{
text:'Remove',
tooltip:'Remove attribute',
iconCls:'remove',
iconCls:'silk-table_delete',
handler: function() {
var selectedItem = AdminGroupAttributesWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminGroupAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -142,35 +161,57 @@ function showAdminGroupAttributesWindow(groupID) {
// Display edit/add form
function showAdminGroupAttributeAddEditWindow(groupID,attrID) {
function showAdminGroupAttributeAddEditWindow(AdminGroupAttributesWindow,groupID,attrID) {
var submitAjaxConfig;
var icon;
// We doing an update
if (attrID) {
icon = 'silk-table_edit';
submitAjaxConfig = {
ID: attrID,
SOAPFunction: 'updateAdminGroupAttribute',
SOAPParams:
'0:ID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
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 = {
GroupID: groupID,
SOAPFunction: 'addAdminGroupAttribute',
SOAPParams:
'0:GroupID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
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
}
});
}
};
}
......@@ -179,6 +220,7 @@ function showAdminGroupAttributeAddEditWindow(groupID,attrID) {
// Window config
{
title: "Attribute Information",
iconCls: icon,
width: 310,
height: 200,
......@@ -226,9 +268,9 @@ function showAdminGroupAttributeAddEditWindow(groupID,attrID) {
displayField: 'Operator',
valueField: 'Operator',
hiddenName: 'Operator',
forceSelection: true,
forceSelection: false,
triggerAction: 'all',
editable: false
editable: true
},
{
fieldLabel: "Value",
......@@ -239,8 +281,8 @@ function showAdminGroupAttributeAddEditWindow(groupID,attrID) {
xtype: 'checkbox',
fieldLabel: 'Disabled',
name: 'Disabled'
},
],
}
]
},
// Submit button config
submitAjaxConfig
......@@ -249,7 +291,7 @@ function showAdminGroupAttributeAddEditWindow(groupID,attrID) {
adminGroupAttributesFormWindow.show();
if (attrID) {
adminGroupAttributesFormWindow.getComponent('formpanel').load({
Ext.getCmp(adminGroupAttributesFormWindow.formPanelID).load({
params: {
ID: attrID,
SOAPUsername: globalConfig.soap.username,
......@@ -267,9 +309,9 @@ function showAdminGroupAttributeAddEditWindow(groupID,attrID) {
// Display remove form
function showAdminGroupAttributeRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
function showAdminGroupAttributeRemoveWindow(AdminGroupAttributesWindow,id) {
// Mask AdminGroupAttributesWindow window
AdminGroupAttributesWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -283,7 +325,7 @@ function showAdminGroupAttributeRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(AdminGroupAttributesWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -292,13 +334,21 @@ function showAdminGroupAttributeRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
AdminGroupAttributesWindow.getEl().unmask();
}
}
});
......
/*
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) {
......@@ -6,12 +24,13 @@ function showAdminGroupMembersWindow(groupID) {
// Window config
{
title: "Members",
iconCls: 'silk-user',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -20,9 +39,9 @@ function showAdminGroupMembersWindow(groupID) {
{
text:'Remove',
tooltip:'Remove member',
iconCls:'remove',
iconCls:'silk-user_delete',
handler: function() {
var selectedItem = AdminGroupMembersWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminGroupMembersWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -93,9 +112,9 @@ function showAdminGroupMembersWindow(groupID) {
// Display remove form
function showAdminGroupMemberRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
function showAdminGroupMemberRemoveWindow(AdminGroupMembersWindow,id) {
// Mask AdminGroupMembersWindow window
AdminGroupMembersWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -109,7 +128,7 @@ function showAdminGroupMemberRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(AdminGroupMembersWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -118,13 +137,21 @@ function showAdminGroupMemberRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
AdminGroupMembersWindow.getEl().unmask();
}
}
});
......
/*
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() {
......@@ -6,12 +24,13 @@ function showAdminGroupWindow() {
// Window config
{
title: "Groups",
iconCls: 'silk-group',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -20,22 +39,22 @@ function showAdminGroupWindow() {
{
text:'Add',
tooltip:'Add group',
iconCls:'add',
iconCls:'silk-group_add',
handler: function() {
showAdminGroupAddEditWindow();
showAdminGroupAddEditWindow(AdminGroupWindow);
}
},
'-',
{
text:'Edit',
tooltip:'Edit group',
iconCls:'edit',
iconCls:'silk-group_edit',
handler: function() {
var selectedItem = AdminGroupWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminGroupWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminGroupAddEditWindow(selectedItem.data.ID);
showAdminGroupAddEditWindow(AdminGroupWindow,selectedItem.data.ID);
} else {
AdminGroupWindow.getEl().mask();
......@@ -57,9 +76,9 @@ function showAdminGroupWindow() {
{
text:'Remove',
tooltip:'Remove group',
iconCls:'remove',
iconCls:'silk-group_delete',
handler: function() {
var selectedItem = AdminGroupWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminGroupWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -85,9 +104,9 @@ function showAdminGroupWindow() {
{
text:'Attributes',
tooltip:'Group attributes',
iconCls:'attributes',
iconCls:'silk-table',
handler: function() {
var selectedItem = AdminGroupWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminGroupWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -113,9 +132,9 @@ function showAdminGroupWindow() {
{
text:'Members',
tooltip:'Group members',
iconCls:'groups',
iconCls:'silk-group',
handler: function() {
var selectedItem = AdminGroupWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminGroupWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -197,27 +216,50 @@ function showAdminGroupWindow() {
// Display edit/add form
function showAdminGroupAddEditWindow(id) {
function showAdminGroupAddEditWindow(AdminGroupWindow,id) {
var submitAjaxConfig;
var icon;
// We doing an update
if (id) {
icon = 'silk-group_edit';
submitAjaxConfig = {
ID: id,
SOAPFunction: 'updateAdminGroup',
SOAPParams:
'0:ID,'+
'0:Name'
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 = {
SOAPFunction: 'createAdminGroup',
SOAPParams:
'0:Name'
params: {
SOAPFunction: 'createAdminGroup',
SOAPParams:
'0:Name'
},
onSuccess: function() {
var store = Ext.getCmp(AdminGroupWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
......@@ -226,6 +268,7 @@ function showAdminGroupAddEditWindow(id) {
// Window config
{
title: "Group Information",
iconCls: icon,
width: 310,
height: 113,
......@@ -246,11 +289,9 @@ function showAdminGroupAddEditWindow(id) {
{
fieldLabel: 'Name',
name: 'Name',
vtype: 'usernamePart',
maskRe: usernamePartRe,
allowBlank: false
},
],
}
]
},
// Submit button config
submitAjaxConfig
......@@ -259,7 +300,7 @@ function showAdminGroupAddEditWindow(id) {
adminGroupFormWindow.show();
if (id) {
adminGroupFormWindow.getComponent('formpanel').load({
Ext.getCmp(adminGroupFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -276,10 +317,10 @@ function showAdminGroupAddEditWindow(id) {
// Display edit/add form
function showAdminGroupRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
// Display remove form
function showAdminGroupRemoveWindow(AdminGroupWindow,id) {
// Mask AdminGroupWindow window
AdminGroupWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -293,7 +334,7 @@ function showAdminGroupRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(AdminGroupWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -302,13 +343,21 @@ function showAdminGroupRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
AdminGroupWindow.getEl().unmask();
}
}
});
......
/*
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) {
......@@ -6,12 +24,13 @@ function showAdminRealmAttributesWindow(realmID) {
// Window config
{
title: "Attributes",
iconCls: 'silk-table',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -20,22 +39,22 @@ function showAdminRealmAttributesWindow(realmID) {
{
text:'Add',
tooltip:'Add attribute',
iconCls:'add',
iconCls:'silk-table_add',
handler: function() {
showAdminRealmAttributeAddEditWindow(realmID);
showAdminRealmAttributeAddEditWindow(AdminRealmAttributesWindow,realmID);
}
},
'-',
{
text:'Edit',
tooltip:'Edit attribute',
iconCls:'edit',
iconCls:'silk-table_edit',
handler: function() {
var selectedItem = AdminRealmAttributesWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminRealmAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminRealmAttributeAddEditWindow(realmID,selectedItem.data.ID);
showAdminRealmAttributeAddEditWindow(AdminRealmAttributesWindow,realmID,selectedItem.data.ID);
} else {
AdminRealmAttributesWindow.getEl().mask();
......@@ -57,9 +76,9 @@ function showAdminRealmAttributesWindow(realmID) {
{
text:'Remove',
tooltip:'Remove attribute',
iconCls:'remove',
iconCls:'silk-table_delete',
handler: function() {
var selectedItem = AdminRealmAttributesWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminRealmAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -142,35 +161,58 @@ function showAdminRealmAttributesWindow(realmID) {
// Display edit/add form
function showAdminRealmAttributeAddEditWindow(realmID,attrID) {
function showAdminRealmAttributeAddEditWindow(AdminRealmAttributesWindow,realmID,attrID) {
var submitAjaxConfig;
var icon;
// We doing an update
if (attrID) {
icon = 'silk-table_edit';
submitAjaxConfig = {
ID: attrID,
SOAPFunction: 'updateAdminRealmAttribute',
SOAPParams:
'0:ID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
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 = {
RealmID: realmID,
SOAPFunction: 'addAdminRealmAttribute',
SOAPParams:
'0:RealmID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
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
}
});
}
};
}
......@@ -179,6 +221,7 @@ function showAdminRealmAttributeAddEditWindow(realmID,attrID) {
// Window config
{
title: "Attribute Information",
iconCls: icon,
width: 310,
height: 200,
......@@ -226,9 +269,9 @@ function showAdminRealmAttributeAddEditWindow(realmID,attrID) {
displayField: 'Operator',
valueField: 'Operator',
hiddenName: 'Operator',
forceSelection: true,
forceSelection: false,
triggerAction: 'all',
editable: false
editable: true
},
{
fieldLabel: "Value",
......@@ -239,8 +282,8 @@ function showAdminRealmAttributeAddEditWindow(realmID,attrID) {
xtype: 'checkbox',
fieldLabel: 'Disabled',
name: 'Disabled'
},
],
}
]
},
// Submit button config
submitAjaxConfig
......@@ -249,7 +292,7 @@ function showAdminRealmAttributeAddEditWindow(realmID,attrID) {
adminRealmAttributesFormWindow.show();
if (attrID) {
adminRealmAttributesFormWindow.getComponent('formpanel').load({
Ext.getCmp(adminRealmAttributesFormWindow.formPanelID).load({
params: {
ID: attrID,
SOAPUsername: globalConfig.soap.username,
......@@ -267,9 +310,9 @@ function showAdminRealmAttributeAddEditWindow(realmID,attrID) {
// Display remove form
function showAdminRealmAttributeRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
function showAdminRealmAttributeRemoveWindow(AdminRealmAttributesWindow,id) {
// Mask AdminRealmAttributesWindow window
AdminRealmAttributesWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -283,7 +326,7 @@ function showAdminRealmAttributeRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(AdminRealmAttributesWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -292,13 +335,21 @@ function showAdminRealmAttributeRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
AdminRealmAttributesWindow.getEl().unmask();
}
}
});
......
/*
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() {
......@@ -6,12 +24,13 @@ function showAdminRealmWindow() {
// Window config
{
title: "Realms",
iconCls: 'silk-world',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -20,22 +39,22 @@ function showAdminRealmWindow() {
{
text:'Add',
tooltip:'Add realm',
iconCls:'add',
iconCls:'silk-world_add',
handler: function() {
showAdminRealmAddEditWindow();
showAdminRealmAddEditWindow(AdminRealmWindow);
}
},
'-',
{
text:'Edit',
tooltip:'Edit realm',
iconCls:'edit',
iconCls:'silk-world_edit',
handler: function() {
var selectedItem = AdminRealmWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminRealmWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminRealmAddEditWindow(selectedItem.data.ID);
showAdminRealmAddEditWindow(AdminRealmWindow,selectedItem.data.ID);
} else {
AdminRealmWindow.getEl().mask();
......@@ -53,12 +72,13 @@ function showAdminRealmWindow() {
}
}
},
'-',
{
text:'Remove',
tooltip:'Remove realm',
iconCls:'remove',
iconCls:'silk-world_delete',
handler: function() {
var selectedItem = AdminRealmWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminRealmWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -84,9 +104,9 @@ function showAdminRealmWindow() {
{
text:'Attributes',
tooltip:'Realm attributes',
iconCls:'attributes',
iconCls:'silk-table',
handler: function() {
var selectedItem = AdminRealmWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminRealmWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -94,6 +114,34 @@ function showAdminRealmWindow() {
} 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",
......@@ -156,27 +204,50 @@ function showAdminRealmWindow() {
// Display edit/add form
function showAdminRealmAddEditWindow(id) {
function showAdminRealmAddEditWindow(AdminRealmWindow,id) {
var submitAjaxConfig;
var icon;
// We doing an update
if (id) {
icon = 'silk-world_edit';
submitAjaxConfig = {
ID: id,
SOAPFunction: 'updateAdminRealm',
SOAPParams:
'0:ID,'+
'0:Name'
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 = {
SOAPFunction: 'createAdminRealm',
SOAPParams:
'0:Name'
params: {
SOAPFunction: 'createAdminRealm',
SOAPParams:
'0:Name'
},
onSuccess: function() {
var store = Ext.getCmp(AdminRealmWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
......@@ -185,6 +256,7 @@ function showAdminRealmAddEditWindow(id) {
// Window config
{
title: "Realm Information",
iconCls: icon,
width: 310,
height: 113,
......@@ -205,11 +277,9 @@ function showAdminRealmAddEditWindow(id) {
{
fieldLabel: 'Name',
name: 'Name',
vtype: 'usernamePart',
maskRe: usernamePartRe,
allowBlank: false
},
],
}
]
},
// Submit button config
submitAjaxConfig
......@@ -218,7 +288,7 @@ function showAdminRealmAddEditWindow(id) {
adminRealmFormWindow.show();
if (id) {
adminRealmFormWindow.getComponent('formpanel').load({
Ext.getCmp(adminRealmFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -235,10 +305,10 @@ function showAdminRealmAddEditWindow(id) {
// Display edit/add form
function showAdminRealmRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
// Display remove form
function showAdminRealmRemoveWindow(AdminRealmWindow,id) {
// Mask AdminRealmWindow window
AdminRealmWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -252,7 +322,7 @@ function showAdminRealmRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(AdminRealmWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -261,13 +331,21 @@ function showAdminRealmRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
AdminRealmWindow.getEl().unmask();
}
}
});
......
/*
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) {
......@@ -6,12 +24,13 @@ function showAdminUserAttributesWindow(userID) {
// Window config
{
title: "Attributes",
iconCls: 'silk-table',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -20,22 +39,22 @@ function showAdminUserAttributesWindow(userID) {
{
text:'Add',
tooltip:'Add attribute',
iconCls:'add',
iconCls:'silk-table_add',
handler: function() {
showAdminUserAttributeAddEditWindow(userID);
showAdminUserAttributeAddEditWindow(AdminUserAttributesWindow,userID);
}
},
'-',
{
text:'Edit',
tooltip:'Edit attribute',
iconCls:'edit',
iconCls:'silk-table_edit',
handler: function() {
var selectedItem = AdminUserAttributesWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminUserAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserAttributeAddEditWindow(userID,selectedItem.data.ID);
showAdminUserAttributeAddEditWindow(AdminUserAttributesWindow,userID,selectedItem.data.ID);
} else {
AdminUserAttributesWindow.getEl().mask();
......@@ -57,9 +76,9 @@ function showAdminUserAttributesWindow(userID) {
{
text:'Remove',
tooltip:'Remove attribute',
iconCls:'remove',
iconCls:'silk-table_delete',
handler: function() {
var selectedItem = AdminUserAttributesWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminUserAttributesWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -142,35 +161,58 @@ function showAdminUserAttributesWindow(userID) {
// Display edit/add form
function showAdminUserAttributeAddEditWindow(userID,attrID) {
function showAdminUserAttributeAddEditWindow(AdminUserAttributesWindow,userID,attrID) {
var submitAjaxConfig;
var icon;
// We doing an update
if (attrID) {
icon = 'silk-table_edit';
submitAjaxConfig = {
ID: attrID,
SOAPFunction: 'updateAdminUserAttribute',
SOAPParams:
'0:ID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
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 = {
UserID: userID,
SOAPFunction: 'addAdminUserAttribute',
SOAPParams:
'0:UserID,'+
'0:Name,'+
'0:Operator,'+
'0:Value,'+
'0:Disabled:boolean'
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
}
});
}
};
}
......@@ -179,6 +221,7 @@ function showAdminUserAttributeAddEditWindow(userID,attrID) {
// Window config
{
title: "Attribute Information",
iconCls: icon,
width: 310,
height: 200,
......@@ -228,9 +271,9 @@ function showAdminUserAttributeAddEditWindow(userID,attrID) {
displayField: 'Operator',
valueField: 'Operator',
hiddenName: 'Operator',
forceSelection: true,
forceSelection: false,
triggerAction: 'all',
editable: false
editable: true
},
{
fieldLabel: "Value",
......@@ -241,8 +284,8 @@ function showAdminUserAttributeAddEditWindow(userID,attrID) {
xtype: 'checkbox',
fieldLabel: 'Disabled',
name: 'Disabled'
},
],
}
]
},
// Submit button config
submitAjaxConfig
......@@ -251,7 +294,7 @@ function showAdminUserAttributeAddEditWindow(userID,attrID) {
adminGroupFormWindow.show();
if (attrID) {
adminGroupFormWindow.getComponent('formpanel').load({
Ext.getCmp(adminGroupFormWindow.formPanelID).load({
params: {
ID: attrID,
SOAPUsername: globalConfig.soap.username,
......@@ -269,9 +312,9 @@ function showAdminUserAttributeAddEditWindow(userID,attrID) {
// Display remove form
function showAdminUserAttributeRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
function showAdminUserAttributeRemoveWindow(AdminUserAttributesWindow,id) {
// Mask AdminUserAttributesWindow window
AdminUserAttributesWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -285,7 +328,7 @@ function showAdminUserAttributeRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(AdminUserAttributesWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -294,13 +337,21 @@ function showAdminUserAttributeRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
AdminUserAttributesWindow.getEl().unmask();
}
}
});
......
/*
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) {
......@@ -6,12 +24,13 @@ function showAdminUserGroupsWindow(userID) {
// Window config
{
title: "Groups",
iconCls: 'silk-group',
width: 400,
height: 335,
minWidth: 400,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -20,18 +39,18 @@ function showAdminUserGroupsWindow(userID) {
{
text:'Add',
tooltip:'Add group',
iconCls:'add',
iconCls:'silk-group_add',
handler: function() {
showAdminUserGroupAddWindow(userID);
showAdminUserGroupAddWindow(AdminUserGroupsWindow,userID);
}
},
'-',
{
text:'Remove',
tooltip:'Remove group',
iconCls:'remove',
iconCls:'silk-group_delete',
handler: function() {
var selectedItem = AdminUserGroupsWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminUserGroupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -96,29 +115,52 @@ function showAdminUserGroupsWindow(userID) {
// Display edit/add form
function showAdminUserGroupAddWindow(userID,id) {
function showAdminUserGroupAddWindow(AdminUserGroupsWindow,userID,id) {
var submitAjaxConfig;
var icon;
// We doing an update
if (id) {
icon = 'silk-group_edit';
submitAjaxConfig = {
ID: id,
SOAPFunction: 'updateAdminGroup',
SOAPParams:
'0:ID,'+
'0:GroupID'
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 = {
UserID: userID,
SOAPFunction: 'addAdminUserGroup',
SOAPParams:
'0:UserID,'+
'0:GroupID'
params: {
UserID: userID,
SOAPFunction: 'addAdminUserGroup',
SOAPParams:
'0:UserID,'+
'0:GroupID'
},
onSuccess: function() {
var store = Ext.getCmp(AdminUserGroupsWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
......@@ -127,6 +169,7 @@ function showAdminUserGroupAddWindow(userID,id) {
// Window config
{
title: "Group Information",
iconCls: icon,
width: 310,
height: 113,
......@@ -169,8 +212,8 @@ function showAdminUserGroupAddWindow(userID,id) {
forceSelection: true,
triggerAction: 'all',
editable: false
},
],
}
]
},
// Submit button config
submitAjaxConfig
......@@ -179,7 +222,7 @@ function showAdminUserGroupAddWindow(userID,id) {
adminGroupFormWindow.show();
if (id) {
adminGroupFormWindow.getComponent('formpanel').load({
Ext.getCmp(adminGroupFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -197,9 +240,9 @@ function showAdminUserGroupAddWindow(userID,id) {
// Display edit/add form
function showAdminUserGroupRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
function showAdminUserGroupRemoveWindow(AdminUserGroupsWindow,id) {
// Mask AdminUserGroupsWindow window
AdminUserGroupsWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -213,7 +256,7 @@ function showAdminUserGroupRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(AdminUserGroupsWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -222,13 +265,21 @@ function showAdminUserGroupRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
AdminUserGroupsWindow.getEl().unmask();
}
}
});
......
/*
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) {
......@@ -6,10 +24,20 @@ function showAdminUserLogsWindow(id) {
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,
......@@ -20,46 +48,34 @@ function showAdminUserLogsWindow(id) {
uxItems: [
{
xtype: 'form',
id: 'search-form',
id: formID,
title: 'Search',
region: 'west',
border: true,
frame: true,
defaultType: 'datefield',
height: 180,
width: 320,
labelWidth: 100,
items: [
{
id: 'after',
name: 'after',
width: 180,
fieldLabel: 'From',
vtype: 'daterange',
format: 'Y-m-d',
value: firstOfMonth,
endDateField: 'before'
},
{
id: 'before',
name: 'before',
width: 180,
fieldLabel: 'To',
vtype: 'daterange',
format: 'Y-m-d',
value: firstOfNext,
startDateField: 'after'
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: 'formbtn',
id: formSearchButtonID,
handler: function() {
// Pull in window, grid & form
var mainWindow = this.ownerCt.ownerCt;
var grid = mainWindow.getComponent('gridpanel');
var form = mainWindow.getComponent('search-form');
var grid = Ext.getCmp(adminUserLogsWindow.gridPanelID);
// Grab store
var store = grid.getStore();
......@@ -68,18 +84,24 @@ function showAdminUserLogsWindow(id) {
var gridFilters = grid.filters;
var timestampFilter = gridFilters.getFilter('EventTimestamp');
// Grab form fields
var afterField = form.getForm().findField('after');
var beforeField = form.getForm().findField('before');
// 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: afterField.getValue(),
before: beforeField.getValue()
});
// Set filter values from form
timestampFilter.setValue({
after: dtSearchStart,
before: dtSearchEnd
});
// Trigger store reload
store.reload();
// Trigger store reload
store.reload();
}
}
}
],
......@@ -87,23 +109,24 @@ function showAdminUserLogsWindow(id) {
},
{
xtype: 'form',
id: 'summary-form',
id: summaryFormID,
region: 'center',
split: true,
border: true,
border: false,
autoScroll: true,
defaultType: 'textarea',
height: 180,
height: 300,
width: 400,
labelWidth: 80,
labelWidth: 0,
items: [
{
id: 'summaryTotal',
id: summaryTotalID,
name: 'summaryTotal',
readOnly: true,
height: 139,
width: 275,
height: 300,
width: 400,
fieldLabel: 'Summary',
hideLabel: true,
fieldClass: 'font-family: monospace; font-size: 10px;',
value: ''
}
......@@ -171,11 +194,13 @@ function showAdminUserLogsWindow(id) {
},
{
header: "Input Mbyte",
dataIndex: 'AcctInputMbyte'
dataIndex: 'AcctInput',
renderer: renderUsageFloat
},
{
header: "Output Mbyte",
dataIndex: 'AcctOutputMbyte'
dataIndex: 'AcctOutput',
renderer: renderUsageFloat
},
{
header: "Session Uptime",
......@@ -221,24 +246,20 @@ function showAdminUserLogsWindow(id) {
{type: 'string', dataIndex: 'CalledStationID'},
{type: 'string', dataIndex: 'AcctSessionID'},
{type: 'string', dataIndex: 'FramedIPAddress'},
{type: 'numeric', dataIndex: 'AcctInputMbyte'},
{type: 'numeric', dataIndex: 'AcctOutputMbyte'},
{type: 'numeric', dataIndex: 'AcctInput'},
{type: 'numeric', dataIndex: 'AcctOutput'},
{type: 'numeric', dataIndex: 'AcctSessionTime'},
{type: 'string', dataIndex: 'ConnectTermReason'}
]
}
);
// Grab store
var store = adminUserLogsWindow.getComponent('gridpanel').getStore();
var store = Ext.getCmp(adminUserLogsWindow.gridPanelID).getStore();
store.on('load',function() {
var inputTotal = store.sum('AcctInputMbyte');
var outputTotal = store.sum('AcctOutputMbyte');
var uptimeTotal = store.sum('AcctSessionTime');
var searchForm = adminUserLogsWindow.getComponent('search-form');
var afterField = (searchForm.getForm().findField('after')).getValue();
var beforeField = (searchForm.getForm().findField('before')).getValue();
// Fetch periodKey from form
var periodKeyField = (Ext.getCmp(formPeriodKeyID)).getValue();
// Mask parent window
adminUserLogsWindow.getEl().mask();
......@@ -247,90 +268,53 @@ function showAdminUserLogsWindow(id) {
adminUserLogsWindow,
{
params: {
From: afterField,
To: beforeField,
PeriodKey: periodKeyField,
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminUserLogs',
SOAPFunction: 'getAdminUserLogsSummary',
SOAPParams: '0:ID,0:From,0:To'
SOAPParams: '0:ID,0:PeriodKey'
},
customSuccess: function (result) {
response = Ext.decode(result.responseText);
// Traffic variables
// Caps
var trafficCap = response.data.trafficCap; // value of -1: prepaid
var trafficCurrentTopupUsed = response.data.trafficCurrentTopupUsed; // value of -1: no current topup
var trafficCurrentTopupCap = response.data.trafficCurrentTopupCap; // value of -1: no current topup
var trafficTopupRemaining = response.data.trafficTopupRemaining;
// Uptime variables
var uptimeCap = response.data.uptimeCap; // value of -1: prepaid
// Usage
var trafficUsage = response.data.trafficUsage;
var uptimeUsage = response.data.uptimeUsage;
var uptimeCurrentTopupUsed = response.data.uptimeCurrentTopupUsed; // value of -1: no current topup
var uptimeCurrentTopupCap = response.data.uptimeCurrentTopupCap; // value of -1: no current topup
var uptimeTopupRemaining = response.data.uptimeTopupRemaining;
// Total up traffic
var trafficTotalAllowed;
var validTrafficTopups;
if (trafficCurrentTopupCap > 0) {
validTrafficTopups = trafficCurrentTopupCap;
validTrafficTopups += trafficTopupRemaining;
} else {
validTrafficTopups = trafficTopupRemaining;
}
if (trafficCap < 0) {
trafficTotalAllowed = validTrafficTopups;
} else {
trafficTotalAllowed = trafficCap + validTrafficTopups;
}
// Traffic usage
var trafficUsage = inputTotal + outputTotal;
// Total up uptime
var uptimeTotalAllowed;
var validUptimeTopups;
if (uptimeCurrentTopupCap > 0) {
validUptimeTopups = uptimeCurrentTopupCap;
validUptimeTopups += uptimeTopupRemaining;
} else {
validUptimeTopups = uptimeTopupRemaining;
}
if (uptimeCap < 0) {
uptimeTotalAllowed = validUptimeTopups;
} else {
uptimeTotalAllowed = uptimeCap + validUptimeTopups;
}
// Get summary field
var form = adminUserLogsWindow.getComponent('summary-form');
var summaryTotal = form.getForm().findField('summaryTotal');
// 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 MB Topup: %d MB\n'+
'Usage: %d/%d MB\n=====================================\n',
trafficCap,validTrafficTopups,trafficUsage,trafficTotalAllowed);
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 Used: %d\n=====================================n',
trafficString += sprintf('Traffic:\nCap: Uncapped\nUsage: %d MB\n',
trafficUsage);
trafficString += '---\n';
// Capped traffic
} else {
trafficString += sprintf(' Traffic\nCap: %d MB Topup: %d MB\n'+
'Usage: %d/%d MB\n=====================================\n',
trafficCap,validTrafficTopups,trafficUsage,trafficTotalAllowed);
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
......@@ -338,29 +322,64 @@ function showAdminUserLogsWindow(id) {
// Prepaid uptime
if (uptimeCap == -1) {
uptimeCap = 'Prepaid';
uptimeString += sprintf(' Uptime\nCap: %s MB Topup: %d MB\n'+
'Usage: %d/%d MB',
uptimeCap,validUptimeTopups,uptimeTotal,uptimeTotalAllowed);
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 Used: %d',
uptimeTotal);
uptimeString += sprintf('Uptime:\nCap: Uncapped\nUsage: %d Min\n',
uptimeUsage);
uptimeString += '---\n';
// Capped uptime
} else {
uptimeString += sprintf(' Uptime\nCap: %d MB Topup: %d MB\n'+
'Usage: %d/%d MB',
uptimeCap,validUptimeTopups,uptimeTotal,uptimeTotalAllowed);
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';
}
summaryTotal.setValue(trafficString+uptimeString);
// 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) {
......@@ -6,11 +24,12 @@ function showAdminUserTopupsWindow(userID) {
// Window config
{
title: "User Topups",
iconCls: 'silk-chart_bar',
width: 500,
height: 335,
minWidth: 500,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -19,22 +38,22 @@ function showAdminUserTopupsWindow(userID) {
{
text:'Add',
tooltip:'Add topup',
iconCls:'add',
iconCls:'silk-chart_bar_add',
handler: function() {
showAdminUserTopupAddEditWindow(userID,0);
showAdminUserTopupAddEditWindow(adminUserTopupsWindow,userID,0);
}
},
'-',
{
text:'Edit',
tooltip:'Edit topup',
iconCls:'option',
iconCls:'silk-chart_bar_edit',
handler: function() {
var selectedItem = adminUserTopupsWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(adminUserTopupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserTopupAddEditWindow(userID,selectedItem.data.ID);
showAdminUserTopupAddEditWindow(adminUserTopupsWindow,userID,selectedItem.data.ID);
} else {
adminUserTopupsWindow.getEl().mask();
......@@ -56,9 +75,9 @@ function showAdminUserTopupsWindow(userID) {
{
text:'Remove',
tooltip:'Remove topup',
iconCls:'remove',
iconCls:'silk-chart_bar_delete',
handler: function() {
var selectedItem = adminUserTopupsWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(adminUserTopupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -116,7 +135,7 @@ function showAdminUserTopupsWindow(userID) {
sortable: true,
dataIndex: 'ValidTo'
}
]),
])
},
// Store config
{
......@@ -147,30 +166,53 @@ function showAdminUserTopupsWindow(userID) {
// Display edit/add form
function showAdminUserTopupAddEditWindow(userID,topupID) {
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 = {
ID: topupID,
SOAPFunction: 'updateAdminUserTopup',
SOAPParams:
'0:ID,0:Value,0:Type,'+
'0:ValidFrom,0:ValidTo'
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 = {
UserID: userID,
SOAPFunction: 'createAdminUserTopup',
SOAPParams:
'0:UserID,0:Value,0:Type,'+
'0:ValidFrom,0:ValidTo'
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
}
});
}
};
}
......@@ -179,6 +221,7 @@ function showAdminUserTopupAddEditWindow(userID,topupID) {
// Window config
{
title: "Topup Information",
iconCls: icon,
width: 400,
height: 200,
......@@ -225,6 +268,7 @@ function showAdminUserTopupAddEditWindow(userID,topupID) {
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'
......@@ -235,11 +279,12 @@ function showAdminUserTopupAddEditWindow(userID,topupID) {
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
......@@ -248,7 +293,7 @@ function showAdminUserTopupAddEditWindow(userID,topupID) {
adminUserTopupFormWindow.show();
if (topupID) {
adminUserTopupFormWindow.getComponent('formpanel').load({
Ext.getCmp(adminUserTopupFormWindow.formPanelID).load({
params: {
id: topupID,
SOAPUsername: globalConfig.soap.username,
......@@ -266,9 +311,9 @@ function showAdminUserTopupAddEditWindow(userID,topupID) {
// Display edit/add form
function showAdminUserTopupRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
function showAdminUserTopupRemoveWindow(adminUserTopupsWindow,id) {
// Mask adminUserTopupsWindow window
adminUserTopupsWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -282,7 +327,7 @@ function showAdminUserTopupRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(adminUserTopupsWindow,{
params: {
id: id,
SOAPUsername: globalConfig.soap.username,
......@@ -291,13 +336,21 @@ function showAdminUserTopupRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
adminUserTopupsWindow.getEl().unmask();
}
}
});
......
/*
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() {
......@@ -6,12 +24,13 @@ function showAdminUserWindow() {
// Window config
{
title: "Users",
iconCls: 'silk-user',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -20,22 +39,22 @@ function showAdminUserWindow() {
{
text:'Add',
tooltip:'Add user',
iconCls:'add',
iconCls:'silk-user_add',
handler: function() {
showAdminUserAddEditWindow();
showAdminUserAddEditWindow(AdminUserWindow);
}
},
'-',
{
text:'Edit',
tooltip:'Edit user',
iconCls:'option',
iconCls:'silk-user_edit',
handler: function() {
var selectedItem = AdminUserWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminUserAddEditWindow(selectedItem.data.ID);
showAdminUserAddEditWindow(AdminUserWindow,selectedItem.data.ID);
} else {
AdminUserWindow.getEl().mask();
......@@ -57,9 +76,9 @@ function showAdminUserWindow() {
{
text:'Remove',
tooltip:'Remove user',
iconCls:'remove',
iconCls:'silk-user_delete',
handler: function() {
var selectedItem = AdminUserWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -85,9 +104,9 @@ function showAdminUserWindow() {
{
text:'Attributes',
tooltip:'User attributes',
iconCls:'attributes',
iconCls:'silk-table',
handler: function() {
var selectedItem = AdminUserWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -113,9 +132,9 @@ function showAdminUserWindow() {
{
text:'Logs',
tooltip:'User logs',
iconCls:'logs',
iconCls: 'silk-page_white_text',
handler: function() {
var selectedItem = AdminUserWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -141,9 +160,9 @@ function showAdminUserWindow() {
{
text:'Groups',
tooltip:'User groups',
iconCls:'groups',
iconCls:'silk-group',
handler: function() {
var selectedItem = AdminUserWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -169,9 +188,9 @@ function showAdminUserWindow() {
{
text:'Topups',
tooltip:'User topups',
iconCls:'logs',
iconCls:'silk-chart_bar',
handler: function() {
var selectedItem = AdminUserWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(AdminUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -241,26 +260,51 @@ function showAdminUserWindow() {
// Display edit/add form
function showAdminUserAddEditWindow(id) {
function showAdminUserAddEditWindow(AdminUserWindow,id) {
var submitAjaxConfig;
var icon;
// We doing an update
if (id) {
icon = 'silk-user_edit';
submitAjaxConfig = {
ID: id,
SOAPFunction: 'updateAdminUser',
SOAPParams:
'0:ID,'+
'0:Username'
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 = {
SOAPFunction: 'createAdminUser',
SOAPParams:
'0:Username'
params: {
SOAPFunction: 'createAdminUser',
SOAPParams:
'0:Username,'+
'0:Disabled'
},
onSuccess: function() {
var store = Ext.getCmp(AdminUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
......@@ -269,12 +313,13 @@ function showAdminUserAddEditWindow(id) {
// Window config
{
title: "User Information",
iconCls: icon,
width: 310,
height: 113,
height: 133,
minWidth: 310,
minHeight: 113
minHeight: 133
},
// Form panel config
{
......@@ -289,11 +334,17 @@ function showAdminUserAddEditWindow(id) {
{
fieldLabel: 'Username',
name: 'Username',
vtype: 'usernamePart',
maskRe: usernamePartRe,
allowBlank: false,
vtype: 'usernameRadius',
maskRe: usernameRadiusPartRe,
allowBlank: false
},
],
{
fieldLabel: 'Disabled',
name: 'Disabled',
xtype: 'checkbox',
inputValue: '1'
}
]
},
// Submit button config
submitAjaxConfig
......@@ -302,7 +353,7 @@ function showAdminUserAddEditWindow(id) {
adminUserFormWindow.show();
if (id) {
adminUserFormWindow.getComponent('formpanel').load({
Ext.getCmp(adminUserFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -320,9 +371,9 @@ function showAdminUserAddEditWindow(id) {
// Display edit/add form
function showAdminUserRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
function showAdminUserRemoveWindow(AdminUserWindow,id) {
// Mask AdminUserWindow window
AdminUserWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -336,7 +387,7 @@ function showAdminUserRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(AdminUserWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -345,13 +396,21 @@ function showAdminUserRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
AdminUserWindow.getEl().unmask();
}
}
});
......
/*
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) {
......@@ -11,7 +29,7 @@ function showWiSPLocationMembersWindow(locationID) {
height: 335,
minWidth: 600,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -22,7 +40,7 @@ function showWiSPLocationMembersWindow(locationID) {
tooltip:'Remove member',
iconCls:'remove',
handler: function() {
var selectedItem = WiSPLocationMembersWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(WiSPLocationMembersWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -87,9 +105,9 @@ function showWiSPLocationMembersWindow(locationID) {
// Display remove form
function showWiSPLocationMemberRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
function showWiSPLocationMemberRemoveWindow(WiSPLocationMembersWindow,id) {
// Mask WiSPLocationMembersWindow window
WiSPLocationMembersWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -103,7 +121,7 @@ function showWiSPLocationMemberRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(WiSPLocationMembersWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -112,13 +130,21 @@ function showWiSPLocationMemberRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
WiSPLocationMembersWindow.getEl().unmask();
}
}
});
......
/*
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() {
......@@ -6,12 +24,13 @@ function showWiSPLocationWindow() {
// Window config
{
title: "Locations",
iconCls: 'silk-map',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -20,22 +39,22 @@ function showWiSPLocationWindow() {
{
text:'Add',
tooltip:'Add location',
iconCls:'add',
iconCls:'silk-map_add',
handler: function() {
showWiSPLocationAddEditWindow();
showWiSPLocationAddEditWindow(WiSPLocationWindow);
}
},
'-',
{
text:'Edit',
tooltip:'Edit location',
iconCls:'edit',
iconCls:'silk-map_edit',
handler: function() {
var selectedItem = WiSPLocationWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(WiSPLocationWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPLocationAddEditWindow(selectedItem.data.ID);
showWiSPLocationAddEditWindow(WiSPLocationWindow,selectedItem.data.ID);
} else {
WiSPLocationWindow.getEl().mask();
......@@ -57,9 +76,9 @@ function showWiSPLocationWindow() {
{
text:'Remove',
tooltip:'Remove location',
iconCls:'remove',
iconCls:'silk-map_delete',
handler: function() {
var selectedItem = WiSPLocationWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(WiSPLocationWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -85,9 +104,9 @@ function showWiSPLocationWindow() {
{
text:'Members',
tooltip:'List members',
iconCls:'groups',
iconCls:'silk-user',
handler: function() {
var selectedItem = WiSPLocationWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(WiSPLocationWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -151,26 +170,49 @@ function showWiSPLocationWindow() {
// Display edit/add form
function showWiSPLocationAddEditWindow(id) {
function showWiSPLocationAddEditWindow(WiSPLocationWindow,id) {
var submitAjaxConfig;
var icon;
// We doing an update
if (id) {
icon = 'silk-map_edit';
submitAjaxConfig = {
ID: id,
SOAPFunction: 'updateWiSPLocation',
SOAPParams:
'0:ID,'+
'0:Name'
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 = {
SOAPFunction: 'createWiSPLocation',
SOAPParams:
'0:Name'
params: {
SOAPFunction: 'createWiSPLocation',
SOAPParams:
'0:Name'
},
onSuccess: function() {
var store = Ext.getCmp(WiSPLocationWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
}
};
}
......@@ -179,6 +221,7 @@ function showWiSPLocationAddEditWindow(id) {
// Window config
{
title: "Location Information",
iconCls: icon,
width: 310,
height: 113,
......@@ -200,8 +243,8 @@ function showWiSPLocationAddEditWindow(id) {
fieldLabel: 'Name',
name: 'Name',
allowBlank: false
},
],
}
]
},
// Submit button config
submitAjaxConfig
......@@ -210,7 +253,7 @@ function showWiSPLocationAddEditWindow(id) {
wispLocationFormWindow.show();
if (id) {
wispLocationFormWindow.getComponent('formpanel').load({
Ext.getCmp(wispLocationFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -226,9 +269,9 @@ function showWiSPLocationAddEditWindow(id) {
// Display remove form
function showWiSPLocationRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
function showWiSPLocationRemoveWindow(WiSPLocationWindow,id) {
// Mask WiSPLocationWindow window
WiSPLocationWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -242,7 +285,7 @@ function showWiSPLocationRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(WiSPLocationWindow,{
params: {
id: id,
SOAPUsername: globalConfig.soap.username,
......@@ -251,13 +294,21 @@ function showWiSPLocationRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
WiSPLocationWindow.getEl().unmask();
}
}
});
......
/*
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() {
......@@ -11,7 +29,7 @@ function showWiSPResellersWindow() {
height: 335,
minWidth: 400,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -31,7 +49,7 @@ function showWiSPResellersWindow() {
tooltip:'Edit Reseller',
iconCls:'option',
handler: function() {
var selectedItem = WiSPResellerWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(WiSPResellerWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -59,7 +77,7 @@ function showWiSPResellersWindow() {
tooltip:'Remove Reseller',
iconCls:'remove',
handler: function() {
var selectedItem = WiSPResellerWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(WiSPResellerWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -254,7 +272,7 @@ function showWiSPResellerEditWindow(id) {
}
]
}
],
]
},
// Submit button config
submitAjaxConfig
......@@ -263,7 +281,7 @@ function showWiSPResellerEditWindow(id) {
WiSPResellerFormWindow.show();
if (id) {
WiSPResellerFormWindow.getComponent('formpanel').load({
Ext.getCmp(WiSPResellerFormWindow.formPanelID).load({
params: {
id: id,
SOAPUsername: globalConfig.soap.username,
......
/*
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) {
......@@ -6,10 +24,20 @@ function showWiSPUserLogsWindow(id) {
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,
......@@ -20,46 +48,34 @@ function showWiSPUserLogsWindow(id) {
uxItems: [
{
xtype: 'form',
id: 'search-form',
id: formID,
title: 'Search',
region: 'west',
border: true,
frame: true,
defaultType: 'datefield',
height: 180,
width: 320,
labelWidth: 100,
items: [
{
id: 'after',
name: 'after',
width: 180,
fieldLabel: 'From',
vtype: 'daterange',
format: 'Y-m-d',
value: firstOfMonth,
endDateField: 'before'
},
{
id: 'before',
name: 'before',
width: 180,
fieldLabel: 'To',
vtype: 'daterange',
format: 'Y-m-d',
value: firstOfNext,
startDateField: 'after'
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: 'formbtn',
id: formSearchButtonID,
handler: function() {
// Pull in window, grid & form
var mainWindow = this.ownerCt.ownerCt;
var grid = mainWindow.getComponent('gridpanel');
var form = mainWindow.getComponent('search-form');
var grid = Ext.getCmp(wispUserLogsWindow.gridPanelID);
// Grab store
var store = grid.getStore();
......@@ -68,18 +84,24 @@ function showWiSPUserLogsWindow(id) {
var gridFilters = grid.filters;
var timestampFilter = gridFilters.getFilter('EventTimestamp');
// Grab form fields
var afterField = form.getForm().findField('after');
var beforeField = form.getForm().findField('before');
// 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: afterField.getValue(),
before: beforeField.getValue()
});
// Set filter values from form
timestampFilter.setValue({
after: dtSearchStart,
before: dtSearchEnd
});
// Trigger store reload
store.reload();
// Trigger store reload
store.reload();
}
}
}
],
......@@ -87,23 +109,24 @@ function showWiSPUserLogsWindow(id) {
},
{
xtype: 'form',
id: 'summary-form',
id: summaryFormID,
region: 'center',
split: true,
border: true,
border: false,
autoScroll: true,
defaultType: 'textarea',
height: 180,
height: 300,
width: 400,
labelWidth: 80,
labelWidth: 0,
items: [
{
id: 'summaryTotal',
id: summaryTotalID,
name: 'summaryTotal',
readOnly: true,
height: 139,
width: 275,
height: 300,
width: 400,
fieldLabel: 'Summary',
hideLabel: true,
fieldClass: 'font-family: monospace; font-size: 10px;',
value: ''
}
......@@ -171,11 +194,13 @@ function showWiSPUserLogsWindow(id) {
},
{
header: "Input Mbyte",
dataIndex: 'AcctInputMbyte'
dataIndex: 'AcctInput',
renderer: renderUsageFloat
},
{
header: "Output Mbyte",
dataIndex: 'AcctOutputMbyte'
dataIndex: 'AcctOutput',
renderer: renderUsageFloat
},
{
header: "Session Uptime",
......@@ -204,9 +229,9 @@ function showWiSPUserLogsWindow(id) {
filters: [
{type: 'numeric', dataIndex: 'ID'},
{
type: 'date',
type: 'date',
format: 'Y-m-d H:i:s',
dataIndex: 'EventTimestamp',
dataIndex: 'EventTimestamp',
value: {
after: firstOfMonth,
before: firstOfNext
......@@ -221,24 +246,20 @@ function showWiSPUserLogsWindow(id) {
{type: 'string', dataIndex: 'CalledStationID'},
{type: 'string', dataIndex: 'AcctSessionID'},
{type: 'string', dataIndex: 'FramedIPAddress'},
{type: 'numeric', dataIndex: 'AcctInputMbyte'},
{type: 'numeric', dataIndex: 'AcctOutputMbyte'},
{type: 'numeric', dataIndex: 'AcctInput'},
{type: 'numeric', dataIndex: 'AcctOutput'},
{type: 'numeric', dataIndex: 'AcctSessionTime'},
{type: 'string', dataIndex: 'ConnectTermReason'}
]
}
);
// Grab store
var store = wispUserLogsWindow.getComponent('gridpanel').getStore();
var store = Ext.getCmp(wispUserLogsWindow.gridPanelID).getStore();
store.on('load',function() {
var inputTotal = store.sum('AcctInputMbyte');
var outputTotal = store.sum('AcctOutputMbyte');
var uptimeTotal = store.sum('AcctSessionTime');
var searchForm = wispUserLogsWindow.getComponent('search-form');
var afterField = (searchForm.getForm().findField('after')).getValue();
var beforeField = (searchForm.getForm().findField('before')).getValue();
// Fetch periodKey from form
var periodKeyField = (Ext.getCmp(formPeriodKeyID)).getValue();
// Mask parent window
wispUserLogsWindow.getEl().mask();
......@@ -247,90 +268,53 @@ function showWiSPUserLogsWindow(id) {
wispUserLogsWindow,
{
params: {
From: afterField,
To: beforeField,
PeriodKey: periodKeyField,
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPUserLogs',
SOAPFunction: 'getWiSPUserLogsSummary',
SOAPParams: '0:ID,0:From,0:To'
SOAPParams: '0:ID,0:PeriodKey'
},
customSuccess: function (result) {
response = Ext.decode(result.responseText);
// Traffic variables
// Caps
var trafficCap = response.data.trafficCap; // value of -1: prepaid
var trafficCurrentTopupUsed = response.data.trafficCurrentTopupUsed; // value of -1: no current topup
var trafficCurrentTopupCap = response.data.trafficCurrentTopupCap; // value of -1: no current topup
var trafficTopupRemaining = response.data.trafficTopupRemaining;
// Uptime variables
var uptimeCap = response.data.uptimeCap; // value of -1: prepaid
// Usage
var trafficUsage = response.data.trafficUsage;
var uptimeUsage = response.data.uptimeUsage;
var uptimeCurrentTopupUsed = response.data.uptimeCurrentTopupUsed; // value of -1: no current topup
var uptimeCurrentTopupCap = response.data.uptimeCurrentTopupCap; // value of -1: no current topup
var uptimeTopupRemaining = response.data.uptimeTopupRemaining;
// Total up traffic
var trafficTotalAllowed;
var validTrafficTopups;
if (trafficCurrentTopupCap > 0) {
validTrafficTopups = trafficCurrentTopupCap;
validTrafficTopups += trafficTopupRemaining;
} else {
validTrafficTopups = trafficTopupRemaining;
}
if (trafficCap < 0) {
trafficTotalAllowed = validTrafficTopups;
} else {
trafficTotalAllowed = trafficCap + validTrafficTopups;
}
// Traffic usage
var trafficUsage = inputTotal + outputTotal;
// Total up uptime
var uptimeTotalAllowed;
var validUptimeTopups;
if (uptimeCurrentTopupCap > 0) {
validUptimeTopups = uptimeCurrentTopupCap;
validUptimeTopups += uptimeTopupRemaining;
} else {
validUptimeTopups = uptimeTopupRemaining;
}
if (uptimeCap < 0) {
uptimeTotalAllowed = validUptimeTopups;
} else {
uptimeTotalAllowed = uptimeCap + validUptimeTopups;
}
// Get summary field
var form = wispUserLogsWindow.getComponent('summary-form');
var summaryTotal = form.getForm().findField('summaryTotal');
// 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 MB Topup: %d MB\n'+
'Usage: %d/%d MB\n=====================================\n',
trafficCap,validTrafficTopups,trafficUsage,trafficTotalAllowed);
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 Used: %d\n=====================================n',
trafficString += sprintf('Traffic:\nCap: Uncapped\nUsage: %d MB\n',
trafficUsage);
trafficString += '---\n';
// Capped traffic
} else {
trafficString += sprintf(' Traffic\nCap: %d MB Topup: %d MB\n'+
'Usage: %d/%d MB\n=====================================\n',
trafficCap,validTrafficTopups,trafficUsage,trafficTotalAllowed);
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
......@@ -338,29 +322,64 @@ function showWiSPUserLogsWindow(id) {
// Prepaid uptime
if (uptimeCap == -1) {
uptimeCap = 'Prepaid';
uptimeString += sprintf(' Uptime\nCap: %s MB Topup: %d MB\n'+
'Usage: %d/%d MB',
uptimeCap,validUptimeTopups,uptimeTotal,uptimeTotalAllowed);
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 Used: %d',
uptimeTotal);
uptimeString += sprintf('Uptime:\nCap: Uncapped\nUsage: %d Min\n',
uptimeUsage);
uptimeString += '---\n';
// Capped uptime
} else {
uptimeString += sprintf(' Uptime\nCap: %d MB Topup: %d MB\n'+
'Usage: %d/%d MB',
uptimeCap,validUptimeTopups,uptimeTotal,uptimeTotalAllowed);
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';
}
summaryTotal.setValue(trafficString+uptimeString);
// Topup breakdown
var tTopups = response.data.AllTrafficTopups;
var uTopups = response.data.AllUptimeTopups;
// Format topups string
var topupString = '';
if (tTopups.length > 0) {
topupString += 'Valid Traffic Topups:';
}
for (var i = 0; i < tTopups.length; i++) {
var id = tTopups[i].ID;
var used = tTopups[i].Used;
var cap = tTopups[i].Cap;
var validTo = tTopups[i].ValidTo;
topupString += sprintf('\nID: %s\nUsage: %d/%d MB\nValid Until: %s\n--',id,used,cap,validTo);
}
if (uTopups.length > 0) {
topupString += 'Valid Uptime Topups:';
}
for (var i = 0; i < uTopups.length; i++) {
var id = uTopups[i].ID;
var used = uTopups[i].Used;
var cap = uTopups[i].Cap;
var validTo = uTopups[i].ValidTo;
topupString += sprintf('\nID: %s\nUsage: %d/%d MB\nValid Until: %s\n--',id,used,cap,validTo);
}
// Get summary field
var form = Ext.getCmp(summaryFormID);
var summaryField = Ext.getCmp(summaryTotalID);
summaryField.setValue(trafficString+uptimeString+topupString);
},
failure: function (result) {
Ext.MessageBox.alert('Failed', 'Couldn\'t fetch data: '+result.date);
},
}
}
);
});
wispUserLogsWindow.show();
wispUserLogsWindow.show();
}
// vim: ts=4
/*
WiSP User Topups
Copyright (C) 2007-2011, AllWorldIT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
function showWiSPUserTopupsWindow(userID) {
......@@ -6,11 +24,12 @@ function showWiSPUserTopupsWindow(userID) {
// Window config
{
title: "User Topups",
iconCls: 'silk-chart_bar',
width: 500,
height: 335,
minWidth: 500,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -19,22 +38,22 @@ function showWiSPUserTopupsWindow(userID) {
{
text:'Add',
tooltip:'Add topup',
iconCls:'add',
iconCls:'silk-chart_bar_add',
handler: function() {
showWiSPUserTopupAddEditWindow(userID,0);
showWiSPUserTopupAddEditWindow(wispUserTopupsWindow,userID,0);
}
},
'-',
{
text:'Edit',
tooltip:'Edit topup',
iconCls:'option',
iconCls:'silk-chart_bar_edit',
handler: function() {
var selectedItem = wispUserTopupsWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(wispUserTopupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPUserTopupAddEditWindow(userID,selectedItem.data.ID);
showWiSPUserTopupAddEditWindow(wispUserTopupsWindow,userID,selectedItem.data.ID);
} else {
wispUserTopupsWindow.getEl().mask();
......@@ -56,9 +75,9 @@ function showWiSPUserTopupsWindow(userID) {
{
text:'Remove',
tooltip:'Remove topup',
iconCls:'remove',
iconCls:'silk-chart_bar_delete',
handler: function() {
var selectedItem = wispUserTopupsWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(wispUserTopupsWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -116,7 +135,7 @@ function showWiSPUserTopupsWindow(userID) {
sortable: true,
dataIndex: 'ValidTo'
}
]),
])
},
// Store config
{
......@@ -147,30 +166,53 @@ function showWiSPUserTopupsWindow(userID) {
// Display edit/add form
function showWiSPUserTopupAddEditWindow(userID,topupID) {
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 = {
ID: topupID,
SOAPFunction: 'updateWiSPUserTopup',
SOAPParams:
'0:ID,0:Value,0:Type,'+
'0:ValidFrom,0:ValidTo'
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 = {
UserID: userID,
SOAPFunction: 'createWiSPUserTopup',
SOAPParams:
'0:UserID,0:Value,0:Type,'+
'0:ValidFrom,0:ValidTo'
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
}
});
}
};
}
......@@ -179,6 +221,7 @@ function showWiSPUserTopupAddEditWindow(userID,topupID) {
// Window config
{
title: "Topup Information",
iconCls: icon,
width: 400,
height: 200,
......@@ -225,6 +268,7 @@ function showWiSPUserTopupAddEditWindow(userID,topupID) {
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'
......@@ -235,11 +279,12 @@ function showWiSPUserTopupAddEditWindow(userID,topupID) {
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
......@@ -248,7 +293,7 @@ function showWiSPUserTopupAddEditWindow(userID,topupID) {
wispUserTopupFormWindow.show();
if (topupID) {
wispUserTopupFormWindow.getComponent('formpanel').load({
Ext.getCmp(wispUserTopupFormWindow.formPanelID).load({
params: {
id: topupID,
SOAPUsername: globalConfig.soap.username,
......@@ -265,10 +310,10 @@ function showWiSPUserTopupAddEditWindow(userID,topupID) {
// Display edit/add form
function showWiSPUserTopupRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
// Display remove form
function showWiSPUserTopupRemoveWindow(wispUserTopupsWindow,id) {
// Mask wispUserTopupsWindow window
wispUserTopupsWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -282,7 +327,7 @@ function showWiSPUserTopupRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(wispUserTopupsWindow,{
params: {
id: id,
SOAPUsername: globalConfig.soap.username,
......@@ -291,13 +336,21 @@ function showWiSPUserTopupRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
wispUserTopupsWindow.getEl().unmask();
}
}
});
......
/*
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() {
......@@ -6,12 +24,13 @@ function showWiSPUserWindow() {
// Window config
{
title: "Users",
iconCls: 'silk-user',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335,
minHeight: 335
},
// Grid config
{
......@@ -20,22 +39,22 @@ function showWiSPUserWindow() {
{
text:'Add',
tooltip:'Add user',
iconCls:'add',
iconCls:'silk-user_add',
handler: function() {
showWiSPUserAddEditWindow();
showWiSPUserAddEditWindow(WiSPUserWindow);
}
},
'-',
},
'-',
{
text:'Edit',
tooltip:'Edit user',
iconCls:'option',
iconCls:'silk-user_edit',
handler: function() {
var selectedItem = WiSPUserWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPUserAddEditWindow(selectedItem.data.ID);
showWiSPUserAddEditWindow(WiSPUserWindow,selectedItem.data.ID);
} else {
WiSPUserWindow.getEl().mask();
......@@ -57,9 +76,9 @@ function showWiSPUserWindow() {
{
text:'Remove',
tooltip:'Remove user',
iconCls:'remove',
iconCls:'silk-user_delete',
handler: function() {
var selectedItem = WiSPUserWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -85,9 +104,9 @@ function showWiSPUserWindow() {
{
text:'Logs',
tooltip:'User logs',
iconCls:'logs',
iconCls: 'silk-page_white_text',
handler: function() {
var selectedItem = WiSPUserWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -113,9 +132,9 @@ function showWiSPUserWindow() {
{
text:'Topups',
tooltip:'User topups',
iconCls:'logs',
iconCls:'silk-chart_bar',
handler: function() {
var selectedItem = WiSPUserWindow.getComponent('gridpanel').getSelectionModel().getSelected();
var selectedItem = Ext.getCmp(WiSPUserWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
......@@ -151,11 +170,6 @@ function showWiSPUserWindow() {
sortable: true,
dataIndex: 'Username'
},
{
header: "Disabled",
sortable: true,
dataIndex: 'Disabled'
},
{
header: "First Name",
sortable: true,
......@@ -175,6 +189,11 @@ function showWiSPUserWindow() {
header: "Phone",
sortable: true,
dataIndex: 'Phone'
},
{
header: "Disabled",
sortable: true,
dataIndex: 'Disabled'
}
]),
autoExpandColumn: 'Username'
......@@ -209,62 +228,177 @@ function showWiSPUserWindow() {
// Display edit/add form
function showWiSPUserAddEditWindow(id) {
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;
attributeStore = new Ext.data.SimpleStore({
fields: [
'name', 'operator', 'value', 'modifier'
],
});
// Attribute record that can be added to above store
var attributeRecord = Ext.data.Record.create([
{name: 'name'},
{name: 'operator'},
{name: 'value'},
{name: 'modifier'}
// 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;
groupStore = new Ext.data.SimpleStore({
fields: [
'name'
],
});
// Group record that can be added to above store
var groupRecord = Ext.data.Record.create([
{name: 'name'}
]);
// 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 = {
ID: id,
SOAPFunction: 'updateWiSPUser',
SOAPParams:
'0:ID,'+
'0:Username,'+
'0:Password,'+
'0:Firstname,'+
'0:Lastname,'+
'0:Phone,'+
'0:LocationID,'+
'0:Email'
};
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:
SOAPParams:
'0:Username,'+
'0:Disabled,'+
'0:Password,'+
'0:Firstname,'+
'0:Lastname,'+
......@@ -276,6 +410,14 @@ function showWiSPUserAddEditWindow(id) {
'0:Number,'+
'0:Prefix'
},
onSuccess: function() {
var store = Ext.getCmp(WiSPUserWindow.gridPanelID).getStore();
store.load({
params: {
limit: 25
}
});
},
hook: function() {
// Get modified attribute records
......@@ -284,20 +426,24 @@ function showWiSPUserAddEditWindow(id) {
var groups = groupStore.getModifiedRecords();
var ret = { };
// Loop and add to our hash
for(var i = 0, len = attributes.length; i < len; i++){
// Set attributes we will be adding
for (var i = 0, len = attributes.length; i < len; i++) {
var attribute = attributes[i];
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');
}
// Loop and add to our hash
for(var i = 0, len = groups.length; i < len; 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];
ret['Groups['+i+'][Name]'] = group.get('name');
}
// Safe to add this attribute
ret['Groups['+i+'][Name]'] = group.get('Name');
}
return ret;
}
};
......@@ -307,43 +453,49 @@ function showWiSPUserAddEditWindow(id) {
// Build the attribute editor grid
var attributeEditor = new Ext.grid.EditorGridPanel({
plain: true,
height: 120,
autoScroll: true,
autoHeight: true,
// Set row selection model
selModel: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
// Inline toolbars
tbar: [
{
text:'Add',
tooltip:'Add attribute',
iconCls:'add',
iconCls:'silk-table_add',
handler: function() {
var newAttrStoreRecord = new attributeRecord({
name: '',
operator: '',
value: '',
modifier: ''
ID: attributeInsertID,
Name: '',
Operator: '',
Value: '',
Modifier: ''
});
attributeStore.insert(0,newAttrStoreRecord);
attributeInsertID -= 1;
}
},
'-',
},
'-',
{
text:'Remove',
tooltip:'Remove attribute',
iconCls:'remove',
iconCls:'silk-table_delete',
handler: function() {
var selectedItem = attributeEditor.getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so remove
// 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();
......@@ -360,40 +512,47 @@ function showWiSPUserAddEditWindow(id) {
});
}
}
},
}
],
cm: new Ext.grid.ColumnModel([
{
id: 'name',
id: 'ID',
header: 'ID',
dataIndex: 'ID',
hidden: true,
width: 30
},
{
id: 'Name',
header: 'Name',
dataIndex: 'name',
dataIndex: 'Name',
width: 150,
editor: new Ext.form.ComboBox({
allowBlank: false,
mode: 'local',
store: [
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,
editable: false
})
},
{
id: 'operator',
id: 'Operator',
header: 'Operator',
dataIndex: 'operator',
dataIndex: 'Operator',
width: 300,
editor: new Ext.form.ComboBox({
allowBlank: false,
mode: 'local',
store: [
[ '=', 'Add as reply if unique' ],
store: [
[ '=', 'Add as reply if unique' ],
[ ':=', 'Set configuration value' ],
[ '==', 'Match value in request' ],
[ '==', 'Match value in request' ],
[ '+=', 'Add reply and set configuration' ],
[ '!=', 'Inverse match value in request' ],
[ '<', 'Match less-than value in request' ],
......@@ -407,28 +566,28 @@ function showWiSPUserAddEditWindow(id) {
[ '||==', 'Match any of these values in request' ]
],
triggerAction: 'all',
editable: true,
editable: true
})
},
{
id: 'value',
id: 'Value',
header: 'Value',
dataIndex: 'value',
dataIndex: 'Value',
width: 100,
editor: new Ext.form.TextField({
allowBlank: false,
allowBlank: false
})
},
{
id: 'modifier',
id: 'Modifier',
header: 'Modifier',
dataIndex: 'modifier',
dataIndex: 'Modifier',
width: 80,
editor: new Ext.form.ComboBox({
allowBlank: false,
mode: 'local',
store: [
[ 'Seconds', 'Seconds' ],
store: [
[ 'Seconds', 'Seconds' ],
[ 'Minutes', 'Minutes' ],
[ 'Hours', 'Hours' ],
[ 'Days', 'Days' ],
......@@ -436,21 +595,32 @@ function showWiSPUserAddEditWindow(id) {
[ 'Months', 'Months' ],
[ 'MBytes', 'MBytes' ],
[ 'GBytes', 'GBytes' ],
[ 'TBytes', 'TBytes' ],
[ 'TBytes', 'TBytes' ]
],
triggerAction: 'all',
editable: true,
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,
height: 120,
autoScroll: true,
autoHeight: true,
// Set row selection model
selModel: new Ext.grid.RowSelectionModel({
......@@ -462,27 +632,34 @@ function showWiSPUserAddEditWindow(id) {
{
text:'Add',
tooltip:'Add group',
iconCls:'add',
iconCls:'silk-group_add',
handler: function() {
var newGroupStoreRecord = new groupRecord({
name: ''
ID: groupInsertID,
Name: ''
});
groupStore.insert(0,newGroupStoreRecord);
groupInsertID -= 1;
}
},
'-',
},
'-',
{
text:'Remove',
tooltip:'Remove group',
iconCls:'remove',
iconCls:'silk-group_delete',
handler: function() {
var selectedItem = groupEditor.getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so remove
// 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();
......@@ -499,16 +676,24 @@ function showWiSPUserAddEditWindow(id) {
});
}
}
},
}
],
cm: new Ext.grid.ColumnModel([
{
id: 'name',
id: 'ID',
header: 'ID',
dataIndex: 'ID',
hidden: true,
width: 30
},
{
id: 'Name',
header: 'Name',
dataIndex: 'name',
dataIndex: 'Name',
width: 150,
editor: new Ext.form.ComboBox({
id: editorComboBoxID,
allowBlank: false,
store: new Ext.ux.JsonStore({
sortInfo: { field: "Name", direction: "ASC" },
......@@ -526,23 +711,37 @@ function showWiSPUserAddEditWindow(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: 342,
height: 362,
minWidth: 700,
minHeight: 342
minHeight: 362
},
// Form panel config
{
......@@ -557,16 +756,20 @@ function showWiSPUserAddEditWindow(id) {
{
fieldLabel: 'Username',
name: 'Username',
vtype: 'usernamePart',
maskRe: usernamePartRe,
allowBlank: true,
vtype: 'usernameRadius',
maskRe: usernameRadiusPartRe,
allowBlank: true
},
{
fieldLabel: 'Password',
name: 'Password',
vtype: 'usernamePart',
maskRe: usernamePartRe,
allowBlank: true,
allowBlank: true
},
{
fieldLabel: 'Disabled',
name: 'Disabled',
xtype: 'checkbox',
inputValue: '1'
},
{
xtype: 'tabpanel',
......@@ -574,27 +777,27 @@ function showWiSPUserAddEditWindow(id) {
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',
vtype: 'usernamePart',
allowBlank: true
},
{
fieldLabel: 'Last Name',
name: 'Lastname',
vtype: 'usernamePart',
allowBlank: true
},
{
......@@ -615,29 +818,21 @@ function showWiSPUserAddEditWindow(id) {
allowBlank: true,
width: 140,
store: 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'
}
}),
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
......@@ -645,7 +840,9 @@ function showWiSPUserAddEditWindow(id) {
},
{
title: 'Attributes',
iconCls: 'silk-table',
layout: 'form',
autoScroll: true,
defaultType: 'textfield',
items: [
attributeEditor
......@@ -653,25 +850,26 @@ function showWiSPUserAddEditWindow(id) {
},
{
title: 'Add Many',
iconCls: 'silk-user_suit',
layout: 'form',
defaultType: 'textfield',
items: [
{
fieldLabel: 'Prefix',
name: 'Prefix',
allowBlank: true,
allowBlank: true
},
{
fieldLabel: 'Number',
name: 'Number',
vtype: 'number',
allowBlank: true,
},
allowBlank: true
}
]
},
}
]
},
],
}
]
},
// Submit button config
submitAjaxConfig
......@@ -679,7 +877,7 @@ function showWiSPUserAddEditWindow(id) {
wispUserFormWindow.show();
if (id) {
wispUserFormWindow.getComponent('formpanel').load({
Ext.getCmp(wispUserFormWindow.formPanelID).load({
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -690,16 +888,19 @@ function showWiSPUserAddEditWindow(id) {
SOAPParams: 'ID'
}
});
locationStore.load();
attributeStore.load();
groupStore.load();
}
}
// Display edit/add form
function showWiSPUserRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
// Display remove form
function showWiSPUserRemoveWindow(WiSPUserWindow,id) {
// Mask WiSPUserWindow window
WiSPUserWindow.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
......@@ -713,7 +914,7 @@ function showWiSPUserRemoveWindow(parent,id) {
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
uxAjaxRequest(WiSPUserWindow,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
......@@ -722,13 +923,21 @@ function showWiSPUserRemoveWindow(parent,id) {
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 {
parent.getEl().unmask();
WiSPUserWindow.getEl().unmask();
}
}
});
......
......@@ -56,6 +56,6 @@
background-image: url(details.gif);
}
.x-resizable-pinned .x-resizable-handle-south{
background:url(resources/extjs/images/default/sizer/s-handle-dark.gif);
background:url(awitef/resources/extjs/images/default/sizer/s-handle-dark.gif);
background-position: top;
}
<?php
# Authentication class
# Copyright (C) 2007-2009, AllWorldIT
# Copyright (C) 2007-2015, 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
......
<?php
# User Control Panel UI Config
# Copyright (C) 2007-2009, AllWorldIT
# Copyright (C) 2007-2015, 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
......