Commit 4b0c6de7 authored by Thivanka Saparamadu's avatar Thivanka Saparamadu

Update

parent 018db342
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"@testing-library/react": "^13.4.0", "@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"axios": "^1.5.0", "axios": "^1.5.0",
"file-saver": "^2.0.5",
"install": "^0.13.0", "install": "^0.13.0",
"npm": "^9.8.1", "npm": "^9.8.1",
"react": "^18.2.0", "react": "^18.2.0",
...@@ -8604,6 +8605,11 @@ ...@@ -8604,6 +8605,11 @@
"webpack": "^4.0.0 || ^5.0.0" "webpack": "^4.0.0 || ^5.0.0"
} }
}, },
"node_modules/file-saver": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz",
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
},
"node_modules/filelist": { "node_modules/filelist": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"@testing-library/react": "^13.4.0", "@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"axios": "^1.5.0", "axios": "^1.5.0",
"file-saver": "^2.0.5",
"install": "^0.13.0", "install": "^0.13.0",
"npm": "^9.8.1", "npm": "^9.8.1",
"react": "^18.2.0", "react": "^18.2.0",
......
import React from "react";
import Backdrop from "@mui/material/Backdrop";
import CircularProgress from "@mui/material/CircularProgress";
import Typography from "@mui/material/Typography";
export default function Loader({ openState, message }) {
return (
<div>
<Backdrop
sx={{ color: "#fff", zIndex: (theme) => theme.zIndex.drawer + 1 }}
open={openState}
>
<div style={{ textAlign: "center" }}>
<CircularProgress color="inherit" sx={{ fontWeight: "bold" }} />
<Typography variant="h5" sx={{ fontWeight: "bold" }}>
{message}
</Typography>
</div>
</Backdrop>
</div>
);
}
import React from "react"; import React from "react";
import "../css/movie-analysis-card.css"; import "../css/movie-analysis-card.css";
import DownloadIcon from "@mui/icons-material/Download"; import DownloadIcon from "@mui/icons-material/Download";
import axios from "axios";
import { saveAs } from "file-saver";
function MovieAnalysisCard({image,name}) { function MovieAnalysisCard({image,name}) {
const [mouseHover, setMouseHover] = React.useState(false); const [mouseHover, setMouseHover] = React.useState(false);
...@@ -13,9 +14,18 @@ function MovieAnalysisCard({image,name}) { ...@@ -13,9 +14,18 @@ function MovieAnalysisCard({image,name}) {
setMouseHover(false); setMouseHover(false);
}; };
const reportDownloadHandler = () => { const reportDownloadHandler = () => {
alert("hi"); axios
.get(`http://localhost:5000/download/${name}`)
.then((res) => {
saveAs(res.request.responseURL, `Result.zip`);
})
.catch((err) => {
alert(err.message);
});
}; };
const myStyle = { const myStyle = {
width: "170px", width: "170px",
height: "200px", height: "200px",
......
.loader-container{
width: 80%;
height: 100vh;
position: fixed;
background-color:rgba(0, 0, 0, 0.349);
z-index:20;
display: flex;
align-items: center;
justify-content: center
}
\ No newline at end of file
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
margin-left: auto; margin-left: auto;
margin-right: 0; margin-right: 0;
} }
.movie-page-container-title { .movie-page-container-title {
font-size: 23px; font-size: 23px;
font-weight: 500; font-weight: 500;
...@@ -23,3 +22,132 @@ ...@@ -23,3 +22,132 @@
.movie-page-result-container::-webkit-scrollbar { .movie-page-result-container::-webkit-scrollbar {
display: none; display: none;
} }
.movie-page-form-wrapper {
width: 25%;
height: 88vh;
background-color: #5143b8;
position: fixed;
top: 12vh;
right: -371px;
z-index: 10;
}
.movie-page-form-wrapper-active {
width: 25%;
height: 88vh;
background-color: #5143b8;
position: fixed;
top: 12vh;
z-index: 10;
animation: formSlider 1s forwards;
}
@keyframes formSlider {
from {
right: -370px;
}
to {
right: 0;
}
}
.movie-page-form-wrapper-expander {
height: 120px;
width: 15px;
position: absolute;
top: 250px;
left: -8px;
z-index: 2;
display: flex;
flex-direction: column;
justify-content: center;
cursor: pointer;
background-image: linear-gradient(to right, #5143b8, rgb(255, 255, 255));
border-radius: 10px;
}
.movie-page-form-container {
width: 100%;
text-align: center;
}
.movie-page-form-title-wrapper {
width: 90%;
display: flex;
justify-content: space-between;
align-items: center;
margin: auto;
margin-top: 15px;
}
.movie-page-form-title {
font-size: 20px;
font-weight: 500;
color: white;
text-align: center;
}
.movie-page-form-one-container {
width: 100%;
display: flex;
flex-direction: column;
padding-top: 10px;
}
.movie-form-input-wrapper {
width: 90%;
display: flex;
flex-direction: column;
text-align: start;
margin: auto;
margin-top: 15px;
}
.movie-form-input-label {
font-size: 15px;
color: white;
margin-bottom: 10px;
}
.movie-form-input {
height: 38px;
border-radius: 12px;
border: none;
outline: none;
background-color: #46399e;
padding-left: 7px;
padding-right: 7px;
color: white;
}
.movie-form-input::placeholder{
color: rgb(197, 197, 197);
}
.movie-form-input-file {
border-radius: 12px;
border: none;
outline: none;
background-color: #46399e;
padding: 10px;
color: white;
}
.movie-form-action-wrapper {
width: 90%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: auto;
margin-top: 20px;
position: absolute;
right: 0;
bottom: 35px;
}
.movie-form-action-button {
width: 180px;
height: 33px;
border-radius: 10px;
border: 2px solid white;
background-color: white;
font-size: 15px;
color: #5143b8;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s;
}
.movie-form-action-button:hover {
transform: scale(1.05);
}
This diff is collapsed.
main.py
\ No newline at end of file
...@@ -4,9 +4,11 @@ import json ...@@ -4,9 +4,11 @@ import json
from Mistakes_Identify import identifyMistakes from Mistakes_Identify import identifyMistakes
import os import os
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from flask_cors import CORS
from functions import allowed_file, enhance_image, zip_folder from functions import allowed_file, enhance_image, zip_folder
app = Flask(__name__) app = Flask(__name__)
CORS(app)
UPLOAD_FOLDER = 'Uploads' UPLOAD_FOLDER = 'Uploads'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
...@@ -26,6 +28,7 @@ def clear_image(): ...@@ -26,6 +28,7 @@ def clear_image():
@app.route('/check/video', methods=['POST']) @app.route('/check/video', methods=['POST'])
def analise_video(): def analise_video():
data = request.json data = request.json
print(data)
required_keys = ['user_id', 'movie_name', 'file_name', 'fps_rate', 'obj_accuracy', 'obj_dimension', 'img_accuracy', required_keys = ['user_id', 'movie_name', 'file_name', 'fps_rate', 'obj_accuracy', 'obj_dimension', 'img_accuracy',
'year'] 'year']
missing_keys = [key for key in required_keys if key not in data] missing_keys = [key for key in required_keys if key not in data]
...@@ -72,20 +75,24 @@ def analise_video(): ...@@ -72,20 +75,24 @@ def analise_video():
return jsonify({"message": "Failed to save data"}), 500 return jsonify({"message": "Failed to save data"}), 500
@app.route('/upload', methods=['POST']) @app.route('/upload/<movieName>', methods=['POST'])
def upload_file(): def upload_file(movieName):
if 'video' not in request.files: if 'video' not in request.files:
print("1")
return jsonify({"message": "Video could not found."}), 400 return jsonify({"message": "Video could not found."}), 400
file = request.files['video'] file = request.files['video']
if file.filename == '': if file.filename == '':
print("2")
return jsonify({"message": "Please select a video."}), 400 return jsonify({"message": "Please select a video."}), 400
if file and allowed_file(file.filename): if file and allowed_file(file.filename):
filename = secure_filename(file.filename) filename = secure_filename(movieName+".mp4")
filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename) filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
file.save(filepath) file.save(filepath)
return jsonify({"message": "Video uploaded successfully. Please wait for the results."}), 201 print("3")
return jsonify({"message": "Video uploaded successfully. Please wait for the results."}),201
else: else:
print("4")
return jsonify({"message": "Please upload a valid file format.(mp4, avi, mkv)"}), 400 return jsonify({"message": "Please upload a valid file format.(mp4, avi, mkv)"}), 400
...@@ -108,7 +115,7 @@ def get_data(userID): ...@@ -108,7 +115,7 @@ def get_data(userID):
if data: if data:
return json.dumps(data), 200 return json.dumps(data), 200
else: else:
return jsonify({"message": "No data found"}), 404 return jsonify([]), 200
else: else:
return jsonify({"message": "Missing user_id parameter"}), 400 return jsonify({"message": "Missing user_id parameter"}), 400
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment