@fiduswriter/frontend 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +66 -0
  3. package/dist/admin_console/index.d.ts +8 -0
  4. package/dist/admin_console/index.d.ts.map +1 -0
  5. package/dist/admin_console/index.js +54 -0
  6. package/dist/admin_console/index.js.map +1 -0
  7. package/dist/api/index.d.ts +193 -0
  8. package/dist/api/index.d.ts.map +1 -0
  9. package/dist/api/index.js +6 -0
  10. package/dist/api/index.js.map +1 -0
  11. package/dist/app/index.d.ts +74 -0
  12. package/dist/app/index.d.ts.map +1 -0
  13. package/dist/app/index.js +471 -0
  14. package/dist/app/index.js.map +1 -0
  15. package/dist/common/index.d.ts +3 -0
  16. package/dist/common/index.d.ts.map +1 -0
  17. package/dist/common/index.js +3 -0
  18. package/dist/common/index.js.map +1 -0
  19. package/dist/common/templates.d.ts +3 -0
  20. package/dist/common/templates.d.ts.map +1 -0
  21. package/dist/common/templates.js +42 -0
  22. package/dist/common/templates.js.map +1 -0
  23. package/dist/common/user_util.d.ts +6 -0
  24. package/dist/common/user_util.d.ts.map +1 -0
  25. package/dist/common/user_util.js +16 -0
  26. package/dist/common/user_util.js.map +1 -0
  27. package/dist/document_templates/actions.d.ts +11 -0
  28. package/dist/document_templates/actions.d.ts.map +1 -0
  29. package/dist/document_templates/actions.js +141 -0
  30. package/dist/document_templates/actions.js.map +1 -0
  31. package/dist/document_templates/editor.d.ts +28 -0
  32. package/dist/document_templates/editor.d.ts.map +1 -0
  33. package/dist/document_templates/editor.js +139 -0
  34. package/dist/document_templates/editor.js.map +1 -0
  35. package/dist/document_templates/index.d.ts +3 -0
  36. package/dist/document_templates/index.d.ts.map +1 -0
  37. package/dist/document_templates/index.js +3 -0
  38. package/dist/document_templates/index.js.map +1 -0
  39. package/dist/document_templates/menu.d.ts +7 -0
  40. package/dist/document_templates/menu.d.ts.map +1 -0
  41. package/dist/document_templates/menu.js +62 -0
  42. package/dist/document_templates/menu.js.map +1 -0
  43. package/dist/document_templates/overview.d.ts +52 -0
  44. package/dist/document_templates/overview.d.ts.map +1 -0
  45. package/dist/document_templates/overview.js +274 -0
  46. package/dist/document_templates/overview.js.map +1 -0
  47. package/dist/document_templates/templates.d.ts +3 -0
  48. package/dist/document_templates/templates.d.ts.map +1 -0
  49. package/dist/document_templates/templates.js +9 -0
  50. package/dist/document_templates/templates.js.map +1 -0
  51. package/dist/documents/importer/docx/import.d.ts +5 -0
  52. package/dist/documents/importer/docx/import.d.ts.map +1 -0
  53. package/dist/documents/importer/docx/import.js +15 -0
  54. package/dist/documents/importer/docx/import.js.map +1 -0
  55. package/dist/documents/importer/docx/index.d.ts +2 -0
  56. package/dist/documents/importer/docx/index.d.ts.map +1 -0
  57. package/dist/documents/importer/docx/index.js +2 -0
  58. package/dist/documents/importer/docx/index.js.map +1 -0
  59. package/dist/documents/importer/native/file.d.ts +7 -0
  60. package/dist/documents/importer/native/file.d.ts.map +1 -0
  61. package/dist/documents/importer/native/file.js +60 -0
  62. package/dist/documents/importer/native/file.js.map +1 -0
  63. package/dist/documents/importer/native/import.d.ts +41 -0
  64. package/dist/documents/importer/native/import.d.ts.map +1 -0
  65. package/dist/documents/importer/native/import.js +126 -0
  66. package/dist/documents/importer/native/import.js.map +1 -0
  67. package/dist/documents/importer/native/index.d.ts +3 -0
  68. package/dist/documents/importer/native/index.d.ts.map +1 -0
  69. package/dist/documents/importer/native/index.js +3 -0
  70. package/dist/documents/importer/native/index.js.map +1 -0
  71. package/dist/documents/importer/odt/import.d.ts +5 -0
  72. package/dist/documents/importer/odt/import.d.ts.map +1 -0
  73. package/dist/documents/importer/odt/import.js +16 -0
  74. package/dist/documents/importer/odt/import.js.map +1 -0
  75. package/dist/documents/importer/odt/index.d.ts +2 -0
  76. package/dist/documents/importer/odt/index.d.ts.map +1 -0
  77. package/dist/documents/importer/odt/index.js +2 -0
  78. package/dist/documents/importer/odt/index.js.map +1 -0
  79. package/dist/documents/importer/pandoc/import.d.ts +5 -0
  80. package/dist/documents/importer/pandoc/import.d.ts.map +1 -0
  81. package/dist/documents/importer/pandoc/import.js +37 -0
  82. package/dist/documents/importer/pandoc/import.js.map +1 -0
  83. package/dist/documents/importer/pandoc/index.d.ts +2 -0
  84. package/dist/documents/importer/pandoc/index.d.ts.map +1 -0
  85. package/dist/documents/importer/pandoc/index.js +2 -0
  86. package/dist/documents/importer/pandoc/index.js.map +1 -0
  87. package/dist/documents/importer/register.d.ts +4 -0
  88. package/dist/documents/importer/register.d.ts.map +1 -0
  89. package/dist/documents/importer/register.js +4 -0
  90. package/dist/documents/importer/register.js.map +1 -0
  91. package/dist/documents/overview/actions.d.ts +32 -0
  92. package/dist/documents/overview/actions.d.ts.map +1 -0
  93. package/dist/documents/overview/actions.js +725 -0
  94. package/dist/documents/overview/actions.js.map +1 -0
  95. package/dist/documents/overview/index.d.ts +98 -0
  96. package/dist/documents/overview/index.d.ts.map +1 -0
  97. package/dist/documents/overview/index.js +814 -0
  98. package/dist/documents/overview/index.js.map +1 -0
  99. package/dist/documents/overview/menu.d.ts +28 -0
  100. package/dist/documents/overview/menu.d.ts.map +1 -0
  101. package/dist/documents/overview/menu.js +222 -0
  102. package/dist/documents/overview/menu.js.map +1 -0
  103. package/dist/documents/overview/templates.d.ts +31 -0
  104. package/dist/documents/overview/templates.d.ts.map +1 -0
  105. package/dist/documents/overview/templates.js +39 -0
  106. package/dist/documents/overview/templates.js.map +1 -0
  107. package/dist/documents/revisions/index.d.ts +14 -0
  108. package/dist/documents/revisions/index.d.ts.map +1 -0
  109. package/dist/documents/revisions/index.js +143 -0
  110. package/dist/documents/revisions/index.js.map +1 -0
  111. package/dist/documents/revisions/templates.d.ts +4 -0
  112. package/dist/documents/revisions/templates.d.ts.map +1 -0
  113. package/dist/documents/revisions/templates.js +36 -0
  114. package/dist/documents/revisions/templates.js.map +1 -0
  115. package/dist/documents/tools.d.ts +16 -0
  116. package/dist/documents/tools.d.ts.map +1 -0
  117. package/dist/documents/tools.js +69 -0
  118. package/dist/documents/tools.js.map +1 -0
  119. package/dist/error_hook/index.d.ts +19 -0
  120. package/dist/error_hook/index.d.ts.map +1 -0
  121. package/dist/error_hook/index.js +75 -0
  122. package/dist/error_hook/index.js.map +1 -0
  123. package/dist/feedback/index.d.ts +12 -0
  124. package/dist/feedback/index.d.ts.map +1 -0
  125. package/dist/feedback/index.js +125 -0
  126. package/dist/feedback/index.js.map +1 -0
  127. package/dist/index.d.ts +42 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/index.js +48 -0
  130. package/dist/index.js.map +1 -0
  131. package/dist/indexed_db/index.d.ts +24 -0
  132. package/dist/indexed_db/index.d.ts.map +1 -0
  133. package/dist/indexed_db/index.js +175 -0
  134. package/dist/indexed_db/index.js.map +1 -0
  135. package/dist/maintenance/index.d.ts +19 -0
  136. package/dist/maintenance/index.d.ts.map +1 -0
  137. package/dist/maintenance/index.js +223 -0
  138. package/dist/maintenance/index.js.map +1 -0
  139. package/dist/menu/index.d.ts +25 -0
  140. package/dist/menu/index.d.ts.map +1 -0
  141. package/dist/menu/index.js +229 -0
  142. package/dist/menu/index.js.map +1 -0
  143. package/dist/menu/templates.d.ts +6 -0
  144. package/dist/menu/templates.d.ts.map +1 -0
  145. package/dist/menu/templates.js +10 -0
  146. package/dist/menu/templates.js.map +1 -0
  147. package/dist/pages/404.d.ts +9 -0
  148. package/dist/pages/404.d.ts.map +1 -0
  149. package/dist/pages/404.js +12 -0
  150. package/dist/pages/404.js.map +1 -0
  151. package/dist/pages/flatpage.d.ts +12 -0
  152. package/dist/pages/flatpage.d.ts.map +1 -0
  153. package/dist/pages/flatpage.js +39 -0
  154. package/dist/pages/flatpage.js.map +1 -0
  155. package/dist/pages/offline.d.ts +10 -0
  156. package/dist/pages/offline.d.ts.map +1 -0
  157. package/dist/pages/offline.js +27 -0
  158. package/dist/pages/offline.js.map +1 -0
  159. package/dist/pages/setup.d.ts +10 -0
  160. package/dist/pages/setup.d.ts.map +1 -0
  161. package/dist/pages/setup.js +22 -0
  162. package/dist/pages/setup.js.map +1 -0
  163. package/dist/plugins/menu/index.d.ts +3 -0
  164. package/dist/plugins/menu/index.d.ts.map +1 -0
  165. package/dist/plugins/menu/index.js +2 -0
  166. package/dist/plugins/menu/index.js.map +1 -0
  167. package/dist/prelogin/index.d.ts +51 -0
  168. package/dist/prelogin/index.d.ts.map +1 -0
  169. package/dist/prelogin/index.js +131 -0
  170. package/dist/prelogin/index.js.map +1 -0
  171. package/dist/prelogin/templates.d.ts +20 -0
  172. package/dist/prelogin/templates.d.ts.map +1 -0
  173. package/dist/prelogin/templates.js +50 -0
  174. package/dist/prelogin/templates.js.map +1 -0
  175. package/dist/state_plugins/contributor_input/add_button.d.ts +22 -0
  176. package/dist/state_plugins/contributor_input/add_button.d.ts.map +1 -0
  177. package/dist/state_plugins/contributor_input/add_button.js +106 -0
  178. package/dist/state_plugins/contributor_input/add_button.js.map +1 -0
  179. package/dist/state_plugins/contributor_input/helpers.d.ts +3 -0
  180. package/dist/state_plugins/contributor_input/helpers.d.ts.map +1 -0
  181. package/dist/state_plugins/contributor_input/helpers.js +23 -0
  182. package/dist/state_plugins/contributor_input/helpers.js.map +1 -0
  183. package/dist/state_plugins/contributor_input/index.d.ts +4 -0
  184. package/dist/state_plugins/contributor_input/index.d.ts.map +1 -0
  185. package/dist/state_plugins/contributor_input/index.js +4 -0
  186. package/dist/state_plugins/contributor_input/index.js.map +1 -0
  187. package/dist/state_plugins/contributor_input/node_view.d.ts +20 -0
  188. package/dist/state_plugins/contributor_input/node_view.d.ts.map +1 -0
  189. package/dist/state_plugins/contributor_input/node_view.js +85 -0
  190. package/dist/state_plugins/contributor_input/node_view.js.map +1 -0
  191. package/dist/state_plugins/index.d.ts +3 -0
  192. package/dist/state_plugins/index.d.ts.map +1 -0
  193. package/dist/state_plugins/index.js +3 -0
  194. package/dist/state_plugins/index.js.map +1 -0
  195. package/dist/state_plugins/tag_input/helpers.d.ts +5 -0
  196. package/dist/state_plugins/tag_input/helpers.d.ts.map +1 -0
  197. package/dist/state_plugins/tag_input/helpers.js +55 -0
  198. package/dist/state_plugins/tag_input/helpers.js.map +1 -0
  199. package/dist/state_plugins/tag_input/index.d.ts +5 -0
  200. package/dist/state_plugins/tag_input/index.d.ts.map +1 -0
  201. package/dist/state_plugins/tag_input/index.js +5 -0
  202. package/dist/state_plugins/tag_input/index.js.map +1 -0
  203. package/dist/state_plugins/tag_input/node_view.d.ts +19 -0
  204. package/dist/state_plugins/tag_input/node_view.d.ts.map +1 -0
  205. package/dist/state_plugins/tag_input/node_view.js +85 -0
  206. package/dist/state_plugins/tag_input/node_view.js.map +1 -0
  207. package/dist/state_plugins/tag_input/tag_editor.d.ts +4 -0
  208. package/dist/state_plugins/tag_input/tag_editor.d.ts.map +1 -0
  209. package/dist/state_plugins/tag_input/tag_editor.js +160 -0
  210. package/dist/state_plugins/tag_input/tag_editor.js.map +1 -0
  211. package/dist/state_plugins/tag_input/tag_editor_plugins.d.ts +5 -0
  212. package/dist/state_plugins/tag_input/tag_editor_plugins.d.ts.map +1 -0
  213. package/dist/state_plugins/tag_input/tag_editor_plugins.js +64 -0
  214. package/dist/state_plugins/tag_input/tag_editor_plugins.js.map +1 -0
  215. package/dist/types.d.ts +53 -0
  216. package/dist/types.d.ts.map +1 -0
  217. package/dist/types.js +2 -0
  218. package/dist/types.js.map +1 -0
  219. package/dist/user/auth/email_confirm.d.ts +23 -0
  220. package/dist/user/auth/email_confirm.d.ts.map +1 -0
  221. package/dist/user/auth/email_confirm.js +123 -0
  222. package/dist/user/auth/email_confirm.js.map +1 -0
  223. package/dist/user/auth/email_confirm_templates.d.ts +12 -0
  224. package/dist/user/auth/email_confirm_templates.d.ts.map +1 -0
  225. package/dist/user/auth/email_confirm_templates.js +30 -0
  226. package/dist/user/auth/email_confirm_templates.js.map +1 -0
  227. package/dist/user/auth/login.d.ts +13 -0
  228. package/dist/user/auth/login.d.ts.map +1 -0
  229. package/dist/user/auth/login.js +186 -0
  230. package/dist/user/auth/login.js.map +1 -0
  231. package/dist/user/auth/password_reset_change.d.ts +11 -0
  232. package/dist/user/auth/password_reset_change.d.ts.map +1 -0
  233. package/dist/user/auth/password_reset_change.js +101 -0
  234. package/dist/user/auth/password_reset_change.js.map +1 -0
  235. package/dist/user/auth/password_reset_request.d.ts +10 -0
  236. package/dist/user/auth/password_reset_request.d.ts.map +1 -0
  237. package/dist/user/auth/password_reset_request.js +82 -0
  238. package/dist/user/auth/password_reset_request.js.map +1 -0
  239. package/dist/user/auth/signup.d.ts +9 -0
  240. package/dist/user/auth/signup.d.ts.map +1 -0
  241. package/dist/user/auth/signup.js +148 -0
  242. package/dist/user/auth/signup.js.map +1 -0
  243. package/dist/user/auth/two_factor.d.ts +10 -0
  244. package/dist/user/auth/two_factor.d.ts.map +1 -0
  245. package/dist/user/auth/two_factor.js +201 -0
  246. package/dist/user/auth/two_factor.js.map +1 -0
  247. package/dist/user/contacts/add_dialog.d.ts +7 -0
  248. package/dist/user/contacts/add_dialog.d.ts.map +1 -0
  249. package/dist/user/contacts/add_dialog.js +84 -0
  250. package/dist/user/contacts/add_dialog.js.map +1 -0
  251. package/dist/user/contacts/delete_dialog.d.ts +6 -0
  252. package/dist/user/contacts/delete_dialog.d.ts.map +1 -0
  253. package/dist/user/contacts/delete_dialog.js +38 -0
  254. package/dist/user/contacts/delete_dialog.js.map +1 -0
  255. package/dist/user/contacts/index.d.ts +35 -0
  256. package/dist/user/contacts/index.d.ts.map +1 -0
  257. package/dist/user/contacts/index.js +234 -0
  258. package/dist/user/contacts/index.js.map +1 -0
  259. package/dist/user/contacts/invite.d.ts +9 -0
  260. package/dist/user/contacts/invite.d.ts.map +1 -0
  261. package/dist/user/contacts/invite.js +21 -0
  262. package/dist/user/contacts/invite.js.map +1 -0
  263. package/dist/user/contacts/menu.d.ts +7 -0
  264. package/dist/user/contacts/menu.d.ts.map +1 -0
  265. package/dist/user/contacts/menu.js +62 -0
  266. package/dist/user/contacts/menu.js.map +1 -0
  267. package/dist/user/contacts/respond_invite.d.ts +9 -0
  268. package/dist/user/contacts/respond_invite.d.ts.map +1 -0
  269. package/dist/user/contacts/respond_invite.js +65 -0
  270. package/dist/user/contacts/respond_invite.js.map +1 -0
  271. package/dist/user/contacts/templates.d.ts +7 -0
  272. package/dist/user/contacts/templates.d.ts.map +1 -0
  273. package/dist/user/contacts/templates.js +24 -0
  274. package/dist/user/contacts/templates.js.map +1 -0
  275. package/dist/user/profile/delete_user.d.ts +8 -0
  276. package/dist/user/profile/delete_user.d.ts.map +1 -0
  277. package/dist/user/profile/delete_user.js +56 -0
  278. package/dist/user/profile/delete_user.js.map +1 -0
  279. package/dist/user/profile/dialogs.d.ts +10 -0
  280. package/dist/user/profile/dialogs.d.ts.map +1 -0
  281. package/dist/user/profile/dialogs.js +311 -0
  282. package/dist/user/profile/dialogs.js.map +1 -0
  283. package/dist/user/profile/index.d.ts +27 -0
  284. package/dist/user/profile/index.d.ts.map +1 -0
  285. package/dist/user/profile/index.js +254 -0
  286. package/dist/user/profile/index.js.map +1 -0
  287. package/dist/user/profile/templates.d.ts +22 -0
  288. package/dist/user/profile/templates.d.ts.map +1 -0
  289. package/dist/user/profile/templates.js +261 -0
  290. package/dist/user/profile/templates.js.map +1 -0
  291. package/dist/workers/adjust_doc_to_template.d.ts +11 -0
  292. package/dist/workers/adjust_doc_to_template.d.ts.map +1 -0
  293. package/dist/workers/adjust_doc_to_template.js +26 -0
  294. package/dist/workers/adjust_doc_to_template.js.map +1 -0
  295. package/package.json +225 -0
  296. package/src/admin_console/index.ts +84 -0
  297. package/src/api/index.ts +149 -0
  298. package/src/app/index.ts +605 -0
  299. package/src/common/index.ts +2 -0
  300. package/src/common/templates.ts +49 -0
  301. package/src/common/user_util.ts +16 -0
  302. package/src/document_templates/actions.ts +179 -0
  303. package/src/document_templates/editor.ts +177 -0
  304. package/src/document_templates/index.ts +2 -0
  305. package/src/document_templates/menu.ts +74 -0
  306. package/src/document_templates/overview.ts +335 -0
  307. package/src/document_templates/templates.ts +9 -0
  308. package/src/documents/importer/docx/import.ts +25 -0
  309. package/src/documents/importer/docx/index.ts +1 -0
  310. package/src/documents/importer/native/file.ts +112 -0
  311. package/src/documents/importer/native/import.ts +219 -0
  312. package/src/documents/importer/native/index.ts +2 -0
  313. package/src/documents/importer/odt/import.ts +26 -0
  314. package/src/documents/importer/odt/index.ts +1 -0
  315. package/src/documents/importer/pandoc/import.ts +57 -0
  316. package/src/documents/importer/pandoc/index.ts +1 -0
  317. package/src/documents/importer/register.ts +8 -0
  318. package/src/documents/overview/actions.ts +1031 -0
  319. package/src/documents/overview/index.ts +1006 -0
  320. package/src/documents/overview/menu.ts +311 -0
  321. package/src/documents/overview/templates.ts +64 -0
  322. package/src/documents/revisions/index.ts +183 -0
  323. package/src/documents/revisions/templates.ts +42 -0
  324. package/src/documents/tools.ts +107 -0
  325. package/src/error_hook/index.ts +129 -0
  326. package/src/feedback/index.ts +185 -0
  327. package/src/global.d.ts +22 -0
  328. package/src/index.ts +95 -0
  329. package/src/indexed_db/index.ts +217 -0
  330. package/src/maintenance/index.ts +258 -0
  331. package/src/menu/index.ts +267 -0
  332. package/src/menu/templates.ts +21 -0
  333. package/src/pages/404.ts +13 -0
  334. package/src/pages/flatpage.ts +43 -0
  335. package/src/pages/offline.ts +39 -0
  336. package/src/pages/setup.ts +34 -0
  337. package/src/plugins/menu/index.ts +3 -0
  338. package/src/prelogin/index.ts +175 -0
  339. package/src/prelogin/templates.ts +86 -0
  340. package/src/types.ts +63 -0
  341. package/src/user/auth/email_confirm.ts +153 -0
  342. package/src/user/auth/email_confirm_templates.ts +76 -0
  343. package/src/user/auth/login.ts +221 -0
  344. package/src/user/auth/password_reset_change.ts +120 -0
  345. package/src/user/auth/password_reset_request.ts +107 -0
  346. package/src/user/auth/signup.ts +182 -0
  347. package/src/user/auth/two_factor.ts +244 -0
  348. package/src/user/contacts/add_dialog.ts +104 -0
  349. package/src/user/contacts/delete_dialog.ts +40 -0
  350. package/src/user/contacts/index.ts +289 -0
  351. package/src/user/contacts/invite.ts +24 -0
  352. package/src/user/contacts/menu.ts +70 -0
  353. package/src/user/contacts/respond_invite.ts +76 -0
  354. package/src/user/contacts/templates.ts +29 -0
  355. package/src/user/profile/delete_user.ts +71 -0
  356. package/src/user/profile/dialogs.ts +363 -0
  357. package/src/user/profile/index.ts +359 -0
  358. package/src/user/profile/templates.ts +299 -0
  359. package/src/workers/adjust_doc_to_template.ts +41 -0
package/src/types.ts ADDED
@@ -0,0 +1,63 @@
1
+ export interface Email {
2
+ address: string
3
+ primary?: boolean
4
+ }
5
+
6
+ export interface User {
7
+ username: string
8
+ emails: Email[]
9
+ name?: string
10
+ avatar?: string
11
+ }
12
+
13
+ export interface Route {
14
+ app: string
15
+ [key: string]: unknown
16
+ }
17
+
18
+ export type RouteMap = Record<string, Route>
19
+
20
+ export interface Settings {
21
+ APPS: string[]
22
+ [key: string]: unknown
23
+ }
24
+
25
+ export interface SiteMenuLike {
26
+ app: App
27
+ navItems: NavItem[]
28
+ }
29
+
30
+ export interface NavItem {
31
+ text: string
32
+ url: string
33
+ title: string
34
+ id: string
35
+ order: number
36
+ keys?: string
37
+ active?: boolean
38
+ }
39
+
40
+ export interface MenuPluginExport {
41
+ new (siteMenu: SiteMenuLike): {init(): void}
42
+ }
43
+
44
+ export type MenuPlugin = Record<string, MenuPluginExport>
45
+
46
+ export type MenuPlugins = Array<[string, MenuPlugin]>
47
+
48
+ export interface App {
49
+ routes: RouteMap
50
+ goTo: (url: string) => void
51
+ settings: Settings
52
+ menuPlugins?: MenuPlugins
53
+ name?: string
54
+ }
55
+
56
+ export interface BaseBodyTemplateOptions {
57
+ user: User
58
+ contents: string
59
+ hasOverview?: boolean
60
+ app: App
61
+ }
62
+
63
+
@@ -0,0 +1,153 @@
1
+ import {
2
+ activateWait,
3
+ addAlert,
4
+ deactivateWait,
5
+ post,
6
+ postJson,
7
+ whenReady
8
+ } from "fwtoolkit"
9
+ import {PreloginPage} from "../../prelogin/index.js"
10
+ import {
11
+ checkTermsTemplate,
12
+ confirmAccountTemplate,
13
+ testServerQuestionTemplate,
14
+ verifiedAccountTemplate
15
+ } from "./email_confirm_templates.js"
16
+
17
+ export class EmailConfirm extends PreloginPage {
18
+ key: string
19
+ validKey: boolean
20
+ loggedIn: boolean
21
+ verified: boolean
22
+ username: string
23
+ email: string
24
+ submissionReady: boolean
25
+ formChecks: Array<() => boolean>
26
+ confirmQuestionsTemplates: Array<() => string>
27
+ confirmMethods: Array<() => Promise<unknown>>
28
+ firstVerification: boolean
29
+
30
+ constructor({app, language}: {app: any; language: string}, key: string) {
31
+ super({app, language})
32
+
33
+ this.title = gettext("Confirm Email")
34
+ this.pluginLoaders = []
35
+
36
+ this.key = key
37
+
38
+ this.validKey = false
39
+ this.loggedIn = false
40
+ this.verified = false
41
+ this.username = ""
42
+ this.email = ""
43
+
44
+ this.submissionReady = false
45
+ this.formChecks = []
46
+ this.confirmQuestionsTemplates = []
47
+ this.confirmMethods = [
48
+ () => post(`/api/user/confirm-email/${this.key}/`)
49
+ ]
50
+ this.firstVerification = false
51
+ }
52
+
53
+ init(): Promise<void> {
54
+ return Promise.all([whenReady(), this.getConfirmData()]).then(() => {
55
+ this.activateFidusPlugins()
56
+ this.render()
57
+ this.bind()
58
+ })
59
+ }
60
+
61
+ getConfirmData(): Promise<void> {
62
+ return postJson("/api/user/get_confirmkey_data/", {key: this.key})
63
+ .then(({json}: any) => {
64
+ this.username = json.username
65
+ this.email = json.email
66
+ this.validKey = true
67
+ this.verified = json.verified
68
+ this.firstVerification = !json.verified
69
+ if (json.logout) {
70
+ this.app.config.user = {is_authenticated: false}
71
+ }
72
+ })
73
+ .catch(() => {})
74
+ }
75
+
76
+ render(): void {
77
+ if (!this.verified) {
78
+ if (this.app.settings?.TEST_SERVER) {
79
+ this.formChecks.push(() =>
80
+ !!(document.getElementById("test-check") as HTMLInputElement)?.matches(
81
+ ":checked"
82
+ )
83
+ )
84
+ this.confirmQuestionsTemplates.unshift(testServerQuestionTemplate)
85
+ }
86
+ this.formChecks.push(() =>
87
+ !!(document.getElementById("terms-check") as HTMLInputElement)?.matches(
88
+ ":checked"
89
+ )
90
+ )
91
+ this.confirmQuestionsTemplates.unshift(checkTermsTemplate)
92
+ }
93
+ this.contents = confirmAccountTemplate({
94
+ validKey: this.validKey,
95
+ username: this.username,
96
+ verified: this.verified,
97
+ email: this.email,
98
+ confirmQuestionsTemplates: this.confirmQuestionsTemplates
99
+ })
100
+ super.render()
101
+ }
102
+
103
+ bind(): void {
104
+ super.bind()
105
+ if (!this.formChecks.length) {
106
+ const submitBtn = document.getElementById("submit")
107
+ if (submitBtn) submitBtn.removeAttribute("disabled")
108
+ this.submissionReady = true
109
+ }
110
+ document.querySelectorAll(".checker").forEach(el =>
111
+ el.addEventListener("click", () => {
112
+ if (this.formChecks.every(check => check())) {
113
+ const submitBtn = document.getElementById("submit")
114
+ if (submitBtn) submitBtn.removeAttribute("disabled")
115
+ this.submissionReady = true
116
+ } else {
117
+ const submitBtn = document.getElementById("submit")
118
+ if (submitBtn) submitBtn.setAttribute("disabled", "disabled")
119
+ this.submissionReady = false
120
+ }
121
+ })
122
+ )
123
+ const submissionButton = document.getElementById("submit")
124
+ if (submissionButton) {
125
+ submissionButton.addEventListener("click", () => {
126
+ if (!this.submissionReady) {
127
+ return
128
+ }
129
+ activateWait()
130
+ Promise.all(this.confirmMethods.map(method => method())).then(() => {
131
+ deactivateWait()
132
+ if ((this.app.config as any).user.is_authenticated) {
133
+ const emailObject = (this.app.config as any).user.emails.find(
134
+ (email: any) => email.address === this.email
135
+ )
136
+ if (emailObject) {
137
+ emailObject.verified = true
138
+ }
139
+ return (this.app.goTo("/user/profile/") as any)
140
+ .then(() =>
141
+ addAlert("info", gettext("Email verified!"))
142
+ )
143
+ } else {
144
+ const contentsDOM = document.querySelector(".fw-contents")
145
+ if (contentsDOM) {
146
+ contentsDOM.innerHTML = verifiedAccountTemplate()
147
+ }
148
+ }
149
+ })
150
+ })
151
+ }
152
+ }
153
+ }
@@ -0,0 +1,76 @@
1
+ /** A template for the confirm email/agree to terms page */
2
+ export const confirmAccountTemplate = ({
3
+ username,
4
+ email,
5
+ verified,
6
+ validKey,
7
+ confirmQuestionsTemplates
8
+ }: {
9
+ username: string
10
+ email: string
11
+ verified: boolean
12
+ validKey: boolean
13
+ confirmQuestionsTemplates: Array<() => string>
14
+ }): string =>
15
+ `<h1 class="fw-login-title">${verified ? gettext("Confirm E-mail Address") : gettext("Confirm E-mail Address and Agree to Terms and Conditions")}</h1>
16
+ ${validKey ? confirmAccountFormTemplate({username, email, verified, confirmQuestionsTemplates}) : expiredConfirmationLinkTemplate()}
17
+ `
18
+
19
+ const confirmAccountFormTemplate = ({
20
+ username,
21
+ email,
22
+ verified,
23
+ confirmQuestionsTemplates
24
+ }: {
25
+ username: string
26
+ email: string
27
+ verified: boolean
28
+ confirmQuestionsTemplates: Array<() => string>
29
+ }): string =>
30
+ `<p>${
31
+ verified
32
+ ? interpolate(
33
+ gettext(
34
+ 'Please confirm that you own the email <a href="mailto:%(email)s">%(email)s</a>.'
35
+ ),
36
+ {email},
37
+ true
38
+ )
39
+ : interpolate(
40
+ gettext(
41
+ 'Please confirm that you own the email <a href="mailto:%(email)s">%(email)s</a>, that you apply for the username %(username)s, and that you have read and agree to our <a href="/pages/terms/" target="_blank">Terms and Conditions</a> and <a href="/pages/privacy/" target="_blank">Privacy Policy</a>.'
42
+ ),
43
+ {email, username},
44
+ true
45
+ )
46
+ }</p>
47
+ <table>
48
+ ${confirmQuestionsTemplates.map(template => `<tr>${template()}</tr>`).join("")}
49
+ </table>
50
+ <p class="submit-wrapper">
51
+ <button type="submit" id="submit" disabled class="fw-button fw-orange fw-uppercase">${gettext("Confirm")}</button>
52
+ </p>
53
+ `
54
+
55
+ export const checkTermsTemplate = (): string =>
56
+ `<td>
57
+ <input type="checkbox" class="checker" id="terms-check">
58
+ </td><td>
59
+ ${gettext('I have read and agree to the <a href="/pages/terms/" target="_blank">Terms and Conditions</a>.')}
60
+ </td>`
61
+
62
+ export const testServerQuestionTemplate = (): string =>
63
+ `<td>
64
+ <input type="checkbox" class="checker" id="test-check">
65
+ </td><td>
66
+ ${gettext("I am aware that I am signing up for a test account and that service may be ended abruptly and without notice, leaving me without my files.")}
67
+ </td>`
68
+
69
+ const expiredConfirmationLinkTemplate = (): string =>
70
+ `<p>
71
+ ${gettext("This e-mail confirmation link expired or is invalid. Please try to open another account.")}
72
+ </p>`
73
+
74
+ export const verifiedAccountTemplate = (): string =>
75
+ `<h1>${gettext("Thanks for verifying!")}</h1>
76
+ <p>${gettext("You can now log in.")}</p>`
@@ -0,0 +1,221 @@
1
+ import {escapeText, postJson} from "fwtoolkit"
2
+ import {PreloginPage} from "../../prelogin/index.js"
3
+
4
+ export class LoginPage extends PreloginPage {
5
+ socialaccount_providers: Array<Record<string, unknown>>
6
+
7
+ constructor({
8
+ app,
9
+ language,
10
+ socialaccount_providers
11
+ }: {
12
+ app: any
13
+ language: string
14
+ socialaccount_providers: Array<Record<string, unknown>>
15
+ }) {
16
+ super({app, language})
17
+ this.socialaccount_providers = socialaccount_providers
18
+ this.title = gettext("Login")
19
+ this.pluginLoaders = []
20
+ this.headerLinks = (
21
+ this.app.settings?.REGISTRATION_OPEN &&
22
+ this.app.settings?.PASSWORD_LOGIN
23
+ ? [
24
+ {type: "label", text: gettext("New here?"), link: ""},
25
+ {
26
+ type: "button",
27
+ text: gettext("Sign up"),
28
+ link: "/account/sign-up/"
29
+ }
30
+ ]
31
+ : []) as any
32
+ }
33
+
34
+ render(): void {
35
+ this.contents = `<div class="fw-login-left">
36
+ <h1 class="fw-login-title">${gettext("Log in")}</h1>
37
+ ${
38
+ this.app.settings?.SOCIALACCOUNT_OPEN
39
+ ? this.socialaccount_providers.length
40
+ ? `<div class="socialaccount_ballot">
41
+ <ul class="socialaccount_providers">
42
+ ${this.socialaccount_providers
43
+ .map(
44
+ (provider: any) => `<li>
45
+ <a title="${provider.name}" class="fw-button fw-socialaccount fw-${provider.id}"
46
+ href="${provider.login_url}">
47
+ <span class="fab fa-${provider.id}"></span>
48
+ ${gettext("Login with")} ${provider.name}
49
+ </a>
50
+ </li>`
51
+ )
52
+ .join("")}
53
+ </ul>
54
+ </div>`
55
+ : ""
56
+ : ""
57
+ }
58
+ </div>
59
+ ${
60
+ this.app.settings?.PASSWORD_LOGIN
61
+ ? `<div class="fw-login-right">
62
+ <form>
63
+ <ul id="non-field-errors" class="fw-errorlist"></ul>
64
+ <div class="input-wrapper">
65
+ <label for="id-login">${gettext("Username")}</label>
66
+ <input type="text" name="login" placeholder="${gettext("Username or e-mail")}" autofocus="autofocus" required="" id="id-login" autocomplete="username">
67
+ <ul id="id-login-errors" class="fw-errorlist"></ul>
68
+ </div>
69
+ <div class="input-wrapper">
70
+ <label for="id-password">${gettext("Password")}</label>
71
+ <input type="password" name="password" placeholder="${gettext("Password")}" required="" id="id-password" autocomplete="current-password">
72
+ <ul id="id-password-errors" class="fw-errorlist"></ul>
73
+ </div>
74
+ <div class="submit-wrapper">
75
+ <button class="fw-button fw-dark fw-uppercase" type="submit" id="login-submit">${gettext("Log in")}</button>
76
+ <br>
77
+ <input type="checkbox" name="remember" id="id-remember">
78
+ <label for="id-remember">${gettext("Remember me")}</label>
79
+ </div>
80
+ <a id="lost-passwd" href="/account/password-reset/">${gettext("Forgot Password?")}</a>
81
+ </form>
82
+ </div>`
83
+ : ""
84
+ }`
85
+ super.render()
86
+ }
87
+
88
+ bind(): void {
89
+ super.bind()
90
+ const socialButtons = document.body.querySelectorAll(".fw-button.fw-socialaccount")
91
+ let btnWidth = 1
92
+
93
+ socialButtons.forEach((button: Element) => {
94
+ const theWidth = (button as HTMLElement).clientWidth
95
+ if (btnWidth < theWidth) {
96
+ btnWidth = theWidth
97
+ }
98
+ })
99
+ btnWidth += 15
100
+ socialButtons.forEach(button => ((button as HTMLElement).style.width = `${btnWidth}px`))
101
+
102
+ const loginSubmit = document.querySelector("#login-submit")
103
+ if (!loginSubmit) {
104
+ return
105
+ }
106
+
107
+ loginSubmit.addEventListener("click", (event: Event) => {
108
+ event.preventDefault()
109
+
110
+ const nonFieldErrors = document.querySelector("#non-field-errors")
111
+ const idLogin = document.querySelector("#id-login") as HTMLInputElement
112
+ const idLoginErrors = document.querySelector("#id-login-errors")
113
+ const idPassword = document.querySelector("#id-password") as HTMLInputElement
114
+ const idPasswordErrors = document.querySelector("#id-password-errors")
115
+ const idRemember = document.querySelector("#id-remember") as HTMLInputElement
116
+ const fwContents = document.querySelector(".fw-contents")
117
+
118
+ if (!idLogin || !idLoginErrors || !idPassword || !idPasswordErrors || !idRemember || !fwContents) {
119
+ return
120
+ }
121
+
122
+ nonFieldErrors!.innerHTML = ""
123
+ idLoginErrors.innerHTML = ""
124
+ idPasswordErrors.innerHTML = ""
125
+
126
+ const login = idLogin.value
127
+ const password = idPassword.value
128
+ const remember = idRemember.checked
129
+ let errors = false
130
+ if (!login.length) {
131
+ idLoginErrors.innerHTML = `<li>${gettext("This field is required.")}</li>`
132
+ errors = true
133
+ }
134
+ if (!password.length) {
135
+ idPasswordErrors.innerHTML = `<li>${gettext("This field is required.")}</li>`
136
+ errors = true
137
+ }
138
+ if (errors) {
139
+ return
140
+ }
141
+ return postJson("/api/user/login/", {login, password, remember})
142
+ .catch((response: any) => {
143
+ if (!(response instanceof Response) || response.status !== 400) {
144
+ return Promise.reject(response)
145
+ }
146
+ return response.json().then((json: any) => {
147
+ const needCode =
148
+ json.form.fields.twofactor.errors.includes("required")
149
+ if (
150
+ needCode &&
151
+ !json.form.errors.length &&
152
+ !json.form.fields.login.errors.length &&
153
+ !json.form.fields.password.errors.length
154
+ ) {
155
+ import("./two_factor.js").then(({twoFactorLoginDialog}) => {
156
+ twoFactorLoginDialog({
157
+ login,
158
+ password,
159
+ remember,
160
+ loginPage: this
161
+ })
162
+ })
163
+ } else {
164
+ json.form.errors.forEach(
165
+ (error: string) =>
166
+ (nonFieldErrors!.innerHTML += `<li>${escapeText(error)}</li>`)
167
+ )
168
+ json.form.fields.login.errors.forEach(
169
+ (error: string) =>
170
+ (idLoginErrors.innerHTML += `<li>${escapeText(error)}</li>`)
171
+ )
172
+ json.form.fields.password.errors.forEach(
173
+ (error: string) =>
174
+ (idPasswordErrors.innerHTML += `<li>${escapeText(error)}</li>`)
175
+ )
176
+ }
177
+
178
+ return {json, status: response.status}
179
+ })
180
+ })
181
+ .then((result: any) => {
182
+ if (!result) return
183
+ const {json, status} = result
184
+ if (status === 400) {
185
+ return
186
+ }
187
+ this.afterLogin(json)
188
+ })
189
+ })
190
+ }
191
+
192
+ afterLogin(json: any): void {
193
+ const currentLang = document.documentElement.lang
194
+ if (json.html && json.html.length > 0) {
195
+ const htmlValues = JSON.parse(json.html)
196
+
197
+ if (htmlValues.Location === "/api/account/confirm-email/") {
198
+ const contentsEl = document.querySelector(".fw-contents")
199
+ if (contentsEl) {
200
+ contentsEl.innerHTML = `<div class="fw-login-left">
201
+ <h1 class="fw-login-title">${gettext("Verify Your E-mail Address")}</h1>
202
+ <p>
203
+ ${gettext("We have sent an e-mail to your email address for verification. Follow the link provided to finalize the signup process.")}
204
+ <br />
205
+ ${gettext("Please contact us if you do not receive it within a few minutes.")}
206
+ </p>
207
+ </div>`
208
+ }
209
+ } else if (
210
+ htmlValues.user?.language &&
211
+ htmlValues.user?.language !== currentLang
212
+ ) {
213
+ window.location.reload()
214
+ } else {
215
+ ;(this.app as any).init()
216
+ }
217
+ } else {
218
+ ;(this.app as any).init()
219
+ }
220
+ }
221
+ }
@@ -0,0 +1,120 @@
1
+ import {escapeText, get, post} from "fwtoolkit"
2
+ import {PreloginPage} from "../../prelogin/index.js"
3
+
4
+ export class PasswordResetChangePassword extends PreloginPage {
5
+ key: string | false
6
+
7
+ constructor({app, language}: {app: any; language: string}, key: string | false = false) {
8
+ super({app, language})
9
+ this.title = gettext("Change Password")
10
+ this.key = key
11
+ }
12
+
13
+ render(): void {
14
+ this.contents = `<div class="fw-login-left">
15
+ <h1 class="fw-login-title">${gettext("Change password")}</h1>
16
+ <p>${gettext("You have indicated that you have forgotten your password. Please enter your new password in the form twice.")}</p>
17
+ </div>
18
+ <div class="fw-login-right">
19
+ <form>
20
+ <ul id="non-field-errors" class="fw-errorlist"></ul>
21
+ <div class="input-wrapper">
22
+ <label for="id-password1">${gettext("Create a password")}</label>
23
+ <input type="password" name="password1" placeholder="${gettext("Password")}" required="" id="id-password1" autocomplete="new-password">
24
+ <ul id="id-password1-errors" class="fw-errorlist"></ul>
25
+ </div>
26
+ <div class="input-wrapper">
27
+ <label for="id-password2">${gettext("Confirm your password")}</label>
28
+ <input type="password" name="password2" placeholder="${gettext("Password (again)")}" required="" id="id-password2" autocomplete="new-password">
29
+ <ul id="id-password2-errors" class="fw-errorlist"></ul>
30
+ </div>
31
+ <div class="submit-wrapper">
32
+ <button class="fw-button fw-dark fw-uppercase" id="change-password-submit" type="submit">${gettext("Change My Password")}</button>
33
+ </div>
34
+ </form>
35
+ </div>`
36
+ super.render()
37
+ }
38
+
39
+ bind(): void {
40
+ super.bind()
41
+
42
+ window.history.replaceState({}, "", "/account/change-password/")
43
+
44
+ const passwordInput = document.getElementById("id-password1")
45
+ if (passwordInput) {
46
+ passwordInput.focus()
47
+ }
48
+
49
+ const submitBtn = document.getElementById("change-password-submit")
50
+ if (submitBtn) {
51
+ submitBtn.addEventListener("click", (event: Event) => {
52
+ event.preventDefault()
53
+ const nonFieldErrors = document.querySelector("#non-field-errors")!
54
+ const pwd1Errors = document.querySelector("#id-password1-errors")!
55
+ const pwd2Errors = document.querySelector("#id-password2-errors")!
56
+ nonFieldErrors.innerHTML = ""
57
+ pwd1Errors.innerHTML = ""
58
+ pwd2Errors.innerHTML = ""
59
+
60
+ const password1 = (document.getElementById("id-password1") as HTMLInputElement).value
61
+ const password2 = (document.getElementById("id-password2") as HTMLInputElement).value
62
+ let errors = false
63
+ if (!password1.length) {
64
+ pwd1Errors.innerHTML = `<li>${gettext("This field is required.")}</li>`
65
+ errors = true
66
+ }
67
+ if (!password2.length) {
68
+ pwd2Errors.innerHTML = `<li>${gettext("This field is required.")}</li>`
69
+ errors = true
70
+ }
71
+ if (password1 !== password2) {
72
+ pwd2Errors.innerHTML = `<li>${gettext("You must type the same password each time.")}</li>`
73
+ errors = true
74
+ }
75
+
76
+ if (errors) {
77
+ return
78
+ }
79
+ get(`/api/account/password/reset/key/${this.key}/`)
80
+ .then((response: any) => {
81
+ return post(response.url, {password1, password2})
82
+ })
83
+ .then(() => {
84
+ if (document.body !== this.dom) {
85
+ return
86
+ }
87
+ const contentsEl = document.querySelector(".fw-contents")
88
+ if (contentsEl) {
89
+ contentsEl.innerHTML = `<div class="fw-login-left">
90
+ <h1 class="fw-login-title">${gettext("Password reset")}</h1>
91
+ <p>
92
+ ${gettext("Your password has been reset and you can now log in with the new password.")}
93
+ </p>
94
+ </div>`
95
+ }
96
+ })
97
+ .catch((response: any) =>
98
+ response.json().then((json: any) => {
99
+ json.form.errors.forEach(
100
+ (error: string) =>
101
+ (nonFieldErrors.innerHTML += `<li>${escapeText(error)}</li>`)
102
+ )
103
+ if (json.form.fields.password1) {
104
+ json.form.fields.password1.errors.forEach(
105
+ (error: string) =>
106
+ (pwd1Errors.innerHTML += `<li>${escapeText(error)}</li>`)
107
+ )
108
+ }
109
+ if (json.form.fields.password2) {
110
+ json.form.fields.password2.errors.forEach(
111
+ (error: string) =>
112
+ (pwd2Errors.innerHTML += `<li>${escapeText(error)}</li>`)
113
+ )
114
+ }
115
+ })
116
+ )
117
+ })
118
+ }
119
+ }
120
+ }