changed react and python server for Download
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
/vrpmdvfrontend-30-03-2023.zip
|
/vrpmdvfrontend-30-03-2023.zip
|
||||||
/vrpmdvfrontend-vor_umbau_menu.zip
|
/vrpmdvfrontend-vor_umbau_menu.zip
|
||||||
|
/vrpmdvserver-before-change-to-small-json.zip
|
||||||
|
|||||||
26
union.py
Normal file
26
union.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
"""
|
||||||
|
Marshmallow fields
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Extension on the already available marshmallow fields
|
||||||
|
"""
|
||||||
|
from marshmallow import ValidationError, fields
|
||||||
|
|
||||||
|
|
||||||
|
class UnionField(fields.Field):
|
||||||
|
"""Field that deserializes multi-type input data to app-level objects."""
|
||||||
|
def __init__(self, types: list = [], *args, **kwargs) -> None:
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
if types:
|
||||||
|
self.types = types
|
||||||
|
else:
|
||||||
|
raise AttributeError('No types provided on union field')
|
||||||
|
|
||||||
|
def _deserialize(self, value, attr, data, **kwargs):
|
||||||
|
if bool([isinstance(value, i) for i in self.types if isinstance(value, i)]):
|
||||||
|
return value
|
||||||
|
else:
|
||||||
|
raise ValidationError(
|
||||||
|
f'Field shoud be any of the following types: [{", ".join([str(i) for i in self.types])}]'
|
||||||
|
)
|
||||||
File diff suppressed because one or more lines are too long
2
vrpmdvfrontend/dist/index.html
vendored
2
vrpmdvfrontend/dist/index.html
vendored
@@ -22,7 +22,7 @@
|
|||||||
<title>
|
<title>
|
||||||
Markus Lehr | VR Predictive Maintenance Device.
|
Markus Lehr | VR Predictive Maintenance Device.
|
||||||
</title>
|
</title>
|
||||||
<script type="module" crossorigin src="/assets/index-a894fc13.js"></script>
|
<script type="module" crossorigin src="/assets/index-530ee5bc.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
|||||||
@@ -50,14 +50,16 @@ import { MonDatafileList } from "./pages/monitorings/mondatfilelist";
|
|||||||
const API_URL = "https://api.fake-rest.refine.dev";
|
const API_URL = "https://api.fake-rest.refine.dev";
|
||||||
|
|
||||||
// Test URL
|
// Test URL
|
||||||
const MONITORINGS_API_URL = 'http://127.0.0.1:5000/vrpmdvapi/1_0';
|
//const MONITORINGS_API_URL = 'http://127.0.0.1:5000/vrpmdvapi/1_0';
|
||||||
const MONITORINGFILES_API_URL = 'http://127.0.0.1:5000/vrpmdvapi/1_0';
|
//const MONITORINGFILES_API_URL = 'http://127.0.0.1:5000/vrpmdvapi/1_0';
|
||||||
|
//const MONITORINGSTATUS_API_URL = 'http://127.0.0.1:5000/vrpmdvapi/1_0';
|
||||||
// Embedded URL
|
// Embedded URL
|
||||||
//const MONITORINGS_API_URL = '/vrpmdvapi/1_0';
|
const MONITORINGS_API_URL = '/vrpmdvapi/1_0';
|
||||||
//const MONDATAFILES_API_URL = '/vrpmdvapi/1_0';
|
const MONITORINGFILES_API_URL = '/vrpmdvapi/1_0';
|
||||||
|
const MONITORINGSTATUS_API_URL = '/vrpmdvapi/1_0';
|
||||||
// .get(`${API_URL}/exams`)
|
// .get(`${API_URL}/exams`)
|
||||||
|
|
||||||
const MONITORINGSTATUS_API_URL = 'http://127.0.0.1:5000/vrpmdvapi/1_0';
|
|
||||||
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
|||||||
1
vrpmdvfrontend/src/components/download/.gitignore
vendored
Normal file
1
vrpmdvfrontend/src/components/download/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/mfdownloadlisttsx.old
|
||||||
273
vrpmdvfrontend/src/components/download/mfdownlaodDialog.tsx
Normal file
273
vrpmdvfrontend/src/components/download/mfdownlaodDialog.tsx
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
|
import DialogTitle from "@mui/material/DialogTitle";
|
||||||
|
import DialogContent from "@mui/material/DialogContent";
|
||||||
|
import DialogActions from "@mui/material/DialogActions";
|
||||||
|
import Dialog from "@mui/material/Dialog";
|
||||||
|
import Input from "@mui/material/Input";
|
||||||
|
import Backdrop from "@mui/material/Backdrop";
|
||||||
|
import { styled } from "@mui/system";
|
||||||
|
import { GridRowId, GridRowSelectionModel } from "@mui/x-data-grid/models";
|
||||||
|
import List from "@mui/material/List/List";
|
||||||
|
import ListItem from "@mui/material/ListItem/ListItem";
|
||||||
|
import ListItemButton from "@mui/material/ListItemButton/ListItemButton";
|
||||||
|
import ListItemAvatar from "@mui/material/ListItemAvatar/ListItemAvatar";
|
||||||
|
import Avatar from "@mui/material/Avatar/Avatar";
|
||||||
|
import ListItemText from "@mui/material/ListItemText/ListItemText";
|
||||||
|
import Download from "@mui/icons-material/Download";
|
||||||
|
import blue from "@mui/material/colors/blue";
|
||||||
|
import { ListItemIcon } from "@mui/material";
|
||||||
|
import DownloadForOfflineIcon from '@mui/icons-material/DownloadForOffline';
|
||||||
|
import DownloadDoneIcon from '@mui/icons-material/DownloadDone';
|
||||||
|
|
||||||
|
import { IMonSampleFile, IMonitoringFile } from "../../pages/monitorings/monitorings.types";
|
||||||
|
import { HttpError } from "@refinedev/core/dist/interfaces/errors/HttpError";
|
||||||
|
import { ConditionalFilter, CrudFilter, CrudFilters, LogicalFilter } from "@refinedev/core/dist/interfaces";
|
||||||
|
import { useApiUrl, useCustom, useList } from "@refinedev/core";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
//const dialogColor = { color: "rgba(255,215,0, 0.7)" };
|
||||||
|
const dialogColor = { color: "primary" };
|
||||||
|
|
||||||
|
export interface MFDialogProps {
|
||||||
|
monitoringId: string;
|
||||||
|
open: boolean;
|
||||||
|
elements: GridRowSelectionModel;
|
||||||
|
onClose: (value: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function MFDownlaodDialiog(props : MFDialogProps) {
|
||||||
|
const { onClose, elements, open, monitoringId } = props;
|
||||||
|
|
||||||
|
//const [open, setOpen] = React.useState(true);
|
||||||
|
//const [value, setValue] = React.useState("red");
|
||||||
|
const [files, setfiles] = React.useState<IMonSampleFile[]>([]);
|
||||||
|
const [filesdownloaded, setfilesdownloaded] = React.useState<IMonSampleFile[]>([]);
|
||||||
|
|
||||||
|
const dataProvider = "monitoringfiles";
|
||||||
|
const apiUrl = useApiUrl(dataProvider);
|
||||||
|
const myUrl = apiUrl + "/monitoringfiles/download";
|
||||||
|
|
||||||
|
|
||||||
|
const filefilters = () : CrudFilter[] => {
|
||||||
|
|
||||||
|
let filters : CrudFilter[] = [];
|
||||||
|
|
||||||
|
let monFilter : LogicalFilter = {
|
||||||
|
field: "monId",
|
||||||
|
operator: "eq",
|
||||||
|
value: monitoringId,
|
||||||
|
};
|
||||||
|
|
||||||
|
filters.push(monFilter);
|
||||||
|
|
||||||
|
for (let index = 0; index < elements.length; index++) {
|
||||||
|
const element = elements[index];
|
||||||
|
let newFilter : LogicalFilter = {
|
||||||
|
field: "fileid",
|
||||||
|
operator: "eq",
|
||||||
|
value: element,
|
||||||
|
};
|
||||||
|
filters.push(newFilter);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return filters;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const { data: mf, isLoading: mfIsLoading, isError: mfError } = useCustom<IMonSampleFile[]>({
|
||||||
|
url: myUrl,
|
||||||
|
method: "get",
|
||||||
|
config: {
|
||||||
|
filters: filefilters(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// const { data, isLoading, isError } = useList<IMonSampleFile, HttpError>({
|
||||||
|
// resource: "monitoringfiles",
|
||||||
|
// filters: filefilters(),
|
||||||
|
// });
|
||||||
|
|
||||||
|
// filters: [
|
||||||
|
// {
|
||||||
|
// field: "monitoring",
|
||||||
|
// operator: "eq",
|
||||||
|
// value: monitoringId,
|
||||||
|
// },
|
||||||
|
// {... filefilters },
|
||||||
|
// ],
|
||||||
|
|
||||||
|
// const { data, isLoading, Is } = useList<IMonSampleFile>({
|
||||||
|
// dataProviderName: dataProvider,
|
||||||
|
// });
|
||||||
|
|
||||||
|
const DownloadJSON = (jsonData: IMonSampleFile) => {
|
||||||
|
const pathname: string = 'download/';
|
||||||
|
const filename: string = jsonData.name + '_' + jsonData.timestamp;
|
||||||
|
const dataStr = 'data:application/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(jsonData));
|
||||||
|
const download = document.createElement('a');
|
||||||
|
download.setAttribute('href', dataStr);
|
||||||
|
download.setAttribute('download', filename + '.json');
|
||||||
|
document.body.appendChild(download);
|
||||||
|
download.click();
|
||||||
|
download.remove();
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
|
||||||
|
if (mfError) {
|
||||||
|
// set errorstate
|
||||||
|
}
|
||||||
|
if (mfIsLoading){
|
||||||
|
|
||||||
|
}
|
||||||
|
if (mf && (mf.data != undefined)) {
|
||||||
|
setfiles(mf.data);
|
||||||
|
}
|
||||||
|
},[mf, mfIsLoading, mfError]);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (files.length > 0 ) {
|
||||||
|
//file : IMonSampleFile = files[0];
|
||||||
|
DownloadJSON(files[0]);
|
||||||
|
let df : IMonSampleFile[] = [files[0], ...filesdownloaded]
|
||||||
|
setfilesdownloaded(df);
|
||||||
|
let tmpfiles = files;
|
||||||
|
tmpfiles.splice(0, 1);
|
||||||
|
setfiles(tmpfiles);
|
||||||
|
}
|
||||||
|
},[files, filesdownloaded] );
|
||||||
|
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
|
||||||
|
// },[filesdownloaded] );
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
onClose(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// const handleClose = (
|
||||||
|
// event: {},
|
||||||
|
// reason: "backdropClick" | "escapeKeyDown"
|
||||||
|
// ) => {
|
||||||
|
// if (reason === "backdropClick") {
|
||||||
|
// console.log(reason);
|
||||||
|
// } else {
|
||||||
|
// onClose(false);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// const handleButtonClick = () => {
|
||||||
|
// setOpen(true);
|
||||||
|
// };
|
||||||
|
|
||||||
|
const handleExit = () => {
|
||||||
|
//console.log(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
// const handleChange = (
|
||||||
|
// event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>
|
||||||
|
// ) => {
|
||||||
|
// setValue(event.target.value);
|
||||||
|
// };
|
||||||
|
|
||||||
|
const handleListItemClick = (value: GridRowId) => {
|
||||||
|
//onClose(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Dialog
|
||||||
|
open={open}
|
||||||
|
aria-label="dialog-input"
|
||||||
|
id="input-dialog"
|
||||||
|
onClose={handleClose}
|
||||||
|
disableEscapeKeyDown
|
||||||
|
//PaperComponent={"span"}
|
||||||
|
PaperProps={{ sx: dialogColor }}
|
||||||
|
scroll="body" //set Dialog sx prop maxHeight to 100 to see the difference
|
||||||
|
TransitionProps={{
|
||||||
|
// http://reactcommunity.org/react-transition-group/transition
|
||||||
|
onExited: handleExit
|
||||||
|
// timeout: {
|
||||||
|
// enter: 1000,
|
||||||
|
// exit: 1000
|
||||||
|
// }
|
||||||
|
}}
|
||||||
|
transitionDuration={{ enter: 1000, exit: 1000 }}
|
||||||
|
sx={{ "& .MuiDialog-paper": { minWidth: "75%", maxHeight: 500 } }}
|
||||||
|
maxWidth="xs"
|
||||||
|
//fullScreen
|
||||||
|
//fullWidth
|
||||||
|
>
|
||||||
|
<DialogTitle>Downloads</DialogTitle>
|
||||||
|
<DialogContent dividers>
|
||||||
|
<List sx={{
|
||||||
|
pt: 0,
|
||||||
|
maxHeight: 200,
|
||||||
|
}}>
|
||||||
|
{filesdownloaded.map((file) => (
|
||||||
|
<ListItem disableGutters key={file.id}>
|
||||||
|
<ListItemText primary={file.name} />
|
||||||
|
<ListItemText primary={file.timestamp} />
|
||||||
|
<ListItemIcon>
|
||||||
|
<DownloadDoneIcon/>
|
||||||
|
</ListItemIcon>
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button autoFocus onClick={handleClose} sx={dialogColor}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleClose} sx={dialogColor}>
|
||||||
|
Ok
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
{elements.map((file) => (
|
||||||
|
<ListItem disableGutters key={file}>
|
||||||
|
<ListItemButton onClick={() => handleListItemClick(file)}>
|
||||||
|
<ListItemText primary={file} />
|
||||||
|
<ListItemAvatar>
|
||||||
|
<Avatar sx={{ bgcolor: blue[100], color: blue[600] }}>
|
||||||
|
<Download />
|
||||||
|
</Avatar>
|
||||||
|
</ListItemAvatar>
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
<ListItem disableGutters>
|
||||||
|
<ListItemButton
|
||||||
|
autoFocus
|
||||||
|
onClick={() => handleListItemClick('addAccount')}
|
||||||
|
>
|
||||||
|
<ListItemAvatar>
|
||||||
|
<Avatar>
|
||||||
|
<AddIcon />
|
||||||
|
</Avatar>
|
||||||
|
</ListItemAvatar>
|
||||||
|
<ListItemText primary="Add account" />
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// <Input onChange={handleChange} />
|
||||||
2
vrpmdvfrontend/src/hooks/data/.gitignore
vendored
Normal file
2
vrpmdvfrontend/src/hooks/data/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/usemfdownload copy.ts.save
|
||||||
|
/usemfdownload copy.ts.save1
|
||||||
144
vrpmdvfrontend/src/hooks/data/usemfdownload.ts
Normal file
144
vrpmdvfrontend/src/hooks/data/usemfdownload.ts
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
import { useCustom } from "@refinedev/core";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface UseMFDownload {
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export interface UseMonDownloadFile {
|
||||||
|
downloadurl: string;
|
||||||
|
resId : string;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export interface UseMonDownloadFileReturnType {
|
||||||
|
success : boolean;
|
||||||
|
//downloadMF: ({downloadurl, resId } : UseMonDownloadFile) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//function useCallApi(userId) {
|
||||||
|
export function useMonfiledownload ({ url }: UseMFDownload): UseMonDownloadFileReturnType {
|
||||||
|
|
||||||
|
|
||||||
|
const [success, setSuccess] = useState<boolean>(false);
|
||||||
|
//const [url, setUrl] = useState<string>(baseurl);
|
||||||
|
|
||||||
|
const {data, isLoading} = useCustom({
|
||||||
|
url: url,
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ((!isLoading) &&(data != null)) {
|
||||||
|
const url = window.URL.createObjectURL(new Blob([data?.data.blob]));
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.href = url;
|
||||||
|
link.download = '${downloadurl}' || "downloaded-file";
|
||||||
|
document.body.appendChild(link);
|
||||||
|
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
document.body.removeChild(link);
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
setSuccess(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return { success };
|
||||||
|
};
|
||||||
|
|
||||||
|
// const downloadMF = ( { downloadurl } : UseMonDownloadFile ) : void => {
|
||||||
|
|
||||||
|
// const {data, isLoading } = useCustom({
|
||||||
|
// url: downloadurl,
|
||||||
|
// method: "get",
|
||||||
|
// });
|
||||||
|
|
||||||
|
// if ((!isLoading) &&(data != null)) {
|
||||||
|
// const url = window.URL.createObjectURL(new Blob([data?.data.blob]));
|
||||||
|
// const link = document.createElement("a");
|
||||||
|
// link.href = url;
|
||||||
|
// link.download = '${downloadurl}' || "downloaded-file";
|
||||||
|
// document.body.appendChild(link);
|
||||||
|
|
||||||
|
// link.click();
|
||||||
|
|
||||||
|
// document.body.removeChild(link);
|
||||||
|
// window.URL.revokeObjectURL(url);
|
||||||
|
// setSuccess(true);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// <div>
|
||||||
|
// </div >
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
const useTimer = ({ interval }: UseTimerOptions): TimerResult => {
|
||||||
|
const [time, setTime] = useState<number>(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timerId = setInterval(() => {
|
||||||
|
setTime((prevTime) => prevTime + 1);
|
||||||
|
}, interval);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearInterval(timerId);
|
||||||
|
};
|
||||||
|
}, [interval]);
|
||||||
|
|
||||||
|
const reset = () => {
|
||||||
|
setTime(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
return { time, reset };
|
||||||
|
};
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
export const useMonfiledownload = ({
|
||||||
|
downloadurl ,
|
||||||
|
resId,
|
||||||
|
}: UseMonDownloadFile): UseMonDownloadFileReturnType => {
|
||||||
|
|
||||||
|
const { data, isLoading } = useCustom({
|
||||||
|
url: downloadurl,
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
|
||||||
|
let success: boolean = false;
|
||||||
|
|
||||||
|
useEffect( () => {
|
||||||
|
if ((!isLoading) &&(data != null)) {
|
||||||
|
const url = window.URL.createObjectURL(new Blob([data?.data.blob]));
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.href = url;
|
||||||
|
link.download = '${downloadurl}' || "downloaded-file";
|
||||||
|
document.body.appendChild(link);
|
||||||
|
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
document.body.removeChild(link);
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}, [data, isLoading]);
|
||||||
|
|
||||||
|
|
||||||
|
return { success }
|
||||||
|
};
|
||||||
|
|
||||||
|
*/
|
||||||
1
vrpmdvfrontend/src/pages/monitorings/__save/.gitignore
vendored
Normal file
1
vrpmdvfrontend/src/pages/monitorings/__save/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/mondatfilelist.tsx.old
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import {
|
|
||||||
useModal,
|
|
||||||
} from "@refinedev/core";
|
|
||||||
|
|
||||||
import Button from "@refinedev/mui";
|
|
||||||
|
|
||||||
|
|
||||||
export const DownloadButton = () => {
|
|
||||||
const { visible, show, close } = useModal();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Button>
|
|
||||||
Download
|
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// {visible && (
|
|
||||||
// <YourModalComponent>
|
|
||||||
// <p>Dummy Modal Content</p>
|
|
||||||
// <button onClick={close}>Close Modal</button>
|
|
||||||
// </YourModalComponent>
|
|
||||||
// )}
|
|
||||||
101
vrpmdvfrontend/src/pages/monitorings/downloadbutton.tsx
Normal file
101
vrpmdvfrontend/src/pages/monitorings/downloadbutton.tsx
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import DownloadIcon from '@mui/icons-material/Download';
|
||||||
|
import DeleteIcon from '@mui/icons-material/Delete';
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const DownloadButton = () => {
|
||||||
|
|
||||||
|
// const { openDialog } = useDialog();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const onClick = () => {}
|
||||||
|
// openDialog({
|
||||||
|
// title: "Profile Settings",
|
||||||
|
// contentText: null,
|
||||||
|
// fields: {
|
||||||
|
// username: {
|
||||||
|
// initialValue: defaultSettings.username
|
||||||
|
// // NOTE: we omit passing a label
|
||||||
|
// },
|
||||||
|
// // here we render something other than a text field by modifying
|
||||||
|
// // the props that are passed to the formik <Field /> component.
|
||||||
|
// onMailingList: {
|
||||||
|
// initialValue: defaultSettings.onMailingList,
|
||||||
|
// fieldProps: {
|
||||||
|
// component: CheckboxWithLabel,
|
||||||
|
// type: "checkbox",
|
||||||
|
// Label: { label: "Receive newsletter" }
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// // Here we pass our own component, if [fieldName].component is
|
||||||
|
// // specified then this component will be rendered and
|
||||||
|
// // [fieldName].fieldProps will be ignored.
|
||||||
|
// notificationRetention: {
|
||||||
|
// initialValue: defaultSettings.notificationRetention,
|
||||||
|
// component: (
|
||||||
|
// <FormControl>
|
||||||
|
// <InputLabel htmlFor="notificationRetention">
|
||||||
|
// Keep notifications for
|
||||||
|
// </InputLabel>
|
||||||
|
// <Field
|
||||||
|
// component={Select}
|
||||||
|
// name="notificationRetention"
|
||||||
|
// inputProps={{
|
||||||
|
// id: "notificationRetention"
|
||||||
|
// }}
|
||||||
|
// >
|
||||||
|
// <MenuItem value={"1_week"}>1 Week</MenuItem>
|
||||||
|
// <MenuItem value={"2_weeks"}>2 Weeks</MenuItem>
|
||||||
|
// <MenuItem value={"1_month"}>1 Month</MenuItem>
|
||||||
|
// </Field>
|
||||||
|
// </FormControl>
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// validationSchema: Yup.object({
|
||||||
|
// username: Yup.string().required("username cannot be empty"),
|
||||||
|
// onMailingList: Yup.boolean(),
|
||||||
|
// notificationRetention: Yup.string()
|
||||||
|
// }),
|
||||||
|
// cancelButton: { children: "Close" },
|
||||||
|
// submitButton: {
|
||||||
|
// children: "Save",
|
||||||
|
// props: { variant: "contained", color: "secondary" }
|
||||||
|
// },
|
||||||
|
// onSubmit: async ({ username, onMailingList, notificationRetention }) =>
|
||||||
|
// alert(
|
||||||
|
// `Saving settings Username [${username}], Receive newsletter [${onMailingList}], Keep notifications for [${notificationRetention}]`
|
||||||
|
// )
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
color= "primary"
|
||||||
|
variant = "text"
|
||||||
|
startIcon= {<DownloadIcon/>}
|
||||||
|
onClick= {() => {
|
||||||
|
onClick;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
|
||||||
|
Download
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// <Button variant="outlined" startIcon={<DownloadIcon/>} onClick={close}>
|
||||||
|
// Download
|
||||||
|
// </Button>
|
||||||
|
|
||||||
|
// {visible && (
|
||||||
|
// <YourModalComponent>
|
||||||
|
// <p>Dummy Modal Content</p>
|
||||||
|
// <button onClick={close}>Close Modal</button>
|
||||||
|
// </YourModalComponent>
|
||||||
|
// )}
|
||||||
230
vrpmdvfrontend/src/pages/monitorings/filter/monfilter.tsx
Normal file
230
vrpmdvfrontend/src/pages/monitorings/filter/monfilter.tsx
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import Checkbox from '@mui/material/Checkbox';
|
||||||
|
import TextField from '@mui/material/TextField';
|
||||||
|
import Autocomplete from '@mui/material/Autocomplete';
|
||||||
|
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
|
||||||
|
import CheckBoxIcon from '@mui/icons-material/CheckBox';
|
||||||
|
import { IMonitoring } from '../monitorings.types';
|
||||||
|
import { useApiUrl, useCustom } from '@refinedev/core';
|
||||||
|
import { GridRowSelectionModel } from '@mui/x-data-grid';
|
||||||
|
import { Dispatch, SetStateAction } from 'react';
|
||||||
|
|
||||||
|
const icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
|
||||||
|
const checkedIcon = <CheckBoxIcon fontSize="small" />;
|
||||||
|
|
||||||
|
export interface IMonFilter {
|
||||||
|
name : string;
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export interface MonDatafileTableProps {
|
||||||
|
setDF: Dispatch<SetStateAction<IMonFilter[]>>
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const MonFilter = ({setDF}: MonDatafileTableProps) => {
|
||||||
|
const dataProvider = "monitoringfiles";
|
||||||
|
const apiUrl = useApiUrl(dataProvider);
|
||||||
|
const myUrl = apiUrl + "/monitoring/mondfaivalable";
|
||||||
|
|
||||||
|
const { data: mons, isLoading: monsIsLoading, isError: monsError } = useCustom<IMonFilter[]>({
|
||||||
|
url: myUrl,
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
|
||||||
|
let monitorings : IMonFilter[] = [];
|
||||||
|
let isDisabled = true;
|
||||||
|
if (mons && (mons.data != undefined)) {
|
||||||
|
setDF(mons.data);
|
||||||
|
monitorings = mons.data;
|
||||||
|
isDisabled= false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Autocomplete
|
||||||
|
limitTags={1}
|
||||||
|
id="monfilter"
|
||||||
|
multiple
|
||||||
|
options={monitorings}
|
||||||
|
disableCloseOnSelect
|
||||||
|
disableClearable
|
||||||
|
getOptionLabel={(option) => option.name}
|
||||||
|
renderOption={(props, option, { selected }) => {
|
||||||
|
const { ...optionProps } = props;
|
||||||
|
return (
|
||||||
|
<li {...optionProps}>
|
||||||
|
<Checkbox
|
||||||
|
icon={icon}
|
||||||
|
checkedIcon={checkedIcon}
|
||||||
|
style={{ marginRight: 8 }}
|
||||||
|
checked={selected}
|
||||||
|
/>
|
||||||
|
{option.name}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
disabled={isDisabled}
|
||||||
|
style={{ width: 500 }}
|
||||||
|
renderInput={(params) => (
|
||||||
|
<TextField {...params} label="Monitoring Filter" placeholder="Filters" variant='outlined' />
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// disableCloseOnSelect
|
||||||
|
// multiple
|
||||||
|
/*
|
||||||
|
import * as React from 'react';
|
||||||
|
import Autocomplete from '@mui/material/Autocomplete';
|
||||||
|
import TextField from '@mui/material/TextField';
|
||||||
|
|
||||||
|
export default function LimitTags() {
|
||||||
|
return (
|
||||||
|
<Autocomplete
|
||||||
|
multiple
|
||||||
|
limitTags={2}
|
||||||
|
id="multiple-limit-tags"
|
||||||
|
options={top100Films}
|
||||||
|
getOptionLabel={(option) => option.title}
|
||||||
|
defaultValue={[top100Films[13], top100Films[12], top100Films[11]]}
|
||||||
|
renderInput={(params) => (
|
||||||
|
<TextField {...params} label="limitTags" placeholder="Favorites" />
|
||||||
|
)}
|
||||||
|
sx={{ width: '500px' }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Top 100 films as rated by IMDb users. http://www.imdb.com/chart/top
|
||||||
|
const top100Films = [
|
||||||
|
{ title: 'The Shawshank Redemption', year: 1994 },
|
||||||
|
{ title: 'The Godfather', year: 1972 },
|
||||||
|
{ title: 'The Godfather: Part II', year: 1974 },
|
||||||
|
{ title: 'The Dark Knight', year: 2008 },
|
||||||
|
{ title: '12 Angry Men', year: 1957 },
|
||||||
|
{ title: "Schindler's List", year: 1993 },
|
||||||
|
{ title: 'Pulp Fiction', year: 1994 },
|
||||||
|
{
|
||||||
|
title: 'The Lord of the Rings: The Return of the King',
|
||||||
|
year: 2003,
|
||||||
|
},
|
||||||
|
{ title: 'The Good, the Bad and the Ugly', year: 1966 },
|
||||||
|
{ title: 'Fight Club', year: 1999 },
|
||||||
|
{
|
||||||
|
title: 'The Lord of the Rings: The Fellowship of the Ring',
|
||||||
|
year: 2001,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Star Wars: Episode V - The Empire Strikes Back',
|
||||||
|
year: 1980,
|
||||||
|
},
|
||||||
|
{ title: 'Forrest Gump', year: 1994 },
|
||||||
|
{ title: 'Inception', year: 2010 },
|
||||||
|
{
|
||||||
|
title: 'The Lord of the Rings: The Two Towers',
|
||||||
|
year: 2002,
|
||||||
|
},
|
||||||
|
{ title: "One Flew Over the Cuckoo's Nest", year: 1975 },
|
||||||
|
{ title: 'Goodfellas', year: 1990 },
|
||||||
|
{ title: 'The Matrix', year: 1999 },
|
||||||
|
{ title: 'Seven Samurai', year: 1954 },
|
||||||
|
{
|
||||||
|
title: 'Star Wars: Episode IV - A New Hope',
|
||||||
|
year: 1977,
|
||||||
|
},
|
||||||
|
{ title: 'City of God', year: 2002 },
|
||||||
|
{ title: 'Se7en', year: 1995 },
|
||||||
|
{ title: 'The Silence of the Lambs', year: 1991 },
|
||||||
|
{ title: "It's a Wonderful Life", year: 1946 },
|
||||||
|
{ title: 'Life Is Beautiful', year: 1997 },
|
||||||
|
{ title: 'The Usual Suspects', year: 1995 },
|
||||||
|
{ title: 'Léon: The Professional', year: 1994 },
|
||||||
|
{ title: 'Spirited Away', year: 2001 },
|
||||||
|
{ title: 'Saving Private Ryan', year: 1998 },
|
||||||
|
{ title: 'Once Upon a Time in the West', year: 1968 },
|
||||||
|
{ title: 'American History X', year: 1998 },
|
||||||
|
{ title: 'Interstellar', year: 2014 },
|
||||||
|
{ title: 'Casablanca', year: 1942 },
|
||||||
|
{ title: 'City Lights', year: 1931 },
|
||||||
|
{ title: 'Psycho', year: 1960 },
|
||||||
|
{ title: 'The Green Mile', year: 1999 },
|
||||||
|
{ title: 'The Intouchables', year: 2011 },
|
||||||
|
{ title: 'Modern Times', year: 1936 },
|
||||||
|
{ title: 'Raiders of the Lost Ark', year: 1981 },
|
||||||
|
{ title: 'Rear Window', year: 1954 },
|
||||||
|
{ title: 'The Pianist', year: 2002 },
|
||||||
|
{ title: 'The Departed', year: 2006 },
|
||||||
|
{ title: 'Terminator 2: Judgment Day', year: 1991 },
|
||||||
|
{ title: 'Back to the Future', year: 1985 },
|
||||||
|
{ title: 'Whiplash', year: 2014 },
|
||||||
|
{ title: 'Gladiator', year: 2000 },
|
||||||
|
{ title: 'Memento', year: 2000 },
|
||||||
|
{ title: 'The Prestige', year: 2006 },
|
||||||
|
{ title: 'The Lion King', year: 1994 },
|
||||||
|
{ title: 'Apocalypse Now', year: 1979 },
|
||||||
|
{ title: 'Alien', year: 1979 },
|
||||||
|
{ title: 'Sunset Boulevard', year: 1950 },
|
||||||
|
{
|
||||||
|
title: 'Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb',
|
||||||
|
year: 1964,
|
||||||
|
},
|
||||||
|
{ title: 'The Great Dictator', year: 1940 },
|
||||||
|
{ title: 'Cinema Paradiso', year: 1988 },
|
||||||
|
{ title: 'The Lives of Others', year: 2006 },
|
||||||
|
{ title: 'Grave of the Fireflies', year: 1988 },
|
||||||
|
{ title: 'Paths of Glory', year: 1957 },
|
||||||
|
{ title: 'Django Unchained', year: 2012 },
|
||||||
|
{ title: 'The Shining', year: 1980 },
|
||||||
|
{ title: 'WALL·E', year: 2008 },
|
||||||
|
{ title: 'American Beauty', year: 1999 },
|
||||||
|
{ title: 'The Dark Knight Rises', year: 2012 },
|
||||||
|
{ title: 'Princess Mononoke', year: 1997 },
|
||||||
|
{ title: 'Aliens', year: 1986 },
|
||||||
|
{ title: 'Oldboy', year: 2003 },
|
||||||
|
{ title: 'Once Upon a Time in America', year: 1984 },
|
||||||
|
{ title: 'Witness for the Prosecution', year: 1957 },
|
||||||
|
{ title: 'Das Boot', year: 1981 },
|
||||||
|
{ title: 'Citizen Kane', year: 1941 },
|
||||||
|
{ title: 'North by Northwest', year: 1959 },
|
||||||
|
{ title: 'Vertigo', year: 1958 },
|
||||||
|
{
|
||||||
|
title: 'Star Wars: Episode VI - Return of the Jedi',
|
||||||
|
year: 1983,
|
||||||
|
},
|
||||||
|
{ title: 'Reservoir Dogs', year: 1992 },
|
||||||
|
{ title: 'Braveheart', year: 1995 },
|
||||||
|
{ title: 'M', year: 1931 },
|
||||||
|
{ title: 'Requiem for a Dream', year: 2000 },
|
||||||
|
{ title: 'Amélie', year: 2001 },
|
||||||
|
{ title: 'A Clockwork Orange', year: 1971 },
|
||||||
|
{ title: 'Like Stars on Earth', year: 2007 },
|
||||||
|
{ title: 'Taxi Driver', year: 1976 },
|
||||||
|
{ title: 'Lawrence of Arabia', year: 1962 },
|
||||||
|
{ title: 'Double Indemnity', year: 1944 },
|
||||||
|
{
|
||||||
|
title: 'Eternal Sunshine of the Spotless Mind',
|
||||||
|
year: 2004,
|
||||||
|
},
|
||||||
|
{ title: 'Amadeus', year: 1984 },
|
||||||
|
{ title: 'To Kill a Mockingbird', year: 1962 },
|
||||||
|
{ title: 'Toy Story 3', year: 2010 },
|
||||||
|
{ title: 'Logan', year: 2017 },
|
||||||
|
{ title: 'Full Metal Jacket', year: 1987 },
|
||||||
|
{ title: 'Dangal', year: 2016 },
|
||||||
|
{ title: 'The Sting', year: 1973 },
|
||||||
|
{ title: '2001: A Space Odyssey', year: 1968 },
|
||||||
|
{ title: "Singin' in the Rain", year: 1952 },
|
||||||
|
{ title: 'Toy Story', year: 1995 },
|
||||||
|
{ title: 'Bicycle Thieves', year: 1948 },
|
||||||
|
{ title: 'The Kid', year: 1921 },
|
||||||
|
{ title: 'Inglourious Basterds', year: 2009 },
|
||||||
|
{ title: 'Snatch', year: 2000 },
|
||||||
|
{ title: '3 Idiots', year: 2009 },
|
||||||
|
{ title: 'Monty Python and the Holy Grail', year: 1975 },
|
||||||
|
];
|
||||||
|
|
||||||
|
*/
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { DataGrid, GridColDef, GridRowSelectionModel } from "@mui/x-data-grid";
|
import { DataGrid, GridColDef, GridRowSelectionModel } from "@mui/x-data-grid";
|
||||||
import { Download, Delete } from "@mui/icons-material";
|
import { Download, Delete, Settings } from "@mui/icons-material";
|
||||||
|
import {UseMonDownloadFile, useMonfiledownload} from "../../hooks/data/usemfdownload"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DateField,
|
DateField,
|
||||||
@@ -12,65 +13,86 @@ import {
|
|||||||
useDataGrid,
|
useDataGrid,
|
||||||
} from "@refinedev/mui";
|
} from "@refinedev/mui";
|
||||||
|
|
||||||
import React from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { IMonitoring, IMonitoringFile } from "./monitorings.types";
|
import { IMonitoring, IMonitoringFile } from "./monitorings.types";
|
||||||
//import { MonitoringStatus } from "./status/monitoringstatus";
|
//import { MonitoringStatus } from "./status/monitoringstatus";
|
||||||
// import { MonitoringStatusEditChip } from "./status/monitoringstatusedit";
|
// import { MonitoringStatusEditChip } from "./status/monitoringstatusedit";
|
||||||
import { useUpdate } from "@refinedev/core";
|
import { useApiUrl, useCustom, useList, useUpdate } from "@refinedev/core";
|
||||||
import Button from "@mui/material/Button/Button";
|
import Button from "@mui/material/Button/Button";
|
||||||
import Stack from "@mui/material/Stack/Stack";
|
import Stack from "@mui/material/Stack/Stack";
|
||||||
|
import { DownloadButton } from "./downloadbutton";
|
||||||
|
import MFDownlaodDialig from "../../components/download/mfdownlaodDialog";
|
||||||
|
import MFDownlaodDialiog from "../../components/download/mfdownlaodDialog";
|
||||||
|
import { IMonFilter, MonFilter } from "./filter/monfilter";
|
||||||
|
import { MonDatafileTable } from "./mondatfiletable";
|
||||||
|
import Autocomplete from "@mui/material/Autocomplete";
|
||||||
|
import TextField from "@mui/material/TextField";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const MonDatafileList = () => {
|
export const MonDatafileList = () => {
|
||||||
const dataProvider = "monitoringfiles";
|
// const dataProvider = "monitoringfiles";
|
||||||
//const dataProvider = "monitorings";
|
// const { dataGridProps } = useDataGrid<IMonitoringFile>({
|
||||||
const { dataGridProps } = useDataGrid<IMonitoringFile>({
|
// syncWithLocation: true,
|
||||||
syncWithLocation: true,
|
// dataProviderName: dataProvider,
|
||||||
dataProviderName: dataProvider,
|
// pagination: {
|
||||||
pagination: {
|
// mode: "client",
|
||||||
mode: "client",
|
// pageSize: 10,
|
||||||
pageSize: 10,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const [selectedRowKeys, setSelectedRowKeys] = React.useState<GridRowSelectionModel>([]);
|
|
||||||
const hasSelected = selectedRowKeys.length > 0;
|
|
||||||
|
|
||||||
|
|
||||||
// const updateSelectedItems = () => {
|
|
||||||
// mutate(
|
|
||||||
// {
|
|
||||||
// resource: "posts",
|
|
||||||
// ids: selectedRowKeys.map(String),
|
|
||||||
// values: {
|
|
||||||
// status: "approved",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// onSuccess: () => {
|
|
||||||
// setSelectedRowKeys([]);
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const { data: categoryData, isLoading: categoryIsLoading } = useMany({
|
|
||||||
// resource: "categories",
|
|
||||||
// ids:
|
|
||||||
// dataGridProps?.rows
|
|
||||||
// ?.map((item: any) => item?.category?.id)
|
|
||||||
// .filter(Boolean) ?? [],
|
|
||||||
// queryOptions: {
|
|
||||||
// enabled: !!dataGridProps?.rows,
|
|
||||||
// },
|
// },
|
||||||
// });
|
// });
|
||||||
|
|
||||||
const { mutate } = useUpdate();
|
const dataProvider = "monitoringfiles";
|
||||||
|
const apiUrl = useApiUrl(dataProvider);
|
||||||
|
const myUrl = apiUrl + "/monitoring/mondfaivalable";
|
||||||
|
|
||||||
|
const { data: mons, isLoading: monsIsLoading, isError: monsError } = useCustom<IMonFilter[]>({
|
||||||
|
url: myUrl,
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
|
||||||
|
let monitorings : IMonFilter[] | undefined = mons?.data;
|
||||||
|
// let isDisabled = true;
|
||||||
|
|
||||||
|
|
||||||
|
// const [filters, setFilters] = useState<IMonFilter[]> (monitorings.length > 0 ? [monitorings[0]] : []);
|
||||||
|
//const [filters, setFilters] = useState<IMonFilter[]> ([]);
|
||||||
|
const [filters, setFilters] = useState<IMonFilter | undefined> (undefined);
|
||||||
|
// const [value, setValue] = useState<string[]>([]);
|
||||||
|
const [selectedRowKeys, setSelectedRowKeys] = useState<GridRowSelectionModel>([]);
|
||||||
|
const hasSelected = selectedRowKeys.length > 0;
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [isDisabled, setDisabled] = useState(true);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect( () => {
|
||||||
|
if (monsIsLoading) {
|
||||||
|
|
||||||
|
}
|
||||||
|
if ((mons!= undefined) && (mons?.data != undefined)) {
|
||||||
|
let initFilter : IMonFilter = mons.data[0];
|
||||||
|
setFilters(initFilter);
|
||||||
|
setDisabled(false);
|
||||||
|
}
|
||||||
|
},[mons, monsIsLoading, monsError]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const onClose = (value: boolean) => {
|
||||||
|
setOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const downloadSelectedItems = () => {
|
||||||
|
setOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const downloadSelectedItems = () => {}
|
|
||||||
const deleteSelectedItems = () => {}
|
const deleteSelectedItems = () => {}
|
||||||
|
|
||||||
|
|
||||||
|
const setItems = () => {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
const columns = React.useMemo<GridColDef<IMonitoringFile>[]>(
|
const columns = React.useMemo<GridColDef<IMonitoringFile>[]>(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
@@ -153,7 +175,6 @@ export const MonDatafileList = () => {
|
|||||||
renderCell: function render({ row }) {
|
renderCell: function render({ row }) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ShowButton hideText recordItemId={row.id} />
|
|
||||||
<DeleteButton hideText recordItemId={row.id} />
|
<DeleteButton hideText recordItemId={row.id} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -166,10 +187,119 @@ export const MonDatafileList = () => {
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
let modal = null;
|
||||||
|
|
||||||
|
if ((open) && (filters != undefined)) {
|
||||||
|
modal = (
|
||||||
|
<MFDownlaodDialig
|
||||||
|
monitoringId= {filters.id}
|
||||||
|
elements={selectedRowKeys}
|
||||||
|
onClose={onClose}
|
||||||
|
open={open}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let table = null;
|
||||||
|
|
||||||
|
if ((monitorings != undefined) && (monitorings.length > 0) && (filters != undefined)) {
|
||||||
|
table = (
|
||||||
|
<MonDatafileTable
|
||||||
|
monfilterId={filters.id}
|
||||||
|
setDF={setSelectedRowKeys}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
table = (
|
||||||
|
<DataGrid
|
||||||
|
rows={[]}
|
||||||
|
columns={columns}
|
||||||
|
autoHeight
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let filterCompo = null;
|
||||||
|
|
||||||
|
if (filters != undefined) {
|
||||||
|
filterCompo = (
|
||||||
|
<Autocomplete
|
||||||
|
options={monitorings!= undefined ? monitorings : []}
|
||||||
|
value={filters}
|
||||||
|
onChange={(event: any, newValue) => {
|
||||||
|
if (newValue != undefined) {
|
||||||
|
setFilters(newValue);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
getOptionLabel={(option) => {
|
||||||
|
return option.name;
|
||||||
|
}}
|
||||||
|
disabled={isDisabled}
|
||||||
|
id="Mon-Filter"
|
||||||
|
sx={{ width: 300 }}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Monitoring Filter" />}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List
|
<List
|
||||||
wrapperProps={{ sx: { backgroundColor: "lightsteelblue", }, }}
|
|
||||||
headerProps={{
|
headerProps={{
|
||||||
|
subheader: (
|
||||||
|
<Stack direction="row">
|
||||||
|
<Button
|
||||||
|
disabled = {!hasSelected}
|
||||||
|
startIcon={<Download color="primary" />}
|
||||||
|
onClick={downloadSelectedItems}
|
||||||
|
>
|
||||||
|
Download
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
disabled = {!hasSelected}
|
||||||
|
startIcon={<Delete color="primary" />}
|
||||||
|
onClick={deleteSelectedItems}
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
startIcon={<Settings color="primary" />}
|
||||||
|
onClick={setItems}
|
||||||
|
>
|
||||||
|
Settings
|
||||||
|
</Button>
|
||||||
|
{filterCompo}
|
||||||
|
</Stack>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{table}
|
||||||
|
{modal}
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// isOptionEqualToValue={(option: IMonFilter[], value) => option === value}
|
||||||
|
|
||||||
|
/*
|
||||||
|
<Button
|
||||||
|
startIcon={<Download color="primary" />}
|
||||||
|
onClick={() => downloadSelectedItems()}
|
||||||
|
>
|
||||||
|
Download
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
<List
|
||||||
|
wrapperProps={{ sx: { backgroundColor: "lightsteelblue", }, }}
|
||||||
|
headerProps={{
|
||||||
subheader: hasSelected && (
|
subheader: hasSelected && (
|
||||||
<Stack direction="row">
|
<Stack direction="row">
|
||||||
<Button
|
<Button
|
||||||
@@ -186,22 +316,9 @@ export const MonDatafileList = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DataGrid
|
*/
|
||||||
{...dataGridProps}
|
|
||||||
columns={columns}
|
|
||||||
autoHeight
|
|
||||||
checkboxSelection
|
|
||||||
onRowSelectionModelChange={(newSelectionModel) => {
|
|
||||||
setSelectedRowKeys(newSelectionModel);
|
|
||||||
}}
|
|
||||||
rowSelectionModel={selectedRowKeys}
|
|
||||||
/>
|
|
||||||
</List>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
<List
|
<List
|
||||||
|
|||||||
215
vrpmdvfrontend/src/pages/monitorings/mondatfiletable.tsx
Normal file
215
vrpmdvfrontend/src/pages/monitorings/mondatfiletable.tsx
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
import { DataGrid, GridColDef, GridRowSelectionModel } from "@mui/x-data-grid";
|
||||||
|
import { Download, Delete, Settings } from "@mui/icons-material";
|
||||||
|
import {UseMonDownloadFile, useMonfiledownload} from "../../hooks/data/usemfdownload"
|
||||||
|
|
||||||
|
import {
|
||||||
|
DateField,
|
||||||
|
DeleteButton,
|
||||||
|
EditButton,
|
||||||
|
List,
|
||||||
|
MarkdownField,
|
||||||
|
NumberField,
|
||||||
|
ShowButton,
|
||||||
|
useDataGrid,
|
||||||
|
} from "@refinedev/mui";
|
||||||
|
|
||||||
|
import React, { Dispatch, SetStateAction } from "react";
|
||||||
|
import { IMonitoring, IMonitoringFile } from "./monitorings.types";
|
||||||
|
import { useApiUrl, useCustom, useList, useUpdate } from "@refinedev/core";
|
||||||
|
import Button from "@mui/material/Button/Button";
|
||||||
|
import Stack from "@mui/material/Stack/Stack";
|
||||||
|
import MFDownlaodDialig from "../../components/download/mfdownlaodDialog";
|
||||||
|
import { IMonFilter } from "./filter/monfilter";
|
||||||
|
|
||||||
|
export interface MonDatafileTableProps {
|
||||||
|
//monfilters: IMonFilter[],
|
||||||
|
monfilterId: string,
|
||||||
|
setDF: Dispatch<SetStateAction<GridRowSelectionModel>>
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// export const MonDatafileTable = ({monfilters, setDF}: MonDatafileTableProps) => {
|
||||||
|
export const MonDatafileTable = ({monfilterId, setDF}: MonDatafileTableProps) => {
|
||||||
|
|
||||||
|
const [selectedRowKeys, setSelectedRowKeys] = React.useState<GridRowSelectionModel>([]);
|
||||||
|
const hasSelected = selectedRowKeys.length > 0;
|
||||||
|
|
||||||
|
|
||||||
|
const dataProvider = "monitoringfiles";
|
||||||
|
|
||||||
|
const { dataGridProps } = useDataGrid<IMonitoringFile>({
|
||||||
|
syncWithLocation: true,
|
||||||
|
dataProviderName: dataProvider,
|
||||||
|
pagination: {
|
||||||
|
mode: "client",
|
||||||
|
pageSize: 10,
|
||||||
|
},
|
||||||
|
filters: {
|
||||||
|
initial: [
|
||||||
|
{
|
||||||
|
field: "monId",
|
||||||
|
operator: "eq",
|
||||||
|
value: monfilterId,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const [open, setOpen] = React.useState(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const handleSelection = (value: GridRowSelectionModel) => {
|
||||||
|
setSelectedRowKeys(value);
|
||||||
|
setDF(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// const onClose = (value: boolean) => {
|
||||||
|
// setOpen(false);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// const downloadSelectedItems = () => {
|
||||||
|
// setOpen(true);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// const deleteSelectedItems = () => {}
|
||||||
|
|
||||||
|
|
||||||
|
// const setItems = () => {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
const columns = React.useMemo<GridColDef<IMonitoringFile>[]>(
|
||||||
|
() => [
|
||||||
|
{
|
||||||
|
field: "name",
|
||||||
|
flex: 1,
|
||||||
|
headerName: "Name",
|
||||||
|
type:"string",
|
||||||
|
minWidth: 250,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: "timestamp",
|
||||||
|
flex: 1,
|
||||||
|
headerName: "Timestamp",
|
||||||
|
minWidth: 30,
|
||||||
|
renderCell: function render({ value }) {
|
||||||
|
let d = new Date();
|
||||||
|
const unixtime = new Date(value);
|
||||||
|
//return <DateField value={unixtime} />;
|
||||||
|
return <DateField value={unixtime} format={'DD-MM-YYYY hh:mm:ss A'}/>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: "samplerate",
|
||||||
|
flex: 0.3,
|
||||||
|
headerName: "Samplerate/Hz",
|
||||||
|
renderCell: function render({ row }) {
|
||||||
|
return (
|
||||||
|
<NumberField
|
||||||
|
value={row.samplerate}
|
||||||
|
options={{
|
||||||
|
minimumIntegerDigits: 1,
|
||||||
|
minimumFractionDigits:0,
|
||||||
|
maximumFractionDigits: 0,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: "sampleperiod",
|
||||||
|
flex: 0.3,
|
||||||
|
headerName: "Period/s",
|
||||||
|
renderCell: function render({ row }) {
|
||||||
|
return (
|
||||||
|
<NumberField
|
||||||
|
value={row.sampleperiod}
|
||||||
|
options={{
|
||||||
|
minimumIntegerDigits: 1,
|
||||||
|
minimumFractionDigits:1,
|
||||||
|
maximumFractionDigits: 3,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: "downtime",
|
||||||
|
flex: 0.3,
|
||||||
|
headerName: "Downtime/s",
|
||||||
|
renderCell: function render({ row }) {
|
||||||
|
return (
|
||||||
|
<NumberField
|
||||||
|
value={row.downtime}
|
||||||
|
options={{
|
||||||
|
minimumIntegerDigits: 1,
|
||||||
|
minimumFractionDigits:1,
|
||||||
|
maximumFractionDigits: 3,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: "actions",
|
||||||
|
headerName: "Actions",
|
||||||
|
sortable: false,
|
||||||
|
renderCell: function render({ row }) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DeleteButton hideText recordItemId={row.id} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
align: "center",
|
||||||
|
headerAlign: "center",
|
||||||
|
minWidth: 80,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DataGrid
|
||||||
|
{...dataGridProps}
|
||||||
|
columns={columns}
|
||||||
|
autoHeight
|
||||||
|
checkboxSelection
|
||||||
|
onRowSelectionModelChange={(newSelectionModel) => {
|
||||||
|
handleSelection(newSelectionModel);
|
||||||
|
}}
|
||||||
|
rowSelectionModel={selectedRowKeys}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
import { useState, createContext, Dispatch, SetStateAction} from 'react';
|
||||||
|
|
||||||
|
interface AppContextInterface {
|
||||||
|
mode: PaletteMode;
|
||||||
|
setMode: Dispatch<SetStateAction<PaletteMode>>
|
||||||
|
}
|
||||||
|
|
||||||
|
function App() {
|
||||||
|
const ColorModeContext = createContext<AppContextInterface>({
|
||||||
|
mode: 'dark', // set a default value
|
||||||
|
setMode: () => {},
|
||||||
|
})
|
||||||
|
|
||||||
|
const [mode, setMode] = useState<PaletteMode>('dark');
|
||||||
|
*/
|
||||||
|
|
||||||
@@ -22,5 +22,20 @@ export interface IMonitoring {
|
|||||||
timestamp: string;
|
timestamp: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IMonSample {
|
||||||
|
channels: number[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IMonSampleFile {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
samplerate: number;
|
||||||
|
sampleperiod: number;
|
||||||
|
downtime: number;
|
||||||
|
timestamp: string;
|
||||||
|
channels: number;
|
||||||
|
values: number[];
|
||||||
|
}
|
||||||
|
|
||||||
//string;
|
//string;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
BIN
vrpmdvserver/__pycache__/vrpmdvmonchannels.cpython-310.pyc
Normal file
BIN
vrpmdvserver/__pycache__/vrpmdvmonchannels.cpython-310.pyc
Normal file
Binary file not shown.
BIN
vrpmdvserver/__pycache__/vrpmdvmonchannelschema.cpython-310.pyc
Normal file
BIN
vrpmdvserver/__pycache__/vrpmdvmonchannelschema.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
vrpmdvserver/__pycache__/vrpmdvmonfilescomplete.cpython-310.pyc
Normal file
BIN
vrpmdvserver/__pycache__/vrpmdvmonfilescomplete.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
vrpmdvserver/__pycache__/vrpmdvmonfilter.cpython-310.pyc
Normal file
BIN
vrpmdvserver/__pycache__/vrpmdvmonfilter.cpython-310.pyc
Normal file
Binary file not shown.
BIN
vrpmdvserver/__pycache__/vrpmdvmonfilterschema.cpython-310.pyc
Normal file
BIN
vrpmdvserver/__pycache__/vrpmdvmonfilterschema.cpython-310.pyc
Normal file
Binary file not shown.
BIN
vrpmdvserver/__pycache__/vrpmdvmonsensor.cpython-310.pyc
Normal file
BIN
vrpmdvserver/__pycache__/vrpmdvmonsensor.cpython-310.pyc
Normal file
Binary file not shown.
BIN
vrpmdvserver/__pycache__/vrpmdvmonsensorschema.cpython-310.pyc
Normal file
BIN
vrpmdvserver/__pycache__/vrpmdvmonsensorschema.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
1
vrpmdvserver/utilities/__pycache__/.gitignore
vendored
Normal file
1
vrpmdvserver/utilities/__pycache__/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/union.cpython-310.pyc
|
||||||
26
vrpmdvserver/utilities/union.py
Normal file
26
vrpmdvserver/utilities/union.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
"""
|
||||||
|
Marshmallow fields
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Extension on the already available marshmallow fields
|
||||||
|
"""
|
||||||
|
from marshmallow import ValidationError, fields
|
||||||
|
|
||||||
|
|
||||||
|
class UnionField(fields.Field):
|
||||||
|
"""Field that deserializes multi-type input data to app-level objects."""
|
||||||
|
def __init__(self, types: list = [], *args, **kwargs) -> None:
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
if types:
|
||||||
|
self.types = types
|
||||||
|
else:
|
||||||
|
raise AttributeError('No types provided on union field')
|
||||||
|
|
||||||
|
def _deserialize(self, value, attr, data, **kwargs):
|
||||||
|
if bool([isinstance(value, i) for i in self.types if isinstance(value, i)]):
|
||||||
|
return value
|
||||||
|
else:
|
||||||
|
raise ValidationError(
|
||||||
|
f'Field shoud be any of the following types: [{", ".join([str(i) for i in self.types])}]'
|
||||||
|
)
|
||||||
@@ -5,11 +5,16 @@ import uuid
|
|||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from marshmallow import EXCLUDE
|
from marshmallow import EXCLUDE, ValidationError
|
||||||
#from vrpmdvcreatemoncmd import VRPMDV_CreateMonCmd
|
#from vrpmdvcreatemoncmd import VRPMDV_CreateMonCmd
|
||||||
#from vrpmdvcreatemonschema import VRPMDV_CreateMonSchema
|
#from vrpmdvcreatemonschema import VRPMDV_CreateMonSchema
|
||||||
#from vrpmdvdeletemoncmd import VRPMDV_DeleteMonCmd
|
#from vrpmdvdeletemoncmd import VRPMDV_DeleteMonCmd
|
||||||
#from vrpmdvdeletemonschema import VRPMDV_DeleteMonSchema
|
#from vrpmdvdeletemonschema import VRPMDV_DeleteMonSchema
|
||||||
|
from vrpmdvmonfilescompleteschema import VRPMDV_MonfilesCompleteSchema
|
||||||
|
from vrpmdvmonfilter import VRPMDV_MonFilter
|
||||||
|
from vrpmdvmonfilterschema import VRPMDV_MonFilterSchema
|
||||||
|
from vrpmdvmonsensorschema import VRPMDV_MonSensorSchema
|
||||||
|
from vrpmdvmonchannelschema import VRPMDV_MonChannelSchema
|
||||||
from vrpmdvmonfilesschema import VRPMDV_MonfilesSchema
|
from vrpmdvmonfilesschema import VRPMDV_MonfilesSchema
|
||||||
from vrpmdvmonitoring import VRPMDV_Monitoring
|
from vrpmdvmonitoring import VRPMDV_Monitoring
|
||||||
from vrpmdvmonitoringschema import VRPMDV_MonitoringSchema
|
from vrpmdvmonitoringschema import VRPMDV_MonitoringSchema
|
||||||
@@ -35,7 +40,7 @@ class VRPMDV_Data:
|
|||||||
self.rtservice.initCoproFW("home/root/elffile","zephyr_openamp_rsc_table.elf")
|
self.rtservice.initCoproFW("home/root/elffile","zephyr_openamp_rsc_table.elf")
|
||||||
self.logTask = None #createCoproLoggingTask()
|
self.logTask = None #createCoproLoggingTask()
|
||||||
self.loaded = self.loadFile()
|
self.loaded = self.loadFile()
|
||||||
self.monfilespath = '/home/markus/monfiles/'
|
self.monfilespath = '/home/root/monfiles/'
|
||||||
#start the monitorings
|
#start the monitorings
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.startMons();
|
self.startMons();
|
||||||
@@ -346,7 +351,7 @@ class VRPMDV_Data:
|
|||||||
try:
|
try:
|
||||||
return next(x for x in self.mons if str(x.id) == id)
|
return next(x for x in self.mons if str(x.id) == id)
|
||||||
except:
|
except:
|
||||||
return "no Item found"
|
return None #"no Item found"
|
||||||
|
|
||||||
def getMonitoring2files(self):
|
def getMonitoring2files(self):
|
||||||
#search in the given directory
|
#search in the given directory
|
||||||
@@ -354,32 +359,36 @@ class VRPMDV_Data:
|
|||||||
#return for the filter
|
#return for the filter
|
||||||
|
|
||||||
|
|
||||||
def getMonitoringfiles(self, id):
|
def getMonitoringfiles(self, id, params):
|
||||||
#search in the given directory
|
#search in the given directory
|
||||||
dirname = os.path.dirname(self.monfilespath)
|
monId = params.get('monId')
|
||||||
dirs = []
|
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
|
||||||
for d in os.listdir(dirname) :
|
logging.info("getMonitoringfiles: monId:%s", monId)
|
||||||
# if os.path.isdir(d) :
|
|
||||||
dirs.append(d)
|
|
||||||
|
|
||||||
#dirs = [d for d in os.listdir(dirname) if os.path.isdir(d)]
|
if (monId == None):
|
||||||
id = '0'
|
return None
|
||||||
#currently we return the first one
|
|
||||||
for dir in dirs:
|
|
||||||
mon = self.findMonitoring(dir)
|
|
||||||
id = mon.id
|
|
||||||
|
|
||||||
|
complete = False
|
||||||
|
|
||||||
|
mons = self.getMonofMonfiles(monId)
|
||||||
|
logging.info("getMonitoringfiles: mons.length:%d", len(mons))
|
||||||
|
if (len(mons) == 0) :
|
||||||
|
return None
|
||||||
|
else :
|
||||||
|
#TODO ML: only one monitoring
|
||||||
|
monId = mons[0].id
|
||||||
|
|
||||||
#TODO ML change to array
|
#TODO ML change to array
|
||||||
#for file in files:
|
#for file in files:
|
||||||
filename = self.monfilespath + str(id) + '/'
|
filename = self.monfilespath + str(monId) + '/'
|
||||||
monfiles = self.loadMonfiles(filename)
|
monfiles = self.loadMonfiles(filename, complete)
|
||||||
schema = VRPMDV_MonfilesSchema()
|
schema = VRPMDV_MonfilesSchema()
|
||||||
result = schema.dumps(monfiles, many=True)
|
result = schema.dumps(monfiles, many=True)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def loadMonfiles(self, id):
|
def loadMonfiles(self, id, complete):
|
||||||
#files = [f for f in os.listdir() if os.path.isfile(f)]
|
#files = [f for f in os.listdir() if os.path.isfile(f)]
|
||||||
|
logging.info("loadMonfiles: monId:%s", id)
|
||||||
completeMonPath = os.path.dirname(id)
|
completeMonPath = os.path.dirname(id)
|
||||||
monfiles = []
|
monfiles = []
|
||||||
for f in os.listdir(completeMonPath) :
|
for f in os.listdir(completeMonPath) :
|
||||||
@@ -387,18 +396,77 @@ class VRPMDV_Data:
|
|||||||
try:
|
try:
|
||||||
completeFilepath = id + str(f)
|
completeFilepath = id + str(f)
|
||||||
with open(completeFilepath, 'r') as f:
|
with open(completeFilepath, 'r') as f:
|
||||||
|
logging.info("loadMonfiles: before fmonfile:%s", completeFilepath)
|
||||||
fmonfile = f.read()
|
fmonfile = f.read()
|
||||||
|
logging.info("loadMonfiles: after fmonfile:%s", completeFilepath)
|
||||||
if fmonfile:
|
if fmonfile:
|
||||||
|
# if (complete):
|
||||||
|
# schema = VRPMDV_MonfilesCompleteSchema()
|
||||||
|
# else :
|
||||||
|
logging.info("loadMonfiles: before schemaload")
|
||||||
schema = VRPMDV_MonfilesSchema()
|
schema = VRPMDV_MonfilesSchema()
|
||||||
|
try:
|
||||||
monfile = schema.loads(fmonfile, unknown=EXCLUDE)
|
monfile = schema.loads(fmonfile, unknown=EXCLUDE)
|
||||||
|
except ValidationError as err:
|
||||||
|
logging.info("SchemaError: %s",err.messages) # => {"email": ['"foo" is not a valid email address.']}
|
||||||
|
logging.info("Data: %s",err.valid_data) # => {"name": "John"}
|
||||||
monfiles.append(monfile)
|
monfiles.append(monfile)
|
||||||
except:
|
except:
|
||||||
#nothing todo ML we should create a file later the database
|
#nothing todo ML we should create a file later the database
|
||||||
print("file not found")
|
print("file not found")
|
||||||
|
logging.info("loadMonfiles: file not found:%s", completeFilepath)
|
||||||
return monfiles
|
return monfiles
|
||||||
|
|
||||||
|
|
||||||
|
def getMonsDFAvalable(self):
|
||||||
|
monfilters = []
|
||||||
|
mons = self.getMonofMonfiles(0)
|
||||||
|
if (len(mons) == 0):
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
schema = VRPMDV_MonFilterSchema()
|
||||||
|
for mon in mons:
|
||||||
|
monfilter = VRPMDV_MonFilter(str(mon.id), mon.name)
|
||||||
|
monfilters.append(monfilter)
|
||||||
|
return schema.dumps(monfilters, many=True)
|
||||||
|
|
||||||
|
def getMonofMonfiles(self, monId) :
|
||||||
|
dirname = os.path.dirname(self.monfilespath)
|
||||||
|
dirs = []
|
||||||
|
for d in os.listdir(dirname) :
|
||||||
|
path_file = self.monfilespath + d #os.sep.join([self.monfilespath, d])
|
||||||
|
if os.path.isdir(path_file) :
|
||||||
|
dirs.append(d)
|
||||||
|
mons = []
|
||||||
|
for dir in dirs:
|
||||||
|
mon = self.findMonitoring(dir)
|
||||||
|
if ((mon != None) and ((monId == 0 ) or (monId == str(mon.id)))):
|
||||||
|
mons.append(mon)
|
||||||
|
# monId = mon.id
|
||||||
|
# else:
|
||||||
|
# return None
|
||||||
|
|
||||||
|
return mons
|
||||||
|
|
||||||
|
|
||||||
|
def getMFDownload(self, params):
|
||||||
|
#search in the given directory
|
||||||
|
monId = params.get('monId')
|
||||||
|
if (monId == None):
|
||||||
|
return None
|
||||||
|
|
||||||
|
fileId = params.get('fileid')
|
||||||
|
mons = self.getMonofMonfiles(monId)
|
||||||
|
|
||||||
|
#TODO ML change to array
|
||||||
|
#for file in files:
|
||||||
|
filename = self.monfilespath + str(monId) + '/'
|
||||||
|
monfiles = self.loadMonfiles(filename, True)
|
||||||
|
schema = VRPMDV_MonfilesCompleteSchema()
|
||||||
|
result = schema.dumps(monfiles, many=True)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# This is to get the directory that the program
|
# This is to get the directory that the program
|
||||||
# is currently running in.
|
# is currently running in.
|
||||||
|
|||||||
9
vrpmdvserver/vrpmdvmonchannels.py
Normal file
9
vrpmdvserver/vrpmdvmonchannels.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import datetime as dt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class VRPMDV_MonChannels:
|
||||||
|
def __init__(self, name , valuetype):
|
||||||
|
self.name = name
|
||||||
|
self.valuetype = valuetype
|
||||||
|
|
||||||
18
vrpmdvserver/vrpmdvmonchannelschema.py
Normal file
18
vrpmdvserver/vrpmdvmonchannelschema.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import uuid
|
||||||
|
import datetime as dt
|
||||||
|
from marshmallow import Schema, fields, post_load, EXCLUDE
|
||||||
|
|
||||||
|
from vrpmdvmonchannels import VRPMDV_MonChannels
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class VRPMDV_MonChannelSchema(Schema):
|
||||||
|
name = fields.String()
|
||||||
|
valuetype = fields.String()
|
||||||
|
#value = fields.Number()
|
||||||
|
|
||||||
|
@post_load
|
||||||
|
def make_vrpmdv_MonfilesChannelSchema(self, data, **kwargs):
|
||||||
|
return VRPMDV_MonChannels(**data)
|
||||||
|
|
||||||
|
|
||||||
@@ -3,12 +3,13 @@ import datetime as dt
|
|||||||
|
|
||||||
|
|
||||||
class VRPMDV_Monfiles:
|
class VRPMDV_Monfiles:
|
||||||
def __init__(self, id, name , samplerate, sampleperiod, downtime, timestamp) :
|
def __init__(self, id, monid, name , samplerate, sampleperiod, downtime, timestamp, hwdescription) :
|
||||||
self.id = id
|
self.id = id
|
||||||
|
self.monid = monid
|
||||||
self.name = name
|
self.name = name
|
||||||
self.samplerate = samplerate
|
self.samplerate = samplerate
|
||||||
self.sampleperiod = sampleperiod
|
self.sampleperiod = sampleperiod
|
||||||
self.downtime = downtime
|
self.downtime = downtime
|
||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
|
self.hwdescription = hwdescription
|
||||||
|
|
||||||
|
|||||||
19
vrpmdvserver/vrpmdvmonfilescomplete.py
Normal file
19
vrpmdvserver/vrpmdvmonfilescomplete.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import datetime as dt
|
||||||
|
|
||||||
|
from vrpmdvmonfiles import VRPMDV_Monfiles
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class VRPMDV_MonfilesComplete(VRPMDV_Monfiles):
|
||||||
|
def __init__(self, id, monid, name , samplerate, sampleperiod, downtime, timestamp, hwdescription, values) :
|
||||||
|
self.id = id
|
||||||
|
self.monid = monid
|
||||||
|
self.name = name
|
||||||
|
self.samplerate = samplerate
|
||||||
|
self.sampleperiod = sampleperiod
|
||||||
|
self.downtime = downtime
|
||||||
|
self.timestamp = timestamp
|
||||||
|
self.hwdescription = hwdescription
|
||||||
|
self.values = values
|
||||||
|
|
||||||
39
vrpmdvserver/vrpmdvmonfilescompleteschema.py
Normal file
39
vrpmdvserver/vrpmdvmonfilescompleteschema.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import uuid
|
||||||
|
import datetime as dt
|
||||||
|
from marshmallow import Schema, fields, post_load, EXCLUDE
|
||||||
|
from utilities.union import UnionField
|
||||||
|
from vrpmdvmonfilescomplete import VRPMDV_MonfilesComplete
|
||||||
|
from vrpmdvmonfilesschema import VRPMDV_MonfilesSchema
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# books = fields.List(fields.Nested("BookSchema", exclude=("author",)))
|
||||||
|
|
||||||
|
class VRPMDV_MonfilesCompleteSchema(Schema):
|
||||||
|
id = fields.String(required=True)
|
||||||
|
monid = fields.String(required=True)
|
||||||
|
name = fields.String(required=True)
|
||||||
|
samplerate = fields.Integer(required=True)
|
||||||
|
sampleperiod = fields.Integer(required=True)
|
||||||
|
downtime = fields.Integer(required=True)
|
||||||
|
timestamp = fields.Integer(required=True)
|
||||||
|
hwdescription = fields.List(fields.Nested("VRPMDV_MonSensorSchema"))
|
||||||
|
values = fields.List(UnionField(
|
||||||
|
types=[int, float],
|
||||||
|
metadata={
|
||||||
|
"description": "Multiple types.",
|
||||||
|
},
|
||||||
|
))
|
||||||
|
|
||||||
|
@post_load
|
||||||
|
def make_vrpmdv_MonfilesCompleteSchema(self, data, **kwargs):
|
||||||
|
return VRPMDV_MonfilesComplete(**data)
|
||||||
|
|
||||||
|
|
||||||
|
# some_field = UnionField(
|
||||||
|
# types=[str, int, float, dict, list, bool, set, tuple],
|
||||||
|
# metadata={
|
||||||
|
# "description": "Multiple types.",
|
||||||
|
# },
|
||||||
|
# )
|
||||||
@@ -1,22 +1,24 @@
|
|||||||
import uuid
|
import uuid
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
from marshmallow import Schema, fields, post_load, EXCLUDE
|
from marshmallow import Schema, fields, post_load, EXCLUDE
|
||||||
|
|
||||||
from vrpmdvmonfiles import VRPMDV_Monfiles
|
from vrpmdvmonfiles import VRPMDV_Monfiles
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class VRPMDV_MonfilesSchema(Schema):
|
class VRPMDV_MonfilesSchema(Schema):
|
||||||
id = fields.String(required=True)
|
id = fields.String(required=True)
|
||||||
|
monid = fields.String(required=True)
|
||||||
name = fields.String(required=True)
|
name = fields.String(required=True)
|
||||||
samplerate = fields.Integer(required=True)
|
samplerate = fields.Integer(required=True)
|
||||||
sampleperiod = fields.Integer(required=True)
|
sampleperiod = fields.Integer(required=True)
|
||||||
downtime = fields.Integer(required=True)
|
downtime = fields.Integer(required=True)
|
||||||
timestamp = fields.Integer(required=True)
|
timestamp = fields.Integer(required=True)
|
||||||
#samples = fields.List()
|
hwdescription = fields.List(fields.Nested("VRPMDV_MonSensorSchema"))
|
||||||
|
|
||||||
|
|
||||||
@post_load
|
@post_load
|
||||||
def make_vrpmdv_Monfiles(self, data, **kwargs):
|
def make_vrpmdv_Monfiles(self, data, **kwargs):
|
||||||
return VRPMDV_Monfiles(**data)
|
return VRPMDV_Monfiles(**data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
10
vrpmdvserver/vrpmdvmonfilter.py
Normal file
10
vrpmdvserver/vrpmdvmonfilter.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import datetime as dt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class VRPMDV_MonFilter:
|
||||||
|
def __init__(self, id, name ) :
|
||||||
|
self.id = id
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
|
||||||
16
vrpmdvserver/vrpmdvmonfilterschema.py
Normal file
16
vrpmdvserver/vrpmdvmonfilterschema.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import uuid
|
||||||
|
import datetime as dt
|
||||||
|
from marshmallow import Schema, fields, post_load
|
||||||
|
from vrpmdvmonfilter import VRPMDV_MonFilter
|
||||||
|
|
||||||
|
|
||||||
|
class VRPMDV_MonFilterSchema(Schema):
|
||||||
|
id = fields.String()
|
||||||
|
name = fields.String()
|
||||||
|
|
||||||
|
@post_load
|
||||||
|
def make_vrpmdv_MonFilter(self, data, **kwargs):
|
||||||
|
return VRPMDV_MonFilter(**data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
15
vrpmdvserver/vrpmdvmonsamples.py.old
Normal file
15
vrpmdvserver/vrpmdvmonsamples.py.old
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import datetime as dt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class VRPMDV_MonValues:
|
||||||
|
def __init__(self, values):
|
||||||
|
self.values = values
|
||||||
|
|
||||||
|
#class VRPMDV_MonSamples:
|
||||||
|
# def __init__(self, sensors):
|
||||||
|
# self.sensors = sensors
|
||||||
|
|
||||||
17
vrpmdvserver/vrpmdvmonsampleschema.py.old
Normal file
17
vrpmdvserver/vrpmdvmonsampleschema.py.old
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import uuid
|
||||||
|
import datetime as dt
|
||||||
|
from marshmallow import Schema, fields, post_load, EXCLUDE
|
||||||
|
|
||||||
|
from vrpmdvmonsamples import VRPMDV_MonSamples
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class VRPMDV_MonfilesSampleSchema(Schema):
|
||||||
|
# sensors = fields.List(fields.Nested("VRPMDV_MonfilesSensorSchema"))
|
||||||
|
values = fields.List();
|
||||||
|
|
||||||
|
@post_load
|
||||||
|
def make_vrpmdv_MonfilesSampleSchema(self, data, **kwargs):
|
||||||
|
return VRPMDV_MonSamples(**data)
|
||||||
11
vrpmdvserver/vrpmdvmonsensor.py
Normal file
11
vrpmdvserver/vrpmdvmonsensor.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import datetime as dt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class VRPMDV_MonSensor:
|
||||||
|
def __init__(self, name , channels):
|
||||||
|
self.name = name
|
||||||
|
self.channels = channels
|
||||||
|
|
||||||
16
vrpmdvserver/vrpmdvmonsensorschema.py
Normal file
16
vrpmdvserver/vrpmdvmonsensorschema.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import uuid
|
||||||
|
import datetime as dt
|
||||||
|
from marshmallow import Schema, fields, post_load, EXCLUDE
|
||||||
|
|
||||||
|
from vrpmdvmonsensor import VRPMDV_MonSensor
|
||||||
|
|
||||||
|
|
||||||
|
class VRPMDV_MonSensorSchema(Schema):
|
||||||
|
name = fields.String()
|
||||||
|
channels = fields.List(fields.Nested("VRPMDV_MonChannelSchema"))
|
||||||
|
|
||||||
|
@post_load
|
||||||
|
def make_vrpmdv_MonfilesSensorSchema(self, data, **kwargs):
|
||||||
|
return VRPMDV_MonSensor(**data)
|
||||||
|
|
||||||
|
|
||||||
@@ -79,15 +79,39 @@ def setStatus(id):
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
@app.route('/vrpmdvapi/1_0/monitoringfiles', methods=['GET'])
|
@app.route('/vrpmdvapi/1_0/monitoring/mondfaivalable', methods=['GET'])
|
||||||
def get_monitoringfiles():
|
def get_mondfaivalable():
|
||||||
#vrpmreq = VRPMDV_MonReqSchema().load(request.get_json())
|
data = vrpmdvdata.getMonsDFAvalable()
|
||||||
#data = vrpmdvdata.createMonitoring(vrpmreq)
|
if (data == None):
|
||||||
data = vrpmdvdata.getMonitoringfiles(0)
|
resp = Response("no Item found", status=404, mimetype='application/json')
|
||||||
|
else:
|
||||||
resp = Response(data, status=200, mimetype='application/json')
|
resp = Response(data, status=200, mimetype='application/json')
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/vrpmdvapi/1_0/monitoringfiles', methods=['GET'])
|
||||||
|
def get_monitoringfiles():
|
||||||
|
vrpmreqjson = request.args
|
||||||
|
#vrpmreq = VRPMDV_MonReqSchema().load(request.get_json())
|
||||||
|
#data = vrpmdvdata.createMonitoring(vrpmreq)
|
||||||
|
data = vrpmdvdata.getMonitoringfiles(0, request.args)
|
||||||
|
if (data == None):
|
||||||
|
resp = Response("no Item found", status=404, mimetype='application/json')
|
||||||
|
else:
|
||||||
|
resp = Response(data, status=200, mimetype='application/json')
|
||||||
|
return resp
|
||||||
|
|
||||||
|
@app.route('/vrpmdvapi/1_0/monitoringfiles/download', methods=['GET'])
|
||||||
|
def get_mfDownload():
|
||||||
|
vrpmreqjson = request.args
|
||||||
|
|
||||||
|
data = vrpmdvdata.getMFDownload(request.args)
|
||||||
|
if (data == None):
|
||||||
|
resp = Response("no Item found", status=404, mimetype='application/json')
|
||||||
|
else:
|
||||||
|
resp = Response(data, status=200, mimetype='application/json')
|
||||||
|
return resp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user