Initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import store from 'new-dashboard/store';
|
||||
import { isAllowed } from 'new-dashboard/core/configuration/filters';
|
||||
|
||||
export default function checkNavigation (storeModule, redirectionRoute) {
|
||||
return checkFilters.bind(this, storeModule, redirectionRoute);
|
||||
}
|
||||
|
||||
export function checkFilters (redirectionRoute, storeModule, to, _, next) {
|
||||
const urlOptions = { ...to.params, ...to.query };
|
||||
|
||||
if (urlOptions.filter && !isAllowed(urlOptions.filter)) {
|
||||
return next({ name: redirectionRoute });
|
||||
}
|
||||
|
||||
store.dispatch(`${storeModule}/setURLOptions`, urlOptions);
|
||||
next();
|
||||
}
|
||||
|
||||
export function mapsBeforeEnter (to, from, next) {
|
||||
store.dispatch('maps/resetFilters');
|
||||
checkFilters('maps', 'maps', to, from, next);
|
||||
}
|
||||
|
||||
export function datasetsBeforeEnter (to, from, next) {
|
||||
store.dispatch('datasets/resetFilters');
|
||||
checkFilters('datasets', 'datasets', to, from, next);
|
||||
}
|
||||
|
||||
export function catalogueDetailBeforeEnter (to, from, next) {
|
||||
if (to.query.category && to.query.country) {
|
||||
store.dispatch('catalogue/fetchDatasets', {
|
||||
category: to.query.category,
|
||||
country: to.query.country
|
||||
});
|
||||
next();
|
||||
} else {
|
||||
next({ name: 'catalogue' });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import store from 'new-dashboard/store';
|
||||
|
||||
export default function fetchOAuthApps (to, from, next) {
|
||||
store.dispatch('oAuthApps/fetch', {
|
||||
baseUrl: store.state.user.base_url,
|
||||
userId: store.state.user.id,
|
||||
apiKey: store.state.user.api_key
|
||||
});
|
||||
next();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import store from 'new-dashboard/store';
|
||||
|
||||
export default function fetchNotifications (to, from, next) {
|
||||
store.dispatch('notifications/fetchNotifications', {
|
||||
baseUrl: store.state.user.base_url,
|
||||
userId: store.state.user.id,
|
||||
apiKey: store.state.user.api_key
|
||||
});
|
||||
next();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import store from 'new-dashboard/store';
|
||||
|
||||
export function fetchOAuthApps (_1, _2, next) {
|
||||
store.dispatch('oAuthApps/fetch', {
|
||||
baseUrl: store.state.user.base_url,
|
||||
userId: store.state.user.id,
|
||||
apiKey: store.state.user.api_key
|
||||
});
|
||||
next();
|
||||
}
|
||||
|
||||
export function fetchIfAppNotFound (to, _, next) {
|
||||
const appId = to.params.id;
|
||||
const storeApp = store.state.oAuthApps.list[appId];
|
||||
|
||||
if (storeApp) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
fetchOAuthApps.apply(this, arguments);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import store from 'new-dashboard/store';
|
||||
|
||||
export default function updateSearchParams (to, _, next) {
|
||||
store.dispatch('search/doSearch', { query: to.params.query, tag: to.params.tag });
|
||||
next();
|
||||
}
|
||||
Reference in New Issue
Block a user