mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-15 02:07:50 -05:00
closer to running
This commit is contained in:
@@ -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['REACT_APP_FRONTEND_SERVER'] != null ? process.env['REACT_APP_FRONTEND_SERVER'] : 'https://openmhz.com';
|
||||||
var frontend_server = process.env['FRONTEND_SERVER'] != null ? process.env['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 media_server = process.env['MEDIA_SERVER'] != null ? process.env['MEDIA_SERVER'] : 'https://media.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';
|
||||||
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;
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
17
frontend/Dockerfile
Normal file
17
frontend/Dockerfile
Normal 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
|
||||||
@@ -2,8 +2,7 @@ import React, { Component } from "react";
|
|||||||
import {
|
import {
|
||||||
Modal,
|
Modal,
|
||||||
Button,
|
Button,
|
||||||
Icon,
|
Icon
|
||||||
Header
|
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
import "./CalendarModal.css";
|
import "./CalendarModal.css";
|
||||||
import DatePicker from 'react-datepicker';
|
import DatePicker from 'react-datepicker';
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ import {
|
|||||||
class CallInfo extends React.Component {
|
class CallInfo extends React.Component {
|
||||||
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
var srcList = "";
|
var srcList = "";
|
||||||
var callLength = "-";
|
var callLength = "-";
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ showStar() {
|
|||||||
render() {
|
render() {
|
||||||
const call = this.props.call;
|
const call = this.props.call;
|
||||||
const time = new Date(call.time);
|
const time = new Date(call.time);
|
||||||
const current = new Date(time).setHours(0, 0, 0, 0);
|
|
||||||
var rowSelected={};
|
var rowSelected={};
|
||||||
let starButton;
|
let starButton;
|
||||||
var starClickable = {};
|
var starClickable = {};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import {Link} from 'react-router-dom';
|
import {Link} from 'react-router-dom';
|
||||||
import CallItem from "./CallItem";
|
|
||||||
import MediaPlayer from "./MediaPlayer";
|
import MediaPlayer from "./MediaPlayer";
|
||||||
import FilterModal from "./FilterModalContainer";
|
import FilterModal from "./FilterModalContainer";
|
||||||
import GroupModal from "./GroupModalContainer";
|
import GroupModal from "./GroupModalContainer";
|
||||||
@@ -15,7 +14,6 @@ import {
|
|||||||
Sticky,
|
Sticky,
|
||||||
Menu,
|
Menu,
|
||||||
Icon,
|
Icon,
|
||||||
Table,
|
|
||||||
Sidebar
|
Sidebar
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
import {Waypoint} from 'react-waypoint';
|
import {Waypoint} from 'react-waypoint';
|
||||||
@@ -51,6 +49,7 @@ class CallPlayer extends React.Component {
|
|||||||
this.handleLiveToggle = this.handleLiveToggle.bind(this);
|
this.handleLiveToggle = this.handleLiveToggle.bind(this);
|
||||||
this.getFilter = this.getFilter.bind(this);
|
this.getFilter = this.getFilter.bind(this);
|
||||||
this.callList = React.createRef();
|
this.callList = React.createRef();
|
||||||
|
this.socket = window.socket;
|
||||||
this.setupSocket = this.setupSocket.bind(this);
|
this.setupSocket = this.setupSocket.bind(this);
|
||||||
this.endSocket = this.endSocket.bind(this);
|
this.endSocket = this.endSocket.bind(this);
|
||||||
this.changeUrl = this.changeUrl.bind(this);
|
this.changeUrl = this.changeUrl.bind(this);
|
||||||
@@ -125,6 +124,7 @@ class CallPlayer extends React.Component {
|
|||||||
filter.type = "group";
|
filter.type = "group";
|
||||||
filter.code = this.props.filterGroupId;
|
filter.code = this.props.filterGroupId;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
case 2:
|
case 2:
|
||||||
filter.type = "talkgroup";
|
filter.type = "talkgroup";
|
||||||
filter.code = this.props.filterTalkgroups;
|
filter.code = this.props.filterTalkgroups;
|
||||||
@@ -134,12 +134,12 @@ class CallPlayer extends React.Component {
|
|||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
endSocket() {
|
endSocket() {
|
||||||
socket.removeAllListeners("new message");
|
this.socket.removeAllListeners("new message");
|
||||||
socket.removeAllListeners("reconnect");
|
this.socket.removeAllListeners("reconnect");
|
||||||
}
|
}
|
||||||
setupSocket() {
|
setupSocket() {
|
||||||
socket.on('new message', this.addCall);
|
this.socket.on('new message', this.addCall);
|
||||||
socket.on('reconnect', (attempts) => {
|
this.socket.on('reconnect', (attempts) => {
|
||||||
console.log("Socket Reconnected after attempts: " + attempts); // true
|
console.log("Socket Reconnected after attempts: " + attempts); // true
|
||||||
if (this.props.live) {
|
if (this.props.live) {
|
||||||
var filter = this.getFilter();
|
var filter = this.getFilter();
|
||||||
@@ -148,7 +148,7 @@ class CallPlayer extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
startSocket(shortName, filterType="", filterCode="", filterStarred=false) {
|
startSocket(shortName, filterType="", filterCode="", filterStarred=false) {
|
||||||
socket.emit("start", {
|
this.socket.emit("start", {
|
||||||
filterCode: filterCode,
|
filterCode: filterCode,
|
||||||
filterType: filterType,
|
filterType: filterType,
|
||||||
filterName: "OpenMHz",
|
filterName: "OpenMHz",
|
||||||
@@ -157,7 +157,7 @@ class CallPlayer extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
stopSocket(){
|
stopSocket(){
|
||||||
socket.emit("stop");
|
this.socket.emit("stop");
|
||||||
}
|
}
|
||||||
handleLiveToggle() {
|
handleLiveToggle() {
|
||||||
if (!this.props.live) {
|
if (!this.props.live) {
|
||||||
@@ -179,19 +179,20 @@ class CallPlayer extends React.Component {
|
|||||||
case 1:
|
case 1:
|
||||||
search = search + `filter-type=group&filter-code=${props.filterGroupId}`;
|
search = search + `filter-type=group&filter-code=${props.filterGroupId}`;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
case 2:
|
case 2:
|
||||||
search = search + `filter-type=talkgroup&filter-code=${props.filterTalkgroups}`;
|
search = search + `filter-type=talkgroup&filter-code=${props.filterTalkgroups}`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (props.filterDate) {
|
if (props.filterDate) {
|
||||||
if (search.length!=1) {
|
if (search.length!==1) {
|
||||||
search = search + '&';
|
search = search + '&';
|
||||||
}
|
}
|
||||||
search = search + `time=${props.filterDate}`;
|
search = search + `time=${props.filterDate}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.filterStarred) {
|
if (props.filterStarred) {
|
||||||
if (search.length!=1) {
|
if (search.length!==1) {
|
||||||
search = search + '&';
|
search = search + '&';
|
||||||
}
|
}
|
||||||
search = search + `starred=true`;
|
search = search + `starred=true`;
|
||||||
@@ -304,7 +305,7 @@ class CallPlayer extends React.Component {
|
|||||||
// is there a star filter?
|
// is there a star filter?
|
||||||
if (uri.hasOwnProperty('starred')) {
|
if (uri.hasOwnProperty('starred')) {
|
||||||
const starred = uri['starred'];
|
const starred = uri['starred'];
|
||||||
filter.filterStarred = starred == 'true'? true : false;
|
filter.filterStarred = starred === 'true'? true : false;
|
||||||
this.setState({urlOptions: true});
|
this.setState({urlOptions: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +339,7 @@ class CallPlayer extends React.Component {
|
|||||||
this.setState({urlOptions: true});
|
this.setState({urlOptions: true});
|
||||||
|
|
||||||
// The Filter is a group
|
// The Filter is a group
|
||||||
if (uri['filter-type'] == "group") {
|
if (uri['filter-type'] === "group") {
|
||||||
filter.filterType = 1;
|
filter.filterType = 1;
|
||||||
filter.filterGroupId = uri["filter-code"];
|
filter.filterGroupId = uri["filter-code"];
|
||||||
filterType="group";
|
filterType="group";
|
||||||
@@ -346,7 +347,7 @@ class CallPlayer extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The Filter is talkgroups
|
// The Filter is talkgroups
|
||||||
if (uri['filter-type'] == 'talkgroup') {
|
if (uri['filter-type'] === 'talkgroup') {
|
||||||
const tg = uri["filter-code"].split(',').map(Number);
|
const tg = uri["filter-code"].split(',').map(Number);
|
||||||
filter.filterType=2;
|
filter.filterType=2;
|
||||||
filter.filterTalkgroups=tg;
|
filter.filterTalkgroups=tg;
|
||||||
@@ -395,6 +396,7 @@ class CallPlayer extends React.Component {
|
|||||||
typeString = 'group';
|
typeString = 'group';
|
||||||
filterCode = nextProps.filterGroupId;
|
filterCode = nextProps.filterGroupId;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
case 2:
|
case 2:
|
||||||
typeString = 'talkgroup';
|
typeString = 'talkgroup';
|
||||||
filterCode = nextProps.filterTalkgroups;
|
filterCode = nextProps.filterTalkgroups;
|
||||||
@@ -445,7 +447,6 @@ class CallPlayer extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var callInfoHeader = "Call Info";
|
var callInfoHeader = "Call Info";
|
||||||
const {sidebarVisible} = this.state
|
|
||||||
|
|
||||||
const currentCall = this.props.callsById[this.state.callId];
|
const currentCall = this.props.callsById[this.state.callId];
|
||||||
|
|
||||||
@@ -466,6 +467,7 @@ class CallPlayer extends React.Component {
|
|||||||
case 1:
|
case 1:
|
||||||
filterLabel = "Group"
|
filterLabel = "Group"
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
case 2:
|
case 2:
|
||||||
filterLabel = "Talkgroups"
|
filterLabel = "Talkgroups"
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -37,10 +37,7 @@ toggleStarred = () => this.setState(prevState => ({ filterStarred: !prevState.fi
|
|||||||
handleClose = () => this.props.onClose(false);
|
handleClose = () => this.props.onClose(false);
|
||||||
handleDone(event) {
|
handleDone(event) {
|
||||||
switch(this.state.activeTab) {
|
switch(this.state.activeTab) {
|
||||||
case 0:
|
|
||||||
this.props.callActions.setAllFilter();
|
|
||||||
this.props.onClose(true);
|
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
if (this.state.selectedGroup) {
|
if (this.state.selectedGroup) {
|
||||||
this.props.callActions.setGroupFilter(this.state.selectedGroup);
|
this.props.callActions.setGroupFilter(this.state.selectedGroup);
|
||||||
@@ -57,8 +54,13 @@ handleDone(event) {
|
|||||||
this.props.onClose(false);
|
this.props.onClose(false);
|
||||||
}
|
}
|
||||||
break;
|
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.callActions.setStarred(this.state.filterStarred);
|
||||||
this.props.onClose(true);
|
this.props.onClose(true);
|
||||||
}
|
}
|
||||||
@@ -73,12 +75,12 @@ componentWillUpdate(nextProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
var obj;
|
||||||
var talkgroupList = [];
|
var talkgroupList = [];
|
||||||
if (this.props.talkgroups) {
|
if (this.props.talkgroups) {
|
||||||
for (const num in this.props.talkgroups) {
|
for (const num in this.props.talkgroups) {
|
||||||
const talkgroup = this.props.talkgroups[num];
|
const talkgroup = this.props.talkgroups[num];
|
||||||
var obj = {
|
obj = {
|
||||||
key: talkgroup.num,
|
key: talkgroup.num,
|
||||||
value: talkgroup.num,
|
value: talkgroup.num,
|
||||||
text: talkgroup.description
|
text: talkgroup.description
|
||||||
@@ -90,7 +92,7 @@ componentWillUpdate(nextProps) {
|
|||||||
if (this.props.groups) {
|
if (this.props.groups) {
|
||||||
for (const num in this.props.groups) {
|
for (const num in this.props.groups) {
|
||||||
const group = this.props.groups[num];
|
const group = this.props.groups[num];
|
||||||
var obj = {
|
obj = {
|
||||||
key: group._id,
|
key: group._id,
|
||||||
value: group._id,
|
value: group._id,
|
||||||
text: group.groupName
|
text: group.groupName
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ import "./CallPlayer.css";
|
|||||||
// ----------------------------------------------------
|
// ----------------------------------------------------
|
||||||
class ListCalls extends React.Component {
|
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/36559661/how-can-i-dispatch-from-child-components-in-react-redux
|
||||||
//https://stackoverflow.com/questions/42597602/react-onclick-pass-event-with-parameter
|
//https://stackoverflow.com/questions/42597602/react-onclick-pass-event-with-parameter
|
||||||
@@ -30,7 +26,7 @@ class ListCalls extends React.Component {
|
|||||||
</Table.Header>
|
</Table.Header>
|
||||||
<Table.Body>
|
<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.Body>
|
||||||
</Table>
|
</Table>
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class MediaPlayer extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillUpdate(nextProps) {
|
componentWillUpdate(nextProps) {
|
||||||
if (nextProps.call && (nextProps.call != this.props.call)) {
|
if (nextProps.call && (nextProps.call !== this.props.call)) {
|
||||||
this.setState({
|
this.setState({
|
||||||
sourceIndex: 0
|
sourceIndex: 0
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ import React, { Component } from "react";
|
|||||||
import {
|
import {
|
||||||
Modal,
|
Modal,
|
||||||
Button,
|
Button,
|
||||||
Icon,
|
Icon
|
||||||
Dropdown
|
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
import "./FilterModal.css";
|
import "./FilterModal.css";
|
||||||
|
|
||||||
|
|||||||
@@ -4,26 +4,6 @@ import {
|
|||||||
FETCH_ERROR_GROUP
|
FETCH_ERROR_GROUP
|
||||||
} from "./group-constants";
|
} 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 = (
|
const group = (
|
||||||
state = {
|
state = {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import axios from "axios";
|
|||||||
import * as types from "./system-constants";
|
import * as types from "./system-constants";
|
||||||
import { push } from 'connected-react-router';
|
import { push } from 'connected-react-router';
|
||||||
|
|
||||||
const FETCH_SUCCESS_STATISTIC = "FETCH_SUCCESS_STATISTIC"
|
|
||||||
|
|
||||||
function beginFetchSystem() {
|
function beginFetchSystem() {
|
||||||
return { type: types.FETCH_SYSTEM };
|
return { type: types.FETCH_SYSTEM };
|
||||||
@@ -19,16 +18,6 @@ function fetchSystemError(data) {
|
|||||||
data };
|
data };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function makeUserRequest(method, data, api = "/login") {
|
|
||||||
// returns a Promise
|
|
||||||
return axios({
|
|
||||||
method: method,
|
|
||||||
url: api,
|
|
||||||
data: data
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function changeUrl(url) {
|
export function changeUrl(url) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch(push(url));
|
dispatch(push(url));
|
||||||
|
|||||||
@@ -1,39 +1,9 @@
|
|||||||
import {
|
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_SYSTEM,
|
||||||
FETCH_SUCCESS_SYSTEM,
|
FETCH_SUCCESS_SYSTEM,
|
||||||
FETCH_ERROR_SYSTEM
|
FETCH_ERROR_SYSTEM
|
||||||
} from "./system-constants";
|
} 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 = (
|
const system = (
|
||||||
state = {
|
state = {
|
||||||
|
|||||||
@@ -49,16 +49,6 @@ function fetchTalkgroupError(data) {
|
|||||||
data };
|
data };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function makeUserRequest(method, data, api) {
|
|
||||||
// returns a Promise
|
|
||||||
return axios({
|
|
||||||
method: method,
|
|
||||||
url: api,
|
|
||||||
data: data
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function changeUrl(url) {
|
export function changeUrl(url) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch(push(url));
|
dispatch(push(url));
|
||||||
|
|||||||
@@ -10,27 +10,6 @@ import {
|
|||||||
FETCH_ERROR_TALKGROUP
|
FETCH_ERROR_TALKGROUP
|
||||||
} from "./talkgroup-constants";
|
} 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 = (
|
const talkgroup = (
|
||||||
state = {
|
state = {
|
||||||
isWaiting: false,
|
isWaiting: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user