Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions zeppelin-web/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"angular-animate": "1.3.8",
"angular-touch": "1.3.8",
"angular-route": "1.3.8",
"angular-resource": "1.3.8",
"angular-bootstrap": "~0.13.0",
"angular-websocket": "~1.0.13",
"ace-builds": "1.1.9",
Expand All @@ -28,7 +29,8 @@
"angular-filter": "~0.5.4",
"ngtoast": "~1.5.5",
"ng-focus-if": "~1.0.2",
"bootstrap3-dialog": "bootstrap-dialog#~1.34.7"
"bootstrap3-dialog": "bootstrap-dialog#~1.34.7",
"floatThead": "~1.3.2"
},
"devDependencies": {
"angular-mocks": "1.3.8"
Expand Down Expand Up @@ -61,4 +63,4 @@
"name": "highlightjs"
}
}
}
}
41 changes: 40 additions & 1 deletion zeppelin-web/src/app/app.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
*/
'use strict';

angular.module('zeppelinWebApp').controller('MainCtrl', function($scope, $rootScope, $window) {
angular.module('zeppelinWebApp').controller('MainCtrl', function($scope, $rootScope, $window, webNotification) {
$rootScope.compiledScope = $scope.$new(true, $rootScope);
$scope.looknfeel = 'default';
$scope.windowFocus = true;
$rootScope.hasNewStatus = false;

var init = function() {
$scope.asIframe = (($window.location.href.indexOf('asIframe') > -1) ? true : false);
Expand Down Expand Up @@ -45,4 +47,41 @@ angular.module('zeppelinWebApp').controller('MainCtrl', function($scope, $rootSc
BootstrapDialog.defaultOptions.onshown = function() {
angular.element('#' + this.id).find('.btn:last').focus();
};

$rootScope.$on('hasNewStatus', function(event, data) {
if (!event.defaultPrevented && data && data === true && $rootScope.hasNewStatus === false) {
$rootScope.hasNewStatus = true;

// Send desktop notification
webNotification.showNotification('Zeppelin Notification', {
body: 'You have a job finished!',
icon: 'my-icon.ico',
onClick: function onNotificationClicked() {
console.log('Notification clicked.');
},
autoClose: 4000 //auto close the notification after 2 seconds (you can manually close it via hide function)
}, function onShow(error, hide) {
if (error) {
window.alert('Unable to show notification: ' + error.message);
} else {
setTimeout(function hideNotification() {
hide();
}, 5000);
}
});

event.preventDefault();
}
});

$window.onblur = function (){
$rootScope.windowFocus = false;
};

$window.onfocus = function (){
$rootScope.windowFocus = true;
if($rootScope.hasNewStatus === true) {
$rootScope.hasNewStatus = false;
}
};
});
3 changes: 2 additions & 1 deletion zeppelin-web/src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ angular.module('zeppelinWebApp', [
'puElasticInput',
'xeditable',
'ngToast',
'focus-if'
'focus-if',
'angular-web-notification'
])
.filter('breakFilter', function() {
return function (text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ angular.module('zeppelinWebApp')
$scope.paragraph.result = data.paragraph.result;
$scope.paragraph.settings = data.paragraph.settings;

// when paragraph finishes, activate blinking tab notification if user is not focusing the the tab.
if (statusChanged && ($rootScope.windowFocus === false)) {
$rootScope.$emit('hasNewStatus', true);
}

if (!$scope.asIframe) {
$scope.paragraph.config = data.paragraph.config;
initializeDefault();
Expand Down
3 changes: 3 additions & 0 deletions zeppelin-web/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
<script src="bower_components/ngtoast/dist/ngToast.js"></script>
<script src="bower_components/ng-focus-if/focusIf.js"></script>
<script src="bower_components/bootstrap3-dialog/dist/js/bootstrap-dialog.min.js"></script>
<script src="bower_components/HTML5-Desktop-Notifications2/desktop-notify.js"></script>
<script src="bower_components/angular-web-notification/angular-web-notification.js"></script>

<!-- endbower -->
<!-- endbuild -->
<!-- build:js({.tmp,src}) scripts/scripts.js -->
Expand Down