diff --git a/webgui/ajax.php b/webgui/ajax.php index 67e3cc051d9462c8dce25a4c5334a13a8c9ea63e..1ea01483e0452d988694aa2be26d3afbcb51d61a 100644 --- a/webgui/ajax.php +++ b/webgui/ajax.php @@ -5,7 +5,7 @@ include_once("include/ajax/functions/AdminUsers.php"); include_once("include/ajax/functions/AdminGroups.php"); include_once("include/ajax/functions/AdminRealms.php"); - include_once("include/ajax/functions/AdminLocations.php"); + include_once("include/ajax/functions/WiSPLocations.php"); define('RES_OK',0); define('RES_ERR',-1); @@ -146,44 +146,39 @@ } switch ($function) { - case "updateAdminGroup": - $res = updateAdminGroup($soapParams); + # WiSPLocations.js functions + case "updateWiSPLocation": + + $res = updateWiSPLocation($soapParams); if (isset($res)) { ajaxException($res); } break; - case "createAdminGroup": + case "createWiSPLocation": - $res = createAdminGroup($soapParams); + $res = createWiSPLocation($soapParams); if (isset($res)) { ajaxException($res); } break; - case "removeAdminGroup": + case "removeWiSPLocation": - $res = removeAdminGroup($soapParams); + $res = removeWiSPLocation($soapParams); if (isset($res)) { ajaxException($res); } break; - case "getWiSPResellers": - - $rawData = array ( - - array( - 'ID' => 10, - 'Name' => 'TestReseller1' - ) - ); + case "getWiSPLocations": - $numResults = 1; + $res = getWiSPLocations($soapParams); + $rawData = $res[0]; $numResults = $res[1]; $res = new json_response; $res->setID('ID'); @@ -195,21 +190,103 @@ echo json_encode($res->export()); break; - case "getLocations": + case "getWiSPLocation": + $rawData = getWiSPLocation($soapParams); + + $res = new json_response; + $res->setID('ID'); + $res->addField('ID','int'); + $res->addField('Name','string'); + $res->parseHash($rawData); + + echo json_encode($res->export()); + break; + + # AdminUsers.js functions + case "updateAdminUser": + + $res = updateAdminUser($soapParams); + if (isset($res)) { + ajaxException($res); + } + + break; + + case "createAdminUser": + + $res = createAdminUser($soapParams); + if (isset($res)) { + ajaxException($res); + } + + break; + + case "removeAdminUser": + + $res = removeAdminUser($soapParams); + if (isset($res)) { + ajaxException($res); + } + + break; + + case "getAdminUsers": - $res = getAdminLocations($soapParams); + $res = getAdminUsers($soapParams); $rawData = $res[0]; $numResults = $res[1]; $res = new json_response; $res->setID('ID'); $res->addField('ID','int'); - $res->addField('Name','string'); + $res->addField('Username','string'); + $res->addField('Disabled','boolean'); $res->parseArray($rawData); $res->setDatasetSize($numResults); echo json_encode($res->export()); break; + case "getAdminUser": + $rawData = getAdminUser($soapParams); + + $res = new json_response; + $res->setID('ID'); + $res->addField('ID','int'); + $res->addField('Username','string'); + $res->addField('Disabled','boolean'); + $res->parseHash($rawData); + + echo json_encode($res->export()); + break; + + # AdminRealms.js functions + case "updateAdminRealm": + + $res = updateAdminRealm($soapParams); + if (isset($res)) { + ajaxException($res); + } + + break; + + case "createAdminRealm": + + $res = createAdminRealm($soapParams); + if (isset($res)) { + ajaxException($res); + } + + break; + + case "removeAdminRealm": + + $res = removeAdminRealm($soapParams); + if (isset($res)) { + ajaxException($res); + } + + break; + case "getAdminRealms": $res = getAdminRealms($soapParams); @@ -226,6 +303,47 @@ echo json_encode($res->export()); break; + case "getAdminRealm": + $rawData = getAdminRealm($soapParams); + + $res = new json_response; + $res->setID('ID'); + $res->addField('ID','int'); + $res->addField('Name','string'); + $res->addField('Disabled','boolean'); + $res->parseHash($rawData); + + echo json_encode($res->export()); + break; + + # AdminGroups.js functions + case "updateAdminGroup": + + $res = updateAdminGroup($soapParams); + if (isset($res)) { + ajaxException($res); + } + + break; + + case "createAdminGroup": + + $res = createAdminGroup($soapParams); + if (isset($res)) { + ajaxException($res); + } + + break; + + case "removeAdminGroup": + + $res = removeAdminGroup($soapParams); + if (isset($res)) { + ajaxException($res); + } + + break; + case "getAdminGroups": $res = getAdminGroups($soapParams); @@ -242,6 +360,7 @@ $res->setDatasetSize($numResults); echo json_encode($res->export()); + break; case "getAdminGroup": @@ -257,23 +376,40 @@ $res->parseHash($rawData); echo json_encode($res->export()); + break; - case "getAdminUsers": + case "getWiSPResellers": - $res = getAdminUsers($soapParams); - $rawData = $res[0]; $numResults = $res[1]; + $rawData = array ( - # Check we have data returned - if (!isset($rawData)) { - # $numResults in this case is actually $msg, which is the errorm essage - ajaxException($numResults); - } + array( + 'ID' => 10, + 'Name' => 'TestReseller1' + ) + ); + + $numResults = 1; $res = new json_response; $res->setID('ID'); $res->addField('ID','int'); - $res->addField('Username','string'); + $res->addField('Name','string'); + $res->parseArray($rawData); + $res->setDatasetSize($numResults); + + echo json_encode($res->export()); + break; + + case "getAdminRealms": + + $res = getAdminRealms($soapParams); + $rawData = $res[0]; $numResults = $res[1]; + + $res = new json_response; + $res->setID('ID'); + $res->addField('ID','int'); + $res->addField('Name','string'); $res->addField('Disabled','boolean'); $res->parseArray($rawData); $res->setDatasetSize($numResults); diff --git a/webgui/icons.css b/webgui/icons.css index 7b308cf3a975cc8bb2c232ca13a34feaeb6d4e84..3c45b53316274225409b110bf33a37528a64dd26 100644 --- a/webgui/icons.css +++ b/webgui/icons.css @@ -11,6 +11,9 @@ .add { background-image:url(resources/extjs/icons/fam/add.gif) !important; } + .edit { + background-image:url(resources/extjs/icons/fam/plugin.gif) !important; + } .option { background-image:url(resources/extjs/icons/fam/plugin.gif) !important; } diff --git a/webgui/include/ajax/functions/AdminGroups.php b/webgui/include/ajax/functions/AdminGroups.php index c9983d2393e2f5046a761bb14cbb7bbc9a0fdffa..e5d95589f7cc75040455a84c74d438345cf17cfa 100644 --- a/webgui/include/ajax/functions/AdminGroups.php +++ b/webgui/include/ajax/functions/AdminGroups.php @@ -3,7 +3,7 @@ include_once("include/db.php"); -# Return list of users +# Return list of groups function getAdminGroups($params) { global $db; @@ -25,24 +25,24 @@ function getAdminGroups($params) { $resultArray = array(); - # loop through rows - while ($row = $sth->fetchObject()) { - $item = array(); + # loop through rows + while ($row = $sth->fetchObject()) { + $item = array(); - $item['ID'] = $row->id; - $item['Name'] = $row->name; - $item['Priority'] = $row->priority; - $item['Disabled'] = $row->disabled; - $item['Comment'] = $row->comment; + $item['ID'] = $row->id; + $item['Name'] = $row->name; + $item['Priority'] = $row->priority; + $item['Disabled'] = $row->disabled; + $item['Comment'] = $row->comment; - # push this row onto array - array_push($resultArray,$item); - } + # push this row onto array + array_push($resultArray,$item); + } return array($resultArray,$numResults); } -# Return list of users +# Return specific group row function getAdminGroup($params) { global $db; @@ -69,7 +69,7 @@ function getAdminGroup($params) { function removeAdminGroup($params) { global $db; - $res = DBDo("DELETE FROM groups WHERE ID = ?",array($params[0][0])); + $res = DBDo("DELETE FROM groups WHERE ID = ?",array($params[0])); if (!is_numeric($res)) { return $res; } diff --git a/webgui/include/ajax/functions/AdminLocations.php b/webgui/include/ajax/functions/AdminLocations.php deleted file mode 100644 index f33669da8a9757310d1d31f8420f88119ea5d103..0000000000000000000000000000000000000000 --- a/webgui/include/ajax/functions/AdminLocations.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -include_once("include/db.php"); - - -# Return list of users -function getAdminLocations($params) { - global $db; - - # Filters and sorts are the same here - $filtersorts = array( - 'ID' => 'wisp_locations.ID', - 'Name' => 'wisp_locations.Name', - ); - - $res = DBSelectSearch("SELECT ID, Name FROM wisp_locations",$params[1],$filtersorts,$filtersorts); - $sth = $res[0]; $numResults = $res[1]; - # If STH is blank, return the error back to whoever requested the data - if (!isset($sth)) { - return $res; - } - - $resultArray = array(); - - # loop through rows - while ($row = $sth->fetchObject()) { - $item = array(); - - $item['ID'] = $row->id; - $item['Name'] = $row->name; - - # push this row onto array - array_push($resultArray,$item); - } - - return array($resultArray,$numResults); -} - -?> diff --git a/webgui/include/ajax/functions/AdminRealms.php b/webgui/include/ajax/functions/AdminRealms.php index 0774c931e920d49b5c5e4a7fab3c776ccdc7352c..7338386ee4784ba63c2ad1a99af3f3c66d606fcf 100644 --- a/webgui/include/ajax/functions/AdminRealms.php +++ b/webgui/include/ajax/functions/AdminRealms.php @@ -3,7 +3,7 @@ include_once("include/db.php"); -# Return list of users +# Return list of realms function getAdminRealms($params) { global $db; @@ -38,4 +38,61 @@ function getAdminRealms($params) { return array($resultArray,$numResults); } +# Return specific realm row +function getAdminRealm($params) { + global $db; + + + $res = DBSelect("SELECT ID, Name, Disabled FROM realms WHERE ID = ?",array($params[0])); + if (!is_object($res)) { + return $res; + } + + $resultArray = array(); + + $row = $res->fetchObject(); + + $resultArray['ID'] = $row->id; + $resultArray['Name'] = $row->name; + $resultArray['Disabled'] = $row->disabled; + + return $resultArray; +} + +# Remove admin realm +function removeAdminRealm($params) { + global $db; + + $res = DBDo("DELETE FROM realms WHERE ID = ?",array($params[0])); + if (!is_numeric($res)) { + return $res; + } + + return NULL; +} + +# Add admin realm +function createAdminRealm($params) { + global $db; + + $res = DBDo("INSERT INTO realms (Name) VALUES (?)",array($params[0]['Name'])); + if (!is_numeric($res)) { + return $res; + } + + return NULL; +} + +# Edit admin realm +function updateAdminRealm($params) { + global $db; + + $res = DBDo("UPDATE realms SET Name = ? WHERE ID = ?",array($params[0]['Name'],$params[0]['ID'])); + if (!is_numeric($res)) { + return $res; + } + + return NULL; +} + ?> diff --git a/webgui/include/ajax/functions/AdminUsers.php b/webgui/include/ajax/functions/AdminUsers.php index f5b4ff3a4ec7c52decf8ada065bedb4d838be536..9a3ce7da18bf024e038814c1be3600669e806b9a 100644 --- a/webgui/include/ajax/functions/AdminUsers.php +++ b/webgui/include/ajax/functions/AdminUsers.php @@ -11,7 +11,7 @@ function getAdminUsers($params) { $filtersorts = array( 'ID' => 'users.ID', 'Username' => 'users.Username', - 'Disabled' => 'users.Disabled' + 'Disabled' => 'users.Disabled', ); $res = DBSelectSearch("SELECT ID, Username, Disabled FROM users",$params[1],$filtersorts,$filtersorts); @@ -38,4 +38,60 @@ function getAdminUsers($params) { return array($resultArray,$numResults); } +# Return specific group row +function getAdminUser($params) { + global $db; + + + $res = DBSelect("SELECT ID, Username, Disabled FROM users WHERE ID = ?",array($params[0])); + if (!is_object($res)) { + return $res; + } + + $resultArray = array(); + + $row = $res->fetchObject(); + + $resultArray['ID'] = $row->id; + $resultArray['Username'] = $row->username; + $resultArray['Disabled'] = $row->disabled; + + return $resultArray; +} + +# Remove admin group +function removeAdminUser($params) { + global $db; + + $res = DBDo("DELETE FROM users WHERE ID = ?",array($params[0])); + if (!is_numeric($res)) { + return $res; + } + + return NULL; +} + +# Add admin group +function createAdminUser($params) { + global $db; + + $res = DBDo("INSERT INTO users (Username) VALUES (?)",array($params[0]['Username'])); + if (!is_numeric($res)) { + return $res; + } + + return NULL; +} + +# Edit admin group +function updateAdminUser($params) { + global $db; + + $res = DBDo("UPDATE users SET Username = ? WHERE ID = ?",array($params[0]['Username'],$params[0]['ID'])); + if (!is_numeric($res)) { + return $res; + } + + return NULL; +} ?> diff --git a/webgui/include/ajax/functions/WiSPLocations.php b/webgui/include/ajax/functions/WiSPLocations.php new file mode 100644 index 0000000000000000000000000000000000000000..4e1003b83e66045767284ecd75e92b05f4376181 --- /dev/null +++ b/webgui/include/ajax/functions/WiSPLocations.php @@ -0,0 +1,95 @@ +<?php + +include_once("include/db.php"); + + +# Return list of locations +function getWiSPLocations($params) { + global $db; + + # Filters and sorts are the same here + $filtersorts = array( + 'ID' => 'groups.ID', + 'Name' => 'groups.Name' + ); + + $res = DBSelectSearch("SELECT ID, Name FROM wisp_locations",$params[1],$filtersorts,$filtersorts); + $sth = $res[0]; $numResults = $res[1]; + # If STH is blank, return the error back to whoever requested the data + if (!isset($sth)) { + return $res; + } + + $resultArray = array(); + + # loop through rows + while ($row = $sth->fetchObject()) { + $item = array(); + + $item['ID'] = $row->id; + $item['Name'] = $row->name; + + # push this row onto array + array_push($resultArray,$item); + } + + return array($resultArray,$numResults); +} + +# Return specific location row +function getWiSPLocation($params) { + global $db; + + + $res = DBSelect("SELECT ID, Name FROM wisp_locations WHERE ID = ?",array($params[0])); + if (!is_object($res)) { + return $res; + } + + $resultArray = array(); + + $row = $res->fetchObject(); + + $resultArray['ID'] = $row->id; + $resultArray['Name'] = $row->name; + + return $resultArray; +} + +# Remove admin group +function removeWiSPLocation($params) { + global $db; + + $res = DBDo("DELETE FROM wisp_locations WHERE ID = ?",array($params[0][0])); + if (!is_numeric($res)) { + return $res; + } + + return NULL; +} + +# Add admin group +function createWiSPLocation($params) { + global $db; + + $res = DBDo("INSERT INTO wisp_locations (Name) VALUES (?)",array($params[0]['Name'])); + if (!is_numeric($res)) { + return $res; + } + + return NULL; +} + +# Edit admin group +function updateWiSPLocation($params) { + global $db; + + $res = DBDo("UPDATE wisp_locations SET Name = ? WHERE ID = ?",array($params[0]['Name'],$params[0]['ID'])); + if (!is_numeric($res)) { + return $res; + } + + return NULL; +} + +?> diff --git a/webgui/js/app/windows/AdminGroups.js b/webgui/js/app/windows/AdminGroups.js index d950de3123e2d2dfa7178e21a34c437c17c52361..d687da9a031975240320a809fdde7182d1c06398 100644 --- a/webgui/js/app/windows/AdminGroups.js +++ b/webgui/js/app/windows/AdminGroups.js @@ -222,7 +222,7 @@ function showAdminGroupAddEditWindow(id) { } // Create window - var wispGroupFormWindow = new Ext.ux.GenericFormWindow( + var adminGroupFormWindow = new Ext.ux.GenericFormWindow( // Window config { title: "Group Information", @@ -256,10 +256,10 @@ function showAdminGroupAddEditWindow(id) { submitAjaxConfig ); - wispGroupFormWindow.show(); + adminGroupFormWindow.show(); if (id) { - wispGroupFormWindow.getComponent('formpanel').load({ + adminGroupFormWindow.getComponent('formpanel').load({ params: { ID: id, SOAPUsername: globalConfig.soap.username, @@ -295,13 +295,13 @@ function showAdminGroupRemoveWindow(parent,id) { // Do ajax request uxAjaxRequest(parent,{ params: { - id: id, + ID: id, SOAPUsername: globalConfig.soap.username, SOAPPassword: globalConfig.soap.password, SOAPAuthType: globalConfig.soap.authtype, SOAPModule: 'AdminGroups', SOAPFunction: 'removeAdminGroup', - SOAPParams: 'id' + SOAPParams: 'ID' } }); @@ -314,12 +314,3 @@ function showAdminGroupRemoveWindow(parent,id) { }); } - - - - - - - - - diff --git a/webgui/js/app/windows/AdminRealms.js b/webgui/js/app/windows/AdminRealms.js index 99a1f92b2b8a1d45297f698640f9aa648f368dd9..7ccee62e43eb85730e99e3dec605d5c90be38b7e 100644 --- a/webgui/js/app/windows/AdminRealms.js +++ b/webgui/js/app/windows/AdminRealms.js @@ -22,10 +22,37 @@ function showAdminRealmWindow() { tooltip:'Add realm', iconCls:'add', handler: function() { - showAdminRealmAddWindow(); + showAdminRealmAddEditWindow(); } }, '-', + { + text:'Edit', + tooltip:'Edit realm', + iconCls:'edit', + handler: function() { + var selectedItem = AdminRealmWindow.getComponent('gridpanel').getSelectionModel().getSelected(); + // Check if we have selected item + if (selectedItem) { + // If so display window + showAdminRealmAddEditWindow(selectedItem.data.ID); + } else { + AdminRealmWindow.getEl().mask(); + + // Display error + Ext.Msg.show({ + title: "Nothing selected", + msg: "No realm selected", + icon: Ext.MessageBox.ERROR, + buttons: Ext.Msg.CANCEL, + modal: false, + fn: function() { + AdminRealmWindow.getEl().unmask(); + } + }); + } + } + }, { text:'Remove', tooltip:'Remove realm', @@ -101,7 +128,7 @@ function showAdminRealmWindow() { dataIndex: 'Disabled' } ]), - autoExpandColumn: 'Service' + autoExpandColumn: 'Name' }, // Store config { @@ -118,7 +145,7 @@ function showAdminRealmWindow() { { filters: [ {type: 'numeric', dataIndex: 'ID'}, - {type: 'string', dataIndex: 'Realmname'}, + {type: 'string', dataIndex: 'Name'}, {type: 'boolean', dataIndex: 'Disabled'} ] } @@ -129,10 +156,9 @@ function showAdminRealmWindow() { // Display edit/add form -function showAdminRealmEditWindow(id) { +function showAdminRealmAddEditWindow(id) { var submitAjaxConfig; - var editMode; // We doing an update @@ -142,40 +168,17 @@ function showAdminRealmEditWindow(id) { SOAPFunction: 'updateAdminRealm', SOAPParams: '0:ID,'+ - '0:UsageCap,'+ - '0:AgentRef,'+ - '0:AgentDisabled:boolean' + '0:Name' }; - editMode = true; // We doing an Add } else { submitAjaxConfig = { SOAPFunction: 'createAdminRealm', SOAPParams: - '0:AgentID,'+ - '0:RealmName,'+ - '0:UsageCap,'+ - '0:AgentRef,'+ - '0:AgentDisabled:boolean' + '0:Name' }; - editMode = false; } - - // Service store - var serviceStore = new Ext.ux.JsonStore({ - ID: id, - sortInfo: { field: "Name", direction: "ASC" }, - baseParams: { - SOAPUsername: globalConfig.soap.username, - SOAPPassword: globalConfig.soap.password, - SOAPAuthType: globalConfig.soap.authtype, - SOAPModule: 'AdminRealms', - SOAPFunction: 'getClasses', - AgentID: 1, - SOAPParams: '0:AgentID,__search' - } - }); // Create window var adminRealmFormWindow = new Ext.ux.GenericFormWindow( @@ -200,153 +203,30 @@ function showAdminRealmEditWindow(id) { }, items: [ { - fieldLabel: 'Realmname', - name: 'Realmname', + fieldLabel: 'Name', + name: 'Name', vtype: 'usernamePart', maskRe: usernamePartRe, - allowBlank: false, - - disabled: editMode + allowBlank: false }, - - { - xtype: 'combo', - - // We use an ID so we can get the box later - id: 'agent_combobox', - - fieldLabel: 'Agent', - name: 'Agent', - allowBlank: false, - width: 225, - - store: new Ext.ux.JsonStore({ - ID: id, - sortInfo: { field: "Name", direction: "ASC" }, - baseParams: { - SOAPUsername: globalConfig.soap.username, - SOAPPassword: globalConfig.soap.password, - SOAPAuthType: globalConfig.soap.authtype, - SOAPModule: 'Agents', - SOAPFunction: 'getAgents', - SOAPParams: '__search' - } - }), - displayField: 'Name', - valueField: 'ID', - hiddenName: 'AgentID', - - forceSelection: false, - triggerAction: 'all', - editable: false, - - disabled: editMode - }, - - { - xtype: 'combo', - - // We use an ID so we can get the box later - id: 'service_combobox', - - fieldLabel: 'Service', - name: 'Service', - allowBlank: false, - width: 340, - - store: serviceStore, - - displayField: 'Service', - valueField: 'ID', - hiddenName: 'ClassID', - - forceSelection: false, - triggerAction: 'all', - editable: false, - - disabled: true - }, - - { - fieldLabel: 'Usage Cap', - name: 'UsageCap', - }, - - { - fieldLabel: 'Agent Ref', - name: 'AgentRef' - }, - - { - xtype: 'checkbox', - fieldLabel: 'Disabled', - name: 'AgentDisabled' - }/*, - { - xtype: 'tabpanel', - plain: 'true', - deferredRender: false, // Load all panels! - activeTab: 0, - height: 100, - defaults: { - layout: 'form', - bodyStyle: 'padding: 10px;' - }, - - items: [ - { - title: 'Policy Settings', - layout: 'form', - defaultType: 'textfield', - items: [ - { - fieldLabel: 'Transport Policy', - name: 'Policy', - vtype: 'number', - value: '1' - } - ] - } - ] - }*/ ], }, // Submit button config submitAjaxConfig ); - // Events - if (!id) { - adminRealmFormWindow.findById('agent_combobox').on({ - select: { - fn: function() { - var tb = this.ownerCt.findById('service_combobox'); - - if (this.getValue()) { - tb.reset(); - serviceStore.baseParams.AgentID = this.getValue(); - serviceStore.reload(); - tb.enable(); - } else { - tb.reset(); - tb.disable(); - } - } - }, - }); - } adminRealmFormWindow.show(); if (id) { adminRealmFormWindow.getComponent('formpanel').load({ params: { - id: id, + ID: id, SOAPUsername: globalConfig.soap.username, SOAPPassword: globalConfig.soap.password, SOAPAuthType: globalConfig.soap.authtype, SOAPModule: 'AdminRealms', SOAPFunction: 'getAdminRealm', - SOAPParams: 'id' + SOAPParams: 'ID' } }); } @@ -363,7 +243,7 @@ function showAdminRealmRemoveWindow(parent,id) { // Display remove confirm window Ext.Msg.show({ title: "Confirm removal", - msg: "Are you very sure you wish to remove this user?", + msg: "Are you very sure you wish to remove this realm?", icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.YESNO, modal: false, @@ -374,13 +254,13 @@ function showAdminRealmRemoveWindow(parent,id) { // Do ajax request uxAjaxRequest(parent,{ params: { - id: id, + ID: id, SOAPUsername: globalConfig.soap.username, SOAPPassword: globalConfig.soap.password, SOAPAuthType: globalConfig.soap.authtype, SOAPModule: 'AdminRealms', SOAPFunction: 'removeAdminRealm', - SOAPParams: 'id' + SOAPParams: 'ID' } }); diff --git a/webgui/js/app/windows/AdminUsers.js b/webgui/js/app/windows/AdminUsers.js index 74438efc5c69211f525eab221612c398d6847a6c..eea0213ccac591fb7f5eb2a4ffd25abb71065278 100644 --- a/webgui/js/app/windows/AdminUsers.js +++ b/webgui/js/app/windows/AdminUsers.js @@ -22,7 +22,7 @@ function showAdminUserWindow() { tooltip:'Add user', iconCls:'add', handler: function() { - showAdminUserEditWindow(); + showAdminUserAddEditWindow(); } }, '-', @@ -35,7 +35,7 @@ function showAdminUserWindow() { // Check if we have selected item if (selectedItem) { // If so display window - showAdminUserEditWindow(selectedItem.data.ID); + showAdminUserAddEditWindow(selectedItem.data.ID); } else { AdminUserWindow.getEl().mask(); @@ -153,11 +153,11 @@ function showAdminUserWindow() { }, { header: "Disabled", - sortable: false, + sortable: true, dataIndex: 'Disabled' } ]), - autoExpandColumn: 'Service' + autoExpandColumn: 'Username' }, // Store config { @@ -185,11 +185,9 @@ function showAdminUserWindow() { // Display edit/add form -function showAdminUserEditWindow(id) { +function showAdminUserAddEditWindow(id) { var submitAjaxConfig; - var editMode; - // We doing an update if (id) { @@ -198,40 +196,17 @@ function showAdminUserEditWindow(id) { SOAPFunction: 'updateAdminUser', SOAPParams: '0:ID,'+ - '0:UsageCap,'+ - '0:AgentRef,'+ - '0:AgentDisabled:boolean' + '0:Username' }; - editMode = true; // We doing an Add } else { submitAjaxConfig = { SOAPFunction: 'createAdminUser', SOAPParams: - '0:AgentID,'+ - '0:UserName,'+ - '0:UsageCap,'+ - '0:AgentRef,'+ - '0:AgentDisabled:boolean' + '0:Username' }; - editMode = false; } - - // Service store - var serviceStore = new Ext.ux.JsonStore({ - ID: id, - sortInfo: { field: "Name", direction: "ASC" }, - baseParams: { - SOAPUsername: globalConfig.soap.username, - SOAPPassword: globalConfig.soap.password, - SOAPAuthType: globalConfig.soap.authtype, - SOAPModule: 'AdminUsers', - SOAPFunction: 'getClasses', - AgentID: 1, - SOAPParams: '0:AgentID,__search' - } - }); // Create window var adminUserFormWindow = new Ext.ux.GenericFormWindow( @@ -261,148 +236,25 @@ function showAdminUserEditWindow(id) { vtype: 'usernamePart', maskRe: usernamePartRe, allowBlank: false, - - disabled: editMode - }, - - { - xtype: 'combo', - - // We use an ID so we can get the box later - id: 'agent_combobox', - - fieldLabel: 'Agent', - name: 'Agent', - allowBlank: false, - width: 225, - - store: new Ext.ux.JsonStore({ - ID: id, - sortInfo: { field: "Name", direction: "ASC" }, - baseParams: { - SOAPUsername: globalConfig.soap.username, - SOAPPassword: globalConfig.soap.password, - SOAPAuthType: globalConfig.soap.authtype, - SOAPModule: 'Agents', - SOAPFunction: 'getAgents', - SOAPParams: '__search' - } - }), - displayField: 'Name', - valueField: 'ID', - hiddenName: 'AgentID', - - forceSelection: false, - triggerAction: 'all', - editable: false, - - disabled: editMode - }, - - { - xtype: 'combo', - - // We use an ID so we can get the box later - id: 'service_combobox', - - fieldLabel: 'Service', - name: 'Service', - allowBlank: false, - width: 340, - - store: serviceStore, - - displayField: 'Service', - valueField: 'ID', - hiddenName: 'ClassID', - - forceSelection: false, - triggerAction: 'all', - editable: false, - - disabled: true }, - - { - fieldLabel: 'Usage Cap', - name: 'UsageCap', - }, - - { - fieldLabel: 'Agent Ref', - name: 'AgentRef' - }, - - { - xtype: 'checkbox', - fieldLabel: 'Disabled', - name: 'AgentDisabled' - }/*, - { - xtype: 'tabpanel', - plain: 'true', - deferredRender: false, // Load all panels! - activeTab: 0, - height: 100, - defaults: { - layout: 'form', - bodyStyle: 'padding: 10px;' - }, - - items: [ - { - title: 'Policy Settings', - layout: 'form', - defaultType: 'textfield', - items: [ - { - fieldLabel: 'Transport Policy', - name: 'Policy', - vtype: 'number', - value: '1' - } - ] - } - ] - }*/ ], }, // Submit button config submitAjaxConfig ); - // Events - if (!id) { - adminUserFormWindow.findById('agent_combobox').on({ - select: { - fn: function() { - var tb = this.ownerCt.findById('service_combobox'); - - if (this.getValue()) { - tb.reset(); - serviceStore.baseParams.AgentID = this.getValue(); - serviceStore.reload(); - tb.enable(); - } else { - tb.reset(); - tb.disable(); - } - } - }, - }); - } adminUserFormWindow.show(); if (id) { adminUserFormWindow.getComponent('formpanel').load({ params: { - id: id, + ID: id, SOAPUsername: globalConfig.soap.username, SOAPPassword: globalConfig.soap.password, SOAPAuthType: globalConfig.soap.authtype, SOAPModule: 'AdminUsers', SOAPFunction: 'getAdminUser', - SOAPParams: 'id' + SOAPParams: 'ID' } }); } @@ -430,13 +282,13 @@ function showAdminUserRemoveWindow(parent,id) { // Do ajax request uxAjaxRequest(parent,{ params: { - id: id, + ID: id, SOAPUsername: globalConfig.soap.username, SOAPPassword: globalConfig.soap.password, SOAPAuthType: globalConfig.soap.authtype, SOAPModule: 'AdminUsers', SOAPFunction: 'removeAdminUser', - SOAPParams: 'id' + SOAPParams: 'ID' } }); diff --git a/webgui/js/app/windows/WiSPLocations.js b/webgui/js/app/windows/WiSPLocations.js index 5cf9c0518bddf04b51510ec3d6aced27daad6145..b069e2ed9f06fe4bda423e3664f8367c4a51d399 100644 --- a/webgui/js/app/windows/WiSPLocations.js +++ b/webgui/js/app/windows/WiSPLocations.js @@ -22,10 +22,38 @@ function showWiSPLocationWindow() { tooltip:'Add location', iconCls:'add', handler: function() { - showWiSPLocationEditWindow(); + showWiSPLocationAddEditWindow(); } }, '-', + { + text:'Edit', + tooltip:'Edit location', + iconCls:'edit', + handler: function() { + var selectedItem = WiSPLocationWindow.getComponent('gridpanel').getSelectionModel().getSelected(); + // Check if we have selected item + if (selectedItem) { + // If so display window + showWiSPLocationAddEditWindow(selectedItem.data.ID); + } else { + WiSPLocationWindow.getEl().mask(); + + // Display error + Ext.Msg.show({ + title: "Nothing selected", + msg: "No location selected", + icon: Ext.MessageBox.ERROR, + buttons: Ext.Msg.CANCEL, + modal: false, + fn: function() { + WiSPLocationWindow.getEl().unmask(); + } + }); + } + } + }, + '-', { text:'Remove', tooltip:'Remove location', @@ -70,7 +98,7 @@ function showWiSPLocationWindow() { // Display error Ext.Msg.show({ title: "Nothing selected", - msg: "No user selected", + msg: "No location selected", icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.CANCEL, modal: false, @@ -105,7 +133,7 @@ function showWiSPLocationWindow() { SOAPPassword: globalConfig.soap.password, SOAPAuthType: globalConfig.soap.authtype, SOAPModule: 'WiSPLocations', - SOAPFunction: 'getLocations', + SOAPFunction: 'getWiSPLocations', SOAPParams: '__null,__search' } }, @@ -122,8 +150,81 @@ function showWiSPLocationWindow() { } +// Display edit/add form +function showWiSPLocationAddEditWindow(id) { + var submitAjaxConfig; + // We doing an update + if (id) { + submitAjaxConfig = { + ID: id, + SOAPFunction: 'updateWiSPLocation', + SOAPParams: + '0:ID,'+ + '0:Name' + }; + + // We doing an Add + } else { + submitAjaxConfig = { + SOAPFunction: 'createWiSPLocation', + SOAPParams: + '0:Name' + }; + } + + // Create window + var wispLocationFormWindow = new Ext.ux.GenericFormWindow( + // Window config + { + title: "Location Information", + + width: 475, + height: 260, + + minWidth: 475, + minHeight: 260 + }, + // Form panel config + { + labelWidth: 85, + baseParams: { + SOAPUsername: globalConfig.soap.username, + SOAPPassword: globalConfig.soap.password, + SOAPAuthType: globalConfig.soap.authtype, + SOAPModule: 'WiSPLocations' + }, + items: [ + { + fieldLabel: 'Name', + name: 'Name', + vtype: 'usernamePart', + maskRe: usernamePartRe, + allowBlank: false + }, + ], + }, + // Submit button config + submitAjaxConfig + ); + + wispLocationFormWindow.show(); + + if (id) { + wispLocationFormWindow.getComponent('formpanel').load({ + params: { + ID: id, + SOAPUsername: globalConfig.soap.username, + SOAPPassword: globalConfig.soap.password, + SOAPAuthType: globalConfig.soap.authtype, + SOAPModule: 'WiSPLocations', + SOAPFunction: 'getWiSPLocation', + SOAPParams: 'ID' + } + }); + } +} // Display remove form @@ -134,7 +235,7 @@ function showWiSPLocationRemoveWindow(parent,id) { // Display remove confirm window Ext.Msg.show({ title: "Confirm removal", - msg: "Are you very sure you wish to remove this user?", + msg: "Are you very sure you wish to remove this location?", icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.YESNO, modal: false, @@ -149,8 +250,8 @@ function showWiSPLocationRemoveWindow(parent,id) { SOAPUsername: globalConfig.soap.username, SOAPPassword: globalConfig.soap.password, SOAPAuthType: globalConfig.soap.authtype, - SOAPModule: 'WiSPUsers', - SOAPFunction: 'removeWiSPUser', + SOAPModule: 'WiSPLocations', + SOAPFunction: 'removeWiSPLocation', SOAPParams: 'id' } }); @@ -164,12 +265,3 @@ function showWiSPLocationRemoveWindow(parent,id) { }); } - - - - - - - - -