Skip to content

Commit

Permalink
Merge pull request #532 from AudiovisualMetadataPlatform/AMP-2532_tas…
Browse files Browse the repository at this point in the history
…kManager

AMP-2532:
  • Loading branch information
yingfeng-iu authored Aug 16, 2024
2 parents 5a989fd + 90dff0f commit 43130eb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 92 deletions.
86 changes: 19 additions & 67 deletions src/components/entity/EntityList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
@change="onInputChange"
>
<option
v-for="option in listOfTaskManager"
v-for="option in configProperties.taskManagers"
:key="option"
>{{ option }}</option
>
Expand Down Expand Up @@ -409,7 +409,7 @@
@change="onInputChange"
>
<option
v-for="option in listOfExternalResources"
v-for="option in configProperties.externalSources"
:key="option"
>{{ option }}</option
>
Expand Down Expand Up @@ -964,7 +964,6 @@ export default {
selectedCollection: sync("selectedCollection"),
selectedItem: sync("selectedItem"),
selectedFile: sync("selectedFile"),
entityConfigs: sync("entityConfigs"),
configProperties: sync("configProperties"),
baseUrl() {
const self = this;
Expand All @@ -976,7 +975,6 @@ export default {
window.location.hash.toLowerCase().indexOf("collection") > -1 &&
window.location.hash.toLowerCase().indexOf("item") === -1
) {
this.getEntityConfigs();
return "collection";
} else if (window.location.hash.toLowerCase().indexOf("item") > -1) {
return "item";
Expand All @@ -994,12 +992,6 @@ export default {
window.location.hash.toLowerCase().indexOf("add-item") > -1
);
},
listOfTaskManager() {
return this.entityConfigs.taskManagers;
},
listOfExternalResources() {
return this.entityConfigs.externalSources;
},
mediaInfo() {
return this.selectedFile && this.selectedFile.mediaInfo
? JSON.stringify(JSON.parse(this.selectedFile.mediaInfo), undefined, 4)
Expand All @@ -1020,20 +1012,17 @@ export default {
);
self.selectedUser = "";
self.idsExcluding.push(getUser.id);
// self.showLoader = true;
self.accessControlService
.findActiveUsersByNameStartingIdsExcluding("", self.idsExcluding)
.then((response) => {
self.userList = self.sharedService.sortByAlphabatical(
response.data,
"username"
);
// self.showLoader = false;
});
},
async handleAssignRolesSaveBtn() {
const self = this;
// self.showLoader = true;
self.accessControlService
.updateRoleAssignments(self.unitEntity.currentUnit, self.newRoles)
.then(async (res) => {
Expand All @@ -1052,10 +1041,8 @@ export default {
}
}
self.refreshRoleAssignments(true);
// self.showLoader = false;
})
.catch((e) => {
// self.showLoader = false;
self.$bvToast.toast(
"Oops! Something went wrong.",
self.sharedService.erorrToastConfig
Expand Down Expand Up @@ -1101,15 +1088,13 @@ export default {
}
// otherwise retrieve RoleAssignments and initialize/reset data
// self.showLoader = true;
const assignRolesResponse = await
self.accessControlService.retrieveRoleAssignments(self.unitEntity.currentUnit);
self.assignedRoles = assignRolesResponse.data;
self.idsExcluding = self.assignedRoles.users.map((user) => user.id);
let userResponse = await self.accessControlService
.findActiveUsersByNameStartingIdsExcluding("", self.idsExcluding);
self.userList = self.sharedService.sortByAlphabatical(userResponse.data, "username");
// self.showLoader = false;
self.userList = self.sharedService.sortByAlphabatical(userResponse.data, "username");
// reset newRoles and assignedRolesUnitChanged
self.newRoles = [];
Expand All @@ -1127,7 +1112,6 @@ export default {
}
// otherwise retrieve RolesSettings and initialize/reset settingsRoles
// self.showLoader = true;
const settingsRolesResponse = await
self.accessControlService.retrieveRoleActionConfig(self.unitEntity.currentUnit);
self.settingsRoles = settingsRolesResponse.data;
Expand Down Expand Up @@ -1159,7 +1143,6 @@ export default {
self.settingsRoles["rolesUpdated"] = new Set();
self.settingsRolesUnitChanged = false;
// self.showLoader = false;
console.log ("Refreshed RolesSettings.");
return true;
},
Expand Down Expand Up @@ -1216,7 +1199,6 @@ export default {
console.log("Updating role " + roleName + " with " + actionIds.length + " actions: " + actionIds);
}
// call updateRoleActionConfig API
// self.showLoader = true;
self.accessControlService
.updateRoleActionConfig(self.unitEntity.currentUnit, roles)
.then(async (res) => {
Expand All @@ -1233,10 +1215,8 @@ export default {
);
}
self.refreshRolesSettings(true);
// self.showLoader = false;
})
.catch((e) => {
// self.showLoader = false;
self.$bvToast.toast(
"Oops! Something went wrong.",
self.sharedService.erorrToastConfig
Expand Down Expand Up @@ -1314,21 +1294,10 @@ export default {
const unitSelectHtml = document.getElementById("unit-select");
if (unitSelectHtml) unitSelectHtml.focus();
}
console.log("EntityList.getAllUnits: unitList.length = " + self.unitEntity.unitList.length);
console.log("EntityList.getAllUnits: unitList = " + self.unitEntity.unitList);
return self.unitEntity.unitList;
});
} catch (error) {
// self.showLoader = false;
console.log(error);
}
},
async getConfigs() {
const self = this;
try {
// self.showLoader = true;
self.configProperties = await self.configPropertiesService.getConfigProperties();
// self.showLoader = false;
} catch (error) {
// self.showLoader = false;
console.log(error);
}
},
Expand Down Expand Up @@ -1375,6 +1344,7 @@ export default {
console.log("EntityList.getEntityData: mediaType = " + self.entity.mediaType);
// self.showLoader = false;
}
return self.entity;
},
async getUnitCollections() {
const self = this;
Expand Down Expand Up @@ -1413,7 +1383,7 @@ export default {
});
// self.showLoader = false;
},
async onView(objInstance) {
onView(objInstance) {
const self = this;
if (self.baseUrl === "collection" && self.purpose) {
self.selectedItem = objInstance;
Expand Down Expand Up @@ -1449,10 +1419,6 @@ export default {
onInputChange(ev) {
this.isDataChanged = true;
},
async getEntityConfigs() {
const self = this;
self.entityService.getEntityConfigs(self);
},
handleSearchItem() {
this.$router.push("/collections/items/item-search");
},
Expand Down Expand Up @@ -1482,56 +1448,42 @@ export default {
next();
}
},
// beforeCreate() {
// console.log ("EntityList.beforeCreate(): showLoader = " + this.showLoader);
// console.log ("EntityList.beforeCreate(): mediaSource = " + this.entity.mediaSource);
// },
// created() {
// console.log ("EntityList.created(): showLoader = " + this.showLoader);
// console.log ("EntityList.created(): mediaSource = " + this.entity.mediaSource);
// },
// beforeUpdate() {
// console.log ("EntityList.beforeUpdate(): showLoader = " + this.showLoader);
// console.log ("EntityList.beforeUpdate(): mediaSource = " + this.entity.mediaSource);
// },
// updated() {
// console.log ("EntityList.updated(): showLoader = " + this.showLoader);
// console.log ("EntityList.created(): mediaSource = " + this.entity.mediaSource);
// },
// beforeMount() {
// console.log ("EntityList.beforeMount(): showLoader = " + this.showLoader);
// console.log ("EntityList.beforeMount(): mediaSource = " + this.entity.mediaSource);
// },
async mounted() {
const self = this;
console.log ("EntityList.mounted start: showLoader = " + this.showLoader);
// retrieve configProperties if not yet populated
if (!self.configProperties || Object.keys(self.configProperties).length === 0) {
await self.getConfigs();
// console.log("EntityList.mounted: configs.length = " + self.configProperties.length);
try {
self.configProperties = await self.configPropertiesService.getConfigProperties();
console.log("EntityList.mounted: taskManagers = " + self.configProperties.taskManagers + ", externalSources = " + self.configProperties.externalSources);
} catch (error) {
console.log(error);
}
}
// retrieve units list and currentUnit info from storage if available, otherwise initialize them
const uEntity = JSON.parse(sessionStorage.getItem("unitEntity"));
if (!uEntity) {
self.unitEntity = { unitList: [], currentUnit: "" };
console.log("EntityList.mounted: unitEntity initialized.");
}
else {
self.unitEntity = uEntity;
console.log("EntityList.mounted: unitList = " + self.unitEntity.unitList + ", currentUnit = " + self.unitEntity.currentUnit);
}
// retrieve units list if not yet populated
if (!self.unitEntity.unitList || !self.unitEntity.unitList.length) {
await self.getAllUnits();
// console.log("EntityList.mounted: unitList.length = " + self.unitEntity.unitList.length);
let unitList = await self.getAllUnits();
console.log("EntityList.mounted - after getAllUnits: unitList = " + unitList);
}
// if currentUnit set, getEntityData for the page
if (self.unitEntity.currentUnit) {
await self.getEntityData();
// console.log("EntityList.mounted: mediaSource = " + this.entity.mediaSource);
let entity = await self.getEntityData();
console.log("EntityList.mounted: mediaSource = " + entity.mediaSource);
}
// adjust size of PFile fields for PFile page
Expand Down
11 changes: 0 additions & 11 deletions src/service/entity-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,4 @@ export default class EntityService {
}
}

async getEntityConfigs(self) {
if(!self.entityConfigs.externalSources.length || !self.entityConfigs.taskManagers.length) {
await self.itemService.getEntityConfigs().then(res => {
self.entityConfigs.externalSources = res.externalSources;
self.entityConfigs.taskManagers = res.taskManagers;
}).catch(err => {
self.$bvToast.toast("Unable to retrive config details. Please try again!", self.sharedService.erorrToastConfig);
})
}
}

}
10 changes: 0 additions & 10 deletions src/service/item-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,4 @@ export default class ItemService extends BaseService{
return await super.get_auth(`/items/search?keyword=${keyword}`).then(result => result.data)
}

/***
* To get a list of external resources and task managers
* @params obj, id
*/

async getEntityConfigs(){
var data = "";
await super.get_auth(`/config?properties=externalSources,taskManagers`).then(result => data = result.data);
return data;
}
}
4 changes: 0 additions & 4 deletions src/store/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ const state = {
isAuthenticated: false,
selectedFile: {},
selectedFilters: {},
entityConfigs: {
externalSources: [],
taskManagers: [],
},
configProperties: {},
allUnits: {}, // all units the current user can read
mgmEvaluation: {
Expand Down

0 comments on commit 43130eb

Please sign in to comment.