Compare commits
6 Commits
feature/do
...
70c4c91035
Author | SHA1 | Date | |
---|---|---|---|
70c4c91035 | |||
aa39597541 | |||
bcbab1383a | |||
bab0984c30 | |||
0667c6ec39 | |||
0d71899ce1 |
@ -1,23 +1,17 @@
|
||||
import { Box, Container, IconButton, Menu, MenuItem, MenuList, Paper, Grow, Popper } from '@material-ui/core';
|
||||
import AccountCircle from '@material-ui/icons/AccountCircle';
|
||||
import AppBar from '@material-ui/core/AppBar';
|
||||
import { positions } from '@material-ui/system';
|
||||
import { Box, Paper } from '@material-ui/core';
|
||||
import { blueGrey, grey, orange } from '@material-ui/core/colors';
|
||||
import { createMuiTheme, createStyles, makeStyles, Theme } from '@material-ui/core/styles';
|
||||
import Toolbar from '@material-ui/core/Toolbar';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import { ThemeProvider } from '@material-ui/styles';
|
||||
import React, { useState, } from 'react';
|
||||
import { BrowserRouter, NavLink, Redirect, Route, Switch, Link } from 'react-router-dom';
|
||||
import BirdmapTitle from './components/appBar/BirdmapTitle';
|
||||
import React, { useState } from 'react';
|
||||
import { BrowserRouter, Redirect, Route, Switch } from 'react-router-dom';
|
||||
import BirdmapBar from './components/appBar/BirdmapBar';
|
||||
import Auth from './components/auth/Auth';
|
||||
import AuthService from './components/auth/AuthService';
|
||||
import { ClickAwayListener } from '@material-ui/core';
|
||||
import MapContainer from './components/heatmap/Heatmap';
|
||||
import Devices from './components/devices/Devices';
|
||||
import { blueGrey, blue, orange, grey } from '@material-ui/core/colors';
|
||||
import DevicesContextProvider from './contexts/DevicesContextProvider'
|
||||
import Dashboard from './components/dashboard/Dashboard';
|
||||
|
||||
import Devices from './components/devices/Devices';
|
||||
import MapContainer from './components/heatmap/Heatmap';
|
||||
import Logs from './components/logs/Logs';
|
||||
import DevicesContextProvider from './contexts/DevicesContextProvider';
|
||||
|
||||
const theme = createMuiTheme({
|
||||
palette: {
|
||||
@ -26,14 +20,13 @@ const theme = createMuiTheme({
|
||||
dark: grey[400],
|
||||
},
|
||||
secondary: {
|
||||
main: orange[200],
|
||||
main: blueGrey[700],
|
||||
dark: blueGrey[50],
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
function App() {
|
||||
|
||||
const [authenticated, setAuthenticated] = useState(AuthService.isAuthenticated());
|
||||
const [isAdmin, setIsAdmin] = useState(AuthService.isAdmin());
|
||||
|
||||
@ -48,6 +41,10 @@ function App() {
|
||||
);
|
||||
}
|
||||
|
||||
const LogsComponent = () => {
|
||||
return <Logs/>
|
||||
}
|
||||
|
||||
const DashboardComponent = () => {
|
||||
return <Dashboard isAdmin={isAdmin}/>;
|
||||
};
|
||||
@ -56,6 +53,7 @@ function App() {
|
||||
return <Devices isAdmin={isAdmin}/>;
|
||||
|
||||
};
|
||||
|
||||
const HeatmapComponent = () => {
|
||||
return (
|
||||
<Paper elevation={0}>
|
||||
@ -64,15 +62,46 @@ function App() {
|
||||
);
|
||||
};
|
||||
|
||||
const HeaderComponent = () => {
|
||||
return (
|
||||
<BirdmapBar onLogout={AuthService.logout} isAdmin={isAdmin} isAuthenticated={authenticated}/>
|
||||
);
|
||||
}
|
||||
|
||||
const PredicateRoute = ({ component: Component, predicate: Predicate, ...rest }: { [x: string]: any, component: any, predicate: any }) => {
|
||||
return (
|
||||
<PredicateRouteInternal {...rest} header={HeaderComponent} body={Component} predicate={Predicate}/>
|
||||
);
|
||||
}
|
||||
|
||||
const PublicRoute = ({ component: Component, ...rest }: { [x: string]: any, component: any }) => {
|
||||
return (
|
||||
<PredicateRoute {...rest} component={Component} predicate={true}/>
|
||||
);
|
||||
}
|
||||
|
||||
const PrivateRoute = ({ component: Component, ...rest }: { [x: string]: any, component: any }) => {
|
||||
return (
|
||||
<PredicateRoute {...rest} component={Component} predicate={authenticated}/>
|
||||
);
|
||||
}
|
||||
|
||||
const AdminRoute = ({ component: Component, ...rest }: { [x: string]: any, component: any }) => {
|
||||
return (
|
||||
<PredicateRoute {...rest} component={Component} predicate={authenticated && isAdmin}/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ThemeProvider theme={theme}>
|
||||
<BrowserRouter>
|
||||
<Switch>
|
||||
<PublicRoute path="/login" component={AuthComponent} />
|
||||
<PublicRoute exact path="/login" component={AuthComponent} />
|
||||
<AdminRoute exact path="/logs" component={LogsComponent} />
|
||||
<DevicesContextProvider>
|
||||
<PrivateRoute path="/" exact authenticated={authenticated} component={DashboardComponent} />
|
||||
<PrivateRoute path="/devices/:id?" exact authenticated={authenticated} component={DevicesComponent} />
|
||||
<PrivateRoute path="/heatmap" exact authenticated={authenticated} component={HeatmapComponent} />
|
||||
<PrivateRoute exact path="/" component={DashboardComponent} />
|
||||
<PrivateRoute exact path="/devices/:id?" component={DevicesComponent} />
|
||||
<PrivateRoute exact path="/heatmap" component={HeatmapComponent} />
|
||||
</DevicesContextProvider>
|
||||
</Switch>
|
||||
</BrowserRouter>
|
||||
@ -82,112 +111,26 @@ function App() {
|
||||
|
||||
export default App;
|
||||
|
||||
const PublicRoute = ({ component: Component, ...rest }: { [x: string]: any, component: any}) => {
|
||||
const PredicateRouteInternal = ({ header: HeaderComponent, body: BodyComponent, predicate: Predicate, ...rest }: { [x: string]: any, header: any, body: any, predicate: any }) => {
|
||||
return (
|
||||
<Route {...rest} render={matchProps => (
|
||||
<DefaultLayout component={Component} authenticated={false} isAdmin={false} {...matchProps} />
|
||||
)} />
|
||||
);
|
||||
}
|
||||
|
||||
const PrivateRoute = ({ component: Component, authenticated: Authenticated, ...rest }: { [x: string]: any, component: any, authenticated: any }) => {
|
||||
return (
|
||||
<Route {...rest} render={matchProps => (
|
||||
Authenticated
|
||||
? <DefaultLayout component={Component} authenticated={Authenticated} {...matchProps} />
|
||||
Predicate
|
||||
? <DefaultLayoutInternal header={HeaderComponent} body={BodyComponent} {...matchProps} />
|
||||
: <Redirect to='/login' />
|
||||
)} />
|
||||
);
|
||||
};
|
||||
|
||||
const DefaultLayout = ({ component: Component, authenticated: Authenticated, ...rest }: { [x: string]: any, component: any, authenticated: any }) => {
|
||||
const DefaultLayoutInternal = ({ header: HeaderComponent, body: BodyComponent, ...rest }: { [x: string]: any, header: any, body: any }) => {
|
||||
const classes = useDefaultLayoutStyles();
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const anchorRef = React.useRef<HTMLButtonElement>(null);
|
||||
|
||||
const handleToggle = () => {
|
||||
setOpen((prevOpen) => !prevOpen);
|
||||
};
|
||||
|
||||
const handleClose = (event: React.MouseEvent<EventTarget>) => {
|
||||
if (anchorRef.current && anchorRef.current.contains(event.target as HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const handleLogout = (event: React.MouseEvent<EventTarget>) => {
|
||||
if (anchorRef.current && anchorRef.current.contains(event.target as HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AuthService.logout();
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
function handleListKeyDown(event: React.KeyboardEvent) {
|
||||
if (event.key === 'Tab') {
|
||||
event.preventDefault();
|
||||
setOpen(false);
|
||||
}
|
||||
}
|
||||
|
||||
const prevOpen = React.useRef(open);
|
||||
React.useEffect(() => {
|
||||
if (prevOpen.current === true && open === false) {
|
||||
anchorRef.current!.focus();
|
||||
}
|
||||
|
||||
prevOpen.current = open;
|
||||
}, [open]);
|
||||
|
||||
|
||||
const renderNavLinks = () => {
|
||||
return Authenticated
|
||||
? <Container className={classes.nav_menu}>
|
||||
<NavLink exact to="/" className={classes.nav_menu_item} activeClassName={classes.nav_menu_item_active}>Dashboard</NavLink>
|
||||
<NavLink to="/devices" className={classes.nav_menu_item} activeClassName={classes.nav_menu_item_active}>Devices</NavLink>
|
||||
<NavLink exact to="/heatmap" className={classes.nav_menu_item} activeClassName={classes.nav_menu_item_active}>Heatmap</NavLink>
|
||||
<IconButton className={classes.nav_menu_icon}
|
||||
ref={anchorRef}
|
||||
aria-haspopup="true"
|
||||
aria-controls={open ? 'menu-list-grow' : undefined}
|
||||
aria-label="account of current user"
|
||||
onClick={handleToggle}>
|
||||
<AccountCircle/>
|
||||
</IconButton>
|
||||
<Popper open={open} anchorEl={anchorRef.current} role={undefined} transition disablePortal>
|
||||
{({ TransitionProps, placement }) => (
|
||||
<Grow
|
||||
{...TransitionProps}
|
||||
style={{ transformOrigin: placement === 'bottom' ? 'center top' : 'center bottom' }}>
|
||||
<Paper>
|
||||
<ClickAwayListener onClickAway={handleClose}>
|
||||
<MenuList autoFocusItem={open} id="menu-list-grow" onKeyDown={handleListKeyDown}>
|
||||
<MenuItem onClick={handleLogout} component={Link} {...{ to: '/login' }}>Logout</MenuItem>
|
||||
</MenuList>
|
||||
</ClickAwayListener>
|
||||
</Paper>
|
||||
</Grow>
|
||||
)}
|
||||
</Popper>
|
||||
</Container>
|
||||
: null;
|
||||
};
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<AppBar position="static" className={classes.bar_root}>
|
||||
<Toolbar>
|
||||
<BirdmapTitle />
|
||||
<Typography component={'span'} className={classes.typo}>
|
||||
{renderNavLinks()}
|
||||
</Typography>
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
<Box zIndex="modal" className={classes.box_root}>
|
||||
<Component {...rest} />
|
||||
<Box className={classes.header}>
|
||||
<HeaderComponent />
|
||||
</Box>
|
||||
<Box className={classes.body}>
|
||||
<BodyComponent {...rest} />
|
||||
</Box>
|
||||
</React.Fragment>
|
||||
);
|
||||
@ -195,46 +138,12 @@ const DefaultLayout = ({ component: Component, authenticated: Authenticated, ...
|
||||
|
||||
const useDefaultLayoutStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
bar_root: {
|
||||
header: {
|
||||
height: '7%',
|
||||
},
|
||||
box_root: {
|
||||
body: {
|
||||
backgroundColor: theme.palette.primary.dark,
|
||||
height: '93%',
|
||||
},
|
||||
typo: {
|
||||
marginLeft: 'auto',
|
||||
color: 'white',
|
||||
},
|
||||
nav_menu: {
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
},
|
||||
nav_menu_icon: {
|
||||
color: 'inherit',
|
||||
marginLeft: '24px',
|
||||
'&:hover': {
|
||||
color: 'inherit',
|
||||
}
|
||||
},
|
||||
nav_menu_item: {
|
||||
textDecoration: 'none',
|
||||
fontWeight: 'normal',
|
||||
color: 'inherit',
|
||||
marginLeft: '24px',
|
||||
'&:hover': {
|
||||
color: 'inherit',
|
||||
}
|
||||
},
|
||||
nav_menu_item_active: {
|
||||
textDecoration: 'underline',
|
||||
fontWeight: 'bold',
|
||||
color: 'inherit',
|
||||
marginLeft: '24px',
|
||||
'&:hover': {
|
||||
color: 'inherit',
|
||||
}
|
||||
},
|
||||
}
|
||||
}),
|
||||
);
|
136
Birdmap.API/ClientApp/src/components/appBar/BirdmapBar.tsx
Normal file
136
Birdmap.API/ClientApp/src/components/appBar/BirdmapBar.tsx
Normal file
@ -0,0 +1,136 @@
|
||||
import { ClickAwayListener, Container, createStyles, Grow, IconButton, makeStyles, MenuItem, MenuList, Paper, Popper, Theme } from '@material-ui/core';
|
||||
import AppBar from '@material-ui/core/AppBar';
|
||||
import Toolbar from '@material-ui/core/Toolbar';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import AccountCircle from '@material-ui/icons/AccountCircle';
|
||||
import React from 'react';
|
||||
import { Link, NavLink } from 'react-router-dom';
|
||||
import BirdmapTitle from './BirdmapTitle';
|
||||
|
||||
export default function BirdmapBar(props: { onLogout: () => void; isAuthenticated: any; isAdmin: any; }) {
|
||||
const classes = useAppbarStyles();
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const anchorRef = React.useRef<HTMLButtonElement>(null);
|
||||
|
||||
const handleToggle = () => {
|
||||
setOpen((prevOpen) => !prevOpen);
|
||||
};
|
||||
|
||||
const handleClose = (event: React.MouseEvent<EventTarget>) => {
|
||||
if (anchorRef.current && anchorRef.current.contains(event.target as HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const handleLogout = (event: React.MouseEvent<EventTarget>) => {
|
||||
if (anchorRef.current && anchorRef.current.contains(event.target as HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
props.onLogout();
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
function handleListKeyDown(event: React.KeyboardEvent) {
|
||||
if (event.key === 'Tab') {
|
||||
event.preventDefault();
|
||||
setOpen(false);
|
||||
}
|
||||
}
|
||||
|
||||
const prevOpen = React.useRef(open);
|
||||
React.useEffect(() => {
|
||||
if (prevOpen.current === true && open === false) {
|
||||
anchorRef.current!.focus();
|
||||
}
|
||||
|
||||
prevOpen.current = open;
|
||||
}, [open]);
|
||||
|
||||
const renderNavLinks = () => {
|
||||
return props.isAuthenticated
|
||||
? <Container className={classes.nav_menu}>
|
||||
<NavLink exact to="/" className={classes.nav_menu_item} activeClassName={classes.nav_menu_item_active}>Dashboard</NavLink>
|
||||
{props.isAdmin ? <NavLink exact to="/logs" className={classes.nav_menu_item} activeClassName={classes.nav_menu_item_active}>Logs</NavLink> : null}
|
||||
<NavLink to="/devices" className={classes.nav_menu_item} activeClassName={classes.nav_menu_item_active}>Devices</NavLink>
|
||||
<NavLink exact to="/heatmap" className={classes.nav_menu_item} activeClassName={classes.nav_menu_item_active}>Heatmap</NavLink>
|
||||
<IconButton className={classes.nav_menu_icon}
|
||||
ref={anchorRef}
|
||||
aria-haspopup="true"
|
||||
aria-controls={open ? 'menu-list-grow' : undefined}
|
||||
aria-label="account of current user"
|
||||
onClick={handleToggle}>
|
||||
<AccountCircle />
|
||||
</IconButton>
|
||||
<Popper open={open} anchorEl={anchorRef.current} role={undefined} transition disablePortal>
|
||||
{({ TransitionProps, placement }) => (
|
||||
<Grow
|
||||
{...TransitionProps}
|
||||
style={{ transformOrigin: placement === 'bottom' ? 'center top' : 'center bottom' }}>
|
||||
<Paper>
|
||||
<ClickAwayListener onClickAway={handleClose}>
|
||||
<MenuList autoFocusItem={open} id="menu-list-grow" onKeyDown={handleListKeyDown}>
|
||||
<MenuItem onClick={handleLogout} component={Link} {...{ to: '/login' }}>Logout</MenuItem>
|
||||
</MenuList>
|
||||
</ClickAwayListener>
|
||||
</Paper>
|
||||
</Grow>
|
||||
)}
|
||||
</Popper>
|
||||
</Container>
|
||||
: null;
|
||||
};
|
||||
|
||||
return (
|
||||
<AppBar position="static">
|
||||
<Toolbar>
|
||||
<BirdmapTitle />
|
||||
<Typography component={'span'} className={classes.typo}>
|
||||
{renderNavLinks()}
|
||||
</Typography>
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
const useAppbarStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
typo: {
|
||||
marginLeft: 'auto',
|
||||
color: 'white',
|
||||
},
|
||||
nav_menu: {
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
},
|
||||
nav_menu_icon: {
|
||||
color: 'inherit',
|
||||
marginLeft: '24px',
|
||||
'&:hover': {
|
||||
color: 'inherit',
|
||||
}
|
||||
},
|
||||
nav_menu_item: {
|
||||
textDecoration: 'none',
|
||||
fontWeight: 'normal',
|
||||
color: 'inherit',
|
||||
marginLeft: '24px',
|
||||
'&:hover': {
|
||||
color: 'inherit',
|
||||
}
|
||||
},
|
||||
nav_menu_item_active: {
|
||||
textDecoration: 'underline',
|
||||
fontWeight: 'bold',
|
||||
color: 'inherit',
|
||||
marginLeft: '24px',
|
||||
'&:hover': {
|
||||
color: 'inherit',
|
||||
}
|
||||
},
|
||||
}),
|
||||
);
|
@ -1,4 +1,5 @@
|
||||
/*global google*/
|
||||
import { Box, withStyles } from '@material-ui/core';
|
||||
import GoogleMapReact from 'google-map-react';
|
||||
import React, { Component } from 'react';
|
||||
import C from '../../common/Constants';
|
||||
@ -8,7 +9,14 @@ import DeviceMarker from './DeviceMarker';
|
||||
const lat_offset = 0.000038;
|
||||
const lng_offset = -0.000058;
|
||||
|
||||
export default class MapContainer extends Component {
|
||||
const styles = theme => ({
|
||||
root: {
|
||||
height: '93vh',
|
||||
width: '100%',
|
||||
}
|
||||
});
|
||||
|
||||
class MapContainer extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
@ -64,6 +72,8 @@ export default class MapContainer extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const {classes} = this.props;
|
||||
|
||||
const heatMapData = {
|
||||
positions: this.state.heatmapPoints,
|
||||
options: {
|
||||
@ -92,7 +102,7 @@ export default class MapContainer extends Component {
|
||||
));
|
||||
|
||||
return (
|
||||
<div style={{ height: '93vh', width: '100%' }}>
|
||||
<Box className={classes.root}>
|
||||
<GoogleMapReact
|
||||
bootstrapURLKeys={{
|
||||
key: ["AIzaSyCZ51VFfxqZ2GkCmVrcNZdUKsM0fuBQUCY"],
|
||||
@ -106,7 +116,9 @@ export default class MapContainer extends Component {
|
||||
defaultCenter={this.state.center}>
|
||||
{Markers}
|
||||
</GoogleMapReact>
|
||||
</div>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(styles)(MapContainer);
|
208
Birdmap.API/ClientApp/src/components/logs/LogService.js
Normal file
208
Birdmap.API/ClientApp/src/components/logs/LogService.js
Normal file
@ -0,0 +1,208 @@
|
||||
"use strict";
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
//----------------------
|
||||
// <auto-generated>
|
||||
// Generated using the NSwag toolchain v13.8.2.0 (NJsonSchema v10.2.1.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org)
|
||||
// </auto-generated>
|
||||
//----------------------
|
||||
// ReSharper disable InconsistentNaming
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ApiException = exports.HttpStatusCode = void 0;
|
||||
var LogService = /** @class */ (function () {
|
||||
function LogService(baseUrl, http) {
|
||||
this.jsonParseReviver = undefined;
|
||||
this.http = http ? http : window;
|
||||
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "api/logs";
|
||||
}
|
||||
LogService.prototype.getAll = function () {
|
||||
var _this = this;
|
||||
var url_ = this.baseUrl + "/all";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
var options_ = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
'Authorization': sessionStorage.getItem('user')
|
||||
}
|
||||
};
|
||||
return this.http.fetch(url_, options_).then(function (_response) {
|
||||
return _this.processGetAll(_response);
|
||||
});
|
||||
};
|
||||
LogService.prototype.processGetAll = function (response) {
|
||||
var _this = this;
|
||||
var status = response.status;
|
||||
var _headers = {};
|
||||
if (response.headers && response.headers.forEach) {
|
||||
response.headers.forEach(function (v, k) { return _headers[k] = v; });
|
||||
}
|
||||
;
|
||||
if (status === 200) {
|
||||
return response.text().then(function (_responseText) {
|
||||
var result200 = null;
|
||||
var resultData200 = _responseText === "" ? null : JSON.parse(_responseText, _this.jsonParseReviver);
|
||||
if (Array.isArray(resultData200)) {
|
||||
result200 = [];
|
||||
for (var _i = 0, resultData200_1 = resultData200; _i < resultData200_1.length; _i++) {
|
||||
var item = resultData200_1[_i];
|
||||
result200.push(item);
|
||||
}
|
||||
}
|
||||
return result200;
|
||||
});
|
||||
}
|
||||
else if (status !== 200 && status !== 204) {
|
||||
return response.text().then(function (_responseText) {
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
});
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
};
|
||||
LogService.prototype.getFiles = function (filenames) {
|
||||
var _this = this;
|
||||
var url_ = this.baseUrl + "?";
|
||||
if (filenames !== undefined && filenames !== null)
|
||||
filenames && filenames.forEach(function (item) { url_ += "filenames=" + encodeURIComponent("" + item) + "&"; });
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
var options_ = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Accept": "application/octet-stream",
|
||||
'Authorization': sessionStorage.getItem('user')
|
||||
}
|
||||
};
|
||||
return this.http.fetch(url_, options_).then(function (_response) {
|
||||
return _this.processGetFiles(_response);
|
||||
});
|
||||
};
|
||||
LogService.prototype.processGetFiles = function (response) {
|
||||
var status = response.status;
|
||||
var _headers = {};
|
||||
if (response.headers && response.headers.forEach) {
|
||||
response.headers.forEach(function (v, k) { return _headers[k] = v; });
|
||||
}
|
||||
;
|
||||
if (status === 200 || status === 206) {
|
||||
var contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
|
||||
var fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
|
||||
var fileName_1 = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
|
||||
return response.blob().then(function (blob) { return { fileName: fileName_1, data: blob, status: status, headers: _headers }; });
|
||||
}
|
||||
else if (status !== 200 && status !== 204) {
|
||||
return response.text().then(function (_responseText) {
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
});
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
};
|
||||
return LogService;
|
||||
}());
|
||||
exports.default = LogService;
|
||||
var HttpStatusCode;
|
||||
(function (HttpStatusCode) {
|
||||
HttpStatusCode["Continue"] = "Continue";
|
||||
HttpStatusCode["SwitchingProtocols"] = "SwitchingProtocols";
|
||||
HttpStatusCode["Processing"] = "Processing";
|
||||
HttpStatusCode["EarlyHints"] = "EarlyHints";
|
||||
HttpStatusCode["OK"] = "OK";
|
||||
HttpStatusCode["Created"] = "Created";
|
||||
HttpStatusCode["Accepted"] = "Accepted";
|
||||
HttpStatusCode["NonAuthoritativeInformation"] = "NonAuthoritativeInformation";
|
||||
HttpStatusCode["NoContent"] = "NoContent";
|
||||
HttpStatusCode["ResetContent"] = "ResetContent";
|
||||
HttpStatusCode["PartialContent"] = "PartialContent";
|
||||
HttpStatusCode["MultiStatus"] = "MultiStatus";
|
||||
HttpStatusCode["AlreadyReported"] = "AlreadyReported";
|
||||
HttpStatusCode["IMUsed"] = "IMUsed";
|
||||
HttpStatusCode["MultipleChoices"] = "Ambiguous";
|
||||
HttpStatusCode["Ambiguous"] = "Ambiguous";
|
||||
HttpStatusCode["MovedPermanently"] = "Moved";
|
||||
HttpStatusCode["Moved"] = "Moved";
|
||||
HttpStatusCode["Found"] = "Redirect";
|
||||
HttpStatusCode["Redirect"] = "Redirect";
|
||||
HttpStatusCode["SeeOther"] = "RedirectMethod";
|
||||
HttpStatusCode["RedirectMethod"] = "RedirectMethod";
|
||||
HttpStatusCode["NotModified"] = "NotModified";
|
||||
HttpStatusCode["UseProxy"] = "UseProxy";
|
||||
HttpStatusCode["Unused"] = "Unused";
|
||||
HttpStatusCode["TemporaryRedirect"] = "TemporaryRedirect";
|
||||
HttpStatusCode["RedirectKeepVerb"] = "TemporaryRedirect";
|
||||
HttpStatusCode["PermanentRedirect"] = "PermanentRedirect";
|
||||
HttpStatusCode["BadRequest"] = "BadRequest";
|
||||
HttpStatusCode["Unauthorized"] = "Unauthorized";
|
||||
HttpStatusCode["PaymentRequired"] = "PaymentRequired";
|
||||
HttpStatusCode["Forbidden"] = "Forbidden";
|
||||
HttpStatusCode["NotFound"] = "NotFound";
|
||||
HttpStatusCode["MethodNotAllowed"] = "MethodNotAllowed";
|
||||
HttpStatusCode["NotAcceptable"] = "NotAcceptable";
|
||||
HttpStatusCode["ProxyAuthenticationRequired"] = "ProxyAuthenticationRequired";
|
||||
HttpStatusCode["RequestTimeout"] = "RequestTimeout";
|
||||
HttpStatusCode["Conflict"] = "Conflict";
|
||||
HttpStatusCode["Gone"] = "Gone";
|
||||
HttpStatusCode["LengthRequired"] = "LengthRequired";
|
||||
HttpStatusCode["PreconditionFailed"] = "PreconditionFailed";
|
||||
HttpStatusCode["RequestEntityTooLarge"] = "RequestEntityTooLarge";
|
||||
HttpStatusCode["RequestUriTooLong"] = "RequestUriTooLong";
|
||||
HttpStatusCode["UnsupportedMediaType"] = "UnsupportedMediaType";
|
||||
HttpStatusCode["RequestedRangeNotSatisfiable"] = "RequestedRangeNotSatisfiable";
|
||||
HttpStatusCode["ExpectationFailed"] = "ExpectationFailed";
|
||||
HttpStatusCode["MisdirectedRequest"] = "MisdirectedRequest";
|
||||
HttpStatusCode["UnprocessableEntity"] = "UnprocessableEntity";
|
||||
HttpStatusCode["Locked"] = "Locked";
|
||||
HttpStatusCode["FailedDependency"] = "FailedDependency";
|
||||
HttpStatusCode["UpgradeRequired"] = "UpgradeRequired";
|
||||
HttpStatusCode["PreconditionRequired"] = "PreconditionRequired";
|
||||
HttpStatusCode["TooManyRequests"] = "TooManyRequests";
|
||||
HttpStatusCode["RequestHeaderFieldsTooLarge"] = "RequestHeaderFieldsTooLarge";
|
||||
HttpStatusCode["UnavailableForLegalReasons"] = "UnavailableForLegalReasons";
|
||||
HttpStatusCode["InternalServerError"] = "InternalServerError";
|
||||
HttpStatusCode["NotImplemented"] = "NotImplemented";
|
||||
HttpStatusCode["BadGateway"] = "BadGateway";
|
||||
HttpStatusCode["ServiceUnavailable"] = "ServiceUnavailable";
|
||||
HttpStatusCode["GatewayTimeout"] = "GatewayTimeout";
|
||||
HttpStatusCode["HttpVersionNotSupported"] = "HttpVersionNotSupported";
|
||||
HttpStatusCode["VariantAlsoNegotiates"] = "VariantAlsoNegotiates";
|
||||
HttpStatusCode["InsufficientStorage"] = "InsufficientStorage";
|
||||
HttpStatusCode["LoopDetected"] = "LoopDetected";
|
||||
HttpStatusCode["NotExtended"] = "NotExtended";
|
||||
HttpStatusCode["NetworkAuthenticationRequired"] = "NetworkAuthenticationRequired";
|
||||
})(HttpStatusCode = exports.HttpStatusCode || (exports.HttpStatusCode = {}));
|
||||
var ApiException = /** @class */ (function (_super) {
|
||||
__extends(ApiException, _super);
|
||||
function ApiException(message, status, response, headers, result) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.isApiException = true;
|
||||
_this.message = message;
|
||||
_this.status = status;
|
||||
_this.response = response;
|
||||
_this.headers = headers;
|
||||
_this.result = result;
|
||||
return _this;
|
||||
}
|
||||
ApiException.isApiException = function (obj) {
|
||||
return obj.isApiException === true;
|
||||
};
|
||||
return ApiException;
|
||||
}(Error));
|
||||
exports.ApiException = ApiException;
|
||||
function throwException(message, status, response, headers, result) {
|
||||
if (result !== null && result !== undefined)
|
||||
throw result;
|
||||
else
|
||||
throw new ApiException(message, status, response, headers, null);
|
||||
}
|
||||
//# sourceMappingURL=LogService.js.map
|
File diff suppressed because one or more lines are too long
201
Birdmap.API/ClientApp/src/components/logs/LogService.ts
Normal file
201
Birdmap.API/ClientApp/src/components/logs/LogService.ts
Normal file
@ -0,0 +1,201 @@
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
//----------------------
|
||||
// <auto-generated>
|
||||
// Generated using the NSwag toolchain v13.8.2.0 (NJsonSchema v10.2.1.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org)
|
||||
// </auto-generated>
|
||||
//----------------------
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
export default class LogService {
|
||||
private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
|
||||
private baseUrl: string;
|
||||
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
|
||||
|
||||
constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
|
||||
this.http = http ? http : <any>window;
|
||||
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "api/logs";
|
||||
}
|
||||
|
||||
getAll(): Promise<string[]> {
|
||||
let url_ = this.baseUrl + "/all";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_ = <RequestInit>{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
'Authorization': sessionStorage.getItem('user')
|
||||
}
|
||||
};
|
||||
|
||||
return this.http.fetch(url_, options_).then((_response: Response) => {
|
||||
return this.processGetAll(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processGetAll(response: Response): Promise<string[]> {
|
||||
const status = response.status;
|
||||
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
|
||||
if (status === 200) {
|
||||
return response.text().then((_responseText) => {
|
||||
let result200: any = null;
|
||||
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
||||
if (Array.isArray(resultData200)) {
|
||||
result200 = [] as any;
|
||||
for (let item of resultData200)
|
||||
result200!.push(item);
|
||||
}
|
||||
return result200;
|
||||
});
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
return response.text().then((_responseText) => {
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
});
|
||||
}
|
||||
return Promise.resolve<string[]>(<any>null);
|
||||
}
|
||||
|
||||
getFiles(filenames: string[] | null | undefined): Promise<FileResponse | null> {
|
||||
let url_ = this.baseUrl + "?";
|
||||
if (filenames !== undefined && filenames !== null)
|
||||
filenames && filenames.forEach(item => { url_ += "filenames=" + encodeURIComponent("" + item) + "&"; });
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_ = <RequestInit>{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Accept": "application/octet-stream",
|
||||
'Authorization': sessionStorage.getItem('user')
|
||||
}
|
||||
};
|
||||
|
||||
return this.http.fetch(url_, options_).then((_response: Response) => {
|
||||
return this.processGetFiles(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processGetFiles(response: Response): Promise<FileResponse | null> {
|
||||
const status = response.status;
|
||||
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
|
||||
if (status === 200 || status === 206) {
|
||||
const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
|
||||
const fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
|
||||
const fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
|
||||
return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
return response.text().then((_responseText) => {
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
});
|
||||
}
|
||||
return Promise.resolve<FileResponse | null>(<any>null);
|
||||
}
|
||||
}
|
||||
|
||||
export interface FileResponse {
|
||||
data: Blob;
|
||||
status: number;
|
||||
fileName?: string;
|
||||
headers?: { [name: string]: any };
|
||||
}
|
||||
|
||||
export enum HttpStatusCode {
|
||||
Continue = "Continue",
|
||||
SwitchingProtocols = "SwitchingProtocols",
|
||||
Processing = "Processing",
|
||||
EarlyHints = "EarlyHints",
|
||||
OK = "OK",
|
||||
Created = "Created",
|
||||
Accepted = "Accepted",
|
||||
NonAuthoritativeInformation = "NonAuthoritativeInformation",
|
||||
NoContent = "NoContent",
|
||||
ResetContent = "ResetContent",
|
||||
PartialContent = "PartialContent",
|
||||
MultiStatus = "MultiStatus",
|
||||
AlreadyReported = "AlreadyReported",
|
||||
IMUsed = "IMUsed",
|
||||
MultipleChoices = "Ambiguous",
|
||||
Ambiguous = "Ambiguous",
|
||||
MovedPermanently = "Moved",
|
||||
Moved = "Moved",
|
||||
Found = "Redirect",
|
||||
Redirect = "Redirect",
|
||||
SeeOther = "RedirectMethod",
|
||||
RedirectMethod = "RedirectMethod",
|
||||
NotModified = "NotModified",
|
||||
UseProxy = "UseProxy",
|
||||
Unused = "Unused",
|
||||
TemporaryRedirect = "TemporaryRedirect",
|
||||
RedirectKeepVerb = "TemporaryRedirect",
|
||||
PermanentRedirect = "PermanentRedirect",
|
||||
BadRequest = "BadRequest",
|
||||
Unauthorized = "Unauthorized",
|
||||
PaymentRequired = "PaymentRequired",
|
||||
Forbidden = "Forbidden",
|
||||
NotFound = "NotFound",
|
||||
MethodNotAllowed = "MethodNotAllowed",
|
||||
NotAcceptable = "NotAcceptable",
|
||||
ProxyAuthenticationRequired = "ProxyAuthenticationRequired",
|
||||
RequestTimeout = "RequestTimeout",
|
||||
Conflict = "Conflict",
|
||||
Gone = "Gone",
|
||||
LengthRequired = "LengthRequired",
|
||||
PreconditionFailed = "PreconditionFailed",
|
||||
RequestEntityTooLarge = "RequestEntityTooLarge",
|
||||
RequestUriTooLong = "RequestUriTooLong",
|
||||
UnsupportedMediaType = "UnsupportedMediaType",
|
||||
RequestedRangeNotSatisfiable = "RequestedRangeNotSatisfiable",
|
||||
ExpectationFailed = "ExpectationFailed",
|
||||
MisdirectedRequest = "MisdirectedRequest",
|
||||
UnprocessableEntity = "UnprocessableEntity",
|
||||
Locked = "Locked",
|
||||
FailedDependency = "FailedDependency",
|
||||
UpgradeRequired = "UpgradeRequired",
|
||||
PreconditionRequired = "PreconditionRequired",
|
||||
TooManyRequests = "TooManyRequests",
|
||||
RequestHeaderFieldsTooLarge = "RequestHeaderFieldsTooLarge",
|
||||
UnavailableForLegalReasons = "UnavailableForLegalReasons",
|
||||
InternalServerError = "InternalServerError",
|
||||
NotImplemented = "NotImplemented",
|
||||
BadGateway = "BadGateway",
|
||||
ServiceUnavailable = "ServiceUnavailable",
|
||||
GatewayTimeout = "GatewayTimeout",
|
||||
HttpVersionNotSupported = "HttpVersionNotSupported",
|
||||
VariantAlsoNegotiates = "VariantAlsoNegotiates",
|
||||
InsufficientStorage = "InsufficientStorage",
|
||||
LoopDetected = "LoopDetected",
|
||||
NotExtended = "NotExtended",
|
||||
NetworkAuthenticationRequired = "NetworkAuthenticationRequired",
|
||||
}
|
||||
|
||||
export class ApiException extends Error {
|
||||
message: string;
|
||||
status: number;
|
||||
response: string;
|
||||
headers: { [key: string]: any; };
|
||||
result: any;
|
||||
|
||||
constructor(message: string, status: number, response: string, headers: { [key: string]: any; }, result: any) {
|
||||
super();
|
||||
|
||||
this.message = message;
|
||||
this.status = status;
|
||||
this.response = response;
|
||||
this.headers = headers;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
protected isApiException = true;
|
||||
|
||||
static isApiException(obj: any): obj is ApiException {
|
||||
return obj.isApiException === true;
|
||||
}
|
||||
}
|
||||
|
||||
function throwException(message: string, status: number, response: string, headers: { [key: string]: any; }, result?: any): any {
|
||||
if (result !== null && result !== undefined)
|
||||
throw result;
|
||||
else
|
||||
throw new ApiException(message, status, response, headers, null);
|
||||
}
|
128
Birdmap.API/ClientApp/src/components/logs/Logs.jsx
Normal file
128
Birdmap.API/ClientApp/src/components/logs/Logs.jsx
Normal file
@ -0,0 +1,128 @@
|
||||
import { Box, Button, Checkbox, List, ListItem, ListItemIcon, ListItemText, Paper, withStyles } from '@material-ui/core';
|
||||
import { blueGrey } from '@material-ui/core/colors';
|
||||
import React, { Component } from 'react';
|
||||
import LogService from './LogService';
|
||||
|
||||
const styles = theme => ({
|
||||
root: {
|
||||
padding: '64px',
|
||||
backgroundColor: theme.palette.primary.dark,
|
||||
},
|
||||
paper: {
|
||||
backgroundColor: blueGrey[50],
|
||||
},
|
||||
});
|
||||
|
||||
class Logs extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
service: null,
|
||||
files: [],
|
||||
checked: [],
|
||||
selectAllChecked: false,
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
var service = new LogService();
|
||||
this.setState({service: service});
|
||||
|
||||
service.getAll().then(result => {
|
||||
this.setState({files: result});
|
||||
}).catch(ex => console.log(ex));
|
||||
}
|
||||
|
||||
handleToggle = (value) => {
|
||||
const currentIndex = this.state.checked.indexOf(value);
|
||||
const newChecked = [...this.state.checked];
|
||||
|
||||
if (currentIndex === -1) {
|
||||
newChecked.push(value);
|
||||
} else {
|
||||
newChecked.splice(currentIndex, 1);
|
||||
}
|
||||
|
||||
this.setState({checked: newChecked});
|
||||
}
|
||||
|
||||
handleSelectAllToggle = () => {
|
||||
this.setState({selectAllChecked: !this.state.selectAllChecked});
|
||||
if (this.state.selectAllChecked) {
|
||||
this.setState({checked: []});
|
||||
} else {
|
||||
const newChecked = [...this.state.files];
|
||||
this.setState({checked: newChecked});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onDownload = () => {
|
||||
this.state.service.getFiles(this.state.checked)
|
||||
.then(result => {
|
||||
const filename = `Logs-${new Date().toISOString()}.zip`;
|
||||
const textUrl = URL.createObjectURL(result.data);
|
||||
const element = document.createElement('a');
|
||||
element.setAttribute('href', textUrl);
|
||||
element.setAttribute('download', filename);
|
||||
element.style.display = 'none';
|
||||
document.body.appendChild(element);
|
||||
element.click();
|
||||
document.body.removeChild(element);
|
||||
this.setState({checked: []});
|
||||
this.setState({selectAllChecked: false});
|
||||
})
|
||||
.catch(ex => console.log(ex));
|
||||
}
|
||||
|
||||
render() {
|
||||
const { classes } = this.props;
|
||||
|
||||
const Files = this.state.files.map((value) => {
|
||||
const labelId = `checkbox-list-label-${value}`;
|
||||
|
||||
return (
|
||||
<ListItem key={value} role={undefined} dense button onClick={() => this.handleToggle(value)}>
|
||||
<ListItemIcon>
|
||||
<Checkbox
|
||||
edge="start"
|
||||
checked={this.state.checked.indexOf(value) !== -1}
|
||||
tabIndex={-1}
|
||||
disableRipple
|
||||
inputProps={{ 'aria-labelledby': labelId }}
|
||||
/>
|
||||
</ListItemIcon>
|
||||
<ListItemText id={labelId} primary={`${value}`} />
|
||||
</ListItem>
|
||||
);
|
||||
})
|
||||
|
||||
return (
|
||||
<Box className={classes.root}>
|
||||
<Paper className={classes.paper}>
|
||||
<List className={classes.paper}>
|
||||
<ListItem key="Select-all" role={undefined} dense button onClick={this.handleSelectAllToggle}>
|
||||
<ListItemIcon>
|
||||
<Checkbox
|
||||
edge="start"
|
||||
checked={this.state.selectAllChecked}
|
||||
tabIndex={-1}
|
||||
disableRipple
|
||||
inputProps={{ 'aria-labelledby': "Select-all" }}
|
||||
/>
|
||||
</ListItemIcon>
|
||||
<ListItemText id="checkbox-list-label-Select-all" primary={(this.state.selectAllChecked ? "Uns" : "S") + "elect all"} />
|
||||
</ListItem>
|
||||
{Files}
|
||||
</List>
|
||||
<Button onClick={this.onDownload}>
|
||||
Download
|
||||
</Button>
|
||||
</Paper>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(styles)(Logs);
|
66
Birdmap.API/Controllers/LogsController.cs
Normal file
66
Birdmap.API/Controllers/LogsController.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Birdmap.API.Controllers
|
||||
{
|
||||
[Authorize(Roles = "Admin")]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class LogsController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<LogsController> _logger;
|
||||
private readonly string _logFolderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Logs");
|
||||
|
||||
public LogsController(ILogger<LogsController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet("all")]
|
||||
public ActionResult<List<string>> GetAll()
|
||||
{
|
||||
_logger.LogInformation($"Getting all log filenames from folder: '{_logFolderPath}'...");
|
||||
|
||||
return Directory.EnumerateFiles(_logFolderPath, "*.log")
|
||||
.Select(f => Path.GetFileName(f))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetFiles([FromQuery] params string[] filenames)
|
||||
{
|
||||
if (!filenames.Any())
|
||||
return null;
|
||||
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
var zipStream = new MemoryStream();
|
||||
|
||||
using (var zip = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
|
||||
{
|
||||
foreach (var file in Directory.GetFiles(_logFolderPath, "*.log"))
|
||||
{
|
||||
var filename = Path.GetFileName(file);
|
||||
|
||||
if (filenames.Contains(filename))
|
||||
{
|
||||
zip.CreateEntryFromFile(file, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zipStream.Position = 0;
|
||||
|
||||
return File(zipStream, "application/octet-stream");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||
WORKDIR /app
|
||||
RUN apt-get update && apt-get install -y curl
|
||||
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
|
||||
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
|
||||
RUN apt-get update && apt-get install -y nodejs
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||
RUN apt-get update && apt-get install -y curl
|
||||
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
|
||||
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
|
||||
RUN apt-get update && apt-get install -y nodejs
|
||||
WORKDIR /src
|
||||
COPY ["Birdmap.API/Birdmap.API.csproj", "Birdmap.API/"]
|
||||
|
@ -5,5 +5,50 @@
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"Kestrel": {
|
||||
"Certificates": {
|
||||
"Default": {
|
||||
"Password": "certpass123",
|
||||
"Path": "C:\\Users\\Ricsi\\AppData\\Roaming\\ASP.NET\\Https\\aspnetapp.pfx"
|
||||
}
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Secret": "7vj.3KW.hYE!}4u6",
|
||||
// "LocalDbConnectionString": "Data Source=DESKTOP-3600\\SQLEXPRESS;Initial Catalog=birdmap;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
|
||||
"LocalDbConnectionString": "Data Source=DESKTOP-3600;Initial Catalog=birdmap2;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
|
||||
"Defaults": {
|
||||
"Services": {
|
||||
"Local Database": "https://localhost:44331/health",
|
||||
"KMLabz Services": "https://birb.k8s.kmlabz.com/devices"
|
||||
},
|
||||
"Users": [
|
||||
{
|
||||
"Name": "admin",
|
||||
"Password": "pass",
|
||||
"Role": "Admin"
|
||||
},
|
||||
{
|
||||
"Name": "user",
|
||||
"Password": "pass",
|
||||
"Role": "User"
|
||||
}
|
||||
]
|
||||
},
|
||||
"UseDummyServices": true,
|
||||
"ServicesBaseUrl": "https://birb.k8s.kmlabz.com/",
|
||||
"Mqtt": {
|
||||
"BrokerHostSettings": {
|
||||
"Host": "localhost",
|
||||
"Port": 1883
|
||||
},
|
||||
|
||||
"ClientSettings": {
|
||||
"Id": "ASP.NET Core client",
|
||||
"Username": "username",
|
||||
"Password": "password",
|
||||
"Topic": "devices/output"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,42 +6,35 @@
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"Kestrel": {
|
||||
"Certificates": {
|
||||
"Default": {
|
||||
"Password": "",
|
||||
"Path": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Secret": "7vj.3KW.hYE!}4u6",
|
||||
// "LocalDbConnectionString": "Data Source=DESKTOP-3600\\SQLEXPRESS;Initial Catalog=birdmap;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
|
||||
//"LocalDbConnectionString": "Data Source=DESKTOP-3600;Initial Catalog=birdmap;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
|
||||
"LocalDbConnectionString": "Data Source=db;Initial Catalog=birdmap;User=sa;Password=RPSsql12345",
|
||||
"Secret": "",
|
||||
"LocalDbConnectionString": "",
|
||||
"Defaults": {
|
||||
"Services": {
|
||||
"Local Database": "https://localhost:44331/health",
|
||||
"KMLabz Services": "https://birb.k8s.kmlabz.com/devices"
|
||||
},
|
||||
"Users": [
|
||||
{
|
||||
"Name": "admin",
|
||||
"Password": "pass",
|
||||
"Role": "Admin"
|
||||
},
|
||||
{
|
||||
"Name": "user",
|
||||
"Password": "pass",
|
||||
"Role": "User"
|
||||
}
|
||||
]
|
||||
"Users": []
|
||||
},
|
||||
"UseDummyServices": true,
|
||||
"UseDummyServices": false,
|
||||
"ServicesBaseUrl": "https://birb.k8s.kmlabz.com/",
|
||||
"Mqtt": {
|
||||
"BrokerHostSettings": {
|
||||
"Host": "localhost",
|
||||
"Host": "",
|
||||
"Port": 1883
|
||||
},
|
||||
|
||||
"ClientSettings": {
|
||||
"Id": "ASP.NET Core client",
|
||||
"Username": "username",
|
||||
"Password": "password",
|
||||
"Topic": "devices/output"
|
||||
"Username": "",
|
||||
"Password": "",
|
||||
"Topic": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true"
|
||||
internalLogLevel="Info"
|
||||
internalLogFile="${basedir}Log/internal-nlog.txt"
|
||||
internalLogFile="${basedir}Logs/internal-nlog.txt"
|
||||
throwConfigExceptions="true">
|
||||
|
||||
<!-- enable asp.net core layout renderers -->
|
||||
@ -14,17 +14,17 @@
|
||||
<!-- the targets to write to -->
|
||||
<targets async="true">
|
||||
<default-target-parameters xsi:type="File" keepFileOpen="false" maxArchiveFiles="10" archiveAboveSize="1048576"/>
|
||||
<target xsi:type="File" name="allFile" fileName="${basedir}Log/birdmap-all-${shortdate}.log"
|
||||
<target xsi:type="File" name="allFile" fileName="${basedir}Logs/birdmap-all-${shortdate}.log"
|
||||
layout="${longdate} [${threadname:whenEmpty=${threadid}}] ${uppercase:${level}} ${logger} - ${message} ${exception:format=tostring}" />
|
||||
|
||||
<target xsi:type="File" name="mqttFile" fileName="${basedir}Log/birdmap-mqtt-${shortdate}.log"
|
||||
<target xsi:type="File" name="mqttFile" fileName="${basedir}Logs/birdmap-mqtt-${shortdate}.log"
|
||||
layout="${longdate} [${threadname:whenEmpty=${threadid}}] ${uppercase:${level}} ${logger} - ${message} ${exception:format=tostring}" />
|
||||
|
||||
<target xsi:type="File" name="hubsFile" fileName="${basedir}Log/birdmap-hubs-${shortdate}.log"
|
||||
<target xsi:type="File" name="hubsFile" fileName="${basedir}Logs/birdmap-hubs-${shortdate}.log"
|
||||
layout="${longdate} [${threadname:whenEmpty=${threadid}}] ${uppercase:${level}} ${logger} - ${message} ${exception:format=tostring}" />
|
||||
|
||||
<!-- another file log, only own logs. Uses some ASP.NET core renderers -->
|
||||
<target xsi:type="File" name="ownFile" fileName="${basedir}Log/birdmap-own-${shortdate}.log"
|
||||
<target xsi:type="File" name="ownFile" fileName="${basedir}Logs/birdmap-own-${shortdate}.log"
|
||||
layout="${longdate} [${threadname:whenEmpty=${threadid}}] ${uppercase:${level}} ${callsite} - ${message} ${exception:format=tostring} (url: ${aspnet-request-url})(action: ${aspnet-mvc-action})" />
|
||||
</targets>
|
||||
|
||||
|
1
MQTTnet.TestApp.WinForm/Retained.json
Normal file
1
MQTTnet.TestApp.WinForm/Retained.json
Normal file
@ -0,0 +1 @@
|
||||
[{"Topic":"devices/output","Payload":"eyJ0YWciOiJkNDhhODAwOC0wYjU2LTRkYzAtODYxMy0zMWY0MDY4OTk0ZDciLCJwcm9iYWJpbGl0eSI6MC4yNTMxNDI4NDgyNjMwOTU1fQ==","QualityOfServiceLevel":1,"Retain":true,"UserProperties":null,"ContentType":null,"ResponseTopic":null,"PayloadFormatIndicator":null,"MessageExpiryInterval":null,"TopicAlias":null,"CorrelationData":null,"SubscriptionIdentifiers":null}]
|
@ -21,11 +21,12 @@ services:
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
- ASPNETCORE_ENVIRONMENT=Development
|
||||
- ASPNETCORE_ENVIRONMENT=Docker
|
||||
- ASPNETCORE_URLS=https://+;http://+
|
||||
- ASPNETCORE_HTTPS_PORT=8001
|
||||
- ASPNETCORE_Kestrel__Certificates__Default__Password=certpass123
|
||||
- ASPNETCORE_Kestrel__Certificates__Default__Path=/root/.aspnet/https/aspnetapp.pfx
|
||||
- Birdmap_Kestrel__Certificates__Default__Password=certpass123
|
||||
- Birdmap_Kestrel__Certificates__Default__Path=/root/.aspnet/https/aspnetapp.pfx
|
||||
- Birdmap_Secret=7gz;]=bQe}n#3~RwC+Y<SrjoE:sHwO
|
||||
- Birdmap_LocalDbConnectionString=Data Source=db;Initial Catalog=birdmap;User=sa;Password=RPSsql12345
|
||||
- Birdmap_Defaults__Users__0__Name=admin
|
||||
- Birdmap_Defaults__Users__0__Password=pass
|
||||
@ -33,7 +34,8 @@ services:
|
||||
- Birdmap_Defaults__Users__1__Name=user
|
||||
- Birdmap_Defaults__Users__1__Password=pass
|
||||
- Birdmap_Defaults__Users__1__Role=User
|
||||
- Birdmap_Defaults__Services__Local-Database=https://localhost/health
|
||||
- Birdmap_Defaults__Services__Local-Database=https://localhost:8001/health
|
||||
- Birdmap_Defaults__Services__KMLabz-Service=https://birb.k8s.kmlabz.com/devices
|
||||
- Birdmap_UseDummyServices=true
|
||||
- Birdmap_ServicesBaseUrl=https://birb.k8s.kmlabz.com/
|
||||
- Birdmap_Mqtt__BrokerHostSettings__Host=localhost
|
||||
|
Reference in New Issue
Block a user