Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { User } from "farmbot/dist/resources/api_resources";
import { TaggedUser, SpecialStatus } from "farmbot";
export const user: User = {
created_at: "2016-10-05T03:02:58.000Z",
email: "farmbot1@farmbot.io",
id: 2,
name: "FarmBot 1",
updated_at: "2017-08-04T19:53:29.724Z"
};
export const taggedUser: TaggedUser = {
kind: "User",
uuid: "1234-5678",
specialStatus: SpecialStatus.SAVED,
body: {
created_at: "2016-10-05T03:02:58.000Z",
email: "farmbot1@farmbot.io",
id: 2,
name: "FarmBot 1",
updated_at: "2017-08-04T19:53:29.724Z"
}
};
"device_id": 8,
"attachment_processed_at": "2017-06-01T14:16:45.899Z",
"updated_at": "2017-06-01T14:16:45.903Z",
"created_at": "2017-06-01T14:14:22.747Z",
"attachment_url": "imgur.com",
"meta": {
"x": 632,
"y": 347,
"z": 164
}
},
"uuid": "Image.8.4"
},
{
"kind": "Image",
"specialStatus": SpecialStatus.SAVED,
"body": {
"id": 7,
"device_id": 8,
"attachment_processed_at": "2017-06-01T14:16:34.839Z",
"updated_at": "2017-06-01T14:16:34.984Z",
"created_at": "2017-06-01T14:14:22.726Z",
"attachment_url": "imgur.com",
"meta": {
"x": 266,
"y": 330,
"z": 53
}
},
"uuid": "Image.7.5"
}
];
};
export function fakeDevice(body: Partial = {}):
TaggedDevice {
return {
"kind": "Device",
"specialStatus": SpecialStatus.SAVED,
"body": { ...DEFAULT_DEVICE_BODY, ...body },
"uuid": "Device.415.0"
};
}
const tr0: TaggedResource = {
"kind": "Sequence",
"specialStatus": SpecialStatus.SAVED,
"body": {
"id": 23,
"name": "Goto 0, 0, 0",
"color": "gray",
"folder_id": undefined,
"body": [
{
"kind": "move_absolute",
"args": {
"location": {
"kind": "coordinate",
"args": {
"x": 0,
"y": 0,
"z": 0
}
.add(Actions.SAVE_RESOURCE_OK, (s, { payload }) => {
indexUpsert(s.index, [payload], "ongoing");
mutateSpecialStatus(payload.uuid, s.index, SpecialStatus.SAVED);
return s;
})
.add(Actions.EDIT_RESOURCE, (s, { payload }) => {
export function getArrayStatus(i: TaggedResource[]): SpecialStatus {
const r = betterCompact(_(i).map(x => x.specialStatus).uniq().value());
if (r.length) {
return (r.includes(SpecialStatus.SAVING)) ?
SpecialStatus.SAVING : SpecialStatus.DIRTY;
} else {
return SpecialStatus.SAVED;
}
}
const isSaved = (t: T) =>
t.specialStatus === SpecialStatus.SAVED;
(d: UpdateMqttData, uuid: string) => {
const tr = asTaggedResource(d);
tr.uuid = uuid;
return overwrite(tr, tr.body, SpecialStatus.SAVED);
};
export function getArrayStatus(i: TaggedResource[]): SpecialStatus {
const r = betterCompact(chain(i).map(x => x.specialStatus).uniq().value());
if (r.length) {
return (r.includes(SpecialStatus.SAVING)) ?
SpecialStatus.SAVING : SpecialStatus.DIRTY;
} else {
return SpecialStatus.SAVED;
}
}
.then(() => {
this.setState({ specialStatusLocal: SpecialStatus.SAVED });
this.dispatch(maybeWarnAboutMissedTasks(this.props.farmEvent,
() => alert(t(Content.REGIMEN_TODAY_SKIPPED_ITEM_RISK)), now));
this.nextRunTimeActions(now);
history.push("/app/designer/events");
})
.catch(() => {
.add(Actions.SAVE_RESOURCE_OK, (s, { payload }) => {
indexUpsert(s.index, [payload], "ongoing");
mutateSpecialStatus(payload.uuid, s.index, SpecialStatus.SAVED);
return s;
})
.add(Actions.EDIT_RESOURCE, (s, { payload }) => {