You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by nd...@apache.org on 2016/04/19 20:14:54 UTC
[2/3] airavata-php-gateway git commit: Addition of Notice Management
to Admin Dashboard UI
Addition of Notice Management to Admin Dashboard 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/41c31b3c
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/41c31b3c
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/41c31b3c
Branch: refs/heads/develop
Commit: 41c31b3c443c5a52b0f9ef9804a69834b180cd95
Parents: 89ca51a
Author: Nipurn Doshi <ni...@gmail.com>
Authored: Tue Apr 19 14:14:17 2016 -0400
Committer: Nipurn Doshi <ni...@gmail.com>
Committed: Tue Apr 19 14:14:17 2016 -0400
----------------------------------------------------------------------
app/controllers/AdminController.php | 11 +-
app/libraries/AdminUtilities.php | 4 +
app/routes.php | 2 +
app/views/admin/manage-notices.blade.php | 244 ++++++++++++++++++++++
app/views/partials/dashboard-block.blade.php | 5 +
5 files changed, 264 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/41c31b3c/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index 1d7b39c..d6de6bd 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -183,6 +183,13 @@ class AdminController extends BaseController {
return View::make("admin/manage-credentials", array("tokens" => $tokens ) );
}
+ public function noticesView(){
+ Session::put("admin-nav", "notices");
+ $notices = array();
+ //$notices = AdminUtilities::getNotices();
+ return View::make("admin/manage-notices", array("notices" => $notices));
+ }
+
public function updateUserRoles(){
if( Input::has("add")){
WSIS::updateUserRoles(Input::get("username"), array("new"=> Input::get("roles"), "deleted" => array() ) );
@@ -299,13 +306,13 @@ class AdminController extends BaseController {
$rules = array(
"username" => "required|min:6",
- "password" => "required|min:6|max:48|regex:/^.*(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[@!$#%*]).*$/",
+ "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 - !@#$%&*',
+ '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();
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/41c31b3c/app/libraries/AdminUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php
index 0c8e195..52e2123 100644
--- a/app/libraries/AdminUtilities.php
+++ b/app/libraries/AdminUtilities.php
@@ -109,4 +109,8 @@ class AdminUtilities
'<p>Airavata System Exception: ' . $ase->getMessage() . '</p>');
}
}
+
+ public static function get_notices(){
+ return Airavata::getNotices( Session::get('authz-token'), $token, Session::get("gateway_id"));
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/41c31b3c/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index ac4c5a8..01b0adc 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -253,6 +253,8 @@ Route::get("admin/dashboard/experiment/summary", function () {
Route::get("admin/dashboard/credential-store", "AdminController@credentialStoreView");
+Route::get("admin/dashboard/notices", "AdminController@noticesView");
+
Route::get("manage/users", "AdminController@usersView");
Route::post("admin/adduser", "AdminController@addAdminSubmit");
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/41c31b3c/app/views/admin/manage-notices.blade.php
----------------------------------------------------------------------
diff --git a/app/views/admin/manage-notices.blade.php b/app/views/admin/manage-notices.blade.php
new file mode 100644
index 0000000..bc9fdd7
--- /dev/null
+++ b/app/views/admin/manage-notices.blade.php
@@ -0,0 +1,244 @@
+@extends('layout.basic')
+
+@section('page-header')
+@parent
+{{ HTML::style('css/admin.css')}}
+@stop
+
+@section('content')
+
+<div id="wrapper">
+ <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
+ @include( 'partials/dashboard-block')
+ <div id="page-wrapper">
+
+ <div class="container-fluid">
+ <div class="col-md-12">
+ @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
+
+ <h1 class="text-center">Notices</h1>
+ <hr/>
+ @if(Session::has("admin"))
+ <div class="col-md-12">
+ <form class="form-horizontal">
+ <h4 class="text-center">Create a new Notice</h4>
+ <div class="form-group required">
+ <label class="control-label col-md-3">Notice Message</label>
+
+ <div class="col-md-6">
+ <textarea type="text" class="form-control" name=""></textarea>
+ </div>
+ </div>
+ <div class='form-group required'>
+ <label class="col-md-3 control-label">Publish date</label>
+ <div class='input-group date col-md-4' id='datetimepicker9'>
+ <input type='text' class="form-control" placeholder="From Date" name="from-date"/>
+ <span class="input-group-addon">
+ <span class="glyphicon glyphicon-calendar"></span>
+ </span>
+ </div>
+ </div>
+ <div class='form-group required'>
+ <label class="col-md-3 control-label">Expiration Date</label>
+ <div class='input-group date col-md-4' id='datetimepicker9'>
+ <input type='text' class="form-control" placeholder="To Date" name="to-date"/>
+ <span class="input-group-addon">
+ <span class="glyphicon glyphicon-calendar"></span>
+ </span>
+ </div>
+ </div>
+
+ <div class="form-group required">
+ <label class="col-md-3 control-label">Priority</label>
+ <div class="col-md-6">
+ <select class="form-control">
+ <option>Low</option>
+ <option>Normal</option>
+ <option>Hight</option>
+ </select>
+ </div>
+ </div>
+ <div class="form-group">
+ <div class=" col-md-offset-3 col-md-3">
+ <button type="submit" class="btn btn-primary form-control" value="Submit">Submit</button>
+ </div>
+ </div>
+ </form>
+ <hr/>
+ </div>
+ <div class="loading-img text-center hide">
+ <img src="../../assets/ajax-loader.gif"/>
+ </div>
+ @endif
+ <h4 class="text-center">Existing Notices</h4>
+ <table class="table table-bordered table-striped table-condensed" style="word-wrap: break-word;">
+ <tr>
+ <th>Notice</th>
+ <th>Publish Date</th>
+ <th>Expiry Date</th>
+ <th>Priority</th>
+ <th>Edit</th>
+ <th>Delete</th>
+ </tr>
+ <tbody class="token-values">
+ @foreach( $notices as $index => $notice)
+ <tr>
+ <td class="">
+ {{ $notice->text }}
+ </td>
+ <td>
+ {{ $notice->publish_date }}
+ </td>
+ <td>
+ {{ $notice->expiry_date }}
+ </td>
+ <td>
+ {{ $notice->priority }}
+ </td>
+ @if( Session::has("admin"))
+ <td>
+ <span data-token="{{$token}}" class="glyphicon glyphicon-pencil"></span>
+ </td>
+ @endif
+ @if( Session::has("admin"))
+ <td>
+ <span data-token="{{$token}}" class="glyphicon glyphicon-trash"></span>
+ </td>
+ @endif
+ </tr>
+ @endforeach
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+</div>
+
+<div class="modal fade" id="delete-role-block" tabindex="-1" role="dialog" aria-labelledby="add-modal"
+ aria-hidden="true">
+ <div class="modal-dialog">
+
+ <form action="{{URL::to('/')}}/admin/deleterole" method="POST">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h3 class="text-center">Delete Role Confirmation</h3>
+ </div>
+ <div class="modal-body">
+ <input type="hidden" class="form-control delete-roleName" name="role"/>
+ Do you really want to delete the role - <span class="delete-role-name"></span>
+ </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>
+
+
+<!-- Remove a Compute Resource from a Gateway -->
+<div class="modal fade" id="remove-token-block" tabindex="-1" role="dialog" aria-labelledby="add-modal"
+ aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h3 class="text-center">Remove SSH Key Confirmation</h3>
+ </div>
+ <div class="modal-body">
+ <input type="hidden" class="form-control remove-crId" name="rem-crId"/>
+ <input type="hidden" class="form-control cr-gpId" name="gpId"/>
+
+ Are you sure, you want to remove the SSH Key?<span class="remove-token-name"> </span>
+ </div>
+ <div class="modal-footer">
+ <div class="form-group">
+ <input type="submit" class="btn btn-danger" value="Remove"/>
+ <input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel"/>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+
+@stop
+
+@section('scripts')
+@parent
+<script>
+ $(".generate-ssh").click( function(){
+ $(".loading-img").removeClass("hide");
+ $.ajax({
+ type: "POST",
+ url: "{{URL::to('/')}}/admin/create-ssh-token"
+ }).success( function( data){
+
+ var tokenJson = data;
+
+ //$(".token-values").html("");
+ $(".generate-ssh").after("<div class='alert alert-success new-token-msg'>New Token has been generated.</div>");
+
+ $(".token-values").prepend("<tr class='alert alert-success'><td>" + tokenJson.token + "</td><td class='public-key'>" + tokenJson.pubkey + "</td>" + "<td><a href=''><span data-token='"+tokenJson.token+"' class='glyphicon glyphicon-trash remove-token'></span></a></td></<tr>");
+ $(".loading-img").addClass("hide");
+
+ setInterval( function(){
+ $(".new-token-msg").fadeOut();
+ }, 3000);
+ }).fail( function( data){
+ $(".loading-img").addClass("hide");
+
+ failureObject = $.parseJSON( data.responseText);
+ $(".generate-ssh").after("<div class='alert alert-danger'>" + failureObject.error.message + "</div>");
+ });
+ });
+
+ $(".remove-token").click( function(){
+ var removeSpan = $(this);
+ var tr = removeSpan.parent().parent();
+ var tokenToRemove = removeSpan.data("token");
+ var publicKey = tr.children(".public-key").html();
+ tr.children(".public-key").html("<div class='alert alert-danger'>Do you really want to remove the token? This action cannot be undone.<br/>" +
+ "<span class='btn-group'>"+
+ "<input type='button' class='btn btn-default remove-token-confirmation' value='Yes'/>" +
+ "<input type='button' class='btn btn-default remove-token-cancel' value='Cancel'/>"+
+ "</span></div>");
+
+
+ tr.find( ".remove-token-confirmation").click( function(){
+ $(".loading-img").removeClass("hide");
+ $.ajax({
+ type: "POST",
+ data:{ "token" : tokenToRemove},
+ url: "{{URL::to('/')}}/admin/remove-ssh-token"
+ }).success( function( data){
+ if( data.responseText == 1)
+ tr.addClass("alert").addClass("alert-danger");
+ tr.fadeOut(1000);
+ }).fail( function( data){
+ tr.after("<tr class='alert alert-danger'><td></td><td>Error occurred : " + $.parseJSON( data.responseText).error.message + "</td><td></td></tr>");
+ }).complete( function(){
+ $(".loading-img").addClass("hide");
+
+ });
+ });
+ tr.find( ".remove-token-cancel").click( function(){
+ tr.children(".public-key").html( publicKey);
+ });
+
+ });
+</script>
+@stop
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/41c31b3c/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 12b63d9..8fd1758 100644
--- a/app/views/partials/dashboard-block.blade.php
+++ b/app/views/partials/dashboard-block.blade.php
@@ -87,6 +87,11 @@
<a class="dashboard-link" href="{{ URL::to('/')}}/admin/dashboard/credential-store"><span class="glyphicon glyphicon-lock"></span> Credential
Store</a>
</li>
+ <li
+ @if( Session::has("admin-nav") && Session::get("admin-nav") == "notices") class="active" @endif>
+ <a class="dashboard-link" href="{{ URL::to('/')}}/admin/dashboard/notices">
+ <span class="glyphicon glyphicon-bell"></span> Notices</a>
+ </li>
<!-- <li>-->
<!-- <a href="forms.html"><i class="fa fa-fw fa-edit"></i> Settings</a>-->
<!-- </li>-->