Add config option to ignore ping/ping

This commit is contained in:
Linus Groh
2019-09-27 19:46:34 +01:00
parent 03712ef2a1
commit 87647c81d3
2 changed files with 16 additions and 3 deletions

View File

@@ -93,6 +93,10 @@ const DEFAULT_CONFIG = {
// disable splitting into separate lines.
maxPointDistance: 1000,
},
// Remove the ping/ping location which is enabled in the recorder's
// Docker image for health checks by default:
// https://github.com/owntracks/recorder/issues/195#issuecomment-304004436
ignorePingLocation: true,
};
// Use deepmerge to combine the default and user-defined configuration.

View File

@@ -1,5 +1,6 @@
import * as types from "@/store/mutation-types";
import * as api from "@/api";
import config from "@/config";
import { isIsoDate } from "@/util";
/**
@@ -99,10 +100,18 @@ const getDevices = async ({ commit, state }) => {
* Load last location of the selected user/device.
*/
const getLastLocations = async ({ commit, state }) => {
commit(
types.SET_LAST_LOCATIONS,
await api.getLastLocations(state.selectedUser, state.selectedDevice)
let lastLocations = await api.getLastLocations(
state.selectedUser,
state.selectedDevice
);
if (config.ignorePingLocation) {
// Remove ping/ping from the owntracks/recorder Docker image
// https://github.com/owntracks/frontend/issues/12
lastLocations = lastLocations.filter(
l => !(l.username === "ping" && l.device === "ping")
);
}
commit(types.SET_LAST_LOCATIONS, lastLocations);
};
/**