Works, needs tests

pull/473/head
Rick Carlino 2017-09-27 18:21:11 -05:00
parent 8adebab5bd
commit de590136af
4 changed files with 22 additions and 8 deletions

View File

@ -10,6 +10,7 @@ import { edit, save } from "../api/crud";
import { updateNO } from "../resources/actions";
import { deleteUser } from "./actions";
import { success } from "farmbot-toastr/dist";
import { LabsFeatures } from "./labs_features";
const KEYS: (keyof User)[] = ["id", "name", "email", "created_at", "updated_at"];
@ -50,6 +51,9 @@ export class Account extends React.Component<Props, {}> {
.props
.dispatch(deleteUser({ password }))} />
</Row>
<Row>
<LabsFeatures />
</Row>
</Col>
</Page>;
}

View File

@ -1,5 +1,3 @@
import { clamp } from "lodash";
/** Improved array that is useful for up/down situations such as the webcam
* feed flipper UI. */
@ -11,10 +9,18 @@ export class Flipper<T> {
}
private inc = (num: number) => {
this.index = clamp(this.index + num, 0, this.list.length - 1);
const i = this.index;
const maxIndex = this.list.length - 1;
const newIndex = i + num;
if (newIndex < 0) {
this.index = maxIndex;
} else if (newIndex > maxIndex) {
this.index = 0;
} else {
this.index = newIndex;
}
return this.index;
}
/** Retrieve the currently viewed item. Returns a fallback when unable to find
* an element. */
get current(): T { return this.list[this.index] || this.fallback; }

View File

@ -50,12 +50,13 @@ export namespace Session {
}
/** Store a boolean value in `localStorage` */
export function setBool(key: BooleanSetting, val: boolean): void {
export function setBool(key: BooleanSetting, val: boolean): boolean {
localStorage.setItem(key, JSON.stringify(val));
return val;
}
export function invertBool(key: BooleanSetting) {
Session.setBool(key, !Session.getBool(key));
export function invertBool(key: BooleanSetting): boolean {
return Session.setBool(key, !Session.getBool(key));
}
/** Extract numeric settings from `localStorage`. Returns `undefined` when

View File

@ -9,7 +9,10 @@ export enum BooleanSetting {
showPlants = "showPlants",
showPoints = "showPoints",
showSpread = "showSpread",
showFarmbot = "showFarmbot"
showFarmbot = "showFarmbot",
/** "Labs" feature names. */
weedDetector = "weedDetector",
}
export enum NumericSetting {