Skip to content

Commit

Permalink
Merge pull request #501 from AudiovisualMetadataPlatform/AMP-2940_ite…
Browse files Browse the repository at this point in the history
…mSearch

Amp 2940 item search
  • Loading branch information
yingfeng-iu authored Nov 15, 2023
2 parents 8ac234a + 203036c commit 10936b8
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 74 deletions.
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
<link rel="stylesheet" type="text/css" href="/css/style.css">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
<title>AMP</title>
<style> body {margin:0px} </style>
<script>window.AG_AdblockGlobalEnabled = true;</script>
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
<!-- <script src="https://kit.fontawesome.com/a076d05399.js"></script> -->
<script type="text/javascript">
var cachebuster = Math.round(new Date().getTime() / 1000);
document.write('<scr' + 'ipt type="text/javascript" src="./config.js?cb=' + cachebuster + '"></scr' + 'ipt>');
Expand Down
4 changes: 2 additions & 2 deletions src/components/account/ForgotPassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
</p>

<div class="form-group" v-if="resend_email">
<label>An email has been sent. </label>
<span><a href="#" @click="sendEmail()">Resend Email?</a></span>
<label>An email with a link to reset password has been sent. Please use the link as soon as possible as it will expire in s short time.</label>
<span><a href="#" @click="sendEmail()">&nbsp; Resend Email</a></span>
</div>
</form>
</div>
Expand Down
35 changes: 25 additions & 10 deletions src/components/entity/EntityList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,6 @@ export default {
JSON.stringify({ ...self.unitEntity })
);
self.getData();
self.assignedRolesUnitChanged = true;
self.settingsRolesUnitChanged = true;
//Checking Access Control
self.accessControlService.checkAccessControl(this);
},
Expand Down Expand Up @@ -1342,7 +1340,9 @@ export default {
async getData() {
const self = this;
if (self.baseUrl === "unit") {
this.getUnitDetails();
self.getUnitDetails();
self.assignedRolesUnitChanged = true;
self.settingsRolesUnitChanged = true;
} else if (self.baseUrl === "collection") {
self.entity = self.selectedCollection;
if (self.selectedCollection && !self.isCreatePage)
Expand Down Expand Up @@ -1401,6 +1401,7 @@ export default {
},
async getCollectionItems() {
const self = this;
self.showLoader = true;
self.itemService
.getCollectionItems(self.selectedCollection.id)
.then((response) => {
Expand All @@ -1412,6 +1413,7 @@ export default {
self.masterRecords = JSON.parse(JSON.stringify(self.records));
}
});
self.showLoader = false;
},
async onView(objInstance) {
const self = this;
Expand Down Expand Up @@ -1494,17 +1496,30 @@ export default {
// TODO below checkAccessControl is unnecessary because it's done upon each unit change
// including change made in item search
if (uEntity && uEntity.currentUnit)
self.accessControlService.checkAccessControl(this);
// if (uEntity && uEntity.currentUnit)
// self.accessControlService.checkAccessControl(this);
if (!uEntity) { //} && !self.selectedUnit) {
// if (!uEntity) { //} && !self.selectedUnit) {
// self.unitEntity = { unitList: [], currentUnit: "" };
// self.getAllUnits();
// } else {
// self.unitEntity = uEntity;
// self.getData();
// }
if (!uEntity) {
self.unitEntity = { unitList: [], currentUnit: "" };
}
else {
self.unitEntity = uEntity;
}
if (!self.unitEntity.unitList || !self.unitEntity.unitList.length) {
self.getAllUnits();
} else {
self.unitEntity = uEntity;
}
if (self.unitEntity.currentUnit) {
self.getData();
self.assignedRolesUnitChanged = true;
self.settingsRolesUnitChanged = true;
}
let formHTML = document.getElementsByClassName("form")[0];
Expand Down
19 changes: 0 additions & 19 deletions src/components/home/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<div class="w-100 home-container">
<loader :show="loading" />

<div class="home tech-bg ex-lg">
<div class="home-body">
Expand Down Expand Up @@ -45,24 +44,16 @@
<script>
import { sync } from "vuex-pathify";
import { env } from "@/helpers/env";
import Loader from "@/components/shared/Loader.vue";
import config from "@/assets/constants/common-contant.js";
import SharedService from "@/service/shared-service";
import EvaluationService from "@/service/evaluation-service";
import ConfigPropertiesService from "@/service/config-properties-service";
export default {
name: "Home",
components: {
Loader,
},
data() {
return {
loading: false,
cardList: config.cards,
sharedService: new SharedService(),
evaluationService: new EvaluationService(),
configPropertiesService: new ConfigPropertiesService(),
};
},
props: {},
Expand All @@ -73,18 +64,8 @@ export default {
if (envKey === "VUE_APP_DOC_AMP_MAIL_TO") window.location.href = url;
else window.open(url, "helpwindow", "width=800, height=500");
},
async networkCalls() {
const self = this;
try {
const configPropertiesResponse = await self.configPropertiesService.getConfigProperties();
self.configProperties = configPropertiesResponse.data;
} catch (error) {
console.log(error);
}
},
},
mounted() {
this.networkCalls();
},
};
</script>
Expand Down
66 changes: 28 additions & 38 deletions src/components/shared/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,8 @@ export default {
self.selectedItemId = record.id;
self.selectedUnit = {};
self.selectedUnit.name = record.unitName;
self.selectedCollection = record.collectionName;
self.selectedCollection = {};
self.selectedCollection.name = record.collectionName;
return;
}
// console.log(self.selectAll);
Expand Down Expand Up @@ -1018,48 +1019,37 @@ export default {
: []
);
break;
case "item-search":
case "item-search":
this.itemService
.getItemDetails(this.selectedItemId)
.then((res) => {
const self = this;
const selectedCollectionId = res._embedded.collection.id;
this.itemService
.getItemById(selectedCollectionId, this.selectedItemId)
self.collectionDetailsService
.getCollection(selectedCollectionId)
.then((response) => {
const self = this;
self.collectionDetailsService
.getCollection(selectedCollectionId)
.then((response) => {
self.selectedCollection = response.data;
//Updating unit id in our session storage for content page
const unitId = response.data._embedded.unit.id;
let uEntity = JSON.parse(
sessionStorage.getItem("unitEntity")
);
console.log("Search: uEntity = " + uEntity);
// if (!uEntity) {
// sessionStorage.setItem("unitEntity",
// JSON.stringify({ ...self.unitEntity })
// );
uEntity.currentUnit = unitId;
sessionStorage.setItem(
"unitEntity",
JSON.stringify({ ...uEntity })
);
//checking permission
if (uEntity && uEntity.currentUnit)
self.accessControlService.checkAccessControl(self);
});
const res = JSON.parse(JSON.stringify(response));
self.selectedItem = res;
self.selectedItem.parentType = self.type;
self.selectedItem.unitName = self.selectedUnit.name;
self.selectedItem.collectionName = self.selectedCollection;
self.$router.push("/collections/items/item-search/details");
});
self.selectedCollection = response.data;
//Updating unit id in our session storage for content page
const unitId = response.data._embedded.unit.id;
let uEntity = JSON.parse(
sessionStorage.getItem("unitEntity")
);
uEntity = uEntity || {};
console.log("Search: uEntity = " + uEntity);
uEntity.currentUnit = unitId;
sessionStorage.setItem(
"unitEntity",
JSON.stringify({ ...uEntity })
);
//checking permission
if (uEntity && uEntity.currentUnit)
self.accessControlService.checkAccessControl(self);
});
self.selectedItem = res;
self.selectedItem.parentType = self.type;
self.selectedItem.unitName = self.selectedUnit.name;
self.selectedItem.collectionName = self.selectedCollection.name;
self.$router.push("/collections/items/item-search/details");
})
.catch((error) => {
this.dataSource = [];
Expand Down
11 changes: 7 additions & 4 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var router = new Router({
name: "home",
component: HomePage,
meta: {
// authorize: [],
helpUrl: env.getEnv("VUE_APP_DOC_AMP_USER_GUIDE"),
},
},
Expand Down Expand Up @@ -477,11 +476,14 @@ router.beforeEach(async (to, from, next) => {
const { authorize } = to.meta;
const currentUser = accountService.currentUserValue;

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

if (env.getDisableAuth() == "true" || !authorize) {
console.log("router: No auth needed.")
return next();
} else if (!currentUser) {
console.log("Current user not logged in yet.");
// not logged in so redirect to login page with the return url
console.log("router: Current user not logged in yet.");
// not logged in so redirect to access-denied page with login link and with the return url
return router.push({ path: "/access-denied", query: { returnUrl: to.path }});
} else {
// TODO, below API call is to validate auth token, in case the locally stored one is compromised;
Expand All @@ -491,14 +493,15 @@ router.beforeEach(async (to, from, next) => {
// return next();
router.app.$store.state.isAuthenticated = false;
router.app.$store.commit("isAuthenticated");
console.log("router: Auth token invalid!")
return next({ path: "/account/login", query: { returnUrl: to.path } });
} else {
router.app.$store.state.isAuthenticated = true;
let action = authorize.actionType + "-" + authorize.targetType;
// let acActions = router.app.$store.state.acActions;
let acActions = store.state.acActions;
let acIsAdmin = store.state.acIsAdmin;
console.log("initPermissions = ", acActions," isAdmin = ", acIsAdmin);
console.log("router: initPermissions = ", acActions," isAdmin = ", acIsAdmin);
if (acActions.includes(action) || acIsAdmin) {
console.log(currentUser.username + " can perform action " + action);
return next();
Expand Down
5 changes: 5 additions & 0 deletions src/service/account-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import BaseService from './base-service.js';

const currentUser = JSON.parse(localStorage.getItem('currentUser'));
const baseService = new BaseService();

// TODO
// API calls for user registration & reset password etc should not use post_auth as
// these APIs do not require authentication; instead just use plain baseService.post

function sendRegisterRequest(username, firstName, lastName, pswd, email) {
const url = `/account/register`;
return baseService.post_auth(url,
Expand Down

0 comments on commit 10936b8

Please sign in to comment.