diff --git a/.gitignore b/.gitignore index 64699be16..313b969ad 100755 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/webpack/routes.tsx b/webpack/routes.tsx index e9d962199..b28b0f24a 100644 --- a/webpack/routes.tsx +++ b/webpack/routes.tsx @@ -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 = (`

Something went wrong!

@@ -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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { getComponent(_discard: void, cb: Function) { import("./404") .then(module => cb(undefined, module.FourOhFour)) - .catch(errorLoading(cb)); + .catch(errorLoading); } } ]