Repository: airavata-php-gateway Updated Branches: refs/heads/develop acda62e31 -> 1281d8277
Adding PGA enhancements and bug fixes 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/f33f4226 Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/f33f4226 Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/f33f4226 Branch: refs/heads/develop Commit: f33f4226893cc986df260b7097fc254f69c8c511 Parents: 9849f3d Author: Sneha Tilak <til...@149-160-244-249.dhcp-bl.indiana.edu> Authored: Thu Jun 29 17:12:12 2017 -0400 Committer: Sneha Tilak <til...@149-160-244-249.dhcp-bl.indiana.edu> Committed: Thu Jun 29 17:12:12 2017 -0400 ---------------------------------------------------------------------- app/config/email_templates.json | 50 ++++ app/controllers/AdminController.php | 111 ++++++--- app/controllers/UpdateController.php | 70 ++++++ app/libraries/AdminUtilities.php | 132 ++++++++--- app/libraries/Airavata/Model/Tenant/Types.php | 2 + .../Airavata/Model/Workspace/Types.php | 2 + app/libraries/CRUtilities.php | 6 +- app/libraries/EmailUtilities.php | 46 ++++ app/routes.php | 11 +- app/views/account/dashboard.blade.php | 74 +++--- app/views/account/update.blade.php | 153 +++++++++++++ app/views/admin/create-gateway.blade.php | 148 ++++++++++++ app/views/admin/manage-gateway.blade.php | 227 ++++++++++++++----- 13 files changed, 869 insertions(+), 163 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/config/email_templates.json ---------------------------------------------------------------------- diff --git a/app/config/email_templates.json b/app/config/email_templates.json index f379ca0..f8a7e34 100644 --- a/app/config/email_templates.json +++ b/app/config/email_templates.json @@ -55,5 +55,55 @@ "</p>", "</div>" ] + }, + + "gateway_request" : { + "subject" : "New Gateway Request", + "body" : [ + "<div>", + "<p>", + "Dear Admin,<br/>", + + "$firstName $lastName has initiated a new Gateway request.", + " The requested Gateway is $gatewayName.", + " Please click the link below to verify the request.<br/>", + + "<a href=\"$url\">$url</a><br/>", + "</p>", + "</div>" + ] + }, + + "update_to_admin" : { + "subject" : "Gateway Details Updated", + "body" : [ + "<div>", + "<p>", + "Dear Admin,<br/>", + + "There has been an update in the Gateway info for Gateway with ID - $gatewayId.", + " Please click the link below to view the changes.<br/>", + + "<a href=\"$url\">$url</a><br/>", + "</p>", + "</div>" + ] + }, + + "update_to_user" : { + "subject" : "Gateway Details Updated", + "body" : [ + "<div>", + "<p>", + "Dear $firstName $lastName,<br/>", + + "There has been an update in the Gateway info for your Gateway with ID - $gatewayId.", + " Please click the link below to view the changes.<br/>", + + "<a href=\"$url\">$url</a><br/>", + "</p>", + "</div>" + ] } + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/controllers/AdminController.php ---------------------------------------------------------------------- diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php index f82dd32..ad7ac78 100644 --- a/app/controllers/AdminController.php +++ b/app/controllers/AdminController.php @@ -170,23 +170,36 @@ class AdminController extends BaseController { public function updateGatewayRequest(){ - //first step of adding tenant and changing gateway request status to Approved. - $returnVal = AdminUtilities::update_gateway( Input::get("gateway_id"), Input::all()); + $returnVal = AdminUtilities::update_gateway( Input::get("gateway_id"), Input::except("oauthClientId","oauthClientSecret")); if( Request::ajax()){ - if( $returnVal == 1) - return json_encode( AdminUtilities::get_gateway( Input::get("gateway_id")) ); - else - return $returnVal; // anything other than positive update result + if( $returnVal == 1) { + $username = Session::get("username"); + $email = Config::get('pga_config.portal')['admin-emails']; + $user_profile = Keycloak::getUserProfile($username); + EmailUtilities::mailToUser($user_profile["firstname"], $user_profile["lastname"], $email, Input::get("gateway_id")); + EmailUtilities::mailToAdmin($email, Input::get("gateway_id")); + return json_encode(AdminUtilities::get_gateway(Input::get("gateway_id"))); + } + else { + return $returnVal; // anything other than positive update result + } } else{ - if( $returnVal == 1) - Session::put("message", "Request has been updated"); - else - Session::put("message", "An error has occurred while updating your request. Please try again or contact admin to report the issue."); + if( $returnVal) { + $username = Session::get("username"); + $email = Config::get('pga_config.portal')['admin-emails']; + $user_profile = Keycloak::getUserProfile($username); + EmailUtilities::mailToUser($user_profile["firstname"], $user_profile["lastname"], $email, Input::get("gateway_id")); + EmailUtilities::mailToAdmin($email, Input::get("gateway_id")); + Session::put("message", "Request has been updated"); + } + else { + Session::put("message", "An error has occurred while updating your request. Please make sure you've entered all the details correctly. Try again or contact admin to report the issue."); + } - return Redirect::to("admin/dashboard"); + return Redirect::back(); - } + } //return 1; } @@ -413,6 +426,12 @@ class AdminController extends BaseController { /* ---- Super Admin Functions ------- */ + public function createGateway(){ + + return View::make("admin/create-gateway"); + + } + public function addGateway(){ $inputs = Input::all(); @@ -435,25 +454,64 @@ class AdminController extends BaseController { $validator = Validator::make( $checkValidation, $rules, $messages); if ($validator->fails()) { - return Response::json( $validator->messages() ); + Session::put("validationMessages", [$validator->messages()] ); + return Redirect::back() + ->withErrors($validator); } else{ - $gateway = AdminUtilities::add_gateway(Input::all()); - - $tm = WSIS::createTenant(1, $inputs["admin-username"] . "@" . $inputs["domain"], $inputs["admin-password"], - $inputs["admin-email"], $inputs["admin-firstname"], $inputs["admin-lastname"], $inputs["domain"]); + $username = Session::get("username"); + $returnVal = AdminUtilities::add_gateway(Input::all()); + + if ($returnVal == 1){ + $email = Config::get('pga_config.portal')['admin-emails']; + $user_profile = Keycloak::getUserProfile($username); + EmailUtilities::gatewayRequestMail($user_profile["firstname"], $user_profile["lastname"], $email, Input::get("gateway-name")); + Session::put("message", "Gateway " . $inputs["gateway-name"] . " has been added."); + } + else{ + Session::put("errorMessages", "Error: A Gateway already exists with the same GatewayId, Name or URL! Please make a new request."); + } - Session::put("message", "Gateway " . $inputs["gatewayName"] . " has been added."); - - return Response::json( array( "gateway" =>$gateway, "tm" => $tm ) ); - if( $gateway == $inputs["gatewayName"] && is_object( $tm ) ) - return Response::json( array( "gateway" =>$gateway, "tm" => $tm ) ); - else - return 0; - //return Redirect::to("admin/dashboard/gateway")->with("message", "Gateway has been successfully added."); + return Redirect::back(); } } + public function checkRequest(){ + $inputs = Input::all(); + + $rules = array( + "email" => "required|email", + ); + + $messages = array( + 'email.format' => 'Please enter a valid Email ID', + ); + + $checkValidation = array(); + $checkValidation["email"] = $inputs["email-address"]; + + $validator = Validator::make( $checkValidation, $rules, $messages); + if ($validator->fails()) { + Session::put("validationMessages", [$validator->messages()] ); + return Redirect::to("admin/dashboard") + ->withErrors($validator); + } + else{ + $username = Session::get("username"); + $returnVal = AdminUtilities::check_request(Input::all()); + + if ($returnVal == 1) { + $email = Config::get('pga_config.portal')['admin-emails']; + $user_profile = Keycloak::getUserProfile($username); + EmailUtilities::gatewayRequestMail($user_profile["firstname"], $user_profile["lastname"], $email, $inputs["gateway-name"]); + Session::put("message", "Your request for Gateway " . $inputs["gateway-name"] . " has been created."); + } + else{ + Session::put("errorMessages", "Error: A Gateway already exists with the same GatewayId, Name or URL! Please make a new request."); + } + return Redirect::to("admin/dashboard"); + } + } public function requestGateway(){ $inputs = Input::all(); @@ -484,9 +542,6 @@ class AdminController extends BaseController { } else{ $gateway = AdminUtilities::request_gateway(Input::all()); - - //$tm = WSIS::createTenant(1, $inputs["admin-username"] . "@" . $inputs["domain"], $inputs["admin-password"], inputs["admin-email"], $inputs["admin-firstname"], $inputs["admin-lastname"], $inputs["domain"]); - Session::put("message", "Your request for Gateway " . $inputs["gateway-name"] . " has been created."); return Redirect::to("admin/dashboard"); http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/controllers/UpdateController.php ---------------------------------------------------------------------- diff --git a/app/controllers/UpdateController.php b/app/controllers/UpdateController.php new file mode 100644 index 0000000..48044f4 --- /dev/null +++ b/app/controllers/UpdateController.php @@ -0,0 +1,70 @@ +<?php + +class UpdateController extends BaseController +{ + + public function updateGatewayRequest(){ + + $gateway = AdminUtilities::update_form( Input::get("gateway-id"), Input::all() ); + + $gatewayData = array ("gatewayId" => $gateway->gatewayId, + "gatewayName" => $gateway->gatewayName, + "emailAddress" => $gateway->emailAddress, + "publicProjectDescription" => $gateway->gatewayPublicAbstract, + "gatewayURL" => $gateway->gatewayURL, + "adminFirstName" => $gateway->gatewayAdminFirstName, + "adminLastName" => $gateway-> gatewayAdminLastName, + "adminUsername" => $gateway->identityServerUserName, + "adminEmail" => $gateway->gatewayAdminEmail, + "projectDetails" => $gateway->reviewProposalDescription); + + return View::make("account/update")->with(array('gatewayData'=>$gatewayData)); + + } + + public function updateDetails(){ + + $inputs = Input::all(); + $rules = array( + "username" => "required|min:6", + "password" => "required|min:6|max:48|regex:/^.*(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[@!$#*]).*$/", + "confirm_password" => "required|same:password", + "email" => "required|email", + ); + + $messages = array( + 'password.regex' => 'Password needs to contain at least (a) One lower case letter (b) One Upper case letter and (c) One number (d) One of the following special characters - !@#$&*', + ); + + $checkValidation = array(); + $checkValidation["username"] = $inputs["admin-username"]; + $checkValidation["password"] = $inputs["admin-password"]; + $checkValidation["confirm_password"] = $inputs["admin-password-confirm"]; + $checkValidation["email"] = $inputs["admin-email"]; + + $validator = Validator::make( $checkValidation, $rules, $messages); + if ($validator->fails()) { + Session::put("validationMessages", $validator->messages() ); + return Redirect::back() + ->withInput(Input::except('password', 'password_confirm')) + ->withErrors($validator); + } + else { + $returnVal = AdminUtilities::user_update_gateway(Input::get("gateway-id"), Input::all()); + + if ($returnVal == 1) { + $username = Session::get("username"); + $email = Config::get('pga_config.portal')['admin-emails']; + $user_profile = Keycloak::getUserProfile($username); + EmailUtilities::mailToUser($user_profile["firstname"], $user_profile["lastname"], $email, Input::get("gateway-id")); + EmailUtilities::mailToAdmin($email, Input::get("gateway-id")); + Session::put("message", "Your Gateway has been updated"); + } else + Session::put("errorMessages", "Error: Please try again or contact admin to report the issue."); + } + + return Redirect::to("admin/dashboard"); + + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/libraries/AdminUtilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php index 1352878..ed80bda 100644 --- a/app/libraries/AdminUtilities.php +++ b/app/libraries/AdminUtilities.php @@ -5,6 +5,7 @@ use Airavata\Model\Workspace\GatewayApprovalStatus; use Airavata\Model\Workspace\Notification; use Airavata\Model\Workspace\NotificationPriority; use Airavata\Model\Credential\Store\CredentialOwnerType; +use Illuminate\Support\Facades\Log; class AdminUtilities { @@ -14,31 +15,70 @@ class AdminUtilities * @param $input * @return string */ - public static function add_gateway($input) + public static function add_gateway($inputs) { $gateway = new Gateway(); - $gateway->gatewayId = $input["gatewayName"]; - $gateway->domain = $input["domain"]; - $gateway->gatewayName = $input["gatewayName"]; - $gateway->emailAddress = $input["admin-email"]; + $id = preg_replace('~^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$~', '', $inputs["gateway-name"]); + $id = strtolower(preg_replace('~[^a-zA-Z0-9]+~', '-', $id)); + $gateway->gatewayId = $id; + $gateway->gatewayName = $inputs["gateway-name"]; + $gateway->emailAddress = $inputs["email-address"]; + $gateway->gatewayURL = $inputs["gateway-url"]; + $gateway->gatewayAdminFirstName = $inputs["admin-firstname"]; + $gateway->gatewayAdminEmail = $inputs["admin-email"]; + $gateway->gatewayAdminLastName = $inputs["admin-lastname"]; + $gateway->identityServerUserName = $inputs["admin-username"]; + $gateway->identityServerPasswordToken = $inputs["admin-password"]; + $gateway->reviewProposalDescription = $inputs["project-details"]; + $gateway->gatewayPublicAbstract = $inputs["public-project-description"]; + $gateway->requesterUsername = Session::get('username'); $gateway->gatewayApprovalStatus = GatewayApprovalStatus::APPROVED; - return Airavata::addGateway(Session::get('authz-token'), $gateway); + + try { + TenantProfileService::addGateway(Session::get('authz-token'), $gateway); + return 1; + } + catch (Exception $ex) { + return -1; + } } public static function get_gateway( $gateway_id) { - return Airavata::getGateway( Session::get("authz-token"), $gateway_id); + return TenantProfileService::getGateway( Session::get("authz-token"), $gateway_id); + } + + public static function check_request( $inputs) + { + $gateway = new Gateway( $inputs); + $id = preg_replace('~^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$~', '', $inputs["gateway-name"]); + $id = strtolower(preg_replace('~[^a-zA-Z0-9]+~', '-', $id)); + $gateway->gatewayId = $id; + $gateway->gatewayApprovalStatus = GatewayApprovalStatus::REQUESTED; + //$gateway->domain = 'airavata.' . $inputs["gateway-acronym"]; + $gateway->gatewayName = $inputs["gateway-name"]; + $gateway->emailAddress = $inputs["email-address"]; + $gateway->gatewayPublicAbstract = $inputs["public-project-description"]; + $gateway->requesterUsername = Session::get('username'); + + try { + TenantProfileService::addGateway(Session::get('authz-token'), $gateway); + return 1; + } + catch (Exception $ex) { + return -1; + } } public static function request_gateway( $inputs) { $gateway = new Gateway( $inputs); $gateway->gatewayId = $inputs["gateway-name"]; - $gateway->gatewayApprovalStatus = GatewayApprovalStatus::REQUESTED; - $gateway->domain = 'airavata.' . $inputs["gateway-acronym"]; + $gateway->gatewayApprovalStatus = GatewayApprovalStatus::APPROVED; + //$gateway->domain = 'airavata.' . $inputs["gateway-acronym"]; $gateway->gatewayName = $inputs["gateway-name"]; $gateway->emailAddress = $inputs["email-address"]; - $gateway->gatewayAcronym = $inputs["gateway-acronym"]; + //$gateway->gatewayAcronym = $inputs["gateway-acronym"]; $gateway->gatewayURL = $inputs["gateway-url"]; $gateway->gatewayAdminFirstName = $inputs["admin-firstname"]; $gateway->gatewayAdminLastName = $inputs["admin-lastname"]; @@ -46,10 +86,9 @@ class AdminUtilities $gateway->identityServerPasswordToken = $inputs["admin-password"]; $gateway->reviewProposalDescription = $inputs["project-details"]; $gateway->gatewayPublicAbstract = $inputs["public-project-description"]; - $gateway->requesterUsername = Session::get('username'); - return Airavata::addGateway(Session::get('authz-token'), $gateway); + return TenantProfileService::addGateway(Session::get('authz-token'), $gateway); } public static function get_gateway_approval_statuses() @@ -58,39 +97,80 @@ class AdminUtilities return $gatewayApprovalStatusObject::$__names; } + public static function update_form( $gatewayId, $gatewayData){ + + if( isset( $gatewayData["updateRequest"])) { + return TenantProfileService::getGateway( Session::get('authz-token'), $gatewayId); + } + + } + + public static function user_update_gateway( $gatewayId, $gatewayData){ + $gateway = TenantProfileService::getGateway( Session::get('authz-token'), $gatewayId); + $gateway->gatewayApprovalStatus = GatewayApprovalStatus::APPROVED; + $gateway->emailAddress = $gatewayData["email-address"]; + $gateway->gatewayURL = $gatewayData["gateway-url"]; + $gateway->identityServerUserName = $gatewayData["admin-username"]; + $gateway->identityServerPasswordToken = $gatewayData["admin-password"]; + $gateway->gatewayAdminFirstName = $gatewayData["admin-firstname"]; + $gateway->gatewayAdminLastName = $gatewayData["admin-lastname"]; + $gateway->gatewayAdminEmail = $gatewayData["admin-email"]; + $gateway->reviewProposalDescription = $gatewayData["project-details"]; + $gateway->gatewayPublicAbstract = $gatewayData["public-project-description"]; + if( TenantProfileService::updateGateway( Session::get('authz-token'), $gateway) ){ + return 1; + } + else{ + //Need to find a better way for this. + // retun echo "Tenant Name is already in use"; + return -1; + } + } + public static function update_gateway( $gatewayId, $gatewayData){ - $gateway = Airavata::getGateway( Session::get('authz-token'), $gatewayId); + $gateway = TenantProfileService::getGateway( Session::get('authz-token'), $gatewayId); if( isset( $gatewayData["cancelRequest"])) $gateway->gatewayApprovalStatus = GatewayApprovalStatus::CANCELLED; else{ $gateway->gatewayName = $gatewayData["gatewayName"]; - $gateway->gatewayAcronym = $gatewayData["gatewayAcronym"]; - $gateway->domain = 'airavata.'. $gatewayData["gatewayAcronym"]; $gateway->gatewayURL = $gatewayData["gatewayURL"]; - $gateway->gatewayName = $gatewayData["gatewayName"]; $gateway->declinedReason = $gatewayData["declinedReason"]; } - - if( isset($gatewayData["createTenant"])){ - if( AdminUtilities::add_tenant( $gateway) ) - $gateway->gatewayApprovalStatus = GatewayApprovalStatus::APPROVED; + if( isset($gatewayData["createTenant"])) { + $gatewayData["declinedReason"] = " "; + foreach ($gatewayData as $data) { + if ($data == null) { + return -1; + } + } + $gateway = IamAdminServices::setUpGateway( Session::get('authz-token'), $gateway); + $gateway->gatewayApprovalStatus = GatewayApprovalStatus::CREATED; + } + elseif( isset( $gatewayData["approveRequest"])){ + $gateway->gatewayApprovalStatus = GatewayApprovalStatus::APPROVED; } elseif( isset( $gatewayData["denyRequest"])){ $gateway->gatewayApprovalStatus = GatewayApprovalStatus::DENIED; - } elseif( isset( $gatewayData["updateGateway"])){ - - //$gateway->gatewayApprovalStatus = GatewayApprovalStatus::APPROVED; - $gateway->oauthClientId = $gatewayData["oauthClientId"]; - $gateway->oauthClientSecret = $gatewayData["oauthClientSecret"]; + $gateway->emailAddress = $gatewayData["emailAddress"]; + $gateway->gatewayURL = $gatewayData["gatewayURL"]; + $gateway->gatewayAdminFirstName = $gatewayData["gatewayAdminFirstName"]; + $gateway->gatewayAdminLastName = $gatewayData["gatewayAdminLastName"]; + $gateway->identityServerUserName = $gatewayData["identityServerUserName"]; + $gateway->reviewProposalDescription = $gatewayData["reviewProposalDescription"]; + $gateway->gatewayPublicAbstract = $gatewayData["gatewayPublicAbstract"]; + $gateway->gatewayApprovalStatus = GatewayApprovalStatus::APPROVED; + } + elseif( isset( $gatewayData["deployGateway"])){ + $gateway->gatewayApprovalStatus = GatewayApprovalStatus::DEPLOYED; } elseif( isset( $gatewayData["deactivateGateway"])){ $gateway->gatewayApprovalStatus = GatewayApprovalStatus::DEACTIVATED; } - if( Airavata::updateGateway( Session::get('authz-token'), $gateway->gatewayId, $gateway) ){ + if( TenantProfileService::updateGateway( Session::get('authz-token'), $gateway) ){ return 1; } else{ http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/libraries/Airavata/Model/Tenant/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Tenant/Types.php b/app/libraries/Airavata/Model/Tenant/Types.php index 74595f8..b217adf 100644 --- a/app/libraries/Airavata/Model/Tenant/Types.php +++ b/app/libraries/Airavata/Model/Tenant/Types.php @@ -25,6 +25,7 @@ final class TenantApprovalStatus { const CANCELLED = 4; const DENIED = 5; const CREATED = 6; + const DEPLOYED = 7; static public $__names = array( 0 => 'REQUESTED', 1 => 'APPROVED', @@ -33,6 +34,7 @@ final class TenantApprovalStatus { 4 => 'CANCELLED', 5 => 'DENIED', 6 => 'CREATED', + 7 => 'DEPLOYED', ); } http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/libraries/Airavata/Model/Workspace/Types.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/Model/Workspace/Types.php b/app/libraries/Airavata/Model/Workspace/Types.php index d929439..850778a 100644 --- a/app/libraries/Airavata/Model/Workspace/Types.php +++ b/app/libraries/Airavata/Model/Workspace/Types.php @@ -25,6 +25,7 @@ final class GatewayApprovalStatus { const CANCELLED = 4; const DENIED = 5; const CREATED = 6; + const DEPLOYED = 7; static public $__names = array( 0 => 'REQUESTED', 1 => 'APPROVED', @@ -33,6 +34,7 @@ final class GatewayApprovalStatus { 4 => 'CANCELLED', 5 => 'DENIED', 6 => 'CREATED', + 7 => 'DEPLOYED', ); } http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/libraries/CRUtilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php index 3349961..71cd779 100755 --- a/app/libraries/CRUtilities.php +++ b/app/libraries/CRUtilities.php @@ -534,12 +534,12 @@ class CRUtilities public static function getAllGateways() { if (Session::has("super-admin")){ - $gateways = Airavata::getAllGateways(Session::get('authz-token')); + $gateways = TenantProfileService::getAllGateways(Session::get('authz-token')); //sort with creation time usort($gateways, CommonUtilities::arrSortObjsByKey('requestCreationTime', 'ASC')); } else { - $gateways[0] = Airavata::getGateway(Session::get('authz-token'), Session::get("gateway_id")); + $gateways[0] = TenantProfileService::getGateway(Session::get('authz-token'), Session::get("gateway_id")); } return $gateways; } @@ -547,7 +547,7 @@ class CRUtilities public static function updateGatewayProfile( $data){ $gatewayResourceProfile = Airavata::getGatewayResourceProfile( Session::get('authz-token'), $data["gateway_id"]); $gatewayResourceProfile->credentialStoreToken = $data["cst"]; - return Airavata::updateGatewayResourceProfile( Session::get('authz-token'), $data["gateway_id"], $gatewayResourceProfile); + return Airavata::updateGatewayResourceProfile( Session::get('authz-token'), $data["gateway_id"], $gatewayResourceProfile); } public static function add_or_update_CRP($inputs) http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/libraries/EmailUtilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/EmailUtilities.php b/app/libraries/EmailUtilities.php index 8e1099a..8ebe027 100644 --- a/app/libraries/EmailUtilities.php +++ b/app/libraries/EmailUtilities.php @@ -89,6 +89,52 @@ class EmailUtilities } } + //PGA sends email to Admin about new request + public static function gatewayRequestMail($firstName, $lastName, $email, $gatewayName){ + + $emailTemplates = json_decode(File::get(app_path() . '/config/email_templates.json')); + $subject = $emailTemplates->gateway_request->subject; + $body = trim(implode($emailTemplates->gateway_request->body)); + + $body = str_replace("\$url", URL::to('/') . '/admin/dashboard/gateway', $body); + $body = str_replace("\$firstName", $firstName, $body); + $body = str_replace("\$lastName", $lastName, $body); + $body = str_replace("\$gatewayName", $gatewayName, $body); + + EmailUtilities::sendEmail($subject, [$email], $body); + + } + + //PGA sends email to User when Gateway is UPDATED + public static function mailToUser($firstName, $lastName, $email, $gatewayId){ + + $emailTemplates = json_decode(File::get(app_path() . '/config/email_templates.json')); + $subject = $emailTemplates->update_to_user->subject; + $body = trim(implode($emailTemplates->update_to_user->body)); + + $body = str_replace("\$url", URL::to('/') . '/admin/dashboard', $body); + $body = str_replace("\$firstName", $firstName, $body); + $body = str_replace("\$lastName", $lastName, $body); + $body = str_replace("\$gatewayId", $gatewayId, $body); + + EmailUtilities::sendEmail($subject, [$email], $body); + + } + + //PGA sends email to Admin when Gateway is UPDATED + public static function mailToAdmin($email, $gatewayId){ + + $emailTemplates = json_decode(File::get(app_path() . '/config/email_templates.json')); + $subject = $emailTemplates->update_to_admin->subject; + $body = trim(implode($emailTemplates->update_to_admin->body)); + + $body = str_replace("\$url", URL::to('/') . '/admin/dashboard/gateway', $body); + $body = str_replace("\$gatewayId", $gatewayId, $body); + + EmailUtilities::sendEmail($subject, [$email], $body); + + } + public static function sendEmail($subject, $recipients, $body){ $mail = new PHPMailer(); http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/routes.php ---------------------------------------------------------------------- diff --git a/app/routes.php b/app/routes.php index 6fa808b..c0a881f 100755 --- a/app/routes.php +++ b/app/routes.php @@ -28,6 +28,8 @@ Route::get("refreshed-token-desktop", "AccountController@getRefreshedTokenForDes Route::get("account/dashboard", "AccountController@dashboard"); +Route::get("account/update-gateway", "UpdateController@updateGatewayRequest"); + Route::get("callback-url", "AccountController@oauthCallback"); Route::get("logout", "AccountController@logout"); @@ -358,8 +360,9 @@ Route::post("admin/create-pwd-token", "AdminController@createPWD"); Route::post("admin/remove-pwd-token", "AdminController@removePWD"); //GatewayProviders -Route::get("provider/request-gateway", "AdminController@requestGateway"); - +Route::get("provider/request-gateway", "AdminController@checkRequest"); +Route::get("provider/add-gateway", "AdminController@requestGateway"); +Route::get("provider/update-details", "UpdateController@updateDetails"); //notices Route::get("admin/dashboard/notices", "AdminController@noticesView"); @@ -373,8 +376,8 @@ Route::post("notice-seen-ack", "AccountController@noticeSeenAck"); //Super Admin Specific calls -Route::post("admin/add-gateway", "AdminController@addGateway"); -Route::get("admin/add-gateway", "AdminController@addGateway"); +Route::get("admin/add-gateway", "AdminController@createGateway"); +Route::get("admin/add-new-gateway", "AdminController@addGateway"); Route::get("admin/update-gateway-request", "AdminController@updateGatewayRequest"); http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/views/account/dashboard.blade.php ---------------------------------------------------------------------- diff --git a/app/views/account/dashboard.blade.php b/app/views/account/dashboard.blade.php index 0899960..f1e5428 100644 --- a/app/views/account/dashboard.blade.php +++ b/app/views/account/dashboard.blade.php @@ -19,6 +19,18 @@ {{ Session::forget("message") }} @endif + @if (Session::has("errorMessages")) + <div class="row"> + <div class="alert alert-danger alert-dismissible" role="alert"> + <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span + class="sr-only">Close</span></button> + {{ Session::get("errorMessages") }} + </div> + </div> + {{ Session::forget("errorMessages") }} + @endif + + @if( Session::has('new-gateway-provider') ) <div style="margin-top:50px;" class="col-md-12"> @if( Session::has("existing-gateway-provider") ) @@ -55,7 +67,7 @@ <td style="max-width: 400px; word-wrap: break-word;">{{ $gateway["gatewayInfo"]->gatewayPublicAbstract }}</td> <td>{{ $gateway["approvalStatus"] }}</td> <td> - @if( $gateway["approvalStatus"] == "APPROVED") + @if( $gateway["approvalStatus"] == "CREATED" || $gateway["approvalStatus"] == "DEPLOYED" ) <div class="btn-group" role="group" aria-label="..."> <button type="button" class="btn btn-default view-credentials" data-gatewayobject="{{ htmlentities( json_encode( $gateway['gatewayInfo'])) }}">View Credentials</button> <!-- @@ -64,10 +76,15 @@ <button type="button" class="btn btn-danger deactivateGateway-button" data-toggle="modal" data-target="#deactivateGateway" data-gatewayid="{{$gatewayId}}">Deactivate Gateway</button> --> </div> - @elseif( $gateway["approvalStatus"] == "REQUESTED") + @elseif( $gateway["approvalStatus"] == "REQUESTED" || $gateway["approvalStatus"] == "APPROVED") <a href="{{URL::to('/')}}/admin/update-gateway-request?gateway_id={{$gatewayId}}&cancelRequest=true"> <button type="button" class="btn btn-danger">Cancel Request</button> </a> + @if( $gateway["approvalStatus"] == "APPROVED") + <a href="{{URL::to('/')}}/account/update-gateway?gateway-id={{$gatewayId}}&updateRequest=true"> + <button type="button" class="gateway-update-button btn btn-default">Update Request</button> + </a> + @endif @endif </td> <td> @@ -96,14 +113,16 @@ <div class="well"> <h6 class="text-center">Need faster or more customised solutions for your Gateway? Contact us at: <a href="mailto:h...@scigap.org">h...@scigap.org</a></h6> </div> + @if ($errors->has()) @foreach ($errors->all() as $error) {{ CommonUtilities::print_error_message($error) }} @endforeach @endif + <div class="row @if(! $errors->has())hide @endif gateway-request-form"> <div class="col-md-offset-2 col-md-8"> - <form id="add-tenant-form" action="{{ URL::to('/') }}/provider/request-gateway"> + <form id="request-tenant-form" action="{{ URL::to('/') }}/provider/request-gateway"> <div class="col-md-12 text-center" style="margin-top:20px;"> <h3>Request your gateway now!</h3> </div> @@ -112,46 +131,10 @@ <input type="text" maxlength="50" name="gateway-name" class="form-control" required="required" value="{{Input::old('gateway-name') }}" /> </div> <div class="form-group required"> - <label class="control-label">Gateway Acronym </label> - <input type="text" name="gateway-acronym" class="gateway-acronym form-control" required="required" value="{{Input::old('gateway-acronym') }}" - pattern="[A-Za-z]+" data-toggle="popover" data-placement="left" data-content="Acronym cannot contain digits or special characters or spaces."/> - </div> - - <div class="form-group required"> - <label class="control-label">Gateway URL</label> - <input type="text" name="gateway-url" id="gateway-url" class="form-control" value="{{Input::old('gateway-url') }}" data-container="body" data-toggle="popover" data-placement="left" data-content="URL to Portal home page or Download URL (for desktop applications) where gateway has been deployed."/> - </div> - <div class="form-group required"> - <label class="control-label">Gateway Admin Username</label> - <input type="text" name="admin-username" value="{{Input::old('admin-username')}}" class="form-control" required="required" /> - </div> - <div class="form-group required"> - <label class="control-label">Gateway Admin Password</label> - <input type="password" id="password" name="admin-password" class="form-control" required="required" title="" type="password" data-container="body" data-toggle="popover" data-placement="left" data-content="Password needs to contain at least (a) One lower case letter (b) One Upper case letter and (c) One number (d) One of the following special characters - !@#$*"/> - </div> - <div class="form-group required"> - <label class="control-label">Admin Password Confirmation</label> - <input type="password" name="admin-password-confirm" class="form-control" required="required"/> - </div> - - <div class="form-group required"> - <label class="control-label">Admin First Name</label> - <input type="text" name="admin-firstname" class="form-control" required="required" value="{{Input::old('admin-firstname') }}"/> - </div> - - <div class="form-group required"> - <label class="control-label">Admin Last Name</label> - <input type="text" name="admin-lastname" class="form-control" required="required" value="{{Input::old('admin-lastname') }}"/> - </div> - <div class="form-group required"> <label class="control-label">Gateway Contact Email</label> <input type="text" name="email-address" class="form-control" required="required" value="{{Input::old('email-address') }}"/> </div> <div class="form-group required"> - <label class="control-label">Project Details</label> - <textarea type="text" name="project-details" maxlength="250" id="project-details" class="form-control" required="required" data-container="body" data-toggle="popover" data-placement="left" data-content="This information will help us to understand and identify your gateway requirements, such as local or remote resources, user management, field of science and communities supported, applications and interfaces, license handling, allocation management, data management, etc... It will help us in serving you and providing you with the best option for you and your research community.">{{Input::old('project-details') }}</textarea> - </div> - <div class="form-group required"> <label class="control-label">Public Project Description</label> <textarea type="text" name="public-project-description" maxlength="250" id="public-project-description" class="form-control" required="required" data-container="body" data-toggle="popover" data-placement="left" data-content="This description will be used to describe the gateway in the Science Gateways List. It help a user decide whether or not this gateway will be useful to them.">{{Input::old('public-project-description') }}</textarea> </div> @@ -162,6 +145,11 @@ </div> <hr/> </div> + + <hr/> + </div> + + <!-- View Credentials --> <div class="modal fade" id="viewCredentials" tabindex="-1" role="dialog" aria-labelledby="vc"> <div class="modal-dialog" role="document"> @@ -188,18 +176,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> <tr> - <td>Admin Password</td> - <td class="admin-password"></td> - </tr> - <tr> <td>Oauth Client Key</td> <td class="oauth-client-key"></td> </tr> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/views/account/update.blade.php ---------------------------------------------------------------------- diff --git a/app/views/account/update.blade.php b/app/views/account/update.blade.php new file mode 100644 index 0000000..77e94b6 --- /dev/null +++ b/app/views/account/update.blade.php @@ -0,0 +1,153 @@ +@extends('layout.basic') + +@section('page-header') + @parent + {{ HTML::style('css/admin.css')}} +@stop + +@section('content') + <div class="container"> + <div class="col-md-12"> + + @if (Session::has("messages")) + <div class="row"> + <div class="alert alert-success alert-dismissible" role="alert"> + <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span + class="sr-only">Close</span></button> + {{ Session::get("messages") }} + </div> + </div> + {{ Session::forget("messages") }} + @endif + + @if (Session::has("errorMessages")) + <div class="row"> + <div class="alert alert-danger alert-dismissible" role="alert"> + <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span + class="sr-only">Close</span></button> + {{ Session::get("errorMessages") }} + </div> + </div> + {{ Session::forget("errorMessages") }} + @endif + + <div class="row gateway-update-form"> + <div class="col-md-offset-2 col-md-8"> + + @if ($errors->has()) + @foreach ($errors->all() as $error) + {{ CommonUtilities::print_error_message($error) }} + @endforeach + @endif + + <form id="add-tenant-form" action="{{ URL::to('/') }}/provider/update-details?gateway_id={{ $gatewayData["gatewayId"] }}&updateRequest=true"> + <div class="col-md-12 text-center" style="margin-top:20px;"> + <h3>Update your Gateway details now!</h3> + </div> + <div class="form-group required"> + <label class="control-label">Gateway ID</label> + <input type="text" maxlength="50" name="gateway-id" class="form-control" readonly="readonly" required="required" value="{{ $gatewayData["gatewayId"] }}" /> + </div> + <div class="form-group required"> + <label class="control-label">Gateway Name</label> + <input type="text" maxlength="50" name="gateway-name" class="form-control" readonly="readonly" required="required" value="{{ $gatewayData["gatewayName"] }}" /> + </div> + + <div class="form-group required"> + <label class="control-label">Gateway URL</label> + <input type="text" name="gateway-url" id="gateway-url" class="form-control" value="{{ $gatewayData["gatewayURL"] }}" data-container="body" data-toggle="popover" data-placement="left" data-content="URL to Portal home page or Download URL (for desktop applications) where gateway has been deployed."/> + </div> + + <div class="form-group required"> + <label class="control-label">Gateway Contact Email</label> + <input type="text" name="email-address" class="form-control" required="required" value="{{ $gatewayData["emailAddress"] }}"/> + </div> + + <div class="form-group required"> + <label class="control-label">Gateway Admin Username</label> + <input type="text" name="admin-username" value="{{ $gatewayData["adminUsername"] }}" class="form-control" required="required" /> + </div> + + <div class="form-group required"> + <label class="control-label">Gateway Admin Password</label> + <input type="password" id="password" name="admin-password" class="form-control" required="required" title="" type="password" data-container="body" data-toggle="popover" data-placement="left" data-content="Password needs to contain at least (a) One lower case letter (b) One Upper case letter and (c) One number (d) One of the following special characters - !@#$*"/> + </div> + + <div class="form-group required"> + <label class="control-label">Admin Password Confirmation</label> + <input type="password" name="admin-password-confirm" class="form-control" required="required"/> + </div> + + <div class="form-group required"> + <label class="control-label">Admin First Name</label> + <input type="text" name="admin-firstname" class="form-control" required="required" value="{{ $gatewayData["adminFirstName"] }}"/> + </div> + + <div class="form-group required"> + <label class="control-label">Admin Last Name</label> + <input type="text" name="admin-lastname" class="form-control" required="required" value="{{ $gatewayData["adminLastName"] }}"/> + </div> + + <div class="form-group required"> + <label class="control-label">Admin Email ID</label> + <input type="text" name="admin-email" class="form-control" required="required" value="{{ $gatewayData["adminEmail"] }}"/> + </div> + + <div class="form-group required"> + <label class="control-label">Project Details</label> + <textarea type="text" name="project-details" maxlength="250" id="project-details" class="form-control" required="required" data-container="body" data-toggle="popover" data-placement="left" data-content="This information will help us to understand and identify your gateway requirements, such as local or remote resources, user management, field of science and communities supported, applications and interfaces, license handling, allocation management, data management, etc... It will help us in serving you and providing you with the best option for you and your research community.">{{ $gatewayData["projectDetails"] }}</textarea> + </div> + + <div class="form-group required"> + <label class="control-label">Public Project Description</label> + <textarea type="text" name="public-project-description" maxlength="250" id="public-project-description" class="form-control" required="required" data-container="body" data-toggle="popover" data-placement="left" data-content="This description will be used to describe the gateway in the Science Gateways List. It help a user decide whether or not this gateway will be useful to them.">{{ $gatewayData["publicProjectDescription"] }}</textarea> + </div> + + <input type="submit" value="Update Details" class="btn btn-primary"/> + <input type="reset" value="Reset" class="btn"> + </form> + </div> + </div> + </div> + </div> + </div> +@stop + +@section('scripts') +@parent +<script> + + $("#password").popover({ + 'trigger':'focus' + }); + + $("#gateway-url").popover({ + 'trigger':'focus' + }); + + $(".gateway-acronym").popover({ + 'trigger':'focus' + }); + + $("#project-details").popover({ + 'trigger':'focus' + }); + + $("#public-project-description").popover({ + 'trigger':'focus' + }); + + $(".view-credentials").click( function(){ + var gatewayObject = $(this).data("gatewayobject"); + $(".admin-username").html( gatewayObject["identityServerUserName"]); + $(".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"); + }); + +</script> +@stop \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/app/views/admin/create-gateway.blade.php ---------------------------------------------------------------------- diff --git a/app/views/admin/create-gateway.blade.php b/app/views/admin/create-gateway.blade.php new file mode 100644 index 0000000..d15f934 --- /dev/null +++ b/app/views/admin/create-gateway.blade.php @@ -0,0 +1,148 @@ +@extends('layout.basic') + +@section('page-header') + @parent + {{ HTML::style('css/admin.css')}} +@stop + +@section('content') + <div class="container"> + <div class="col-md-12"> + <div class="row gateway-update-form"> + <div class="col-md-offset-2 col-md-8"> + + @if( Session::has("message")) + <div class="row"> + <div class="alert alert-success alert-dismissible" role="alert"> + <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span + class="sr-only">Close</span></button> + {{ Session::get("message") }} + </div> + </div> + {{ Session::forget("message") }} + @endif + + @if (Session::has("errorMessages")) + <div class="row"> + <div class="alert alert-danger alert-dismissible" role="alert"> + <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span + class="sr-only">Close</span></button> + {{ Session::get("errorMessages") }} + </div> + </div> + {{ Session::forget("errorMessages") }} + @endif + + @if ($errors->has()) + @foreach ($errors->all() as $error) + {{ CommonUtilities::print_error_message($error) }} + @endforeach + @endif + + <form id="add-tenant-form" action="{{ URL::to('/') }}/admin/add-new-gateway"> + <div class="col-md-12 text-center" style="margin-top:20px;"> + <h3>Add your Gateway now!</h3> + </div> + <div class="form-group required"> + <label class="control-label">Gateway Name</label> + <input type="text" maxlength="50" name="gateway-name" class="form-control" required="required" value="{{Input::old('gateway-name') }}" /> + </div> + + <div class="form-group required"> + <label class="control-label">Gateway URL</label> + <input type="text" name="gateway-url" id="gateway-url" class="form-control" value="{{Input::old('gateway-url') }}" data-container="body" data-toggle="popover" data-placement="left" data-content="URL to Portal home page or Download URL (for desktop applications) where gateway has been deployed."/> + </div> + + <div class="form-group required"> + <label class="control-label">Gateway Contact Email</label> + <input type="text" name="email-address" class="form-control" required="required" value="{{Input::old('email-address') }}"/> + </div> + + <div class="form-group required"> + <label class="control-label">Gateway Admin Username</label> + <input type="text" name="admin-username" value="{{Input::old('admin-username')}}" class="form-control" required="required" /> + </div> + + <div class="form-group required"> + <label class="control-label">Gateway Admin Password</label> + <input type="password" id="password" name="admin-password" class="form-control" required="required" title="" type="password" data-container="body" data-toggle="popover" data-placement="left" data-content="Password needs to contain at least (a) One lower case letter (b) One Upper case letter and (c) One number (d) One of the following special characters - !@#$*"/> + </div> + + <div class="form-group required"> + <label class="control-label">Admin Password Confirmation</label> + <input type="password" name="admin-password-confirm" class="form-control" required="required"/> + </div> + + <div class="form-group required"> + <label class="control-label">Admin First Name</label> + <input type="text" name="admin-firstname" class="form-control" required="required" value="{{Input::old('admin-firstname') }}"/> + </div> + + <div class="form-group required"> + <label class="control-label">Admin Last Name</label> + <input type="text" name="admin-lastname" class="form-control" required="required" value="{{Input::old('admin-lastname') }}"/> + </div> + + <div class="form-group required"> + <label class="control-label">Admin Email ID</label> + <input type="text" name="admin-email" class="form-control" required="required" value="{{Input::old('admin-email') }}"/> + </div> + + <div class="form-group required"> + <label class="control-label">Project Details</label> + <textarea type="text" name="project-details" maxlength="250" id="project-details" class="form-control" required="required" data-container="body" data-toggle="popover" data-placement="left" data-content="This information will help us to understand and identify your gateway requirements, such as local or remote resources, user management, field of science and communities supported, applications and interfaces, license handling, allocation management, data management, etc... It will help us in serving you and providing you with the best option for you and your research community.">{{Input::old('project-details') }}</textarea> + </div> + + <div class="form-group required"> + <label class="control-label">Public Project Description</label> + <textarea type="text" name="public-project-description" maxlength="250" id="public-project-description" class="form-control" required="required" data-container="body" data-toggle="popover" data-placement="left" data-content="This description will be used to describe the gateway in the Science Gateways List. It help a user decide whether or not this gateway will be useful to them.">{{Input::old('public-project-description') }}</textarea> + </div> + + <input type="submit" value="Submit" class="btn btn-primary"/> + <input type="reset" value="Reset" class="btn"> + </form> + </div> + </div> + </div> + </div> + </div> +@stop + +@section('scripts') + @parent + <script> + + $("#password").popover({ + 'trigger':'focus' + }); + + $("#gateway-url").popover({ + 'trigger':'focus' + }); + + $(".gateway-acronym").popover({ + 'trigger':'focus' + }); + + $("#project-details").popover({ + 'trigger':'focus' + }); + + $("#public-project-description").popover({ + 'trigger':'focus' + }); + + $(".view-credentials").click( function(){ + var gatewayObject = $(this).data("gatewayobject"); + $(".admin-username").html( gatewayObject["identityServerUserName"]); + $(".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"); + }); + + </script> +@stop \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f33f4226/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 795af43..3ecddc5 100644 --- a/app/views/admin/manage-gateway.blade.php +++ b/app/views/admin/manage-gateway.blade.php @@ -35,8 +35,25 @@ </div> {{ Session::forget("message") }} @endif + + @if (Session::has("errorMessages")) + <div class="row"> + <div class="alert alert-danger alert-dismissible" role="alert"> + <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span + class="sr-only">Close</span></button> + {{ Session::get("errorMessages") }} + </div> + </div> + {{ Session::forget("errorMessages") }} + @endif </div> + @if ($errors->has()) + @foreach ($errors->all() as $error) + {{ CommonUtilities::print_error_message($error) }} + @endforeach + @endif + <div class="col-md-12"> <ul class="nav nav-tabs nav-justified" id="tabs" role="tablist"> <li class="active"><a href="#tab-currentGateway" data-toggle="tab">Gateway - {{ Session::get("gateway_id") }}</a></li> @@ -64,14 +81,11 @@ <div class="tab-pane" id="tab-requestedGateways"> <div class="row"> - <form id="add-tenant-form" action="{{ URL::to('/') }}/admin/add-gateway"> - <div class="col-md-12"> - <button type="button" class="btn btn-default toggle-add-tenant"><span + <a href="{{ URL::to('/') }}/admin/add-gateway"> + <button type="button" class="btn btn-default toggle-add-tenant"><span class="glyphicon glyphicon-plus"></span>Add a new gateway - </button> - </div> - @include('partials/add-gateway-block') - </form> + </button> + </a> </div> <div class="row"> <div class="col-md-12 table-responsive"> @@ -216,9 +230,11 @@ <form action="{{URL::to('/')}}/admin/update-gateway-request" id="update-gateway-request" method="GET"> <div class="modal-header"> - <button type="button" class="close update-gateway-request-close-modal" data-dismiss="modal" aria-label="Close"><span + <button type="button" class="close update-gateway-request-close-modal" data-dismiss="modal" aria-label="Close" onclick="window.location.reload()"><span aria-hidden="true">×</span></button> - <h3>Approve Gateway Request</h3> + + <h3>View the Gateway Details</h3> + </div> <!-- <div class="modal-body onTenantLoad"> @@ -230,59 +246,53 @@ <h3>Gateway Tenant has been added. Please fill in rest of the required details.</h3> --> <div class="form-group"> - <h4>GatewayId: <span class="gatewayid-for-approval"></span></h4> + <h4>Gateway ID: <span class="gatewayid-for-approval"></span></h4> </div> <div class="form-group"> <label>Gateway Name</label> - <input type="text" name="gatewayName" class="form-control gatewayName"/> + <input type="text" readonly="readonly" name="gatewayName" class="form-control gatewayName"/> </div> <div class="form-group"> - <label>Gateway Acronym</label> - <input type="text" name="gatewayAcronym" class="form-control gatewayAcronym"/> - </div> - <div class="form-group"> - <label>Gateway Domain</label> - <input type="text" class="form-control domain" value="Domain will become - 'airavata' . [gateway acroym]" readonly="readonly" /> - </div> - <div class="form-group"> - <label>Gateway Url</label> - <input type="text" name="gatewayURL" class="form-control gatewayURL"/> + <label>Contact Email Address</label> + <input type="text" name="emailAddress" id="emailAddress" class="form-control emailAddress"/> </div> <div class="form-group"> - <label>Gateway Public Abstract</label> - <textarea readonly="readonly" name="gatewayPublicAbstract" class="form-control gatewayPublicAbstract"></textarea> + <label>Gateway URL</label> + <input type="text" name="gatewayURL" id="gatewayURL" class="form-control gatewayURL"/> </div> <div class="form-group"> - <label>Gateway Proposal Description</label> - <textarea readonly="readonly" name="reviewProposalDescription" class="form-control reviewProposalDescription"></textarea> + <label>Gateway Admin Username</label> + <input type="text" name="identityServerUserName" id="identityServerUserName" class="form-control identityServerUserName"/> </div> <div class="form-group"> <label>Gateway Admin First Name</label> - <input type="text" readonly="readonly" name="gatewayAdminFirstName" class="form-control gatewayAdminFirstName"/> + <input type="text" name="gatewayAdminFirstName" id="gatewayAdminFirstName" class="form-control gatewayAdminFirstName"/> </div> <div class="form-group"> <label>Gateway Admin Last Name</label> - <input type="text" readonly="readonly" name="gatewayAdminLastName" class="form-control gatewayAdminLastName"/> + <input type="text" name="gatewayAdminLastName" id="gatewayAdminLastName" class="form-control gatewayAdminLastName"/> </div> <div class="form-group"> - <label>Contact Email Address</label> - <input type="text" readonly="readonly" name="emailAddress" class="form-control emailAddress"/> + <label>Admin Email ID</label> + <input type="text" name="gatewayAdminEmail" id="gatewayAdminEmail" class="form-control emailAddress"/> </div> <div class="form-group"> - <label>Gateway Admin Username</label> - <input type="text" readonly="readonly" name="identityServerUserName" class="form-control identityServerUserName"/> + <label>Gateway Public Abstract</label> + <textarea name="gatewayPublicAbstract" id="gatewayPublicAbstract" class="form-control gatewayPublicAbstract"></textarea> </div> <div class="form-group"> - <label>Gateway Admin First Name</label> - <input type="text" readonly="readonly" name="gatewayAdminFirstName" class="form-control gatewayAdminFirstName"/> + <label>Gateway Proposal Description</label> + <textarea name="reviewProposalDescription" id="reviewProposalDescription" class="form-control reviewProposalDescription"></textarea> </div> + <div class="form-group"> <label>Oauth Client Id</label> - <input type="text" name="oauthClientId" class="form-control oauthClientId"/> + <input type="text" readonly="readonly" name="oauthClientId" class="form-control oauthClientId"/> </div> + <div class="form-group"> <label>Oauth Client Secret</label> - <input type="text" name="oauthClientSecret" class="form-control oauthClientSecret"/> + <input type="text" readonly="readonly" name="oauthClientSecret" class="form-control oauthClientSecret"/> </div> <div class="form-group"> <label>SciGaP Admin Comments</label> @@ -291,7 +301,7 @@ <div class="form-group"> <label>Status</label> - <input type="text" name="gatewayApprovalStatus" class="form-control gatewayApprovalStatus" readonly="readonly" /> + <input type="text" readonly="readonly" name="gatewayApprovalStatus" class="form-control gatewayApprovalStatus"/> <!-- <select name="gatewayApprovalStatus" class="form-control gatewayApprovalStatus"> @foreach( $gatewayApprovalStatuses as $val => $status) @@ -303,10 +313,12 @@ <input type="hidden" class="gatewayid-for-approval" name="gateway_id"> </div> <div class="modal-footer submit-actions"> - <button type="submit" name="status" class="btn btn-primary notCreatedGateway update-gateway" value="createTenant">Create Tenant</button> - <button type="submit" name="status" class="btn btn-danger notCreatedGateway update-gateway" value="denyRequest">Deny Request</button> - <button type="submit" name="status" class="btn btn-primary createdGateway update-gateway" value="updateGateway">Update Gateway</button> - <button type="submit" name="status" class="btn btn-danger createdGateway update-gateway" value="deactivateGateway">Deactivate Gateway</button> + <button type="submit" name="status" class="btn btn-primary update-gateway notApprovedGateway" value="approveRequest" >Approve Request</button> + <button type="submit" name="status" class="btn btn-danger update-gateway notApprovedGateway" value="denyRequest" >Deny Request</button> + <button type="submit" name="status" class="btn btn-primary update-gateway approvedGateway" value="updateGateway" >Update Gateway</button> + <button type="submit" name="status" class="btn btn-primary update-gateway approvedGateway" value="createTenant" >Create Tenant</button> + <button type="submit" name="status" class="btn btn-primary update-gateway createdGateway" value="deployGateway" >Deploy Gateway</button> + <button type="submit" name="status" class="btn btn-danger update-gateway createdGateway" value="deactivateGateway" >Deactivate Gateway</button> </div> </form> @@ -500,16 +512,16 @@ }); - $(".add-tenant").slideUp(); + /*$(".add-tenant").slideUp(); $(".toggle-add-tenant").click(function () { $('html, body').animate({ scrollTop: $(".toggle-add-tenant").offset().top }, 500); $(".add-tenant").slideDown(); - }); + });*/ - $("#add-tenant-form").submit(function (event) { + /*$("#add-tenant-form").submit(function (event) { event.preventDefault(); event.stopPropagation(); var formData = $("#add-tenant-form").serialize(); @@ -547,7 +559,7 @@ $("#add-gateway-loading").modal("hide"); $(".loading-gif").addClass("hide"); }); - }); + });*/ disableInputs( $(".super-admin-gateways-view")); @@ -599,25 +611,130 @@ editableInputs( $("#update-gateway-request"), true); if( gatewayApprovalStatuses[ gatewayObject.gatewayApprovalStatus] == "REQUESTED"){ - $(".createdGateway").each( function( i, thisButton){ - if( $(thisButton).val() == "deactivateGateway"){ + $(".approvedGateway").each(function (i, thisButton) { + if ($(thisButton).val() == "updateGateway") { + $(thisButton).addClass("hide"); + } + if ($(thisButton).val() == "createTenant") { + $(thisButton).addClass("hide"); + } + }); + $(".createdGateway").each(function (i, thisButton) { + if ($(thisButton).val() == "deployGateway") { + $(thisButton).addClass("hide"); + } + if ($(thisButton).val() == "deactivateGateway") { + $(thisButton).addClass("hide"); + } + }); + $(".notApprovedGateway").removeClass("hide"); { + $('#emailAddress').attr('readonly', false); + $('#gatewayURL').attr('readonly', false); + $('#identityServerUserName').attr('readonly', false); + $('#gatewayAdminFirstName').attr('readonly', false); + $('#gatewayAdminLastName').attr('readonly', false); + $('#gatewayAdminEmail').attr('readonly', false); + $('#gatewayPublicAbstract').attr('readonly', false); + $('#reviewProposalDescription').attr('readonly', false); + } + } + else if( gatewayApprovalStatuses[ gatewayObject.gatewayApprovalStatus] == "APPROVED"){ + $(".notApprovedGateway").each(function (i, thisButton) { + if ($(thisButton).val() == "approveRequest") { + $(thisButton).addClass("hide"); + } + if ($(thisButton).val() == "denyRequest") { $(thisButton).addClass("hide"); } }); - $(".notCreatedGateway").removeClass("hide"); + $(".createdGateway").each(function (i, thisButton) { + if ($(thisButton).val() == "deployGateway") { + $(thisButton).addClass("hide"); + } + if ($(thisButton).val() == "deactivateGateway") { + $(thisButton).addClass("hide"); + } + }); + $(".approvedGateway").removeClass("hide"); { + $('#emailAddress').attr('readonly', false); + $('#gatewayURL').attr('readonly', false); + $('#identityServerUserName').attr('readonly', false); + $('#gatewayAdminFirstName').attr('readonly', false); + $('#gatewayAdminLastName').attr('readonly', false); + $('#gatewayAdminEmail').attr('readonly', false); + $('#gatewayPublicAbstract').attr('readonly', false); + $('#reviewProposalDescription').attr('readonly', false); + } + } + else if( gatewayApprovalStatuses[ gatewayObject.gatewayApprovalStatus] == "CREATED"){ + $(".approvedGateway").each(function (i, thisButton) { + if ($(thisButton).val() == "updateGateway") { + $(thisButton).addClass("hide"); + } + if ($(thisButton).val() == "createTenant") { + $(thisButton).addClass("hide"); + } + }); + $(".notApprovedGateway").each(function (i, thisButton) { + if ($(thisButton).val() == "approveRequest") { + $(thisButton).addClass("hide"); + } + if ($(thisButton).val() == "denyRequest") { + $(thisButton).addClass("hide"); + } + }); + $(".createdGateway").removeClass("hide"); { + $('#emailAddress').attr('readonly', true); + $('#gatewayURL').attr('readonly', true); + $('#identityServerUserName').attr('readonly', true); + $('#gatewayAdminFirstName').attr('readonly', true); + $('#gatewayAdminLastName').attr('readonly', true); + $('#gatewayAdminEmail').attr('readonly', true); + $('#gatewayPublicAbstract').attr('readonly', true); + $('#reviewProposalDescription').attr('readonly', true); + } + } + else if( gatewayApprovalStatuses[ gatewayObject.gatewayApprovalStatus] == "DEPLOYED"){ + $(".notApprovedGateway").each(function (i, thisButton) { + if ($(thisButton).val() == "approveRequest") { + $(thisButton).addClass("hide"); + } + if ($(thisButton).val() == "denyRequest") { + $(thisButton).addClass("hide"); + } + }); + $(".approvedGateway").each(function (i, thisButton) { + if ($(thisButton).val() == "updateGateway") { + $(thisButton).addClass("hide"); + } + if ($(thisButton).val() == "createTenant") { + $(thisButton).addClass("hide"); + } + }); + $(".createdGateway").each(function (i, thisButton) { + if ($(thisButton).val() == "deployGateway") { + $(thisButton).addClass("hide"); + } + if ($(thisButton).val() == "deactivateGateway") { + $(thisButton).removeClass("hide"); + } + $('#emailAddress').attr('readonly', true); + $('#gatewayURL').attr('readonly', true); + $('#identityServerUserName').attr('readonly', true); + $('#gatewayAdminFirstName').attr('readonly', true); + $('#gatewayAdminLastName').attr('readonly', true); + $('#gatewayAdminEmail').attr('readonly', true); + $('#gatewayPublicAbstract').attr('readonly', true); + $('#reviewProposalDescription').attr('readonly', true); + }); } else if( gatewayApprovalStatuses[ gatewayObject.gatewayApprovalStatus] == "CANCELLED" || gatewayApprovalStatuses[ gatewayObject.gatewayApprovalStatus] == "DENIED" || gatewayApprovalStatuses[ gatewayObject.gatewayApprovalStatus] == "DEACTIVATED"){ - + editableInputs( $("#update-gateway-request"), false); $(".update-gateway-request-close-modal").removeAttr("disabled"); } - else - { - $(".createdGateway").removeClass("hide"); - $(".notCreatedGateway").addClass("hide"); - } $("#approve-gateway").modal("show"); }); @@ -648,7 +765,7 @@ 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."); + $(".submit-actions").before("<div class='alert alert-danger fail-alert'>All fields are required to create the gateway! Please make sure you've first updated all the Gateway details accurately. Try again or contact admin to report the issue."); } else{ $(".submit-actions").before("<div class='alert alert-danger fail-alert'>Error updating Gateway. Please try again."); @@ -656,7 +773,7 @@ } else{ if( updateVal == "createTenant"){ - $(".submit-actions").before("<div class='alert alert-success success-alert'>Tenant has been created with domain name- airavata." + $(".gatewayAcronym").val()); + $(".submit-actions").before("<div class='alert alert-success success-alert'>Tenant has been created!"); $(".notCreatedGateway").addClass("hide"); $(".createdGateway").removeClass("hide");