Changeset View
Changeset View
Standalone View
Standalone View
src/resources/js/app.js
Show All 32 Lines | |||||
} | } | ||||
let loadingRoute | let loadingRoute | ||||
// Note: This has to be before the app is created | // Note: This has to be before the app is created | ||||
// Note: You cannot use app inside of the function | // Note: You cannot use app inside of the function | ||||
window.router.beforeEach((to, from, next) => { | window.router.beforeEach((to, from, next) => { | ||||
// check if the route requires authentication and user is not logged in | // check if the route requires authentication and user is not logged in | ||||
if (to.matched.some(route => route.meta.requiresAuth) && !store.state.isLoggedIn) { | if (to.meta.requiresAuth && !store.state.isLoggedIn) { | ||||
// remember the original request, to use after login | // remember the original request, to use after login | ||||
store.state.afterLogin = to; | store.state.afterLogin = to; | ||||
// redirect to login page | // redirect to login page | ||||
next({ name: 'login' }) | next({ name: 'login' }) | ||||
return | return | ||||
} | } | ||||
Show All 35 Lines | data() { | ||||
} | } | ||||
}, | }, | ||||
methods: { | methods: { | ||||
// Clear (bootstrap) form validation state | // Clear (bootstrap) form validation state | ||||
clearFormValidation(form) { | clearFormValidation(form) { | ||||
$(form).find('.is-invalid').removeClass('is-invalid') | $(form).find('.is-invalid').removeClass('is-invalid') | ||||
$(form).find('.invalid-feedback').remove() | $(form).find('.invalid-feedback').remove() | ||||
}, | }, | ||||
hasPermission(type) { | |||||
const authInfo = store.state.authInfo | |||||
const key = 'enable' + type.charAt(0).toUpperCase() + type.slice(1) | |||||
return !!(authInfo && authInfo.statusInfo[key]) | |||||
}, | |||||
hasRoute(name) { | hasRoute(name) { | ||||
return this.$router.resolve({ name: name }).resolved.matched.length > 0 | return this.$router.resolve({ name: name }).resolved.matched.length > 0 | ||||
}, | }, | ||||
hasSKU(name) { | hasSKU(name) { | ||||
const authInfo = store.state.authInfo | const authInfo = store.state.authInfo | ||||
return authInfo.statusInfo.skus && authInfo.statusInfo.skus.indexOf(name) != -1 | return authInfo.statusInfo.skus && authInfo.statusInfo.skus.indexOf(name) != -1 | ||||
}, | }, | ||||
isController(wallet_id) { | isController(wallet_id) { | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | methods: { | ||||
} | } | ||||
if (!domain.isVerified || !domain.isLdapReady || !domain.isConfirmed) { | if (!domain.isVerified || !domain.isLdapReady || !domain.isConfirmed) { | ||||
return 'Not Ready' | return 'Not Ready' | ||||
} | } | ||||
return 'Active' | return 'Active' | ||||
}, | }, | ||||
distlistStatusClass(list) { | |||||
if (list.isDeleted) { | |||||
return 'text-muted' | |||||
} | |||||
if (list.isSuspended) { | |||||
return 'text-warning' | |||||
} | |||||
if (!list.isLdapReady) { | |||||
return 'text-danger' | |||||
} | |||||
return 'text-success' | |||||
}, | |||||
distlistStatusText(list) { | |||||
if (list.isDeleted) { | |||||
return 'Deleted' | |||||
} | |||||
if (list.isSuspended) { | |||||
return 'Suspended' | |||||
} | |||||
if (!list.isLdapReady) { | |||||
return 'Not Ready' | |||||
} | |||||
return 'Active' | |||||
}, | |||||
pageName(path) { | pageName(path) { | ||||
let page = this.$route.path | let page = this.$route.path | ||||
// check if it is a "menu page", find the page name | // check if it is a "menu page", find the page name | ||||
// otherwise we'll use the real path as page name | // otherwise we'll use the real path as page name | ||||
window.config.menu.every(item => { | window.config.menu.every(item => { | ||||
if (item.location == page && item.page) { | if (item.location == page && item.page) { | ||||
page = item.page | page = item.page | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | methods: { | ||||
return 'Not Ready' | return 'Not Ready' | ||||
} | } | ||||
return 'Active' | return 'Active' | ||||
}, | }, | ||||
updateBodyClass(name) { | updateBodyClass(name) { | ||||
// Add 'class' attribute to the body, different for each page | // Add 'class' attribute to the body, different for each page | ||||
// so, we can apply page-specific styles | // so, we can apply page-specific styles | ||||
let className = 'page-' + (name || this.pageName()).replace(/\/.*$/, '') | document.body.className = 'page-' + (name || this.pageName()).replace(/\/.*$/, '') | ||||
$(document.body).removeClass().addClass(className) | |||||
} | } | ||||
} | } | ||||
}) | }) | ||||
// Add a axios request interceptor | // Add a axios request interceptor | ||||
window.axios.interceptors.request.use( | window.axios.interceptors.request.use( | ||||
config => { | config => { | ||||
// This is the only way I found to change configuration options | // This is the only way I found to change configuration options | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | error => { | ||||
else { | else { | ||||
msg_text = msg | msg_text = msg | ||||
} | } | ||||
let feedback = $('<div class="invalid-feedback">').text(msg_text) | let feedback = $('<div class="invalid-feedback">').text(msg_text) | ||||
if (input.is('.list-input')) { | if (input.is('.list-input')) { | ||||
// List input widget | // List input widget | ||||
input.children(':not(:first-child)').each((index, element) => { | let controls = input.children(':not(:first-child)') | ||||
if (!controls.length && typeof msg == 'string') { | |||||
// this is an empty list (the main input only) | |||||
// and the error message is not an array | |||||
input.find('.main-input').addClass('is-invalid') | |||||
} else { | |||||
controls.each((index, element) => { | |||||
if (msg[index]) { | if (msg[index]) { | ||||
$(element).find('input').addClass('is-invalid') | $(element).find('input').addClass('is-invalid') | ||||
} | } | ||||
}) | }) | ||||
} | |||||
input.addClass('is-invalid').next('.invalid-feedback').remove() | input.addClass('is-invalid').next('.invalid-feedback').remove() | ||||
input.after(feedback) | input.after(feedback) | ||||
} | } | ||||
else { | else { | ||||
// Standard form element | // Standard form element | ||||
input.addClass('is-invalid') | input.addClass('is-invalid') | ||||
input.parent().find('.invalid-feedback').remove() | input.parent().find('.invalid-feedback').remove() | ||||
Show All 21 Lines |