Skip to content

Commit

Permalink
added support for showing owls, not tested yet
Browse files Browse the repository at this point in the history
  • Loading branch information
lurume84 committed Dec 18, 2020
1 parent c92fbab commit 88b2a8f
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<script src="js/login/LoginView.js"></script>
<script src="js/login/LoginInteractor.js"></script>
<script src="js/login/LoginPresenter.js"></script>
<script src="js/homescreen/HomescreenView.js"></script>
<script src="js/homescreen/HomescreenPresenter.js"></script>
<script src="js/homescreen/HomescreenInteractor.js"></script>
<title>Blink Viewer</title>
</head>
<body>
Expand Down Expand Up @@ -73,7 +76,6 @@ <h4 class="mdl-dialog__title"><img src="img/logo_white.png"/></h4>
<form class="verify" action="#">
<div class="mdl-dialog__content">
A verification code has been sent to <span class="email"></span>

<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input verification" id="verificationInput"/>
<label class="mdl-textfield__label" for="verificationInput">Verification...</label>
Expand Down
21 changes: 21 additions & 0 deletions js/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,27 @@ blink.listeners = blink.listeners || {};
return new blink.interactors.ActivityInteractor();
},
enumerable: false
},
getHomescreenPresenter : {
value: function()
{
return new blink.presenters.HomescreenPresenter(this);
},
enumerable: false
},
getHomescreenView : {
value: function(presenter)
{
return new blink.views.HomescreenView(presenter);
},
enumerable: false
},
getHomescreenInteractor : {
value: function()
{
return new blink.interactors.HomescreenInteractor();
},
enumerable: false
}
});

Expand Down
10 changes: 10 additions & 0 deletions js/camera/CameraView.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@
},
enumerable: false
},
onOwls : {
value: function(cameras)
{
$.each( cameras, function( key, value2 )
{
self.presenter.getCamera(value2.network_id, value2.id, value2.name, self.load);
});
},
enumerable: false
},
initContent : {
value: function(card, data)
{
Expand Down
36 changes: 36 additions & 0 deletions js/homescreen/HomescreenInteractor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(function(interactors)
{
function HomescreenInteractor()
{

}

Object.defineProperties(HomescreenInteractor.prototype,
{
get : {
value: function(listener)
{
$.ajax
({
type: "GET",
url: "https://rest-" + credentials.region + "." + server + "/api/v3/accounts/" + credentials.account.id + "/homescreen",
dataType: 'json',
beforeSend: function(xhr) {
xhr.setRequestHeader("TOKEN_AUTH", credentials.token);
},
success: function (data)
{
listener.onSuccess(data);
},
error: function (jqxhr, textStatus, error)
{
listener.onError(jqxhr.responseJSON);
}
});
},
enumerable: false
}
});

interactors.HomescreenInteractor = HomescreenInteractor;
})(blink.interactors);
36 changes: 36 additions & 0 deletions js/homescreen/HomescreenPresenter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(function(presenters)
{
function HomescreenPresenter(Context)
{
this.interactor = Context.getHomescreenInteractor();
this.cameraView = Context.getCameraPresenter().cameraView;

this.view = Context.getHomescreenView(this);
this.view.init();
}

Object.defineProperties(HomescreenPresenter.prototype,
{
get : {
value: function(onSuccess)
{
var self = this;

this.interactor.get(new blink.listeners.BaseDecisionListener(
function(data)
{
onSuccess(data);

self.cameraView.onOwls(data.owls);
},
function(data)
{
self.view.showError(data);
}));
},
enumerable: false
}
});

presenters.HomescreenPresenter = HomescreenPresenter;
})(blink.presenters);
44 changes: 44 additions & 0 deletions js/homescreen/HomescreenView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
(function(views)
{
var self;

function HomescreenView(presenter)
{
self = this;
this.presenter = presenter;
}

Object.defineProperties(HomescreenView.prototype,
{
init : {
value: function()
{

},
enumerable: false
},
onLogin : {
value: function()
{
self.presenter.get(self.onLoad);
},
enumerable: false
},
onLoad : {
value: function(data)
{
console.log(data)
},
enumerable: false
},
showError : {
value: function(data)
{
document.querySelector('#toast').MaterialSnackbar.showSnackbar({message: data.message});
},
enumerable: false
}
});

views.HomescreenView = HomescreenView;
})(blink.views);
2 changes: 2 additions & 0 deletions js/login/LoginPresenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
this.loginView = Context.getLoginView(this);
this.loginView.init();

this.homescreenView = Context.getHomescreenPresenter().view;
this.networkView = Context.getNetworkPresenter().networkView;
this.activityView = Context.getActivityPresenter().activityView;
}
Expand Down Expand Up @@ -125,6 +126,7 @@
function(data)
{
self.loginView.load(data);
self.homescreenView.onLogin(data);
self.activityView.onLogin(data);
self.networkView.onLogin(data);
},
Expand Down

0 comments on commit 88b2a8f

Please sign in to comment.