Repository: airavata-php-gateway Updated Branches: refs/heads/dreg-gateway 8f3d7621e -> dc0c79c41
sync codes to remove user-pending status 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/9549e183 Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/9549e183 Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/9549e183 Branch: refs/heads/dreg-gateway Commit: 9549e1838086b63aefbb212e49ac529f7341def5 Parents: d426398 Author: root <root@osboxes> Authored: Tue Feb 21 20:25:55 2017 +0000 Committer: root <root@osboxes> Committed: Tue Feb 21 20:25:55 2017 +0000 ---------------------------------------------------------------------- app/config/pga_config.php.template | 8 +++ app/controllers/AccountController.php | 9 +-- app/controllers/AdminController.php | 65 ++++++++++-------- app/libraries/CommonUtilities.php | 4 ++ app/storage/.gitignore | 1 - app/storage/cache/.gitignore | 2 - app/storage/logs/.gitignore | 2 - app/storage/meta/.gitignore | 2 - app/storage/sessions/.gitignore | 2 - app/storage/views/.gitignore | 2 - app/views/account/dashboard.blade.php | 5 ++ app/views/admin/manage-gateway.blade.php | 70 +++++++++----------- app/views/layout/basic.blade.php | 10 ++- .../compute-resource-preferences.blade.php | 2 +- app/views/partials/dashboard-block.blade.php | 6 +- .../partials/experiment-queue-block.blade.php | 0 public/css/admin.css | 10 ++- 17 files changed, 109 insertions(+), 91 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/config/pga_config.php.template ---------------------------------------------------------------------- diff --git a/app/config/pga_config.php.template b/app/config/pga_config.php.template index ac378f6..8370364 100644 --- a/app/config/pga_config.php.template +++ b/app/config/pga_config.php.template @@ -24,6 +24,14 @@ return array( 'user-role-name' => 'Internal/everyone', /** + * Initial user role. This is the initial user role assigned to a new + * user. Set this to one of the three roles above to automatically + * grant new users that role, or set to some other role ('user-pending') + * to require admin approval before users have access. + */ + 'initial-role-name' => 'user-pending', + + /** * Tenant Domain */ 'tenant-domain' => 'master.airavata', http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/controllers/AccountController.php ---------------------------------------------------------------------- diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 1490ee1..a9ac6b4 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -56,14 +56,15 @@ class AccountController extends BaseController WSIS::registerUserAccount($username, $password, $email, $first_name, $last_name, $organization, $address, $country, $telephone, $mobile, $im, $url, Config::get('pga_config.wsis')['tenant-domain']); - /*add user to role - user-pending */ + /*add user to the initial role */ + $initialRoleName = CommonUtilities::getInitialRoleName(); $allRoles = WSIS::getAllRoles(); - if(! in_array( "user-pending", $allRoles)){ - WSIS::addRole( "user-pending"); + if(! in_array( $initialRoleName, $allRoles)){ + WSIS::addRole( $initialRoleName); } - $userRoles["new"] = "user-pending"; + $userRoles["new"] = $initialRoleName; if( Config::get('pga_config.portal')['super-admin-portal'] == true ){ http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/controllers/AdminController.php ---------------------------------------------------------------------- diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php index 9735b9a..6dd27bd 100644 --- a/app/controllers/AdminController.php +++ b/app/controllers/AdminController.php @@ -99,12 +99,18 @@ class AdminController extends BaseController { } + private function cmp($a, $b) + { + return strcmp($b->requestCreationTime, $a->requestCreationTime); + } + public function gatewayView(){ //only for super admin //Session::put("super-admin", true); $gatewaysInfo = CRUtilities::getAllGatewayProfilesData(); $gateways = $gatewaysInfo["gateways"]; + usort($gateways, array($this, "cmp")); $tokens = AdminUtilities::get_all_ssh_tokens(); $pwdTokens = AdminUtilities::get_all_pwd_tokens(); $srData = SRUtilities::getEditSRData(); @@ -230,22 +236,44 @@ class AdminController extends BaseController { $recipients = array($userProfile["email"]); $this->sendAccessGrantedEmailToTheUser(Input::get("username"), $recipients); - // remove the pending role when access is granted, unless - // the admin is trying to add the user to the pending role - if(in_array("user-pending", $newCurrentRoles) && !in_array("user-pending", $roles["new"])) { - $userRoles["new"] = array(); - $userRoles["deleted"] = "user-pending"; - WSIS::updateUserRoles( $username, $userRoles); - } else if(in_array("user-pending", $newCurrentRoles) && in_array("user-pending", $roles["new"])) { - // When user-pending role added remove all roles except for user-pending and Internal/everyone - $userRoles["new"] = array(); - $userRoles["deleted"] = array_diff($newCurrentRoles, array("user-pending", "Internal/everyone")); - WSIS::updateUserRoles( $username, $userRoles); + // remove the initial role when the initial role isn't a privileged + // role and the admin has now assigned the user to a privileged + // role, unless the admin is trying to add the user back to the + // initial role + if (!$this->isInitialRoleOneOfPrivilegedRoles()) { + + $initialRoleName = CommonUtilities::getInitialRoleName(); + if(in_array($initialRoleName, $newCurrentRoles) && !in_array($initialRoleName, $roles["new"])) { + $userRoles["new"] = array(); + $userRoles["deleted"] = $initialRoleName; + WSIS::updateUserRoles( $username, $userRoles); + } else if(in_array($initialRoleName, $newCurrentRoles) && in_array($initialRoleName, $roles["new"])) { + // When initial role added remove all roles except for initial role and Internal/everyone + $userRoles["new"] = array(); + $userRoles["deleted"] = array_diff($newCurrentRoles, array($initialRoleName, "Internal/everyone")); + WSIS::updateUserRoles( $username, $userRoles); + } } } return Redirect::to("admin/dashboard/roles")->with( "message", "Roles has been added."); } + /* + * Return true if the initial-role-name is one of the three privileged + * roles. This is used to figure out whether the initial-role-name is a + * 'user-pending' kind of role (returns false), or whether the initial role + * is a privileged role (returns true) and no admin intervention is + * necessary. + */ + private function isInitialRoleOneOfPrivilegedRoles() { + + $initialRoleName = CommonUtilities::getInitialRoleName(); + $adminRoleName = Config::get("pga_config.wsis")["admin-role-name"]; + $adminReadOnlyRoleName = Config::get("pga_config.wsis")["read-only-admin-role-name"]; + $userRoleName = Config::get("pga_config.wsis")["user-role-name"]; + return in_array($initialRoleName, array($adminRoleName, $adminReadOnlyRoleName, $userRoleName)); + } + public function removeRoleFromUser(){ $roles["deleted"] = array(Input::all()["roleName"]); $roles["new"] = array(); @@ -272,21 +300,6 @@ class AdminController extends BaseController { return View::make("admin/manage-credentials", array("tokens" => $tokens , "pwdTokens" => $pwdTokens) ); } - public function updateUserRoles(){ - if( Input::has("add")){ - WSIS::updateUserRoles(Input::get("username"), array("new"=> Input::get("roles"), "deleted" => array() ) ); - $roles = WSIS::getUserRoles(Input::get("username")); - if(in_array(Config::get("pga_config.wsis")["admin-role-name"], $roles) || in_array(Config::get("pga_config.wsis")["read-only-admin-role-name"], $roles) - || in_array(Config::get("pga_config.wsis")["user-role-name"], $roles)){ - $userProfile = WSIS::getUserProfile(Input::get("username")); - $recipients = array($userProfile["email"]); - $this->sendAccessGrantedEmailToTheUser(Input::get("username"), $recipients); - } - } - else - return WSIS::updateUserRoles(Input::get("username"), array("new"=> array(), "deleted" => Input::get("roles") ) ); - } - private function sendAccessGrantedEmailToTheUser($username, $recipients){ $mail = new PHPMailer; http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/libraries/CommonUtilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/CommonUtilities.php b/app/libraries/CommonUtilities.php index 6792dcc..957f922 100644 --- a/app/libraries/CommonUtilities.php +++ b/app/libraries/CommonUtilities.php @@ -461,5 +461,9 @@ class CommonUtilities return false; } } + + public static function getInitialRoleName() { + return Config::get('pga_config.wsis.initial-role-name', 'user-pending'); + } } http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/storage/.gitignore ---------------------------------------------------------------------- diff --git a/app/storage/.gitignore b/app/storage/.gitignore deleted file mode 100644 index 35b719c..0000000 --- a/app/storage/.gitignore +++ /dev/null @@ -1 +0,0 @@ -services.manifest \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/storage/cache/.gitignore ---------------------------------------------------------------------- diff --git a/app/storage/cache/.gitignore b/app/storage/cache/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/app/storage/cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/storage/logs/.gitignore ---------------------------------------------------------------------- diff --git a/app/storage/logs/.gitignore b/app/storage/logs/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/app/storage/logs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/storage/meta/.gitignore ---------------------------------------------------------------------- diff --git a/app/storage/meta/.gitignore b/app/storage/meta/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/app/storage/meta/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/storage/sessions/.gitignore ---------------------------------------------------------------------- diff --git a/app/storage/sessions/.gitignore b/app/storage/sessions/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/app/storage/sessions/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/storage/views/.gitignore ---------------------------------------------------------------------- diff --git a/app/storage/views/.gitignore b/app/storage/views/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/app/storage/views/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/views/account/dashboard.blade.php ---------------------------------------------------------------------- diff --git a/app/views/account/dashboard.blade.php b/app/views/account/dashboard.blade.php index c67747b..340059c 100644 --- a/app/views/account/dashboard.blade.php +++ b/app/views/account/dashboard.blade.php @@ -187,6 +187,10 @@ <td class="gateway-url"></td> </tr> <tr> + <td>Gateway Domain</td> + <td class="gateway-domain"></td> + </tr> + <tr> <td>Admin Username</td> <td class="admin-username"></td> </tr> @@ -510,6 +514,7 @@ $(".admin-password").html( gatewayObject["identityServerPasswordToken"]); $(".gateway-id").html( gatewayObject["gatewayId"]); $(".gateway-url").html( gatewayObject["gatewayURL"]); + $(".gateway-domain").html( gatewayObject["domain"]); $(".oauth-client-key").html( gatewayObject["oauthClientId"]); $(".oauth-client-secret").html( gatewayObject["oauthClientSecret"]); $("#viewCredentials").modal("show"); http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/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 099bec8..795af43 100644 --- a/app/views/admin/manage-gateway.blade.php +++ b/app/views/admin/manage-gateway.blade.php @@ -638,52 +638,42 @@ dataObj[updateGatewayData[i].name] = updateGatewayData[i].value; } - if( updateVal == "createTenant" && - ( $.trim( dataObj['oauthClientId'] ) == "" || $.trim( dataObj['oauthClientSecret'] ) == "") ){ - $(".submit-actions").before("<div class='alert alert-danger fail-alert'>Tenant creation requires Oauth Client Id and Oauth Client Secret fields to be filled.</div>"); - $(".loading-gif").remove(); - } - else - { - $.ajax({ - url: "{{URL::to('/')}}/admin/update-gateway-request", - method: "GET", - data: updateGatewayData - }).done( function( data){ - $(".loading-gif").remove(); - if( data == -1 ){ - //errors only with -1 - if( updateVal == "createTenant"){ - $(".submit-actions").before("<div class='alert alert-danger fail-alert'>Tenant creation has failed as Tenant with the same Domain name- airavata." + $(".gatewayAcronym").val() + " already exists in Identity Server. Please change Gateway Acronym and try again."); - } - else{ - $(".submit-actions").before("<div class='alert alert-danger fail-alert'>Error updating Gateway. Please try again."); - } + $.ajax({ + url: "{{URL::to('/')}}/admin/update-gateway-request", + method: "GET", + data: updateGatewayData + }).done( function( data){ + $(".loading-gif").remove(); + if( data == -1 ){ + //errors only with -1 + if( updateVal == "createTenant"){ + $(".submit-actions").before("<div class='alert alert-danger fail-alert'>Tenant creation has failed as Tenant with the same Domain name- airavata." + $(".gatewayAcronym").val() + " already exists in Identity Server. Please change Gateway Acronym and try again."); } else{ - if( updateVal == "createTenant"){ - $(".submit-actions").before("<div class='alert alert-success success-alert'>Tenant has been created with domain name- airavata." + $(".gatewayAcronym").val()); - $(".notCreatedGateway").addClass("hide"); - - $(".createdGateway").removeClass("hide"); + $(".submit-actions").before("<div class='alert alert-danger fail-alert'>Error updating Gateway. Please try again."); + } + } + else{ + if( updateVal == "createTenant"){ + $(".submit-actions").before("<div class='alert alert-success success-alert'>Tenant has been created with domain name- airavata." + $(".gatewayAcronym").val()); + $(".notCreatedGateway").addClass("hide"); - } - else{ - $(".submit-actions").before("<div class='alert alert-success success-alert'>Gateway has been updated successfully."); - } + $(".createdGateway").removeClass("hide"); - //refresh data next time if same popup is opened. - var gatewayIdWithoutSpaces = dataObj['gateway_id'].replace(/\s+/g, '-'); - $("#view-" + gatewayIdWithoutSpaces).data("gatewayobject", data); - $("#view-" + gatewayIdWithoutSpaces ).parent().parent().find(".form-gatewayName").html( dataObj['gatewayName']); - $("#view-" + gatewayIdWithoutSpaces ).parent().parent().find(".form-gatewayURL").html( dataObj['gatewayURL']); } - //$(".onTenantComplete").removeClass("hide"); - //$(".onTenantLoad").addClass("hide"); - //$(".onTenantComplete").removeClass("hide"); - }); - } + else{ + $(".submit-actions").before("<div class='alert alert-success success-alert'>Gateway has been updated successfully."); + } + + //refresh data next time if same popup is opened. + var gatewayIdWithoutSpaces = dataObj['gateway_id'].replace(/\s+/g, '-'); + $("#view-" + gatewayIdWithoutSpaces).data("gatewayobject", data); + $("#view-" + gatewayIdWithoutSpaces ).parent().parent().find(".form-gatewayName").html( dataObj['gatewayName']); + $("#view-" + gatewayIdWithoutSpaces ).parent().parent().find(".form-gatewayURL").html( dataObj['gatewayURL']); + } + }); + }); $(".gaStatuses option[value=REQUESTED]").prop("selected", true); http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/views/layout/basic.blade.php ---------------------------------------------------------------------- diff --git a/app/views/layout/basic.blade.php b/app/views/layout/basic.blade.php index b621ecd..3e5e396 100755 --- a/app/views/layout/basic.blade.php +++ b/app/views/layout/basic.blade.php @@ -14,6 +14,9 @@ $title = Session::get("portal-title"); position: relative; z-index:101; } +.content-area{ + margin: 20px 0; +} </style> <div class="theme-header"> <!-- Header from theme --> @@ -92,12 +95,13 @@ var fullName = "{{Session::get("user-profile")["firstname"] . " " . Session::get //put sidebar below all headers in admin dashboards if( $(".side-nav").length > 0){ var headerHeight = $(".pga-header").height() + $(".theme-header").height(); - $(".side-nav").css("padding-top", headerHeight); - + $(".side-nav").css("top", headerHeight); + $(".side-nav").affix(); var selectedDashboardHeight = $(window).height() - headerHeight; + if( selectedDashboardHeight < $(".side-nav").height()) { - $(".side-nav").height( selectedDashboardHeight).css("overflow-y", "scroll").css("overflow-x", "none"); + $(".side-nav").height( selectedDashboardHeight); } } http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/views/partials/compute-resource-preferences.blade.php ---------------------------------------------------------------------- diff --git a/app/views/partials/compute-resource-preferences.blade.php b/app/views/partials/compute-resource-preferences.blade.php index 86f0b3d..62a3a39 100644 --- a/app/views/partials/compute-resource-preferences.blade.php +++ b/app/views/partials/compute-resource-preferences.blade.php @@ -106,7 +106,7 @@ <label class="control-label col-md-3">Gateway Id for Usage Reporting</label> <div class="col-md-9"> - <input type="text" name="allocationProjectNumber" class="form-control" + <input type="text" name="usageReportingGatewayId" class="form-control" value="@if( isset( $preferences) ) {{$preferences->usageReportingGatewayId }}@endif"/> <small>Enter Id of the Gateway using this resource if it requires reporting its usage back to the resource.</small> </div> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/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 d2b5220..8a07d78 100644 --- a/app/views/partials/dashboard-block.blade.php +++ b/app/views/partials/dashboard-block.blade.php @@ -1,7 +1,5 @@ -<div class="collapse navbar-collapse navbar-ex1-collapse"> - <ul class="nav navbar-nav side-nav"> - - +<div class="collapse navbar-collapse navbar-ex1-collapse" > + <ul class="nav navbar-nav side-nav" data-spy="affix" > <li @if( Session::has("admin-nav") && Session::get("admin-nav") == "exp-statistics") class="active" @endif> <a class="dashboard-link" href="{{ URL::to('/')}}/admin/dashboard/experiments"> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/app/views/partials/experiment-queue-block.blade.php ---------------------------------------------------------------------- diff --git a/app/views/partials/experiment-queue-block.blade.php b/app/views/partials/experiment-queue-block.blade.php old mode 100644 new mode 100755 http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9549e183/public/css/admin.css ---------------------------------------------------------------------- diff --git a/public/css/admin.css b/public/css/admin.css index 9d49c68..a1b18b4 100644 --- a/public/css/admin.css +++ b/public/css/admin.css @@ -116,12 +116,15 @@ ul.alert-dropdown { width: 200px; } +.affix{ + top:0; +} + /* Side Navigation */ @media(min-width:768px) { .side-nav { - position: fixed; - top:0; + position:fixed; z-index: 100; left: 225px; width: 225px; @@ -129,6 +132,9 @@ ul.alert-dropdown { border: none; border-radius: 0; background-color: #222; + + overflow-y: auto; + overflow-x: none; } .side-nav>li>a {