Skip to content

Commit

Permalink
Code cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
Didosa committed Apr 1, 2023
1 parent 9c4b4ff commit c34f259
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 13 deletions.
1 change: 0 additions & 1 deletion PiLotAPIProxy/LogbookProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

using PiLot.Model.Logbook;


namespace PiLot.APIProxy {

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion PiLotAPIProxy/PositionProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Text.Json;
using System.Threading.Tasks;

using PiLot.Utils.Logger;
using PiLot.Model.Nav;


Expand Down
1 change: 0 additions & 1 deletion PiLotAPIProxy/TrackProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

using PiLot.Model.Nav;


namespace PiLot.APIProxy {

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion PiLotBackupAPI/Helpers/BackupHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using PiLot.Data.Files;
using PiLot.Model.Nav;
using PiLot.Model.Logbook;
using PiLot.Utils.Logger;
using PiLot.Model.Sensors;
using PiLot.Utils.Logger;

namespace PiLot.Backup.API.Helpers {

Expand Down
3 changes: 2 additions & 1 deletion PiLotBackupAPI/Helpers/ConfigHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;

using PiLot.Utils.Logger;

Expand Down Expand Up @@ -40,7 +41,7 @@ private void ReadConfig() {
try {
String fileContent = null;
fileContent = File.ReadAllText(configPath);
this.config = System.Text.Json.JsonSerializer.Deserialize<Config>(fileContent);
this.config = JsonSerializer.Deserialize<Config>(fileContent);
} catch (Exception ex) {
Logger.Log("Error reading config: {0}", ex.Message, LogLevels.ERROR);
this.config = null;
Expand Down
3 changes: 1 addition & 2 deletions PiLotBackupClient/Model/Config.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace PiLot.Backup.Client.Model {
Expand Down
8 changes: 6 additions & 2 deletions PiLotBackupClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

namespace PiLot.Backup.Client {

/// <summary>
/// Console app that sends changed data to the backup api within an interval. This
/// is intended to run as a service.
/// </summary>
class Program {

private const Int32 TIMERINTERVALMS = 1000 * 60 * 5;
Expand Down Expand Up @@ -78,7 +82,7 @@ private static void StartTimer() {
private static async void TimerEventAsync() {
if (!Program.busy) {
Program.busy = true;
await Program.PerformBackup();
await Program.PerformBackupAsync();
Program.busy = false;
}
}
Expand All @@ -87,7 +91,7 @@ private static async void TimerEventAsync() {
/// Performs the backup for each target, if the target is reachable, and finally commits
/// the backup and updates the lastSuccess date if everything goes well
/// </summary>
private static async Task PerformBackup() {
private static async Task PerformBackupAsync() {
ConfigHelper configHelper = new ConfigHelper();
Out.WriteDebug($"Found {configHelper.BackupTargets.Count} Backup Targets");
Boolean success = true;
Expand Down
1 change: 1 addition & 0 deletions PiLotPhotosWatcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System;
using System.Collections.Generic;
using System.Configuration;

using PiLot.Utils.Logger;

namespace PiLot.PhotosWatcher {
Expand Down
1 change: 0 additions & 1 deletion PiLotSensors/BaseDevice.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using PiLot.APIProxy;
Expand Down
20 changes: 18 additions & 2 deletions PiLotWeb/js/Service/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ PiLot.Service.Nav = (function () {
pData[3],
pData[4],
pData[5],
RC.Date.DateHelper.isoToLuxon(pData[6], locale),
RC.Date.DateHelper.isoToLuxon(pData[7], locale),
this.processDate(pData[6], locale),
this.processDate(pData[7], locale),
pData[8],
pData[9]
);
Expand All @@ -154,6 +154,22 @@ PiLot.Service.Nav = (function () {
return result;
},

/**
* converts a value to a date. The value can either be an iso string
* or the number of seconds since epoc. Different backends send
* different values, that's why we do this.
*/
processDate: function (pDate, pLocale) {
const type = typeof (pDate);
let result;
if (type === 'string') {
result = RC.Date.DateHelper.isoToLuxon(pDate, pLocale);
} else if (type === 'number') {
result = RC.Date.DateHelper.unixToLuxon(pDate, pLocale);
}
return result;
},

/**
* Gets the cached map of all categories
* @returns {Map} key: id, value: category
Expand Down
11 changes: 10 additions & 1 deletion PiLotWeb/js/View/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,27 +799,36 @@ PiLot.View.Map = (function () {
this.categoryIcons = null; // map with key=category.id and value=icon html
this.poiDetailControl = null; // PiLot.View.Nav.PoiDetails
this.poiFormControl = null; // PiLot.View.Nav.PoiForm
this.moving = false; // helper to avoid loading pois twice when zooming and moving
this.initializeAsync();
};

MapPois.prototype = {

initializeAsync: async function () {
this.pois = new Map();
this.seamap.getLeafletMap().on('movestart', this.leafletMap_movestart.bind(this));
this.seamap.getLeafletMap().on('moveend', this.leafletMap_moveend.bind(this));
this.seamap.getLeafletMap().on('zoomend', this.leafletMap_zoomend.bind(this));
this.settingsControl.on('applySettings', this.settings_applySettings.bind(this));
this.addContextPopupLink();
await this.loadPoisAsync();
},

leafletMap_movestart: function () {
this.moving = true;
},

leafletMap_moveend: function () {
this.loadPoisAsync();
this.resizeMarkers(this.pois);
this.moving = false;
},

leafletMap_zoomend: function () {
this.loadPoisAsync();
if (!this.moving) {
this.loadPoisAsync();
}
},

settings_applySettings: function (pSender) {
Expand Down

0 comments on commit c34f259

Please sign in to comment.