From 35e8f4b4974515733737c5cc1dd439ca47860007 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 31 May 2017 16:55:00 +0500 Subject: Implement Events panel --- web/app/model/Event.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'web/app/model') diff --git a/web/app/model/Event.js b/web/app/model/Event.js index 7a43086..d225402 100644 --- a/web/app/model/Event.js +++ b/web/app/model/Event.js @@ -1,5 +1,6 @@ /* - * Copyright 2015 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +39,28 @@ Ext.define('Traccar.model.Event', { }, { name: 'geofenceId', type: 'int' + }, { + name: 'text', + calculate: function (data) { + var text, alarmKey, geofence; + if (data.type === 'commandResult') { + text = Strings.eventCommandResult + ': ' + data.attributes.result; + } else if (data.type === 'alarm') { + alarmKey = 'alarm' + data.attributes.alarm.charAt(0).toUpperCase() + data.attributes.alarm.slice(1); + text = Strings[alarmKey] || alarmKey; + } else if (data.type === 'textMessage') { + text = Strings.eventTextMessage + ': ' + data.attributes.message; + } else { + text = Traccar.app.getEventString(data.type); + } + if (data.geofenceId !== 0) { + geofence = Ext.getStore('Geofences').getById(data.geofenceId); + if (geofence) { + text += ' \"' + geofence.get('name') + '"'; + } + } + return text; + } }, { name: 'attributes' }] -- cgit v1.2.3