Repository: airavata-php-gateway Updated Branches: refs/heads/0.15-release-branch c80db9a36 -> 6ea67871c
implementing AIRAVATA-1783 Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/6ea67871 Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/6ea67871 Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/6ea67871 Branch: refs/heads/0.15-release-branch Commit: 6ea67871ce53df3a7f6fc88b085c12cca7fa7cf4 Parents: c80db9a Author: Supun Nakandala <[email protected]> Authored: Sat Jul 18 19:52:01 2015 +0530 Committer: Supun Nakandala <[email protected]> Committed: Sat Jul 18 19:52:01 2015 +0530 ---------------------------------------------------------------------- app/config/pga_config.php.template | 5 + app/controllers/AccountController.php | 6 +- app/controllers/ApplicationController.php | 15 +- app/controllers/ComputeResource.php | 261 ------------------- app/controllers/ComputeResourceController.php | 261 +++++++++++++++++++ app/filters.php | 9 + app/libraries/CommonUtilities.php | 2 +- app/routes.php | 22 +- app/views/admin/manage-credentials.blade.php | 4 + app/views/admin/manage-gateway.blade.php | 8 +- app/views/admin/manage-roles.blade.php | 7 +- app/views/admin/manage-users.blade.php | 3 +- app/views/application/deployment.blade.php | 6 +- app/views/application/interface.blade.php | 6 +- app/views/application/module.blade.php | 6 +- app/views/partials/dashboard-block.blade.php | 6 + .../partials/interface-input-block.blade.php | 2 + .../partials/interface-output-block.blade.php | 2 + app/views/resource/browse.blade.php | 8 + app/views/resource/view.blade.php | 2 + 20 files changed, 352 insertions(+), 289 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/config/pga_config.php.template ---------------------------------------------------------------------- diff --git a/app/config/pga_config.php.template b/app/config/pga_config.php.template index ea4f97f..8dfbe7c 100644 --- a/app/config/pga_config.php.template +++ b/app/config/pga_config.php.template @@ -14,6 +14,11 @@ return array( 'admin-role-name' => 'admin', /** + * Read only Admin Role Name + */ + 'read-only-admin' => 'admin-read-only', + + /** * Gateway user role */ 'user-role-name' => 'Internal/everyone', http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/controllers/AccountController.php ---------------------------------------------------------------------- diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 132a492..1401fd3 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -68,9 +68,13 @@ class AccountController extends BaseController $password = $_POST['password']; try { if (WSIS::authenticate($username, $password)) { - if (in_array(Config::get('pga_config.wsis')['admin-role-name'], (array)WSIS::getUserRoles($username))) { + $userRoles = (array)WSIS::getUserRoles($username); + if (in_array(Config::get('pga_config.wsis')['admin-role-name'], $userRoles)) { Session::put("admin", true); } + if (in_array(Config::get('pga_config.wsis')['read-only-admin'], $userRoles)) { + Session::put("admin-read-only", true); + } CommonUtilities::store_id_in_session($username); CommonUtilities::print_success_message('Login successful! You will be redirected to your home page shortly.'); http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/controllers/ApplicationController.php ---------------------------------------------------------------------- diff --git a/app/controllers/ApplicationController.php b/app/controllers/ApplicationController.php index 756a8a0..adf3a4b 100644 --- a/app/controllers/ApplicationController.php +++ b/app/controllers/ApplicationController.php @@ -18,6 +18,7 @@ class ApplicationController extends BaseController { public function modifyAppModuleSubmit() { + $this->beforeFilter('verifyeditadmin'); $update = false; if( Input::has("appModuleId") ) $update = true; @@ -38,6 +39,7 @@ class ApplicationController extends BaseController { public function deleteAppModule() { + $this->beforeFilter('verifyeditadmin'); if( AppUtilities::deleteAppModule( Input::get("appModuleId") ) ) $message = "Module has been deleted successfully!"; else @@ -47,17 +49,16 @@ class ApplicationController extends BaseController { } - public function createAppInterfaceView() + public function showAppInterfaceView() { - $data = array(); $data = AppUtilities::getAppInterfaceData(); - //var_dump( $data["appInterfaces"][14] ); exit; Session::put("admin-nav", "app-interface"); return View::make("application/interface", $data); } public function createAppInterfaceSubmit() { + $this->beforeFilter('verifyeditadmin'); $appInterfaceValues = Input::all(); //var_dump( $appInterfaceValues); exit; AppUtilities::create_or_update_appInterface( $appInterfaceValues); @@ -67,6 +68,7 @@ class ApplicationController extends BaseController { public function editAppInterfaceSubmit() { + $this->beforeFilter('verifyeditadmin'); if( Input::has("app-interface-id")) { $update = true; @@ -85,6 +87,7 @@ class ApplicationController extends BaseController { public function deleteAppInterface() { + $this->beforeFilter('verifyeditadmin'); if( AppUtilities::deleteAppInterface( Input::get("appInterfaceId") ) ) $message = "Interface has been deleted successfully!"; else @@ -94,9 +97,8 @@ class ApplicationController extends BaseController { } - public function createAppDeploymentView() + public function showAppDeploymentView() { - $data = array(); $data = AppUtilities::getAppDeploymentData(); //var_dump( $data); exit; Session::put("admin-nav", "app-deployment"); @@ -105,6 +107,7 @@ class ApplicationController extends BaseController { public function createAppDeploymentSubmit() { + $this->beforeFilter('verifyeditadmin'); $appDeploymentValues = Input::all(); AppUtilities::create_or_update_appDeployment( $appDeploymentValues ); return Redirect::to("app/deployment")->with("message", "App Deployment was created successfully!"); @@ -112,6 +115,7 @@ class ApplicationController extends BaseController { public function editAppDeploymentSubmit() { + $this->beforeFilter('verifyeditadmin'); if( Input::has("app-deployment-id")) { $update = true; @@ -142,6 +146,7 @@ class ApplicationController extends BaseController { public function deleteAppDeployment() { + $this->beforeFilter('verifyeditadmin'); if( AppUtilities::deleteAppDeployment( Input::get("appDeploymentId") ) ) $message = "Deployment has been deleted successfully!"; else http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/controllers/ComputeResource.php ---------------------------------------------------------------------- diff --git a/app/controllers/ComputeResource.php b/app/controllers/ComputeResource.php deleted file mode 100755 index 5a246ce..0000000 --- a/app/controllers/ComputeResource.php +++ /dev/null @@ -1,261 +0,0 @@ -<?php - -class ComputeResource extends BaseController -{ - - /** - * Instantiate a new Compute Resource Controller Instance - **/ - - public function __construct() - { - $this->beforeFilter('verifyadmin'); - Session::put("nav-active", "compute-resource"); - - } - - public function createView() - { - Session::put("admin-nav", "cr-create"); - return View::make("resource/create"); - } - - public function createSubmit() - { - - $hostAliases = Input::get("hostaliases"); - $ips = Input::get("ips"); - //Compute resource is by default enabled - $computeDescription = array( - "hostName" => trim(Input::get("hostname")), - "hostAliases" => array_unique(array_filter($hostAliases)), - "ipAddresses" => array_unique(array_filter($ips)), - "resourceDescription" => Input::get("description"), - "enabled" => true - ); - $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription); - - return Redirect::to("cr/edit?crId=" . $computeResource->computeResourceId); - } - - public function editView() - { - - $data = CRUtilities::getEditCRData(); - $computeResourceId = ""; - if (Input::has("crId")) - $computeResourceId = Input::get("crId"); - else if (Session::has("computeResource")) { - $computeResource = Session::get("computeResource"); - $computeResourceId = $computeResource->computeResourceId; - } - - if ($computeResourceId != "") { - $computeResource = CRUtilities::get_compute_resource($computeResourceId); - $jobSubmissionInterfaces = array(); - $dataMovementInterfaces = array(); - $addedJSP = array(); - $addedDMI = array(); - //var_dump( $computeResource->jobSubmissionInterfaces); exit; - if (count($computeResource->jobSubmissionInterfaces)) { - foreach ($computeResource->jobSubmissionInterfaces as $JSI) { - $jobSubmissionInterfaces[] = CRUtilities::getJobSubmissionDetails($JSI->jobSubmissionInterfaceId, $JSI->jobSubmissionProtocol); - $addedJSP[] = $JSI->jobSubmissionProtocol; - } - } - //var_dump( CRUtilities::getJobSubmissionDetails( $data["computeResource"]->jobSubmissionInterfaces[0]->jobSubmissionInterfaceId, 1) ); exit; - if (count($computeResource->dataMovementInterfaces)) { - foreach ($computeResource->dataMovementInterfaces as $DMI) { - $dataMovementInterfaces[] = CRUtilities::getDataMovementDetails($DMI->dataMovementInterfaceId, $DMI->dataMovementProtocol); - $addedDMI[] = $DMI->dataMovementProtocol; - } - } - - $data["computeResource"] = $computeResource; - $data["jobSubmissionInterfaces"] = $jobSubmissionInterfaces; - $data["dataMovementInterfaces"] = $dataMovementInterfaces; - $data["addedJSP"] = $addedJSP; - $data["addedDMI"] = $addedDMI; - //var_dump($data["jobSubmissionInterfaces"]); exit; - return View::make("resource/edit", $data); - } else - return View::make("resource/browse")->with("login-alert", "Unable to retrieve this Compute Resource. Please report this error to devs."); - - } - - public function editSubmit() - { - - $tabName = ""; - if (Input::get("cr-edit") == "resDesc") /* Modify compute Resource description */ { - $computeDescription = CRUtilities::get_compute_resource(Input::get("crId")); - $computeDescription->hostName = trim(Input::get("hostname")); - $computeDescription->hostAliases = array_unique(array_filter(Input::get("hostaliases"))); - $computeDescription->ipAddresses = array_unique(array_filter(Input::get("ips"))); - $computeDescription->resourceDescription = Input::get("description"); - $computeDescription->maxMemoryPerNode = Input::get("maxMemoryPerNode"); - //var_dump( $computeDescription); exit; - - $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription, true); - - $tabName = "#tab-desc"; - } - if (Input::get("cr-edit") == "queue") /* Add / Modify a Queue */ { - $queue = array("queueName" => Input::get("qname"), - "queueDescription" => Input::get("qdesc"), - "maxRunTime" => Input::get("qmaxruntime"), - "maxNodes" => Input::get("qmaxnodes"), - "maxProcessors" => Input::get("qmaxprocessors"), - "maxJobsInQueue" => Input::get("qmaxjobsinqueue"), - "maxMemory" => Input::get("qmaxmemoryinqueue") - ); - - $computeDescription = CRUtilities::get_compute_resource(Input::get("crId")); - $computeDescription->batchQueues[] = CRUtilities::createQueueObject($queue); - $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription, true); - //var_dump( $computeResource); exit; - $tabName = "#tab-queues"; - } else if (Input::get("cr-edit") == "delete-queue") { - CRUtilities::deleteQueue(Input::get("crId"), Input::get("queueName")); - $tabName = "#tab-queues"; - } else if (Input::get("cr-edit") == "fileSystems") { - $computeDescription = CRUtilities::get_compute_resource(Input::get("crId")); - $computeDescription->fileSystems = array_filter(Input::get("fileSystems"), "trim"); - $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription, true); - - $tabName = "#tab-filesystem"; - } else if (Input::get("cr-edit") == "jsp" || Input::get("cr-edit") == "edit-jsp") /* Add / Modify a Job Submission Interface */ { - $update = false; - if (Input::get("cr-edit") == "edit-jsp") - $update = true; - - $jobSubmissionInterface = CRUtilities::create_or_update_JSIObject(Input::all(), $update); - - $tabName = "#tab-jobSubmission"; - } else if (Input::get("cr-edit") == "jsi-priority") { - $inputs = Input::all(); - $computeDescription = CRUtilities::get_compute_resource(Input::get("crId")); - foreach ($computeDescription->jobSubmissionInterfaces as $index => $jsi) { - foreach ($inputs["jsi-id"] as $idIndex => $jsiId) { - if ($jsiId == $jsi->jobSubmissionInterfaceId) { - $computeDescription->jobSubmissionInterfaces[$index]->priorityOrder = $inputs["jsi-priority"][$idIndex]; - break; - } - } - } - $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription, true); - - return 1; //currently done by ajax. - } else if (Input::get("cr-edit") == "dmp" || Input::get("cr-edit") == "edit-dmi") /* Add / Modify a Data Movement Interface */ { - $update = false; - if (Input::get("cr-edit") == "edit-dmi") - $update = true; - $dataMovementInterface = CRUtilities::create_or_update_DMIObject(Input::all(), $update); - - $tabName = "#tab-dataMovement"; - } else if (Input::get("cr-edit") == "dmi-priority") { - $inputs = Input::all(); - $computeDescription = CRUtilities::get_compute_resource(Input::get("crId")); - foreach ($computeDescription->dataMovementInterfaces as $index => $dmi) { - foreach ($inputs["dmi-id"] as $idIndex => $dmiId) { - if ($dmiId == $dmi->dataMovementInterfaceId) { - $computeDescription->dataMovementInterfaces[$index]->priorityOrder = $inputs["dmi-priority"][$idIndex]; - break; - } - } - } - $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription, true); - - return 1; //currently done by ajax. - } - - return Redirect::to("cr/edit?crId=" . Input::get("crId") . $tabName); - } - - public function viewView() - { - - $data = CRUtilities::getEditCRData(); - $computeResourceId = ""; - if (Input::has("crId")) - $computeResourceId = Input::get("crId"); - else if (Session::has("computeResource")) { - $computeResource = Session::get("computeResource"); - $computeResourceId = $computeResource->computeResourceId; - } - - if ($computeResourceId != "") { - $computeResource = CRUtilities::get_compute_resource($computeResourceId); - $jobSubmissionInterfaces = array(); - $dataMovementInterfaces = array(); - $addedJSP = array(); - $addedDMI = array(); - //var_dump( $computeResource->jobSubmissionInterfaces); exit; - if (count($computeResource->jobSubmissionInterfaces)) { - foreach ($computeResource->jobSubmissionInterfaces as $JSI) { - $jobSubmissionInterfaces[] = CRUtilities::getJobSubmissionDetails($JSI->jobSubmissionInterfaceId, $JSI->jobSubmissionProtocol); - $addedJSP[] = $JSI->jobSubmissionProtocol; - } - } - //var_dump( CRUtilities::getJobSubmissionDetails( $data["computeResource"]->jobSubmissionInterfaces[0]->jobSubmissionInterfaceId, 1) ); exit; - if (count($computeResource->dataMovementInterfaces)) { - foreach ($computeResource->dataMovementInterfaces as $DMI) { - $dataMovementInterfaces[] = CRUtilities::getDataMovementDetails($DMI->dataMovementInterfaceId, $DMI->dataMovementProtocol); - $addedDMI[] = $DMI->dataMovementProtocol; - } - } - - $data["computeResource"] = $computeResource; - $data["jobSubmissionInterfaces"] = $jobSubmissionInterfaces; - $data["dataMovementInterfaces"] = $dataMovementInterfaces; - $data["addedJSP"] = $addedJSP; - $data["addedDMI"] = $addedDMI; - //var_dump($data["jobSubmissionInterfaces"]); exit; - return View::make("resource/view", $data); - } else - return View::make("resource/browse")->with("login-alert", "Unable to retrieve this Compute Resource. Please report this error to devs."); - - } - - public function deleteActions() - { - - $result = CRUtilities::deleteActions(Input::all()); - if (Input::has("jsiId")) { - return Redirect::to("cr/edit?crId=" . Input::get("crId") . "#tab-jobSubmission") - ->with("message", "Job Submission Interface was deleted successfully"); - } - if (Input::has("dmiId")) { - return Redirect::to("cr/edit?crId=" . Input::get("crId") . "#tab-dataMovement") - ->with("message", "Data Movement Protocol was deleted successfully"); - } elseif (Input::has("del-crId")) { - return Redirect::to("cr/browse")->with("message", "The Compute Resource has been successfully deleted."); - } else - return $result; - } - - public function browseView() - { - $data = CRUtilities::getBrowseCRData(false); - $allCRs = $data["crObjects"]; - $appDeployments = $data["appDeployments"]; - - $connectedDeployments = array(); - foreach ((array)$allCRs as $resource) { - $crId = $resource->computeResourceId; - $connectedDeployments[$crId] = 0; - foreach ((array)$appDeployments as $deploymentObject) { - if ($crId == $deploymentObject->computeHostId) - $connectedDeployments[$crId]++; - } - } - Session::put("admin-nav", "cr-browse"); - return View::make("resource/browse", array( - "allCRs" => $allCRs, - "connectedDeployments" => $connectedDeployments - )); - - } -} - -?> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/controllers/ComputeResourceController.php ---------------------------------------------------------------------- diff --git a/app/controllers/ComputeResourceController.php b/app/controllers/ComputeResourceController.php new file mode 100755 index 0000000..918070a --- /dev/null +++ b/app/controllers/ComputeResourceController.php @@ -0,0 +1,261 @@ +<?php + +class ComputeResourceController extends BaseController +{ + + /** + * Instantiate a new Compute Resource Controller Instance + **/ + + public function __construct() + { + $this->beforeFilter('verifyadmin'); + Session::put("nav-active", "compute-resource"); + + } + + public function createView() + { + $this->beforeFilter('verifyeditadmin'); + Session::put("admin-nav", "cr-create"); + return View::make("resource/create"); + } + + public function createSubmit() + { + $this->beforeFilter('verifyeditadmin'); + $hostAliases = Input::get("hostaliases"); + $ips = Input::get("ips"); + //Compute resource is by default enabled + $computeDescription = array( + "hostName" => trim(Input::get("hostname")), + "hostAliases" => array_unique(array_filter($hostAliases)), + "ipAddresses" => array_unique(array_filter($ips)), + "resourceDescription" => Input::get("description"), + "enabled" => true + ); + $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription); + + return Redirect::to("cr/edit?crId=" . $computeResource->computeResourceId); + } + + public function editView() + { + $this->beforeFilter('verifyeditadmin'); + $data = CRUtilities::getEditCRData(); + $computeResourceId = ""; + if (Input::has("crId")) + $computeResourceId = Input::get("crId"); + else if (Session::has("computeResource")) { + $computeResource = Session::get("computeResource"); + $computeResourceId = $computeResource->computeResourceId; + } + + if ($computeResourceId != "") { + $computeResource = CRUtilities::get_compute_resource($computeResourceId); + $jobSubmissionInterfaces = array(); + $dataMovementInterfaces = array(); + $addedJSP = array(); + $addedDMI = array(); + //var_dump( $computeResource->jobSubmissionInterfaces); exit; + if (count($computeResource->jobSubmissionInterfaces)) { + foreach ($computeResource->jobSubmissionInterfaces as $JSI) { + $jobSubmissionInterfaces[] = CRUtilities::getJobSubmissionDetails($JSI->jobSubmissionInterfaceId, $JSI->jobSubmissionProtocol); + $addedJSP[] = $JSI->jobSubmissionProtocol; + } + } + //var_dump( CRUtilities::getJobSubmissionDetails( $data["computeResource"]->jobSubmissionInterfaces[0]->jobSubmissionInterfaceId, 1) ); exit; + if (count($computeResource->dataMovementInterfaces)) { + foreach ($computeResource->dataMovementInterfaces as $DMI) { + $dataMovementInterfaces[] = CRUtilities::getDataMovementDetails($DMI->dataMovementInterfaceId, $DMI->dataMovementProtocol); + $addedDMI[] = $DMI->dataMovementProtocol; + } + } + + $data["computeResource"] = $computeResource; + $data["jobSubmissionInterfaces"] = $jobSubmissionInterfaces; + $data["dataMovementInterfaces"] = $dataMovementInterfaces; + $data["addedJSP"] = $addedJSP; + $data["addedDMI"] = $addedDMI; + //var_dump($data["jobSubmissionInterfaces"]); exit; + return View::make("resource/edit", $data); + } else + return View::make("resource/browse")->with("login-alert", "Unable to retrieve this Compute Resource. Please report this error to devs."); + + } + + public function editSubmit() + { + $this->beforeFilter('verifyeditadmin'); + $tabName = ""; + if (Input::get("cr-edit") == "resDesc") /* Modify compute Resource description */ { + $computeDescription = CRUtilities::get_compute_resource(Input::get("crId")); + $computeDescription->hostName = trim(Input::get("hostname")); + $computeDescription->hostAliases = array_unique(array_filter(Input::get("hostaliases"))); + $computeDescription->ipAddresses = array_unique(array_filter(Input::get("ips"))); + $computeDescription->resourceDescription = Input::get("description"); + $computeDescription->maxMemoryPerNode = Input::get("maxMemoryPerNode"); + //var_dump( $computeDescription); exit; + + $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription, true); + + $tabName = "#tab-desc"; + } + if (Input::get("cr-edit") == "queue") /* Add / Modify a Queue */ { + $queue = array("queueName" => Input::get("qname"), + "queueDescription" => Input::get("qdesc"), + "maxRunTime" => Input::get("qmaxruntime"), + "maxNodes" => Input::get("qmaxnodes"), + "maxProcessors" => Input::get("qmaxprocessors"), + "maxJobsInQueue" => Input::get("qmaxjobsinqueue"), + "maxMemory" => Input::get("qmaxmemoryinqueue") + ); + + $computeDescription = CRUtilities::get_compute_resource(Input::get("crId")); + $computeDescription->batchQueues[] = CRUtilities::createQueueObject($queue); + $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription, true); + //var_dump( $computeResource); exit; + $tabName = "#tab-queues"; + } else if (Input::get("cr-edit") == "delete-queue") { + CRUtilities::deleteQueue(Input::get("crId"), Input::get("queueName")); + $tabName = "#tab-queues"; + } else if (Input::get("cr-edit") == "fileSystems") { + $computeDescription = CRUtilities::get_compute_resource(Input::get("crId")); + $computeDescription->fileSystems = array_filter(Input::get("fileSystems"), "trim"); + $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription, true); + + $tabName = "#tab-filesystem"; + } else if (Input::get("cr-edit") == "jsp" || Input::get("cr-edit") == "edit-jsp") /* Add / Modify a Job Submission Interface */ { + $update = false; + if (Input::get("cr-edit") == "edit-jsp") + $update = true; + + $jobSubmissionInterface = CRUtilities::create_or_update_JSIObject(Input::all(), $update); + + $tabName = "#tab-jobSubmission"; + } else if (Input::get("cr-edit") == "jsi-priority") { + $inputs = Input::all(); + $computeDescription = CRUtilities::get_compute_resource(Input::get("crId")); + foreach ($computeDescription->jobSubmissionInterfaces as $index => $jsi) { + foreach ($inputs["jsi-id"] as $idIndex => $jsiId) { + if ($jsiId == $jsi->jobSubmissionInterfaceId) { + $computeDescription->jobSubmissionInterfaces[$index]->priorityOrder = $inputs["jsi-priority"][$idIndex]; + break; + } + } + } + $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription, true); + + return 1; //currently done by ajax. + } else if (Input::get("cr-edit") == "dmp" || Input::get("cr-edit") == "edit-dmi") /* Add / Modify a Data Movement Interface */ { + $update = false; + if (Input::get("cr-edit") == "edit-dmi") + $update = true; + $dataMovementInterface = CRUtilities::create_or_update_DMIObject(Input::all(), $update); + + $tabName = "#tab-dataMovement"; + } else if (Input::get("cr-edit") == "dmi-priority") { + $inputs = Input::all(); + $computeDescription = CRUtilities::get_compute_resource(Input::get("crId")); + foreach ($computeDescription->dataMovementInterfaces as $index => $dmi) { + foreach ($inputs["dmi-id"] as $idIndex => $dmiId) { + if ($dmiId == $dmi->dataMovementInterfaceId) { + $computeDescription->dataMovementInterfaces[$index]->priorityOrder = $inputs["dmi-priority"][$idIndex]; + break; + } + } + } + $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription, true); + + return 1; //currently done by ajax. + } + + return Redirect::to("cr/edit?crId=" . Input::get("crId") . $tabName); + } + + public function viewView() + { + $data = CRUtilities::getEditCRData(); + $computeResourceId = ""; + if (Input::has("crId")) + $computeResourceId = Input::get("crId"); + else if (Session::has("computeResource")) { + $computeResource = Session::get("computeResource"); + $computeResourceId = $computeResource->computeResourceId; + } + + if ($computeResourceId != "") { + $computeResource = CRUtilities::get_compute_resource($computeResourceId); + $jobSubmissionInterfaces = array(); + $dataMovementInterfaces = array(); + $addedJSP = array(); + $addedDMI = array(); + //var_dump( $computeResource->jobSubmissionInterfaces); exit; + if (count($computeResource->jobSubmissionInterfaces)) { + foreach ($computeResource->jobSubmissionInterfaces as $JSI) { + $jobSubmissionInterfaces[] = CRUtilities::getJobSubmissionDetails($JSI->jobSubmissionInterfaceId, $JSI->jobSubmissionProtocol); + $addedJSP[] = $JSI->jobSubmissionProtocol; + } + } + //var_dump( CRUtilities::getJobSubmissionDetails( $data["computeResource"]->jobSubmissionInterfaces[0]->jobSubmissionInterfaceId, 1) ); exit; + if (count($computeResource->dataMovementInterfaces)) { + foreach ($computeResource->dataMovementInterfaces as $DMI) { + $dataMovementInterfaces[] = CRUtilities::getDataMovementDetails($DMI->dataMovementInterfaceId, $DMI->dataMovementProtocol); + $addedDMI[] = $DMI->dataMovementProtocol; + } + } + + $data["computeResource"] = $computeResource; + $data["jobSubmissionInterfaces"] = $jobSubmissionInterfaces; + $data["dataMovementInterfaces"] = $dataMovementInterfaces; + $data["addedJSP"] = $addedJSP; + $data["addedDMI"] = $addedDMI; + //var_dump($data["jobSubmissionInterfaces"]); exit; + return View::make("resource/view", $data); + } else + return View::make("resource/browse")->with("login-alert", "Unable to retrieve this Compute Resource. Please report this error to devs."); + + } + + public function deleteActions() + { + $this->beforeFilter('verifyeditadmin'); + $result = CRUtilities::deleteActions(Input::all()); + if (Input::has("jsiId")) { + return Redirect::to("cr/edit?crId=" . Input::get("crId") . "#tab-jobSubmission") + ->with("message", "Job Submission Interface was deleted successfully"); + } + if (Input::has("dmiId")) { + return Redirect::to("cr/edit?crId=" . Input::get("crId") . "#tab-dataMovement") + ->with("message", "Data Movement Protocol was deleted successfully"); + } elseif (Input::has("del-crId")) { + return Redirect::to("cr/browse")->with("message", "The Compute Resource has been successfully deleted."); + } else + return $result; + } + + public function browseView() + { + $data = CRUtilities::getBrowseCRData(false); + $allCRs = $data["crObjects"]; + $appDeployments = $data["appDeployments"]; + + $connectedDeployments = array(); + foreach ((array)$allCRs as $resource) { + $crId = $resource->computeResourceId; + $connectedDeployments[$crId] = 0; + foreach ((array)$appDeployments as $deploymentObject) { + if ($crId == $deploymentObject->computeHostId) + $connectedDeployments[$crId]++; + } + } + Session::put("admin-nav", "cr-browse"); + return View::make("resource/browse", array( + "allCRs" => $allCRs, + "connectedDeployments" => $connectedDeployments + )); + + } +} + +?> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/filters.php ---------------------------------------------------------------------- diff --git a/app/filters.php b/app/filters.php index 4106032..2fb6c3c 100755 --- a/app/filters.php +++ b/app/filters.php @@ -89,6 +89,15 @@ Route::filter('verifylogin', function () { Route::filter('verifyadmin', function () { if (CommonUtilities::verify_login()) { + if (!(Session::has("admin") || Session::has("admin-read-only"))) { + return Redirect::to("home")->with("admin-alert", true); + } + } else + return Redirect::to("home")->with("login-alert", true); +}); + +Route::filter('verifyeditadmin', function () { + if (CommonUtilities::verify_login()) { if (!Session::has("admin")) { return Redirect::to("home")->with("admin-alert", true); } http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/libraries/CommonUtilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/CommonUtilities.php b/app/libraries/CommonUtilities.php index c67d2b4..0ba24d2 100644 --- a/app/libraries/CommonUtilities.php +++ b/app/libraries/CommonUtilities.php @@ -190,7 +190,7 @@ class CommonUtilities if ("user-console" == Session::get("nav-active")) $active = " active "; } - if (Session::has("admin")) + if (Session::has("admin") || Session::has("admin-read-only")) echo '<li class="' . $active . '"><a href="' . URL::to("/") . '/admin/dashboard"><span class="glyphicon glyphicon-user"></span>Admin Dashboard</a></li>'; // else // echo '<li><a href="' . URL::to("/") . '/user/profile"><span class="glyphicon glyphicon-user"></span> Profile</a></li>'; http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/routes.php ---------------------------------------------------------------------- diff --git a/app/routes.php b/app/routes.php index e5f6f65..20dfbe1 100755 --- a/app/routes.php +++ b/app/routes.php @@ -85,23 +85,23 @@ Route::get("cr/create", function () { return Redirect::to("cr/create/step1"); }); -Route::get("cr/create", "ComputeResource@createView"); +Route::get("cr/create", "ComputeResourceController@createView"); -Route::post("cr/create", "ComputeResource@createSubmit"); +Route::post("cr/create", "ComputeResourceController@createSubmit"); -Route::get("cr/edit", "ComputeResource@editView"); +Route::get("cr/edit", "ComputeResourceController@editView"); -Route::post("cr/edit", "ComputeResource@editSubmit"); +Route::post("cr/edit", "ComputeResourceController@editSubmit"); -Route::get("cr/view", "ComputeResource@viewView"); +Route::get("cr/view", "ComputeResourceController@viewView"); -Route::get("cr/browse", "ComputeResource@browseView"); +Route::get("cr/browse", "ComputeResourceController@browseView"); -Route::post("cr/delete-jsi", "ComputeResource@deleteActions"); +Route::post("cr/delete-jsi", "ComputeResourceController@deleteActions"); -Route::post("cr/delete-dmi", "ComputeResource@deleteActions"); +Route::post("cr/delete-dmi", "ComputeResourceController@deleteActions"); -Route::post("cr/delete-cr", "ComputeResource@deleteActions"); +Route::post("cr/delete-cr", "ComputeResourceController@deleteActions"); /* * Application Catalog Routes */ @@ -114,7 +114,7 @@ Route::post("app/module-edit", "ApplicationController@modifyAppModuleSubmit"); Route::post("app/module-delete", "ApplicationController@deleteAppModule"); -Route::get("app/interface", "ApplicationController@createAppInterfaceView"); +Route::get("app/interface", "ApplicationController@showAppInterfaceView"); Route::post("app/interface-create", "ApplicationController@createAppInterfaceSubmit"); @@ -122,7 +122,7 @@ Route::post("app/interface-edit", "ApplicationController@editAppInterfaceSubmit" Route::post("app/interface-delete", "ApplicationController@deleteAppInterface"); -Route::get("app/deployment", "ApplicationController@createAppDeploymentView"); +Route::get("app/deployment", "ApplicationController@showAppDeploymentView"); Route::post("app/deployment-create", "ApplicationController@createAppDeploymentSubmit"); http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/admin/manage-credentials.blade.php ---------------------------------------------------------------------- diff --git a/app/views/admin/manage-credentials.blade.php b/app/views/admin/manage-credentials.blade.php index cebd634..040d1a8 100644 --- a/app/views/admin/manage-credentials.blade.php +++ b/app/views/admin/manage-credentials.blade.php @@ -54,6 +54,7 @@ </td> </tr> </table> + @if(Session::has("admin")) <table class="table"> <tr class="text-center table-condensed"> <td> @@ -61,7 +62,9 @@ </td> </tr> </table> + @endif + @if(Session::has("admin")) <div class="row"> <h1 class="text-center">My Proxy Credentials</h1> @@ -89,6 +92,7 @@ </table> </div> </div> + @endif <h1 class="text-center">Amazon Credentials</h1> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/admin/manage-gateway.blade.php ---------------------------------------------------------------------- diff --git a/app/views/admin/manage-gateway.blade.php b/app/views/admin/manage-gateway.blade.php index 7bff156..2c4265b 100644 --- a/app/views/admin/manage-gateway.blade.php +++ b/app/views/admin/manage-gateway.blade.php @@ -45,23 +45,26 @@ data-parent="#accordion2" href="#collapse-gateway-{{$indexGP}}"> {{ $gp->gatewayName }} </a> - + @if(Session::has("admin")) <div class="pull-right col-md-2 gateway-options fade"> <span class="glyphicon glyphicon-pencil edit-gateway" style="cursor:pointer;" data-toggle="modal" data-target="#edit-gateway-block" data-gp-id="{{ $gp->gatewayId }}" data-gp-name="{{ $gp->gatewayName }}"></span> </div> + @endif </h4> </div> <div id="collapse-gateway-{{$indexGP}}" class="panel-collapse collapse"> <div class="panel-body"> <div class="app-interface-block"> <div class="row"> + @if(Session::has("admin")) <div class="col-md-10"> <button class="btn btn-default add-cr" data-gpid="{{$gp->gatewayId}}"><span class="glyphicon glyphicon-plus"></span> Add a Compute Resource </button> </div> + @endif <div class="col-md-10"> @if( isset( $gp->profile->computeResourcePreferences) ) <div> @@ -79,7 +82,7 @@ href="#collapse-crp-{{$indexGP}}-{{$indexCRP}}"> {{ $crp->crDetails->hostName }} </a> - + @if(Session::has("admin")) <div class="pull-right col-md-2 gateway-options fade"> <span class="glyphicon glyphicon-remove remove-resource" style="cursor:pointer;" data-toggle="modal" @@ -88,6 +91,7 @@ data-cr-id="{{$crp->computeResourceId}}" data-gp-id="{{ $gp->gatewayId }}"></span> </div> + @endif </h4> </div> <div id="collapse-crp-{{$indexGP}}-{{$indexCRP}}" http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/admin/manage-roles.blade.php ---------------------------------------------------------------------- diff --git a/app/views/admin/manage-roles.blade.php b/app/views/admin/manage-roles.blade.php index 21a7e61..3bdc278 100644 --- a/app/views/admin/manage-roles.blade.php +++ b/app/views/admin/manage-roles.blade.php @@ -32,11 +32,14 @@ <th> Role </th> + @if(Session::has("admin")) <th>Actions</th> + @endif </tr> @foreach( $roles as $role) <tr> <td class="role-name">{{ $role }}</td> + @if(Session::has("admin")) <td> <span class="glyphicon glyphicon-pencil edit-role-name"></span> <a href="{{URL::to('/')}}/admin/dashboard/users?role={{$role}}"> @@ -44,9 +47,11 @@ </a> <span class="glyphicon glyphicon-trash delete-role"></span> </td> + @endif </tr> @endforeach </table> + @if(Session::has("admin")) <div class="col-md-12"> <button type="button" class="btn btn-default toggle-add-role"><span class="glyphicon glyphicon-plus"></span>Add a new Role @@ -75,7 +80,7 @@ </div> </form> </div> - + @endif </div> </div> </div> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/admin/manage-users.blade.php ---------------------------------------------------------------------- diff --git a/app/views/admin/manage-users.blade.php b/app/views/admin/manage-users.blade.php index 444ff21..58e96b5 100644 --- a/app/views/admin/manage-users.blade.php +++ b/app/views/admin/manage-users.blade.php @@ -34,7 +34,6 @@ <th> Role : <select onchange="location = this.options[this.selectedIndex].value;"> - <option>Select a role</option> <option value="{{URL::to('/')}}/admin/dashboard/users">All</option> @foreach( (array)$roles as $role) <option value="{{URL::to('/')}}/admin/dashboard/users?role={{$role}}" @@ -81,6 +80,7 @@ </div> <div class="roles-list"> </div> + @if(Session::has("admin")) <div class="add-roles-block hide"> <div class="form-group well"> <label class="control-label">Add a new roles to the user</label> @@ -94,6 +94,7 @@ </button> </div> </div> + @endif </div> <div class="modal-footer"> <div class="success-message"></div> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/application/deployment.blade.php ---------------------------------------------------------------------- diff --git a/app/views/application/deployment.blade.php b/app/views/application/deployment.blade.php index 6bf237c..b2fb9e3 100644 --- a/app/views/application/deployment.blade.php +++ b/app/views/application/deployment.blade.php @@ -14,10 +14,11 @@ <div id="page-wrapper"> <div class="container-fluid"> <div class="col-md-offset-2 col-md-8"> - + @if(Session::has("admin")) <div class="row"> <button class="btn btn-default create-app-deployment">Create a new Application Deployment</button> </div> + @endif @if( count( $appDeployments) ) @if( Session::has("message")) <div class="row"> @@ -47,7 +48,7 @@ data-parent="#accordion" href="#collapse-{{$index}}"> {{ $deployment->appDeploymentId }} </a> - + @if(Session::has("admin")) <div class="pull-right col-md-2 deployment-options fade"> <span class="glyphicon glyphicon-pencil edit-app-deployment" style="cursor:pointer;" data-toggle="modal" data-target="#edit-app-deployment-block" @@ -56,6 +57,7 @@ data-toggle="modal" data-target="#delete-app-deployment-block" data-deployment-id="{{ $deployment->appDeploymentId }}"></span> </div> + @endif </h4> </div> <div id="collapse-{{$index}}" class="panel-collapse collapse"> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/application/interface.blade.php ---------------------------------------------------------------------- diff --git a/app/views/application/interface.blade.php b/app/views/application/interface.blade.php index cfe61d3..d428d63 100644 --- a/app/views/application/interface.blade.php +++ b/app/views/application/interface.blade.php @@ -14,10 +14,11 @@ <div id="page-wrapper"> <div class="container-fluid"> <div class="col-md-offset-2 col-md-8"> - + @if(Session::has("admin")) <div class="row"> <button class="btn btn-default create-app-interface">Create a new Application Interface</button> </div> + @endif @if( count( $appInterfaces) ) @if( Session::has("message")) <div class="row"> @@ -47,7 +48,7 @@ data-parent="#accordion" href="#collapse-{{$index}}"> {{ $interface->applicationName }} </a> - + @if(Session::has("admin")) <div class="pull-right col-md-2 interface-options fade"> <span class="glyphicon glyphicon-pencil edit-app-interface" style="cursor:pointer;" data-toggle="modal" data-target="#edit-app-interface-block" @@ -56,6 +57,7 @@ data-toggle="modal" data-target="#delete-app-interface-block" data-interface-id="{{ $interface->applicationInterfaceId }}"></span> </div> + @endif </h4> </div> <div id="collapse-{{$index}}" class="panel-collapse collapse"> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/application/module.blade.php ---------------------------------------------------------------------- diff --git a/app/views/application/module.blade.php b/app/views/application/module.blade.php index 2c6bc0f..604bb76 100644 --- a/app/views/application/module.blade.php +++ b/app/views/application/module.blade.php @@ -14,10 +14,11 @@ <div id="page-wrapper"> <div class="container-fluid"> <div class="col-md-offset-2 col-md-8"> - + @if(Session::has("admin")) <button class="btn btn-default create-app-module" data-toggle="modal" data-target="#new-app-module-block">Create a new Application Module </button> + @endif @if( count( $modules) ) @if( Session::has("message")) @@ -47,7 +48,7 @@ href="#collapse-{{$index}}"> {{ $module->appModuleName }} </a> - + @if(Session::has("admin")) <div class="pull-right col-md-2 module-options fade"> <span class="glyphicon glyphicon-pencil edit-app-module" style="cursor:pointer;" data-toggle="modal" data-target="#edit-app-module-block" @@ -56,6 +57,7 @@ data-toggle="modal" data-target="#delete-app-module-block" data-module-data="{{ htmlentities(json_encode( $module) ) }}"></span> </div> + @endif </h4> </div> <div id="collapse-{{$index}}" class="panel-collapse collapse"> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/partials/dashboard-block.blade.php ---------------------------------------------------------------------- diff --git a/app/views/partials/dashboard-block.blade.php b/app/views/partials/dashboard-block.blade.php index b8dbdc7..71e6c64 100644 --- a/app/views/partials/dashboard-block.blade.php +++ b/app/views/partials/dashboard-block.blade.php @@ -21,20 +21,25 @@ <li> <a><i class="fa fa-fw fa-table"></i>Compute Resources</a> <ul> + @if(Session::has("admin")) <li @if( Session::has("admin-nav") && Session::get("admin-nav") == "cr-create") class="active" @endif> <a class="dashboard-link" href="{{ URL::to('/')}}/cr/create"><i class="fa fa-fw fa-table"></i>Register</a> </li> + @endif + @if(Session::has("admin") || Session::has("admin-read-only")) <li @if( Session::has("admin-nav") && Session::get("admin-nav") == "cr-browse") class="active" @endif> <a class="dashboard-link" href="{{ URL::to('/')}}/cr/browse"><i class="fa fa-fw fa-table"></i>Browse</a> </li> + @endif </ul> </li> <li> <a><i class="fa fa-fw fa-table"></i>App Catalog</a> <ul> + @if(Session::has("admin") || Session::has("admin-read-only")) <li @if( Session::has("admin-nav") && Session::get("admin-nav") == "app-module") class="active" @endif> <a class="dashboard-link" href="{{ URL::to('/')}}/app/module"><i class="fa fa-fw fa-table"></i>Module</a> @@ -47,6 +52,7 @@ @if( Session::has("admin-nav") && Session::get("admin-nav") == "app-deployment") class="active" @endif> <a class="dashboard-link" href="{{ URL::to('/')}}/app/deployment"><i class="fa fa-fw fa-table"></i>Deployment</a> </li> + @endif </ul> </li> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/partials/interface-input-block.blade.php ---------------------------------------------------------------------- diff --git a/app/views/partials/interface-input-block.blade.php b/app/views/partials/interface-input-block.blade.php index 5062adb..ca02ca9 100644 --- a/app/views/partials/interface-input-block.blade.php +++ b/app/views/partials/interface-input-block.blade.php @@ -1,5 +1,7 @@ <div class="well app-input-data-block"> + @if(Session::has("admin")) <span class="glyphicon glyphicon-trash pull-right remove-input-space"></span> + @endif <h4>App Input Fields</h4> <div class="form-group required"> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/partials/interface-output-block.blade.php ---------------------------------------------------------------------- diff --git a/app/views/partials/interface-output-block.blade.php b/app/views/partials/interface-output-block.blade.php index 97f1ea6..b2bc5d5 100644 --- a/app/views/partials/interface-output-block.blade.php +++ b/app/views/partials/interface-output-block.blade.php @@ -1,5 +1,7 @@ <div class="well"> + @if(Session::has("admin")) <span class="glyphicon glyphicon-trash pull-right remove-output-space"></span> + @endif <h4>App Output Fields</h4> <div class="form-group required"> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/resource/browse.blade.php ---------------------------------------------------------------------- diff --git a/app/views/resource/browse.blade.php b/app/views/resource/browse.blade.php index b17fd75..c9b5382 100644 --- a/app/views/resource/browse.blade.php +++ b/app/views/resource/browse.blade.php @@ -49,10 +49,14 @@ <th>Name</th> <th>Id</th> + @if(Session::has("admin")) <th>Enabled</th> <th>Edit</th> + @endif <th>View</th> + @if(Session::has("admin")) <th>Delete</th> + @endif </tr> @foreach($allCRs as $resource) @@ -64,6 +68,7 @@ <tr id="crDetails"> <td>{{ $crName }}</td> <td>{{ $crId }}</td> + @if(Session::has("admin")) <td> @if(!$enabled) <div class="checkbox"> @@ -79,11 +84,13 @@ <span class="glyphicon glyphicon-pencil"></span> </a> </td> + @endif <td> <a href="{{URL::to('/')}}/cr/view?crId={{ $crId }}" title="Edit"> <span class="glyphicon glyphicon-list"></span> </a> </td> + @if(Session::has("admin")) <td> <a href="#" title="Delete"> <span class="glyphicon glyphicon-trash del-cr" data-toggle="modal" @@ -92,6 +99,7 @@ data-crid="{{$crId}}"></span> </a> </td> + @endif </tr> @endforeach http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6ea67871/app/views/resource/view.blade.php ---------------------------------------------------------------------- diff --git a/app/views/resource/view.blade.php b/app/views/resource/view.blade.php index 9678e17..495ba55 100644 --- a/app/views/resource/view.blade.php +++ b/app/views/resource/view.blade.php @@ -19,11 +19,13 @@ <div class="well"> <h4>Compute Resource : {{ $computeResource->hostName }} + @if(Session::has("admin")) <div class="pull-right"> <a href="{{URL::to('/')}}/cr/edit?crId={{Input::get('crId') }}" title="Edit"> <span class="glyphicon glyphicon-pencil"></span> </a> </div> + @endif </h4> </div> @if( Session::has("message"))
