From e4ccac9966920fdbf6a0a3b4bbb389f1f2e8e9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Fr=C3=B6hle?= Date: Tue, 18 Dec 2018 00:38:26 +0100 Subject: [PATCH] v2 autoremove finisched alerts --- dist/autoloader.js | 2 +- dist/autoloaderV2.js | 61 ++++++++++++++++++++++++++++++-------------- src/autoloaderV2.js | 59 +++++++++++++++++++++++++++++------------- 3 files changed, 84 insertions(+), 38 deletions(-) diff --git a/dist/autoloader.js b/dist/autoloader.js index 5d18179..28c4886 100755 --- a/dist/autoloader.js +++ b/dist/autoloader.js @@ -1,4 +1,4 @@ -/*Generated on:Tue Dec 18 2018 00:29:40 GMT+0100 (CET)*/ +/*Generated on:Tue Dec 18 2018 00:38:26 GMT+0100 (CET)*/ var AutomaticDispose_Branch = "master"; var AutomaticDispose_URL = "https://jf.git.rest/Jomaar/automatic-dispose/raw/branch/"; var da_lss_adis_time = new Date().getTime(); diff --git a/dist/autoloaderV2.js b/dist/autoloaderV2.js index 2f88329..9b7b335 100644 --- a/dist/autoloaderV2.js +++ b/dist/autoloaderV2.js @@ -1,4 +1,4 @@ -/*Generated on:Tue Dec 18 2018 00:29:40 GMT+0100 (CET)*/ +/*Generated on:Tue Dec 18 2018 00:38:26 GMT+0100 (CET)*/ /* * Dexie.js - a minimalistic wrapper for IndexedDB * =============================================== @@ -18125,17 +18125,40 @@ class AutomaticDispose { ReadAndAddMissions(MissionID, Runner) { const self = this; + return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], () => { - if (typeof MissionID != 'undefined') { - return self.AddMission(MissionID, Runner); - } else { - return self.ADisSettings.runner_divs.forEach(async (RunnerX, index) => { - await $("#" + RunnerX).find(".missionSideBarEntry").each(async (index, elem) => { - MissionID = $(elem).attr("mission_id"); - await self.AddMission(MissionID, RunnerX); + + self.ADSettings().then(() => { + return self.ADisDB.ADisMissions.toCollection() + }).then((Missions) => { + if (typeof Missions !== "undefined") { + + return Missions.count((count) => { + if (count > 0) { + return Missions.each((MyMission) => { + var MissionElement = $("#mission_" + MyMission.missionID); + if (MissionElement.length == 0 || $('#mission_panel_' + MyMission.missionID).hasClass('mission_panel_green')) { + // remove + console.log("Remove :", MyMission) + self.RemoveMissionsFromQueue(MyMission.missionID) + } + }); + } }); - }) - } + } + }).then(() => { + + if (typeof MissionID != 'undefined') { + return self.AddMission(MissionID, Runner); + } else { + return self.ADisSettings.runner_divs.forEach(async (RunnerX, index) => { + await $("#" + RunnerX).find(".missionSideBarEntry").each(async (index, elem) => { + MissionID = $(elem).attr("mission_id"); + await self.AddMission(MissionID, RunnerX); + }); + }) + } + }); }); } @@ -18217,7 +18240,7 @@ class AutomaticDispose { }); } else { - + var MissionElement = $("#mission_" + ID); var MissionID = MissionElement.attr("mission_id"); @@ -18584,37 +18607,37 @@ class AutomaticDispose { }).then(async () => { return await self.CollectInvolvedVehicles(); }).then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.CollectPatients(); }) .then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.ProcessEmergencyMedicalService() }) .then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.ProcessFireDepartment() }) .then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.ProcessPoliceDepartment() }) .then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.ProcessTechnicalEmergencyService() }) .then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.ProcessWaterRescue() @@ -18639,7 +18662,7 @@ class AutomaticDispose { }) }; - + var $div = $("#mission-form > div:nth-child(7) > a"); var isShow = $div.is(':hidden'); //console.log($div, isShow); @@ -18663,7 +18686,7 @@ class AutomaticDispose { alarming(self) }, 250); } - + } diff --git a/src/autoloaderV2.js b/src/autoloaderV2.js index f460282..4deb375 100644 --- a/src/autoloaderV2.js +++ b/src/autoloaderV2.js @@ -884,17 +884,40 @@ class AutomaticDispose { ReadAndAddMissions(MissionID, Runner) { const self = this; + return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], () => { - if (typeof MissionID != 'undefined') { - return self.AddMission(MissionID, Runner); - } else { - return self.ADisSettings.runner_divs.forEach(async (RunnerX, index) => { - await $("#" + RunnerX).find(".missionSideBarEntry").each(async (index, elem) => { - MissionID = $(elem).attr("mission_id"); - await self.AddMission(MissionID, RunnerX); + + self.ADSettings().then(() => { + return self.ADisDB.ADisMissions.toCollection() + }).then((Missions) => { + if (typeof Missions !== "undefined") { + + return Missions.count((count) => { + if (count > 0) { + return Missions.each((MyMission) => { + var MissionElement = $("#mission_" + MyMission.missionID); + if (MissionElement.length == 0 || $('#mission_panel_' + MyMission.missionID).hasClass('mission_panel_green')) { + // remove + console.log("Remove :", MyMission) + self.RemoveMissionsFromQueue(MyMission.missionID) + } + }); + } }); - }) - } + } + }).then(() => { + + if (typeof MissionID != 'undefined') { + return self.AddMission(MissionID, Runner); + } else { + return self.ADisSettings.runner_divs.forEach(async (RunnerX, index) => { + await $("#" + RunnerX).find(".missionSideBarEntry").each(async (index, elem) => { + MissionID = $(elem).attr("mission_id"); + await self.AddMission(MissionID, RunnerX); + }); + }) + } + }); }); } @@ -976,7 +999,7 @@ class AutomaticDispose { }); } else { - + var MissionElement = $("#mission_" + ID); var MissionID = MissionElement.attr("mission_id"); @@ -1343,37 +1366,37 @@ class AutomaticDispose { }).then(async () => { return await self.CollectInvolvedVehicles(); }).then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.CollectPatients(); }) .then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.ProcessEmergencyMedicalService() }) .then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.ProcessFireDepartment() }) .then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.ProcessPoliceDepartment() }) .then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.ProcessTechnicalEmergencyService() }) .then(async () => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0){ + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { return } return await self.ProcessWaterRescue() @@ -1398,7 +1421,7 @@ class AutomaticDispose { }) }; - + var $div = $("#mission-form > div:nth-child(7) > a"); var isShow = $div.is(':hidden'); //console.log($div, isShow); @@ -1422,7 +1445,7 @@ class AutomaticDispose { alarming(self) }, 250); } - + }