選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ConfigService.js 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /**
  2. * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
  3. *
  4. * @author John Molakvoæ <skjnldsv@protonmail.com>
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. export default class Config {
  23. /**
  24. * Is public upload allowed on link shares ?
  25. *
  26. * @returns {boolean}
  27. * @readonly
  28. * @memberof Config
  29. */
  30. get isPublicUploadEnabled() {
  31. return document.getElementById('filestable')
  32. && document.getElementById('filestable').dataset.allowPublicUpload === 'yes'
  33. }
  34. /**
  35. * Are link share allowed ?
  36. *
  37. * @returns {boolean}
  38. * @readonly
  39. * @memberof Config
  40. */
  41. get isShareWithLinkAllowed() {
  42. return document.getElementById('allowShareWithLink')
  43. && document.getElementById('allowShareWithLink').value === 'yes'
  44. }
  45. /**
  46. * Get the federated sharing documentation link
  47. *
  48. * @returns {string}
  49. * @readonly
  50. * @memberof Config
  51. */
  52. get federatedShareDocLink() {
  53. return OC.appConfig.core.federatedCloudShareDoc
  54. }
  55. /**
  56. * Get the default link share expiration date as string
  57. *
  58. * @returns {string}
  59. * @readonly
  60. * @memberof Config
  61. */
  62. get defaultExpirationDateString() {
  63. let expireDateString = ''
  64. if (this.isDefaultExpireDateEnabled) {
  65. const date = window.moment.utc()
  66. const expireAfterDays = this.defaultExpireDate
  67. date.add(expireAfterDays, 'days')
  68. expireDateString = date.format('YYYY-MM-DD')
  69. }
  70. return expireDateString
  71. }
  72. /**
  73. * Get the default internal expiration date as string
  74. *
  75. * @returns {string}
  76. * @readonly
  77. * @memberof Config
  78. */
  79. get defaultInternalExpirationDateString() {
  80. let expireDateString = ''
  81. if (this.isDefaultInternalExpireDateEnabled) {
  82. const date = window.moment.utc()
  83. const expireAfterDays = this.defaultInternalExpireDate
  84. date.add(expireAfterDays, 'days')
  85. expireDateString = date.format('YYYY-MM-DD')
  86. }
  87. return expireDateString
  88. }
  89. /**
  90. * Are link shares password-enforced ?
  91. *
  92. * @returns {boolean}
  93. * @readonly
  94. * @memberof Config
  95. */
  96. get enforcePasswordForPublicLink() {
  97. return OC.appConfig.core.enforcePasswordForPublicLink === true
  98. }
  99. /**
  100. * Is password asked by default on link shares ?
  101. *
  102. * @returns {boolean}
  103. * @readonly
  104. * @memberof Config
  105. */
  106. get enableLinkPasswordByDefault() {
  107. return OC.appConfig.core.enableLinkPasswordByDefault === true
  108. }
  109. /**
  110. * Is link shares expiration enforced ?
  111. *
  112. * @returns {boolean}
  113. * @readonly
  114. * @memberof Config
  115. */
  116. get isDefaultExpireDateEnforced() {
  117. return OC.appConfig.core.defaultExpireDateEnforced === true
  118. }
  119. /**
  120. * Is there a default expiration date for new link shares ?
  121. *
  122. * @returns {boolean}
  123. * @readonly
  124. * @memberof Config
  125. */
  126. get isDefaultExpireDateEnabled() {
  127. return OC.appConfig.core.defaultExpireDateEnabled === true
  128. }
  129. /**
  130. * Is internal shares expiration enforced ?
  131. *
  132. * @returns {boolean}
  133. * @readonly
  134. * @memberof Config
  135. */
  136. get isDefaultInternalExpireDateEnforced() {
  137. return OC.appConfig.core.defaultInternalExpireDateEnforced === true
  138. }
  139. /**
  140. * Is there a default expiration date for new internal shares ?
  141. *
  142. * @returns {boolean}
  143. * @readonly
  144. * @memberof Config
  145. */
  146. get isDefaultInternalExpireDateEnabled() {
  147. return OC.appConfig.core.defaultInternalExpireDateEnabled === true
  148. }
  149. /**
  150. * Are users on this server allowed to send shares to other servers ?
  151. *
  152. * @returns {boolean}
  153. * @readonly
  154. * @memberof Config
  155. */
  156. get isRemoteShareAllowed() {
  157. return OC.appConfig.core.remoteShareAllowed === true
  158. }
  159. /**
  160. * Is sharing my mail (link share) enabled ?
  161. *
  162. * @returns {boolean}
  163. * @readonly
  164. * @memberof Config
  165. */
  166. get isMailShareAllowed() {
  167. const capabilities = OC.getCapabilities()
  168. // eslint-disable-next-line camelcase
  169. return capabilities?.files_sharing?.sharebymail !== undefined
  170. // eslint-disable-next-line camelcase
  171. && capabilities?.files_sharing?.public?.enabled === true
  172. }
  173. /**
  174. * Get the default days to link shares expiration
  175. *
  176. * @returns {int}
  177. * @readonly
  178. * @memberof Config
  179. */
  180. get defaultExpireDate() {
  181. return OC.appConfig.core.defaultExpireDate
  182. }
  183. /**
  184. * Get the default days to internal shares expiration
  185. *
  186. * @returns {int}
  187. * @readonly
  188. * @memberof Config
  189. */
  190. get defaultInternalExpireDate() {
  191. return OC.appConfig.core.defaultInternalExpireDate
  192. }
  193. /**
  194. * Is resharing allowed ?
  195. *
  196. * @returns {boolean}
  197. * @readonly
  198. * @memberof Config
  199. */
  200. get isResharingAllowed() {
  201. return OC.appConfig.core.resharingAllowed === true
  202. }
  203. /**
  204. * Is password enforced for mail shares ?
  205. *
  206. * @returns {boolean}
  207. * @readonly
  208. * @memberof Config
  209. */
  210. get isPasswordForMailSharesRequired() {
  211. return (OC.getCapabilities().files_sharing.sharebymail === undefined) ? false : OC.getCapabilities().files_sharing.sharebymail.password.enforced
  212. }
  213. /**
  214. * Is sharing with groups allowed ?
  215. *
  216. * @returns {boolean}
  217. * @readonly
  218. * @memberof Config
  219. */
  220. get allowGroupSharing() {
  221. return OC.appConfig.core.allowGroupSharing === true
  222. }
  223. /**
  224. * Get the maximum results of a share search
  225. *
  226. * @returns {int}
  227. * @readonly
  228. * @memberof Config
  229. */
  230. get maxAutocompleteResults() {
  231. return parseInt(OC.config['sharing.maxAutocompleteResults'], 10) || 25
  232. }
  233. /**
  234. * Get the minimal string length
  235. * to initiate a share search
  236. *
  237. * @returns {int}
  238. * @readonly
  239. * @memberof Config
  240. */
  241. get minSearchStringLength() {
  242. return parseInt(OC.config['sharing.minSearchStringLength'], 10) || 0
  243. }
  244. /**
  245. * Get the password policy config
  246. *
  247. * @returns {Object}
  248. * @readonly
  249. * @memberof Config
  250. */
  251. get passwordPolicy() {
  252. const capabilities = OC.getCapabilities()
  253. return capabilities.password_policy ? capabilities.password_policy : {}
  254. }
  255. }