From 87647c81d3b74ca3af6c1ef378f70124aa9c2f56 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 27 Sep 2019 19:46:34 +0100 Subject: [PATCH] Add config option to ignore ping/ping --- src/config.js | 4 ++++ src/store/actions.js | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/config.js b/src/config.js index 8df81e5..7353b36 100644 --- a/src/config.js +++ b/src/config.js @@ -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. diff --git a/src/store/actions.js b/src/store/actions.js index 49e1318..18f8ac1 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -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); }; /**