Update GSOD function

pull/524/head
Rick Carlino 2017-11-02 12:15:56 -05:00
parent 3f39a81a9b
commit 53e0384d04
2 changed files with 34 additions and 30 deletions

8
.gitignore vendored
View File

@ -3,6 +3,7 @@
*.log
*.pem
/tmp
# For self hosted users...
api_docs.md
config/application.yml
config/database.yml
@ -13,10 +14,9 @@ log/*.log
mqtt/rabbitmq.config
node_modules
node_modules/
public/dist
public/webpack
# For self hosted users...
public/system
package-lock.json
public/dist
public/system
public/webpack
public/webpack/*
tmp

View File

@ -16,13 +16,13 @@ interface RootComponentProps {
store: Store;
}
const errorLoading = (cb: Function) => function handleError(err: object) {
function errorLoading(err: object) {
console.error("Dynamic page loading failed", err);
const container = document.getElementById("root");
const stack = _.get(err, "stack", "No stack.");
const message = _.get(err, "message", "No message available.");
_.get(window, "Rollbar.error", (_x: string) => { })(message);
if (container) {
const message = _.get(err, "message", "No message available.");
_.get(window, "Rollbar.error", (_x: string) => { })(message);
container.innerHTML = (`
<div>
<h1> Something went wrong! </h1>
@ -58,13 +58,15 @@ const errorLoading = (cb: Function) => function handleError(err: object) {
const element = y[x];
element.remove();
}
};
}
// errorLoading(() => { })({});
const controlsRoute = {
path: "app/controls",
getComponent(_discard: void, cb: Function) {
import("./controls/controls")
.then((module) => cb(undefined, module.Controls))
.catch(errorLoading(cb));
.catch(errorLoading);
}
};
@ -118,7 +120,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./account/index")
.then(module => cb(undefined, module.Account))
.catch(errorLoading(cb));
.catch(errorLoading);
}
},
controlsRoute,
@ -127,7 +129,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./devices/devices")
.then(module => cb(undefined, module.Devices))
.catch(errorLoading(cb));
.catch(errorLoading);
}
},
{
@ -135,7 +137,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farmware/index")
.then(module => cb(undefined, module.FarmwarePage))
.catch(errorLoading(cb));
.catch(errorLoading);
}
},
{
@ -144,7 +146,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farm_designer/index")
.then(module => cb(undefined, module.FarmDesigner))
.catch(errorLoading(cb));
.catch(errorLoading);
},
childRoutes: [
{
@ -152,7 +154,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/plant_inventory")
.then(module => cb(undefined, module.Plants))
.catch(errorLoading(cb));
.catch(errorLoading);
},
},
{
@ -160,7 +162,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/crop_catalog")
.then(module => cb(undefined, module.CropCatalog))
.catch(errorLoading(cb));
.catch(errorLoading);
},
},
{
@ -168,7 +170,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/crop_info")
.then(module => cb(undefined, module.CropInfo))
.catch(errorLoading(cb));
.catch(errorLoading);
},
},
{
@ -176,7 +178,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/add_plant")
.then(module => cb(undefined, module.AddPlant))
.catch(errorLoading(cb));
.catch(errorLoading);
},
},
{
@ -184,7 +186,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/select_plants")
.then(module => cb(undefined, module.SelectPlants))
.catch(errorLoading(cb));
.catch(errorLoading);
},
},
{
@ -192,7 +194,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/plant_info")
.then(module => cb(undefined, module.PlantInfo))
.catch(errorLoading(cb));
.catch(errorLoading);
},
},
{
@ -200,7 +202,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/edit_plant_info")
.then(module => cb(undefined, module.EditPlantInfo))
.catch(errorLoading(cb));
.catch(errorLoading);
},
},
{
@ -208,7 +210,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farm_designer/farm_events/farm_events")
.then(module => cb(undefined, module.FarmEvents))
.catch(errorLoading(cb));
.catch(errorLoading);
}
},
{
@ -216,7 +218,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farm_designer/farm_events/add_farm_event")
.then(module => cb(undefined, module.AddFarmEvent))
.catch(errorLoading(cb));
.catch(errorLoading);
}
},
{
@ -224,7 +226,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./farm_designer/farm_events/edit_farm_event")
.then(module => cb(undefined, module.EditFarmEvent))
.catch(errorLoading(cb));
.catch(errorLoading);
}
}
]
@ -234,7 +236,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./regimens/index")
.then(module => cb(undefined, module.Regimens))
.catch(errorLoading(cb));
.catch(errorLoading);
},
},
{
@ -242,15 +244,17 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./regimens/index")
.then(module => cb(undefined, module.Regimens))
.catch(errorLoading(cb));
.catch(errorLoading);
}
},
{
path: "app/sequences",
getComponent(_discard: void, cb: Function) {
import("./sequences/sequences")
.then(module => cb(undefined, module.Sequences))
.catch(errorLoading(cb));
.then(module => {
cb(undefined, module.Sequences);
})
.catch(errorLoading);
},
},
{
@ -258,7 +262,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./sequences/sequences")
.then(module => cb(undefined, module.Sequences))
.catch(errorLoading(cb));
.catch(errorLoading);
},
},
{
@ -266,7 +270,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./tools/index")
.then(module => cb(undefined, module.Tools))
.catch(errorLoading(cb));
.catch(errorLoading);
}
},
{
@ -274,7 +278,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
import("./404")
.then(module => cb(undefined, module.FourOhFour))
.catch(errorLoading(cb));
.catch(errorLoading);
}
}
]