Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue frontend #173

Merged
merged 35 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c8c3abb
Create initial Vue app
marySalvi Nov 15, 2023
7cc6d53
Change directory endpoint to return json instead of html
marySalvi Nov 17, 2023
585eee8
Allow 8080 origin
marySalvi Nov 21, 2023
df67977
Remove vite example code and assets
marySalvi Nov 22, 2023
246d21d
Configure app to use tailwind and Daisyui
marySalvi Nov 22, 2023
eea56e0
Update directory endpoint and create fetch function
marySalvi Nov 27, 2023
38c0e81
Update frontend README and reset env variable on sigint
marySalvi Dec 1, 2023
d178c47
Mount UI dist to fastapi endpoint
marySalvi Jan 3, 2024
6da10fb
Add vue assets to binary build
marySalvi Jan 9, 2024
52e60dc
Update hatchling dependcies and web asset directory
marySalvi Jan 9, 2024
d55acbb
Add development workflow
marySalvi Jan 9, 2024
ab82ef6
Fix readme typo
marySalvi Jan 12, 2024
342fd55
Start frame-work for redact components
marySalvi Dec 5, 2023
4f6aea0
Add menu steps and file browser modal
marySalvi Dec 13, 2023
f9efda5
Update DirectoryData class to provide name and path to ui
marySalvi Dec 13, 2023
2e56fef
Add icons
marySalvi Dec 13, 2023
1ed7057
Change from document selector to ref usage. Add selected directory te…
marySalvi Dec 19, 2023
ce0c74b
Change api to return both path and name for path instances
marySalvi Dec 19, 2023
7d33f21
Standardize vue component order
marySalvi Dec 19, 2023
2613ee5
Add redaction functionalityx
marySalvi Dec 22, 2023
f9bcf25
Add progress bar
marySalvi Dec 22, 2023
2fd401a
Remove jinja templates and djlint. Linting updates
marySalvi Jan 30, 2024
65c117a
Add linting and formatting to frontend
marySalvi Jan 30, 2024
7d14111
Set default directory for frontend
marySalvi Jan 30, 2024
4cae3f1
Move logo to public folder so vite builds properly
marySalvi Feb 2, 2024
9462f11
Refactor gui.py, remove unnecessary code and add fastapi routing
marySalvi Feb 13, 2024
7fca541
Fix shutdown_event error and remove unused import
marySalvi Feb 19, 2024
a28bc77
Fix typehint NameError
marySalvi Feb 19, 2024
7908bcc
Create dynamic websocket url and add connection message
marySalvi Feb 19, 2024
2d9ec53
Remove shutdown_event after redaction in gui
marySalvi Feb 20, 2024
6c9373c
Update tests
marySalvi Dec 28, 2023
e21b5cc
Update gui e2e test to use subprocess
marySalvi Feb 27, 2024
55fc1cf
Remove std PIPEs from test to prevent windows blocking.
marySalvi Mar 6, 2024
c95f49e
Remove sleep and unused fixture.
marySalvi Mar 8, 2024
2cfcf10
Merge pull request #186 from DigitalSlideArchive/vue-test_updates
marySalvi Mar 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Build artifacts
/imagedephi/web_static/

# Developer tools
.envrc
.vscode/*
# Redacted Images
*/web_static/*

# Sample Redacted Images
*/REDACTED_*
*/Redacted_*
Redacted_*/
Expand Down
2 changes: 2 additions & 0 deletions client/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This could leak to production. Should only be used in DEBUG mode for FastAPI
VITE_APP_API_URL=http://127.0.0.1:8000
20 changes: 20 additions & 0 deletions client/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-env node */

module.exports = {
root: true,
env: {
node: true,
},
extends: [
"eslint:recommended",
"plugin:vue/vue3-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
parser: "vue-eslint-parser",
parserOptions: {
parser: "@typescript-eslint/parser",
},
plugins: ["@typescript-eslint"],

};
24 changes: 24 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules/*
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
21 changes: 21 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Development
For efficient front end developement in the project root run:

```bash
export DEBUG=True
hypercorn --reload imagedephi.gui.app:app
```

In a new terminal:

```bash
cd client/
yarn dev
```

**Note**
`imagedephi gui` will break and tests will fail in debug mode. Remember to reset variable when done with development.

```bash
export DEBUG=False
```
12 changes: 12 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ImageDePHI</title>
</head>
<body class="bg-base-300 min-h-screen">
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
39 changes: 39 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "imagedephi",
"private": true,
"version": "0.0.0",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"lint:tsc": "vue-tsc --noEmit",
"lint:check": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore --fix ",
"lint:format": "prettier src --write",
"lint": "npm-run-all lint:*",
"dev": "NODE_ENV=development vite --port 8080",
"build:clean": "rimraf ../imagedephi/web_static",
"build:compile": "vite build --outDir ../imagedephi/web_static",
"build": "npm-run-all build:clean build:compile"
},
"dependencies": {
"eslint-config-prettier": "^9.1.0",
"remixicon": "^3.6.0",
"vue": "^3.3.4"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"@vitejs/plugin-vue": "^4.2.3",
"autoprefixer": "^10.4.16",
"daisyui": "^4.0.7",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.31",
"rimraf": "^5.0.5",
"eslint": "^8.56.0",
"eslint-plugin-vue": "^9.19.2",
"prettier": "^3.1.1",
"tailwindcss": "^3.3.5",
"typescript": "^5.3.3",
"vite": "^4.4.5",
"vue-tsc": "^1.8.5"
}
}
6 changes: 6 additions & 0 deletions client/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
File renamed without changes
7 changes: 7 additions & 0 deletions client/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup lang="ts">
import HomePage from "./HomePage.vue";
</script>

<template>
<HomePage />
</template>
103 changes: 103 additions & 0 deletions client/src/HomePage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<script setup lang="ts">
import { ref } from "vue";

import { redactImages } from "./api/rest";
import { selectedDirectories } from "./store/directoryStore";

import MenuSteps from "./components/MenuSteps.vue";
import FileBrowser from "./components/FileBrowser.vue";

const inputModal = ref(null);
const outputModal = ref(null);
const redacting = ref(false);
const progress = ref({
count: 0,
max: 0,
});

const wsBase = import.meta.env.VITE_APP_API_URL
? new URL(import.meta.env.VITE_APP_API_URL)
: new URL(import.meta.url);

const ws = new WebSocket("ws:" + wsBase.host + "/ws");

ws.onmessage = (event) => {
const data = JSON.parse(event.data);
progress.value = {
count: data.count,
max: data.max,
};
};
</script>

<template>
<div class="flex">
<input id="side-drawer" type="checkbox" class="drawer-toggle" />
<div class="flex max-w-md">
<div :class="`pl-4 py-4 ${redacting ? 'opacity-50' : ''}`">
<div class="bg-base-100 drop-shadow-xl rounded flex flex-col">
<div class="flex justify-between content-center p-4 border-b">
<div class="max-h6 w-auto self-center">
<img src="/logo.png" />
</div>
<div class="flex items-center space-y-0.5">
<a class="btn btn-ghost btn-square btn-sm">
<i class="ri-side-bar-line text-lg text-neutral"></i>
</a>
</div>
</div>
<MenuSteps
:step-number="1"
step-title="Input Directory"
help-text="Location of the images you’d like to process."
:input-modal="inputModal"
/>
<MenuSteps
:step-number="2"
step-title="Output Directory"
help-text="Location of the images after they are processed."
:output-modal="outputModal"
/>
<FileBrowser
ref="inputModal"
:modal-id="'inputDirectory'"
:title="'Input Directory'"
/>
<FileBrowser
ref="outputModal"
:modal-id="'outputDirectory'"
:title="'Output Directory'"
/>
<button
type="submit"
class="btn btn-wide bg-accent m-auto"
:disabled="redacting"
@click="
redactImages(
selectedDirectories.inputDirectory,
selectedDirectories.outputDirectory,
),
(redacting = true)
"
>
De-phi Images
</button>
</div>
</div>
</div>
<div v-if="redacting" class="card w-96 bg-base-100 m-auto">
<div class="card-body">
<h2 class="card-title">Redaction in progress:</h2>
<p>
Redacting image {{ progress.count }} of {{ progress.max }} images.
</p>
<progress
v-if="redacting"
class="progress progress-primary"
:value="progress.count"
:max="progress.max"
></progress>
</div>
</div>
</div>
</template>
33 changes: 33 additions & 0 deletions client/src/api/rest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const basePath = import.meta.env.VITE_APP_API_URL
? import.meta.env.VITE_APP_API_URL
: "";

export async function getDirectoryInfo(path?: string) {
const selectedPath = path ? path : "/";
const response = await fetch(
`${basePath}/directory/?directory=${selectedPath}`,
{
method: "GET",
mode: "cors",
},
);
return response.json().then((data) => {
return data[0].directory_data;
});
}

export async function redactImages(
inputDirectory: string,
outputDirectory: string,
) {
const response = await fetch(
`${basePath}/redact/?input_directory=${inputDirectory}&output_directory=${outputDirectory}`,
{
method: "POST",
mode: "cors",
},
);
return response.json().then((data) => {
return data;
});
}
Binary file added client/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading