diff --git a/app/store/agents.js b/app/store/agents.js index fbcc9ca..59b0627 100644 --- a/app/store/agents.js +++ b/app/store/agents.js @@ -11,7 +11,7 @@ const Agents = () => { agent.ip = ip agent.profile = profile agent.interval = parseInt(interval) - agent.last_beacon_date = moment.utc().format('MM/DD/YYYY, hh:mm:SS A') + agent.last_beacon_date = moment().format('MM/DD/YYYY, hh:mm:ss A') agent.status = true obj.agents.push(agent) return agent.id @@ -22,8 +22,8 @@ const Agents = () => { if (!agent) { return null } else { - const lbd = moment(agent.last_beacon_date, 'MM DD YYYY, hh:mm:SS A') - const diff = (lbd.diff(moment(), 'second') * -1) + const lbd = moment(agent.last_beacon_date, 'MM/DD/YYYY, hh:mm:ss A').utc() + const diff = (lbd.diff(moment().utc(), 'seconds') * -1) if (diff > agent.interval) { agent.status = false } @@ -34,7 +34,7 @@ const Agents = () => { obj.updateAgentBeaconTime = (agentId) => { obj.agents.forEach(a => { if (a.id === agentId) { - a.last_beacon_date = moment.utc().format('MM/DD/YYYY, hh:mm:SS A') + a.last_beacon_date = moment().format('MM/DD/YYYY, hh:mm:ss A') return true } }) @@ -63,8 +63,8 @@ const Agents = () => { obj.getAllAgents = () => { obj.agents.forEach(agent => { - const lbd = moment(agent.last_beacon_date, 'MM DD YYYY, hh:mm:SS A') - const diff = (lbd.diff(moment(), 'second') * -1) + const lbd = moment(agent.last_beacon_date, 'MM/DD/YYYY, hh:mm:ss A').utc() + const diff = (lbd.diff(moment().utc(), 'seconds') * -1) if (diff > agent.interval) { agent.status = false } diff --git a/app/store/tasks.js b/app/store/tasks.js index f87b34d..6d7da4c 100644 --- a/app/store/tasks.js +++ b/app/store/tasks.js @@ -1,3 +1,5 @@ +const moment = require('moment') + const Tasks = () => { const obj = {} obj.tasks = [] @@ -7,7 +9,7 @@ const Tasks = () => { task.agentId = agentId task.command = command task.id = obj.tasks.length + 1 - task.tasked_date = new Date(Date.now()).toLocaleString() + task.tasked_date = moment().format('MM/DD/YYYY, hh:mm:SS A') task.complete_date = '' task.response = '' obj.tasks.push(task) @@ -32,7 +34,7 @@ const Tasks = () => { obj.tasks.forEach(t => { if (t.id === taskId) { t.response = response - t.complete_date = new Date(Date.now()).toLocaleString() + t.complete_date = moment().format('MM/DD/YYYY, hh:mm:SS A') } }) }