Added google maps heatmap

This commit is contained in:
kunkliricsi 2020-11-11 16:55:50 +01:00
parent 4281c2d524
commit a52f6acd71
26 changed files with 1011 additions and 1217 deletions

View File

@ -35,6 +35,7 @@
<PackageReference Include="NLog" Version="4.7.5" />
<PackageReference Include="NLog.Web" Version="4.9.3" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.3" />
<PackageReference Include="NSwag.AspNetCore" Version="13.8.2" />
</ItemGroup>
<ItemGroup>
@ -49,9 +50,9 @@
<None Remove="ClientApp\src\common\ErrorDispatcher.ts" />
<None Remove="ClientApp\src\common\ServiceBase.ts" />
<None Remove="ClientApp\src\components\auth\Auth.tsx" />
<None Remove="ClientApp\src\components\auth\AuthClient.ts" />
<None Remove="ClientApp\src\components\auth\AuthService.ts" />
<None Remove="ClientApp\src\components\devices\DeviceService.ts" />
<None Remove="ClientApp\src\components\heatmap\heatmap.tsx" />
</ItemGroup>
<ItemGroup>

View File

@ -1199,6 +1199,11 @@
"resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz",
"integrity": "sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow=="
},
"@googlemaps/js-api-loader": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/@googlemaps/js-api-loader/-/js-api-loader-1.8.0.tgz",
"integrity": "sha512-aFxlJVFOC00KELhlaqU6tpnxj9szVdG7OSHxQzc9uhp4Ky8/zvYNnzZg2S+pPvhe+WkJPugQL8fowP5nYTBXUg=="
},
"@hapi/address": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz",
@ -1424,6 +1429,11 @@
"@types/yargs": "^13.0.0"
}
},
"@mapbox/point-geometry": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz",
"integrity": "sha1-ioP5M1x4YO/6Lu7KJUMyqgru2PI="
},
"@material-ui/core": {
"version": "4.11.0",
"resolved": "https://registry.npmjs.org/@material-ui/core/-/core-4.11.0.tgz",
@ -1559,6 +1569,33 @@
"react-is": "^16.8.0"
}
},
"@microsoft/signalr": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/@microsoft/signalr/-/signalr-5.0.0.tgz",
"integrity": "sha512-AsbU1ZB4Q9JsZ77W13VGT8gi/cVrFn3XbvVfULSwrC9DVCXF2JpkBDh0cCmRaYs9M3kqKohiVM1WPqNeAGil/g==",
"requires": {
"abort-controller": "^3.0.0",
"eventsource": "^1.0.7",
"fetch-cookie": "^0.7.3",
"node-fetch": "^2.6.0",
"ws": "^6.0.0"
},
"dependencies": {
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"ws": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz",
"integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==",
"requires": {
"async-limiter": "~1.0.0"
}
}
}
},
"@mrmlnc/readdir-enhanced": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz",
@ -2170,6 +2207,14 @@
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz",
"integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q=="
},
"abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"requires": {
"event-target-shim": "^5.0.0"
}
},
"accepts": {
"version": "1.3.7",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
@ -3406,6 +3451,11 @@
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg=="
},
"can-use-dom": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/can-use-dom/-/can-use-dom-0.1.0.tgz",
"integrity": "sha1-IsxKNKCrxDlQ9CxkEQJKP2NmtFo="
},
"caniuse-api": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz",
@ -3450,6 +3500,11 @@
"supports-color": "^5.3.0"
}
},
"change-emitter": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/change-emitter/-/change-emitter-0.1.6.tgz",
"integrity": "sha1-6LL+PX8at9aaMhma/5HqaTFAlRU="
},
"chardet": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz",
@ -4857,6 +4912,24 @@
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
},
"encoding": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
"integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
"requires": {
"iconv-lite": "^0.6.2"
},
"dependencies": {
"iconv-lite": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.2.tgz",
"integrity": "sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==",
"requires": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
}
}
}
},
"end-of-stream": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
@ -4972,6 +5045,11 @@
"next-tick": "~1.0.0"
}
},
"es6-denodeify": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/es6-denodeify/-/es6-denodeify-0.1.5.tgz",
"integrity": "sha1-MdTV/pxVA+ElRgQ5MQ4WoqPznB8="
},
"es6-iterator": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
@ -5498,6 +5576,11 @@
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
},
"event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
},
"eventemitter3": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
@ -5857,6 +5940,44 @@
"bser": "2.1.1"
}
},
"fbjs": {
"version": "0.8.17",
"resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz",
"integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=",
"requires": {
"core-js": "^1.0.0",
"isomorphic-fetch": "^2.1.1",
"loose-envify": "^1.0.0",
"object-assign": "^4.1.0",
"promise": "^7.1.1",
"setimmediate": "^1.0.5",
"ua-parser-js": "^0.7.18"
},
"dependencies": {
"core-js": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz",
"integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY="
},
"promise": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
"integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
"requires": {
"asap": "~2.0.3"
}
}
}
},
"fetch-cookie": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-0.7.3.tgz",
"integrity": "sha512-rZPkLnI8x5V+zYAiz8QonAHsTb4BY+iFowFBI1RFn0zrO343AVp9X7/yUj/9wL6Ef/8fLls8b/vGtzUvmyAUGA==",
"requires": {
"es6-denodeify": "^0.1.1",
"tough-cookie": "^2.3.3"
}
},
"figgy-pudding": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz",
@ -6326,6 +6447,17 @@
}
}
},
"google-map-react": {
"version": "2.1.9",
"resolved": "https://registry.npmjs.org/google-map-react/-/google-map-react-2.1.9.tgz",
"integrity": "sha512-//Pa0o6sdspU2H0ehVztSDQSnYYeV6TY4Z6ftty34yiCJYLliOzeq17dA9uFkyUFdL+XwbTU6e9mfs+bjBMIzw==",
"requires": {
"@googlemaps/js-api-loader": "^1.7.0",
"@mapbox/point-geometry": "^0.1.0",
"eventemitter3": "^4.0.4",
"prop-types": "^15.7.2"
}
},
"google-maps": {
"version": "4.3.3",
"resolved": "https://registry.npmjs.org/google-maps/-/google-maps-4.3.3.tgz",
@ -6334,6 +6466,11 @@
"@types/googlemaps": "^3.39.1"
}
},
"google-maps-infobox": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/google-maps-infobox/-/google-maps-infobox-2.0.0.tgz",
"integrity": "sha512-hTuWmWZZSOxf5D/z7l3/hTF1grgRvLG53BEKMdjiKOG+FcK/kH7vqseUeyIU9Zj2ZIqKTOaro0nknxpAuRq4Vw=="
},
"google-maps-react": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/google-maps-react/-/google-maps-react-2.0.6.tgz",
@ -7207,6 +7344,15 @@
"resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8="
},
"isomorphic-fetch": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz",
"integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=",
"requires": {
"node-fetch": "^1.0.1",
"whatwg-fetch": ">=0.10.0"
}
},
"isstream": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
@ -8321,6 +8467,16 @@
"object-visit": "^1.0.0"
}
},
"marker-clusterer-plus": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/marker-clusterer-plus/-/marker-clusterer-plus-2.1.4.tgz",
"integrity": "sha1-+O/3TVmdqzt9Dj/tUmTqDnBPXWc="
},
"markerwithlabel": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/markerwithlabel/-/markerwithlabel-2.0.2.tgz",
"integrity": "sha512-C/cbm1A0h/u54gwHk5ZJNdUU3V3+1BbCpRPMsMyFA7vF4yL+aB4rWpxACz29TpQ+cTg6/iQroExh0PMSRGtQFg=="
},
"md5.js": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
@ -8734,6 +8890,15 @@
"tslib": "^1.10.0"
}
},
"node-fetch": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
"requires": {
"encoding": "^0.1.11",
"is-stream": "^1.0.1"
}
},
"node-forge": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz",
@ -10809,6 +10974,50 @@
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.7.tgz",
"integrity": "sha512-TAv1KJFh3RhqxNvhzxj6LeT5NWklP6rDr2a0jaTfsZ5wSZWHOGeqQyejUp3xxLfPt2UpyJEcVQB/zyPcmonNFA=="
},
"react-google-maps": {
"version": "9.4.5",
"resolved": "https://registry.npmjs.org/react-google-maps/-/react-google-maps-9.4.5.tgz",
"integrity": "sha512-8z5nX9DxIcBCXuEiurmRT1VXVwnzx0C6+3Es6lxB2/OyY2SLax2/LcDu6Aldxnl3HegefTL7NJzGeaKAJ61pOA==",
"requires": {
"babel-runtime": "^6.11.6",
"can-use-dom": "^0.1.0",
"google-maps-infobox": "^2.0.0",
"invariant": "^2.2.1",
"lodash": "^4.16.2",
"marker-clusterer-plus": "^2.1.4",
"markerwithlabel": "^2.0.1",
"prop-types": "^15.5.8",
"recompose": "^0.26.0",
"scriptjs": "^2.5.8",
"warning": "^3.0.0"
},
"dependencies": {
"hoist-non-react-statics": {
"version": "2.5.5",
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz",
"integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw=="
},
"recompose": {
"version": "0.26.0",
"resolved": "https://registry.npmjs.org/recompose/-/recompose-0.26.0.tgz",
"integrity": "sha512-KwOu6ztO0mN5vy3+zDcc45lgnaUoaQse/a5yLVqtzTK13czSWnFGmXbQVmnoMgDkI5POd1EwIKSbjU1V7xdZog==",
"requires": {
"change-emitter": "^0.1.2",
"fbjs": "^0.8.1",
"hoist-non-react-statics": "^2.3.1",
"symbol-observable": "^1.0.4"
}
},
"warning": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz",
"integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=",
"requires": {
"loose-envify": "^1.0.0"
}
}
}
},
"react-is": {
"version": "16.12.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.12.0.tgz",
@ -11189,6 +11398,26 @@
"util.promisify": "^1.0.0"
}
},
"recompose": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/recompose/-/recompose-0.30.0.tgz",
"integrity": "sha512-ZTrzzUDa9AqUIhRk4KmVFihH0rapdCSMFXjhHbNrjAWxBuUD/guYlyysMnuHjlZC/KRiOKRtB4jf96yYSkKE8w==",
"requires": {
"@babel/runtime": "^7.0.0",
"change-emitter": "^0.1.2",
"fbjs": "^0.8.1",
"hoist-non-react-statics": "^2.3.1",
"react-lifecycles-compat": "^3.0.2",
"symbol-observable": "^1.0.4"
},
"dependencies": {
"hoist-non-react-statics": {
"version": "2.5.5",
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz",
"integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw=="
}
}
},
"recursive-readdir": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz",
@ -11748,6 +11977,11 @@
}
}
},
"scriptjs": {
"version": "2.5.9",
"resolved": "https://registry.npmjs.org/scriptjs/-/scriptjs-2.5.9.tgz",
"integrity": "sha512-qGVDoreyYiP1pkQnbnFAUIS5AjenNwwQBdl7zeos9etl+hYKWahjRTfzAZZYBv5xNHx7vNKCmaLDQZ6Fr2AEXg=="
},
"seamless-immutable": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/seamless-immutable/-/seamless-immutable-7.1.4.tgz",
@ -13262,6 +13496,11 @@
"integrity": "sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==",
"dev": true
},
"ua-parser-js": {
"version": "0.7.22",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.22.tgz",
"integrity": "sha512-YUxzMjJ5T71w6a8WWVcMGM6YWOTX27rCoIQgLXiWaxqXSx9D7DNjiGWn1aJIRSQ5qr0xuhra77bSIh6voR/46Q=="
},
"unicode-canonical-property-names-ecmascript": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz",

View File

@ -6,8 +6,10 @@
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@microsoft/signalr": "^5.0.0",
"bootstrap": "^4.3.1",
"connected-react-router": "6.5.2",
"google-map-react": "^2.1.9",
"google-maps": "^4.3.3",
"google-maps-react": "^2.0.6",
"history": "4.10.1",
@ -16,11 +18,13 @@
"popper.js": "^1.16.0",
"react": "^16.11.0",
"react-dom": "16.11.0",
"react-google-maps": "^9.4.5",
"react-redux": "7.1.1",
"react-router": "5.1.2",
"react-router-dom": "5.1.2",
"react-scripts": "^3.4.4",
"reactstrap": "8.1.1",
"recompose": "^0.30.0",
"redux": "4.0.4",
"redux-thunk": "2.3.0",
"svgo": "1.3.0"

View File

@ -3,6 +3,7 @@ import AccountCircle from '@material-ui/icons/AccountCircle';
import AppBar from '@material-ui/core/AppBar';
import blue from '@material-ui/core/colors/blue';
import orange from '@material-ui/core/colors/orange';
import { positions } from '@material-ui/system';
import { createMuiTheme, createStyles, makeStyles, Theme } from '@material-ui/core/styles';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
@ -13,6 +14,7 @@ import BirdmapTitle from './common/components/BirdmapTitle';
import Auth from './components/auth/Auth';
import AuthService from './components/auth/AuthService';
import { ClickAwayListener } from '@material-ui/core';
import MapContainer from './components/heatmap/Heatmap';
const theme = createMuiTheme({
@ -51,7 +53,11 @@ function App() {
};
const HeatmapComponent = () => {
return <Typography>Heatmap</Typography>;
return (
<Paper elevation={0}>
<MapContainer />
</Paper>
);
};
return (
@ -174,7 +180,7 @@ const DefaultLayout = ({ component: Component, authenticated: Authenticated, isA
</Typography>
</Toolbar>
</AppBar>
<Box style={{ margin: '32px' }}>
<Box zIndex="modal">
<Component isAdmin={IsAdmin} {...rest} />
</Box>
</React.Fragment>

View File

@ -54,15 +54,15 @@ export default function Auth(props: any) {
setIsLoggingIn(true);
AuthService.login(username, password)
.then(() => {
props.onAuthenticated();
history.push('/');
}).catch(() => {
setShowError(true);
setErrorMessage('Invalid credentials');
}).finally(() => {
setIsLoggingIn(false);
});
.then(() => {
setIsLoggingIn(false);
props.onAuthenticated();
history.push('/');
}).catch(() => {
setShowError(true);
setIsLoggingIn(false);
setErrorMessage('Invalid credentials');
});
};
const renderErrorLabel = () => {

View File

@ -0,0 +1,256 @@
"use strict";
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.RegisterRequest = exports.AuthenticateRequest = exports.HttpStatusCode = void 0;
var AuthClient = /** @class */ (function () {
function AuthClient(baseUrl, http) {
this.jsonParseReviver = undefined;
this.http = http ? http : window;
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "";
}
AuthClient.prototype.authenticate = function (model) {
var _this = this;
var url_ = this.baseUrl + "/api/Auth/authenticate";
url_ = url_.replace(/[?&]$/, "");
var content_ = JSON.stringify(model);
var options_ = {
body: content_,
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.http.fetch(url_, options_).then(function (_response) {
return _this.processAuthenticate(_response);
});
};
AuthClient.prototype.processAuthenticate = 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);
result200 = resultData200 !== undefined ? resultData200 : null;
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);
};
AuthClient.prototype.register = function (model) {
var _this = this;
var url_ = this.baseUrl + "/api/Auth/register";
url_ = url_.replace(/[?&]$/, "");
var content_ = JSON.stringify(model);
var options_ = {
body: content_,
method: "POST",
headers: {
"Content-Type": "application/json",
}
};
return this.http.fetch(url_, options_).then(function (_response) {
return _this.processRegister(_response);
});
};
AuthClient.prototype.processRegister = 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 === 204) {
return response.text().then(function (_responseText) {
return;
});
}
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 AuthClient;
}());
exports.default = AuthClient;
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 AuthenticateRequest = /** @class */ (function () {
function AuthenticateRequest(data) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
this[property] = data[property];
}
}
}
AuthenticateRequest.prototype.init = function (_data) {
if (_data) {
this.username = _data["username"];
this.password = _data["password"];
}
};
AuthenticateRequest.fromJS = function (data) {
data = typeof data === 'object' ? data : {};
var result = new AuthenticateRequest();
result.init(data);
return result;
};
AuthenticateRequest.prototype.toJSON = function (data) {
data = typeof data === 'object' ? data : {};
data["username"] = this.username;
data["password"] = this.password;
return data;
};
return AuthenticateRequest;
}());
exports.AuthenticateRequest = AuthenticateRequest;
var RegisterRequest = /** @class */ (function () {
function RegisterRequest(data) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
this[property] = data[property];
}
}
}
RegisterRequest.prototype.init = function (_data) {
if (_data) {
this.username = _data["username"];
this.password = _data["password"];
this.confirmPassword = _data["confirmPassword"];
}
};
RegisterRequest.fromJS = function (data) {
data = typeof data === 'object' ? data : {};
var result = new RegisterRequest();
result.init(data);
return result;
};
RegisterRequest.prototype.toJSON = function (data) {
data = typeof data === 'object' ? data : {};
data["username"] = this.username;
data["password"] = this.password;
data["confirmPassword"] = this.confirmPassword;
return data;
};
return RegisterRequest;
}());
exports.RegisterRequest = RegisterRequest;
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=AuthClient.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,274 @@
export default class AuthClient {
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 : "";
}
authenticate(model: AuthenticateRequest): Promise<any> {
let url_ = this.baseUrl + "/api/Auth/authenticate";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(model);
let options_ = <RequestInit>{
body: content_,
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.http.fetch(url_, options_).then((_response: Response) => {
return this.processAuthenticate(_response);
});
}
protected processAuthenticate(response: Response): Promise<any> {
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);
result200 = resultData200 !== undefined ? resultData200 : <any>null;
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<any>(<any>null);
}
register(model: RegisterRequest): Promise<void> {
let url_ = this.baseUrl + "/api/Auth/register";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(model);
let options_ = <RequestInit>{
body: content_,
method: "POST",
headers: {
"Content-Type": "application/json",
}
};
return this.http.fetch(url_, options_).then((_response: Response) => {
return this.processRegister(_response);
});
}
protected processRegister(response: Response): Promise<void> {
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 === 204) {
return response.text().then((_responseText) => {
return;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<void>(<any>null);
}
}
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 AuthenticateRequest implements IAuthenticateRequest {
username!: string;
password!: string;
constructor(data?: IAuthenticateRequest) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
(<any>this)[property] = (<any>data)[property];
}
}
}
init(_data?: any) {
if (_data) {
this.username = _data["username"];
this.password = _data["password"];
}
}
static fromJS(data: any): AuthenticateRequest {
data = typeof data === 'object' ? data : {};
let result = new AuthenticateRequest();
result.init(data);
return result;
}
toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["username"] = this.username;
data["password"] = this.password;
return data;
}
}
export interface IAuthenticateRequest {
username: string;
password: string;
}
export class RegisterRequest implements IRegisterRequest {
username!: string;
password!: string;
confirmPassword!: string;
constructor(data?: IRegisterRequest) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
(<any>this)[property] = (<any>data)[property];
}
}
}
init(_data?: any) {
if (_data) {
this.username = _data["username"];
this.password = _data["password"];
this.confirmPassword = _data["confirmPassword"];
}
}
static fromJS(data: any): RegisterRequest {
data = typeof data === 'object' ? data : {};
let result = new RegisterRequest();
result.init(data);
return result;
}
toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["username"] = this.username;
data["password"] = this.password;
data["confirmPassword"] = this.confirmPassword;
return data;
}
}
export interface IRegisterRequest {
username: string;
password: string;
confirmPassword: string;
}
export interface FileResponse {
data: Blob;
status: number;
fileName?: string;
headers?: { [name: string]: any };
}
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);
}

View File

@ -1,10 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ServiceBase_1 = require("../../common/ServiceBase");
var login_url = 'api/auth/authenticate';
var AuthClient_1 = require("./AuthClient");
exports.default = {
isAuthenticated: function () {
return sessionStorage.getItem('user') !== null;
return sessionStorage.getItem('user') !== null && sessionStorage.getItem('user') !== undefined;
},
isAdmin: function () {
return sessionStorage.getItem('role') === 'Admin';
@ -14,21 +13,16 @@ exports.default = {
sessionStorage.removeItem('role');
},
login: function (username, password) {
var body = {
var service = new AuthClient_1.default();
var request = new AuthClient_1.AuthenticateRequest({
username: username,
password: password
};
var options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
};
return ServiceBase_1.default.makeRequest(login_url, options)
});
return service.authenticate(request)
.then(function (response) {
sessionStorage.setItem('user', response.token_type + " " + response.access_token);
sessionStorage.setItem('role', response.role);
console.log(response);
sessionStorage.setItem('user', response.tokenType + " " + response.accessToken);
sessionStorage.setItem('role', response.userRole);
return Promise.resolve();
});
}

View File

@ -1 +1 @@
{"version":3,"file":"AuthService.js","sourceRoot":"","sources":["AuthService.ts"],"names":[],"mappings":";;AAAA,wDAAmD;AAEnD,IAAM,SAAS,GAAG,uBAAuB,CAAC;AAE1C,kBAAe;IACX,eAAe;QACX,OAAO,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IACnD,CAAC;IAED,OAAO;QACH,OAAO,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC;IACtD,CAAC;IAED,MAAM;QACF,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAClC,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,EAAL,UAAM,QAAgB,EAAE,QAAgB;QACpC,IAAI,IAAI,GAAG;YACP,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,QAAQ;SACrB,CAAC;QACF,IAAI,OAAO,GAAG;YACV,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACL,cAAc,EAAE,kBAAkB;aACrC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC7B,CAAC;QAEF,OAAO,qBAAW,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC;aAC7C,IAAI,CAAC,UAAA,QAAQ;YACV,cAAc,CAAC,OAAO,CAAC,MAAM,EAAK,QAAQ,CAAC,UAAU,SAAI,QAAQ,CAAC,YAAc,CAAC,CAAC;YAClF,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC9C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;IACX,CAAC;CACJ,CAAA"}
{"version":3,"file":"AuthService.js","sourceRoot":"","sources":["AuthService.ts"],"names":[],"mappings":";;AAAA,2CAA+D;AAE/D,kBAAe;IACX,eAAe;QACX,OAAO,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;IACnG,CAAC;IAED,OAAO;QACH,OAAO,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC;IACtD,CAAC;IAED,MAAM;QACF,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAClC,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,EAAL,UAAM,QAAgB,EAAE,QAAgB;QACpC,IAAM,OAAO,GAAG,IAAI,oBAAU,EAAE,CAAC;QAEjC,IAAI,OAAO,GAAG,IAAI,gCAAmB,CAAC;YAClC,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,QAAQ;SACrB,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC;aAC/B,IAAI,CAAC,UAAA,QAAQ;YACV,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACtB,cAAc,CAAC,OAAO,CAAC,MAAM,EAAK,QAAQ,CAAC,SAAS,SAAI,QAAQ,CAAC,WAAa,CAAC,CAAC;YAChF,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAClD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;IACX,CAAC;CACJ,CAAA"}

View File

@ -1,10 +1,8 @@
import ServiceBase from '../../common/ServiceBase';
const login_url = 'api/auth/authenticate';
import AuthClient, { AuthenticateRequest } from './AuthClient';
export default {
isAuthenticated() {
return sessionStorage.getItem('user') !== null;
return sessionStorage.getItem('user') !== null && sessionStorage.getItem('user') !== undefined;
},
isAdmin() {
@ -17,22 +15,18 @@ export default {
},
login(username: string, password: string) {
let body = {
const service = new AuthClient();
let request = new AuthenticateRequest({
username: username,
password: password
};
let options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
};
});
return ServiceBase.makeRequest(login_url, options)
return service.authenticate(request)
.then(response => {
sessionStorage.setItem('user', `${response.token_type} ${response.access_token}`);
sessionStorage.setItem('role', response.role);
console.log(response);
sessionStorage.setItem('user', `${response.tokenType} ${response.accessToken}`);
sessionStorage.setItem('role', response.userRole);
return Promise.resolve();
});
}

View File

@ -38,7 +38,8 @@ var DeviceService = /** @class */ (function () {
var options_ = {
method: "GET",
headers: {
"Accept": "application/json"
"Accept": "application/json",
'Authorization': sessionStorage.getItem('user')
}
};
return this.http.fetch(url_, options_).then(function (_response) {
@ -89,7 +90,9 @@ var DeviceService = /** @class */ (function () {
url_ = url_.replace(/[?&]$/, "");
var options_ = {
method: "POST",
headers: {}
headers: {
'Authorization': sessionStorage.getItem('user')
}
};
return this.http.fetch(url_, options_).then(function (_response) {
return _this.processOfflineall(_response);
@ -129,7 +132,9 @@ var DeviceService = /** @class */ (function () {
url_ = url_.replace(/[?&]$/, "");
var options_ = {
method: "POST",
headers: {}
headers: {
'Authorization': sessionStorage.getItem('user')
}
};
return this.http.fetch(url_, options_).then(function (_response) {
return _this.processOnlineall(_response);
@ -174,7 +179,8 @@ var DeviceService = /** @class */ (function () {
var options_ = {
method: "GET",
headers: {
"Accept": "application/json"
"Accept": "application/json",
'Authorization': sessionStorage.getItem('user')
}
};
return this.http.fetch(url_, options_).then(function (_response) {
@ -223,7 +229,9 @@ var DeviceService = /** @class */ (function () {
url_ = url_.replace(/[?&]$/, "");
var options_ = {
method: "POST",
headers: {}
headers: {
'Authorization': sessionStorage.getItem('user')
}
};
return this.http.fetch(url_, options_).then(function (_response) {
return _this.processOfflinedevice(_response);
@ -267,7 +275,9 @@ var DeviceService = /** @class */ (function () {
url_ = url_.replace(/[?&]$/, "");
var options_ = {
method: "POST",
headers: {}
headers: {
'Authorization': sessionStorage.getItem('user')
}
};
return this.http.fetch(url_, options_).then(function (_response) {
return _this.processOnlinedevice(_response);
@ -316,7 +326,8 @@ var DeviceService = /** @class */ (function () {
var options_ = {
method: "GET",
headers: {
"Accept": "application/json"
"Accept": "application/json",
'Authorization': sessionStorage.getItem('user')
}
};
return this.http.fetch(url_, options_).then(function (_response) {
@ -369,7 +380,9 @@ var DeviceService = /** @class */ (function () {
url_ = url_.replace(/[?&]$/, "");
var options_ = {
method: "POST",
headers: {}
headers: {
'Authorization': sessionStorage.getItem('user')
}
};
return this.http.fetch(url_, options_).then(function (_response) {
return _this.processOfflinesensor(_response);

File diff suppressed because one or more lines are too long

View File

@ -27,7 +27,8 @@ export class DeviceService {
let options_ = <RequestInit>{
method: "GET",
headers: {
"Accept": "application/json"
"Accept": "application/json",
'Authorization': sessionStorage.getItem('user')
}
};
@ -73,6 +74,7 @@ export class DeviceService {
let options_ = <RequestInit>{
method: "POST",
headers: {
'Authorization': sessionStorage.getItem('user')
}
};
@ -111,6 +113,7 @@ export class DeviceService {
let options_ = <RequestInit>{
method: "POST",
headers: {
'Authorization': sessionStorage.getItem('user')
}
};
@ -153,7 +156,8 @@ export class DeviceService {
let options_ = <RequestInit>{
method: "GET",
headers: {
"Accept": "application/json"
"Accept": "application/json",
'Authorization': sessionStorage.getItem('user')
}
};
@ -199,6 +203,7 @@ export class DeviceService {
let options_ = <RequestInit>{
method: "POST",
headers: {
'Authorization': sessionStorage.getItem('user')
}
};
@ -241,6 +246,7 @@ export class DeviceService {
let options_ = <RequestInit>{
method: "POST",
headers: {
'Authorization': sessionStorage.getItem('user')
}
};
@ -287,7 +293,8 @@ export class DeviceService {
let options_ = <RequestInit>{
method: "GET",
headers: {
"Accept": "application/json"
"Accept": "application/json",
'Authorization': sessionStorage.getItem('user')
}
};
@ -337,6 +344,7 @@ export class DeviceService {
let options_ = <RequestInit>{
method: "POST",
headers: {
'Authorization': sessionStorage.getItem('user')
}
};

View File

@ -0,0 +1,101 @@
/*global google*/
import GoogleMapReact from 'google-map-react';
import React, { Component } from 'react';
import DevicesService, { DeviceService } from '../devices/DeviceService'
import { HubConnectionBuilder } from '@microsoft/signalr';
const hub_url = '/hubs/devices';
const method_name = 'NotifyDeviceAsync';
export default class MapContainer extends Component {
constructor(props) {
super(props);
this.state = {
devices: [],
center: {
lat: 48.275939, lng: 21.469640
},
points: [],
heatmapPoints: [],
connection: null,
}
}
componentDidMount() {
const service = new DeviceService();
service.getall().then(result => {
this.setState({ devices: result })
}).catch(ex => {
console.log(ex)
});
const newConnection = new HubConnectionBuilder()
.withUrl(hub_url)
.withAutomaticReconnect()
.build();
this.setState({ connection: newConnection });
newConnection.start()
.then(result => {
console.log('Hub Connected!');
newConnection.on(method_name, (id, date, prob) => {
this.state.points.push({ id, date, prob });
//console.log(method_name + " recieved: [id: " + id + ", date: " + date + ", prob: " + prob + "]");
if (prob > 0.5) {
var device = this.state.devices.filter(function (x) { return x.id === id })[0]
var newPoint = { lat: device.coordinates.latitude, lng: device.coordinates.longitude };
this.setState({
heatmapPoints: [...this.state.heatmapPoints, newPoint ]
});
if (this._googleMap !== undefined) {
const point = { location: new google.maps.LatLng(newPoint.lat, newPoint.lng), weight: prob };
this._googleMap.heatmap.data.push(point)
}
}
});
})
.catch(e => console.log('Hub Connection failed: ', e));
}
componentWillUnmount() {
if (this.state.connection) {
this.state.connection.off(method_name);
}
}
render() {
const heatMapData = {
positions: this.state.heatmapPoints,
options: {
radius: 50,
opacity: 0.6,
}
}
const mapOptions = {
overviewMapControl: true,
mapTypeId: 'terrain'
}
return (
<div style={{ height: '91vh', width: '100%' }}>
<GoogleMapReact
bootstrapURLKeys={{
key: ["AIzaSyCZ51VFfxqZ2GkCmVrcNZdUKsM0fuBQUCY"],
libraries: ['visualization']
}}
ref={(el) => this._googleMap = el}
options={mapOptions}
defaultZoom={18}
heatmapLibrary={true}
heatmap={heatMapData}
defaultCenter={this.state.center}>
</GoogleMapReact>
</div>
);
}
}

View File

@ -1,555 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initMap = void 0;
var google_maps_1 = require("google-maps");
var map, heatmap;
function initMap() {
var options = { /* todo */};
var loader = new google_maps_1.Loader('AIzaSyCZ51VFfxqZ2GkCmVrcNZdUKsM0fuBQUCY', options);
loader.load().then(function (google) {
map = new google.maps.Map(document.getElementById("map"), {
zoom: 13,
center: { lat: 37.775, lng: -122.434 },
mapTypeId: "satellite",
});
heatmap = new google.maps.visualization.HeatmapLayer({
data: getPoints(),
map: map,
});
});
}
exports.initMap = initMap;
function toggleHeatmap() {
heatmap.setMap(heatmap.getMap() ? null : map);
}
function changeGradient() {
var gradient = [
"rgba(0, 255, 255, 0)",
"rgba(0, 255, 255, 1)",
"rgba(0, 191, 255, 1)",
"rgba(0, 127, 255, 1)",
"rgba(0, 63, 255, 1)",
"rgba(0, 0, 255, 1)",
"rgba(0, 0, 223, 1)",
"rgba(0, 0, 191, 1)",
"rgba(0, 0, 159, 1)",
"rgba(0, 0, 127, 1)",
"rgba(63, 0, 91, 1)",
"rgba(127, 0, 63, 1)",
"rgba(191, 0, 31, 1)",
"rgba(255, 0, 0, 1)",
];
heatmap.set("gradient", heatmap.get("gradient") ? null : gradient);
}
function changeRadius() {
heatmap.set("radius", heatmap.get("radius") ? null : 20);
}
function changeOpacity() {
heatmap.set("opacity", heatmap.get("opacity") ? null : 0.2);
}
// Heatmap data: 500 Points
function getPoints() {
return [
new google.maps.LatLng(37.782551, -122.445368),
new google.maps.LatLng(37.782745, -122.444586),
new google.maps.LatLng(37.782842, -122.443688),
new google.maps.LatLng(37.782919, -122.442815),
new google.maps.LatLng(37.782992, -122.442112),
new google.maps.LatLng(37.7831, -122.441461),
new google.maps.LatLng(37.783206, -122.440829),
new google.maps.LatLng(37.783273, -122.440324),
new google.maps.LatLng(37.783316, -122.440023),
new google.maps.LatLng(37.783357, -122.439794),
new google.maps.LatLng(37.783371, -122.439687),
new google.maps.LatLng(37.783368, -122.439666),
new google.maps.LatLng(37.783383, -122.439594),
new google.maps.LatLng(37.783508, -122.439525),
new google.maps.LatLng(37.783842, -122.439591),
new google.maps.LatLng(37.784147, -122.439668),
new google.maps.LatLng(37.784206, -122.439686),
new google.maps.LatLng(37.784386, -122.43979),
new google.maps.LatLng(37.784701, -122.439902),
new google.maps.LatLng(37.784965, -122.439938),
new google.maps.LatLng(37.78501, -122.439947),
new google.maps.LatLng(37.78536, -122.439952),
new google.maps.LatLng(37.785715, -122.44003),
new google.maps.LatLng(37.786117, -122.440119),
new google.maps.LatLng(37.786564, -122.440209),
new google.maps.LatLng(37.786905, -122.44027),
new google.maps.LatLng(37.786956, -122.440279),
new google.maps.LatLng(37.800224, -122.43352),
new google.maps.LatLng(37.800155, -122.434101),
new google.maps.LatLng(37.80016, -122.43443),
new google.maps.LatLng(37.800378, -122.434527),
new google.maps.LatLng(37.800738, -122.434598),
new google.maps.LatLng(37.800938, -122.43465),
new google.maps.LatLng(37.801024, -122.434889),
new google.maps.LatLng(37.800955, -122.435392),
new google.maps.LatLng(37.800886, -122.435959),
new google.maps.LatLng(37.800811, -122.436275),
new google.maps.LatLng(37.800788, -122.436299),
new google.maps.LatLng(37.800719, -122.436302),
new google.maps.LatLng(37.800702, -122.436298),
new google.maps.LatLng(37.800661, -122.436273),
new google.maps.LatLng(37.800395, -122.436172),
new google.maps.LatLng(37.800228, -122.436116),
new google.maps.LatLng(37.800169, -122.43613),
new google.maps.LatLng(37.800066, -122.436167),
new google.maps.LatLng(37.784345, -122.422922),
new google.maps.LatLng(37.784389, -122.422926),
new google.maps.LatLng(37.784437, -122.422924),
new google.maps.LatLng(37.784746, -122.422818),
new google.maps.LatLng(37.785436, -122.422959),
new google.maps.LatLng(37.78612, -122.423112),
new google.maps.LatLng(37.786433, -122.423029),
new google.maps.LatLng(37.786631, -122.421213),
new google.maps.LatLng(37.78666, -122.421033),
new google.maps.LatLng(37.786801, -122.420141),
new google.maps.LatLng(37.786823, -122.420034),
new google.maps.LatLng(37.786831, -122.419916),
new google.maps.LatLng(37.787034, -122.418208),
new google.maps.LatLng(37.787056, -122.418034),
new google.maps.LatLng(37.787169, -122.417145),
new google.maps.LatLng(37.787217, -122.416715),
new google.maps.LatLng(37.786144, -122.416403),
new google.maps.LatLng(37.785292, -122.416257),
new google.maps.LatLng(37.780666, -122.390374),
new google.maps.LatLng(37.780501, -122.391281),
new google.maps.LatLng(37.780148, -122.392052),
new google.maps.LatLng(37.780173, -122.391148),
new google.maps.LatLng(37.780693, -122.390592),
new google.maps.LatLng(37.781261, -122.391142),
new google.maps.LatLng(37.781808, -122.39173),
new google.maps.LatLng(37.78234, -122.392341),
new google.maps.LatLng(37.782812, -122.393022),
new google.maps.LatLng(37.7833, -122.393672),
new google.maps.LatLng(37.783809, -122.394275),
new google.maps.LatLng(37.784246, -122.394979),
new google.maps.LatLng(37.784791, -122.395958),
new google.maps.LatLng(37.785675, -122.396746),
new google.maps.LatLng(37.786262, -122.39578),
new google.maps.LatLng(37.786776, -122.395093),
new google.maps.LatLng(37.787282, -122.394426),
new google.maps.LatLng(37.787783, -122.393767),
new google.maps.LatLng(37.788343, -122.393184),
new google.maps.LatLng(37.788895, -122.392506),
new google.maps.LatLng(37.789371, -122.391701),
new google.maps.LatLng(37.789722, -122.390952),
new google.maps.LatLng(37.790315, -122.390305),
new google.maps.LatLng(37.790738, -122.389616),
new google.maps.LatLng(37.779448, -122.438702),
new google.maps.LatLng(37.779023, -122.438585),
new google.maps.LatLng(37.778542, -122.438492),
new google.maps.LatLng(37.7781, -122.438411),
new google.maps.LatLng(37.777986, -122.438376),
new google.maps.LatLng(37.77768, -122.438313),
new google.maps.LatLng(37.777316, -122.438273),
new google.maps.LatLng(37.777135, -122.438254),
new google.maps.LatLng(37.776987, -122.438303),
new google.maps.LatLng(37.776946, -122.438404),
new google.maps.LatLng(37.776944, -122.438467),
new google.maps.LatLng(37.776892, -122.438459),
new google.maps.LatLng(37.776842, -122.438442),
new google.maps.LatLng(37.776822, -122.438391),
new google.maps.LatLng(37.776814, -122.438412),
new google.maps.LatLng(37.776787, -122.438628),
new google.maps.LatLng(37.776729, -122.43865),
new google.maps.LatLng(37.776759, -122.438677),
new google.maps.LatLng(37.776772, -122.438498),
new google.maps.LatLng(37.776787, -122.438389),
new google.maps.LatLng(37.776848, -122.438283),
new google.maps.LatLng(37.77687, -122.438239),
new google.maps.LatLng(37.777015, -122.438198),
new google.maps.LatLng(37.777333, -122.438256),
new google.maps.LatLng(37.777595, -122.438308),
new google.maps.LatLng(37.777797, -122.438344),
new google.maps.LatLng(37.77816, -122.438442),
new google.maps.LatLng(37.778414, -122.438508),
new google.maps.LatLng(37.778445, -122.438516),
new google.maps.LatLng(37.778503, -122.438529),
new google.maps.LatLng(37.778607, -122.438549),
new google.maps.LatLng(37.77867, -122.438644),
new google.maps.LatLng(37.778847, -122.438706),
new google.maps.LatLng(37.77924, -122.438744),
new google.maps.LatLng(37.779738, -122.438822),
new google.maps.LatLng(37.780201, -122.438882),
new google.maps.LatLng(37.7804, -122.438905),
new google.maps.LatLng(37.780501, -122.438921),
new google.maps.LatLng(37.780892, -122.438986),
new google.maps.LatLng(37.781446, -122.439087),
new google.maps.LatLng(37.781985, -122.439199),
new google.maps.LatLng(37.782239, -122.439249),
new google.maps.LatLng(37.782286, -122.439266),
new google.maps.LatLng(37.797847, -122.429388),
new google.maps.LatLng(37.797874, -122.42918),
new google.maps.LatLng(37.797885, -122.429069),
new google.maps.LatLng(37.797887, -122.42905),
new google.maps.LatLng(37.797933, -122.428954),
new google.maps.LatLng(37.798242, -122.42899),
new google.maps.LatLng(37.798617, -122.429075),
new google.maps.LatLng(37.798719, -122.429092),
new google.maps.LatLng(37.798944, -122.429145),
new google.maps.LatLng(37.79932, -122.429251),
new google.maps.LatLng(37.79959, -122.429309),
new google.maps.LatLng(37.799677, -122.429324),
new google.maps.LatLng(37.799966, -122.42936),
new google.maps.LatLng(37.800288, -122.42943),
new google.maps.LatLng(37.800443, -122.429461),
new google.maps.LatLng(37.800465, -122.429474),
new google.maps.LatLng(37.800644, -122.42954),
new google.maps.LatLng(37.800948, -122.42962),
new google.maps.LatLng(37.801242, -122.429685),
new google.maps.LatLng(37.801375, -122.429702),
new google.maps.LatLng(37.8014, -122.429703),
new google.maps.LatLng(37.801453, -122.429707),
new google.maps.LatLng(37.801473, -122.429709),
new google.maps.LatLng(37.801532, -122.429707),
new google.maps.LatLng(37.801852, -122.429729),
new google.maps.LatLng(37.802173, -122.429789),
new google.maps.LatLng(37.802459, -122.429847),
new google.maps.LatLng(37.802554, -122.429825),
new google.maps.LatLng(37.802647, -122.429549),
new google.maps.LatLng(37.802693, -122.429179),
new google.maps.LatLng(37.802729, -122.428751),
new google.maps.LatLng(37.766104, -122.409291),
new google.maps.LatLng(37.766103, -122.409268),
new google.maps.LatLng(37.766138, -122.409229),
new google.maps.LatLng(37.766183, -122.409231),
new google.maps.LatLng(37.766153, -122.409276),
new google.maps.LatLng(37.766005, -122.409365),
new google.maps.LatLng(37.765897, -122.40957),
new google.maps.LatLng(37.765767, -122.409739),
new google.maps.LatLng(37.765693, -122.410389),
new google.maps.LatLng(37.765615, -122.411201),
new google.maps.LatLng(37.765533, -122.412121),
new google.maps.LatLng(37.765467, -122.412939),
new google.maps.LatLng(37.765444, -122.414821),
new google.maps.LatLng(37.765444, -122.414964),
new google.maps.LatLng(37.765318, -122.415424),
new google.maps.LatLng(37.763961, -122.415296),
new google.maps.LatLng(37.763115, -122.415196),
new google.maps.LatLng(37.762967, -122.415183),
new google.maps.LatLng(37.762278, -122.415127),
new google.maps.LatLng(37.761675, -122.415055),
new google.maps.LatLng(37.760932, -122.414988),
new google.maps.LatLng(37.759337, -122.414862),
new google.maps.LatLng(37.773187, -122.421922),
new google.maps.LatLng(37.773043, -122.422118),
new google.maps.LatLng(37.773007, -122.422165),
new google.maps.LatLng(37.772979, -122.422219),
new google.maps.LatLng(37.772865, -122.422394),
new google.maps.LatLng(37.772779, -122.422503),
new google.maps.LatLng(37.772676, -122.422701),
new google.maps.LatLng(37.772606, -122.422806),
new google.maps.LatLng(37.772566, -122.42284),
new google.maps.LatLng(37.772508, -122.422852),
new google.maps.LatLng(37.772387, -122.423011),
new google.maps.LatLng(37.772099, -122.423328),
new google.maps.LatLng(37.771704, -122.423783),
new google.maps.LatLng(37.771481, -122.424081),
new google.maps.LatLng(37.7714, -122.424179),
new google.maps.LatLng(37.771352, -122.42422),
new google.maps.LatLng(37.771248, -122.424327),
new google.maps.LatLng(37.770904, -122.424781),
new google.maps.LatLng(37.77052, -122.425283),
new google.maps.LatLng(37.770337, -122.425553),
new google.maps.LatLng(37.770128, -122.425832),
new google.maps.LatLng(37.769756, -122.426331),
new google.maps.LatLng(37.7693, -122.426902),
new google.maps.LatLng(37.769132, -122.427065),
new google.maps.LatLng(37.769092, -122.427103),
new google.maps.LatLng(37.768979, -122.427172),
new google.maps.LatLng(37.768595, -122.427634),
new google.maps.LatLng(37.768372, -122.427913),
new google.maps.LatLng(37.768337, -122.427961),
new google.maps.LatLng(37.768244, -122.428138),
new google.maps.LatLng(37.767942, -122.428581),
new google.maps.LatLng(37.767482, -122.429094),
new google.maps.LatLng(37.767031, -122.429606),
new google.maps.LatLng(37.766732, -122.429986),
new google.maps.LatLng(37.76668, -122.430058),
new google.maps.LatLng(37.766633, -122.430109),
new google.maps.LatLng(37.76658, -122.430211),
new google.maps.LatLng(37.766367, -122.430594),
new google.maps.LatLng(37.76591, -122.431137),
new google.maps.LatLng(37.765353, -122.431806),
new google.maps.LatLng(37.764962, -122.432298),
new google.maps.LatLng(37.764868, -122.432486),
new google.maps.LatLng(37.764518, -122.432913),
new google.maps.LatLng(37.763435, -122.434173),
new google.maps.LatLng(37.762847, -122.434953),
new google.maps.LatLng(37.762291, -122.435935),
new google.maps.LatLng(37.762224, -122.436074),
new google.maps.LatLng(37.761957, -122.436892),
new google.maps.LatLng(37.761652, -122.438886),
new google.maps.LatLng(37.761284, -122.439955),
new google.maps.LatLng(37.76121, -122.440068),
new google.maps.LatLng(37.761064, -122.44072),
new google.maps.LatLng(37.76104, -122.441411),
new google.maps.LatLng(37.761048, -122.442324),
new google.maps.LatLng(37.760851, -122.443118),
new google.maps.LatLng(37.759977, -122.444591),
new google.maps.LatLng(37.759913, -122.444698),
new google.maps.LatLng(37.759623, -122.445065),
new google.maps.LatLng(37.758902, -122.445158),
new google.maps.LatLng(37.758428, -122.44457),
new google.maps.LatLng(37.757687, -122.44334),
new google.maps.LatLng(37.757583, -122.44324),
new google.maps.LatLng(37.757019, -122.442787),
new google.maps.LatLng(37.756603, -122.442322),
new google.maps.LatLng(37.75638, -122.441602),
new google.maps.LatLng(37.75579, -122.441382),
new google.maps.LatLng(37.754493, -122.442133),
new google.maps.LatLng(37.754361, -122.442206),
new google.maps.LatLng(37.753719, -122.44265),
new google.maps.LatLng(37.753096, -122.442915),
new google.maps.LatLng(37.751617, -122.443211),
new google.maps.LatLng(37.751496, -122.443246),
new google.maps.LatLng(37.750733, -122.443428),
new google.maps.LatLng(37.750126, -122.443536),
new google.maps.LatLng(37.750103, -122.443784),
new google.maps.LatLng(37.75039, -122.44401),
new google.maps.LatLng(37.750448, -122.444013),
new google.maps.LatLng(37.750536, -122.44404),
new google.maps.LatLng(37.750493, -122.444141),
new google.maps.LatLng(37.790859, -122.402808),
new google.maps.LatLng(37.790864, -122.402768),
new google.maps.LatLng(37.790995, -122.402539),
new google.maps.LatLng(37.791148, -122.402172),
new google.maps.LatLng(37.791385, -122.401312),
new google.maps.LatLng(37.791405, -122.400776),
new google.maps.LatLng(37.791288, -122.400528),
new google.maps.LatLng(37.791113, -122.400441),
new google.maps.LatLng(37.791027, -122.400395),
new google.maps.LatLng(37.791094, -122.400311),
new google.maps.LatLng(37.791211, -122.400183),
new google.maps.LatLng(37.79106, -122.399334),
new google.maps.LatLng(37.790538, -122.398718),
new google.maps.LatLng(37.790095, -122.398086),
new google.maps.LatLng(37.789644, -122.39736),
new google.maps.LatLng(37.789254, -122.396844),
new google.maps.LatLng(37.788855, -122.396397),
new google.maps.LatLng(37.788483, -122.395963),
new google.maps.LatLng(37.788015, -122.395365),
new google.maps.LatLng(37.787558, -122.394735),
new google.maps.LatLng(37.787472, -122.394323),
new google.maps.LatLng(37.78763, -122.394025),
new google.maps.LatLng(37.787767, -122.393987),
new google.maps.LatLng(37.787486, -122.394452),
new google.maps.LatLng(37.786977, -122.395043),
new google.maps.LatLng(37.786583, -122.395552),
new google.maps.LatLng(37.78654, -122.39561),
new google.maps.LatLng(37.786516, -122.395659),
new google.maps.LatLng(37.786378, -122.395707),
new google.maps.LatLng(37.786044, -122.395362),
new google.maps.LatLng(37.785598, -122.394715),
new google.maps.LatLng(37.785321, -122.394361),
new google.maps.LatLng(37.785207, -122.394236),
new google.maps.LatLng(37.785751, -122.394062),
new google.maps.LatLng(37.785996, -122.393881),
new google.maps.LatLng(37.786092, -122.39383),
new google.maps.LatLng(37.785998, -122.393899),
new google.maps.LatLng(37.785114, -122.394365),
new google.maps.LatLng(37.785022, -122.394441),
new google.maps.LatLng(37.784823, -122.394635),
new google.maps.LatLng(37.784719, -122.394629),
new google.maps.LatLng(37.785069, -122.394176),
new google.maps.LatLng(37.7855, -122.39365),
new google.maps.LatLng(37.78577, -122.393291),
new google.maps.LatLng(37.785839, -122.393159),
new google.maps.LatLng(37.782651, -122.400628),
new google.maps.LatLng(37.782616, -122.400599),
new google.maps.LatLng(37.782702, -122.40047),
new google.maps.LatLng(37.782915, -122.400192),
new google.maps.LatLng(37.783137, -122.399887),
new google.maps.LatLng(37.783414, -122.399519),
new google.maps.LatLng(37.783629, -122.399237),
new google.maps.LatLng(37.783688, -122.399157),
new google.maps.LatLng(37.783716, -122.399106),
new google.maps.LatLng(37.783798, -122.399072),
new google.maps.LatLng(37.783997, -122.399186),
new google.maps.LatLng(37.784271, -122.399538),
new google.maps.LatLng(37.784577, -122.399948),
new google.maps.LatLng(37.784828, -122.40026),
new google.maps.LatLng(37.784999, -122.400477),
new google.maps.LatLng(37.785113, -122.400651),
new google.maps.LatLng(37.785155, -122.400703),
new google.maps.LatLng(37.785192, -122.400749),
new google.maps.LatLng(37.785278, -122.400839),
new google.maps.LatLng(37.785387, -122.400857),
new google.maps.LatLng(37.785478, -122.40089),
new google.maps.LatLng(37.785526, -122.401022),
new google.maps.LatLng(37.785598, -122.401148),
new google.maps.LatLng(37.785631, -122.401202),
new google.maps.LatLng(37.78566, -122.401267),
new google.maps.LatLng(37.803986, -122.426035),
new google.maps.LatLng(37.804102, -122.425089),
new google.maps.LatLng(37.804211, -122.424156),
new google.maps.LatLng(37.803861, -122.423385),
new google.maps.LatLng(37.803151, -122.423214),
new google.maps.LatLng(37.802439, -122.423077),
new google.maps.LatLng(37.80174, -122.422905),
new google.maps.LatLng(37.801069, -122.422785),
new google.maps.LatLng(37.800345, -122.422649),
new google.maps.LatLng(37.799633, -122.422603),
new google.maps.LatLng(37.79975, -122.4217),
new google.maps.LatLng(37.799885, -122.420854),
new google.maps.LatLng(37.799209, -122.420607),
new google.maps.LatLng(37.795656, -122.400395),
new google.maps.LatLng(37.795203, -122.400304),
new google.maps.LatLng(37.778738, -122.415584),
new google.maps.LatLng(37.778812, -122.415189),
new google.maps.LatLng(37.778824, -122.415092),
new google.maps.LatLng(37.778833, -122.414932),
new google.maps.LatLng(37.778834, -122.414898),
new google.maps.LatLng(37.77874, -122.414757),
new google.maps.LatLng(37.778501, -122.414433),
new google.maps.LatLng(37.778182, -122.414026),
new google.maps.LatLng(37.777851, -122.413623),
new google.maps.LatLng(37.777486, -122.413166),
new google.maps.LatLng(37.777109, -122.412674),
new google.maps.LatLng(37.776743, -122.412186),
new google.maps.LatLng(37.77644, -122.4118),
new google.maps.LatLng(37.776295, -122.411614),
new google.maps.LatLng(37.776158, -122.41144),
new google.maps.LatLng(37.775806, -122.410997),
new google.maps.LatLng(37.775422, -122.410484),
new google.maps.LatLng(37.775126, -122.410087),
new google.maps.LatLng(37.775012, -122.409854),
new google.maps.LatLng(37.775164, -122.409573),
new google.maps.LatLng(37.775498, -122.40918),
new google.maps.LatLng(37.775868, -122.40873),
new google.maps.LatLng(37.776256, -122.40824),
new google.maps.LatLng(37.776519, -122.407928),
new google.maps.LatLng(37.776539, -122.407904),
new google.maps.LatLng(37.776595, -122.407854),
new google.maps.LatLng(37.776853, -122.407547),
new google.maps.LatLng(37.777234, -122.407087),
new google.maps.LatLng(37.777644, -122.406558),
new google.maps.LatLng(37.778066, -122.406017),
new google.maps.LatLng(37.778468, -122.405499),
new google.maps.LatLng(37.778866, -122.404995),
new google.maps.LatLng(37.779295, -122.404455),
new google.maps.LatLng(37.779695, -122.40395),
new google.maps.LatLng(37.779982, -122.403584),
new google.maps.LatLng(37.780295, -122.403223),
new google.maps.LatLng(37.780664, -122.402766),
new google.maps.LatLng(37.781043, -122.402288),
new google.maps.LatLng(37.781399, -122.401823),
new google.maps.LatLng(37.781727, -122.401407),
new google.maps.LatLng(37.781853, -122.401247),
new google.maps.LatLng(37.781894, -122.401195),
new google.maps.LatLng(37.782076, -122.400977),
new google.maps.LatLng(37.782338, -122.400603),
new google.maps.LatLng(37.782666, -122.400133),
new google.maps.LatLng(37.783048, -122.399634),
new google.maps.LatLng(37.78345, -122.399198),
new google.maps.LatLng(37.783791, -122.398998),
new google.maps.LatLng(37.784177, -122.398959),
new google.maps.LatLng(37.784388, -122.398971),
new google.maps.LatLng(37.784404, -122.399128),
new google.maps.LatLng(37.784586, -122.399524),
new google.maps.LatLng(37.784835, -122.399927),
new google.maps.LatLng(37.785116, -122.400307),
new google.maps.LatLng(37.785282, -122.400539),
new google.maps.LatLng(37.785346, -122.400692),
new google.maps.LatLng(37.765769, -122.407201),
new google.maps.LatLng(37.76579, -122.407414),
new google.maps.LatLng(37.765802, -122.407755),
new google.maps.LatLng(37.765791, -122.408219),
new google.maps.LatLng(37.765763, -122.408759),
new google.maps.LatLng(37.765726, -122.409348),
new google.maps.LatLng(37.765716, -122.409882),
new google.maps.LatLng(37.765708, -122.410202),
new google.maps.LatLng(37.765705, -122.410253),
new google.maps.LatLng(37.765707, -122.410369),
new google.maps.LatLng(37.765692, -122.41072),
new google.maps.LatLng(37.765699, -122.411215),
new google.maps.LatLng(37.765687, -122.411789),
new google.maps.LatLng(37.765666, -122.412373),
new google.maps.LatLng(37.765598, -122.412883),
new google.maps.LatLng(37.765543, -122.413039),
new google.maps.LatLng(37.765532, -122.413125),
new google.maps.LatLng(37.7655, -122.413553),
new google.maps.LatLng(37.765448, -122.414053),
new google.maps.LatLng(37.765388, -122.414645),
new google.maps.LatLng(37.765323, -122.41525),
new google.maps.LatLng(37.765303, -122.415847),
new google.maps.LatLng(37.765251, -122.416439),
new google.maps.LatLng(37.765204, -122.41702),
new google.maps.LatLng(37.765172, -122.417556),
new google.maps.LatLng(37.765164, -122.418075),
new google.maps.LatLng(37.765153, -122.418618),
new google.maps.LatLng(37.765136, -122.419112),
new google.maps.LatLng(37.765129, -122.419378),
new google.maps.LatLng(37.765119, -122.419481),
new google.maps.LatLng(37.7651, -122.419852),
new google.maps.LatLng(37.765083, -122.420349),
new google.maps.LatLng(37.765045, -122.42093),
new google.maps.LatLng(37.764992, -122.421481),
new google.maps.LatLng(37.76498, -122.421695),
new google.maps.LatLng(37.764993, -122.421843),
new google.maps.LatLng(37.764986, -122.422255),
new google.maps.LatLng(37.764975, -122.422823),
new google.maps.LatLng(37.764939, -122.423411),
new google.maps.LatLng(37.764902, -122.424014),
new google.maps.LatLng(37.764853, -122.424576),
new google.maps.LatLng(37.764826, -122.424922),
new google.maps.LatLng(37.764796, -122.425375),
new google.maps.LatLng(37.764782, -122.425869),
new google.maps.LatLng(37.764768, -122.426089),
new google.maps.LatLng(37.764766, -122.426117),
new google.maps.LatLng(37.764723, -122.426276),
new google.maps.LatLng(37.764681, -122.426649),
new google.maps.LatLng(37.782012, -122.4042),
new google.maps.LatLng(37.781574, -122.404911),
new google.maps.LatLng(37.781055, -122.405597),
new google.maps.LatLng(37.780479, -122.406341),
new google.maps.LatLng(37.779996, -122.406939),
new google.maps.LatLng(37.779459, -122.407613),
new google.maps.LatLng(37.778953, -122.408228),
new google.maps.LatLng(37.778409, -122.408839),
new google.maps.LatLng(37.777842, -122.409501),
new google.maps.LatLng(37.777334, -122.410181),
new google.maps.LatLng(37.776809, -122.410836),
new google.maps.LatLng(37.77624, -122.411514),
new google.maps.LatLng(37.775725, -122.412145),
new google.maps.LatLng(37.77519, -122.412805),
new google.maps.LatLng(37.774672, -122.413464),
new google.maps.LatLng(37.774084, -122.414186),
new google.maps.LatLng(37.773533, -122.413636),
new google.maps.LatLng(37.773021, -122.413009),
new google.maps.LatLng(37.772501, -122.412371),
new google.maps.LatLng(37.771964, -122.411681),
new google.maps.LatLng(37.771479, -122.411078),
new google.maps.LatLng(37.770992, -122.410477),
new google.maps.LatLng(37.770467, -122.409801),
new google.maps.LatLng(37.77009, -122.408904),
new google.maps.LatLng(37.769657, -122.408103),
new google.maps.LatLng(37.769132, -122.407276),
new google.maps.LatLng(37.768564, -122.406469),
new google.maps.LatLng(37.76798, -122.405745),
new google.maps.LatLng(37.76738, -122.405299),
new google.maps.LatLng(37.766604, -122.405297),
new google.maps.LatLng(37.765838, -122.4052),
new google.maps.LatLng(37.765139, -122.405139),
new google.maps.LatLng(37.764457, -122.405094),
new google.maps.LatLng(37.763716, -122.405142),
new google.maps.LatLng(37.762932, -122.405398),
new google.maps.LatLng(37.762126, -122.405813),
new google.maps.LatLng(37.761344, -122.406215),
new google.maps.LatLng(37.760556, -122.406495),
new google.maps.LatLng(37.759732, -122.406484),
new google.maps.LatLng(37.75891, -122.406228),
new google.maps.LatLng(37.758182, -122.405695),
new google.maps.LatLng(37.757676, -122.405118),
new google.maps.LatLng(37.757039, -122.404346),
new google.maps.LatLng(37.756335, -122.403719),
new google.maps.LatLng(37.755503, -122.403406),
new google.maps.LatLng(37.754665, -122.403242),
new google.maps.LatLng(37.753837, -122.403172),
new google.maps.LatLng(37.752986, -122.403112),
new google.maps.LatLng(37.751266, -122.403355),
];
}
//# sourceMappingURL=heatmap.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,561 +0,0 @@
import { Loader, LoaderOptions } from 'google-maps';
let map: google.maps.Map, heatmap: google.maps.visualization.HeatmapLayer;
function initMap(): void {
const options: LoaderOptions = {/* todo */ };
const loader = new Loader('AIzaSyCZ51VFfxqZ2GkCmVrcNZdUKsM0fuBQUCY', options);
loader.load().then(function (google) {
map = new google.maps.Map(document.getElementById("map") as HTMLElement, {
zoom: 13,
center: { lat: 37.775, lng: -122.434 },
mapTypeId: "satellite",
});
heatmap = new google.maps.visualization.HeatmapLayer({
data: getPoints(),
map: map,
});
});
}
function toggleHeatmap() {
heatmap.setMap(heatmap.getMap() ? null : map);
}
function changeGradient() {
const gradient = [
"rgba(0, 255, 255, 0)",
"rgba(0, 255, 255, 1)",
"rgba(0, 191, 255, 1)",
"rgba(0, 127, 255, 1)",
"rgba(0, 63, 255, 1)",
"rgba(0, 0, 255, 1)",
"rgba(0, 0, 223, 1)",
"rgba(0, 0, 191, 1)",
"rgba(0, 0, 159, 1)",
"rgba(0, 0, 127, 1)",
"rgba(63, 0, 91, 1)",
"rgba(127, 0, 63, 1)",
"rgba(191, 0, 31, 1)",
"rgba(255, 0, 0, 1)",
];
heatmap.set("gradient", heatmap.get("gradient") ? null : gradient);
}
function changeRadius() {
heatmap.set("radius", heatmap.get("radius") ? null : 20);
}
function changeOpacity() {
heatmap.set("opacity", heatmap.get("opacity") ? null : 0.2);
}
// Heatmap data: 500 Points
function getPoints() {
return [
new google.maps.LatLng(37.782551, -122.445368),
new google.maps.LatLng(37.782745, -122.444586),
new google.maps.LatLng(37.782842, -122.443688),
new google.maps.LatLng(37.782919, -122.442815),
new google.maps.LatLng(37.782992, -122.442112),
new google.maps.LatLng(37.7831, -122.441461),
new google.maps.LatLng(37.783206, -122.440829),
new google.maps.LatLng(37.783273, -122.440324),
new google.maps.LatLng(37.783316, -122.440023),
new google.maps.LatLng(37.783357, -122.439794),
new google.maps.LatLng(37.783371, -122.439687),
new google.maps.LatLng(37.783368, -122.439666),
new google.maps.LatLng(37.783383, -122.439594),
new google.maps.LatLng(37.783508, -122.439525),
new google.maps.LatLng(37.783842, -122.439591),
new google.maps.LatLng(37.784147, -122.439668),
new google.maps.LatLng(37.784206, -122.439686),
new google.maps.LatLng(37.784386, -122.43979),
new google.maps.LatLng(37.784701, -122.439902),
new google.maps.LatLng(37.784965, -122.439938),
new google.maps.LatLng(37.78501, -122.439947),
new google.maps.LatLng(37.78536, -122.439952),
new google.maps.LatLng(37.785715, -122.44003),
new google.maps.LatLng(37.786117, -122.440119),
new google.maps.LatLng(37.786564, -122.440209),
new google.maps.LatLng(37.786905, -122.44027),
new google.maps.LatLng(37.786956, -122.440279),
new google.maps.LatLng(37.800224, -122.43352),
new google.maps.LatLng(37.800155, -122.434101),
new google.maps.LatLng(37.80016, -122.43443),
new google.maps.LatLng(37.800378, -122.434527),
new google.maps.LatLng(37.800738, -122.434598),
new google.maps.LatLng(37.800938, -122.43465),
new google.maps.LatLng(37.801024, -122.434889),
new google.maps.LatLng(37.800955, -122.435392),
new google.maps.LatLng(37.800886, -122.435959),
new google.maps.LatLng(37.800811, -122.436275),
new google.maps.LatLng(37.800788, -122.436299),
new google.maps.LatLng(37.800719, -122.436302),
new google.maps.LatLng(37.800702, -122.436298),
new google.maps.LatLng(37.800661, -122.436273),
new google.maps.LatLng(37.800395, -122.436172),
new google.maps.LatLng(37.800228, -122.436116),
new google.maps.LatLng(37.800169, -122.43613),
new google.maps.LatLng(37.800066, -122.436167),
new google.maps.LatLng(37.784345, -122.422922),
new google.maps.LatLng(37.784389, -122.422926),
new google.maps.LatLng(37.784437, -122.422924),
new google.maps.LatLng(37.784746, -122.422818),
new google.maps.LatLng(37.785436, -122.422959),
new google.maps.LatLng(37.78612, -122.423112),
new google.maps.LatLng(37.786433, -122.423029),
new google.maps.LatLng(37.786631, -122.421213),
new google.maps.LatLng(37.78666, -122.421033),
new google.maps.LatLng(37.786801, -122.420141),
new google.maps.LatLng(37.786823, -122.420034),
new google.maps.LatLng(37.786831, -122.419916),
new google.maps.LatLng(37.787034, -122.418208),
new google.maps.LatLng(37.787056, -122.418034),
new google.maps.LatLng(37.787169, -122.417145),
new google.maps.LatLng(37.787217, -122.416715),
new google.maps.LatLng(37.786144, -122.416403),
new google.maps.LatLng(37.785292, -122.416257),
new google.maps.LatLng(37.780666, -122.390374),
new google.maps.LatLng(37.780501, -122.391281),
new google.maps.LatLng(37.780148, -122.392052),
new google.maps.LatLng(37.780173, -122.391148),
new google.maps.LatLng(37.780693, -122.390592),
new google.maps.LatLng(37.781261, -122.391142),
new google.maps.LatLng(37.781808, -122.39173),
new google.maps.LatLng(37.78234, -122.392341),
new google.maps.LatLng(37.782812, -122.393022),
new google.maps.LatLng(37.7833, -122.393672),
new google.maps.LatLng(37.783809, -122.394275),
new google.maps.LatLng(37.784246, -122.394979),
new google.maps.LatLng(37.784791, -122.395958),
new google.maps.LatLng(37.785675, -122.396746),
new google.maps.LatLng(37.786262, -122.39578),
new google.maps.LatLng(37.786776, -122.395093),
new google.maps.LatLng(37.787282, -122.394426),
new google.maps.LatLng(37.787783, -122.393767),
new google.maps.LatLng(37.788343, -122.393184),
new google.maps.LatLng(37.788895, -122.392506),
new google.maps.LatLng(37.789371, -122.391701),
new google.maps.LatLng(37.789722, -122.390952),
new google.maps.LatLng(37.790315, -122.390305),
new google.maps.LatLng(37.790738, -122.389616),
new google.maps.LatLng(37.779448, -122.438702),
new google.maps.LatLng(37.779023, -122.438585),
new google.maps.LatLng(37.778542, -122.438492),
new google.maps.LatLng(37.7781, -122.438411),
new google.maps.LatLng(37.777986, -122.438376),
new google.maps.LatLng(37.77768, -122.438313),
new google.maps.LatLng(37.777316, -122.438273),
new google.maps.LatLng(37.777135, -122.438254),
new google.maps.LatLng(37.776987, -122.438303),
new google.maps.LatLng(37.776946, -122.438404),
new google.maps.LatLng(37.776944, -122.438467),
new google.maps.LatLng(37.776892, -122.438459),
new google.maps.LatLng(37.776842, -122.438442),
new google.maps.LatLng(37.776822, -122.438391),
new google.maps.LatLng(37.776814, -122.438412),
new google.maps.LatLng(37.776787, -122.438628),
new google.maps.LatLng(37.776729, -122.43865),
new google.maps.LatLng(37.776759, -122.438677),
new google.maps.LatLng(37.776772, -122.438498),
new google.maps.LatLng(37.776787, -122.438389),
new google.maps.LatLng(37.776848, -122.438283),
new google.maps.LatLng(37.77687, -122.438239),
new google.maps.LatLng(37.777015, -122.438198),
new google.maps.LatLng(37.777333, -122.438256),
new google.maps.LatLng(37.777595, -122.438308),
new google.maps.LatLng(37.777797, -122.438344),
new google.maps.LatLng(37.77816, -122.438442),
new google.maps.LatLng(37.778414, -122.438508),
new google.maps.LatLng(37.778445, -122.438516),
new google.maps.LatLng(37.778503, -122.438529),
new google.maps.LatLng(37.778607, -122.438549),
new google.maps.LatLng(37.77867, -122.438644),
new google.maps.LatLng(37.778847, -122.438706),
new google.maps.LatLng(37.77924, -122.438744),
new google.maps.LatLng(37.779738, -122.438822),
new google.maps.LatLng(37.780201, -122.438882),
new google.maps.LatLng(37.7804, -122.438905),
new google.maps.LatLng(37.780501, -122.438921),
new google.maps.LatLng(37.780892, -122.438986),
new google.maps.LatLng(37.781446, -122.439087),
new google.maps.LatLng(37.781985, -122.439199),
new google.maps.LatLng(37.782239, -122.439249),
new google.maps.LatLng(37.782286, -122.439266),
new google.maps.LatLng(37.797847, -122.429388),
new google.maps.LatLng(37.797874, -122.42918),
new google.maps.LatLng(37.797885, -122.429069),
new google.maps.LatLng(37.797887, -122.42905),
new google.maps.LatLng(37.797933, -122.428954),
new google.maps.LatLng(37.798242, -122.42899),
new google.maps.LatLng(37.798617, -122.429075),
new google.maps.LatLng(37.798719, -122.429092),
new google.maps.LatLng(37.798944, -122.429145),
new google.maps.LatLng(37.79932, -122.429251),
new google.maps.LatLng(37.79959, -122.429309),
new google.maps.LatLng(37.799677, -122.429324),
new google.maps.LatLng(37.799966, -122.42936),
new google.maps.LatLng(37.800288, -122.42943),
new google.maps.LatLng(37.800443, -122.429461),
new google.maps.LatLng(37.800465, -122.429474),
new google.maps.LatLng(37.800644, -122.42954),
new google.maps.LatLng(37.800948, -122.42962),
new google.maps.LatLng(37.801242, -122.429685),
new google.maps.LatLng(37.801375, -122.429702),
new google.maps.LatLng(37.8014, -122.429703),
new google.maps.LatLng(37.801453, -122.429707),
new google.maps.LatLng(37.801473, -122.429709),
new google.maps.LatLng(37.801532, -122.429707),
new google.maps.LatLng(37.801852, -122.429729),
new google.maps.LatLng(37.802173, -122.429789),
new google.maps.LatLng(37.802459, -122.429847),
new google.maps.LatLng(37.802554, -122.429825),
new google.maps.LatLng(37.802647, -122.429549),
new google.maps.LatLng(37.802693, -122.429179),
new google.maps.LatLng(37.802729, -122.428751),
new google.maps.LatLng(37.766104, -122.409291),
new google.maps.LatLng(37.766103, -122.409268),
new google.maps.LatLng(37.766138, -122.409229),
new google.maps.LatLng(37.766183, -122.409231),
new google.maps.LatLng(37.766153, -122.409276),
new google.maps.LatLng(37.766005, -122.409365),
new google.maps.LatLng(37.765897, -122.40957),
new google.maps.LatLng(37.765767, -122.409739),
new google.maps.LatLng(37.765693, -122.410389),
new google.maps.LatLng(37.765615, -122.411201),
new google.maps.LatLng(37.765533, -122.412121),
new google.maps.LatLng(37.765467, -122.412939),
new google.maps.LatLng(37.765444, -122.414821),
new google.maps.LatLng(37.765444, -122.414964),
new google.maps.LatLng(37.765318, -122.415424),
new google.maps.LatLng(37.763961, -122.415296),
new google.maps.LatLng(37.763115, -122.415196),
new google.maps.LatLng(37.762967, -122.415183),
new google.maps.LatLng(37.762278, -122.415127),
new google.maps.LatLng(37.761675, -122.415055),
new google.maps.LatLng(37.760932, -122.414988),
new google.maps.LatLng(37.759337, -122.414862),
new google.maps.LatLng(37.773187, -122.421922),
new google.maps.LatLng(37.773043, -122.422118),
new google.maps.LatLng(37.773007, -122.422165),
new google.maps.LatLng(37.772979, -122.422219),
new google.maps.LatLng(37.772865, -122.422394),
new google.maps.LatLng(37.772779, -122.422503),
new google.maps.LatLng(37.772676, -122.422701),
new google.maps.LatLng(37.772606, -122.422806),
new google.maps.LatLng(37.772566, -122.42284),
new google.maps.LatLng(37.772508, -122.422852),
new google.maps.LatLng(37.772387, -122.423011),
new google.maps.LatLng(37.772099, -122.423328),
new google.maps.LatLng(37.771704, -122.423783),
new google.maps.LatLng(37.771481, -122.424081),
new google.maps.LatLng(37.7714, -122.424179),
new google.maps.LatLng(37.771352, -122.42422),
new google.maps.LatLng(37.771248, -122.424327),
new google.maps.LatLng(37.770904, -122.424781),
new google.maps.LatLng(37.77052, -122.425283),
new google.maps.LatLng(37.770337, -122.425553),
new google.maps.LatLng(37.770128, -122.425832),
new google.maps.LatLng(37.769756, -122.426331),
new google.maps.LatLng(37.7693, -122.426902),
new google.maps.LatLng(37.769132, -122.427065),
new google.maps.LatLng(37.769092, -122.427103),
new google.maps.LatLng(37.768979, -122.427172),
new google.maps.LatLng(37.768595, -122.427634),
new google.maps.LatLng(37.768372, -122.427913),
new google.maps.LatLng(37.768337, -122.427961),
new google.maps.LatLng(37.768244, -122.428138),
new google.maps.LatLng(37.767942, -122.428581),
new google.maps.LatLng(37.767482, -122.429094),
new google.maps.LatLng(37.767031, -122.429606),
new google.maps.LatLng(37.766732, -122.429986),
new google.maps.LatLng(37.76668, -122.430058),
new google.maps.LatLng(37.766633, -122.430109),
new google.maps.LatLng(37.76658, -122.430211),
new google.maps.LatLng(37.766367, -122.430594),
new google.maps.LatLng(37.76591, -122.431137),
new google.maps.LatLng(37.765353, -122.431806),
new google.maps.LatLng(37.764962, -122.432298),
new google.maps.LatLng(37.764868, -122.432486),
new google.maps.LatLng(37.764518, -122.432913),
new google.maps.LatLng(37.763435, -122.434173),
new google.maps.LatLng(37.762847, -122.434953),
new google.maps.LatLng(37.762291, -122.435935),
new google.maps.LatLng(37.762224, -122.436074),
new google.maps.LatLng(37.761957, -122.436892),
new google.maps.LatLng(37.761652, -122.438886),
new google.maps.LatLng(37.761284, -122.439955),
new google.maps.LatLng(37.76121, -122.440068),
new google.maps.LatLng(37.761064, -122.44072),
new google.maps.LatLng(37.76104, -122.441411),
new google.maps.LatLng(37.761048, -122.442324),
new google.maps.LatLng(37.760851, -122.443118),
new google.maps.LatLng(37.759977, -122.444591),
new google.maps.LatLng(37.759913, -122.444698),
new google.maps.LatLng(37.759623, -122.445065),
new google.maps.LatLng(37.758902, -122.445158),
new google.maps.LatLng(37.758428, -122.44457),
new google.maps.LatLng(37.757687, -122.44334),
new google.maps.LatLng(37.757583, -122.44324),
new google.maps.LatLng(37.757019, -122.442787),
new google.maps.LatLng(37.756603, -122.442322),
new google.maps.LatLng(37.75638, -122.441602),
new google.maps.LatLng(37.75579, -122.441382),
new google.maps.LatLng(37.754493, -122.442133),
new google.maps.LatLng(37.754361, -122.442206),
new google.maps.LatLng(37.753719, -122.44265),
new google.maps.LatLng(37.753096, -122.442915),
new google.maps.LatLng(37.751617, -122.443211),
new google.maps.LatLng(37.751496, -122.443246),
new google.maps.LatLng(37.750733, -122.443428),
new google.maps.LatLng(37.750126, -122.443536),
new google.maps.LatLng(37.750103, -122.443784),
new google.maps.LatLng(37.75039, -122.44401),
new google.maps.LatLng(37.750448, -122.444013),
new google.maps.LatLng(37.750536, -122.44404),
new google.maps.LatLng(37.750493, -122.444141),
new google.maps.LatLng(37.790859, -122.402808),
new google.maps.LatLng(37.790864, -122.402768),
new google.maps.LatLng(37.790995, -122.402539),
new google.maps.LatLng(37.791148, -122.402172),
new google.maps.LatLng(37.791385, -122.401312),
new google.maps.LatLng(37.791405, -122.400776),
new google.maps.LatLng(37.791288, -122.400528),
new google.maps.LatLng(37.791113, -122.400441),
new google.maps.LatLng(37.791027, -122.400395),
new google.maps.LatLng(37.791094, -122.400311),
new google.maps.LatLng(37.791211, -122.400183),
new google.maps.LatLng(37.79106, -122.399334),
new google.maps.LatLng(37.790538, -122.398718),
new google.maps.LatLng(37.790095, -122.398086),
new google.maps.LatLng(37.789644, -122.39736),
new google.maps.LatLng(37.789254, -122.396844),
new google.maps.LatLng(37.788855, -122.396397),
new google.maps.LatLng(37.788483, -122.395963),
new google.maps.LatLng(37.788015, -122.395365),
new google.maps.LatLng(37.787558, -122.394735),
new google.maps.LatLng(37.787472, -122.394323),
new google.maps.LatLng(37.78763, -122.394025),
new google.maps.LatLng(37.787767, -122.393987),
new google.maps.LatLng(37.787486, -122.394452),
new google.maps.LatLng(37.786977, -122.395043),
new google.maps.LatLng(37.786583, -122.395552),
new google.maps.LatLng(37.78654, -122.39561),
new google.maps.LatLng(37.786516, -122.395659),
new google.maps.LatLng(37.786378, -122.395707),
new google.maps.LatLng(37.786044, -122.395362),
new google.maps.LatLng(37.785598, -122.394715),
new google.maps.LatLng(37.785321, -122.394361),
new google.maps.LatLng(37.785207, -122.394236),
new google.maps.LatLng(37.785751, -122.394062),
new google.maps.LatLng(37.785996, -122.393881),
new google.maps.LatLng(37.786092, -122.39383),
new google.maps.LatLng(37.785998, -122.393899),
new google.maps.LatLng(37.785114, -122.394365),
new google.maps.LatLng(37.785022, -122.394441),
new google.maps.LatLng(37.784823, -122.394635),
new google.maps.LatLng(37.784719, -122.394629),
new google.maps.LatLng(37.785069, -122.394176),
new google.maps.LatLng(37.7855, -122.39365),
new google.maps.LatLng(37.78577, -122.393291),
new google.maps.LatLng(37.785839, -122.393159),
new google.maps.LatLng(37.782651, -122.400628),
new google.maps.LatLng(37.782616, -122.400599),
new google.maps.LatLng(37.782702, -122.40047),
new google.maps.LatLng(37.782915, -122.400192),
new google.maps.LatLng(37.783137, -122.399887),
new google.maps.LatLng(37.783414, -122.399519),
new google.maps.LatLng(37.783629, -122.399237),
new google.maps.LatLng(37.783688, -122.399157),
new google.maps.LatLng(37.783716, -122.399106),
new google.maps.LatLng(37.783798, -122.399072),
new google.maps.LatLng(37.783997, -122.399186),
new google.maps.LatLng(37.784271, -122.399538),
new google.maps.LatLng(37.784577, -122.399948),
new google.maps.LatLng(37.784828, -122.40026),
new google.maps.LatLng(37.784999, -122.400477),
new google.maps.LatLng(37.785113, -122.400651),
new google.maps.LatLng(37.785155, -122.400703),
new google.maps.LatLng(37.785192, -122.400749),
new google.maps.LatLng(37.785278, -122.400839),
new google.maps.LatLng(37.785387, -122.400857),
new google.maps.LatLng(37.785478, -122.40089),
new google.maps.LatLng(37.785526, -122.401022),
new google.maps.LatLng(37.785598, -122.401148),
new google.maps.LatLng(37.785631, -122.401202),
new google.maps.LatLng(37.78566, -122.401267),
new google.maps.LatLng(37.803986, -122.426035),
new google.maps.LatLng(37.804102, -122.425089),
new google.maps.LatLng(37.804211, -122.424156),
new google.maps.LatLng(37.803861, -122.423385),
new google.maps.LatLng(37.803151, -122.423214),
new google.maps.LatLng(37.802439, -122.423077),
new google.maps.LatLng(37.80174, -122.422905),
new google.maps.LatLng(37.801069, -122.422785),
new google.maps.LatLng(37.800345, -122.422649),
new google.maps.LatLng(37.799633, -122.422603),
new google.maps.LatLng(37.79975, -122.4217),
new google.maps.LatLng(37.799885, -122.420854),
new google.maps.LatLng(37.799209, -122.420607),
new google.maps.LatLng(37.795656, -122.400395),
new google.maps.LatLng(37.795203, -122.400304),
new google.maps.LatLng(37.778738, -122.415584),
new google.maps.LatLng(37.778812, -122.415189),
new google.maps.LatLng(37.778824, -122.415092),
new google.maps.LatLng(37.778833, -122.414932),
new google.maps.LatLng(37.778834, -122.414898),
new google.maps.LatLng(37.77874, -122.414757),
new google.maps.LatLng(37.778501, -122.414433),
new google.maps.LatLng(37.778182, -122.414026),
new google.maps.LatLng(37.777851, -122.413623),
new google.maps.LatLng(37.777486, -122.413166),
new google.maps.LatLng(37.777109, -122.412674),
new google.maps.LatLng(37.776743, -122.412186),
new google.maps.LatLng(37.77644, -122.4118),
new google.maps.LatLng(37.776295, -122.411614),
new google.maps.LatLng(37.776158, -122.41144),
new google.maps.LatLng(37.775806, -122.410997),
new google.maps.LatLng(37.775422, -122.410484),
new google.maps.LatLng(37.775126, -122.410087),
new google.maps.LatLng(37.775012, -122.409854),
new google.maps.LatLng(37.775164, -122.409573),
new google.maps.LatLng(37.775498, -122.40918),
new google.maps.LatLng(37.775868, -122.40873),
new google.maps.LatLng(37.776256, -122.40824),
new google.maps.LatLng(37.776519, -122.407928),
new google.maps.LatLng(37.776539, -122.407904),
new google.maps.LatLng(37.776595, -122.407854),
new google.maps.LatLng(37.776853, -122.407547),
new google.maps.LatLng(37.777234, -122.407087),
new google.maps.LatLng(37.777644, -122.406558),
new google.maps.LatLng(37.778066, -122.406017),
new google.maps.LatLng(37.778468, -122.405499),
new google.maps.LatLng(37.778866, -122.404995),
new google.maps.LatLng(37.779295, -122.404455),
new google.maps.LatLng(37.779695, -122.40395),
new google.maps.LatLng(37.779982, -122.403584),
new google.maps.LatLng(37.780295, -122.403223),
new google.maps.LatLng(37.780664, -122.402766),
new google.maps.LatLng(37.781043, -122.402288),
new google.maps.LatLng(37.781399, -122.401823),
new google.maps.LatLng(37.781727, -122.401407),
new google.maps.LatLng(37.781853, -122.401247),
new google.maps.LatLng(37.781894, -122.401195),
new google.maps.LatLng(37.782076, -122.400977),
new google.maps.LatLng(37.782338, -122.400603),
new google.maps.LatLng(37.782666, -122.400133),
new google.maps.LatLng(37.783048, -122.399634),
new google.maps.LatLng(37.78345, -122.399198),
new google.maps.LatLng(37.783791, -122.398998),
new google.maps.LatLng(37.784177, -122.398959),
new google.maps.LatLng(37.784388, -122.398971),
new google.maps.LatLng(37.784404, -122.399128),
new google.maps.LatLng(37.784586, -122.399524),
new google.maps.LatLng(37.784835, -122.399927),
new google.maps.LatLng(37.785116, -122.400307),
new google.maps.LatLng(37.785282, -122.400539),
new google.maps.LatLng(37.785346, -122.400692),
new google.maps.LatLng(37.765769, -122.407201),
new google.maps.LatLng(37.76579, -122.407414),
new google.maps.LatLng(37.765802, -122.407755),
new google.maps.LatLng(37.765791, -122.408219),
new google.maps.LatLng(37.765763, -122.408759),
new google.maps.LatLng(37.765726, -122.409348),
new google.maps.LatLng(37.765716, -122.409882),
new google.maps.LatLng(37.765708, -122.410202),
new google.maps.LatLng(37.765705, -122.410253),
new google.maps.LatLng(37.765707, -122.410369),
new google.maps.LatLng(37.765692, -122.41072),
new google.maps.LatLng(37.765699, -122.411215),
new google.maps.LatLng(37.765687, -122.411789),
new google.maps.LatLng(37.765666, -122.412373),
new google.maps.LatLng(37.765598, -122.412883),
new google.maps.LatLng(37.765543, -122.413039),
new google.maps.LatLng(37.765532, -122.413125),
new google.maps.LatLng(37.7655, -122.413553),
new google.maps.LatLng(37.765448, -122.414053),
new google.maps.LatLng(37.765388, -122.414645),
new google.maps.LatLng(37.765323, -122.41525),
new google.maps.LatLng(37.765303, -122.415847),
new google.maps.LatLng(37.765251, -122.416439),
new google.maps.LatLng(37.765204, -122.41702),
new google.maps.LatLng(37.765172, -122.417556),
new google.maps.LatLng(37.765164, -122.418075),
new google.maps.LatLng(37.765153, -122.418618),
new google.maps.LatLng(37.765136, -122.419112),
new google.maps.LatLng(37.765129, -122.419378),
new google.maps.LatLng(37.765119, -122.419481),
new google.maps.LatLng(37.7651, -122.419852),
new google.maps.LatLng(37.765083, -122.420349),
new google.maps.LatLng(37.765045, -122.42093),
new google.maps.LatLng(37.764992, -122.421481),
new google.maps.LatLng(37.76498, -122.421695),
new google.maps.LatLng(37.764993, -122.421843),
new google.maps.LatLng(37.764986, -122.422255),
new google.maps.LatLng(37.764975, -122.422823),
new google.maps.LatLng(37.764939, -122.423411),
new google.maps.LatLng(37.764902, -122.424014),
new google.maps.LatLng(37.764853, -122.424576),
new google.maps.LatLng(37.764826, -122.424922),
new google.maps.LatLng(37.764796, -122.425375),
new google.maps.LatLng(37.764782, -122.425869),
new google.maps.LatLng(37.764768, -122.426089),
new google.maps.LatLng(37.764766, -122.426117),
new google.maps.LatLng(37.764723, -122.426276),
new google.maps.LatLng(37.764681, -122.426649),
new google.maps.LatLng(37.782012, -122.4042),
new google.maps.LatLng(37.781574, -122.404911),
new google.maps.LatLng(37.781055, -122.405597),
new google.maps.LatLng(37.780479, -122.406341),
new google.maps.LatLng(37.779996, -122.406939),
new google.maps.LatLng(37.779459, -122.407613),
new google.maps.LatLng(37.778953, -122.408228),
new google.maps.LatLng(37.778409, -122.408839),
new google.maps.LatLng(37.777842, -122.409501),
new google.maps.LatLng(37.777334, -122.410181),
new google.maps.LatLng(37.776809, -122.410836),
new google.maps.LatLng(37.77624, -122.411514),
new google.maps.LatLng(37.775725, -122.412145),
new google.maps.LatLng(37.77519, -122.412805),
new google.maps.LatLng(37.774672, -122.413464),
new google.maps.LatLng(37.774084, -122.414186),
new google.maps.LatLng(37.773533, -122.413636),
new google.maps.LatLng(37.773021, -122.413009),
new google.maps.LatLng(37.772501, -122.412371),
new google.maps.LatLng(37.771964, -122.411681),
new google.maps.LatLng(37.771479, -122.411078),
new google.maps.LatLng(37.770992, -122.410477),
new google.maps.LatLng(37.770467, -122.409801),
new google.maps.LatLng(37.77009, -122.408904),
new google.maps.LatLng(37.769657, -122.408103),
new google.maps.LatLng(37.769132, -122.407276),
new google.maps.LatLng(37.768564, -122.406469),
new google.maps.LatLng(37.76798, -122.405745),
new google.maps.LatLng(37.76738, -122.405299),
new google.maps.LatLng(37.766604, -122.405297),
new google.maps.LatLng(37.765838, -122.4052),
new google.maps.LatLng(37.765139, -122.405139),
new google.maps.LatLng(37.764457, -122.405094),
new google.maps.LatLng(37.763716, -122.405142),
new google.maps.LatLng(37.762932, -122.405398),
new google.maps.LatLng(37.762126, -122.405813),
new google.maps.LatLng(37.761344, -122.406215),
new google.maps.LatLng(37.760556, -122.406495),
new google.maps.LatLng(37.759732, -122.406484),
new google.maps.LatLng(37.75891, -122.406228),
new google.maps.LatLng(37.758182, -122.405695),
new google.maps.LatLng(37.757676, -122.405118),
new google.maps.LatLng(37.757039, -122.404346),
new google.maps.LatLng(37.756335, -122.403719),
new google.maps.LatLng(37.755503, -122.403406),
new google.maps.LatLng(37.754665, -122.403242),
new google.maps.LatLng(37.753837, -122.403172),
new google.maps.LatLng(37.752986, -122.403112),
new google.maps.LatLng(37.751266, -122.403355),
];
}
// [END maps_layer_heatmap]
export { initMap };

View File

@ -1,21 +0,0 @@
import { Map, GoogleApiWrapper } from 'google-maps-react';
export function Heatmap() {
const mapStyles = {
width: '100%',
height: '100%',
};
return (
<Map
google={this.props.google}
zoom={8}
style={mapStyles}
initialCenter={{ lat: 47.444, lng: -122.176 }}
/>
);
}
export default GoogleApiWrapper({
apiKey: 'AIzaSyCZ51VFfxqZ2GkCmVrcNZdUKsM0fuBQUCY'
});

View File

@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Authorization;
namespace Birdmap.API.Controllers
{
[Authorize(Roles = "Admin")]
[Authorize(Roles = "User, Admin")]
[ApiController]
[Route("api/[controller]")]
public class DevicesController : ControllerBase
@ -26,7 +26,6 @@ namespace Birdmap.API.Controllers
/// <summary>Get all device info</summary>
/// <returns>Array of devices</returns>
[Authorize(Roles = "User,Admin")]
[HttpGet]
public async Task<ActionResult<List<Device>>> Getall()
{
@ -37,6 +36,7 @@ namespace Birdmap.API.Controllers
/// <summary>Shut down all devices</summary>
/// <returns>Message sent</returns>
[Authorize(Roles = "Admin")]
[HttpPost, Route("offline")]
public async Task<IActionResult> Offlineall()
{
@ -49,6 +49,7 @@ namespace Birdmap.API.Controllers
/// <summary>Bring all devices online</summary>
/// <returns>Message sent</returns>
[Authorize(Roles = "Admin")]
[HttpPost, Route("online")]
public async Task<IActionResult> Onlineall()
{
@ -62,7 +63,6 @@ namespace Birdmap.API.Controllers
/// <summary>Get all device info</summary>
/// <param name="deviceID">ID of device to query</param>
/// <returns>Information about a particular device</returns>
[Authorize(Roles = "User,Admin")]
[HttpGet, Route("{deviceID}")]
public async Task<ActionResult<Device>> Getdevice([BindRequired] Guid deviceID)
{
@ -74,6 +74,7 @@ namespace Birdmap.API.Controllers
/// <summary>Shut down device</summary>
/// <param name="deviceID">ID of device to shut down</param>
/// <returns>Message sent</returns>
[Authorize(Roles = "Admin")]
[HttpPost, Route("{deviceID}/offline")]
public async Task<IActionResult> Offlinedevice([BindRequired] Guid deviceID)
{
@ -87,6 +88,7 @@ namespace Birdmap.API.Controllers
/// <summary>Bring device online</summary>
/// <param name="deviceID">ID of device to bring online</param>
/// <returns>Message sent</returns>
[Authorize(Roles = "Admin")]
[HttpPost, Route("{deviceID}/online")]
public async Task<IActionResult> Onlinedevice([BindRequired] Guid deviceID)
{
@ -101,7 +103,6 @@ namespace Birdmap.API.Controllers
/// <param name="deviceID">ID of device to query</param>
/// <param name="sensorID">ID of sensor to query</param>
/// <returns>Information about a sensor</returns>
[Authorize(Roles = "User,Admin")]
[HttpGet, Route("{deviceID}/{sensorID}")]
public async Task<ActionResult<Sensor>> Getsensor([BindRequired] Guid deviceID, [BindRequired] Guid sensorID)
{
@ -114,6 +115,7 @@ namespace Birdmap.API.Controllers
/// <param name="deviceID">ID of device to query</param>
/// <param name="sensorID">ID of sensor to query</param>
/// <returns>Message sent</returns>
[Authorize(Roles = "Admin")]
[HttpPost, Route("{deviceID}/{sensorID}/offline")]
public async Task<IActionResult> Offlinesensor([BindRequired] Guid deviceID, [BindRequired] Guid sensorID)
{
@ -128,6 +130,7 @@ namespace Birdmap.API.Controllers
/// <param name="deviceID">ID of device to query</param>
/// <param name="sensorID">ID of sensor to query</param>
/// <returns>Message sent</returns>
[Authorize(Roles = "Admin")]
[HttpPost, Route("{deviceID}/{sensorID}/online")]
public async Task<IActionResult> Onlinesensor([BindRequired] Guid deviceID, [BindRequired] Guid sensorID)
{

View File

@ -14,7 +14,7 @@ using System.Threading.Tasks;
namespace Birdmap.API.Controllers
{
[Authorize(Roles = "Admin")]
[Authorize(Roles = "User, Admin")]
[ApiController]
[Route("api/[controller]")]
public class ServicesController : ControllerBase
@ -30,7 +30,6 @@ namespace Birdmap.API.Controllers
_logger = logger;
}
[Authorize(Roles = "User,Admin")]
[HttpGet, ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<List<ServiceInfo>>> GetAsync()
{
@ -59,6 +58,7 @@ namespace Birdmap.API.Controllers
return serviceInfos.ToList();
}
[Authorize(Roles = "Admin")]
[HttpPost, ProducesResponseType(StatusCodes.Status201Created)]
public async Task<ActionResult<ServiceRequest>> PostAsync(ServiceRequest request)
{
@ -73,6 +73,7 @@ namespace Birdmap.API.Controllers
_mapper.Map<ServiceRequest>(created));
}
[Authorize(Roles = "Admin")]
[HttpPut, ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> PutAsync(ServiceRequest request)
{
@ -85,6 +86,7 @@ namespace Birdmap.API.Controllers
return NoContent();
}
[Authorize(Roles = "Admin")]
[HttpDelete("{id}"), ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> DeleteAsync(int id)
{

View File

@ -28,7 +28,7 @@ namespace Birdmap.API.Services.Hubs
return base.OnDisconnectedAsync(exception);
}
public Task UserJoinedAsync(Guid deviceId, DateTime date, double probability)
public Task SendNotification(Guid deviceId, DateTime date, double probability)
{
return Clients.All.NotifyDeviceAsync(deviceId, date, probability);
}

View File

@ -57,10 +57,17 @@ namespace Birdmap.API.Services.Mqtt
_logger.LogInformation($"Recieved [{eventArgs.ClientId}] " +
$"Topic: {eventArgs.ApplicationMessage.Topic} | Payload: {message} | QoS: {eventArgs.ApplicationMessage.QualityOfServiceLevel} | Retain: {eventArgs.ApplicationMessage.Retain}");
var payload = JsonConvert.DeserializeObject<Payload>(message);
var inputResponse = await _inputService.GetInputAsync(payload.TagID);
try
{
var payload = JsonConvert.DeserializeObject<Payload>(message);
var inputResponse = await _inputService.GetInputAsync(payload.TagID);
await _hubContext.Clients.All.NotifyDeviceAsync(inputResponse.Message.Device_id, inputResponse.Message.Date.UtcDateTime, payload.Probability);
await _hubContext.Clients.All.NotifyDeviceAsync(inputResponse.Message.Device_id, inputResponse.Message.Date.UtcDateTime, payload.Probability);
}
catch (Exception ex)
{
_logger.LogError(ex, $"Could not handle application message.");
}
}
public async Task HandleConnectedAsync(MqttClientConnectedEventArgs eventArgs)

View File

@ -12,6 +12,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using NSwag.Generation.Processors.Security;
using System.Text;
namespace Birdmap.API
@ -51,7 +52,7 @@ namespace Birdmap.API
})
.AddJwtBearer(opt =>
{
// opt.RequireHttpsMetadata = false;
//opt.RequireHttpsMetadata = false;
opt.SaveToken = true;
opt.IncludeErrorDetails = true;
opt.TokenValidationParameters = new TokenValidationParameters
@ -95,6 +96,20 @@ namespace Birdmap.API
{
configuration.RootPath = "ClientApp/build";
});
services.AddSwaggerDocument(opt =>
{
opt.Title = "Birdmap";
opt.OperationProcessors.Add(new OperationSecurityScopeProcessor("Jwt Token"));
opt.AddSecurity("Jwt Token", new string[] { },
new NSwag.OpenApiSecurityScheme
{
Type = NSwag.OpenApiSecuritySchemeType.ApiKey,
Name = "Authorization",
In = NSwag.OpenApiSecurityApiKeyLocation.Header,
Description = "Bearer {token}",
});
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -104,19 +119,20 @@ namespace Birdmap.API
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseMiddleware<ExceptionHandlerMiddleware>();
}
app.UseMiddleware<ExceptionHandlerMiddleware>();
app.UseOpenApi();
app.UseSwaggerUi3();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseSpaStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseAuthentication();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{

View File

@ -10,11 +10,11 @@ namespace Birdmap.BLL.Services
{
public class DummyDeviceAndInputService : DeviceAndInputServiceBase
{
private const int numberOfDevices = 15;
private const int numberOfDevices = 50;
private const double centerLong = 21.469640;
private const double centerLat = 48.275939;
private const double radius = 0.000200;
private const double radius = 0.001;
private static readonly Random Rand = new Random();

View File

@ -10,6 +10,7 @@
namespace MQTTnet.TestApp.WinForm
{
using System;
using System.Threading;
using System.Windows.Forms;
/// <summary>
@ -17,16 +18,28 @@ namespace MQTTnet.TestApp.WinForm
/// </summary>
internal static class Program
{
static readonly Mutex mutex = new Mutex(true, "{B9D725A5-48F1-4907-974F-B6C3B9C8C4BB}");
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
if (!mutex.WaitOne(TimeSpan.Zero, true))
return;
try
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
finally
{
mutex.ReleaseMutex();
}
}
}
}