AIRAVATA-2156 Basic first credential store UI For now just displaying the default credential store SSH public key to the user.
Also added management of user resources to the user dashboard and the beginnings of a compute resources view. 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/0b8d5f22 Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/0b8d5f22 Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/0b8d5f22 Branch: refs/heads/develop Commit: 0b8d5f22f000f1820e7b68464ec3e065ccd647cc Parents: 06ede1d Author: Marcus Christie <[email protected]> Authored: Wed Oct 12 09:50:21 2016 -0400 Committer: Marcus Christie <[email protected]> Committed: Thu Oct 20 10:21:42 2016 -0400 ---------------------------------------------------------------------- app/controllers/AccountController.php | 23 ++++++++++++ app/libraries/URPUtilities.php | 42 ++++++++++++++++++++++ app/routes.php | 5 +++ app/views/account/compute-resources.blade.php | 17 +++++++++ app/views/account/credential-store.blade.php | 37 +++++++++++++++++++ app/views/account/dashboard.blade.php | 39 ++++++++++++++++++++ 6 files changed, 163 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/0b8d5f22/app/controllers/AccountController.php ---------------------------------------------------------------------- diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index ddcecef..9295f66 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -467,4 +467,27 @@ class AccountController extends BaseController Session::put("notice-seen", true); } + public function getCredentialStore() { + + $userResourceProfile = URPUtilities::get_or_create_user_resource_profile(); + $publicKey = AdminUtilities::get_pubkey_from_token($userResourceProfile->credentialStoreToken); + + return View::make("account/credential-store", array( + "token" => $userResourceProfile->credentialStoreToken, + "publicKey" => $publicKey + )); + } + + public function getComputeResources(){ + $userResourceProfile = URPUtilities::get_or_create_user_resource_profile(); + return View::make("account/compute-resources", array( + "userResourceProfile" => $userResourceProfile + )); + } + + // TODO: Only used for testing, remove + public function deleteUserResourceProfile(){ + URPUtilities::delete_user_resource_profile(); + return Redirect::to("account/dashboard"); + } } http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/0b8d5f22/app/libraries/URPUtilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/URPUtilities.php b/app/libraries/URPUtilities.php new file mode 100644 index 0000000..435c643 --- /dev/null +++ b/app/libraries/URPUtilities.php @@ -0,0 +1,42 @@ +<?php + +use Airavata\API\Error\AiravataSystemException; +use Airavata\Model\AppCatalog\UserResourceProfile\UserResourceProfile; + +class URPUtilities +{ + + public static function get_or_create_user_resource_profile() + { + $userId = Session::get('username'); + $gatewayId = Session::get('gateway_id'); + try { + return Airavata::getUserResourceProfile(Session::get('authz-token'), $userId, $gatewayId); + } catch (AiravataSystemException $ase) { + // TODO: replace try/catch with null check once backend is updated, see AIRAVATA-2117 + // Assume that exception was thrown because there is no UserResourceProfile + + // Create a minimal UserResourceProfile with an SSH credential store token + $credentialStoreToken = AdminUtilities::create_ssh_token(); + $userResourceProfileData = new UserResourceProfile(array( + "userId" => $userId, + "gatewayID" => $gatewayId, + "" => $credentialStoreToken + ) + ); + Airavata::registerUserResourceProfile(Session::get('authz-token'), $userResourceProfileData); + + return Airavata::getUserResourceProfile(Session::get('authz-token'), $userId, $gatewayId); + } + } + + // Only used for testing + public static function delete_user_resource_profile() + { + $userId = Session::get('username'); + $gatewayId = Session::get('gateway_id'); + Airavata::deleteUserResourceProfile(Session::get('authz-token'), $userId, $gatewayId); + } +} + +?> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/0b8d5f22/app/routes.php ---------------------------------------------------------------------- diff --git a/app/routes.php b/app/routes.php index b1ad089..bb3025e 100755 --- a/app/routes.php +++ b/app/routes.php @@ -48,6 +48,11 @@ Route::get("allocation-request", "AccountController@allocationRequestView"); Route::post("allocation-request", "AccountController@allocationRequestSubmit"); +Route::get("account/credential-store", "AccountController@getCredentialStore"); +Route::get("account/computeResources", "AccountController@getComputeResources"); +// TODO: just for testing +Route::get("account/deleteURP", "AccountController@deleteUserResourceProfile"); + /* * The following routes will not work without logging in. * http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/0b8d5f22/app/views/account/compute-resources.blade.php ---------------------------------------------------------------------- diff --git a/app/views/account/compute-resources.blade.php b/app/views/account/compute-resources.blade.php new file mode 100644 index 0000000..89d64a8 --- /dev/null +++ b/app/views/account/compute-resources.blade.php @@ -0,0 +1,17 @@ +@extends('layout.basic') + +@section('page-header') +@parent +@stop + +@section('content') +<div class="container"> +{{var_dump($userResourceProfile)}} +</div> + +@stop + +@section('scripts') +@parent +<script></script> +@stop \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/0b8d5f22/app/views/account/credential-store.blade.php ---------------------------------------------------------------------- diff --git a/app/views/account/credential-store.blade.php b/app/views/account/credential-store.blade.php new file mode 100644 index 0000000..71f76fa --- /dev/null +++ b/app/views/account/credential-store.blade.php @@ -0,0 +1,37 @@ +@extends('layout.basic') + +@section('page-header') +@parent +@stop + +@section('content') +<div class="container"> + <h1>SSH Keys</h1> + <h2>Default SSH Key</h2> + + <table class="table table-bordered table-condensed" style="word-wrap: break-word; table-layout: fixed; width: 100%;"> + <thead> + <tr> + <th>Token</th> + <th>Public Key</th> + </tr> + </thead> + <tbody> + <tr> + <td> + {{ $token }} + </td> + <td> + {{ $publicKey }} + </td> + </tr> + </tbody> + </table> +</div> + +@stop + +@section('scripts') +@parent +<script></script> +@stop \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/0b8d5f22/app/views/account/dashboard.blade.php ---------------------------------------------------------------------- diff --git a/app/views/account/dashboard.blade.php b/app/views/account/dashboard.blade.php index b701ca3..c7d0e93 100644 --- a/app/views/account/dashboard.blade.php +++ b/app/views/account/dashboard.blade.php @@ -383,6 +383,45 @@ </div> </div> </a> + @else + + <div class="row well"> + + <h3>Manage Personal Computing and Storage Resources</h3> + + <a href="{{URL::to('/')}}/account/computeResources"> + <div class=" col-md-4 well"> + <div class="col-md-12"> + <span class="glyphicon glyphicon-briefcase console-icon"></span> + </div> + <div class="col-md-12"> + <h4>Compute Resources</h4> + </div> + </div> + </a> + + <a href="{{URL::to('/')}}/account/storageResources"> + <div class=" col-md-4 well"> + <div class="col-md-12"> + <span class="glyphicon glyphicon-folder-open console-icon"></span> + </div> + <div class="col-md-12"> + <h4>Storage Resources</h4> + </div> + </div> + </a> + + <a href="{{URL::to('/')}}/account/credential-store"> + <div class=" col-md-4 well"> + <div class="col-md-12"> + <span class="glyphicon glyphicon-lock console-icon"></span> + </div> + <div class="col-md-12"> + <h4>Credential Store</h4> + </div> + </div> + </a> + @endif
