pull/1451/head
Rick Carlino 2019-09-19 08:37:05 -05:00
parent 7843a1e93c
commit fc2c42161f
10 changed files with 47 additions and 19 deletions

View File

@ -1,8 +1,8 @@
module Configs
class Update < Mutations::Command
HOTFIX = [ :encoder_scaling_x, :encoder_scaling_y, :encoder_scaling_z ]
BAD = 56
GOOD = 5556
HOTFIX = [:encoder_scaling_x, :encoder_scaling_y, :encoder_scaling_z]
BAD = 56
GOOD = 5556
required do
duck :target, methods: [:update_attributes!]
@ -11,6 +11,7 @@ module Configs
def execute
target.assign_attributes(sliced_attrs)
# Remove HOTFIX after November 12, 2019 - RC
HOTFIX.map do |attr|
target.assign_attributes(attr => GOOD) if target.try(attr) == BAD
end
@ -20,7 +21,7 @@ module Configs
def sliced_attrs
whitelist = target.class.column_names.map(&:to_sym)
updates = update_attrs
updates = update_attrs
.deep_symbolize_keys
.except(:device_id, :id, :created_at)
updates.slice(*whitelist)

View File

@ -11,7 +11,6 @@ module Devices
string :timezone
time :last_saw_mq
integer :mounted_tool_id, nils: true
integer :turnkey_sequence_id, nils: true
end
def validate

View File

@ -0,0 +1,8 @@
class BeginTurnKeySequenceFeature < ActiveRecord::Migration[5.2]
def change
add_foreign_key :fbos_configs, :sequences, column: :boot_sequence_id
add_column :devices, :last_ota, :datetime
add_column :devices, :last_ota_check, :datetime
end
end

View File

@ -7,7 +7,10 @@ jest.mock("../../api/crud", () => {
});
jest.mock("../../resources/getters", () => {
return { getWebAppConfig: jest.fn(() => (undefined)) };
return {
getWebAppConfig: jest.fn(() => (undefined)),
getFbosConfig: jest.fn(() => (undefined)),
};
});
describe("toggleWebAppBool", () => {

View File

@ -16,6 +16,7 @@ import { PowerAndReset } from "./fbos_settings/power_and_reset";
import { SendDiagnosticReport } from "./send_diagnostic_report";
import axios from "axios";
import { t } from "../../i18next_wrapper";
import { SequenceSelectBox } from "../../sequences/sequence_select_box";
export enum ColWidth {
label = 3,
@ -98,6 +99,22 @@ export class FarmbotOsSettings
value={this.props.deviceAccount.body.name} />
</Col>
</Row>
<Row>
{console.log("Move this under 'FIRMWARE' dropdown tomorrow.")}
<Col xs={ColWidth.label}>
<label>
{t("BOOT SEQUENCE")}
</label>
</Col>
<Col xs={9}>
<SequenceSelectBox
onChange={(ddi) => {
this.updateFbosConfig(ddi.value);
}}
resources={this.props.resources}
sequenceId={this.props.boot_sequence_id} />
</Col>
</Row>
<Row>
<Col xs={ColWidth.label}>
<label>

View File

@ -26,7 +26,7 @@ describe("resourceUsageList", () => {
"Sequence.Sequence": {
"Regimen.9.9": { "Sequence.10.10": true, "Sequence.11.11": true }
},
"Sequence.Device": { "Device.99.99": { "Sequence.12.12": true } }
"Sequence.FbosConfig": { "Device.99.99": { "Sequence.12.12": true } }
};
const actual = Object.keys(resourceUsageList(x)).sort();
const expected =

View File

@ -22,7 +22,7 @@ export type UsageKind =
| "Sequence.Regimen"
| "Sequence.FarmEvent"
| "Sequence.Sequence"
| "Sequence.Device";
| "Sequence.FbosConfig";
/** This variable ensures that `EVERY_USAGE_KIND` does not have typos and is
* up-to-date all `UsageKind`s */
@ -31,7 +31,7 @@ const values: Record<UsageKind, UsageKind> = {
"Sequence.Regimen": "Sequence.Regimen",
"Sequence.FarmEvent": "Sequence.FarmEvent",
"Sequence.Sequence": "Sequence.Sequence",
"Sequence.Device": "Sequence.Device"
"Sequence.FbosConfig": "Sequence.FbosConfig"
};
/** Array that contains every `UsageKind` token for easy runtime iteration. */

View File

@ -72,7 +72,7 @@ export const emptyState = (): RestResources => {
"Sequence.FarmEvent": {},
"Sequence.Regimen": {},
"Sequence.Sequence": {},
"Sequence.Device": {}
"Sequence.FbosConfig": {}
}
}
};

View File

@ -28,7 +28,7 @@ import { ReduxAction } from "../redux/interfaces";
import { ActionHandler } from "../redux/generate_reducer";
import { get } from "lodash";
import { Actions } from "../constants";
import { maybeGetDevice } from "./selectors";
import { getFbosConfig } from "./getters";
export function findByUuid(index: ResourceIndex, uuid: string): TaggedResource {
const x = index.references[uuid];
@ -197,16 +197,16 @@ const BEFORE_HOOKS: IndexerHook = {
const AFTER_HOOKS: IndexerHook = {
Device: (i) => {
console.log("Hmmm");
const dev = maybeGetDevice(i);
if (dev && dev.body.turnkey_sequence_id) {
const tracker = i.inUse["Sequence.Device"];
const conf = getFbosConfig(i);
if (conf && conf.body.boot_sequence_id) {
const tracker = i.inUse["Sequence.FbosConfig"];
const sequence =
findByKindAndId(i, "Sequence", dev.body.turnkey_sequence_id);
findByKindAndId(i, "Sequence", conf.body.boot_sequence_id);
tracker[sequence.uuid] = tracker[sequence.uuid] || {};
tracker[sequence.uuid][dev.uuid] = true;
tracker[sequence.uuid][conf.uuid] = true;
} else {
i.inUse["Sequence.Device"] = {};
i.inUse["Sequence.FbosConfig"] = {};
}
},
FarmEvent: reindexAllFarmEventUsage,

View File

@ -45,7 +45,7 @@
"coveralls": "3.0.6",
"enzyme": "3.10.0",
"enzyme-adapter-react-16": "1.14.0",
"farmbot": "8.2.0",
"farmbot": "8.2.2",
"i18next": "17.0.14",
"lodash": "4.17.15",
"markdown-it": "10.0.0",