> {
@@ -48,7 +42,9 @@ export function injectState(
"Component with injectState must be mounted inside ProvideState"
);
}
- return ;
+ // tslint:disable-next-line:no-object-literal-type-assertion
+ const allProps: Readonly
= {...this.props, appState: state} as Readonly
;
+ return ;
};
return {consumeState};
}
diff --git a/client/styles/DeviceView.scss b/client/styles/DeviceView.scss
index 878a383..5dc6aed 100644
--- a/client/styles/DeviceView.scss
+++ b/client/styles/DeviceView.scss
@@ -81,3 +81,10 @@ $connected-color: #13d213;
.ui.modal.programEditor > .header > .header.item .inline.fields {
margin-bottom: 0;
}
+
+.runSectionForm-runButton {
+ display: inline-block;
+ &, .ui.disabled.button {
+ pointer-events: auto !important;
+ }
+}
diff --git a/client/styles/DurationView.scss b/client/styles/DurationView.scss
index 1dc7db9..91e4cef 100644
--- a/client/styles/DurationView.scss
+++ b/client/styles/DurationView.scss
@@ -4,7 +4,7 @@ $durationInput-labelWidth: 2.5em;
.field .durationInputs {
display: flex; // max-width: 100%;
- justify-content: start;
+ justify-content: flex-start;
flex-wrap: wrap;
margin: -$durationInput-spacing / 2;
diff --git a/client/styles/ProgramSequenceView.scss b/client/styles/ProgramSequenceView.scss
index 16c8120..50fd59a 100644
--- a/client/styles/ProgramSequenceView.scss
+++ b/client/styles/ProgramSequenceView.scss
@@ -8,12 +8,16 @@
.programSequence-item {
list-style-type: none;
display: flex;
+ align-items: center;
margin-bottom: 0.5em;
&.dragging {
z-index: 1010;
}
.fields {
- margin: 0em 0em 1em !important;
+ display: flex;
+ align-items: center;
+ margin: 0em !important;
+ padding: 0em !important;
}
.ui.icon.button {
height: fit-content;
diff --git a/common/jsonRpc/index.ts b/common/jsonRpc/index.ts
index 5dd80c5..3845055 100644
--- a/common/jsonRpc/index.ts
+++ b/common/jsonRpc/index.ts
@@ -133,7 +133,7 @@ export type IResponseHandler<
ResponseTypes,
ErrorType,
Method extends keyof ResponseTypes = keyof ResponseTypes
-> = (response: ResponseData) => void;
+> = (response: Response) => void;
export interface ResponseHandlers<
ResponseTypes = DefaultResponseTypes,
diff --git a/common/sprinklersRpc/mqtt/index.ts b/common/sprinklersRpc/mqtt/index.ts
index 18dc534..74c7434 100644
--- a/common/sprinklersRpc/mqtt/index.ts
+++ b/common/sprinklersRpc/mqtt/index.ts
@@ -218,7 +218,7 @@ class MqttSprinklersDevice extends s.SprinklersDevice {
}
doUnsubscribe() {
- this.apiClient.client.unsubscribe(this.subscriptions, err => {
+ this.apiClient.client.unsubscribe(this.subscriptions, (err: Error | undefined) => {
if (err) {
log.error({ err, id: this.id }, "error unsubscribing to device");
} else {
diff --git a/common/sprinklersRpc/schema/requests.ts b/common/sprinklersRpc/schema/requests.ts
index 2e2c7b5..2cfe916 100644
--- a/common/sprinklersRpc/schema/requests.ts
+++ b/common/sprinklersRpc/schema/requests.ts
@@ -36,8 +36,8 @@ export const updateProgram: ModelSchema<
deserializer: (json, done) => {
done(null, json);
},
- beforeDeserialize: () => {},
- afterDeserialize: () => {},
+ beforeDeserialize: undefined as any,
+ afterDeserialize: undefined as any,
}
});
diff --git a/server/Database.ts b/server/Database.ts
index 98ca307..cf3f861 100644
--- a/server/Database.ts
+++ b/server/Database.ts
@@ -47,7 +47,7 @@ export class Database {
const users: User[] = [];
for (let i = 0; i < NUM; i++) {
const username = "alex" + i;
- let user = await this.users.findByUsername(username);
+ let user = await this.users.findByUsername(username, { devices: true });
if (!user) {
user = await this.users.create({
name: "Alex Mikhalev" + i,
@@ -74,7 +74,10 @@ export class Database {
for (let j = 0; j < 5; j++) {
const userIdx = (i + j * 10) % NUM;
const user = users[userIdx];
- user.devices = (user.devices || []).concat([device]);
+ if (!user.devices) {
+ user.devices = [];
+ }
+ user.devices.push(device);
}
}
await this.sprinklersDevices.save(devices);
diff --git a/server/commands/device.ts b/server/commands/device.ts
index c114a74..59443bf 100644
--- a/server/commands/device.ts
+++ b/server/commands/device.ts
@@ -70,7 +70,7 @@ export default class DeviceCommand extends ManageCommand {
}
getFindConditions(flags: DeviceFlags, action: Action): FindConditions {
- let whereClause: FindConditions = {};
+ const whereClause: FindConditions = {};
if (flags.id) {
whereClause.id = flags.id;
}
@@ -125,7 +125,7 @@ export default class DeviceCommand extends ManageCommand {
query = query.where("user.username = :username", { username: flags.username });
}
const devices = await query.getMany();
- if (devices.length == 0) {
+ if (devices.length === 0) {
this.log("No sprinklers devices found");
return 1;
}
@@ -146,7 +146,7 @@ export default class DeviceCommand extends ManageCommand {
if (!user) {
return this.error(`Could not find user with username '${flags.username}'`);
}
- let query = this.database.sprinklersDevices.createQueryBuilder()
+ const query = this.database.sprinklersDevices.createQueryBuilder()
.relation("users")
.of(device);
if (flags["add-user"]) {
diff --git a/server/express/api/devices.ts b/server/express/api/devices.ts
index ec3fdc6..a19d13b 100644
--- a/server/express/api/devices.ts
+++ b/server/express/api/devices.ts
@@ -108,6 +108,12 @@ export function devices(state: ServerState) {
async (req, res) => {
const token: DeviceToken = req.token! as any;
const deviceId = token.aud;
+ const devs = await state.database.sprinklersDevices.count({
+ deviceId
+ });
+ if (devs === 0) {
+ throw new ApiError("deviceId not found", ErrorCode.NotFound);
+ }
const clientId = `device-${deviceId}`;
res.send({
mqttUrl: state.mqttUrl,