Skip to content

Commit

Permalink
allow to abandon liveview
Browse files Browse the repository at this point in the history
  • Loading branch information
lurume84 committed Jul 16, 2019
1 parent c713fcb commit b59f36c
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 8 deletions.
5 changes: 5 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,9 @@
top: 0;
left: 0;
display:none;
}

.mdl-card__actions .live
{
color: red !important;
}
24 changes: 23 additions & 1 deletion js/camera/CameraInteractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,29 @@
});
},
enumerable: false
}
},
requestUnjoin : {
value: function( camera, listener)
{
$.ajax
({
type: "DELETE",
url: "http://127.0.0.1:9191/live",
data: JSON.stringify({camera_id: camera}),
dataType: 'json',
contentType: 'application/json',
success: function (data)
{
listener.onSuccess(data);
},
error: function (jqxhr, textStatus, error)
{
listener.onError(error);
}
});
},
enumerable: false
},
});

interactors.CameraInteractor = CameraInteractor;
Expand Down
19 changes: 18 additions & 1 deletion js/camera/CameraPresenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,24 @@
}));
},
enumerable: false
}
},
requestUnjoin : {
value: function(camera)
{
var self = this;

this.interactor.requestUnjoin(camera, new blink.listeners.BaseDecisionListener(
function(data)
{
self.cameraView.onUnjoin(data, camera);
},
function(data)
{
self.cameraView.showError(data);
}));
},
enumerable: false
},
});

presenters.CameraPresenter = CameraPresenter;
Expand Down
49 changes: 43 additions & 6 deletions js/camera/CameraView.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
});

actions.find(".thumbnail-button").click(function(){self.requestThumbnail(data);});
actions.find(".live-view-button").click(function(){self.requestLiveView(data);});
actions.find(".live-view-button").click(function(){self.clickLiveView(data);});

title.appendTo(card);
text.appendTo(card);
Expand Down Expand Up @@ -163,27 +163,58 @@
},
enumerable: false
},
requestLiveView : {
clickLiveView : {
value: function(data)
{
var card = $("#card" + data.camera_id);

if(!card.find(".mdl-button").prop('disabled'))
var button = card.find(".live-view-button");

if(!button.prop('disabled'))
{
card.find(".mdl-button").attr("disabled", true);

self.presenter.requestLiveView(data.network_id, data.camera_id);
if(!button.hasClass("live"))
{
self.presenter.requestLiveView(data.network_id, data.camera_id);
}
else
{
button.attr("disabled", true);
self.presenter.requestUnjoin(data.camera_id);
}
}
},
enumerable: false
},
onRequestLiveView : {
value: function(data, camera_id)
{
var card = $("#card" + camera_id);
card.find(".live-view-button").attr("disabled", true);

self.presenter.requestJoin(camera_id, data.server, self.onJoin);
},
enumerable: false
},
onUnjoin : {
value: function(data, camera_id)
{
var card = $("#card" + camera_id);
card.find(".live-view-button").attr("disabled", true);

var video = card.find("video");

var button = card.find(".live-view-button");

button.attr("disabled", false);
button.removeClass("live");
button.find(".action").removeClass("fa-eye-slash").addClass("fa-eye");

video.hide();

video[0].stop();
},
enumerable: false
},
onJoin : {
value: function(data)
{
Expand All @@ -193,6 +224,12 @@

var video = card.find("video");

var button = card.find(".live-view-button");

button.attr("disabled", false);
button.addClass("live");
button.find(".action").removeClass("fa-eye").addClass("fa-eye-slash");

video.show();

var hlsConfig = {
Expand Down

0 comments on commit b59f36c

Please sign in to comment.