mostly seems to be working!

This commit is contained in:
Luke Berndt
2021-01-24 14:08:53 -05:00
parent 2035855a77
commit 11eed81e80
50 changed files with 723 additions and 343 deletions

View File

@@ -27,7 +27,7 @@ class Navigation extends Component {
{this.props.user.authenticated ? (
<Menu style={navStyle}>
<Menu.Item name="systems" header>
{ process.env.REACT_APP_SITE_NAME}
{process.env.REACT_APP_SITE_NAME}
</Menu.Item>
<Menu.Menu position="right">
<Link to="/list-systems">

View File

@@ -19,7 +19,6 @@ const restricted = (BaseComponent, store) => {
}
checkAuthentication(params) {
const { history } = params;
const authenticated = store.getState().user.authenticated;
if (!authenticated) {
axios

View File

@@ -0,0 +1,31 @@
import React, { Component } from "react";
import { Modal, Icon, Button, Header } from "semantic-ui-react";
class Message extends Component {
constructor(props) {
super(props);
}
_logout = event => {
event.preventDefault();
this.props.manualLogout();
};
render() {
return (
<Modal open={this.props.open} onClose={this.props.onClose} basic size="small">
<Header icon="info" content={this.props.title} />
<Modal.Content>
<p>{this.props.message}</p>
</Modal.Content>
<Modal.Actions>
<Button color='green' onClick={this.props.onClose} inverted>
<Icon name='checkmark' /> Got it
</Button>
</Modal.Actions>
</Modal>
);
}
}
export default Message;

View File

@@ -79,7 +79,8 @@ function makeUserRequest(method, data, api = "/login") {
return axios({
method: method,
url: api,
data: data
data: data,
config: {withCredentials: true}
});
}
@@ -96,7 +97,7 @@ export function updateGroup(data) {
return dispatch => {
dispatch(beginUpdateGroup());
return makeUserRequest("post", data, "/groups/" + data.shortName + "/" + data._id)
return makeUserRequest("post", data, process.env.REACT_APP_ADMIN_SERVER + "/groups/" + data.shortName + "/" + data._id)
.then(response => {
if (response.data.success) {
dispatch(updateGroupSuccess(response.data.group));
@@ -144,7 +145,7 @@ export function fetchGroups(shortName) {
if (shouldFetchGroups(getState(), shortName)) {
dispatch(beginFetchGroup());
return axios
.get("/groups/" + shortName)
.get(process.env.REACT_APP_ADMIN_SERVER + "/groups/" + shortName, {withCredentials: true})
.then(response => {
if (response.data.success) {
const data = { shortName: shortName, groups: response.data.groups };
@@ -175,7 +176,7 @@ export function saveGroupOrder(shortName, data) {
return makeUserRequest(
"post",
data,
"/groups/" + shortName + "/reorder"
process.env.REACT_APP_ADMIN_SERVER + "/groups/" + shortName + "/reorder"
)
.then(response => {
if (response.data.success) {
@@ -199,7 +200,7 @@ export function deleteGroup(shortName, groupId) {
return dispatch => {
dispatch(beginDeleteGroup());
return makeUserRequest("delete", null, "/groups/" + shortName + "/" + groupId)
return makeUserRequest("delete", null, process.env.REACT_APP_ADMIN_SERVER + "/groups/" + shortName + "/" + groupId)
.then(response => {
if (response.data.success) {
const data = {shortName: shortName, groupId: groupId}
@@ -224,7 +225,7 @@ export function createGroup(data) {
return dispatch => {
dispatch(beginCreateGroup());
return makeUserRequest("post", data, "/groups/" + data.shortName)
return makeUserRequest("post", data, process.env.REACT_APP_ADMIN_SERVER + "/groups/" + data.shortName)
.then(response => {
if (response.data.success) {
dispatch(createGroupSuccess(response.data.group));

View File

@@ -70,7 +70,7 @@ export function fetch(shortName) {
dispatch(beginFetchPermission());
return axios
.get("/permissions/"+shortName)
.get(process.env.REACT_APP_ADMIN_SERVER + "/permissions/"+shortName, {withCredentials: true})
.then(response => {
if (response.data.success) {
dispatch(fetchPermissionSuccess(response.data.permissions));
@@ -94,8 +94,8 @@ export function update(data) {
return (dispatch, getState) => {
dispatch(beginUpdateRole());
var url = "/permissions/" + data.shortName + "/" + data.permissionId;
return axios.post( url, data)
var url = process.env.REACT_APP_ADMIN_SERVER + "/permissions/" + data.shortName + "/" + data.permissionId;
return axios.post( url, data, {withCredentials: true})
.then(response => {
if (response.data.success) {
dispatch(updateRoleSuccess(response.data.permission));
@@ -118,8 +118,8 @@ export function update(data) {
export function addPermission(data) {
return (dispatch, getState) => {
dispatch(beginAddPermission());
var url = "/permissions/" + data.shortName;
return axios.post( url, data)
var url = process.env.REACT_APP_ADMIN_SERVER + "/permissions/" + data.shortName;
return axios.post( url, data, {withCredentials: true})
.then(response => {
if (response.data.success) {
dispatch(addPermissionSuccess(response.data.permission));
@@ -144,8 +144,8 @@ export function deletePermission(data) {
return (dispatch, getState) => {
dispatch(beginDeletePermission());
var url = "/permissions/" + data.shortName + "/" + data.permissionId;
return axios.delete( url)
var url = process.env.REACT_APP_ADMIN_SERVER + "/permissions/" + data.shortName + "/" + data.permissionId;
return axios.delete( url, {withCredentials: true})
.then(response => {
if (response.data.success) {
dispatch(deletePermissionSuccess(data.permissionId));

View File

@@ -1,10 +1,10 @@
import React, { Component } from "react";
import { Group } from '@vx/group';
import { curveStep} from '@vx/curve';
import { LinePath } from '@vx/shape';
import { scaleLinear, scaleBand, scaleTime } from '@vx/scale';
import { Group } from '@visx/group';
import { curveStep} from '@visx/curve';
import { LinePath } from '@visx/shape';
import { scaleLinear, scaleBand, scaleTime } from '@visx/scale';
import { timeParse, timeFormat } from 'd3-time-format';
import { AxisBottom, AxisLeft } from '@vx/axis';
import { AxisBottom, AxisLeft } from '@visx/axis';
import { Dimmer, Loader } from "semantic-ui-react";
@@ -29,6 +29,9 @@ constructor(props) {
const width = this.props.width;
const height = 500;
const margin = { top: 20, bottom: 40, left: 40, right: 20 };
const parseDate = timeParse("%Y%m%d");
const format = timeFormat("%b %d");
const formatDate = (date) => format(parseDate(date));
// Then we'll create some bounds
const xMax = width - margin.left - margin.right;

View File

@@ -1,18 +1,15 @@
import React, { Component } from "react";
import { Group } from '@vx/group';
import { GlyphCircle } from '@vx/glyph';
import { scaleLinear, scaleBand, scaleTime, scaleOrdinal } from '@vx/scale';
import { Group } from '@visx/group';
import { GlyphCircle } from '@visx/glyph';
import { scaleLinear, scaleTime, scaleOrdinal } from '@visx/scale';
import { timeParse, timeFormat } from 'd3-time-format';
import { AxisBottom, AxisLeft } from '@vx/axis';
import { Dimmer, Loader } from "semantic-ui-react";
import {
LegendOrdinal
} from '@vx/legend';
import { AxisBottom, AxisLeft } from '@visx/axis';
import { Loader } from "semantic-ui-react";
import { LegendOrdinal} from '@visx/legend';
class ErrorChart extends Component {
constructor(props) {
super(props);
}
constructor(props) {
super(props);
}
render() {
var errorData = this.props.data;
@@ -54,58 +51,58 @@ constructor(props) {
});
var xScale, yScale, xPoint, yPoint;
if (errorData) {
// We'll use some mock data from `@vx/mock-data` for this.
data = errorData.data;
// scales
xScale = scaleTime({
range: [0, xMax],
domain: [errorData.minDate, errorData.maxDate],
tickFormat: () => (val) => formatDate(val)
});
yScale = scaleLinear({
range: [yMax, 0],
domain: [0, errorData.maxValue],
});
zScale = scaleOrdinal({
domain: errorData.legend,
range: ["#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00", "#b82e2e", "#316395", "#994499", "#22aa99", "#aaaa11", "#6633cc", "#e67300", "#8b0707", "#651067", "#329262", "#5574a6", "#3b3eac"]
});
xPoint = compose(xScale, x);
yPoint = compose(yScale, y);
// We'll use some mock data from `@vx/mock-data` for this.
data = errorData.data;
// scales
xScale = scaleTime({
range: [0, xMax],
domain: [errorData.minDate, errorData.maxDate],
tickFormat: () => (val) => formatDate(val)
});
yScale = scaleLinear({
range: [yMax, 0],
domain: [0, errorData.maxValue],
});
zScale = scaleOrdinal({
domain: errorData.legend,
range: ["#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00", "#b82e2e", "#316395", "#994499", "#22aa99", "#aaaa11", "#6633cc", "#e67300", "#8b0707", "#651067", "#329262", "#5574a6", "#3b3eac"]
});
xPoint = compose(xScale, x);
yPoint = compose(yScale, y);
}
return (
<div style={{
width: 900
}}>
<svg width={width} height={height} style={{
float: "left"
}}>
<Group left={margin.left} top={margin.top} >
<AxisBottom top={yMax} scale={xScale} numTicks={width > 520 ? 10 : 5} />
<AxisLeft scale={yScale} />
{data.map((band, i) => {
return (
<Group key={`band-${i}`}>
{band.data.map((point, j) => {
return (
<GlyphCircle
className="dot"
key={`point-${point.x}-${j}`}
fill={dotColor(i)}
left={xScale(x(point))}
top={yScale(y(point))}
size={6.0}
/>
);
})}
</Group>
);
})}
</Group>
</svg>
<div
return (
<div style={{
width: 900
}}>
<svg width={width} height={height} style={{
float: "left"
}}>
<Group left={margin.left} top={margin.top} >
<AxisBottom top={yMax} scale={xScale} numTicks={width > 520 ? 10 : 5} />
<AxisLeft scale={yScale} />
{data.map((band, i) => {
return (
<Group key={`band-${i}`}>
{band.data.map((point, j) => {
return (
<GlyphCircle
className="dot"
key={`point-${point.x}-${j}`}
fill={dotColor(i)}
left={xScale(x(point))}
top={yScale(y(point))}
size={6.0}
/>
);
})}
</Group>
);
})}
</Group>
</svg>
<div
style={{
float: "right"
}}
@@ -114,19 +111,19 @@ return (
scale={zScale}
labelMargin="0 15px 0 0"
onMouseOver={data => event => {
console.log(
`mouse over: ${data.text}`,
`index: ${data.index}`,
);
}}
console.log(
`mouse over: ${data.text}`,
`index: ${data.index}`,
);
}}
/>
</div>
</div>
</div>
);
}
);
}
}

View File

@@ -1,6 +1,6 @@
import React, { Component } from "react"
import CallChart from "./CallChart"
import { ParentSize } from "@vx/responsive";
import { ParentSize } from "@visx/responsive";
class ResponsiveCallChart extends Component {
constructor(props) {

View File

@@ -1,6 +1,6 @@
import React, { Component } from "react"
import ErrorChart from "./ErrorChart"
import { ParentSize } from "@vx/responsive";
import { ParentSize } from "@visx/responsive";
class ResponsiveErrorChart extends Component {
constructor(props) {

View File

@@ -1,7 +1,7 @@
import React, {Component} from "react";
import {Link} from "react-router-dom";
import ListTalkgroups from "../Talkgroups/ListTalkgroups.js";
import MessageBox from "../components/pure/Message.js";
import MessageBox from "../Components/Message.js";
import ListGroups from "../Group/ListGroups.js";
import GroupModal from "../Group/GroupModalContainer.js";
import UpdatePermissionModal from "../Permission/UpdatePermissionModalContainer.js";
@@ -24,14 +24,6 @@ import {
Label
} from "semantic-ui-react";
function planName(planType) {
switch (planType) {
case freePlanValue:
return "Free";
case proPlanValue:
return "Pro";
}
}
class System extends Component {
constructor(props) {
@@ -55,7 +47,6 @@ class System extends Component {
);
this.handleSystemDeleteConfirm = this.handleSystemDeleteConfirm.bind(this);
this.handleSystemDeleteCancel = this.handleSystemDeleteCancel.bind(this);
this.handleUpgradePlan = this.handleUpgradePlan.bind(this);
this.handleUpdatePermissionClose = this.handleUpdatePermissionClose.bind(
this
);
@@ -259,9 +250,6 @@ class System extends Component {
});
}
handleUpgradePlan() {
window.location = process.env.REACT_APP_ACCOUNT_SERVER + "/update-plans";
}
handleUpload(file) {
this.props.talkgroupActions
@@ -319,7 +307,6 @@ class System extends Component {
let fileInput = null;
var location = "";
var example = "";
var plan = "";
var groupRender = () => {};
if (system) {
@@ -348,25 +335,6 @@ class System extends Component {
);
}
switch (system.planType) {
case freePlanValue:
const tempPlan = planName(system.planType) + " plan";
plan = (
<div>
{tempPlan}
<Label as="a" onClick={this.handleUpgradePlan}>
{" "}
<Icon name="plus" />
Upgrade Plan
</Label>
</div>
);
break;
case proPlanValue:
plan = planName(system.planType) + " plan";
break;
}
example =
'{\n\t"systems": [\n\t\t{\n\t\t\t"shortName": "' +
@@ -655,7 +623,6 @@ class System extends Component {
<Header as="h1">
<Header.Content>
{this.props.system.name}
{/* <Header.Subheader>{plan}</Header.Subheader> */}
</Header.Content>
</Header>

View File

@@ -103,7 +103,7 @@ export function updateSystem(data) {
return dispatch => {
dispatch(beginUpdateSystem());
return makeUserRequest("post", data, process.env.REACT_APP_BACKEND_SERVER + "/systems/" + data.shortName)
return makeUserRequest("post", data, process.env.REACT_APP_ADMIN_SERVER + "/systems/" + data.shortName, {withCredentials: true})
.then(response => {
if (response.data.success) {
dispatch(updateSystemSuccess(response.data.system));
@@ -162,7 +162,7 @@ export function fetchSystems() {
dispatch(beginFetchSystem());
return axios
.get(process.env.REACT_APP_ADMIN_SERVER + "/systems")
.get(process.env.REACT_APP_ADMIN_SERVER + "/systems", {withCredentials: true})
.then(response => {
if (response.data.success) {
dispatch(fetchSystemSuccess(response.data.systems));
@@ -187,7 +187,7 @@ export function deleteSystem(shortName) {
return dispatch => {
dispatch(beginDeleteSystem());
return makeUserRequest("delete", null, process.env.REACT_APP_BACKEND_SERVER + "/systems/"+shortName)
return makeUserRequest("delete", null, process.env.REACT_APP_ADMIN_SERVER + "/systems/"+shortName, {withCredentials: true})
.then(response => {
if (response.data.success) {
dispatch(deleteSystemSuccess({shortName: shortName}));
@@ -211,7 +211,7 @@ export function createSystem(data) {
return dispatch => {
dispatch(beginCreateSystem());
return makeUserRequest("post", data, process.env.REACT_APP_BACKEND_SERVER + "/systems")
return makeUserRequest("post", data, process.env.REACT_APP_ADMIN_SERVER + "/systems", {withCredentials: true})
.then(response => {
if (response.data.success) {
dispatch(createSystemSuccess(response.data.system));

View File

@@ -49,16 +49,6 @@ function fetchTalkgroupError(data) {
data };
}
function makeUserRequest(method, data, api) {
// returns a Promise
return axios({
method: method,
url: api,
data: data
});
}
export function changeUrl(url) {
return dispatch => {
dispatch(push(url));
@@ -68,13 +58,14 @@ export function changeUrl(url) {
// https://stackoverflow.com/questions/41878838/how-do-i-set-multipart-in-axios-with-react
function fileUpload(shortName, file){
const url = "/talkgroups/" + shortName + "/import";
const url = process.env.REACT_APP_ADMIN_SERVER + "/talkgroups/" + shortName + "/import";
const formData = new FormData();
formData.append('file',file)
const config = {
headers: {
'content-type': 'multipart/form-data'
}
},
withCredentials: true
}
return post(url, formData,config)
}
@@ -121,7 +112,7 @@ export function exportTalkgroups(
dispatch(beginExportTalkgroup());
return axios
.get("/talkgroups/" + shortName + "/export")
.get(process.env.REACT_APP_ADMIN_SERVER + "/talkgroups/" + shortName + "/export", { withCredentials: true })
.then(response => {
if (response.data.success) {
var data = {shortName: shortName, talkgroups: response.data.talkgroups}
@@ -159,7 +150,7 @@ export function fetchTalkgroups(shortName) {
dispatch(beginFetchTalkgroup());
return axios
.get("/talkgroups/"+shortName)
.get(process.env.REACT_APP_ADMIN_SERVER + "/talkgroups/"+shortName, { withCredentials: true })
.then(response => {
if (response.data.success) {
var data = {shortName: shortName, talkgroups: response.data.talkgroups}

View File

@@ -9,6 +9,7 @@ import App from "./App/App"
import Restricted from "./App/Restricted"
import About from "./Components/About"
import SystemContainer from "./System/SystemContainer"
import ListSystemsContainer from "./System/ListSystemsContainer"
import UpdateSystemContainer from "./System/UpdateSystemContainer"
import CreateSystemContainer from "./System/CreateSystemContainer"
@@ -22,10 +23,12 @@ ReactDOM.render(
<>
<App>
<Switch>
<Route path="/about" component={About} />
<Route path="/update-system/:shortName" component={UpdateSystemContainer} />
<Route path="/create-system" component={CreateSystemContainer} />
<Route path="/list-systems" component={ListSystemsContainer} />
<Route path="/about" component={Restricted(About, store)} />
<Route path="/system/:shortName" component={Restricted(SystemContainer, store)} />
<Route path="/update-system/:shortName" component={Restricted(UpdateSystemContainer, store)} />
<Route path="/create-system" component={Restricted(CreateSystemContainer, store)} />
<Route path="/list-systems" component={Restricted(ListSystemsContainer,store)} />
<Route path="/" component={Restricted(ListSystemsContainer, store)} />
<Route render={() => (<div>Miss</div>)} />
</Switch>
</App>

View File

@@ -6,12 +6,14 @@ import systemReducer from "../System/system-reducer"
import talkgroupReducer from "../Talkgroups/talkgroup-reducer"
import groupReducer from "../Group/group-reducer"
import errorReducer from "../System/error-reducer"
import statisticReducer from "../System/statistic-reducer"
import permissionReducer from "../Permission/permission-reducer"
import userReducer from "../User/user-reducer"
const createRootReducer = (history) => combineReducers({
router: connectRouter(history),
system: systemReducer,
statistic: statisticReducer,
talkgroup: talkgroupReducer,
group: groupReducer,
user: userReducer,