about summary refs log tree commit diff
path: root/gn2/wqflask/templates/oauth2
diff options
context:
space:
mode:
Diffstat (limited to 'gn2/wqflask/templates/oauth2')
-rw-r--r--gn2/wqflask/templates/oauth2/confirm-resource-role-unassign-privilege.html34
-rw-r--r--gn2/wqflask/templates/oauth2/create-role.html42
-rw-r--r--gn2/wqflask/templates/oauth2/data-list-mrna.html2
-rw-r--r--gn2/wqflask/templates/oauth2/data-list-phenotype.html3
-rw-r--r--gn2/wqflask/templates/oauth2/profile_nav.html7
-rw-r--r--gn2/wqflask/templates/oauth2/view-group-role.html102
-rw-r--r--gn2/wqflask/templates/oauth2/view-resource-role.html149
-rw-r--r--gn2/wqflask/templates/oauth2/view-resource.html56
8 files changed, 253 insertions, 142 deletions
diff --git a/gn2/wqflask/templates/oauth2/confirm-resource-role-unassign-privilege.html b/gn2/wqflask/templates/oauth2/confirm-resource-role-unassign-privilege.html
new file mode 100644
index 00000000..988cf3b4
--- /dev/null
+++ b/gn2/wqflask/templates/oauth2/confirm-resource-role-unassign-privilege.html
@@ -0,0 +1,34 @@
+{%extends "base.html"%}
+{%from "oauth2/profile_nav.html" import profile_nav%}
+{%from "oauth2/display_error.html" import display_error%}
+{%block title%}View User{%endblock%}
+{%block content%}
+<div class="container">
+  {{profile_nav(uipages, user_privileges)}}
+  {{flash_me()}}
+
+  <form id="frm_confirm_resource_role_unassign_privilege"
+        method="POST"
+        action="{{url_for('oauth2.resource.unassign_privilege_from_resource_role',
+                resource_id=resource.resource_id,
+                role_id=role.role_id)}}">
+    <p>
+      Are you sure you want to unassign the privilege to
+      '{{privilege.privilege_description}}' from the role '{{role.role_name}}'
+      on resource '{{resource.resource_name}}'?</p>
+    <input type="hidden"
+           name="privilege_id"
+           value="{{privilege.privilege_id}}" />
+    
+    <input type="submit"
+           name="confirm"
+           value="Cancel"
+           class="btn btn-success" />
+
+    <input type="submit"
+           name="confirm"
+           value="Unassign"
+           class="btn btn-danger" />
+  </form>
+</div>
+{%endblock%}
diff --git a/gn2/wqflask/templates/oauth2/create-role.html b/gn2/wqflask/templates/oauth2/create-role.html
index f2bff7b4..6cf0bb78 100644
--- a/gn2/wqflask/templates/oauth2/create-role.html
+++ b/gn2/wqflask/templates/oauth2/create-role.html
@@ -7,31 +7,43 @@
   {{profile_nav("roles", user_privileges)}}
   <h3>Create Role</h3>
 
-  {{flash_me()}}
+  <p>Create a new role to act on resource "{{resource.resource_name}}"</p>
 
-  {%if group_privileges_error is defined%}
-  {{display_error("Group Privileges", group_privileges_error)}}
+  {%if resource_role_error is defined%}
+  {{display_error("Resource Role", resource_role_error)}}
   {%else%}
-  {%if "group:role:create-role" in user_privileges%}
-  <form method="POST" action="{{url_for('oauth2.role.create_role')}}">
-    <legend>Create Group Role</legend>
+  {%if "resource:role:create-role" in (user_privileges|map(attribute="privilege_id")) %}
+  <form method="POST" action="{{url_for('oauth2.resource.create_resource_role',
+                              resource_id=resource.resource_id)}}">
+    <legend>create resource role</legend>
+
+    {{flash_me()}}
+
     <div class="form-group">
       <label for="role_name" class="form-label">Name</label>
-      <input type="text" id="role_name" name="role_name" required="required"
-	     class="form-control"
-	     {%if prev_role_name is defined and prev_role_name is not none%}
-	     value="{{prev_role_name}}"
-	     {%endif%} />
+      <div class="input-group">
+        <span class="input-group-addon">
+          {{resource.resource_name|replace(" ", "_")}}::
+        </span>
+        <input type="text" id="role_name" name="role_name" required="required"
+	       class="form-control"
+	       {%if prev_role_name is defined and prev_role_name is not none%}
+	       value="{{prev_role_name}}"
+	       {%endif%} />
+      </div>
+      <span class="form-text text-muted">
+        The name of the role will have the resource's name appended.
+      </span>
     </div>
     <label class="form-label">Privileges</label>
-    {%for priv in group_privileges%}
+    {%for priv in user_privileges%}
     <div class="checkbox">
-      <label for="chk:{{priv.privilege_id}}">
-	<input type="checkbox" id="chk:{{priv.privilege_id}}"
+      <label for="chk-{{priv.privilege_id}}">
+	<input type="checkbox" id="chk-{{priv.privilege_id}}"
 	       name="privileges[]" value={{priv.privilege_id}} />
 	<span style="text-transform: capitalize;">
 	  {{priv.privilege_description}}
-	</span> ({{priv.privilege_id}})
+	</span>
       </label>
     </div>
     {%endfor%}
diff --git a/gn2/wqflask/templates/oauth2/data-list-mrna.html b/gn2/wqflask/templates/oauth2/data-list-mrna.html
index 728e95d4..c5c1c27e 100644
--- a/gn2/wqflask/templates/oauth2/data-list-mrna.html
+++ b/gn2/wqflask/templates/oauth2/data-list-mrna.html
@@ -92,7 +92,7 @@
   <div class="row">
     <span id="search-messages" class="alert-danger" style="display:none"></span>
     <form id="frm-search"
-	  action="{{search_uri}}"
+	  action="{{url_for('oauth2.data.json_search_mrna')}}"
 	  method="POST">
       <legend>Search: mRNA Assay</legend>
       <input type="hidden" value="{{species_name}}" name="species"
diff --git a/gn2/wqflask/templates/oauth2/data-list-phenotype.html b/gn2/wqflask/templates/oauth2/data-list-phenotype.html
index e5172c70..d355f3f9 100644
--- a/gn2/wqflask/templates/oauth2/data-list-phenotype.html
+++ b/gn2/wqflask/templates/oauth2/data-list-phenotype.html
@@ -113,7 +113,8 @@
     <form id="frm-search-traits"
 	  action="#"
 	  method="POST"
-	  data-gn-server-url="{{gn_server_url}}">
+          data-search-endpoint="{{search_endpoint}}"
+          data-pheno-results-template="{{pheno_results_template}}">
       {%if dataset_type == "mrna"%}
       <legend>mRNA: Search</legend>
       {%else%}
diff --git a/gn2/wqflask/templates/oauth2/profile_nav.html b/gn2/wqflask/templates/oauth2/profile_nav.html
index aa752905..c79bccbc 100644
--- a/gn2/wqflask/templates/oauth2/profile_nav.html
+++ b/gn2/wqflask/templates/oauth2/profile_nav.html
@@ -17,13 +17,6 @@
   </li>
 
   <li role="presentation"
-      {%if calling_page == "roles"%}
-      class="active"
-      {%endif%}>
-    <a href="{{url_for('oauth2.role.user_roles')}}">Roles</a>
-  </li>
-
-  <li role="presentation"
       {%if calling_page == "resources"%}
       class="active"
       {%endif%}>
diff --git a/gn2/wqflask/templates/oauth2/view-group-role.html b/gn2/wqflask/templates/oauth2/view-group-role.html
deleted file mode 100644
index 5da023bf..00000000
--- a/gn2/wqflask/templates/oauth2/view-group-role.html
+++ /dev/null
@@ -1,102 +0,0 @@
-{%extends "base.html"%}
-{%from "oauth2/profile_nav.html" import profile_nav%}
-{%from "oauth2/display_error.html" import display_error%}
-{%block title%}View User{%endblock%}
-{%block content%}
-<div class="container" style="min-width: 1250px;">
-  {{profile_nav("roles", user_privileges)}}
-  <h3>View Group Role</h3>
-
-  {{flash_me()}}
-
-  <div class="container-fluid">
-    <div class="row">
-      <h3>Role Details</h3>
-      {%if group_role_error is defined%}
-      {{display_error("Group Role", group_role_error)}}
-      {%else%}
-      <table class="table">
-	<caption>Details for '{{group_role.role.role_name}}' Role</caption>
-	<thead>
-	  <tr>
-	    <th>Privilege</th>
-	    <th>Description</th>
-	    <th>Action</th>
-	  </tr>
-	</thead>
-	<tbody>
-	  {%for privilege in group_role.role.privileges%}
-	  <tr>
-	    <td>{{privilege.privilege_id}}</td>
-	    <td>{{privilege.privilege_description}}</td>
-	    <td>
-	      <form action="{{url_for(
-			    'oauth2.group.delete_privilege_from_role',
-			    group_role_id=group_role.group_role_id)}}"
-		    method="POST">
-		<input type="hidden" name="privilege_id"
-		       value="{{privilege.privilege_id}}" />
-		<input type="submit" class="btn btn-danger"
-		       value="Remove"
-		       {%if not group_role.role.user_editable%}
-		       disabled="disabled"
-		       {%endif%} />
-	      </form>
-	    </td>
-	  </tr>
-	  {%endfor%}
-	</tbody>
-      </table>
-      {%endif%}
-    </div>
-
-    <div class="row">
-      <h3>Other Privileges</h3>
-      <table class="table">
-	<caption>Other Privileges not Assigned to this Role</caption>
-	<thead>
-	  <tr>
-	    <th>Privilege</th>
-	    <th>Description</th>
-	    <th>Action</th>
-	  </tr>
-	</thead>
-
-	<tbody>
-	  {%for priv in group_privileges%}
-	  <tr>
-	    <td>{{priv.privilege_id}}</td>
-	    <td>{{priv.privilege_description}}</td>
-	    <td>
-	      <form action="{{url_for(
-			    'oauth2.group.add_privilege_to_role',
-			    group_role_id=group_role.group_role_id)}}"
-		    method="POST">
-		<input type="hidden" name="privilege_id"
-		       value="{{priv.privilege_id}}" />
-		<input type="submit" class="btn btn-warning"
-		       value="Add to Role"
-		       {%if not group_role.role.user_editable%}
-		       disabled="disabled"
-		       {%endif%} />
-	      </form>
-	    </td>
-	  </tr>
-	  {%else%}
-	  <tr>
-	    <td colspan="3">
-	      <span class="glyphicon glyphicon-info-sign text-info">
-	      </span>
-	      &nbsp;
-	      <span class="text-info">All privileges assigned!</span>
-	    </td>
-	  </tr>
-	  {%endfor%}
-	</tbody>
-      </table>
-    </div>
-
-  </div>
-
-</div>
-{%endblock%}
diff --git a/gn2/wqflask/templates/oauth2/view-resource-role.html b/gn2/wqflask/templates/oauth2/view-resource-role.html
new file mode 100644
index 00000000..4bd0ab45
--- /dev/null
+++ b/gn2/wqflask/templates/oauth2/view-resource-role.html
@@ -0,0 +1,149 @@
+{%extends "base.html"%}
+{%from "oauth2/profile_nav.html" import profile_nav%}
+{%from "oauth2/display_error.html" import display_error%}
+{%block title%}View User{%endblock%}
+{%block content%}
+
+{%macro unassign_button(resource_id, role_id, privilege_id)%}
+<form method="GET"
+      action="{{url_for('oauth2.resource.unassign_privilege_from_resource_role',
+              resource_id=resource_id,
+              role_id=role_id)}}"
+      id="frm_unlink_privilege_{{privilege_id}}">
+  <input type="hidden" name="resource_id" value="{{resource_id}}" />
+  <input type="hidden" name="role_id" value="{{role_id}}" />
+  <input type="hidden" name="privilege_id" value="{{privilege_id}}" />
+  <input type="submit" value="Unassign" class="btn btn-danger" />
+</form>
+{%endmacro%}
+
+<div class="container">
+  <div class="row">
+    {{profile_nav(uipages, user_privileges)}}
+    {{flash_me()}}
+    {%if resource_error is defined%}
+    {{display_error("Resource", resource_error)}}
+    {%else%}
+    <h3>Role for Resource '{{resource.resource_name}}'</h3>
+    {%if role_error is defined%}
+    {{display_error("Role", role_error)}}
+    {%else%}
+    <table class="table">
+      <caption>Role '{{role.role_name}}' for resource '{{resource.resource_name}}'</caption>
+      <thead>
+        <tr>
+          <th>Role Name</th>
+          <th>Privilege</th>
+          <th>Action</th>
+        </tr>
+      </thead>
+
+      <tbody>
+        {%for priv in role.privileges%}
+        {%if loop.index0 == 0%}
+        <tr>
+          <td rowspan="{{role.privileges | length}}"
+              style="text-align: center;vertical-align: middle;">
+            {{role.role_name}}</td>
+          <td>{{priv.privilege_description}}</td>
+          <td>{{unassign_button(resource.resource_id, role.role_id, priv.privilege_id)}}</td>
+        </tr>
+        {%else%}
+        <tr>
+          <td>{{priv.privilege_description}}</td>
+          <td>{{unassign_button(resource.resource_id, role.role_id, priv.privilege_id)}}</td>
+        </tr>
+        {%endif%}
+        {%else%}
+        <tr>
+          <td colspan="3">
+            <p class="text-info">
+              <span class="glyphicon glyphicon-info-sign text-info"></span>
+              &nbsp;
+              This role has no privileges.
+            </p>
+          </td>
+        </tr>
+        {%endfor%}
+      </tbody>
+    </table>
+  </div>
+
+  <div class="row">
+    <form id="frm_assign_privileges" method="POST" action="#">
+      <input type="hidden" name="resource_id" value="{{resource_id}}" />
+      <input type="hidden" name="role_id" value="{{role_id}}" />
+      {%if unassigned_privileges | length == 0%}
+      <p class="text-info">
+        <strong>{{title}}</strong>:
+        <span class="glyphicon glyphicon-info-sign text-info"></span>
+        &nbsp;
+        There are no more privileges left to assign.
+      </p>
+      {%else%}
+      <fieldset>
+        <legend>Select privileges to assign to this role</legend>
+        {%for priv in unassigned_privileges%}
+        <div class="checkbox">
+          <label for="rdo_{{priv.privilege_id}}">
+            <input type="checkbox" value="{{priv.privilege_id}}" />
+            {{priv.privilege_description}}
+          </label>
+        </div>
+        {%endfor%}
+      </fieldset>
+
+      <input type="submit" class="btn btn-primary" value="Assign" />
+      {%endif%}
+    </form>
+  </div>
+
+  {%if user_error is defined%}
+  {{display_error("Users", user_error)}}
+  {%endif%}
+
+  {%if users is defined and users | length > 0%}
+  <div class="row">
+    <h3>Users</h3>
+
+    <table class="table">
+      <caption>
+        Users assigned role '{{role.role_name}}' on resource
+        '{{resource.resource_name}}'
+      </caption>
+
+      <thead>
+        <tr>
+          <th>Email</th>
+          <th>Name</th>
+        </tr>
+      </thead>
+
+      <tbody>
+        {%for user in users%}
+        <tr>
+          <td>{{user.email}}</td>
+          <td>{{user.name}}</td>
+        </tr>
+        {%endfor%}
+        </tbody>
+    </table>
+  </div>
+  {%endif%}
+
+  {%if users is defined and users | length == 0%}
+  <div class="row">
+    <h3>Delete this role</h3>
+    <p class="text-danger">
+      <strong>Delete Role</strong>:
+      <span class="glyphicon glyphicon-exclamation-sign text-danger"></span>
+      &nbsp;
+      This will delete this role, and you will no longer have access to it.
+    </p>
+  </div>
+  {%endif%}
+  {%endif%}
+  {%endif%}
+</div>
+
+{%endblock%}
diff --git a/gn2/wqflask/templates/oauth2/view-resource.html b/gn2/wqflask/templates/oauth2/view-resource.html
index 275fcb24..0788e30c 100644
--- a/gn2/wqflask/templates/oauth2/view-resource.html
+++ b/gn2/wqflask/templates/oauth2/view-resource.html
@@ -2,6 +2,10 @@
 {%from "oauth2/profile_nav.html" import profile_nav%}
 {%from "oauth2/display_error.html" import display_error%}
 {%block title%}View User{%endblock%}
+{%block css%}
+<link rel="stylesheet" href="/static/new/css/pills.css" />
+<link rel="stylesheet" href="/static/new/css/resource-roles.css" />
+{%endblock%}
 {%block content%}
 <div class="container" style="min-width: 1250px;">
   {{profile_nav("resources", user_privileges)}}
@@ -230,7 +234,27 @@
     </div>
 
     <div class="row">
-      <h3>User Roles</h3>
+      <h3>Available Resource Roles</h3>
+      <div class="resource_roles">
+        {%for role in resource_roles%}
+        <a class="pill"
+           href="{{url_for('oauth2.resource.view_resource_role',
+                 resource_id=resource.resource_id,
+                 role_id=role.role_id)}}"
+           title="Role page for role named '{{role.role_name}}'">
+          {{role.role_name}}
+        </a>
+        {%endfor%}
+      </div>
+      <hr />
+      <a title="create a new role for this resource"
+         href="{{url_for('oauth2.resource.create_resource_role',
+               resource_id=resource.resource_id)}}"
+         class="btn btn-info">New Role</a>
+    </div>
+
+    <div class="row">
+      <h3>Users: Assigned Roles</h3>
       {%if users_n_roles_error is defined%}
       {{display_error("Users and Roles", users_n_roles_error)}}
       {%else%}
@@ -254,14 +278,14 @@
 	    <th>Role</th>
 	    <th>Action</th>
 	  </tr>
-	  {%for grole in user_row.roles%}
+	  {%for role in user_row.roles%}
 	  <tr>
 	    <td>
 	      <a href="{{url_for(
 		       'oauth2.role.role',
-		       role_id=grole.role_id)}}"
-		 title="Details for '{{grole.role_name}}' role">
-		{{grole.role_name}}
+		       role_id=role.role_id)}}"
+		 title="Details for '{{role.role_name}}' role">
+		{{role.role_name}}
 	      </a>
 	    </td>
 	    <td>
@@ -270,8 +294,8 @@
 		    method="POST">
 		<input type="hidden" name="user_id"
 		       value="{{user_row.user.user_id}}" />
-		<input type="hidden" name="group_role_id"
-		       value="{{grole.group_role_id}}">
+		<input type="hidden" name="role_id"
+		       value="{{role.role_id}}">
 		<input type="submit"
 		       value="Unassign"
 		       class="btn btn-danger"
@@ -301,8 +325,8 @@
 
     <div class="row">
       <h3>Assign</h3>
-      {%if group_roles_error is defined%}
-      {{display_error("Group Roles", group_roles_error)}}
+      {%if resource_roles_error is defined%}
+      {{display_error("Resource Roles", resource_roles_error)}}
       {%elif users_error is defined%}
       {{display_error("Users", users_error)}}
       {%else%}
@@ -312,13 +336,13 @@
 	    method="POST" autocomplete="off">
 	<input type="hidden" name="resource_id" value="{{resource_id}}" />
 	<div class="form-group">
-	  <label for="group_role_id" class="form-label">Role</label>
-	  <select class="form-control" name="group_role_id"
-		  id="group_role_id" required="required">
-	    <option value="">Select role</option>
-	    {%for grole in group_roles%}
-	    <option value="{{grole.group_role_id}}">
-	      {{grole.role.role_name}}
+	  <label for="role_id" class="form-label">Role</label>
+	  <select class="form-control" name="role_id"
+		  id="role_id" required="required">
+	    <option value="">Select role</option>>
+	    {%for rrole in resource_roles%}
+	    <option value="{{rrole.role_id}}">
+	      {{rrole.role_name}}
 	    </option>
 	    {%endfor%}
 	  </select>