Skip to content

Commit

Permalink
Composition API Migration for moving towards real-time collaboration (#…
Browse files Browse the repository at this point in the history
…186)

* First steps of work in progress to migrate towards using the composition API and applying a store to manage the view.

* work in progress for revising tests for composition API and first pass for composition api with an analysisStore and view

* Fixed issues discovered during system testing with the first pass of the store migration

* first draft of testing done; cut time down in half but its still taking too long at around 300 something ms

* Finished cleaning up unit tests for the migrated toast code, and updated VueJS' version to be able to use useTempalteRef

* Renaming the RosalutionToast to ToastDialog to correspond with the other dialog components

* Secured the specific endpoints by requiring an authenticated user to access them

* Updated system test to force click in the situation the menu visibility isn't opened correctly by the test

* Fixed the 'AS' characters for the dockerfiles and fixing the accidental change as an option

* Fixed issue Rabab found in review; where the store was not switching to representing a different analysis when loading a different analysis.
  • Loading branch information
SeriousHorncat committed Dec 11, 2024
1 parent 1131f69 commit bc739b6
Show file tree
Hide file tree
Showing 27 changed files with 1,485 additions and 1,162 deletions.
4 changes: 2 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Local Development Stage
FROM python:3.11-slim-bookworm as development-stage
FROM python:3.11-slim-bookworm AS development-stage
WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
COPY ./src /app/src
ENTRYPOINT ["/bin/sh", "-c", "uvicorn src.main:app --host 0.0.0.0 --port 8000 --log-level info --reload"]

# Production Build Stage
FROM python:3.11-slim-bookworm as production-stage
FROM python:3.11-slim-bookworm AS production-stage
WORKDIR /app
COPY logging.conf /app/logging.conf
COPY requirements.txt /app/requirements.txt
Expand Down
6 changes: 5 additions & 1 deletion backend/src/routers/analysis_discussion_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@


@router.get("/{analysis_name}/discussions")
def get_analysis_discussions(analysis_name: str, repositories=Depends(database)):
def get_analysis_discussions(
analysis_name: str,
repositories=Depends(database),
username: VerifyUser = Security(get_current_user) #pylint: disable=unused-argument
):
""" Returns a list of discussion posts for a given analysis """

found_analysis = repositories['analysis'].find_by_name(analysis_name)
Expand Down
27 changes: 20 additions & 7 deletions backend/src/routers/analysis_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


@router.get("", tags=["analysis"], response_model=List[Analysis])
def get_all_analyses(repositories=Depends(database)):
def get_all_analyses(repositories=Depends(database), username: VerifyUser = Security(get_current_user)): #pylint: disable=unused-argument
"""Returns every analysis available"""
return repositories["analysis"].all()

Expand Down Expand Up @@ -76,7 +76,11 @@ async def create_file(


@router.get("/{analysis_name}", tags=["analysis"], response_model=Analysis, response_model_exclude_none=True)
def get_analysis_by_name(analysis_name: str, repositories=Depends(database)):
def get_analysis_by_name(
analysis_name: str,
repositories=Depends(database),
username: VerifyUser = Security(get_current_user) #pylint: disable=unused-argument
):
"""Returns analysis case data by calling method to find case by it's analysis_name"""
analysis = repositories["analysis"].find_by_name(analysis_name)

Expand Down Expand Up @@ -116,15 +120,24 @@ def update_event(
raise HTTPException(status_code=409, detail=str(exception)) from exception


@router.get("/download/{file_id}")
def download_file_by_id(file_id: str, repositories=Depends(database)):
@router.get("/download/{file_id}", tags=["analysis"])
def download_file_by_id(
file_id: str,
repositories=Depends(database),
username: VerifyUser = Security(get_current_user) #pylint: disable=unused-argument
):
""" Returns a file from GridFS using the file's id """
grid_fs_file = repositories['bucket'].stream_analysis_file_by_id(file_id)
return StreamingResponse(grid_fs_file, media_type=grid_fs_file.content_type)


@router.get("/{analysis_name}/download/{file_name}")
def download(analysis_name: str, file_name: str, repositories=Depends(database)):
@router.get("/{analysis_name}/download/{file_name}", tags=["analysis"])
def download(
analysis_name: str,
file_name: str,
repositories=Depends(database),
username: VerifyUser = Security(get_current_user) #pylint: disable=unused-argument
):
""" Returns a file saved to an analysis from GridFS by file name """
# Does file exist by name in the given analysis?
file = repositories['analysis'].find_file_by_name(analysis_name, file_name)
Expand All @@ -135,7 +148,7 @@ def download(analysis_name: str, file_name: str, repositories=Depends(database))
return StreamingResponse(repositories['bucket'].stream_analysis_file_by_id(file['attachment_id']))


@router.put("/{analysis_name}/attach/{third_party_enum}")
@router.put("/{analysis_name}/attach/{third_party_enum}", tags=["analysis"])
def attach_third_party_link(
analysis_name: str,
third_party_enum: ThirdPartyLinkType,
Expand Down
1 change: 1 addition & 0 deletions backend/src/routers/annotation_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def annotate_analysis(
background_tasks: BackgroundTasks,
repositories=Depends(database),
annotation_task_queue=Depends(annotation_queue),
authorized=Security(get_authorization, scopes=["write"]) #pylint: disable=unused-argument
):
"""
Placeholder to initiate annotations for an analysis. This queueing/running
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.5'

services:
reverse-proxy:
image: traefik
Expand Down
6 changes: 3 additions & 3 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Local development stage
FROM node:20.8-alpine3.18 as development-stage
FROM node:20.8-alpine3.18 AS development-stage
WORKDIR /app
COPY package.json /app/
COPY yarn.lock /app/
Expand All @@ -10,7 +10,7 @@ EXPOSE 3000
ENTRYPOINT ["yarn", "dev:host"]

# Production Build stage
FROM node:20.8-alpine3.18 as production-build
FROM node:20.8-alpine3.18 AS production-build
WORKDIR /app
COPY ./src /app/src/
COPY package.json /app/
Expand All @@ -23,7 +23,7 @@ ENV VITE_ROSALUTION_VERSION=$VERSION_BUILD_TAG

RUN yarn install --frozen-lockfile && yarn build --base=/rosalution/

FROM nginx:1.25.2-alpine3.18 as production-stage
FROM nginx:1.25.2-alpine3.18 AS production-stage

COPY etc/default.conf /etc/nginx/conf.d/
COPY --from=production-build /app/dist/ /usr/share/nginx/html/
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@fortawesome/free-solid-svg-icons": "6.4.2",
"@fortawesome/vue-fontawesome": "3.0.3",
"@rollup/plugin-strip": "3.0.4",
"vue": "3.3.4",
"vue": "3.5.12",
"vue-router": "4.2.5"
},
"devDependencies": {
Expand Down
38 changes: 38 additions & 0 deletions frontend/src/components/AnalysisView/useActionMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {ref} from 'vue';
import {StatusType, getWorkflowStatusIcon} from '@/config.js';


/**
* Builds an actionMenu that can be used for the main header
* @return {Object} {actionChoices, builder} to return the actions to render and the builder to update the choices
*/
export function useActionMenu() {
const actionChoices = ref([]);

const builder = {
addWorkflowActions: (latest, operation) => {
if ( latest in StatusType ) {
for ( const [text, nextEvent, nextStatus] of StatusType[latest].transitions) {
builder.addMenuAction(text, getWorkflowStatusIcon(nextStatus), () => {
operation(nextEvent);
});
}
}
},
addMenuAction: (text, icon, operation) => {
actionChoices.value.push({
icon: icon,
text: text,
operation: operation,
});
},
addDivider: () => {
actionChoices.value.push({divider: true});
},
clear: () => {
actionChoices.value = [];
},
};

return {actionChoices, builder};
}
134 changes: 0 additions & 134 deletions frontend/src/components/Dialogs/Toast.vue

This file was deleted.

Loading

0 comments on commit bc739b6

Please sign in to comment.