AIRAVATA-2156 Delete credential option added to UI
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/cd045ecf Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/cd045ecf Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/cd045ecf Branch: refs/heads/develop Commit: cd045ecf8f13526e19e7914df808587262d08747 Parents: 2685fa8 Author: Marcus Christie <[email protected]> Authored: Wed Oct 26 10:06:21 2016 -0400 Committer: Marcus Christie <[email protected]> Committed: Wed Oct 26 11:22:27 2016 -0400 ---------------------------------------------------------------------- app/controllers/AccountController.php | 15 ++++++-- app/routes.php | 1 + app/views/account/credential-store.blade.php | 43 ++++++++++++++++++++++- 3 files changed, 56 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/cd045ecf/app/controllers/AccountController.php ---------------------------------------------------------------------- diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index e93318e..6ac13f3 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -148,7 +148,7 @@ class AccountController extends BaseController CommonUtilities::store_id_in_session($username); Session::put("gateway_id", Config::get('pga_config.airavata')['gateway-id']); - if(Session::has("admin") || Session::has("admin-read-only") || Session::has("authorized-user")){ + if(Session::has("admin") || Session::has("admin-read-only") || Session::has("authorized-user")){ return $this->initializeWithAiravata($username); } @@ -489,11 +489,22 @@ class AccountController extends BaseController URPUtilities::update_user_resource_profile($userResourceProfile); $credentialSummaryMap = $this->create_credential_summary_map(URPUtilities::get_all_ssh_pub_keys_summary_for_user()); - $description = $credentialSummaryMap["$defaultToken"]["description"]; + $description = $credentialSummaryMap[$defaultToken]["description"]; return Redirect::to("account/credential-store")->with("message", "SSH Key '$description' is now the default"); } + public function deleteCredential() { + + $credentialStoreToken = Input::get("credentialStoreToken"); + $credentialSummaryMap = $this->create_credential_summary_map(URPUtilities::get_all_ssh_pub_keys_summary_for_user()); + $description = $credentialSummaryMap[$credentialStoreToken]["description"]; + + if (AdminUtilities::remove_ssh_token($credentialStoreToken)) { + return Redirect::to("account/credential-store")->with("message", "SSH Key '$description' is was deleted"); + } + } + private function create_credential_summary_map($credentialSummaries) { $credentialSummaryMap = array(); http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/cd045ecf/app/routes.php ---------------------------------------------------------------------- diff --git a/app/routes.php b/app/routes.php index 3fd11e6..a81816f 100755 --- a/app/routes.php +++ b/app/routes.php @@ -50,6 +50,7 @@ Route::post("allocation-request", "AccountController@allocationRequestSubmit"); Route::get("account/credential-store", "AccountController@getCredentialStore"); Route::post("account/set-default-credential", "AccountController@setDefaultCredential"); +Route::post("account/delete-credential", "AccountController@deleteCredential"); Route::get("account/computeResources", "AccountController@getComputeResources"); // TODO: just for testing http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/cd045ecf/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 index 58666b0..20eadcd 100644 --- a/app/views/account/credential-store.blade.php +++ b/app/views/account/credential-store.blade.php @@ -38,6 +38,7 @@ <tr> <th>Description</th> <th>Public Key</th> + <th>Delete</th> </tr> </thead> <tbody> @@ -49,15 +50,55 @@ <td> {{ $credentialSummary["publicKey"] }} </td> + <td> + <span data-token="{{$credentialSummary["credentialStoreToken"]}}" + data-description="{{$credentialSummary["description"]}}" + class="glyphicon glyphicon-trash delete-credential"></span> + </td> </tr> @endforeach </tbody> </table> </div> +<div class="modal fade" id="delete-credential-modal" tabindex="-1" role="dialog" aria-labelledby="delete-credential-modal-title" + aria-hidden="true"> + <div class="modal-dialog"> + + <form action="{{URL::to('/')}}/account/delete-credential" method="POST"> + <div class="modal-content"> + <div class="modal-header"> + <h3 class="text-center" id="delete-credential-modal-title">Delete SSH Public Key</h3> + </div> + <div class="modal-body"> + <input type="hidden" class="form-control" name="credentialStoreToken"/> + + Do you really want to delete the <span class="credential-description"></span> SSH public key? + </div> + <div class="modal-footer"> + <div class="form-group"> + <input type="submit" class="btn btn-danger" value="Delete"/> + <input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel"/> + </div> + </div> + </div> + + </form> + </div> +</div> @stop @section('scripts') @parent -<script></script> +<script> +$('.delete-credential').on('click', function(){ + + var credentialStoreToken = $(this).data('token'); + var credentialDescription = $(this).data('description'); + + $("#delete-credential-modal input[name=credentialStoreToken]").val(credentialStoreToken); + $("#delete-credential-modal .credential-description").text(credentialDescription); + $("#delete-credential-modal").modal("show"); +}); +</script> @stop \ No newline at end of file
