closer to running

This commit is contained in:
Luke Berndt
2021-01-14 22:22:46 -05:00
parent 86eb854848
commit e20529b7f5
19 changed files with 51 additions and 141 deletions

View File

@@ -36,17 +36,9 @@ const isDev = process.env.NODE_ENV === "development"
var backend_server = process.env['BACKEND_SERVER'] != null ? process.env['BACKEND_SERVER'] : 'https://api.openmhz.com';
var frontend_server = process.env['FRONTEND_SERVER'] != null ? process.env['FRONTEND_SERVER'] : 'https://openmhz.com';
var media_server = process.env['MEDIA_SERVER'] != null ? process.env['MEDIA_SERVER'] : 'https://media.openmhz.com'; //'https://s3.amazonaws.com/robotastic';
var socket_server = process.env['SOCKET_SERVER'] != null ? process.env['SOCKET_SERVER'] : 'wss://api.openmhz.com'; //'https://s3.amazonaws.com/robotastic';
var admin_server = process.env['ADMIN_SERVER'] != null ? process.env['ADMIN_SERVER'] : 'https://admin.openmhz.com'; //'https://s3.amazonaws.com/robotastic';
var account_server = process.env['ACCOUNT_SERVER'] != null ? process.env['ACCOUNT_SERVER'] : 'https://account.openmhz.com'; //'https://s3.amazonaws.com/robotastic';
var site_name = process.env['SITE_NAME'] != null ? process.env['SITE_NAME'] : "OpenMHz";
const proPlanValue = process.env['PRO_PLAN'] != null ? process.env['PRO_PLAN'] : 10;
const freePlanValue = process.env['FREE_PLAN'] != null ? process.env['FREE_PLAN'] : 0;
const proPlanPrice = process.env['PRO_PLAN_PRICE'] != null ? process.env['PRO_PLAN_PRICE'] : 15;
const freePlanPrice = process.env['FREE_PLAN_PRICE'] != null ? process.env['FREE_PLAN_PRICE'] : 0;
var frontend_server = process.env['REACT_APP_FRONTEND_SERVER'] != null ? process.env['REACT_APP_FRONTEND_SERVER'] : 'https://openmhz.com';
var account_server = process.env['REACT_APP_ACCOUNT_SERVER'] != null ? process.env['REACT_APP_ACCOUNT_SERVER'] : 'https://account.openmhz.com'; //'https://s3.amazonaws.com/robotastic';
var admin_server = process.env['REACT_APP_ADMIN_SERVER'] != null ? process.env['REACT_APP_ADMIN_SERVER'] : 'https://admin.openmhz.com'; //'https://s3.amazonaws.com/robotastic';
// -------------------------------------------

File diff suppressed because one or more lines are too long

17
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
# build environment
FROM node:13.12.0-alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
RUN npm install
RUN npm install react-scripts@3.4.1 -g --silent
COPY . ./
RUN npm run build
# production environment
FROM node:13.12.0-alpine
RUN mkdir -p /app/public
WORKDIR /app
RUN npm install -g serve
COPY --from=build /app/build /app/public
CMD serve -s public -l 3000

View File

@@ -2,8 +2,7 @@ import React, { Component } from "react";
import {
Modal,
Button,
Icon,
Header
Icon
} from "semantic-ui-react";
import "./CalendarModal.css";
import DatePicker from 'react-datepicker';

View File

@@ -12,10 +12,6 @@ import {
class CallInfo extends React.Component {
constructor(props) {
super(props);
}
render() {
var srcList = "";
var callLength = "-";

View File

@@ -71,7 +71,6 @@ showStar() {
render() {
const call = this.props.call;
const time = new Date(call.time);
const current = new Date(time).setHours(0, 0, 0, 0);
var rowSelected={};
let starButton;
var starClickable = {};

View File

@@ -1,6 +1,5 @@
import React from "react";
import {Link} from 'react-router-dom';
import CallItem from "./CallItem";
import MediaPlayer from "./MediaPlayer";
import FilterModal from "./FilterModalContainer";
import GroupModal from "./GroupModalContainer";
@@ -15,7 +14,6 @@ import {
Sticky,
Menu,
Icon,
Table,
Sidebar
} from "semantic-ui-react";
import {Waypoint} from 'react-waypoint';
@@ -51,6 +49,7 @@ class CallPlayer extends React.Component {
this.handleLiveToggle = this.handleLiveToggle.bind(this);
this.getFilter = this.getFilter.bind(this);
this.callList = React.createRef();
this.socket = window.socket;
this.setupSocket = this.setupSocket.bind(this);
this.endSocket = this.endSocket.bind(this);
this.changeUrl = this.changeUrl.bind(this);
@@ -125,6 +124,7 @@ class CallPlayer extends React.Component {
filter.type = "group";
filter.code = this.props.filterGroupId;
break;
default:
case 2:
filter.type = "talkgroup";
filter.code = this.props.filterTalkgroups;
@@ -134,12 +134,12 @@ class CallPlayer extends React.Component {
return filter;
}
endSocket() {
socket.removeAllListeners("new message");
socket.removeAllListeners("reconnect");
this.socket.removeAllListeners("new message");
this.socket.removeAllListeners("reconnect");
}
setupSocket() {
socket.on('new message', this.addCall);
socket.on('reconnect', (attempts) => {
this.socket.on('new message', this.addCall);
this.socket.on('reconnect', (attempts) => {
console.log("Socket Reconnected after attempts: " + attempts); // true
if (this.props.live) {
var filter = this.getFilter();
@@ -148,7 +148,7 @@ class CallPlayer extends React.Component {
})
}
startSocket(shortName, filterType="", filterCode="", filterStarred=false) {
socket.emit("start", {
this.socket.emit("start", {
filterCode: filterCode,
filterType: filterType,
filterName: "OpenMHz",
@@ -157,7 +157,7 @@ class CallPlayer extends React.Component {
});
}
stopSocket(){
socket.emit("stop");
this.socket.emit("stop");
}
handleLiveToggle() {
if (!this.props.live) {
@@ -179,19 +179,20 @@ class CallPlayer extends React.Component {
case 1:
search = search + `filter-type=group&filter-code=${props.filterGroupId}`;
break;
default:
case 2:
search = search + `filter-type=talkgroup&filter-code=${props.filterTalkgroups}`;
break;
}
if (props.filterDate) {
if (search.length!=1) {
if (search.length!==1) {
search = search + '&';
}
search = search + `time=${props.filterDate}`;
}
if (props.filterStarred) {
if (search.length!=1) {
if (search.length!==1) {
search = search + '&';
}
search = search + `starred=true`;
@@ -304,7 +305,7 @@ class CallPlayer extends React.Component {
// is there a star filter?
if (uri.hasOwnProperty('starred')) {
const starred = uri['starred'];
filter.filterStarred = starred == 'true'? true : false;
filter.filterStarred = starred === 'true'? true : false;
this.setState({urlOptions: true});
}
@@ -338,7 +339,7 @@ class CallPlayer extends React.Component {
this.setState({urlOptions: true});
// The Filter is a group
if (uri['filter-type'] == "group") {
if (uri['filter-type'] === "group") {
filter.filterType = 1;
filter.filterGroupId = uri["filter-code"];
filterType="group";
@@ -346,7 +347,7 @@ class CallPlayer extends React.Component {
}
// The Filter is talkgroups
if (uri['filter-type'] == 'talkgroup') {
if (uri['filter-type'] === 'talkgroup') {
const tg = uri["filter-code"].split(',').map(Number);
filter.filterType=2;
filter.filterTalkgroups=tg;
@@ -395,6 +396,7 @@ class CallPlayer extends React.Component {
typeString = 'group';
filterCode = nextProps.filterGroupId;
break;
default:
case 2:
typeString = 'talkgroup';
filterCode = nextProps.filterTalkgroups;
@@ -445,7 +447,6 @@ class CallPlayer extends React.Component {
}
var callInfoHeader = "Call Info";
const {sidebarVisible} = this.state
const currentCall = this.props.callsById[this.state.callId];
@@ -466,6 +467,7 @@ class CallPlayer extends React.Component {
case 1:
filterLabel = "Group"
break;
default:
case 2:
filterLabel = "Talkgroups"
break;

View File

@@ -37,10 +37,7 @@ toggleStarred = () => this.setState(prevState => ({ filterStarred: !prevState.fi
handleClose = () => this.props.onClose(false);
handleDone(event) {
switch(this.state.activeTab) {
case 0:
this.props.callActions.setAllFilter();
this.props.onClose(true);
break;
case 1:
if (this.state.selectedGroup) {
this.props.callActions.setGroupFilter(this.state.selectedGroup);
@@ -57,8 +54,13 @@ handleDone(event) {
this.props.onClose(false);
}
break;
default:
case 0:
this.props.callActions.setAllFilter();
this.props.onClose(true);
break;
}
if (this.state.filterStarred != this.props.filterStarred) {
if (this.state.filterStarred !== this.props.filterStarred) {
this.props.callActions.setStarred(this.state.filterStarred);
this.props.onClose(true);
}
@@ -73,12 +75,12 @@ componentWillUpdate(nextProps) {
}
render() {
var obj;
var talkgroupList = [];
if (this.props.talkgroups) {
for (const num in this.props.talkgroups) {
const talkgroup = this.props.talkgroups[num];
var obj = {
obj = {
key: talkgroup.num,
value: talkgroup.num,
text: talkgroup.description
@@ -90,7 +92,7 @@ componentWillUpdate(nextProps) {
if (this.props.groups) {
for (const num in this.props.groups) {
const group = this.props.groups[num];
var obj = {
obj = {
key: group._id,
value: group._id,
text: group.groupName

View File

@@ -9,10 +9,6 @@ import "./CallPlayer.css";
// ----------------------------------------------------
class ListCalls extends React.Component {
constructor(props) {
super(props);
}
//https://stackoverflow.com/questions/36559661/how-can-i-dispatch-from-child-components-in-react-redux
//https://stackoverflow.com/questions/42597602/react-onclick-pass-event-with-parameter
@@ -30,7 +26,7 @@ class ListCalls extends React.Component {
</Table.Header>
<Table.Body>
{this.props.callsAllIds.map((callId, index) => <CallItem activeCall={callId == this.props.activeCallId ? true : false} call={this.props.callsById[callId]} talkgroups={this.props.talkgroups} key={index} onClick={this.props.playCall}/>)}
{this.props.callsAllIds.map((callId, index) => <CallItem activeCall={callId === this.props.activeCallId ? true : false} call={this.props.callsById[callId]} talkgroups={this.props.talkgroups} key={index} onClick={this.props.playCall}/>)}
</Table.Body>
</Table>

View File

@@ -66,7 +66,7 @@ class MediaPlayer extends React.Component {
}
componentWillUpdate(nextProps) {
if (nextProps.call && (nextProps.call != this.props.call)) {
if (nextProps.call && (nextProps.call !== this.props.call)) {
this.setState({
sourceIndex: 0
});

View File

@@ -2,8 +2,7 @@ import React, { Component } from "react";
import {
Modal,
Button,
Icon,
Dropdown
Icon
} from "semantic-ui-react";
import "./FilterModal.css";

View File

@@ -4,26 +4,6 @@ import {
FETCH_ERROR_GROUP
} from "./group-constants";
function updateObject(oldObject, newValues) {
// Encapsulate the idea of passing a new object as the first parameter
// to Object.assign to ensure we correctly copy data instead of mutating
return Object.assign({}, oldObject, newValues);
}
function updateItemInArray(array, itemId, updateItemCallback) {
const updatedItems = array.map(item => {
if(item.id !== itemId) {
// Since we only want to update one item, preserve all others as they are now
return item;
}
// Use the provided callback to create an updated item
const updatedItem = updateItemCallback(item);
return updatedItem;
});
return updatedItems;
}
const group = (
state = {

View File

@@ -3,7 +3,6 @@ import axios from "axios";
import * as types from "./system-constants";
import { push } from 'connected-react-router';
const FETCH_SUCCESS_STATISTIC = "FETCH_SUCCESS_STATISTIC"
function beginFetchSystem() {
return { type: types.FETCH_SYSTEM };
@@ -19,16 +18,6 @@ function fetchSystemError(data) {
data };
}
function makeUserRequest(method, data, api = "/login") {
// returns a Promise
return axios({
method: method,
url: api,
data: data
});
}
export function changeUrl(url) {
return dispatch => {
dispatch(push(url));

View File

@@ -1,39 +1,9 @@
import {
CREATE_SYSTEM,
CREATE_SUCCESS_SYSTEM,
CREATE_ERROR_SYSTEM,
UPDATE_SYSTEM,
UPDATE_SUCCESS_SYSTEM,
UPDATE_ERROR_SYSTEM,
DELETE_SYSTEM,
DELETE_SUCCESS_SYSTEM,
DELETE_ERROR_SYSTEM,
FETCH_SYSTEM,
FETCH_SUCCESS_SYSTEM,
FETCH_ERROR_SYSTEM
} from "./system-constants";
function updateObject(oldObject, newValues) {
// Encapsulate the idea of passing a new object as the first parameter
// to Object.assign to ensure we correctly copy data instead of mutating
return Object.assign({}, oldObject, newValues);
}
function updateObjectInArray(array, shortName, updatedItem) {
return array.map( item => {
if(item.shortName !== shortName) {
// This isn't the item we care about - keep it as-is
return item;
}
// Otherwise, this is the one we want - return an updated value
return {
...item,
...updatedItem
};
});
}
const system = (
state = {

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));

View File

@@ -10,27 +10,6 @@ import {
FETCH_ERROR_TALKGROUP
} from "./talkgroup-constants";
function updateObject(oldObject, newValues) {
// Encapsulate the idea of passing a new object as the first parameter
// to Object.assign to ensure we correctly copy data instead of mutating
return Object.assign({}, oldObject, newValues);
}
function updateItemInArray(array, itemId, updateItemCallback) {
const updatedItems = array.map(item => {
if(item.id !== itemId) {
// Since we only want to update one item, preserve all others as they are now
return item;
}
// Use the provided callback to create an updated item
const updatedItem = updateItemCallback(item);
return updatedItem;
});
return updatedItems;
}
const talkgroup = (
state = {
isWaiting: false,