From daa12b2891b243d8815b017ff705ff9fbcd37f74 Mon Sep 17 00:00:00 2001 From: Nadim Ritter Date: Mon, 20 Nov 2023 13:30:09 +0100 Subject: [PATCH 1/2] rename api call, small refactoring --- .../views/proctoring/ProctoringViewPage.vue | 367 ++++++++++++++++++ 1 file changed, 367 insertions(+) create mode 100644 client/src/components/views/proctoring/ProctoringViewPage.vue diff --git a/client/src/components/views/proctoring/ProctoringViewPage.vue b/client/src/components/views/proctoring/ProctoringViewPage.vue new file mode 100644 index 0000000..4665677 --- /dev/null +++ b/client/src/components/views/proctoring/ProctoringViewPage.vue @@ -0,0 +1,367 @@ + + + + + \ No newline at end of file From 8cfce2eb8040a6542db9153e9c985084c6616ced Mon Sep 17 00:00:00 2001 From: Nadim Ritter Date: Mon, 20 Nov 2023 13:30:52 +0100 Subject: [PATCH 2/2] rename api call (sesseion --> screenshot-data), small refactoring --- .../components/views/ProctoringViewPage.vue | 367 ------------------ .../components/views/gallery/GalleryImage.vue | 2 +- .../views/gallery/GalleryViewPage.vue | 2 +- client/src/models/session.ts | 2 +- client/src/router/index.ts | 2 +- ...ionService.ts => screenshotDataService.ts} | 8 +- .../component-services/galleryViewService.ts | 12 +- .../proctoringViewService.ts | 12 +- client/src/store/proctoringStore.ts | 7 + .../controllers/screenshot-data.controller.ts | 28 ++ server/src/controllers/session.controller.ts | 28 -- server/src/routes/routes.ts | 6 +- ....service.ts => screenshot-data.service.ts} | 6 +- 13 files changed, 61 insertions(+), 421 deletions(-) delete mode 100644 client/src/components/views/ProctoringViewPage.vue rename client/src/services/api-services/{sessionService.ts => screenshotDataService.ts} (60%) create mode 100644 client/src/store/proctoringStore.ts create mode 100644 server/src/controllers/screenshot-data.controller.ts delete mode 100644 server/src/controllers/session.controller.ts rename server/src/services/{session.service.ts => screenshot-data.service.ts} (60%) diff --git a/client/src/components/views/ProctoringViewPage.vue b/client/src/components/views/ProctoringViewPage.vue deleted file mode 100644 index d0da97f..0000000 --- a/client/src/components/views/ProctoringViewPage.vue +++ /dev/null @@ -1,367 +0,0 @@ - - - - - \ No newline at end of file diff --git a/client/src/components/views/gallery/GalleryImage.vue b/client/src/components/views/gallery/GalleryImage.vue index 5a9bee8..9d6254f 100644 --- a/client/src/components/views/gallery/GalleryImage.vue +++ b/client/src/components/views/gallery/GalleryImage.vue @@ -95,7 +95,7 @@ //props const props = defineProps<{ - screenshot: Screenshot | undefined, + screenshot: ScreenshotData | undefined, timestamp: number, groupUuid: string }>(); diff --git a/client/src/components/views/gallery/GalleryViewPage.vue b/client/src/components/views/gallery/GalleryViewPage.vue index f97dd37..baa15ab 100644 --- a/client/src/components/views/gallery/GalleryViewPage.vue +++ b/client/src/components/views/gallery/GalleryViewPage.vue @@ -157,7 +157,7 @@ if(appBarStore.galleryIsMetadataEnabled && group?.value?.screenshots != null){ for(let i = 0; i < group.value?.screenshots.length; i++){ - const screenshot: Screenshot | null = await galleryViewService.getLatestScreenshotData(group.value.screenshots[i].uuid, timestamp.value); + const screenshot: ScreenshotData | null = await galleryViewService.getLatestScreenshotData(group.value.screenshots[i].uuid, timestamp.value); const metaData: MetaData | undefined = screenshot?.metaData; group.value.screenshots[i].metaData = metaData == null ? {} : metaData; } diff --git a/client/src/models/session.ts b/client/src/models/session.ts index fbe8229..322436f 100644 --- a/client/src/models/session.ts +++ b/client/src/models/session.ts @@ -1,6 +1,6 @@ //todo: change name -type Screenshot = { +type ScreenshotData = { startTime: number; timestamp: number; endTime: number; diff --git a/client/src/router/index.ts b/client/src/router/index.ts index 4253334..1346370 100644 --- a/client/src/router/index.ts +++ b/client/src/router/index.ts @@ -5,7 +5,7 @@ import RegisterPage from "@/components/views/RegisterPage.vue" import StartPage from "@/components/views/StartPage.vue" import SearchPage from "@/components/views/search/SearchPage.vue" import GalleryViewPage from "@/components/views/gallery/GalleryViewPage.vue" -import ProctoringViewPage from "@/components/views/ProctoringViewPage.vue" +import ProctoringViewPage from "@/components/views/proctoring/ProctoringViewPage.vue" import UserAccountPage from "@/components/views/user-account/UserAccountPage.vue" import UserInfo from "@/components/views/user-account/UserInfo.vue" import * as authenticationService from "@/services/api-services/authenticationService"; diff --git a/client/src/services/api-services/sessionService.ts b/client/src/services/api-services/screenshotDataService.ts similarity index 60% rename from client/src/services/api-services/sessionService.ts rename to client/src/services/api-services/screenshotDataService.ts index fc068dd..ed07515 100644 --- a/client/src/services/api-services/sessionService.ts +++ b/client/src/services/api-services/screenshotDataService.ts @@ -1,10 +1,10 @@ import axios, { AxiosResponse } from 'axios' import * as apiService from "@/services/api-services/apiService"; -export async function getSessionBySessionId(sessionId: string): Promise { +export async function getScreenshotDataBySessionId(sessionId: string): Promise { try { - const url: string = "/session/" + sessionId; + const url: string = "/screenshot-data/" + sessionId; const {data, status}: AxiosResponse = await apiService.api.get(url, {headers: apiService.getHeaders()}); if (status === 200) { @@ -17,10 +17,10 @@ export async function getSessionBySessionId(sessionId: string): Promise { +export async function getScreenshotDataByTimestamp(sessionId: string, timestamp: string): Promise { try { - const url: string = "/session/" + sessionId + "/" + timestamp; + const url: string = "/screenshot-data/" + sessionId + "/" + timestamp; const {data, status}: AxiosResponse = await apiService.api.get(url, {headers: apiService.getHeaders()}); if (status === 200) { diff --git a/client/src/services/component-services/galleryViewService.ts b/client/src/services/component-services/galleryViewService.ts index 443b76a..2cda075 100644 --- a/client/src/services/component-services/galleryViewService.ts +++ b/client/src/services/component-services/galleryViewService.ts @@ -1,5 +1,5 @@ import * as groupService from "@/services/api-services/groupService"; -import * as sessionService from "@/services/api-services/sessionService"; +import * as screenshotDataService from "@/services/api-services/screenshotDataService"; import { SortOrder } from "@/models/sortOrderEnum"; import {navigateTo} from "@/router/navigation"; import { useAuthStore } from "@/store/app"; @@ -23,9 +23,9 @@ export async function getGroup(groupUuid: string, currentWindow: number, pageSiz } } -export async function getLatestScreenshotData(sessionUuid: string, timestamp: number): Promise{ +export async function getLatestScreenshotData(sessionUuid: string, timestamp: number): Promise{ try{ - return await sessionService.getSessionByTimestamp(sessionUuid, timestamp.toString()); + return await screenshotDataService.getScreenshotDataByTimestamp(sessionUuid, timestamp.toString()); }catch(error){ console.error(error); return null; @@ -39,7 +39,7 @@ export function calcIndex(i: number, n: number, gridSize: number): number { return ((i - 1) * gridSize + (n - 1)); } -export function currentIndexExists(screenshots: Screenshot[] | undefined, index: number): boolean { +export function currentIndexExists(screenshots: ScreenshotData[] | undefined, index: number): boolean { if (screenshots != null && screenshots.length > index) { return true; @@ -67,7 +67,7 @@ export function currentIndexExists(screenshots: Screenshot[] | undefined, index: // return screenshotLink; // } -export function createImageLinkWithToken(screenshot: Screenshot | undefined, timestamp: number): string { +export function createImageLinkWithToken(screenshot: ScreenshotData | undefined, timestamp: number): string { const authStore = useAuthStore(); if(screenshot == null){ @@ -90,7 +90,7 @@ export function createImageLinkWithToken(screenshot: Screenshot | undefined, tim // } // } -export function navigateToProctoringView(screenshot: Screenshot | undefined, groupUuid: string) { +export function navigateToProctoringView(screenshot: ScreenshotData | undefined, groupUuid: string) { if (screenshot != null) { navigateTo("/recording/" + screenshot.uuid); } diff --git a/client/src/services/component-services/proctoringViewService.ts b/client/src/services/component-services/proctoringViewService.ts index 5931f3e..59c69f2 100644 --- a/client/src/services/component-services/proctoringViewService.ts +++ b/client/src/services/component-services/proctoringViewService.ts @@ -1,20 +1,20 @@ -import * as sessionService from "@/services/api-services/sessionService"; +import * as screenshotDataService from "@/services/api-services/screenshotDataService"; import * as timeUtils from "@/utils/timeUtils"; //=============api================== -export async function getSessionBySessionId(sessionId: string): Promise{ +export async function getScreenshotDataBySessionId(sessionId: string): Promise{ try{ - return await sessionService.getSessionBySessionId(sessionId); + return await screenshotDataService.getScreenshotDataBySessionId(sessionId); }catch(error){ console.error(error); return null; } } -export async function getSessionByTimestamp(sessionId: string, timestamp: string): Promise{ +export async function getScreenshotDataByTimestamp(sessionId: string, timestamp: string): Promise{ try{ - return await sessionService.getSessionByTimestamp(sessionId, timestamp); + return await screenshotDataService.getScreenshotDataByTimestamp(sessionId, timestamp); }catch(error){ console.error(error); return null; @@ -34,7 +34,7 @@ export function getScreenshotMetadata(sliderTime: number, currentScreenshotMetad }; } -export function getSessionInfodata(session: Screenshot | null): object{ +export function getSessionInfodata(session: ScreenshotData | null): object{ if(session == null){ return {}; } diff --git a/client/src/store/proctoringStore.ts b/client/src/store/proctoringStore.ts new file mode 100644 index 0000000..51791cc --- /dev/null +++ b/client/src/store/proctoringStore.ts @@ -0,0 +1,7 @@ +import { defineStore } from "pinia"; +import * as timeUtils from "@/utils/timeUtils"; +import { ref, computed } from "vue"; + + +export const useProctoringStore = defineStore("proctoring", () => { +}); \ No newline at end of file diff --git a/server/src/controllers/screenshot-data.controller.ts b/server/src/controllers/screenshot-data.controller.ts new file mode 100644 index 0000000..97e34bd --- /dev/null +++ b/server/src/controllers/screenshot-data.controller.ts @@ -0,0 +1,28 @@ +import {Request, Response} from 'express'; +import * as apiService from "../services/api.service"; +import * as screenshotDataService from '../services/screenshot-data.service'; + +export async function getScreenshotDataBySessionId(req: Request, res: Response){ + + try{ + const session: object = await screenshotDataService.getScreenshotDataBySessionId(req.headers.authorization, req.params.sessionId); + + return res.status(200).json(session); + + }catch(error){ + apiService.handleGenericApiError(error, res); + } +} + + +export async function getScreenshotDataByTimestamp(req: Request, res: Response){ + + try{ + const session: object = await screenshotDataService.getScreenshotDataByTimestamp(req.headers.authorization, req.params.sessionId, req.params.timestamp); + + return res.status(200).json(session); + + }catch(error){ + apiService.handleGenericApiError(error, res); + } +} \ No newline at end of file diff --git a/server/src/controllers/session.controller.ts b/server/src/controllers/session.controller.ts deleted file mode 100644 index 95a3284..0000000 --- a/server/src/controllers/session.controller.ts +++ /dev/null @@ -1,28 +0,0 @@ -import {Request, Response} from 'express'; -import * as apiService from "../services/api.service"; -import * as sessionService from '../services/session.service'; - -export async function getSessionBySessionId(req: Request, res: Response){ - - try{ - const session: object = await sessionService.getSessionBySessionId(req.headers.authorization, req.params.sessionId); - - return res.status(200).json(session); - - }catch(error){ - apiService.handleGenericApiError(error, res); - } -} - - -export async function getSessionByTimestamp(req: Request, res: Response){ - - try{ - const session: object = await sessionService.getSessionByTimestamp(req.headers.authorization, req.params.sessionId, req.params.timestamp); - - return res.status(200).json(session); - - }catch(error){ - apiService.handleGenericApiError(error, res); - } -} \ No newline at end of file diff --git a/server/src/routes/routes.ts b/server/src/routes/routes.ts index f2425ec..06d66d8 100644 --- a/server/src/routes/routes.ts +++ b/server/src/routes/routes.ts @@ -1,6 +1,6 @@ import express, {Router} from 'express'; import * as groupController from '../controllers/group.controller'; -import * as sessionController from '../controllers/session.controller'; +import * as screenshotDataController from '../controllers/screenshot-data.controller'; import * as searchController from '../controllers/search.controller'; import * as userAccountController from '../controllers/user-account.controller'; import * as settingsController from '../controllers/settings.controller'; @@ -13,8 +13,8 @@ router.get("/settings", settingsController.getSettings) router.get("/group", groupController.getGroups); router.get("/group/:uuid", groupController.getGroupByUuid); -router.get("/session/:sessionId", sessionController.getSessionBySessionId); -router.get("/session/:sessionId/:timestamp", sessionController.getSessionByTimestamp); +router.get("/screenshot-data/:sessionId", screenshotDataController.getScreenshotDataBySessionId); +router.get("/screenshot-data/:sessionId/:timestamp", screenshotDataController.getScreenshotDataByTimestamp); router.get("/search/sessions", searchController.searchSessions); router.get("/search/screenshots", searchController.searchScreenshots); diff --git a/server/src/services/session.service.ts b/server/src/services/screenshot-data.service.ts similarity index 60% rename from server/src/services/session.service.ts rename to server/src/services/screenshot-data.service.ts index 98874aa..052018a 100644 --- a/server/src/services/session.service.ts +++ b/server/src/services/screenshot-data.service.ts @@ -1,9 +1,9 @@ import axios from "axios"; import * as apiService from "./api.service"; -const sessionUrl: string = "/proctoring/session/"; +const sessionUrl: string = "/proctoring/screenshot-data/"; -export async function getSessionBySessionId(token: string, sessionId: string): Promise{ +export async function getScreenshotDataBySessionId(token: string, sessionId: string): Promise{ const url: string = sessionUrl + sessionId; const {data, status} = await apiService.api.get(url, {headers: apiService.getHeaders(token)}); @@ -11,7 +11,7 @@ export async function getSessionBySessionId(token: string, sessionId: string): P } -export async function getSessionByTimestamp(token: string, sessionId: string, timestamp: string): Promise{ +export async function getScreenshotDataByTimestamp(token: string, sessionId: string, timestamp: string): Promise{ const url: string = sessionUrl + sessionId + "/" + timestamp; const {data, status} = await apiService.api.get(url, {headers: apiService.getHeaders(token)});