resources.ftl 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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 showHideActions(elm) {
  58. if (elm.style.display == 'none') {
  59. elm.style.display = '';
  60. } else {
  61. elm.style.display = 'none';
  62. }
  63. }
  64. function removeScopeElm(elm) {
  65. var td = elm.parentNode;
  66. var tr = td.parentNode;
  67. var tbody = tr.parentNode;
  68. td.removeChild(elm);
  69. var childCount = td.childNodes.length - 1;
  70. for (i = 0; i < td.childNodes.length; i++) {
  71. if (!td.childNodes[i].tagName || td.childNodes[i].tagName.toUpperCase() != 'DIV') {
  72. td.removeChild(td.childNodes[i]);
  73. childCount--;
  74. }
  75. }
  76. if (childCount <= 0) {
  77. tbody.removeChild(tr);
  78. }
  79. }
  80. function removeAllScopes(id) {
  81. var scopesElm = document.getElementsByName('removeScope-' + id);
  82. for (i = 0; i < scopesElm.length; i++) {
  83. var td = scopesElm[i].parentNode.parentNode;
  84. var tr = td.parentNode;
  85. var tbody = tr.parentNode;
  86. tbody.removeChild(tr);
  87. }
  88. }
  89. function selectAllCheckBoxes(formName, elm, name) {
  90. var shares = document.forms[formName].getElementsByTagName('input');
  91. for (i = 0; i < shares.length; i++) {
  92. if (shares[i].name == name) {
  93. shares[i].checked = elm.checked;
  94. }
  95. }
  96. }
  97. </script>
  98. <div class="row">
  99. <div class="col-md-10">
  100. <h2>
  101. ${msg("myResources")}
  102. </h2>
  103. </div>
  104. </div>
  105. <#if authorization.resourcesWaitingApproval?size != 0>
  106. <div class="row">
  107. <div class="col-md-12">
  108. <h3>
  109. ${msg("needMyApproval")}
  110. </h3>
  111. </div>
  112. </div>
  113. <div class="row">
  114. <div class="col-md-12">
  115. <table class="table table-striped table-bordered">
  116. <thead>
  117. <tr>
  118. <th>${msg("resource")}</th>
  119. <th>${msg("requestor")}</th>
  120. <th>${msg("permissionRequestion")}</th>
  121. <th>${msg("action")}</th>
  122. </tr>
  123. </thead>
  124. <tbody>
  125. <#list authorization.resourcesWaitingApproval as resource>
  126. <#list resource.permissions as permission>
  127. <form action="${url.getResourceGrant(resource.id)}" name="approveForm-${resource.id}-${permission.requester.username}" method="post">
  128. <input type="hidden" name="action" value="grant">
  129. <input type="hidden" name="requester" value="${permission.requester.username}">
  130. <input type="hidden" id="stateChecker" name="stateChecker" value="${stateChecker}">
  131. <tr>
  132. <td>
  133. <#if resource.displayName??>${resource.displayName}<#else>${resource.name}</#if>
  134. </td>
  135. <td>
  136. <#if permission.requester.email??>${permission.requester.email}<#else>${permission.requester.username}</#if>
  137. </td>
  138. <td>
  139. <#list permission.scopes as scope>
  140. <#if scope.scope??>
  141. <div class="search-box">
  142. <#if scope.scope.displayName??>
  143. ${scope.scope.displayName}
  144. <#else>
  145. ${scope.scope.name}
  146. </#if>
  147. <button class="close-icon" type="button" id="grant-remove-scope-${resource.name}-${permission.requester.username}-${scope.scope.name}" name="removeScope-${resource.id}-${permission.requester.username}" onclick="removeScopeElm(this.parentNode);document.forms['approveForm-${resource.id}-${permission.requester.username}']['action'].value = 'deny';document.forms['approveForm-${resource.id}-${permission.requester.username}'].submit();"><i class="fa fa-times" aria-hidden="true"></i></button>
  148. <input type="hidden" name="permission_id" value="${scope.id}"/>
  149. </div>
  150. <#else>
  151. ${msg("anyPermission")}
  152. </#if>
  153. </#list>
  154. </td>
  155. <td width="20%" align="middle" style="vertical-align: middle">
  156. <a href="#" id="grant-${resource.name}-${permission.requester.username}" onclick="document.forms['approveForm-${resource.id}-${permission.requester.username}']['action'].value = 'grant';document.forms['approveForm-${resource.id}-${permission.requester.username}'].submit();" type="submit" class="btn btn-primary">${msg("doApprove")}</a>
  157. <a href="#" id="deny-${resource.name}-${permission.requester.username}" onclick="removeAllScopes('${resource.id}-${permission.requester.username}');document.forms['approveForm-${resource.id}-${permission.requester.username}']['action'].value = 'deny';document.forms['approveForm-${resource.id}-${permission.requester.username}'].submit();" type="submit" class="btn btn-danger">${msg("doDeny")}</a>
  158. </td>
  159. </tr>
  160. </form>
  161. </#list>
  162. </#list>
  163. </tbody>
  164. </table>
  165. </div>
  166. </div>
  167. </#if>
  168. <div class="row">
  169. <div class="col-md-12">
  170. <h3>
  171. ${msg("myResourcesSub")}
  172. </h3>
  173. </div>
  174. </div>
  175. <div class="row">
  176. <div class="col-md-12">
  177. <table class="table table-striped table-bordered">
  178. <thead>
  179. <tr>
  180. <th>${msg("resource")}</th>
  181. <th>${msg("application")}</th>
  182. <th>${msg("peopleSharingThisResource")}</th>
  183. </tr>
  184. </thead>
  185. <tbody>
  186. <#if authorization.resources?size != 0>
  187. <#list authorization.resources as resource>
  188. <tr>
  189. <td>
  190. <a id="detail-${resource.name}" href="${url.getResourceDetailUrl(resource.id)}">
  191. <#if resource.displayName??>${resource.displayName}<#else>${resource.name}</#if>
  192. </a>
  193. </td>
  194. <td>
  195. <#if resource.resourceServer.baseUri??>
  196. <a href="${resource.resourceServer.baseUri}">${resource.resourceServer.name}</a>
  197. <#else>
  198. ${resource.resourceServer.name}
  199. </#if>
  200. </td>
  201. <td>
  202. <#if resource.shares?size != 0>
  203. <a href="${url.getResourceDetailUrl(resource.id)}">${resource.shares?size} <i class="fa fa-users"></i></a>
  204. <#else>
  205. ${msg("notBeingShared")}
  206. </#if>
  207. </td>
  208. </tr>
  209. </#list>
  210. <#else>
  211. <tr>
  212. <td colspan="4">${msg("notHaveAnyResource")}</td>
  213. </tr>
  214. </#if>
  215. </tbody>
  216. </table>
  217. </div>
  218. </div>
  219. <div class="row">
  220. <div class="col-md-12">
  221. <h3>
  222. ${msg("resourcesSharedWithMe")}
  223. </h3>
  224. </div>
  225. </div>
  226. <div class="row">
  227. <div class="col-md-12">
  228. <form action="${url.resourceUrl}" name="shareForm" method="post">
  229. <input type="hidden" name="action" value="cancel"/>
  230. <input type="hidden" id="stateChecker" name="stateChecker" value="${stateChecker}">
  231. <table class="table table-striped table-bordered">
  232. <thead>
  233. <tr>
  234. <th width="5%"><input type="checkbox" onclick="selectAllCheckBoxes('shareForm', this, 'resource_id');" <#if authorization.sharedResources?size == 0>disabled="true"</#if></td>
  235. <th>${msg("resource")}</th>
  236. <th>${msg("owner")}</th>
  237. <th>${msg("application")}</th>
  238. <th>${msg("permission")}</th>
  239. <th>${msg("date")}</th>
  240. </tr>
  241. </thead>
  242. <tbody>
  243. <#if authorization.sharedResources?size != 0>
  244. <#list authorization.sharedResources as resource>
  245. <tr>
  246. <td>
  247. <input type="checkbox" name="resource_id" value="${resource.id}"/>
  248. </td>
  249. <td>
  250. <#if resource.displayName??>${resource.displayName}<#else>${resource.name}</#if>
  251. </td>
  252. <td>
  253. ${resource.ownerName}
  254. </td>
  255. <td>
  256. <#if resource.resourceServer.baseUri??>
  257. <a href="${resource.resourceServer.baseUri}">${resource.resourceServer.name}</a>
  258. <#else>
  259. ${resource.resourceServer.name}
  260. </#if>
  261. </td>
  262. <td>
  263. <#if resource.permissions?size != 0>
  264. <ul>
  265. <#list resource.permissions as permission>
  266. <#list permission.scopes as scope>
  267. <#if scope.granted && scope.scope??>
  268. <li>
  269. <#if scope.scope.displayName??>
  270. ${scope.scope.displayName}
  271. <#else>
  272. ${scope.scope.name}
  273. </#if>
  274. </li>
  275. <#else>
  276. ${msg("anyPermission")}
  277. </#if>
  278. </#list>
  279. </#list>
  280. </ul>
  281. <#else>
  282. Any action
  283. </#if>
  284. </td>
  285. <td>
  286. ${resource.permissions[0].grantedDate?datetime}
  287. </td>
  288. </tr>
  289. </#list>
  290. <#else>
  291. <tr>
  292. <td colspan="6">${msg("noResourcesSharedWithYou")}</td>
  293. </tr>
  294. </#if>
  295. </tbody>
  296. </table>
  297. </form>
  298. </div>
  299. <#if authorization.sharedResources?size != 0>
  300. <div class="col-md-12">
  301. <a href="#" onclick="document.forms['shareForm'].submit();" type="submit" class="btn btn-danger">${msg("doRemoveSharing")}</a>
  302. </div>
  303. </#if>
  304. </div>
  305. <#if authorization.resourcesWaitingOthersApproval?size != 0>
  306. <br/>
  307. <div class="row">
  308. <div class="col-md-12">
  309. <h3>
  310. ${msg("requestsWaitingApproval")}
  311. </h3>
  312. </div>
  313. </div>
  314. <div class="row">
  315. <div class="col-md-12">
  316. <i class="pficon pficon-info"></i> ${msg("havePermissionRequestsWaitingForApproval",authorization.resourcesWaitingOthersApproval?size)}
  317. <a href="#" onclick="document.getElementById('waitingApproval').style.display=''">${msg("clickHereForDetails")}</a>
  318. <div class="row">
  319. <div class="col-md-12"></div>
  320. </div>
  321. <div class="row">
  322. <div class="col-md-12"></div>
  323. </div>
  324. <div class="row">
  325. <div class="col-md-12"></div>
  326. </div>
  327. <div class="row" id="waitingApproval" style="display:none">
  328. <div class="col-md-12">
  329. <form action="${url.resourceUrl}" name="waitingApprovalForm" method="post">
  330. <input type="hidden" name="action" value="cancelRequest"/>
  331. <input type="hidden" id="stateChecker" name="stateChecker" value="${stateChecker}">
  332. <table class="table table-striped table-bordered">
  333. <thead>
  334. <tr>
  335. <th width="5%"><input type="checkbox" onclick="selectAllCheckBoxes('waitingApprovalForm', this, 'resource_id');" <#if authorization.resourcesWaitingOthersApproval?size == 0>disabled="true"</#if></th>
  336. <th>${msg("resource")}</th>
  337. <th>${msg("owner")}</th>
  338. <th>${msg("action")}</th>
  339. <th>${msg("date")}</th>
  340. </tr>
  341. </thead>
  342. <tbody>
  343. <#list authorization.resourcesWaitingOthersApproval as resource>
  344. <tr>
  345. <td>
  346. <input type="checkbox" name="resource_id" value="${resource.id}"/>
  347. </td>
  348. <td>
  349. <#if resource.displayName??>${resource.displayName}<#else>${resource.name}</#if>
  350. </td>
  351. <td>
  352. ${resource.ownerName}
  353. </td>
  354. <td>
  355. <ul>
  356. <#list resource.permissions as permission>
  357. <#list permission.scopes as scope>
  358. <li>
  359. <#if scope.scope??>
  360. <#if scope.scope.displayName??>
  361. ${scope.scope.displayName}
  362. <#else>
  363. ${scope.scope.name}
  364. </#if>
  365. <#else>
  366. ${msg("anyPermission")}
  367. </#if>
  368. </li>
  369. </#list>
  370. </#list>
  371. </ul>
  372. </td>
  373. <td>
  374. ${resource.permissions[0].createdDate?datetime}
  375. </td>
  376. </tr>
  377. </#list>
  378. </tbody>
  379. </table>
  380. </form>
  381. </div>
  382. <div class="col-md-12">
  383. <a href="#" onclick="document.forms['waitingApprovalForm'].submit();" type="submit" class="btn btn-danger">${msg("doRemoveRequest")}</a>
  384. </div>
  385. </div>
  386. </div>
  387. </div>
  388. </#if>
  389. </@layout.mainLayout>