pull/376/head
Rick Carlino 2017-08-03 07:35:54 -05:00
parent d3239c602f
commit c265430007
4 changed files with 80 additions and 30 deletions

36
src/debug_area.tsx 100644
View File

@ -0,0 +1,36 @@
import * as React from "react";
interface DebugProps {
}
export function Debug(props: DebugProps) {
return <div>
Hello?
<hr />
Hello?
<hr />
<Wow />
</div>;
}
let SIZE = 100;
let RED = { height: SIZE, width: SIZE, border: "2px solid red" };
let BLUE = { height: SIZE, width: SIZE, border: "2px solid blue" };
class Wow extends React.Component<{}, {}> {
render() {
return <div>
<div style={RED} draggable={true}>
Drag me
</div>
<div
style={BLUE}
onDrop={() => {
console.log("DROP");
}}
onDropCapture={() => { console.log("DROP CAPTURE"); }} >
Drop here
</div>
</div>;
}
}

View File

@ -13,9 +13,10 @@ export const links = [
{ name: "Farmware", icon: "crosshairs", slug: "farmware" }
];
// if (process.env.NODE_ENV !== "production") {
// links.push({ name: "X", icon: "leaf", slug: "debug" });
// }
if (process.env.NODE_ENV !== "production") {
links.push({ name: "💾", icon: "leaf", slug: "debug" });
}
export const NavLinks = () => {
let currPath = history.getCurrentLocation().pathname;
return (

View File

@ -20,7 +20,7 @@ interface RootComponentProps {
let errorLoading = (cb: Function) => function handleError(err: object) {
console.error("Dynamic page loading failed", err);
var container = document.getElementById("root");
let container = document.getElementById("root");
let stack = _.get(err, "stack", "No stack.");
if (container) {
let message = _.get(err, "message", "No message available.");
@ -44,7 +44,7 @@ let errorLoading = (cb: Function) => function handleError(err: object) {
${JSON.stringify({
message,
stack: stack.split("\n").join("<br/>")
}, null, " ")}
}, undefined, " ")}
</pre>
</div>
`);
@ -55,8 +55,8 @@ let errorLoading = (cb: Function) => function handleError(err: object) {
localStorage.clear();
}
let y = document.querySelectorAll("link");
for (var x = 0; x < y.length; x++) {
var element = y[x];
for (let x = 0; x < y.length; x++) {
let element = y[x];
element.remove();
}
};
@ -64,7 +64,7 @@ let controlsRoute = {
path: "app/controls",
getComponent(_discard: void, cb: Function) {
import("./controls/controls").then(
(module) => cb(null, module.Controls)
(module) => cb(undefined, module.Controls)
).catch(errorLoading(cb));
}
};
@ -119,7 +119,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "app/account",
getComponent(_discard: void, cb: Function) {
import("./account/index").then(
(module) => cb(null, module.Account)
(module) => cb(undefined, module.Account)
).catch(errorLoading(cb));
}
},
@ -128,7 +128,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "app/device",
getComponent(_discard: void, cb: Function) {
import("./devices/devices").then(
(module) => cb(null, module.Devices)
(module) => cb(undefined, module.Devices)
).catch(errorLoading(cb));
}
},
@ -136,7 +136,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "app/farmware",
getComponent(_discard: void, cb: Function) {
import("./farmware/index").then(
(module) => cb(null, module.FarmwarePage)
(module) => cb(undefined, module.FarmwarePage)
).catch(errorLoading(cb));
}
},
@ -145,7 +145,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
onEnter: this.maybeReplaceDesignerModules.bind(this),
getComponent(_discard: void, cb: Function) {
import("./farm_designer/index").then(
(module) => cb(null, module.FarmDesigner)
(module) => cb(undefined, module.FarmDesigner)
).catch(errorLoading(cb));
},
childRoutes: [
@ -153,7 +153,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "plants",
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/plant_inventory").then(
(module) => cb(null, module.Plants)
(module) => cb(undefined, module.Plants)
).catch(errorLoading(cb));
},
},
@ -161,7 +161,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "plants/crop_search",
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/crop_catalog").then(
(module) => cb(null, module.CropCatalog)
(module) => cb(undefined, module.CropCatalog)
).catch(errorLoading(cb));
},
},
@ -169,7 +169,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "plants/crop_search/:crop",
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/crop_info").then(
(module) => cb(null, module.CropInfo)
(module) => cb(undefined, module.CropInfo)
).catch(errorLoading(cb));
},
},
@ -177,7 +177,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "plants/crop_search/:crop/add",
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/dnd_crop_mobile").then(
(module) => cb(null, module.DNDCropMobile)
(module) => cb(undefined, module.DNDCropMobile)
).catch(errorLoading(cb));
},
},
@ -185,7 +185,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "plants/:plant_id",
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/plant_info").then(
(module) => cb(null, module.PlantInfo)
(module) => cb(undefined, module.PlantInfo)
).catch(errorLoading(cb));
},
},
@ -193,7 +193,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "plants/:plant_id/edit",
getComponent(_discard: void, cb: Function) {
import("./farm_designer/plants/edit_plant_info").then(
(module) => cb(null, module.EditPlantInfo)
(module) => cb(undefined, module.EditPlantInfo)
).catch(errorLoading(cb));
},
},
@ -201,7 +201,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "farm_events",
getComponent(_discard: void, cb: Function) {
import("./farm_designer/farm_events/farm_events").then(
(module) => cb(null, module.FarmEvents)
(module) => cb(undefined, module.FarmEvents)
).catch(errorLoading(cb));
}
},
@ -209,7 +209,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "farm_events/add",
getComponent(_discard: void, cb: Function) {
import("./farm_designer/farm_events/add_farm_event").then(
(module) => cb(null, module.AddFarmEvent)
(module) => cb(undefined, module.AddFarmEvent)
).catch(errorLoading(cb));
}
},
@ -217,7 +217,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "farm_events/:farm_event_id",
getComponent(_discard: void, cb: Function) {
import("./farm_designer/farm_events/edit_farm_event").then(
(module) => cb(null, module.EditFarmEvent)
(module) => cb(undefined, module.EditFarmEvent)
).catch(errorLoading(cb));
}
}
@ -228,11 +228,11 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
getComponent(_discard: void, cb: Function) {
if (!isMobile()) {
import("./regimens/index").then(
(module) => cb(null, module.Regimens)
(module) => cb(undefined, module.Regimens)
).catch(errorLoading(cb));
} else {
import("./regimens/list/index").then(
(module) => cb(null, module.RegimensList)
(module) => cb(undefined, module.RegimensList)
).catch(errorLoading(cb));
}
},
@ -241,7 +241,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "app/regimens/:regimen",
getComponent(_discard: void, cb: Function) {
import("./regimens/index").then(
(module) => cb(null, module.Regimens)
(module) => cb(undefined, module.Regimens)
).catch(errorLoading(cb));
}
},
@ -249,7 +249,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "app/sequences",
getComponent(_discard: void, cb: Function) {
import("./sequences/sequences").then(
(module) => cb(null, module.Sequences)
(module) => cb(undefined, module.Sequences)
).catch(errorLoading(cb));
},
},
@ -257,7 +257,7 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "app/sequences/:sequence",
getComponent(_discard: void, cb: Function) {
import("./sequences/sequences").then(
(module) => cb(null, module.Sequences)
(module) => cb(undefined, module.Sequences)
).catch(errorLoading(cb));
},
},
@ -265,15 +265,25 @@ export class RootComponent extends React.Component<RootComponentProps, {}> {
path: "app/tools",
getComponent(_discard: void, cb: Function) {
import("./tools/index").then(
(module) => cb(null, module.Tools)
(module) => cb(undefined, module.Tools)
).catch(errorLoading(cb));
}
},
{
path: "app/debug",
getComponent(_discard: void, cb: Function) {
import("./debug_area")
.then(module => cb(undefined, module.Debug))
.catch(function () {
debugger;
});
},
},
{
path: "*",
getComponent(_discard: void, cb: Function) {
import("./404").then(
(module) => cb(null, module.FourOhFour)
(module) => cb(undefined, module.FourOhFour)
).catch(errorLoading(cb));
}
}

View File

@ -63,8 +63,11 @@
"no-shadowed-variable": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unused-variable": [
true
"jsx-closing-bracket-location": [
1,
{
"selfClosing": "after-props"
}
],
"no-use-before-declare": true,
"no-var-keyword": true,