Skip to content

Commit

Permalink
#546 you now can delete with the trash icon
Browse files Browse the repository at this point in the history
  • Loading branch information
pliablepixels committed May 4, 2018
1 parent beb3c67 commit 0b8460e
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 5 deletions.
26 changes: 21 additions & 5 deletions www/js/EventCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ angular.module('zmApp.controllers')
//console.log ("********* BEFORE ENTER");
//

$scope.modalData = {"doRefresh":false};

$scope.footerState = ionPullUpFooterState.MINIMIZED;
$scope.gifshotSupported = true;
document.addEventListener("pause", onPause, false);
Expand Down Expand Up @@ -1843,8 +1845,15 @@ angular.module('zmApp.controllers')
// Takes care of deleting individual events
//--------------------------------------------------------------------------



$scope.deleteEvent = function(id, itemid)
{
deleteEvent(id,itemid);

};

function deleteEvent (id,itemid) {
//$scope.eventList.showDelete = false;
//curl -XDELETE http://server/zm/api/events/1.json
var loginData = NVRDataModel.getLogin();
Expand All @@ -1861,7 +1870,7 @@ angular.module('zmApp.controllers')



$http.delete(apiDelete)
return $http.delete(apiDelete)
.success(function(data)
{
$ionicLoading.hide();
Expand All @@ -1880,14 +1889,14 @@ angular.module('zmApp.controllers')
else
{


$ionicLoading.hide();
$ionicLoading.show(
{
template: "{{'kSuccess' | translate}}...",
noBackdrop: true,
duration: 1000
});
$scope.events.splice(itemid, 1);
if (itemid > 0) $scope.events.splice(itemid, 1);

}

Expand All @@ -1905,8 +1914,7 @@ angular.module('zmApp.controllers')
NVRDataModel.debug("delete error: " + JSON.stringify(data));
NVRDataModel.displayBanner('error', [$translate.instant('kDeleteEventError1'), $translate.instant('kDeleteEventError2')]);
});

};
}

//------------------------------------------------
// Tapping on the filter sign lets you reset it
Expand Down Expand Up @@ -2908,6 +2916,8 @@ angular.module('zmApp.controllers')
mycarouselWatcher();
//NVRDataModel.debug("EventCtrl: Open Modal with Base path " + relativepath);

$scope.modalData = {"doRefresh":false};

$scope.event = event;

NVRDataModel.setAwake(NVRDataModel.getKeepAwake());
Expand Down Expand Up @@ -2954,6 +2964,12 @@ angular.module('zmApp.controllers')
{
$scope.modal.remove();
}
if ($scope.modalData.doRefresh) {
$scope.modalData.doRefresh = false;
NVRDataModel.debug ("Reloading events since we deleted some...");
doRefresh();
}


};

Expand Down
73 changes: 73 additions & 0 deletions www/js/EventModalCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,79 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro

};



$scope.deleteAndMoveNext = function (id) {
NVRDataModel.debug ("Delete and move next called with: "+id);
deleteEvent(id)
.then (function (succ) {
$ionicLoading.hide();
$scope.modalData.doRefresh = true;
jumpToEvent(id,1);

})
};

function deleteEvent (id) {
//$scope.eventList.showDelete = false;
//curl -XDELETE http://server/zm/api/events/1.json
var loginData = NVRDataModel.getLogin();
var apiDelete = loginData.apiurl + "/events/" + id + ".json";
NVRDataModel.debug("DeleteEvent: ID=" + id );
NVRDataModel.log("Delete event " + apiDelete);

$ionicLoading.show(
{
template: "{{'kDeletingEvent' | translate}}...",
noBackdrop: true,
duration: zm.httpTimeout
});

return $http.delete(apiDelete)
.success(function(data)
{
$ionicLoading.hide();
NVRDataModel.debug("delete output: " + JSON.stringify(data));

if (data.message == 'Error')
{
$ionicLoading.show(
{
template: "{{'kError' | translate}}...",
noBackdrop: true,
duration: 1500
});

}
else
{

$ionicLoading.hide();
$ionicLoading.show(
{
template: "{{'kSuccess' | translate}}...",
noBackdrop: true,
duration: 1000
});


}

// NVRDataModel.displayBanner('info', [$translate.instant('kDeleteEventSuccess')], 2000, 2000);




//doRefresh();

})
.error(function(data)
{
$ionicLoading.hide();
NVRDataModel.debug("delete error: " + JSON.stringify(data));
NVRDataModel.displayBanner('error', [$translate.instant('kDeleteEventError1'), $translate.instant('kDeleteEventError2')]);
});
}
//--------------------------------------------------------
//Navigate to next/prev event in full screen mode
//--------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions www/templates/events-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@
<li ng-if="$root.isAlarm">
<a data-badge="{{$root.alarmCount}}" class="notification-badge animated infinite tada" href="" ng-click="handleAlarms()"><i class="ion-ios-bell"></i></a>
</li>

<li>
<a href="" ng-click="deleteAndMoveNext(eventId)"><i class="ion-trash-a"></i></a>
</li>



</ul>
</div>
</div> <!-- not live feed or snapshot -->
Expand Down

0 comments on commit 0b8460e

Please sign in to comment.