Skip to content

Commit c87e43e

Browse files
Merge pull request #91 from scottwittenburg/session-timeout-and-email-fixes
Session timeout and email fixes
2 parents cb126be + 49eac7c commit c87e43e

24 files changed

+1970
-1235
lines changed

client/.env.development

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
PUBLIC_ADDRESS=localhost:8081
2-
MIQA_SESSION_TIMEOUT=31536000

client/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
},
66
extends: ["plugin:vue/essential", "@vue/prettier"],
77
rules: {
8-
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
8+
"no-console": "off",
99
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off"
1010
},
1111
parserOptions: {

client/package-lock.json

Lines changed: 1674 additions & 1101 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"lint": "vue-cli-service lint"
99
},
1010
"dependencies": {
11-
"@girder/components": "git+https://github.com/girder/girder_web_components.git#v2.2.6",
11+
"@girder/components": "git+https://github.com/girder/girder_web_components.git#v3.0.2",
1212
"bluebird": "^3.5.5",
1313
"itk": "14.0.0",
1414
"mousetrap": "scottwittenburg/mousetrap#fix-listener-leak",
@@ -27,14 +27,14 @@
2727
"@babel/runtime-corejs2": "7.11.0",
2828
"@vue/cli-plugin-babel": "^3.3.0",
2929
"@vue/cli-plugin-eslint": "^3.3.0",
30-
"@vue/cli-service": "^3.3.0",
30+
"@vue/cli-service": "^4.5.12",
3131
"@vue/eslint-config-prettier": "^4.0.1",
3232
"babel-eslint": "^10.0.1",
3333
"copy-webpack-plugin": "^4.6.0",
3434
"core-js": "^2.6.5",
3535
"eslint": "^5.8.0",
3636
"eslint-plugin-vue": "^5.0.0",
37-
"pug": "^2.0.3",
37+
"pug": "^3.0.1",
3838
"pug-loader": "^2.4.0",
3939
"pug-plain-loader": "^1.0.0",
4040
"sass": "^1.26.10",

client/src/App.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
import { mapActions, mapGetters } from "vuex";
23
export default {
34
name: "App",
45
components: {},
@@ -9,19 +10,32 @@ export default {
910
data: () => ({
1011
userLevel: { value: null }
1112
}),
13+
computed: {
14+
...mapGetters(["sessionStatus"])
15+
},
1216
watch: {
1317
"girderRest.user"(user) {
1418
if (!user) {
1519
this.$router.push("/login");
16-
} else {
17-
this.setUserLevel();
20+
}
21+
},
22+
sessionStatus(status) {
23+
if (status === "timeout") {
24+
this.$prompt({
25+
title: "Session Expired",
26+
text: "Your session has expired and you will be logged out",
27+
positiveButton: "Ok"
28+
}).then(() => {
29+
this.logout();
30+
});
1831
}
1932
}
2033
},
2134
created() {
2235
this.setUserLevel();
2336
},
2437
methods: {
38+
...mapActions(["logout"]),
2539
async setUserLevel() {
2640
if (!this.girderRest.user) {
2741
return;

client/src/components/EmailDialog.vue

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,19 @@ export default {
3838
}),
3939
computed: {
4040
...mapState(["screenshots"]),
41-
...mapGetters(["currentDataset", "currentSession", "siteMap"])
41+
...mapGetters([
42+
"currentUser",
43+
"currentDataset",
44+
"currentSession",
45+
"siteMap"
46+
])
4247
},
4348
watch: {
49+
currentUser(value) {
50+
if (value) {
51+
this.initialize();
52+
}
53+
},
4454
currentDataset(value) {
4555
if (value) {
4656
this.initialize();
@@ -93,16 +103,21 @@ export default {
93103
this.to = this.toCandidates.map(c => c.name);
94104
this.cc = this.ccCandidates.map(c => c.name);
95105
this.bcc = this.bccCandidates.map(c => c.name);
106+
if (this.currentUser) {
107+
this.bcc.push(this.currentUser.email);
108+
}
96109
this.showCC = !!this.cc.length;
97110
this.showBCC = !!this.bcc.length;
98-
var experiment = `Regarding ${this.currentSession.meta.experimentId} (${this.currentSession.meta.experimentId2}), ${this.currentSession.name}`;
111+
var experiment = `Regarding ${this.currentSession.meta.experimentId}, ${this.currentSession.name}`;
99112
this.subject = experiment;
100-
this.body = `${experiment}
101-
102-
${location.href}
103-
113+
this.body = `Experiment: ${this.currentSession.meta.experimentId}
114+
Scan: ${this.currentSession.name}`;
115+
if (this.note) {
116+
this.body = `${this.body}
117+
Note:
104118
${this.note}
105119
`;
120+
}
106121
this.initialized = true;
107122
},
108123
toggleScreenshotSelection(screenshot) {
@@ -143,6 +158,19 @@ ${this.note}
143158
this.sending = false;
144159
this.$emit("input", false);
145160
this.initialized = false;
161+
for (let i = this.screenshots.length - 1; i >= 0; i--) {
162+
const screenshot = this.screenshots[i];
163+
if (this.selectedScreenshots.indexOf(screenshot) !== -1) {
164+
this.removeScreenshot(screenshot);
165+
}
166+
}
167+
this.selectedScreenshots = [];
168+
},
169+
getBorder(screenshot) {
170+
if (this.selectedScreenshots.indexOf(screenshot) === -1) {
171+
return "transparent";
172+
}
173+
return this.$vuetify.theme.currentTheme.primary;
146174
}
147175
}
148176
};
@@ -166,7 +194,7 @@ ${this.note}
166194
label="to"
167195
v-model="to"
168196
:candidates="toCandidates.map(c => c.name)"
169-
:required="!(to.length + cc.length + bcc.length)"
197+
:required="true"
170198
/>
171199
</v-flex>
172200
<v-flex shrink>
@@ -180,7 +208,7 @@ ${this.note}
180208
label="cc"
181209
v-model="cc"
182210
:candidates="ccCandidates.map(c => c.name)"
183-
:required="!(to.length + cc.length + bcc.length)"
211+
:required="false"
184212
/>
185213
</v-flex>
186214
</v-layout>
@@ -190,7 +218,7 @@ ${this.note}
190218
label="bcc"
191219
v-model="bcc"
192220
:candidates="bccCandidates.map(c => c.name)"
193-
:required="!(to.length + cc.length + bcc.length)"
221+
:required="false"
194222
/>
195223
</v-flex>
196224
</v-layout>
@@ -225,16 +253,15 @@ ${this.note}
225253
class="screenshot"
226254
@click="toggleScreenshotSelection(screenshot)"
227255
:style="{
228-
borderColor:
229-
selectedScreenshots.indexOf(screenshot) === -1
230-
? 'transparent'
231-
: $vuetify.theme.primary
256+
borderColor: getBorder(screenshot)
232257
}"
233258
>
234259
<v-img :src="screenshot.dataURL" aspect-ratio="1"></v-img>
235260
<v-card-text class="text-truncate">
236261
<v-tooltip top>
237-
<span slot="activator">{{ screenshot.name }}</span>
262+
<template #activator="{ on }">
263+
<span v-on="on">{{ screenshot.name }}</span>
264+
</template>
238265
<span>{{ screenshot.name }}</span>
239266
</v-tooltip>
240267
</v-card-text>

client/src/components/EmailRecipientCombobox.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ export default {
5353
>
5454
<template #selection="{ item, parent, selected }">
5555
<v-chip
56+
:key="JSON.stringify(item)"
5657
:color="isValid(item) ? '' : 'error'"
5758
:input-value="selected"
5859
small
5960
close
6061
@input="parent.selectItem(item)"
62+
@click:close="parent.selectItem(item)"
6163
>{{ item }}</v-chip
6264
>
6365
</template>
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
<script>
2+
import { mapActions } from "vuex";
3+
24
import NavbarTitle from "@/components/NavbarTitle";
35
import UserButton from "@/components/girder/UserButton";
46
import NavigationTabs from "@/components/NavigationTabs";
7+
import SessionTimer from "@/components/SessionTimer";
58
69
export default {
710
name: "GenericNavigationBar",
811
components: {
912
NavbarTitle,
1013
UserButton,
11-
NavigationTabs
14+
NavigationTabs,
15+
SessionTimer
1216
},
13-
inject: ["girderRest"]
17+
inject: ["girderRest"],
18+
methods: {
19+
...mapActions(["logout"])
20+
}
1421
};
1522
</script>
1623

@@ -19,6 +26,7 @@ export default {
1926
<NavbarTitle />
2027
<NavigationTabs />
2128
<v-spacer></v-spacer>
22-
<UserButton @user="girderRest.logout()" />
29+
<SessionTimer />
30+
<UserButton @user="logout()" />
2331
</v-app-bar>
2432
</template>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script>
2+
import { mapGetters } from "vuex";
3+
4+
export default {
5+
name: "SessionTimer",
6+
computed: {
7+
...mapGetters(["remainingSessionTime"]),
8+
showTimeRemaining() {
9+
const remaining = this.remainingSessionTime;
10+
return remaining > 0 && remaining < 300;
11+
},
12+
timeRemaining() {
13+
const secondsRemaining = this.remainingSessionTime;
14+
const minutesRemaining = Math.ceil(secondsRemaining / 60.0);
15+
const what = minutesRemaining > 1 ? "minutes" : "minute";
16+
return `Session will expire in under ${minutesRemaining} ${what}`;
17+
}
18+
}
19+
};
20+
</script>
21+
22+
<template>
23+
<v-text-field
24+
class="mt-6 warning-text"
25+
v-show="showTimeRemaining"
26+
readonly
27+
flat
28+
dense
29+
solo
30+
background-color="transparent"
31+
:value="timeRemaining"
32+
></v-text-field>
33+
</template>
34+
35+
<style lang="scss">
36+
.warning-text {
37+
font-size: 1.1em;
38+
font-weight: bold;
39+
}
40+
</style>

client/src/components/VtkViewer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default {
130130
var dataURL = await this.view.captureImage();
131131
this.setCurrentScreenshot({
132132
name: `${this.currentSession.meta.experimentId}/${
133-
this.currentSession.meta.experimentId2
133+
this.currentSession.name
134134
}/${cleanDatasetName(this.currentDataset.name)}/${this.displayName}`,
135135
dataURL
136136
});

0 commit comments

Comments
 (0)