Skip to content

Commit 54ede4b

Browse files
committed
Fix Variables
1 parent 8e31574 commit 54ede4b

File tree

6 files changed

+86
-85
lines changed

6 files changed

+86
-85
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service/src/routes/observations.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module.exports = function (app, security) {
5555
return res.sendStatus(403);
5656
}
5757

58-
var tasks = [];
58+
const tasks = [];
5959
if (validateObservationId) {
6060
tasks.push(function (done) {
6161
/*
@@ -181,7 +181,7 @@ module.exports = function (app, security) {
181181
}
182182

183183
function getUserForObservation(req, res, next) {
184-
var userId = req.observation.userId;
184+
let userId = req.observation.userId;
185185
if (!userId) return next();
186186

187187
new api.User().getById(userId, function (err, user) {
@@ -193,19 +193,19 @@ module.exports = function (app, security) {
193193
}
194194

195195
function getIconForObservation(req, res, next) {
196-
var form = {};
197-
var primary;
198-
var secondary;
196+
let form = {};
197+
let primary;
198+
let secondary;
199199
if (req.observation.properties.forms.length) {
200-
var formId = req.observation.properties.forms[0].formId;
201-
var formDefinitions = req.event.forms.filter(function (form) {
200+
let formId = req.observation.properties.forms[0].formId;
201+
let formDefinitions = req.event.forms.filter(function (form) {
202202
return form._id === formId;
203203
});
204204

205205
if (formDefinitions.length) {
206206
form = formDefinitions[0];
207207
primary = req.observation.properties.forms[0][form.primaryField];
208-
secondary = req.observation.properties.forms[0][form.variantField];
208+
secondary = req.observation.properties.forms[0][form.letiantField];
209209
}
210210
}
211211

web-app/src/app/event/event.service.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export class EventService {
398398
}
399399

400400
addObservationFavorite(observation) {
401-
var event = this.eventsById[observation.eventId];
401+
let event = this.eventsById[observation.eventId];
402402
return this.observationService
403403
.addObservationFavorite(event, observation)
404404
.pipe(
@@ -410,7 +410,7 @@ export class EventService {
410410
}
411411

412412
removeObservationFavorite(observation) {
413-
var event = this.eventsById[observation.eventId];
413+
let event = this.eventsById[observation.eventId];
414414
return this.observationService
415415
.removeObservationFavorite(event, observation)
416416
.pipe(
@@ -425,7 +425,7 @@ export class EventService {
425425
observation: Observation,
426426
important
427427
): Observable<Observation> {
428-
var event = this.eventsById[observation.eventId];
428+
let event = this.eventsById[observation.eventId];
429429
return this.observationService
430430
.markObservationAsImportantForEvent(event, observation, important)
431431
.pipe(
@@ -439,7 +439,7 @@ export class EventService {
439439
clearObservationAsImportant(
440440
observation: Observation
441441
): Observable<Observation> {
442-
var event = this.eventsById[observation.eventId];
442+
let event = this.eventsById[observation.eventId];
443443
return this.observationService
444444
.clearObservationAsImportantForEvent(event, observation)
445445
.pipe(
@@ -451,7 +451,7 @@ export class EventService {
451451
}
452452

453453
archiveObservation(observation): Observable<Observation> {
454-
var event = this.eventsById[observation.eventId];
454+
let event = this.eventsById[observation.eventId];
455455
return this.observationService
456456
.archiveObservationForEvent(event, observation)
457457
.pipe(
@@ -486,13 +486,13 @@ export class EventService {
486486
}
487487

488488
getForms(observation: Observation, options?: any) {
489-
var event = this.eventsById[observation.eventId];
489+
let event = this.eventsById[observation.eventId];
490490
return this.getFormsForEvent(event, options);
491491
}
492492

493493
getFormsForEvent(event: Event, options?: any) {
494494
options = options || {};
495-
var forms = event.forms;
495+
let forms = event.forms;
496496
if (options.archived === false) {
497497
forms = forms.filter((form: Form) => !form.archived);
498498
}
@@ -669,24 +669,24 @@ export class EventService {
669669
}
670670

671671
parseObservations(event: Event, observations: Observation[]): void {
672-
var added = [];
673-
var updated = [];
674-
var removed = [];
672+
const added = [];
673+
const updated = [];
674+
const removed = [];
675675

676-
var observationsById = {};
677-
var filteredObservationsById =
676+
const observationsById = {};
677+
let filteredObservationsById =
678678
this.eventsById[event.id].filteredObservationsById;
679679
observations.forEach((observation: Observation) => {
680680
// Check if this observation passes the current filter
681681
if (this.filterService.observationInFilter(observation)) {
682682
// Check if we already have this observation, if so update, otherwise add
683-
var localObservation = filteredObservationsById[observation.id];
683+
let localObservation = filteredObservationsById[observation.id];
684684
if (localObservation) {
685685
if (localObservation.lastModified !== observation.lastModified) {
686686
updated.push(observation);
687687
} else if (observation.attachments) {
688-
var some = _.some(observation.attachments, function (attachment) {
689-
var localAttachment = _.find(
688+
let some = _.some(observation.attachments, function (attachment) {
689+
let localAttachment = _.find(
690690
localObservation.attachments,
691691
function (a) {
692692
return a.id === attachment.id;
@@ -713,7 +713,7 @@ export class EventService {
713713
});
714714

715715
// remaining elements were not pulled from the server, hence we should remove them
716-
removed = Object.values(filteredObservationsById);
716+
removed.push(Object.values(filteredObservationsById));
717717

718718
this.eventsById[event.id].observationsById = _.keyBy(observations, "id");
719719
this.eventsById[event.id].filteredObservationsById = observationsById;
@@ -741,7 +741,7 @@ export class EventService {
741741
delete userLocation.locations;
742742

743743
if (userLocation.user.iconUrl) {
744-
var params = new HttpParams();
744+
let params = new HttpParams();
745745
params = params.append(
746746
"access_token",
747747
this.localStorageService.getToken()

web-app/src/app/filter/filter.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class FilterComponent implements OnInit {
7575
this.selectedUsers = users;
7676
this.selectedForms = forms;
7777
if (!this.eventUsers.length) {
78-
var eUsers = await this.getUsers(event);
78+
let eUsers = await this.getUsers(event);
7979
this.eventUsers.push(...eUsers);
8080
}
8181
if (!this.eventForms.length && event.forms) this.eventForms = event.forms;
@@ -218,8 +218,8 @@ export class FilterComponent implements OnInit {
218218
this.userControl.setValue("");
219219
this.formControl.setValue("");
220220

221-
var newEvent: Event = event.option.value;
222-
var eUsers = await this.getUsers(newEvent);
221+
let newEvent: Event = event.option.value;
222+
let eUsers = await this.getUsers(newEvent);
223223

224224
this.eventUsers = eUsers;
225225
this.eventForms = newEvent.forms;
@@ -312,7 +312,7 @@ export class FilterComponent implements OnInit {
312312
*/
313313

314314
onFilter(): void {
315-
var options: IntervalOptions = {};
315+
const options: IntervalOptions = {};
316316
if (this.intervalChoice.filter === "custom") {
317317
options.startDate = this.startDate;
318318
options.endDate = this.endDate;

web-app/src/app/filter/filter.service.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ export class FilterService {
103103
*/
104104

105105
setFilter(filter: Filter): void {
106-
var eventChanged = null;
107-
var teamsChanged = null;
108-
var usersChanged = null;
109-
var formsChanged = null;
110-
var timeIntervalChanged = null;
111-
var actionFilterChanged = null;
106+
let eventChanged = null;
107+
let teamsChanged = null;
108+
let usersChanged = null;
109+
let formsChanged = null;
110+
let timeIntervalChanged = null;
111+
let actionFilterChanged = null;
112112

113113
if (filter.users) usersChanged = this.setUsers(filter.users);
114114

@@ -124,9 +124,9 @@ export class FilterService {
124124
// if they changed the event, and didn't set teams filter
125125
// then reset teams filter to empty array
126126
if (!filter.teams) {
127-
var oldTeamIds = this.localStorageService.getTeams() || [];
128-
var teams = [];
129-
for (var i = 0; i < filter.event.teams.length; i++) {
127+
let oldTeamIds = this.localStorageService.getTeams() || [];
128+
const teams = [];
129+
for (let i = 0; i < filter.event.teams.length; i++) {
130130
if (oldTeamIds.indexOf(this.event.teams[i].id) != -1) {
131131
teams.push(this.event.teams[i]);
132132
}
@@ -144,7 +144,7 @@ export class FilterService {
144144
timeIntervalChanged = filter.timeInterval;
145145
}
146146

147-
var changed: Changes = {};
147+
const changed: Changes = {};
148148
if (eventChanged) changed.event = eventChanged;
149149
if (teamsChanged) changed.teams = teamsChanged;
150150
if (usersChanged) changed.users = usersChanged;
@@ -156,7 +156,7 @@ export class FilterService {
156156
}
157157

158158
removeFilters() {
159-
var changed: Changes = {};
159+
const changed: Changes = {};
160160
if (this.event) {
161161
changed.event = { removed: [this.event] };
162162
this.event = null;
@@ -180,8 +180,8 @@ export class FilterService {
180180
removed: [this.event],
181181
};
182182
} else if ((newEvent && !this.event) || this.event.id !== newEvent.id) {
183-
var added = [newEvent];
184-
var removed = this.event ? [this.event] : [];
183+
const added = [newEvent];
184+
const removed = this.event ? [this.event] : [];
185185

186186
this.userService.addRecentEvent(newEvent).subscribe({
187187
error: (e) => console.error("Error adding recent event", e),
@@ -209,8 +209,8 @@ export class FilterService {
209209
*/
210210

211211
setUsers(newUsers: User[]): filterChanges {
212-
var added = [];
213-
var removed = [];
212+
const added = [];
213+
const removed = [];
214214

215215
newUsers.forEach((user: User) => {
216216
if (this.users.findIndex((u) => u.id === user.id) < 0) added.push(user);
@@ -236,8 +236,8 @@ export class FilterService {
236236
*/
237237

238238
setForms(newForms: Form[]): filterChanges {
239-
var added = [];
240-
var removed = [];
239+
const added = [];
240+
const removed = [];
241241

242242
newForms.forEach((form: Form) => {
243243
if (this.forms.findIndex((f) => f.id === form.id) < 0) added.push(form);
@@ -263,16 +263,16 @@ export class FilterService {
263263
*/
264264

265265
setTeams(newTeams: Team[]): filterChanges {
266-
var added = [];
267-
var removed = [];
266+
const added = [];
267+
const removed = [];
268268

269269
newTeams.forEach((team: Team) => {
270270
if (!this.teamsById[team.id]) {
271271
added.push(team);
272272
}
273273
});
274274

275-
var newTeamsById = _.keyBy(newTeams, "id");
275+
let newTeamsById = _.keyBy(newTeams, "id");
276276
Object.values(this.teamsById).forEach((team: Team) => {
277277
if (!newTeamsById[team.id]) {
278278
removed.push(team);
@@ -386,7 +386,7 @@ export class FilterService {
386386

387387
hasFormInList(observationForms: FormProperties[]): boolean {
388388
if (this.forms.length <= 0) return true;
389-
var intersection = this.forms
389+
const intersection = this.forms
390390
.map((x) => x.id)
391391
.filter((fID) => observationForms.map((y) => y.formId).includes(fID));
392392
return intersection.length > 0;
@@ -399,9 +399,9 @@ export class FilterService {
399399
*/
400400

401401
isObservationInTimeFilter(o: Observation): boolean {
402-
var time: SearchInterval = this.formatInterval(this.interval);
402+
const time: SearchInterval = this.formatInterval(this.interval);
403403
if (time) {
404-
var properties = o.properties;
404+
const properties = o.properties;
405405
if (time?.start && time?.end) {
406406
return moment(properties.timestamp).isBetween(time.start, time.end);
407407
} else if (time?.start) {
@@ -434,23 +434,23 @@ export class FilterService {
434434

435435
formatInterval(interval: Interval): SearchInterval {
436436
if (!interval) return null;
437-
var choice = interval.choice;
438-
var options = interval.options;
439-
var start: string = null;
440-
var end: string = null;
437+
const choice = interval.choice;
438+
const options = interval.options;
439+
let start: string = null;
440+
let end: string = null;
441441

442442
if (choice.filter === "all") {
443443
return null;
444444
} else if (choice.filter === "today") {
445445
start = moment().startOf("day").toISOString();
446446
end = moment().endOf("day").toISOString();
447447
} else if (choice.filter === "custom") {
448-
var startDate = moment(options.startDate);
448+
let startDate = moment(options.startDate);
449449
if (startDate) {
450450
startDate = options.localTime ? startDate.utc() : startDate;
451451
start = startDate.utc().toISOString();
452452
}
453-
var endDate = moment(options.endDate);
453+
let endDate = moment(options.endDate);
454454
if (endDate) {
455455
endDate = options.localTime ? endDate.utc() : endDate;
456456
end = endDate.utc().toISOString();

0 commit comments

Comments
 (0)