Skip to content
This repository has been archived by the owner on Mar 13, 2021. It is now read-only.

Commit

Permalink
Refresh sensor value graph
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-asriyan committed Jul 21, 2019
1 parent 1d92b87 commit 2aa8fcb
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 126 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ module.exports = {
browser: true,
},
rules: {
'indent': [
'error',
2, {
'CallExpression': {'arguments': 1},
"SwitchCase": 1
},
],
'require-jsdoc': 0,
'max-len': [
1, {
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ package.json.ember-try

# idea
.idea

# m4m tests
tests/**/*
15 changes: 11 additions & 4 deletions app/routes/account/sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class extends Route {
model({'sensor_id': sensorId, field}) {
this.set('sensorId', sensorId);
this.get('store').query('sensor-value', {sensorId, field});
this.set('field', field);
return this.get('store').peekRecord('sensor', sensorId);
}

Expand All @@ -31,20 +32,26 @@ export default class extends Route {
const sensorId = this.get('sensorId');
const sensor = this.get('store').peekRecord('sensor', sensorId);

const from = new Date(Math.max(...sensor.get('values').mapBy(internal).toArray()));
(await this.get('store').query('sensor-value', {sensorId, from})).forEach((value) => {
const from_ = new Date(Math.max(...sensor.get('values').mapBy('timestamp').toArray()));
(await this.get('store').query(
'sensor-value',
{
sensorId,
'from': from_,
'field': this.get('field'),
})).forEach((value) => {
this.get('store').pushPayload({
'sensor-value': [
{
sensor: value.get('sensor.id'),
id: value.get('id'),
value: value.get('value'),
time: value.get('time'),
timestamp: value.get('timestamp'),
},
],
});
});
}, 60 * 1000);
}, 1000);
this.set('autoUpdateTimer', timer);
}

Expand Down
8 changes: 4 additions & 4 deletions app/routes/account/subject.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export default class extends Route {
const result = this.get('store').peekRecord('object', objectId);

result.get('sensors').
filter((sensor) => sensor.get('typeName') === 'gps' || sensor.get('typeName') === 'obd').
forEach((sensor) => {
this.get('store').query('sensor-value', {sensorId: sensor.get('id'), limit: 1});
});
filter((sensor) => sensor.get('typeName') === 'gps' || sensor.get('typeName') === 'obd').
forEach((sensor) => {
this.get('store').query('sensor-value', {sensorId: sensor.get('id'), limit: 1});
});

return result;
}
Expand Down
4 changes: 1 addition & 3 deletions app/serializers/sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export default class extends ApplicationSerializer.extend(DS.EmbeddedRecordsMixi
serviceCompany: get(resourceHash, 'finance.service_company'),
};

return super.normalize(modelClass,
Object.assign(resourceHash, additional),
);
return super.normalize(modelClass, Object.assign(resourceHash, additional));
}
}
16 changes: 8 additions & 8 deletions app/services/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ export default class extends Service {
const contentType = method === 'POST' ? 'application/json' : undefined;

return this.get('ajax').request(
this.buildUrl(
path,
this.buildUrl(
path,
this.get('sendToken') ? {token: this.get('auth.token')} : undefined,
),
Object.assign({
method: method,
data,
contentType,
}, options)).then((response) => {
),
Object.assign({
method: method,
data,
contentType,
}, options)).then((response) => {
this.set('auth.isAuthorized', true);
return response;
}).catch((e) => {
Expand Down
11 changes: 6 additions & 5 deletions app/utils/to-pretty-string.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export default function(value,
{
commas = true,
fractionDigits = 2,
} = {},
export default function(
value,
{
commas = true,
fractionDigits = 2,
} = {},
) {
if (!value) return '0';
const [integer, fraction] = value.toString().split('.');
Expand Down
5 changes: 0 additions & 5 deletions tests/.eslintrc.js

This file was deleted.

8 changes: 0 additions & 8 deletions tests/helpers/destroy-app.js

This file was deleted.

22 changes: 0 additions & 22 deletions tests/helpers/module-for-acceptance.js

This file was deleted.

16 changes: 0 additions & 16 deletions tests/helpers/start-app.js

This file was deleted.

33 changes: 0 additions & 33 deletions tests/index.html

This file was deleted.

7 changes: 0 additions & 7 deletions tests/test-helper.js

This file was deleted.

11 changes: 0 additions & 11 deletions tests/unit/routes/setup-test.js

This file was deleted.

0 comments on commit 2aa8fcb

Please sign in to comment.