@fiduswriter/frontend 0.1.24 → 0.1.26

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 (57) hide show
  1. package/dist/api/index.d.ts +9 -3
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/app/index.d.ts.map +1 -1
  4. package/dist/app/index.js +10 -4
  5. package/dist/app/index.js.map +1 -1
  6. package/dist/document_templates/editor.js +1 -1
  7. package/dist/document_templates/editor.js.map +1 -1
  8. package/dist/document_templates/overview.js +1 -1
  9. package/dist/document_templates/overview.js.map +1 -1
  10. package/dist/documents/overview/index.js +1 -1
  11. package/dist/documents/overview/index.js.map +1 -1
  12. package/dist/documents/overview/menu.d.ts.map +1 -1
  13. package/dist/documents/overview/menu.js +6 -2
  14. package/dist/documents/overview/menu.js.map +1 -1
  15. package/dist/feedback/index.d.ts +2 -1
  16. package/dist/feedback/index.d.ts.map +1 -1
  17. package/dist/feedback/index.js +7 -4
  18. package/dist/feedback/index.js.map +1 -1
  19. package/dist/indexed_db/index.d.ts +1 -1
  20. package/dist/indexed_db/index.d.ts.map +1 -1
  21. package/dist/indexed_db/index.js +23 -8
  22. package/dist/indexed_db/index.js.map +1 -1
  23. package/dist/menu/index.js +5 -2
  24. package/dist/menu/index.js.map +1 -1
  25. package/dist/prelogin/index.js +1 -1
  26. package/dist/prelogin/index.js.map +1 -1
  27. package/dist/types.d.ts +1 -0
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/user/auth/password_reset_change.d.ts +2 -2
  30. package/dist/user/auth/password_reset_change.d.ts.map +1 -1
  31. package/dist/user/auth/password_reset_change.js +6 -6
  32. package/dist/user/auth/password_reset_change.js.map +1 -1
  33. package/dist/user/contacts/index.js +1 -1
  34. package/dist/user/contacts/index.js.map +1 -1
  35. package/dist/user/profile/delete_user.d.ts +2 -1
  36. package/dist/user/profile/delete_user.d.ts.map +1 -1
  37. package/dist/user/profile/delete_user.js +7 -3
  38. package/dist/user/profile/delete_user.js.map +1 -1
  39. package/dist/user/profile/index.d.ts.map +1 -1
  40. package/dist/user/profile/index.js +2 -2
  41. package/dist/user/profile/index.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/api/index.ts +9 -1
  44. package/src/app/index.ts +9 -4
  45. package/src/document_templates/editor.ts +1 -1
  46. package/src/document_templates/overview.ts +1 -1
  47. package/src/documents/overview/index.ts +1 -1
  48. package/src/documents/overview/menu.ts +7 -2
  49. package/src/feedback/index.ts +7 -4
  50. package/src/indexed_db/index.ts +29 -8
  51. package/src/menu/index.ts +8 -8
  52. package/src/prelogin/index.ts +1 -1
  53. package/src/types.ts +1 -0
  54. package/src/user/auth/password_reset_change.ts +11 -7
  55. package/src/user/contacts/index.ts +1 -1
  56. package/src/user/profile/delete_user.ts +8 -4
  57. package/src/user/profile/index.ts +3 -2
@@ -1,4 +1,4 @@
1
- import {ensureCSS, post} from "fwtoolkit"
1
+ import {ensureCSS} from "fwtoolkit"
2
2
 
3
3
  // Creates the feedback tab. The tab is meant for user feedback to the developers while FW is still in
4
4
  // a somewhat early stage. It is included in a way so it's easy to remove from all the templates.
@@ -6,9 +6,11 @@ import {ensureCSS, post} from "fwtoolkit"
6
6
 
7
7
  export class FeedbackTab {
8
8
  previousActiveElement: HTMLElement | null
9
+ app: any
9
10
 
10
- constructor() {
11
+ constructor(app?: any) {
11
12
  this.previousActiveElement = null
13
+ this.app = app
12
14
  }
13
15
 
14
16
  init(): void {
@@ -114,13 +116,14 @@ export class FeedbackTab {
114
116
  closeFeedbackEl.style.display = "none"
115
117
  feedbackFormEl.style.visibility = "hidden"
116
118
 
117
- post("/api/feedback/feedback/", {message: messageEl.value})
119
+ ;(this.app as any).apiConnectors.feedback
120
+ .send({message: messageEl.value})
118
121
  .then(() => {
119
122
  messageEl.value = ""
120
123
  closeFeedbackEl.style.display = "block"
121
124
  responseEl.style.display = "block"
122
125
  })
123
- .catch(_error => {
126
+ .catch((_error: Error) => {
124
127
  messageEl.value = ""
125
128
  closeFeedbackEl.style.display = "block"
126
129
  })
@@ -1,5 +1,5 @@
1
1
  // Changing this number will make clients flush their database.
2
- const DB_VERSION = 4
2
+ const DB_VERSION = 5
3
3
 
4
4
  interface DbTableProperties {
5
5
  keyPath?: string
@@ -62,19 +62,40 @@ export class IndexedDB {
62
62
  }
63
63
  }
64
64
 
65
- updateData(objectStoreName: string, data: Record<string, unknown>): void {
65
+ updateData(
66
+ objectStoreName: string,
67
+ data: Record<string, unknown>,
68
+ retry: boolean = true
69
+ ): void {
66
70
  const request = window.indexedDB.open(this.dbName, DB_VERSION)
67
71
  request.onerror = (event: Event) => {
68
- this.reset(event).then(() => this.updateData(objectStoreName, data))
72
+ this.reset(event).then(() => this.updateData(objectStoreName, data, false))
69
73
  }
70
74
 
71
75
  request.onsuccess = (event: Event) => {
72
76
  const db = (event.target as IDBOpenDBRequest).result
73
- const objectStore = db
74
- .transaction(objectStoreName, "readwrite")
75
- .objectStore(objectStoreName)
76
- for (const d in data) {
77
- objectStore.put(d)
77
+ try {
78
+ const objectStore = db
79
+ .transaction(objectStoreName, "readwrite")
80
+ .objectStore(objectStoreName)
81
+ for (const d in data) {
82
+ objectStore.put(d)
83
+ }
84
+ } catch (error) {
85
+ // Before resetting IndexedDB make sure to close connections to
86
+ // avoid blocking the delete IndexedDB process
87
+ db.close()
88
+ if (
89
+ retry &&
90
+ error instanceof DOMException &&
91
+ error.name === "NotFoundError"
92
+ ) {
93
+ this.reset().then(() =>
94
+ this.updateData(objectStoreName, data, false)
95
+ )
96
+ } else {
97
+ throw error
98
+ }
78
99
  }
79
100
  }
80
101
 
package/src/menu/index.ts CHANGED
@@ -209,14 +209,14 @@ export class SiteMenu implements SiteMenuLike {
209
209
  sessionStorage.removeItem(key)
210
210
  }
211
211
  }
212
- import("fwtoolkit/network").then(({post}) =>
213
- post("/api/user/logout/").then(() => {
214
- window.location.href =
215
- this.app.routes[""].app === "document"
216
- ? "/"
217
- : "/documents/"
218
- })
219
- )
212
+ ;(this.app.apiConnectors as any).auth
213
+ .logout()
214
+ .then(() => {
215
+ window.location.href =
216
+ this.app.routes[""].app === "document"
217
+ ? "/"
218
+ : "/documents/"
219
+ })
220
220
  break
221
221
  }
222
222
  }
@@ -169,7 +169,7 @@ export class PreloginPage {
169
169
  document.body = this.dom
170
170
  ensureCSS([staticUrl("css/prelogin.css")])
171
171
  setDocTitle(this.title, this.app)
172
- const feedbackTab = new FeedbackTab()
172
+ const feedbackTab = new FeedbackTab(this.app)
173
173
  feedbackTab.init()
174
174
  }
175
175
  }
package/src/types.ts CHANGED
@@ -50,6 +50,7 @@ export interface App {
50
50
  goTo: (url: string) => void
51
51
  settings: Settings
52
52
  menuPlugins?: MenuPlugins
53
+ apiConnectors?: Record<string, any>
53
54
  name?: string
54
55
  }
55
56
 
@@ -1,10 +1,10 @@
1
- import {escapeText, get, post} from "fwtoolkit"
1
+ import {escapeText} from "fwtoolkit"
2
2
  import {PreloginPage} from "../../prelogin/index.js"
3
3
 
4
4
  export class PasswordResetChangePassword extends PreloginPage {
5
- key: string | false
5
+ key: string
6
6
 
7
- constructor({app, language}: {app: any; language: string}, key: string | false = false) {
7
+ constructor({app, language}: {app: any; language: string}, key: string) {
8
8
  super({app, language})
9
9
  this.title = gettext("Change Password")
10
10
  this.key = key
@@ -76,10 +76,14 @@ export class PasswordResetChangePassword extends PreloginPage {
76
76
  if (errors) {
77
77
  return
78
78
  }
79
- get(`/api/account/password/reset/key/${this.key}/`)
80
- .then((response: any) => {
81
- return post(response.url, {password1, password2})
82
- })
79
+ ;(this.app as any).apiConnectors.auth
80
+ .passwordResetKeyGet(this.key)
81
+ .then(({url}: {url: string}) =>
82
+ (this.app as any).apiConnectors.auth.passwordResetKeyPost(
83
+ url,
84
+ {password1, password2}
85
+ )
86
+ )
83
87
  .then(() => {
84
88
  if (document.body !== this.dom) {
85
89
  return
@@ -62,7 +62,7 @@ export class ContactsOverview {
62
62
  })
63
63
  document.body = this.dom
64
64
  setDocTitle(gettext("Contacts"), this.app)
65
- const feedbackTab = new FeedbackTab()
65
+ const feedbackTab = new FeedbackTab(this.app)
66
66
  feedbackTab.init()
67
67
  }
68
68
 
@@ -1,12 +1,14 @@
1
- import {Dialog, activateWait, addAlert, deactivateWait, postBare} from "fwtoolkit"
1
+ import {Dialog, activateWait, addAlert, deactivateWait} from "fwtoolkit"
2
2
  import {deleteUserDialogTemplate} from "./templates.js"
3
3
 
4
4
  export class DeleteUserDialog {
5
5
  username: string
6
+ app: any
6
7
  dialog: any
7
8
 
8
- constructor(username: string) {
9
+ constructor(username: string, app: any) {
9
10
  this.username = username
11
+ this.app = app
10
12
  }
11
13
 
12
14
  init(): void {
@@ -45,8 +47,10 @@ export class DeleteUserDialog {
45
47
  deleteCurrentUser(password: string): void {
46
48
  activateWait()
47
49
 
48
- postBare("/api/user/delete/", {password}).then((response: Response) => {
49
- switch (response.status) {
50
+ this.app.apiConnectors.userProfile
51
+ .deleteUser({password})
52
+ .then((response: Response) => {
53
+ switch (response.status) {
50
54
  case 200:
51
55
  window.location.href = "/"
52
56
  break
@@ -53,7 +53,8 @@ export class Profile {
53
53
  changePwdDialog({username: this.user.username, app: this.app}),
54
54
  "#delete-account": (_el, _event) => {
55
55
  const dialog = new DeleteUserDialog(
56
- (this.dom.querySelector("#delete-account") as HTMLElement).dataset.username!
56
+ (this.dom.querySelector("#delete-account") as HTMLElement).dataset.username!,
57
+ this.app
57
58
  )
58
59
  dialog.init()
59
60
  },
@@ -175,7 +176,7 @@ export class Profile {
175
176
  ])
176
177
 
177
178
  setDocTitle(gettext("Configure profile"), this.app)
178
- const feedbackTab = new FeedbackTab()
179
+ const feedbackTab = new FeedbackTab(this.app)
179
180
  feedbackTab.init()
180
181
  }
181
182