Add auto update
This commit is contained in:
parent
3b5d1e033a
commit
c5e909da1b
2 changed files with 7 additions and 15 deletions
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'Identity', 'Image', function ($scope, Compute, $rootScope, Loading, Identity, Image)
|
||||
{
|
||||
|
||||
graph = new joint.dia.Graph;
|
||||
paper = new joint.dia.Paper({
|
||||
el: $('#graphHolder'),
|
||||
|
@ -87,18 +86,14 @@ mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'I
|
|||
|
||||
var tryToRetrieveData = function () {
|
||||
// If no data retrieve about machine and user is logged
|
||||
if (Compute.getData().machines == null && Identity.isAlreadyLogin()) {
|
||||
if (Identity.isAlreadyLogin()) {
|
||||
Loading.start(); // Show loading gif
|
||||
Compute.pullData(callMeAfterPullData); // Retrieve data and call the callback
|
||||
} else {
|
||||
// Else if user is logged and data is already retrieve
|
||||
// simply display data
|
||||
if (Identity.isAlreadyLogin()) {
|
||||
callMeAfterPullData(); // Display data
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
tryToRetrieveData();
|
||||
|
||||
// On user login
|
||||
$scope.$on('loginEvent', function () {
|
||||
tryToRetrieveData();
|
||||
|
|
|
@ -14,12 +14,9 @@ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', '$roo
|
|||
|
||||
// If user is login try to retrieve data
|
||||
if (Identity.isAlreadyLogin()) {
|
||||
if (Image.getData().images == null) {
|
||||
Loading.start();
|
||||
Image.getImages(callMeAfterGetImage);
|
||||
} else {
|
||||
callMeAfterGetImage();
|
||||
}
|
||||
Loading.start();
|
||||
Image.getImages(callMeAfterGetImage);
|
||||
|
||||
}
|
||||
|
||||
// Manager logout event
|
||||
|
|
Loading…
Add table
Reference in a new issue