Changeset View
Changeset View
Standalone View
Standalone View
src/resources/js/app.js
Show First 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | methods: { | ||||
removeLoader(elem) { | removeLoader(elem) { | ||||
$(elem).find('.app-loader').remove() | $(elem).find('.app-loader').remove() | ||||
}, | }, | ||||
startLoading, | startLoading, | ||||
stopLoading, | stopLoading, | ||||
isLoading() { | isLoading() { | ||||
return isLoading > 0 | return isLoading > 0 | ||||
}, | }, | ||||
errorPage(code, msg) { | errorPage(code, msg, hint) { | ||||
// Until https://github.com/vuejs/vue-router/issues/977 is implemented | // Until https://github.com/vuejs/vue-router/issues/977 is implemented | ||||
// we can't really use router to display error page as it has two side | // we can't really use router to display error page as it has two side | ||||
// effects: it changes the URL and adds the error page to browser history. | // effects: it changes the URL and adds the error page to browser history. | ||||
// For now we'll be replacing current view with error page "manually". | // For now we'll be replacing current view with error page "manually". | ||||
const map = { | const map = { | ||||
400: "Bad request", | 400: "Bad request", | ||||
401: "Unauthorized", | 401: "Unauthorized", | ||||
403: "Access denied", | 403: "Access denied", | ||||
404: "Not found", | 404: "Not found", | ||||
405: "Method not allowed", | 405: "Method not allowed", | ||||
500: "Internal server error" | 500: "Internal server error" | ||||
} | } | ||||
if (!msg) msg = map[code] || "Unknown Error" | if (!msg) msg = map[code] || "Unknown Error" | ||||
if (!hint) hint = '' | |||||
const error_page = `<div id="error-page" class="error-page"><div class="code">${code}</div><div class="message">${msg}</div></div>` | const error_page = '<div id="error-page" class="error-page">' | ||||
+ `<div class="code">${code}</div><div class="message">${msg}</div><div class="hint">${hint}</div>` | |||||
+ '</div>' | |||||
$('#error-page').remove() | $('#error-page').remove() | ||||
$('#app').append(error_page) | $('#app').append(error_page) | ||||
app.updateBodyClass('error') | app.updateBodyClass('error') | ||||
}, | }, | ||||
errorHandler(error) { | errorHandler(error) { | ||||
this.stopLoading() | this.stopLoading() | ||||
▲ Show 20 Lines • Show All 304 Lines • Show Last 20 Lines |