Skip to content

Commit

Permalink
Merge pull request #351 from ReproNim/fix/save
Browse files Browse the repository at this point in the history
Addresses various fixes and enhancements
  • Loading branch information
satra authored Nov 1, 2024
2 parents 817f1d7 + a401e6b commit 5383e69
Show file tree
Hide file tree
Showing 9 changed files with 1,241 additions and 3,106 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '21.x'
node-version: '23.x'

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ use a Docker setup.

```shell
docker run -it --rm -p 8080:8080 -v $(pwd):/src --entrypoint bash \
--platform linux/amd64 node:21.7.2-bookworm-slim
--platform linux/amd64 node:23.1.0-bookworm-slim
```

In the container terminal
Expand Down
4,269 changes: 1,208 additions & 3,061 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div id="timer" class="timer" v-if="showTimer">
<!-- Timer Component -->
<Timer
starttime="Dec 23, 2020 02:37:25"
starttime="Oct 31, 2024 21:00:00"
:endtime=expiryTime
trans='{
"day":"Day",
Expand Down Expand Up @@ -127,7 +127,6 @@ import Vue from 'vue';
import BootstrapVue from 'bootstrap-vue';
import axios from 'axios';
import Bowser from "bowser";
import moment from 'moment';
import _ from 'lodash';
import JSZip from 'jszip';
import { v4 as uuidv4 } from 'uuid';
Expand Down Expand Up @@ -285,11 +284,8 @@ export default {
},
setActivity(index) {
if (!this.checkDisableBack && this.isProtocolUrl) { // check if disableBack not enabled
if (this.$route.query.url) {
this.$router.push(`/activities/${index}?url=${this.$route.query.url}`);
} else {
this.$router.push(`/activities/${index}`);
}
const query = this.$route.fullPath.replace(this.$route.path, '')
this.$router.push(`/activities/${index}` + query);
}
},
updateProgress(progress) {
Expand Down Expand Up @@ -652,10 +648,14 @@ export default {
return path;
},
expiryTime() {
let endDate = moment(this.$store.getters.getExpiryTime)['_i'];
endDate = endDate.replace(' ', '+');
// console.log(537, endDate, new Date(endDate).toString(), new Date(endDate).getTime());
return new Date(endDate).getTime();
const timestamp = this.$store.getters.getExpiryTime;
const formattedTime = timestamp.replace(
/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z/,
'$1-$2-$3T$4:$5:$6Z'
);
const time = Date.parse(formattedTime);
console.log(537, timestamp, formattedTime, time);
return time;
},
showTimer() {
return !!this.$store.getters.getExpiryTime;
Expand Down
7 changes: 2 additions & 5 deletions src/components/Landing/Landing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,8 @@ export default {
// eslint-disable-next-line consistent-return
const visibleAct = _.map(this.actVisibility, (ac, key) => (ac === true ? key : '')).filter(String);
const nextIndex = visibleAct[visibleAct.indexOf(currentIndex) + 1];
if (this.$route.query.url) {
this.$router.push(`/activities/${nextIndex}?url=${this.$route.query.url}`);
} else {
this.$router.push(`/activities/${nextIndex}`);
}
const query = this.$route.fullPath.replace(this.$route.path, '')
this.$router.push(`/activities/${nextIndex}` + query);
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/Section/Section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export default {
startedAtTime: this.t0,
endedAtTime: t1,
wasAssociatedWith: {
version: '0.0.1',
version: '1.0.0',
url: uiUrl,
'@id': 'https://github.com/ReproNim/reproschema-ui',
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/StudyIntroduction/StudyIntroduction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export default {
if (this.step < this.totalSteps) {
this.step += 1;
} else if (this.step === this.totalSteps) {
this.$router.push('/activities/0');
const query = this.$route.fullPath.replace(this.$route.path, '')
this.$router.push(`/activities/0` + query);
}
},
learnMore() {
Expand Down
13 changes: 6 additions & 7 deletions src/components/Survey/Survey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
startedAtTime: this.t0,
endedAtTime: t1,
wasAssociatedWith: {
version: '0.0.1',
version: '1.0.0',
url: uiUrl,
'@id': 'https://github.com/ReproNim/reproschema-ui',
},
Expand Down Expand Up @@ -439,11 +439,8 @@
const currentIndex = parseInt(this.$store.state.activityIndex);
const visibleAct = _.map(this.actVisibility, (ac, key) => (ac === true ? key : '')).filter(String);
const nextIndex = visibleAct[visibleAct.indexOf(currentIndex) + 1];
if (this.$route.query.url) {
this.$router.push(`/activities/${nextIndex}?url=${this.$route.query.url}`);
} else {
this.$router.push(`/activities/${nextIndex}`);
}
const query = this.$route.fullPath.replace(this.$route.path, '')
this.$router.push(`/activities/${nextIndex}` + query);
},
uploadZipData() {
const Response = this.$store.state.exportResponses;
Expand All @@ -460,6 +457,7 @@
const expiryMinutes = this.$store.state.expiryMinutes;
const jszip = new JSZip();
const fileName = `${uuidv4()}-${this.participantId}-activity${currentIndex}`;
const activityData = [];
_.map(data.response[currentIndex], (itemObj) => {
const newObj = { ...itemObj };
if (itemObj['@type'] === 'reproschema:Response') {
Expand All @@ -470,10 +468,11 @@
newObj.value = `${keyStrings[keyStrings.length-1]}-${rId}.wav`;
}
}
activityData.push(newObj);
});
// write out the activity files
jszip.folder(fileName).file(`activity_${currentIndex}.jsonld`,
JSON.stringify(data.response[currentIndex], null, 4));
JSON.stringify(activityData, null, 4));
jszip.generateAsync({ type: 'blob' })
.then((myzipfile) => {
// console.log(492, 'generate async ');
Expand Down
27 changes: 9 additions & 18 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ import Landing from '@/components/Landing/';
import StudyIntroduction from '@/components/StudyIntroduction/';
import config from '../config';

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => {
if (err.name !== 'NavigationDuplicated') {
throw err
}
})
}
Vue.use(Router);


const router = new Router({
routes: [
{
Expand All @@ -30,22 +39,4 @@ const router = new Router({
],
});

router.beforeEach((to, from, next) => {

if ((from.query.auth_token && !to.query.auth_token)
|| (from.query.uid && !to.query.uid)){
if (from.path === to.path) {
next(false);
} else {
next({
path: to.path,
query: from.query,
});
}
} else {
next();
}

})

export default router

0 comments on commit 5383e69

Please sign in to comment.