sharedcomponents.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <!--
  2. Copyright (C) 2019-2022 Nicola Murino
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as published
  5. by the Free Software Foundation, version 3.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU Affero General Public License for more details.
  10. You should have received a copy of the GNU Affero General Public License
  11. along with this program. If not, see <https://www.gnu.org/licenses/>.
  12. -->
  13. {{define "shared_user_group"}}
  14. <script type="text/javascript">
  15. $("body").on("click", ".add_new_dirperms_field_btn", function () {
  16. var index = $(".form_field_dirperms_outer").find(".form_field_dirperms_outer_row").length;
  17. while (document.getElementById("idSubDirPermsPath"+index) != null){
  18. index++;
  19. }
  20. $(".form_field_dirperms_outer").append(`
  21. <div class="row form_field_dirperms_outer_row">
  22. <div class="form-group col-md-8">
  23. <input type="text" class="form-control" id="idSubDirPermsPath${index}" name="sub_perm_path${index}" placeholder="directory path, i.e. /dir" value="" maxlength="255">
  24. </div>
  25. <div class="form-group col-md-3">
  26. <select class="form-control" id="idSubDirPermissions${index}" name="sub_perm_permissions${index}" multiple>
  27. </select>
  28. </div>
  29. <div class="form-group col-md-1">
  30. <button class="btn btn-circle btn-danger remove_dirperms_btn_frm_field">
  31. <i class="fas fa-trash"></i>
  32. </button>
  33. </div>
  34. </div>
  35. `);
  36. {{- range .ValidPerms}}
  37. $("#idSubDirPermissions"+index).append($('<option>').val('{{.}}').text('{{.}}'));
  38. {{- end}}
  39. $("#idSubDirPermissions"+index).selectpicker();
  40. });
  41. $("body").on("click", ".remove_dirperms_btn_frm_field", function () {
  42. $(this).closest(".form_field_dirperms_outer_row").remove();
  43. });
  44. $("body").on("click", ".add_new_vfolder_field_btn", function () {
  45. var index = $(".form_field_vfolders_outer").find(".form_field_vfolder_outer_row").length;
  46. while (document.getElementById("idVolderPath" + index) != null) {
  47. index++;
  48. }
  49. $(".form_field_vfolders_outer").append(`
  50. <div class="row form_field_vfolder_outer_row">
  51. <div class="form-group col-md-3">
  52. <input type="text" class="form-control" id="idVolderPath${index}" name="vfolder_path" placeholder="mount path, i.e. /vfolder" value="" maxlength="255">
  53. </div>
  54. <div class="form-group col-md-3">
  55. <select class="form-control" id="idVfolderName${index}" name="vfolder_name">
  56. <option value=""></option>
  57. </select>
  58. </div>
  59. <div class="form-group col-md-3">
  60. <input type="text" class="form-control" id="idVfolderQuotaSize${index}" name="vfolder_quota_size"
  61. value="" aria-describedby="vqsHelpBlock${index}">
  62. <small id="vqsHelpBlock${index}" class="form-text text-muted">
  63. Quota size
  64. </small>
  65. </div>
  66. <div class="form-group col-md-2">
  67. <input type="number" class="form-control" id="idVfolderQuotaFiles${index}" name="vfolder_quota_files"
  68. value="" min="-1" aria-describedby="vqfHelpBlock${index}">
  69. <small id="vqfHelpBlock${index}" class="form-text text-muted">
  70. Quota files
  71. </small>
  72. </div>
  73. <div class="form-group col-md-1">
  74. <button class="btn btn-circle btn-danger remove_vfolder_btn_frm_field">
  75. <i class="fas fa-trash"></i>
  76. </button>
  77. </div>
  78. </div>
  79. `);
  80. {{- range .VirtualFolders}}
  81. $("#idVfolderName"+index).append($('<option>').val('{{.Name}}').text('{{.Name}}'));
  82. {{- end}}
  83. $("#idVfolderName"+index).selectpicker({'liveSearch': true});
  84. });
  85. $("body").on("click", ".remove_vfolder_btn_frm_field", function () {
  86. $(this).closest(".form_field_vfolder_outer_row").remove();
  87. });
  88. $("body").on("click", ".add_new_bwlimit_field_btn", function () {
  89. var index = $(".form_field_bwlimits_outer").find(".form_field_bwlimits_outer_row").length;
  90. while (document.getElementById("idBandwidthLimitSources"+index) != null){
  91. index++;
  92. }
  93. $(".form_field_bwlimits_outer").append(`
  94. <div class="row form_field_bwlimits_outer_row">
  95. <div class="form-group col-md-8">
  96. <textarea class="form-control" id="idBandwidthLimitSources0" name="bandwidth_limit_sources${index}" rows="4" placeholder=""
  97. aria-describedby="bwLimitSourcesHelpBlock${index}"></textarea>
  98. <small id="bwLimitSourcesHelpBlock${index}" class="form-text text-muted">
  99. Comma separated IP/Mask in CIDR format, example: "192.168.1.0/24,10.8.0.100/32"
  100. </small>
  101. </div>
  102. <div class="col-md-3">
  103. <div class="form-group">
  104. <input type="number" class="form-control" id="idUploadBandwidthSource${index}" name="upload_bandwidth_source${index}"
  105. placeholder="" value="" min="0" aria-describedby="ulHelpBlock${index}">
  106. <small id="ulHelpBlock${index}" class="form-text text-muted">
  107. UL (KB/s). 0 means no limit
  108. </small>
  109. </div>
  110. <div class="form-group">
  111. <input type="number" class="form-control" id="idDownloadBandwidthSource${index}" name="download_bandwidth_source${index}"
  112. placeholder="" value="" min="0" aria-describedby="dlHelpBlock${index}">
  113. <small id="dlHelpBlock${index}" class="form-text text-muted">
  114. DL (KB/s). 0 means no limit
  115. </small>
  116. </div>
  117. </div>
  118. <div class="form-group col-md-1">
  119. <button class="btn btn-circle btn-danger remove_bwlimit_btn_frm_field">
  120. <i class="fas fa-trash"></i>
  121. </button>
  122. </div>
  123. </div>
  124. `);
  125. });
  126. $("body").on("click", ".remove_bwlimit_btn_frm_field", function () {
  127. $(this).closest(".form_field_bwlimits_outer_row").remove();
  128. });
  129. $("body").on("click", ".add_new_dtlimit_field_btn", function () {
  130. var index = $(".form_field_dtlimits_outer").find(".form_field_dtlimits_outer_row").length;
  131. while (document.getElementById("idDataTransferLimitSources"+index) != null){
  132. index++;
  133. }
  134. $(".form_field_dtlimits_outer").append(`
  135. <div class="row form_field_dtlimits_outer_row">
  136. <div class="form-group col-md-5">
  137. <textarea class="form-control" id="idDataTransferLimitSources${index}" name="data_transfer_limit_sources${index}" rows="4" placeholder=""
  138. aria-describedby="dtLimitSourcesHelpBlock${index}"></textarea>
  139. <small id="dtLimitSourcesHelpBlock${index}" class="form-text text-muted">
  140. Comma separated IP/Mask in CIDR format, example: "192.168.1.0/24,10.8.0.100/32"
  141. </small>
  142. </div>
  143. <div class="col-md-3">
  144. <div class="form-group">
  145. <input type="number" class="form-control" id="idUploadTransferSource${index}" name="upload_data_transfer_source${index}"
  146. placeholder="" value="" min="0" aria-describedby="ulDtHelpBlock${index}">
  147. <small id="ulDtHelpBlock${index}" class="form-text text-muted">
  148. UL (MB). 0 means no limit
  149. </small>
  150. </div>
  151. <div class="form-group">
  152. <input type="number" class="form-control" id="idDownloadTransferSource${index}" name="download_data_transfer_source${index}"
  153. placeholder="" value="" min="0" aria-describedby="dlDtHelpBlock${index}">
  154. <small id="dlDtHelpBlock${index}" class="form-text text-muted">
  155. DL (MB). 0 means no limit
  156. </small>
  157. </div>
  158. </div>
  159. <div class="col-md-3">
  160. <div class="form-group">
  161. <input type="number" class="form-control" id="idTotalTransferSource${index}" name="total_data_transfer_source${index}"
  162. placeholder="" value="" min="0" aria-describedby="totalDtHelpBlock${index}">
  163. <small id="totalDtHelpBlock${index}" class="form-text text-muted">
  164. Total (MB). 0 means no limit
  165. </small>
  166. </div>
  167. </div>
  168. <div class="form-group col-md-1">
  169. <button class="btn btn-circle btn-danger remove_dtlimit_btn_frm_field">
  170. <i class="fas fa-trash"></i>
  171. </button>
  172. </div>
  173. </div>
  174. `);
  175. });
  176. $("body").on("click", ".remove_dtlimit_btn_frm_field", function () {
  177. $(this).closest(".form_field_dtlimits_outer_row").remove();
  178. });
  179. $("body").on("click", ".add_new_pattern_field_btn", function () {
  180. var index = $(".form_field_patterns_outer").find(".form_field_patterns_outer_row").length;
  181. while (document.getElementById("idPatternPath"+index) != null){
  182. index++;
  183. }
  184. $(".form_field_patterns_outer").append(`
  185. <div class="row form_field_patterns_outer_row">
  186. <div class="form-group col-md-3">
  187. <input type="text" class="form-control" id="idPatternPath${index}" name="pattern_path${index}" placeholder="directory path, i.e. /dir" value="" maxlength="255">
  188. </div>
  189. <div class="form-group col-md-4">
  190. <input type="text" class="form-control" id="idPatterns${index}" name="patterns${index}" placeholder="*.zip,?.txt" value="" maxlength="255">
  191. </div>
  192. <div class="form-group col-md-2">
  193. <select class="form-control" id="idPatternType${index}" name="pattern_type${index}">
  194. <option value="denied">Denied</option>
  195. <option value="allowed">Allowed</option>
  196. </select>
  197. </div>
  198. <div class="form-group col-md-2">
  199. <select class="form-control" id="idPatternPolicy${index}" name="pattern_policy${index}">
  200. <option value="0">Visible</option>
  201. <option value="1">Hidden</option>
  202. </select>
  203. </div>
  204. <div class="form-group col-md-1">
  205. <button class="btn btn-circle btn-danger remove_pattern_btn_frm_field">
  206. <i class="fas fa-trash"></i>
  207. </button>
  208. </div>
  209. </div>
  210. `);
  211. $("#idPatternType"+index).selectpicker();
  212. $("#idPatternPolicy"+index).selectpicker();
  213. });
  214. $("body").on("click", ".remove_pattern_btn_frm_field", function () {
  215. $(this).closest(".form_field_patterns_outer_row").remove();
  216. });
  217. </script>
  218. {{end}}