Skip to content

Commit

Permalink
Merge pull request #550 from AudiovisualMetadataPlatform/AMP-3469_men…
Browse files Browse the repository at this point in the history
…uBVN

Amp 3469 menu bvn
  • Loading branch information
yingfeng-iu authored Dec 2, 2024
2 parents cf65ae5 + c3c8053 commit 0ee6964
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/components/navigation/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
>
<b-nav-item
:id="menu.url"
@click="routeTo(menu)"
@click.prevent="routeTo(menu)"
:class="{
'd-none': resolvePermissions(menu.permissionKey)
}"
Expand Down Expand Up @@ -121,6 +121,7 @@ export default {
"Workflow editor session is active. Please click on done button before leaving the page."
);
} else {
console.log("routing to home");
self.$router.push("/");
}
},
Expand All @@ -135,6 +136,7 @@ export default {
self.$router.push(`${menu.url}/${data.id}`);
}
} else {
console.log("routing to menu");
self.$router.push(`${menu.url}`).catch(error => {
if (error.name !== 'NavigationDuplicated') {
throw error;
Expand All @@ -144,15 +146,19 @@ export default {
},
resolvePermissions(keys) {
if(this.acIsAdmin) {
console.log("resolvePermissions: is Admin", keys);
return false;
} else {
if(Array.isArray(keys) && keys.length > 0) {
console.log("resolvePermissions: keys is array", keys);
return keys.map(key => {
return this.acActions.indexOf(key) < 0;
}).reduce((acc, current) => acc && current, true);
} else if(typeof keys === "string") {
console.log("resolvePermissions: keys is string", keys);
return this.acActions.indexOf(keys) < 0;
} else {
console.log("resolvePermissions: permission denied", keys);
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import router from "./router";
import { store } from "./store/amp-store";
// import { VuePlugin } from "vuera";
import VueFilterDateFormat from "@vuejs-community/vue-filter-date-format";
import {createBootstrap} from "bootstrap-vue-next/plugins";
import moment from "moment";
import {createBootstrap} from "bootstrap-vue-next/plugins";
import "bootstrap/dist/css/bootstrap.css";
import "bootstrap-vue-next/dist/bootstrap-vue-next.css";

Expand Down
10 changes: 5 additions & 5 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,11 @@ router.beforeEach(async (to, from, next) => {
const { authorize } = to.meta;
const currentUser = accountService.currentUserValue;

console.log("from: ", from, "\nto: ", to, "\nnext: ", next);
console.log("currentUser: ", currentUser);
console.log("router: from: ", from, "\nto: ", to, "\nnext: ", next);
console.log("router: currentUser: ", currentUser);

if (env.getDisableAuth() == "true" || !authorize) {
console.log("router: No auth needed.")
console.log("router: No auth needed.")
return next();
} else if (!currentUser) {
console.log("router: Current user not logged in yet.");
Expand All @@ -469,11 +469,11 @@ router.beforeEach(async (to, from, next) => {
// below API call is to validate the auth token before new page is loaded, in case the current login has expired;
// there should be better way to achieve this without making such extra API call
var success = await accountService.validate();
console.log("success = " + success);
if (!success) {
// return next();
store.state.isAuthenticated = false;
store.commit("isAuthenticated");
console.log("router: Auth token invalid!")
console.log("router: Auth token invalid! routing to login page.")
return next({ path: "/account/login", query: { returnUrl: to.path } });
} else {
store.state.isAuthenticated = true;
Expand Down

0 comments on commit 0ee6964

Please sign in to comment.