diff --git a/client/src/components/ControlPanel.vue b/client/src/components/ControlPanel.vue index 1ec1be0d..7d17269b 100644 --- a/client/src/components/ControlPanel.vue +++ b/client/src/components/ControlPanel.vue @@ -68,8 +68,11 @@ export default { return (this.representation && Math.ceil(this.representation.getPropertyDomainByName('windowWidth').max)) || 0; }, autoWindow() { - return this.currentViewData.autoWindow - || Math.ceil((this.winMax * 0.3) / 10) * 10; + return this.currentViewData.autoWindow || this.winMax; + }, + autoLevel() { + return this.currentViewData.autoLevel + || Math.ceil((this.levMax * 0.4) / 10) * 10; }, levMin() { return (this.representation && this.representation.getPropertyDomainByName('windowLevel').min) || 0; @@ -77,10 +80,6 @@ export default { levMax() { return (this.representation && Math.ceil(this.representation.getPropertyDomainByName('windowLevel').max)) || 0; }, - autoLevel() { - return this.currentViewData.autoLevel - || Math.ceil((this.levMax * 0.2) / 10) * 10; - }, }, watch: { window(value) { @@ -175,6 +174,8 @@ export default { updateWinLev() { this.window = this.autoWindow; this.level = this.autoLevel; + this.representation.setWindowWidth(this.window); + this.representation.setWindowLevel(this.level); }, navigateToFrame(frameId) { if (frameId && frameId !== this.$route.params.frameId) { @@ -577,6 +578,7 @@ export default { :lock-owner="lockOwner" :loading-lock="loadingLock" @handleKeyPress="handleKeyPress" + @switchLock="switchLock" /> diff --git a/client/src/components/DecisionButtons.vue b/client/src/components/DecisionButtons.vue index 257ac8dd..78d9162c 100644 --- a/client/src/components/DecisionButtons.vue +++ b/client/src/components/DecisionButtons.vue @@ -37,6 +37,12 @@ export default { newComment: '', confirmedPresent: [], confirmedAbsent: [], + decisionShortcuts: { + U: 'u', + UE: 'i', + 'Q?': 'o', + UN: 'p', + }, }; }, computed: { @@ -131,25 +137,6 @@ export default { if (!this.currentViewData.currentAutoEvaluation) { this.pollInterval = setInterval(this.pollForEvaluation, 1000 * 10); } - const decisionShortcuts = { - u: 'U', - i: 'UE', - o: 'Q?', - p: 'UN', - }; - window.addEventListener('keydown', (event) => { - if ( - (this.$refs.commentInput && !this.$refs.commentInput.isFocused) - && Object.keys(decisionShortcuts).includes(event.key) - ) { - const code = decisionShortcuts[event.key]; - if (this.options.map( - (option) => option.code, - ).includes(code)) { - this.handleCommentSave(decisionShortcuts[event.key]); - } - } - }); }, beforeUnmount() { clearInterval(this.pollInterval); @@ -176,6 +163,9 @@ export default { (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(), ); }, + switchLock() { + this.$emit('switchLock', this.currentViewData.experimentId, null, true); + }, getCurrentChipState(artifact) { // this function determines the styling of the four chip states. // four states of a chip are: @@ -451,6 +441,10 @@ export default { style="text-align: center" > @@ -487,7 +481,7 @@ export default { :loading="loadingLock" :disabled="loadingLock" color="primary" - @click="switchLock(experimentId, null, force=true)" + @click="switchLock" > {{ lockOwner ?"Steal edit access" :"Claim edit access" }} diff --git a/miqa/core/models/project.py b/miqa/core/models/project.py index bfa8d62b..9869b934 100644 --- a/miqa/core/models/project.py +++ b/miqa/core/models/project.py @@ -1,5 +1,6 @@ from uuid import uuid4 +from django.apps import apps from django.contrib.auth.models import User from django.core.exceptions import ValidationError from django.db import models @@ -111,6 +112,13 @@ def update_group(self, group_name, user_list): for previously_permitted_user in old_list: if previously_permitted_user.username not in user_list: remove_perm(group_name, previously_permitted_user, self) + if 'reviewer' in group_name: + locked_experiments = apps.get_model('core', 'Experiment').objects.filter( + project=self, lock_owner=previously_permitted_user + ) + for locked_experiment in locked_experiments: + locked_experiment.lock_owner = None + locked_experiment.save() for username in user_list: new_permitted_user = User.objects.get(username=username)