glib-web 0.5.98 → 0.6.2
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.
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/action.js +167 -167
- package/actions/analytics/logEvent.js +0 -0
- package/actions/auth/creditCard.js +0 -0
- package/actions/auth/restart.js +0 -0
- package/actions/auth/saveCsrfToken.js +0 -0
- package/actions/cables/push.js +0 -0
- package/actions/dialogs/alert.js +0 -0
- package/actions/dialogs/notification.js +0 -0
- package/actions/dialogs/oauth.js +0 -0
- package/actions/dialogs/open.js +0 -0
- package/actions/dialogs/options.js +0 -0
- package/actions/dialogs/show.js +0 -0
- package/actions/forms/submit.js +0 -0
- package/actions/http/delete.js +0 -0
- package/actions/http/patch.js +0 -0
- package/actions/http/post.js +0 -0
- package/actions/http/put.js +0 -0
- package/actions/panels/scrollTo.js +18 -18
- package/actions/panels/scrollToBottom.js +0 -0
- package/actions/runMultiple.js +0 -0
- package/actions/sheets/select.js +0 -0
- package/actions/snackbars/alert.js +0 -0
- package/actions/snackbars/select.js +0 -0
- package/actions/timeouts/set.js +20 -20
- package/actions/windows/close.js +0 -0
- package/actions/windows/closeAll.js +0 -0
- package/actions/windows/closeWithReload.js +0 -0
- package/actions/windows/open.js +0 -0
- package/actions/windows/openWeb.js +0 -0
- package/actions/windows/refreshState.js +5 -5
- package/actions/windows/reload.js +0 -0
- package/actions/ws/push.js +0 -0
- package/app.vue +180 -180
- package/components/_badge.vue +23 -23
- package/components/_button.vue +107 -107
- package/components/_dropdownMenu.vue +76 -76
- package/components/_icon.vue +50 -50
- package/components/_message.vue +0 -0
- package/components/avatar.vue +18 -18
- package/components/banners/alert.vue +0 -0
- package/components/banners/select.vue +82 -82
- package/components/button.vue +33 -40
- package/components/calendar.vue +0 -0
- package/components/charts/column.vue +47 -34
- package/components/charts/line.vue +67 -65
- package/components/chip.vue +51 -26
- package/components/component.vue +225 -225
- package/components/datetime.vue +0 -0
- package/components/fab.vue +0 -0
- package/components/fields/_patternText.vue +65 -65
- package/components/fields/_select.vue +86 -86
- package/components/fields/autocomplete.vue +73 -73
- package/components/fields/check.vue +91 -81
- package/components/fields/checkGroup.vue +58 -58
- package/components/fields/country/countries.js +0 -0
- package/components/fields/country/field.vue +0 -0
- package/components/fields/country/regions.js +0 -0
- package/components/fields/creditCard.vue +22 -13
- package/components/fields/date.vue +24 -24
- package/components/fields/datetime.vue +0 -0
- package/components/fields/dynamicGroup.vue +0 -0
- package/components/fields/dynamicSelect.vue +0 -0
- package/components/fields/file.vue +0 -0
- package/components/fields/googlePlace.vue +0 -0
- package/components/fields/hidden.vue +0 -0
- package/components/fields/location.vue +198 -198
- package/components/fields/newRichText.vue +0 -0
- package/components/fields/phone/countries.js +315 -315
- package/components/fields/phone/field.vue +351 -351
- package/components/fields/phone/sprite.css +1071 -1071
- package/components/fields/radio.vue +16 -16
- package/components/fields/radioGroup.vue +42 -42
- package/components/fields/rating.vue +0 -0
- package/components/fields/richText.vue +0 -0
- package/components/fields/select.vue +17 -17
- package/components/fields/stripe/stripeFields.vue +93 -93
- package/components/fields/stripe/stripeIndividualFields.vue +207 -207
- package/components/fields/stripeExternalAccount.vue +135 -135
- package/components/fields/text.vue +0 -0
- package/components/fields/textarea.vue +0 -0
- package/components/fields/timeZone.vue +22 -22
- package/components/fields/timer.vue +83 -83
- package/components/h1.vue +28 -28
- package/components/h2.vue +28 -20
- package/components/h3.vue +29 -22
- package/components/h4.vue +28 -20
- package/components/h5.vue +28 -20
- package/components/h6.vue +28 -20
- package/components/hr.vue +0 -0
- package/components/html.vue +0 -0
- package/components/icon.vue +25 -25
- package/components/image.vue +0 -0
- package/components/label.vue +62 -62
- package/components/map.vue +0 -0
- package/components/markdown.vue +0 -0
- package/components/mixins/{chart.js → chart/annotation.js} +73 -73
- package/components/mixins/chart/tooltip.js +31 -0
- package/components/mixins/events.js +178 -178
- package/components/mixins/generic.js +0 -0
- package/components/mixins/list/autoload.js +0 -0
- package/components/mixins/longClick.js +0 -0
- package/components/mixins/scrolling.js +0 -0
- package/components/mixins/styles.js +222 -222
- package/components/mixins/table/autoload.js +0 -0
- package/components/mixins/table/export.js +0 -0
- package/components/mixins/table/import.js +0 -0
- package/components/mixins/text.js +20 -20
- package/components/mixins/tooltip.js +11 -0
- package/components/mixins/ws/actionCable.js +48 -48
- package/components/mixins/ws/phoenixSocket.js +0 -0
- package/components/p.vue +0 -0
- package/components/panels/carousel.vue +55 -55
- package/components/panels/column.vue +0 -0
- package/components/panels/custom.vue +0 -0
- package/components/panels/flow.vue +81 -81
- package/components/panels/form.vue +130 -130
- package/components/panels/horizontal.vue +0 -0
- package/components/panels/list.vue +247 -247
- package/components/panels/responsive.vue +94 -94
- package/components/panels/scroll.vue +0 -0
- package/components/panels/split.vue +0 -0
- package/components/panels/table.vue +0 -0
- package/components/panels/ul.vue +34 -34
- package/components/panels/vertical.vue +0 -0
- package/components/panels/web.vue +11 -11
- package/components/progressbar.vue +36 -36
- package/components/spacer.vue +0 -0
- package/components/switch.vue +42 -42
- package/components/tabBar.vue +68 -68
- package/extensions/array.js +0 -0
- package/extensions/string.js +21 -21
- package/index.js +199 -199
- package/keys.js +0 -0
- package/nav/appbar.vue +136 -136
- package/nav/content.vue +0 -0
- package/nav/dialog.vue +127 -127
- package/nav/drawer.vue +105 -105
- package/nav/drawerButton.vue +31 -31
- package/nav/drawerLabel.vue +0 -0
- package/nav/sheet.vue +0 -0
- package/nav/snackbar.vue +0 -0
- package/package.json +44 -44
- package/settings.json.example +0 -0
- package/static/plugins/alignment/alignment.js +0 -0
- package/static/plugins/alignment/alignment.min.js +0 -0
- package/static/plugins/beyondgrammar/beyondgrammar.js +0 -0
- package/static/plugins/beyondgrammar/beyondgrammar.min.js +0 -0
- package/static/plugins/blockcode/blockcode.js +0 -0
- package/static/plugins/blockcode/blockcode.min.js +0 -0
- package/static/plugins/clips/clips.js +0 -0
- package/static/plugins/clips/clips.min.js +0 -0
- package/static/plugins/counter/counter.js +0 -0
- package/static/plugins/counter/counter.min.js +0 -0
- package/static/plugins/definedlinks/definedlinks.js +0 -0
- package/static/plugins/definedlinks/definedlinks.min.js +0 -0
- package/static/plugins/handle/handle.js +0 -0
- package/static/plugins/handle/handle.min.js +0 -0
- package/static/plugins/icons/icons.js +0 -0
- package/static/plugins/icons/icons.min.js +0 -0
- package/static/plugins/imageposition/imageposition.js +0 -0
- package/static/plugins/imageposition/imageposition.min.js +0 -0
- package/static/plugins/inlineformat/inlineformat.js +0 -0
- package/static/plugins/inlineformat/inlineformat.min.js +0 -0
- package/static/plugins/removeformat/removeformat.js +0 -0
- package/static/plugins/removeformat/removeformat.min.js +0 -0
- package/static/plugins/selector/selector.js +0 -0
- package/static/plugins/selector/selector.min.js +0 -0
- package/static/plugins/specialchars/specialchars.js +0 -0
- package/static/plugins/specialchars/specialchars.min.js +0 -0
- package/static/plugins/textdirection/textdirection.js +0 -0
- package/static/plugins/textdirection/textdirection.min.js +0 -0
- package/static/plugins/textexpander/textexpander.js +0 -0
- package/static/plugins/textexpander/textexpander.min.js +0 -0
- package/static/plugins/underline/underline.js +0 -0
- package/static/plugins/underline/underline.min.js +0 -0
- package/static/redactorx.css +0 -0
- package/static/redactorx.js +0 -0
- package/static/redactorx.min.css +0 -0
- package/static/redactorx.min.js +0 -0
- package/static/redactorx.usm.min.js +0 -0
- package/styles/test.sass +0 -0
- package/styles/test.scss +0 -0
- package/templates/_menu.vue +38 -38
- package/templates/comment.vue +202 -202
- package/templates/featured.vue +32 -32
- package/templates/thumbnail.vue +145 -145
- package/templates/unsupported.vue +12 -12
- package/utils/app.js +0 -0
- package/utils/dom.js +0 -0
- package/utils/form.js +0 -0
- package/utils/hash.js +0 -0
- package/utils/helper.js +0 -0
- package/utils/history.js +70 -70
- package/utils/http.js +209 -209
- package/utils/launch.js +135 -135
- package/utils/private/ws.js +0 -0
- package/utils/public.js +0 -0
- package/utils/settings.js +0 -0
- package/utils/storage.js +0 -0
- package/utils/type.js +0 -0
- package/utils/uploader.js +0 -0
- package/utils/url.js +136 -136
package/utils/http.js
CHANGED
|
@@ -1,209 +1,209 @@
|
|
|
1
|
-
import Type from "./type";
|
|
2
|
-
import Action from "../action";
|
|
3
|
-
|
|
4
|
-
let loading = false;
|
|
5
|
-
|
|
6
|
-
class HttpRequest {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.controller = new AbortController();
|
|
9
|
-
this.canceled = false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
cancel() {
|
|
13
|
-
this.canceled = true;
|
|
14
|
-
this.controller.abort();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default class {
|
|
19
|
-
static _extractFormData(properties, needCsrfToken) {
|
|
20
|
-
// if (properties["formDataEncoded"]) {
|
|
21
|
-
// return properties["formData"];
|
|
22
|
-
// }
|
|
23
|
-
|
|
24
|
-
const data = properties.formData;
|
|
25
|
-
if (data instanceof FormData) {
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const formData = new FormData();
|
|
30
|
-
var params = data || {};
|
|
31
|
-
for (const key in params) {
|
|
32
|
-
formData.append(key, params[key]);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (needCsrfToken && !Type.isString(params["authenticity_token"])) {
|
|
36
|
-
formData.append("authenticity_token", Utils.dom.getCsrf());
|
|
37
|
-
}
|
|
38
|
-
return formData;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static load(properties, target, component) {
|
|
42
|
-
const url = new URL(properties["url"]);
|
|
43
|
-
const domainMatched = window.location.hostname == url.hostname;
|
|
44
|
-
if (Utils.settings.reactive && domainMatched) {
|
|
45
|
-
const currentUrl = window.location.href;
|
|
46
|
-
const htmlUrl = Utils.url.htmlUrl(properties["url"]);
|
|
47
|
-
|
|
48
|
-
Utils.http.execute(properties, "GET", component, (data, response) => {
|
|
49
|
-
if (htmlUrl !== currentUrl) {
|
|
50
|
-
const redirectUrl = Utils.url.htmlUrl(response.url);
|
|
51
|
-
Utils.history.pushPage(data, redirectUrl);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this.forceComponentUpdate(() => {
|
|
55
|
-
Utils.history.resetScroll();
|
|
56
|
-
window.vueApp.page = data;
|
|
57
|
-
Action.execute(properties["onOpen"], target, component);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
} else {
|
|
61
|
-
window.location = Utils.url.htmlUrl(properties["url"]);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static analyticsHeaders(component) {
|
|
66
|
-
const pageAnalytics =
|
|
67
|
-
window.vueApp.temp.analytics || window.vueApp.page.analytics || {};
|
|
68
|
-
const featureAnalytics = pageAnalytics.feature;
|
|
69
|
-
|
|
70
|
-
const headers = {};
|
|
71
|
-
if (featureAnalytics) {
|
|
72
|
-
const componentAnalytics = component.spec.analytics || {};
|
|
73
|
-
if (componentAnalytics.disabled) {
|
|
74
|
-
return headers;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
Utils.type.ifString(
|
|
78
|
-
componentAnalytics.group || featureAnalytics.group,
|
|
79
|
-
value => (headers["GApp-Analytics-Referer-Group"] = value)
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
Utils.type.ifString(
|
|
83
|
-
componentAnalytics.action || featureAnalytics.action,
|
|
84
|
-
value => (headers["GApp-Analytics-Referer-Action"] = value)
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
Utils.type.ifString(
|
|
88
|
-
componentAnalytics.segment || featureAnalytics.segment,
|
|
89
|
-
value => (headers["GApp-Analytics-Referer-Segment"] = value)
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
Utils.type.ifString(
|
|
93
|
-
componentAnalytics.placement,
|
|
94
|
-
value => (headers["GApp-Analytics-Referer-Placement"] = value)
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
return headers;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
static reload(properties, component) {
|
|
101
|
-
const currentUrl = window.location.href;
|
|
102
|
-
const data = {
|
|
103
|
-
url: properties.url || currentUrl
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
Utils.http.execute(data, "GET", component, (page, response) => {
|
|
107
|
-
Utils.http.forceComponentUpdate(() => {
|
|
108
|
-
window.vueApp.page = page;
|
|
109
|
-
const redirectUrl = Utils.url.htmlUrl(response.url);
|
|
110
|
-
Utils.history.updatePage(redirectUrl);
|
|
111
|
-
|
|
112
|
-
GLib.action.execute(properties["onReload"], null, component);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
static execute(properties, methodName, component, jsonHandler) {
|
|
118
|
-
this.startIndicator(component);
|
|
119
|
-
|
|
120
|
-
// `fetch()` only supports uppercase
|
|
121
|
-
const method = methodName.toUpperCase();
|
|
122
|
-
let url = Utils.url.jsonUrl(properties["url"]);
|
|
123
|
-
let body = this._extractFormData(properties, method !== "GET");
|
|
124
|
-
if (method === "GET") {
|
|
125
|
-
url = Utils.url.appendParams(url, body);
|
|
126
|
-
body = null;
|
|
127
|
-
}
|
|
128
|
-
console.log(`${method} ${url}`);
|
|
129
|
-
|
|
130
|
-
const request = new HttpRequest();
|
|
131
|
-
let response = null;
|
|
132
|
-
const vm = this;
|
|
133
|
-
|
|
134
|
-
const analyticsHeaders = this.analyticsHeaders(component);
|
|
135
|
-
|
|
136
|
-
fetch(url, {
|
|
137
|
-
method: method,
|
|
138
|
-
body: body,
|
|
139
|
-
headers: Object.assign({ Accept: "text/html" }, analyticsHeaders),
|
|
140
|
-
// Make sure to pass cookies for same origin URLs.
|
|
141
|
-
// Needed for some browsers, e.g. Edge and Android's native.
|
|
142
|
-
credentials: "same-origin",
|
|
143
|
-
signal: request.controller.signal
|
|
144
|
-
})
|
|
145
|
-
.then(res => {
|
|
146
|
-
vm.stopIndicator(component);
|
|
147
|
-
|
|
148
|
-
if (res.status >= 500) {
|
|
149
|
-
throw "Server error";
|
|
150
|
-
} else if (res.status >= 400) {
|
|
151
|
-
throw "Not accessible";
|
|
152
|
-
} else {
|
|
153
|
-
response = res;
|
|
154
|
-
return res.json();
|
|
155
|
-
}
|
|
156
|
-
})
|
|
157
|
-
.then(data => {
|
|
158
|
-
console.debug("Success", data);
|
|
159
|
-
jsonHandler(data, response);
|
|
160
|
-
})
|
|
161
|
-
.catch(error => {
|
|
162
|
-
vm.stopIndicator(component);
|
|
163
|
-
if (!request.canceled) {
|
|
164
|
-
console.error("Error:", error);
|
|
165
|
-
Utils.launch.snackbar.error(error);
|
|
166
|
-
} else {
|
|
167
|
-
console.info("Canceled");
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
return request;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
static startIndicator(component) {
|
|
175
|
-
this._showIndicator();
|
|
176
|
-
component.$data._isBusy = true;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
static stopIndicator(component) {
|
|
180
|
-
this._hideIndicator();
|
|
181
|
-
component.$data._isBusy = false;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
static _showIndicator() {
|
|
185
|
-
loading = true;
|
|
186
|
-
setTimeout(() => {
|
|
187
|
-
if (loading) {
|
|
188
|
-
loading = false;
|
|
189
|
-
window.vueApp.indicator = true;
|
|
190
|
-
}
|
|
191
|
-
}, 200);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
static _hideIndicator() {
|
|
195
|
-
loading = false;
|
|
196
|
-
window.vueApp.indicator = false;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// See generic.js
|
|
200
|
-
static forceComponentUpdate(handler) {
|
|
201
|
-
window.vueApp.isStale = true;
|
|
202
|
-
|
|
203
|
-
// Queue the execution so the first isStale has time to resets state before handler gets executed
|
|
204
|
-
setTimeout(() => {
|
|
205
|
-
handler();
|
|
206
|
-
window.vueApp.isStale = false;
|
|
207
|
-
}, 0);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
1
|
+
import Type from "./type";
|
|
2
|
+
import Action from "../action";
|
|
3
|
+
|
|
4
|
+
let loading = false;
|
|
5
|
+
|
|
6
|
+
class HttpRequest {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.controller = new AbortController();
|
|
9
|
+
this.canceled = false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
cancel() {
|
|
13
|
+
this.canceled = true;
|
|
14
|
+
this.controller.abort();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default class {
|
|
19
|
+
static _extractFormData(properties, needCsrfToken) {
|
|
20
|
+
// if (properties["formDataEncoded"]) {
|
|
21
|
+
// return properties["formData"];
|
|
22
|
+
// }
|
|
23
|
+
|
|
24
|
+
const data = properties.formData;
|
|
25
|
+
if (data instanceof FormData) {
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const formData = new FormData();
|
|
30
|
+
var params = data || {};
|
|
31
|
+
for (const key in params) {
|
|
32
|
+
formData.append(key, params[key]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (needCsrfToken && !Type.isString(params["authenticity_token"])) {
|
|
36
|
+
formData.append("authenticity_token", Utils.dom.getCsrf());
|
|
37
|
+
}
|
|
38
|
+
return formData;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static load(properties, target, component) {
|
|
42
|
+
const url = new URL(properties["url"]);
|
|
43
|
+
const domainMatched = window.location.hostname == url.hostname;
|
|
44
|
+
if (Utils.settings.reactive && domainMatched) {
|
|
45
|
+
const currentUrl = window.location.href;
|
|
46
|
+
const htmlUrl = Utils.url.htmlUrl(properties["url"]);
|
|
47
|
+
|
|
48
|
+
Utils.http.execute(properties, "GET", component, (data, response) => {
|
|
49
|
+
if (htmlUrl !== currentUrl) {
|
|
50
|
+
const redirectUrl = Utils.url.htmlUrl(response.url);
|
|
51
|
+
Utils.history.pushPage(data, redirectUrl);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.forceComponentUpdate(() => {
|
|
55
|
+
Utils.history.resetScroll();
|
|
56
|
+
window.vueApp.page = data;
|
|
57
|
+
Action.execute(properties["onOpen"], target, component);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
window.location = Utils.url.htmlUrl(properties["url"]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static analyticsHeaders(component) {
|
|
66
|
+
const pageAnalytics =
|
|
67
|
+
window.vueApp.temp.analytics || window.vueApp.page.analytics || {};
|
|
68
|
+
const featureAnalytics = pageAnalytics.feature;
|
|
69
|
+
|
|
70
|
+
const headers = {};
|
|
71
|
+
if (featureAnalytics) {
|
|
72
|
+
const componentAnalytics = component.spec.analytics || {};
|
|
73
|
+
if (componentAnalytics.disabled) {
|
|
74
|
+
return headers;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
Utils.type.ifString(
|
|
78
|
+
componentAnalytics.group || featureAnalytics.group,
|
|
79
|
+
value => (headers["GApp-Analytics-Referer-Group"] = value)
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
Utils.type.ifString(
|
|
83
|
+
componentAnalytics.action || featureAnalytics.action,
|
|
84
|
+
value => (headers["GApp-Analytics-Referer-Action"] = value)
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
Utils.type.ifString(
|
|
88
|
+
componentAnalytics.segment || featureAnalytics.segment,
|
|
89
|
+
value => (headers["GApp-Analytics-Referer-Segment"] = value)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
Utils.type.ifString(
|
|
93
|
+
componentAnalytics.placement,
|
|
94
|
+
value => (headers["GApp-Analytics-Referer-Placement"] = value)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return headers;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static reload(properties, component) {
|
|
101
|
+
const currentUrl = window.location.href;
|
|
102
|
+
const data = {
|
|
103
|
+
url: properties.url || currentUrl
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
Utils.http.execute(data, "GET", component, (page, response) => {
|
|
107
|
+
Utils.http.forceComponentUpdate(() => {
|
|
108
|
+
window.vueApp.page = page;
|
|
109
|
+
const redirectUrl = Utils.url.htmlUrl(response.url);
|
|
110
|
+
Utils.history.updatePage(redirectUrl);
|
|
111
|
+
|
|
112
|
+
GLib.action.execute(properties["onReload"], null, component);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static execute(properties, methodName, component, jsonHandler) {
|
|
118
|
+
this.startIndicator(component);
|
|
119
|
+
|
|
120
|
+
// `fetch()` only supports uppercase
|
|
121
|
+
const method = methodName.toUpperCase();
|
|
122
|
+
let url = Utils.url.jsonUrl(properties["url"]);
|
|
123
|
+
let body = this._extractFormData(properties, method !== "GET");
|
|
124
|
+
if (method === "GET") {
|
|
125
|
+
url = Utils.url.appendParams(url, body);
|
|
126
|
+
body = null;
|
|
127
|
+
}
|
|
128
|
+
console.log(`${method} ${url}`);
|
|
129
|
+
|
|
130
|
+
const request = new HttpRequest();
|
|
131
|
+
let response = null;
|
|
132
|
+
const vm = this;
|
|
133
|
+
|
|
134
|
+
const analyticsHeaders = this.analyticsHeaders(component);
|
|
135
|
+
|
|
136
|
+
fetch(url, {
|
|
137
|
+
method: method,
|
|
138
|
+
body: body,
|
|
139
|
+
headers: Object.assign({ Accept: "text/html" }, analyticsHeaders),
|
|
140
|
+
// Make sure to pass cookies for same origin URLs.
|
|
141
|
+
// Needed for some browsers, e.g. Edge and Android's native.
|
|
142
|
+
credentials: "same-origin",
|
|
143
|
+
signal: request.controller.signal
|
|
144
|
+
})
|
|
145
|
+
.then(res => {
|
|
146
|
+
vm.stopIndicator(component);
|
|
147
|
+
|
|
148
|
+
if (res.status >= 500) {
|
|
149
|
+
throw "Server error";
|
|
150
|
+
} else if (res.status >= 400) {
|
|
151
|
+
throw "Not accessible";
|
|
152
|
+
} else {
|
|
153
|
+
response = res;
|
|
154
|
+
return res.json();
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
.then(data => {
|
|
158
|
+
console.debug("Success", data);
|
|
159
|
+
jsonHandler(data, response);
|
|
160
|
+
})
|
|
161
|
+
.catch(error => {
|
|
162
|
+
vm.stopIndicator(component);
|
|
163
|
+
if (!request.canceled) {
|
|
164
|
+
console.error("Error:", error);
|
|
165
|
+
Utils.launch.snackbar.error(error);
|
|
166
|
+
} else {
|
|
167
|
+
console.info("Canceled");
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return request;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static startIndicator(component) {
|
|
175
|
+
this._showIndicator();
|
|
176
|
+
component.$data._isBusy = true;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
static stopIndicator(component) {
|
|
180
|
+
this._hideIndicator();
|
|
181
|
+
component.$data._isBusy = false;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static _showIndicator() {
|
|
185
|
+
loading = true;
|
|
186
|
+
setTimeout(() => {
|
|
187
|
+
if (loading) {
|
|
188
|
+
loading = false;
|
|
189
|
+
window.vueApp.indicator = true;
|
|
190
|
+
}
|
|
191
|
+
}, 200);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
static _hideIndicator() {
|
|
195
|
+
loading = false;
|
|
196
|
+
window.vueApp.indicator = false;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// See generic.js
|
|
200
|
+
static forceComponentUpdate(handler) {
|
|
201
|
+
window.vueApp.isStale = true;
|
|
202
|
+
|
|
203
|
+
// Queue the execution so the first isStale has time to resets state before handler gets executed
|
|
204
|
+
setTimeout(() => {
|
|
205
|
+
handler();
|
|
206
|
+
window.vueApp.isStale = false;
|
|
207
|
+
}, 0);
|
|
208
|
+
}
|
|
209
|
+
}
|
package/utils/launch.js
CHANGED
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import Vue from "vue";
|
|
2
|
-
import Dialog from "../nav/dialog";
|
|
3
|
-
import Sheet from "../nav/sheet";
|
|
4
|
-
import Snackbar from "../nav/snackbar";
|
|
5
|
-
import Vuetify from "vuetify";
|
|
6
|
-
|
|
7
|
-
export default class {
|
|
8
|
-
static dialog(properties, target) {
|
|
9
|
-
if (!this.stack) {
|
|
10
|
-
this.stack = [];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// https://css-tricks.com/creating-vue-js-component-instances-programmatically/
|
|
14
|
-
const DialogClass = Vue.extend(Dialog);
|
|
15
|
-
const instance = new DialogClass({
|
|
16
|
-
vuetify: new Vuetify({
|
|
17
|
-
theme: {
|
|
18
|
-
themes: Utils.settings.themes
|
|
19
|
-
}
|
|
20
|
-
}),
|
|
21
|
-
propsData: {
|
|
22
|
-
spec: properties,
|
|
23
|
-
stack: this.stack,
|
|
24
|
-
target: target,
|
|
25
|
-
vueApp: window.vueApp
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
// instance.stack = this.stack;
|
|
29
|
-
|
|
30
|
-
const placeholder = document.body.appendChild(
|
|
31
|
-
document.createElement("div")
|
|
32
|
-
);
|
|
33
|
-
instance.$mount(placeholder);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static closeDialog(properties, target, component) {
|
|
37
|
-
if (!this.stack) {
|
|
38
|
-
this.stack = [];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
Utils.type.ifObject(this.stack.last(), dialog => {
|
|
42
|
-
dialog.close();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
Utils.type.ifObject(properties["onClose"], it => {
|
|
46
|
-
Action.execute(it, target, component);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static get sheet() {
|
|
51
|
-
return LaunchSheet;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static get snackbar() {
|
|
55
|
-
return LaunchSnackbar;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static alert(message, target) {
|
|
59
|
-
const properties = {
|
|
60
|
-
message: message
|
|
61
|
-
};
|
|
62
|
-
const spec = Object.assign({}, properties, {
|
|
63
|
-
buttons: [
|
|
64
|
-
{
|
|
65
|
-
text: "OK",
|
|
66
|
-
onClick: properties.onClose
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
});
|
|
70
|
-
this.dialog(spec, target);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
class LaunchSheet {
|
|
75
|
-
static open(properties) {
|
|
76
|
-
const SheetClass = Vue.extend(Sheet);
|
|
77
|
-
const instance = new SheetClass({
|
|
78
|
-
vuetify: new Vuetify({
|
|
79
|
-
theme: {
|
|
80
|
-
themes: Utils.settings.themes
|
|
81
|
-
}
|
|
82
|
-
}),
|
|
83
|
-
propsData: { spec: properties }
|
|
84
|
-
});
|
|
85
|
-
const placeholder = document.body.appendChild(
|
|
86
|
-
document.createElement("div")
|
|
87
|
-
);
|
|
88
|
-
instance.$mount(placeholder);
|
|
89
|
-
// instance.show = true
|
|
90
|
-
return instance;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
static confirm(properties, onConfirm) {
|
|
94
|
-
const spec = Object.assign({}, properties, {
|
|
95
|
-
buttons: [
|
|
96
|
-
{
|
|
97
|
-
text: "Confirm",
|
|
98
|
-
onClickFunction: onConfirm
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
});
|
|
102
|
-
this.open(spec);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
static alert(message, buttons) {
|
|
106
|
-
const spec = { message: message, buttons: buttons };
|
|
107
|
-
this.open(spec);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
class LaunchSnackbar {
|
|
112
|
-
static open(properties) {
|
|
113
|
-
const SnackbarClass = Vue.extend(Snackbar);
|
|
114
|
-
const instance = new SnackbarClass({
|
|
115
|
-
vuetify: window.vueApp.vuetify,
|
|
116
|
-
propsData: { spec: properties, vueApp: window.vueApp }
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const placeholder = document.body.appendChild(
|
|
120
|
-
document.createElement("div")
|
|
121
|
-
);
|
|
122
|
-
instance.$mount(placeholder);
|
|
123
|
-
instance.show = true;
|
|
124
|
-
return instance;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
static error(message) {
|
|
128
|
-
this.open({ message: message, styleClasses: ["error"] });
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
static indicator(message) {
|
|
132
|
-
const instance = this.open({ message: message, timeout: -1 });
|
|
133
|
-
instance.indicator = true;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
1
|
+
import Vue from "vue";
|
|
2
|
+
import Dialog from "../nav/dialog";
|
|
3
|
+
import Sheet from "../nav/sheet";
|
|
4
|
+
import Snackbar from "../nav/snackbar";
|
|
5
|
+
import Vuetify from "vuetify";
|
|
6
|
+
|
|
7
|
+
export default class {
|
|
8
|
+
static dialog(properties, target) {
|
|
9
|
+
if (!this.stack) {
|
|
10
|
+
this.stack = [];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// https://css-tricks.com/creating-vue-js-component-instances-programmatically/
|
|
14
|
+
const DialogClass = Vue.extend(Dialog);
|
|
15
|
+
const instance = new DialogClass({
|
|
16
|
+
vuetify: new Vuetify({
|
|
17
|
+
theme: {
|
|
18
|
+
themes: Utils.settings.themes
|
|
19
|
+
}
|
|
20
|
+
}),
|
|
21
|
+
propsData: {
|
|
22
|
+
spec: properties,
|
|
23
|
+
stack: this.stack,
|
|
24
|
+
target: target,
|
|
25
|
+
vueApp: window.vueApp
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
// instance.stack = this.stack;
|
|
29
|
+
|
|
30
|
+
const placeholder = document.body.appendChild(
|
|
31
|
+
document.createElement("div")
|
|
32
|
+
);
|
|
33
|
+
instance.$mount(placeholder);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static closeDialog(properties, target, component) {
|
|
37
|
+
if (!this.stack) {
|
|
38
|
+
this.stack = [];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
Utils.type.ifObject(this.stack.last(), dialog => {
|
|
42
|
+
dialog.close();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
Utils.type.ifObject(properties["onClose"], it => {
|
|
46
|
+
Action.execute(it, target, component);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static get sheet() {
|
|
51
|
+
return LaunchSheet;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static get snackbar() {
|
|
55
|
+
return LaunchSnackbar;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static alert(message, target) {
|
|
59
|
+
const properties = {
|
|
60
|
+
message: message
|
|
61
|
+
};
|
|
62
|
+
const spec = Object.assign({}, properties, {
|
|
63
|
+
buttons: [
|
|
64
|
+
{
|
|
65
|
+
text: "OK",
|
|
66
|
+
onClick: properties.onClose
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
this.dialog(spec, target);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
class LaunchSheet {
|
|
75
|
+
static open(properties) {
|
|
76
|
+
const SheetClass = Vue.extend(Sheet);
|
|
77
|
+
const instance = new SheetClass({
|
|
78
|
+
vuetify: new Vuetify({
|
|
79
|
+
theme: {
|
|
80
|
+
themes: Utils.settings.themes
|
|
81
|
+
}
|
|
82
|
+
}),
|
|
83
|
+
propsData: { spec: properties }
|
|
84
|
+
});
|
|
85
|
+
const placeholder = document.body.appendChild(
|
|
86
|
+
document.createElement("div")
|
|
87
|
+
);
|
|
88
|
+
instance.$mount(placeholder);
|
|
89
|
+
// instance.show = true
|
|
90
|
+
return instance;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static confirm(properties, onConfirm) {
|
|
94
|
+
const spec = Object.assign({}, properties, {
|
|
95
|
+
buttons: [
|
|
96
|
+
{
|
|
97
|
+
text: "Confirm",
|
|
98
|
+
onClickFunction: onConfirm
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
this.open(spec);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static alert(message, buttons) {
|
|
106
|
+
const spec = { message: message, buttons: buttons };
|
|
107
|
+
this.open(spec);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
class LaunchSnackbar {
|
|
112
|
+
static open(properties) {
|
|
113
|
+
const SnackbarClass = Vue.extend(Snackbar);
|
|
114
|
+
const instance = new SnackbarClass({
|
|
115
|
+
vuetify: window.vueApp.vuetify,
|
|
116
|
+
propsData: { spec: properties, vueApp: window.vueApp }
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const placeholder = document.body.appendChild(
|
|
120
|
+
document.createElement("div")
|
|
121
|
+
);
|
|
122
|
+
instance.$mount(placeholder);
|
|
123
|
+
instance.show = true;
|
|
124
|
+
return instance;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static error(message) {
|
|
128
|
+
this.open({ message: message, styleClasses: ["error"] });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
static indicator(message) {
|
|
132
|
+
const instance = this.open({ message: message, timeout: -1 });
|
|
133
|
+
instance.indicator = true;
|
|
134
|
+
}
|
|
135
|
+
}
|