resource-detail.ftl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <#import "template.ftl" as layout>
  2. <@layout.mainLayout active='authorization' bodyClass='authorization'; section>
  3. <style>
  4. .search-box,.close-icon,.search-wrapper {
  5. position: relative;
  6. }
  7. .search-wrapper {
  8. width: 500px;
  9. margin: auto;
  10. margin-top: 50px;
  11. }
  12. .search-box {
  13. font-weight: 600;
  14. color: white;
  15. border: 1px solid #006e9c;
  16. outline: 0;
  17. border-radius: 15px;
  18. background-color: #0085cf;
  19. padding: 2px 5px;
  20. }
  21. .search-box:focus {
  22. box-shadow: 0 0 15px 5px #b0e0ee;
  23. border: 2px solid #bebede;
  24. }
  25. .close-icon {
  26. border:1px solid transparent;
  27. background-color: transparent;
  28. display: inline-block;
  29. float: right;
  30. outline: 0;
  31. cursor: pointer;
  32. }
  33. .close-icon:after {
  34. display: block;
  35. width: 15px;
  36. height: 15px;
  37. background-color: #FA9595;
  38. z-index:1;
  39. right: 35px;
  40. top: 0;
  41. bottom: 0;
  42. margin: auto;
  43. padding: 2px;
  44. border-radius: 50%;
  45. text-align: center;
  46. color: white;
  47. font-weight: normal;
  48. font-size: 12px;
  49. box-shadow: 0 0 2px #E50F0F;
  50. cursor: pointer;
  51. }
  52. .search-box:not(:valid) ~ .close-icon {
  53. display: none;
  54. }
  55. </style>
  56. <script>
  57. function removeScopeElm(elm) {
  58. elm.parentNode.removeChild(elm);
  59. }
  60. function removeAllScopes(id) {
  61. var scopesElm = document.getElementsByName('removeScope-' + id);
  62. for (i = 0; i < scopesElm.length; i++) {
  63. var td = scopesElm[i].parentNode.parentNode;
  64. var tr = td.parentNode;
  65. var tbody = tr.parentNode;
  66. tbody.removeChild(tr);
  67. }
  68. }
  69. function getChildren(parent, childId) {
  70. var childNodes = [];
  71. for (i = 0; i < parent.childNodes.length; i++) {
  72. if (parent.childNodes[i].id == childId) {
  73. childNodes.push(parent.childNodes[i]);
  74. }
  75. }
  76. return childNodes;
  77. }
  78. </script>
  79. <div class="row">
  80. <div class="col-md-10">
  81. <h2>
  82. <a href="${url.resourceUrl}">${msg("myResources")}</a> <i class="fa fa-angle-right"></i> <#if authorization.resource.displayName??>${authorization.resource.displayName}<#else>${authorization.resource.name}</#if>
  83. </h2>
  84. </div>
  85. </div>
  86. <#if authorization.resource.iconUri??>
  87. <img src="${authorization.resource.iconUri}">
  88. <br/>
  89. </#if>
  90. <div class="row">
  91. <div class="col-md-10">
  92. <h3>
  93. ${msg("peopleAccessResource")}
  94. </h3>
  95. </div>
  96. </div>
  97. <div class="row">
  98. <div class="col-md-12">
  99. <table class="table table-striped table-bordered">
  100. <thead>
  101. <tr>
  102. <th>${msg("user")}</th>
  103. <th>${msg("permission")}</th>
  104. <th>${msg("date")}</th>
  105. <th>${msg("action")}</th>
  106. </tr>
  107. </thead>
  108. <tbody>
  109. <#if authorization.resource.shares?size != 0>
  110. <#list authorization.resource.shares as permission>
  111. <form action="${url.getResourceGrant(authorization.resource.id)}" name="revokeForm-${authorization.resource.id}-${permission.requester.username}" method="post">
  112. <input type="hidden" name="action" value="revoke">
  113. <input type="hidden" name="requester" value="${permission.requester.username}">
  114. <input type="hidden" id="stateChecker" name="stateChecker" value="${stateChecker}">
  115. <tr>
  116. <td>
  117. <#if permission.requester.email??>${permission.requester.email}<#else>${permission.requester.username}</#if>
  118. </td>
  119. <td>
  120. <#if permission.scopes?size != 0>
  121. <#list permission.scopes as scope>
  122. <#if scope.granted && scope.scope??>
  123. <div class="search-box">
  124. <#if scope.scope.displayName??>
  125. ${scope.scope.displayName}
  126. <#else>
  127. ${scope.scope.name}
  128. </#if>
  129. <button class="close-icon" type="button" name="removeScope-${authorization.resource.id}-${permission.requester.username}" onclick="removeScopeElm(this.parentNode);document.forms['revokeForm-${authorization.resource.id}-${permission.requester.username}'].submit();"><i class="fa fa-times" aria-hidden="true"></i></button>
  130. <input type="hidden" name="permission_id" value="${scope.id}"/>
  131. </div>
  132. <#else>
  133. ${msg("anyPermission")}
  134. </#if>
  135. </#list>
  136. <#else>
  137. Any action
  138. </#if>
  139. </td>
  140. <td>
  141. ${permission.createdDate?datetime}
  142. </td>
  143. <td width="20%" align="middle" style="vertical-align: middle">
  144. <a href="#" id="revoke-${authorization.resource.name}-${permission.requester.username}" onclick="removeAllScopes('${authorization.resource.id}-${permission.requester.username}');document.forms['revokeForm-${authorization.resource.id}-${permission.requester.username}'].submit();" type="submit" class="btn btn-primary">${msg("doRevoke")}</a>
  145. </td>
  146. </tr>
  147. </form>
  148. </#list>
  149. <#else>
  150. <tr>
  151. <td colspan="4">${msg("resourceIsNotBeingShared")}</td>
  152. </tr>
  153. </#if>
  154. </tbody>
  155. </table>
  156. </form>
  157. </div>
  158. </div>
  159. <div class="row">
  160. <div class="col-md-10">
  161. <h3>
  162. ${msg("resourceManagedPolicies")}
  163. </h3>
  164. </div>
  165. </div>
  166. <div class="row">
  167. <div class="col-md-12">
  168. <table class="table table-striped table-bordered">
  169. <thead>
  170. <tr>
  171. <th>${msg("description")}</th>
  172. <th>${msg("permission")}</th>
  173. <th>${msg("action")}</th>
  174. </tr>
  175. </thead>
  176. <tbody>
  177. <#if authorization.resource.policies?size != 0>
  178. <#list authorization.resource.policies as permission>
  179. <form action="${url.getResourceGrant(authorization.resource.id)}" name="revokePolicyForm-${authorization.resource.id}-${permission.id}" method="post">
  180. <input type="hidden" name="action" value="revokePolicy">
  181. <input type="hidden" name="permission_id" value="${permission.id}"/>
  182. <input type="hidden" id="stateChecker" name="stateChecker" value="${stateChecker}">
  183. <tr>
  184. <td>
  185. <#if permission.description??>
  186. ${permission.description}
  187. </#if>
  188. </td>
  189. <td>
  190. <#if permission.scopes?size != 0>
  191. <#list permission.scopes as scope>
  192. <div class="search-box">
  193. <#if scope.displayName??>
  194. ${scope.displayName}
  195. <#else>
  196. ${scope.name}
  197. </#if>
  198. <button class="close-icon" type="button" name="removePolicyScope-${authorization.resource.id}-${permission.id}-${scope.id}" onclick="removeScopeElm(this.parentNode);document.forms['revokePolicyForm-${authorization.resource.id}-${permission.id}'].submit();"><i class="fa fa-times" aria-hidden="true"></i></button>
  199. <input type="hidden" name="permission_id" value="${permission.id}:${scope.id}"/>
  200. </div>
  201. </#list>
  202. <#else>
  203. ${msg("anyAction")}
  204. </#if>
  205. </td>
  206. <td width="20%" align="middle" style="vertical-align: middle">
  207. <a href="#" id="revokePolicy-${authorization.resource.name}-${permission.id}" onclick="document.forms['revokePolicyForm-${authorization.resource.id}-${permission.id}']['action'].value = 'revokePolicyAll';document.forms['revokePolicyForm-${authorization.resource.id}-${permission.id}'].submit();" type="submit" class="btn btn-primary">${msg("doRevoke")}</a>
  208. </td>
  209. </tr>
  210. </form>
  211. </#list>
  212. <#else>
  213. <tr>
  214. <td colspan="3">
  215. ${msg("resourceNoPermissionsGrantingAccess")}
  216. </td>
  217. </tr>
  218. </#if>
  219. </tbody>
  220. </table>
  221. </form>
  222. </div>
  223. </div>
  224. <div class="row">
  225. <div class="col-md-10">
  226. <h3>
  227. ${msg("shareWithOthers")}
  228. </h3>
  229. </div>
  230. </div>
  231. <div class="row">
  232. <div class="col-md-10">
  233. <form action="${url.getResourceShare(authorization.resource.id)}" name="shareForm" method="post">
  234. <input type="hidden" id="stateChecker" name="stateChecker" value="${stateChecker}">
  235. <div class="col-sm-3 col-md-3">
  236. <label for="password" class="control-label">${msg("username")} or ${msg("email")} </label> <span class="required">*</span>
  237. </div>
  238. <div class="col-sm-8 col-md-8">
  239. <div class="row">
  240. <div class="col-md-12">
  241. <input type="text" class="form-control" id="user_id" name="user_id" autofocus autocomplete="off">
  242. </div>
  243. <div class="col-md-12">
  244. <br/>
  245. <#list authorization.resource.scopes as scope>
  246. <div id="scope" class="search-box">
  247. <#if scope.displayName??>
  248. ${scope.displayName}
  249. <#else>
  250. ${scope.name}
  251. </#if>
  252. <button class="close-icon" id="share-remove-scope-${authorization.resource.name}-${scope.name}" type="button" onclick="if (getChildren(this.parentNode.parentNode, 'scope').length > 1) {removeScopeElm(this.parentNode)}"><i class="fa fa-times" aria-hidden="true"></i></button>
  253. <input type="hidden" name="scope_id" value="${scope.id}"/>
  254. </div>
  255. </#list>
  256. </div>
  257. <div class="col-md-12">
  258. <br/>
  259. <a href="#" onclick="document.forms['shareForm'].submit()" type="submit" id="share-button" class="btn btn-primary">${msg("share")}</a>
  260. </div>
  261. </div>
  262. </div>
  263. </form>
  264. </div>
  265. </div>
  266. <br/>
  267. </@layout.mainLayout>