From 268da411d914686db568da85053e01e898882d9f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 8 Jun 2021 15:58:17 -0400 Subject: [PATCH] Use getStat instead of other jquery code to update the event data. Don't refresh before rename ajax finishes. Deprecate the n/a handling in getStat. Not sure why it's needed. Sync update eventData with what is returned by ajax status call. Fixes #3265 --- web/skins/classic/views/js/event.js | 34 ++++++------------------- web/skins/classic/views/js/event.js.php | 13 +++++----- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/web/skins/classic/views/js/event.js b/web/skins/classic/views/js/event.js index 0a73dd9d4..e2d3c9ce3 100644 --- a/web/skins/classic/views/js/event.js +++ b/web/skins/classic/views/js/event.js @@ -424,7 +424,6 @@ function streamFastRev(action) { if (vid) { //There is no reverse play with mp4. Set the speed to 0 and manually set the time back. revSpeed = -1*(rates[rates.indexOf(revSpeed*-100)-1]/100); if (rates.indexOf(revSpeed*-100) == 0) { - console.log("paused?"); setButtonState('fastRevBtn', 'unavail'); } clearInterval(intervalRewind); @@ -583,28 +582,9 @@ function getEventResponse(respObj, respText) { } eventData = respObj.event; + getStat(); currEventId = eventData.Id; - $j('#dataEventId').text( eventData.Id ); - $j('#dataEventName').text( eventData.Name ); - $j('#dataMonitorId').text(''+eventData.MonitorId+''); - $j('#dataMonitorName').text(''+eventData.MonitorName+''); - $j('#dataCause').text( eventData.Cause ); - if ( eventData.Notes ) { - $j('#dataCause').prop( 'title', eventData.Notes ); - } else { - $j('#dataCause').prop( 'title', causeString ); - } - $j('#dataStartTime').text( eventData.StartDateTime ); - $j('#dataDuration').text( eventData.Length ); - $j('#dataFrames').text( eventData.Frames ); - $j('#dataAlarmFrames').text( eventData.AlarmFrames ); - $j('dataTotalScore').text( eventData.TotScore ); - $j('dataAvgScore').text( eventData.AvgScore ); - $j('dataMaxScore').text( eventData.MaxScore ); - $j('dataDiskSpace').text( eventData.DiskSpace ); - $j('dataStorage').text( eventData.Storage ); - // Refresh the status of the archive buttons archiveBtn.prop('disabled', !(!eventData.Archived && canEdit.Events)); unarchiveBtn.prop('disabled', !(eventData.Archived && canEdit.Events)); @@ -612,7 +592,6 @@ function getEventResponse(respObj, respText) { history.replaceState(null, null, '?view=event&eid=' + eventData.Id + filterQuery + sortQuery); //if popup removed, check if this allows forward if ( vid && CurEventDefVideoPath ) { vid.src({type: 'video/mp4', src: CurEventDefVideoPath}); //Currently mp4 is all we use - console.log('getEventResponse'); initialAlarmCues(eventData.Id);//ajax and render, new event addVideoTimingTrack(vid, LabelFormat, eventData.MonitorName, eventData.Length, eventData.StartDateTime); CurEventDefVideoPath = null; @@ -640,7 +619,6 @@ function getNearEventsResponse(respObj, respText) { if (checkStreamForErrors('getNearEventsResponse', respObj)) { return; } - console.log(respObj); prevEventId = respObj.nearevents.PrevEventId; nextEventId = respObj.nearevents.NextEventId; prevEventStartTime = Date.parse(respObj.nearevents.PrevEventStartTime); @@ -709,6 +687,7 @@ function getActResponse(respObj, respText) { if (respObj.refreshEvent) { eventQuery(eventData.Id); } + $j('#eventRenameModal').modal('hide'); } function actQuery(action, parms) { @@ -726,8 +705,6 @@ function actQuery(action, parms) { function renameEvent() { var newName = $j('input').val(); actQuery('rename', {eventName: newName}); - //FIXME: update the value of the event name rather than reload the whole page - window.location.reload(true); } function exportEvent() { @@ -826,7 +803,8 @@ function getStat() { var th = $j('').addClass('text-right').text(eventDataStrings[key]); var tdString; - switch ( ( eventData[key] && eventData[key].length ) ? key : 'n/a') { + //switch ( ( eventData[key] && eventData[key].length ) ? key : 'n/a') { + switch (key) { case 'Frames': tdString = '' + eventData[key] + ''; break; @@ -839,6 +817,10 @@ function getStat() { case 'n/a': tdString = 'n/a'; break; + case 'Archived': + case 'Emailed': + tdString = eventData[key] ? yesStr : noStr; + break; default: tdString = eventData[key]; } diff --git a/web/skins/classic/views/js/event.js.php b/web/skins/classic/views/js/event.js.php index a07f4a3b2..cdd4e9041 100644 --- a/web/skins/classic/views/js/event.js.php +++ b/web/skins/classic/views/js/event.js.php @@ -49,7 +49,7 @@ var eventData = { Height: 'Height() ?>', Length: 'Length() ?>', StartDateTime: 'StartDateTime() ?>', - StartDateTimeFmt: 'StartDateTime())) ?>', + StartDateTimeShort: 'StartDateTime())) ?>', EndDateTime: 'EndDateTime() ?>', Frames: 'Frames() ?>', AlarmFrames: 'AlarmFrames() ?>', @@ -58,20 +58,21 @@ var eventData = { MaxScore: 'MaxScore() ?>', DiskSpace: 'DiskSpace(null)) ?>', Storage: 'Storage()->Name()).( $Event->SecondaryStorageId() ? ', '.validHtmlStr($Event->SecondaryStorage()->Name()) : '' ) ?>', - ArchivedStr: 'Archived ? translate('Yes') : translate('No') ?>', - EmailedStr: 'Emailed ? translate('Yes') : translate('No') ?>', Archived: Archived?'true':'false' ?>, Emailed: Emailed?'true':'false' ?> }; +var yesStr = ''; +var noStr = ''; + var eventDataStrings = { Id: '', Name: '', MonitorId: '', MonitorName: '', Cause: '', - StartDateTimeFmt: '', + StartDateTimeShort: '', Length: '', Frames: '', AlarmFrames: '', @@ -80,8 +81,8 @@ var eventDataStrings = { MaxScore: '', DiskSpace: '', Storage: '', - ArchivedStr: '', - EmailedStr: '' + Archived: '', + Emailed: '' }; var monitorUrl = 'Storage()->Server()->UrlToIndex(); ?>';