qcobjectsnewapp 2.5.22-ts → 2.5.24-ts

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 (30) hide show
  1. package/VERSION +1 -1
  2. package/package.json +1 -1
  3. package/public/js/init.js +20 -20
  4. package/public/js/init.js.map +3 -3
  5. package/public/js/packages/com.qcobjects.installer.js +15 -15
  6. package/public/js/packages/com.qcobjects.installer.js.map +3 -3
  7. package/public/js/packages/com.qcobjects.services.github.js +4 -4
  8. package/public/js/packages/com.qcobjects.services.github.js.map +3 -3
  9. package/public/js/packages/com.qcobjects.services.newapp.js +4 -4
  10. package/public/js/packages/com.qcobjects.services.newapp.js.map +3 -3
  11. package/public/js/packages/org.quickcorp.custom.components.js +8 -8
  12. package/public/js/packages/org.quickcorp.custom.components.js.map +2 -2
  13. package/public/js/packages/org.quickcorp.custom.controllers.js +16 -16
  14. package/public/js/packages/org.quickcorp.custom.controllers.js.map +3 -3
  15. package/public/js/packages/org.quickcorp.custom.effects.js +4 -4
  16. package/public/js/packages/org.quickcorp.custom.effects.js.map +3 -3
  17. package/public/js/packages/org.quickcorp.custom.js +20 -20
  18. package/public/js/packages/org.quickcorp.custom.js.map +3 -3
  19. package/public/js/packages/org.quickcorp.custom.models.js +4 -4
  20. package/public/js/packages/org.quickcorp.custom.models.js.map +3 -3
  21. package/public/js/packages/org.quickcorp.custom.views.js +4 -4
  22. package/public/js/packages/org.quickcorp.custom.views.js.map +3 -3
  23. package/src/js/packages/com.qcobjects.installer.ts +83 -81
  24. package/src/js/packages/com.qcobjects.services.github.ts +173 -148
  25. package/src/js/packages/com.qcobjects.services.newapp.ts +20 -18
  26. package/src/js/packages/org.quickcorp.custom.components.ts +5 -7
  27. package/src/js/packages/org.quickcorp.custom.controllers.ts +115 -111
  28. package/src/js/packages/org.quickcorp.custom.effects.ts +23 -21
  29. package/src/js/packages/org.quickcorp.custom.models.ts +12 -11
  30. package/src/js/packages/org.quickcorp.custom.views.ts +13 -12
@@ -3,96 +3,98 @@
3
3
  import { InheritClass, Package, logger, set, get } from "qcobjects";
4
4
  import { NotificationComponent } from "qcobjects-sdk";
5
5
 
6
- Package("com.qcobjects.installer", [
7
- class Installer extends InheritClass {
8
- root: Element;
9
- promptEvent!: HTMLElement;
6
+ export class Installer extends InheritClass {
7
+ root: Element;
8
+ promptEvent!: HTMLElement;
10
9
 
11
- /**
12
- * Creates an instance of Installer.
13
- * @date 18/04/2023 - 22:27:17
14
- *
15
- * @constructor
16
- * @param {HTMLElement} root
17
- */
18
- constructor (root: HTMLElement) {
19
- super();
10
+ /**
11
+ * Creates an instance of Installer.
12
+ * @date 18/04/2023 - 22:27:17
13
+ *
14
+ * @constructor
15
+ * @param {HTMLElement} root
16
+ */
17
+ constructor(root: HTMLElement) {
18
+ super();
20
19
 
21
- this.root = root;
22
- window.addEventListener("beforeinstallprompt", () => this.beforeinstallprompt.bind(this), false);
23
- window.addEventListener("appinstalled", () => this.installed.bind(this), false);
20
+ this.root = root;
21
+ window.addEventListener("beforeinstallprompt", () => this.beforeinstallprompt.bind(this), false);
22
+ window.addEventListener("appinstalled", () => this.installed.bind(this), false);
24
23
 
25
- root.addEventListener("click", () => this.install.bind(this));
26
- root.addEventListener("touchend", () => this.install.bind(this));
24
+ root.addEventListener("click", () => this.install.bind(this));
25
+ root.addEventListener("touchend", () => this.install.bind(this));
27
26
 
28
- window.matchMedia("(display-mode: standalone)").addEventListener("change", (evt) => {
29
- let displayMode = "browser";
30
- if (evt.matches) {
31
- displayMode = "standalone";
32
- }
33
- NotificationComponent.success(`TWA in ${displayMode} Mode`);
34
- });
35
- set("installer", this);
36
- }
27
+ window.matchMedia("(display-mode: standalone)").addEventListener("change", (evt) => {
28
+ let displayMode = "browser";
29
+ if (evt.matches) {
30
+ displayMode = "standalone";
31
+ }
32
+ NotificationComponent.success(`TWA in ${displayMode} Mode`);
33
+ });
34
+ set("installer", this);
35
+ }
37
36
 
38
- /**
39
- * It is executed before the install prompt event
40
- * @date 18/04/2023 - 22:27:30
41
- *
42
- * @param {Event} e
43
- * @returns {boolean}
44
- */
45
- beforeinstallprompt (e: Event) {
46
- logger.debug("registering installer event");
47
- e.preventDefault();
48
- set("promptEvent", e);
49
- this.root.classList.add("available");
50
- return false;
51
- }
37
+ /**
38
+ * It is executed before the install prompt event
39
+ * @date 18/04/2023 - 22:27:30
40
+ *
41
+ * @param {Event} e
42
+ * @returns {boolean}
43
+ */
44
+ beforeinstallprompt(e: Event) {
45
+ logger.debug("registering installer event");
46
+ e.preventDefault();
47
+ set("promptEvent", e);
48
+ this.root.classList.add("available");
49
+ return false;
50
+ }
52
51
 
53
- /**
54
- * it works after the install event
55
- * @date 18/04/2023 - 22:28:36
56
- */
57
- installed () {
58
- logger.debug("app is already installed");
59
- set("promptEvent", null);
60
- // This fires after onbeforinstallprompt OR after manual add to homescreen.
61
- this.root.classList.remove("available");
62
- }
52
+ /**
53
+ * it works after the install event
54
+ * @date 18/04/2023 - 22:28:36
55
+ */
56
+ installed() {
57
+ logger.debug("app is already installed");
58
+ set("promptEvent", null);
59
+ // This fires after onbeforinstallprompt OR after manual add to homescreen.
60
+ this.root.classList.remove("available");
61
+ }
63
62
 
64
- /**
65
- * it executes the install after the button click
66
- * @date 18/04/2023 - 22:29:11
67
- */
68
- install () {
69
- const root = this.root;
70
- logger.debug("installer actioned");
71
- let promptEvent = get("promptEvent", null);
72
- if (promptEvent) {
73
- logger.debug("prompt event");
63
+ /**
64
+ * it executes the install after the button click
65
+ * @date 18/04/2023 - 22:29:11
66
+ */
67
+ install() {
68
+ const root = this.root;
69
+ logger.debug("installer actioned");
70
+ let promptEvent = get("promptEvent", null);
71
+ if (promptEvent) {
72
+ logger.debug("prompt event");
74
73
 
75
- promptEvent.prompt();
76
- promptEvent.userChoice
77
- .then(function (choiceResult: { outcome: string }) {
78
- if (choiceResult.outcome === "accepted") {
79
- // The user actioned the prompt (good or bad).
80
- // good is handled in
81
- root.classList.remove("available");
82
- } else {
83
- logger.debug("User has chosen not to install the PWA");
84
- }
85
- promptEvent = null;
86
- })
87
- .catch(function (installError: { toString: () => string }) {
88
- // Boo. update the UI.
89
- promptEvent = null;
74
+ promptEvent.prompt();
75
+ promptEvent.userChoice
76
+ .then(function (choiceResult: { outcome: string }) {
77
+ if (choiceResult.outcome === "accepted") {
78
+ // The user actioned the prompt (good or bad).
79
+ // good is handled in
90
80
  root.classList.remove("available");
91
- logger.warn(`Error during install: ${installError.toString()}`);
92
- });
93
- } else {
94
- logger.debug("It is not possible to get the prompt event for install ");
95
- }
81
+ } else {
82
+ logger.debug("User has chosen not to install the PWA");
83
+ }
84
+ promptEvent = null;
85
+ })
86
+ .catch(function (installError: { toString: () => string }) {
87
+ // Boo. update the UI.
88
+ promptEvent = null;
89
+ root.classList.remove("available");
90
+ logger.warn(`Error during install: ${installError.toString()}`);
91
+ });
92
+ } else {
93
+ logger.debug("It is not possible to get the prompt event for install ");
96
94
  }
97
95
  }
96
+ }
97
+
98
+ Package("com.qcobjects.installer", [
99
+ Installer
98
100
  ]);
@@ -33,156 +33,181 @@ type ItemProject = {
33
33
  };
34
34
  type ItemsProject = Array<ItemProject>;
35
35
 
36
- Package("com.qcobjects.services.github", [
37
- class GitHubService extends JSONService {
38
- /**
39
- * Name of the service
40
- * @date 18/04/2023 - 22:30:07
41
- *
42
- * @type {string}
43
- */
44
- name = "myservice";
45
-
46
- /**
47
- * It specifies if the service has a external url. If true, you can pass absolute urls in url property
48
- * @date 18/04/2023 - 22:30:37
49
- *
50
- * @type {boolean}
51
- */
52
- external = true;
53
-
54
- /**
55
- * If it is true, the service call will be cached
56
- * @date 18/04/2023 - 22:31:41
57
- *
58
- * @type {boolean}
59
- */
60
- cached = false;
61
-
62
- /**
63
- * It can be GET, POST, PUT
64
- * @date 18/04/2023 - 22:32:29
65
- *
66
- * @type {string}
67
- */
68
- method = "GET";
69
-
70
- /**
71
- * You can add special headers using this property
72
- * @date 18/04/2023 - 22:33:20
73
- *
74
- * @type {{ "Content-Type": string; }}
75
- */
76
- headers = { "Content-Type": "application/json" };
77
-
78
- /**
79
- * URL for the service call
80
- * @date 18/04/2023 - 22:34:09
81
- *
82
- * @type {string}
83
- */
84
- url = "https://api.github.com/orgs/QuickCorp/repos";
85
-
86
- /**
87
- * This is used internally for XHR requests. Default value is false.
88
- * @date 18/04/2023 - 22:34:29
89
- *
90
- * @type {boolean}
91
- */
92
- withCredentials = false;
93
-
94
- /**
95
- * It is called once the service call is done
96
- * @param param0 this param has two properties, one is the native request call (XHR or Fetch object). The second property is the service object.
97
- * @returns Promise
98
- */
99
- done({ request, service }: StandardResponse) {
100
-
101
- const result:ItemsProject = (JSON.parse(service.template as string) as Array<Project>)
102
- .reverse().map(function (project: Project) {
103
- return {
104
- id: project.id,
105
- description: project.description,
106
- title: project.name,
107
- url: project.html_url,
108
- repo_stargazers_count: project.stargazers_count,
109
- repo_watchers_count: project.watchers_count
110
- };
111
- });
112
-
113
- service.template = JSON.stringify({
114
- result
115
- });
116
- return super.done({ request, service });
117
- }
118
- },
119
-
120
- class GitHubTagService extends JSONService {
121
- name = "myservice";
122
- external = true;
123
- cached = false;
124
- method = "GET";
125
- headers = { "Content-Type": "application/json" };
126
- url = "https://api.github.com/search/repositories?q=qcobjects";
127
- withCredentials = false;
128
-
129
- done({ request, service }: StandardResponse) {
130
- logger.debug(String(request));
131
- const result:ItemsProject = (JSON.parse(service.template as string) as GitHubTagServiceResponse)
132
- .items.map(function (project: Project) {
133
- return {
134
- id: project.id,
135
- description: project.description,
136
- title: project.name,
137
- url: project.html_url,
138
- repo_stargazers_count: project.stargazers_count,
139
- repo_watchers_count: project.watchers_count
140
- };
141
- });
142
-
143
- service.template = JSON.stringify({
144
- result
145
- });
146
- return super.done({ request, service });
147
- }
148
- },
149
-
150
- class QCObjectsVersionService extends Service {
151
- name = "qcobjects_version_service";
152
- external = true;
153
- cached = false;
154
- method = "GET";
155
- headers = { "Content-Type": "application/json" };
156
- url = "https://api.github.com/repos/QuickCorp/QCObjects/tags";
157
- withCredentials = false;
158
-
159
- done({ service }: StandardResponse) {
160
- const latest = JSON.parse(service.template as string)[0];
161
- service.template = {
162
- version: latest.name
36
+ export class GitHubService extends JSONService {
37
+ /**
38
+ * Name of the service
39
+ * @date 18/04/2023 - 22:30:07
40
+ *
41
+ * @type {string}
42
+ */
43
+ name = "myservice";
44
+
45
+ /**
46
+ * It specifies if the service has a external url. If true, you can pass absolute urls in url property
47
+ * @date 18/04/2023 - 22:30:37
48
+ *
49
+ * @type {boolean}
50
+ */
51
+ external = true;
52
+
53
+ /**
54
+ * If it is true, the service call will be cached
55
+ * @date 18/04/2023 - 22:31:41
56
+ *
57
+ * @type {boolean}
58
+ */
59
+ cached = false;
60
+
61
+ /**
62
+ * It can be GET, POST, PUT
63
+ * @date 18/04/2023 - 22:32:29
64
+ *
65
+ * @type {string}
66
+ */
67
+ method = "GET";
68
+
69
+ /**
70
+ * You can add special headers using this property
71
+ * @date 18/04/2023 - 22:33:20
72
+ *
73
+ * @type {{ "Content-Type": string; }}
74
+ */
75
+ headers = { "Content-Type": "application/json", "charset": "utf-8" };
76
+
77
+ /**
78
+ * URL for the service call
79
+ * @date 18/04/2023 - 22:34:09
80
+ *
81
+ * @type {string}
82
+ */
83
+ url = "https://api.github.com/orgs/QuickCorp/repos";
84
+
85
+ /**
86
+ * This is used internally for XHR requests. Default value is false.
87
+ * @date 18/04/2023 - 22:34:29
88
+ *
89
+ * @type {boolean}
90
+ */
91
+ withCredentials = false;
92
+
93
+ constructor() {
94
+ super();
95
+ // Remove charset header to avoid CORS preflight issues with external APIs
96
+ // (charset is not a CORS-safelisted request header)
97
+ delete this.headers.charset;
98
+ }
99
+
100
+ /**
101
+ * It is called once the service call is done
102
+ * @param param0 this param has two properties, one is the native request call (XHR or Fetch object). The second property is the service object.
103
+ * @returns Promise
104
+ */
105
+ done({ request, service }: StandardResponse) {
106
+
107
+ const result:ItemsProject = (JSON.parse(service.template as string) as Array<Project>)
108
+ .reverse().map(function (project: Project) {
109
+ return {
110
+ id: project.id,
111
+ description: project.description,
112
+ title: project.name,
113
+ url: project.html_url,
114
+ repo_stargazers_count: project.stargazers_count,
115
+ repo_watchers_count: project.watchers_count
163
116
  };
164
- }
165
-
166
- },
167
-
168
- class QCObjectsStarsForksService extends Service {
169
- name = "qcobjects_stars_forks_service";
170
- external = true;
171
- cached = false;
172
- method = "GET";
173
- headers = { "Content-Type": "application/json" };
174
- url = "https://api.github.com/repos/QuickCorp/QCObjects";
175
- withCredentials = false;
176
-
177
- done({ service }: StandardResponse) {
178
- const repo:Project = (JSON.parse(service.template as string) as Project);
179
- service.template = {
180
- forks: repo.forks_count,
181
- stars: repo.stargazers_count,
182
- watchers: repo.watchers_count,
183
- size: Math.round(repo.size / 1000)
117
+ });
118
+
119
+ service.template = JSON.stringify({
120
+ result
121
+ });
122
+ return super.done({ request, service });
123
+ }
124
+ }
125
+
126
+ export class GitHubTagService extends JSONService {
127
+ name = "myservice";
128
+ external = true;
129
+ cached = false;
130
+ method = "GET";
131
+ headers = { "Content-Type": "application/json", "charset": "utf-8" };
132
+ url = "https://api.github.com/search/repositories?q=qcobjects";
133
+ withCredentials = false;
134
+
135
+ constructor() {
136
+ super();
137
+ delete this.headers.charset;
138
+ }
139
+
140
+ done({ request, service }: StandardResponse) {
141
+ logger.debug(String(request));
142
+ const result:ItemsProject = (JSON.parse(service.template as string) as GitHubTagServiceResponse)
143
+ .items.map(function (project: Project) {
144
+ return {
145
+ id: project.id,
146
+ description: project.description,
147
+ title: project.name,
148
+ url: project.html_url,
149
+ repo_stargazers_count: project.stargazers_count,
150
+ repo_watchers_count: project.watchers_count
184
151
  };
185
- }
152
+ });
153
+
154
+ service.template = JSON.stringify({
155
+ result
156
+ });
157
+ return super.done({ request, service });
158
+ }
159
+ }
160
+
161
+ export class QCObjectsVersionService extends Service {
162
+ name = "qcobjects_version_service";
163
+ external = true;
164
+ cached = false;
165
+ method = "GET";
166
+ headers = { "Content-Type": "application/json", "charset": "utf-8" };
167
+ url = "https://api.github.com/repos/QuickCorp/QCObjects/tags";
168
+ withCredentials = false;
169
+
170
+ constructor() {
171
+ super();
172
+ delete this.headers.charset;
173
+ }
174
+
175
+ done({ service }: StandardResponse) {
176
+ const latest = JSON.parse(service.template as string)[0];
177
+ service.template = {
178
+ version: latest.name
179
+ };
180
+ }
181
+ }
186
182
 
183
+ export class QCObjectsStarsForksService extends Service {
184
+ name = "qcobjects_stars_forks_service";
185
+ external = true;
186
+ cached = false;
187
+ method = "GET";
188
+ headers = { "Content-Type": "application/json", "charset": "utf-8" };
189
+ url = "https://api.github.com/repos/QuickCorp/QCObjects";
190
+ withCredentials = false;
191
+
192
+ constructor() {
193
+ super();
194
+ delete this.headers.charset;
187
195
  }
196
+
197
+ done({ service }: StandardResponse) {
198
+ const repo:Project = (JSON.parse(service.template as string) as Project);
199
+ service.template = {
200
+ forks: repo.forks_count,
201
+ stars: repo.stargazers_count,
202
+ watchers: repo.watchers_count,
203
+ size: Math.round(repo.size / 1000)
204
+ };
205
+ }
206
+ }
207
+
208
+ Package("com.qcobjects.services.github", [
209
+ GitHubService,
210
+ GitHubTagService,
211
+ QCObjectsVersionService,
212
+ QCObjectsStarsForksService
188
213
  ]);
@@ -7,25 +7,27 @@ type StandardResponse = {
7
7
  service: Service;
8
8
  };
9
9
 
10
- Package("com.qcobjects.services.newapp", [
11
- class AdminCheckService extends Service {
12
-
13
- url = "/admin";
14
-
15
- done (standardResponse:StandardResponse){
16
- const hasAdmin = (template:string) => {
17
- return (/<base href="\/admin\/" target="_self">/).test(template);
18
- };
19
- standardResponse.service.template = _DataStringify({
20
- hasAdmin: hasAdmin(standardResponse.service.template as unknown as string)
21
- });
22
- }
10
+ export class AdminCheckService extends Service {
11
+
12
+ url = "/admin";
23
13
 
24
- fail (standardResponse:StandardResponse){
25
- standardResponse.service.template = _DataStringify({
26
- hasAdmin: false
27
- });
28
- }
14
+ done (standardResponse:StandardResponse){
15
+ const hasAdmin = (template:string) => {
16
+ return (/<base href="\/admin\/" target="_self">/).test(template);
17
+ };
18
+ standardResponse.service.template = _DataStringify({
19
+ hasAdmin: hasAdmin(standardResponse.service.template as unknown as string)
20
+ });
21
+ }
29
22
 
23
+ fail (standardResponse:StandardResponse){
24
+ standardResponse.service.template = _DataStringify({
25
+ hasAdmin: false
26
+ });
30
27
  }
28
+
29
+ }
30
+
31
+ Package("com.qcobjects.services.newapp", [
32
+ AdminCheckService
31
33
  ]);
@@ -6,7 +6,7 @@ type ComponentServiceData = Component & {
6
6
  serviceData:any;
7
7
  }
8
8
 
9
- class GitHubGrid extends Component {
9
+ export class GitHubGrid extends Component {
10
10
  name = "github-grid";
11
11
  tplsource = "inline";
12
12
  template = `
@@ -23,7 +23,7 @@ class GitHubGrid extends Component {
23
23
  `;
24
24
  }
25
25
 
26
- class DeployGrid extends Component {
26
+ export class DeployGrid extends Component {
27
27
  name = "deploygrid";
28
28
  template = `
29
29
  <style>
@@ -46,7 +46,7 @@ class DeployGrid extends Component {
46
46
  `;
47
47
  }
48
48
 
49
- class AdminCheckComponent extends Component {
49
+ export class AdminCheckComponent extends Component {
50
50
  shadowed = true;
51
51
  tplsource = "inline";
52
52
 
@@ -58,7 +58,7 @@ class AdminCheckComponent extends Component {
58
58
 
59
59
  }
60
60
 
61
- class AdminSidebarOption extends AdminCheckComponent {
61
+ export class AdminSidebarOption extends AdminCheckComponent {
62
62
  name = "admin-sidebar-option";
63
63
  template = `
64
64
  <style>
@@ -141,7 +141,7 @@ class AdminSidebarOption extends AdminCheckComponent {
141
141
  }
142
142
  }
143
143
 
144
- class AdminButton extends AdminCheckComponent {
144
+ export class AdminButton extends AdminCheckComponent {
145
145
  name = "admin-button";
146
146
  template = `
147
147
  <style>
@@ -186,10 +186,8 @@ class AdminButton extends AdminCheckComponent {
186
186
  }
187
187
  return super.done(standardResponse);
188
188
  }
189
-
190
189
  }
191
190
 
192
-
193
191
  Package("org.quickcorp.custom.components", [
194
192
  AdminButton,
195
193
  AdminSidebarOption,