Commit 3a994d1b by Johannes Edmeier

Add polyfills to support Internet Explorer

Add ES6 and SSE polyfills to support Internet Explorer 11 and Edge. Using Edge the ui has all features like in Chrome / FF. For IE 11 the desktop notifications aren't available. closes #280
parent 0f1bd5a3
......@@ -25,6 +25,9 @@ require('./css/core.css');
require('./img/favicon.png');
require('eventsource-polyfill');
require('es6-shim');
var angular = require('angular');
var module = angular.module('sba-core', [require('angular-ui-router')]);
global.sbaModules.push(module.name);
......
......@@ -19,9 +19,10 @@ var yaml = require('js-yaml');
module.exports = function () {
return function (input) {
if (Object.keys(input).length === 0) {
if (typeof (input) === 'object' && Object.keys(input).length === 0) {
return '';
}
return yaml.dump(input, {
skipInvalid: true,
sort: true,
......
......@@ -94,46 +94,48 @@ module.run(function ($rootScope, $state, Notification, Application, ApplicationG
}
});
// setups up the sse-reciever
$rootScope.journalEventSource = new EventSource('api/journal?stream');
$rootScope.$on('$destroy', function () {
$rootScope.journalEventSource.close();
});
if (typeof (EventSource) !== 'undefined') {
// setups up the sse-reciever
$rootScope.journalEventSource = new EventSource('api/journal?stream');
$rootScope.$on('$destroy', function () {
$rootScope.journalEventSource.close();
});
$rootScope.journalEventSource.addEventListener('message', function (message) {
var event = JSON.parse(message.data);
Object.setPrototypeOf(event.application, Application.prototype);
var title = event.application.name;
var options = {
tag: event.application.id,
body: 'Instance ' + event.application.id + '\n' + event.application.healthUrl,
icon: require('./img/unknown.png'),
timeout: 10000,
url: $state.href('apps.details', {
id: event.application.id
})
};
if (event.type === 'REGISTRATION') {
applicationGroups.addApplication(event.application, false);
refresh(event.application);
title += ' instance registered.';
options.tag = event.application.id + '-REGISTRY';
} else if (event.type === 'DEREGISTRATION') {
applicationGroups.removeApplication(event.application);
title += ' instance removed.';
options.tag = event.application.id + '-REGISTRY';
} else if (event.type === 'STATUS_CHANGE') {
refresh(event.application);
applicationGroups.addApplication(event.application, true);
title += ' instance is ' + event.to.status;
options.tag = event.application.id + '-STATUS';
options.icon = event.to.status !== 'UP' ? require('./img/error.png') : require('./img/ok.png');
options.body = event.from.status + ' --> ' + event.to.status + '\n' + options.body;
}
$rootScope.journalEventSource.addEventListener('message', function (message) {
var event = JSON.parse(message.data);
Object.setPrototypeOf(event.application, Application.prototype);
var title = event.application.name;
var options = {
tag: event.application.id,
body: 'Instance ' + event.application.id + '\n' + event.application.healthUrl,
icon: require('./img/unknown.png'),
timeout: 10000,
url: $state.href('apps.details', {
id: event.application.id
})
};
if (event.type === 'REGISTRATION') {
applicationGroups.addApplication(event.application, false);
refresh(event.application);
title += ' instance registered.';
options.tag = event.application.id + '-REGISTRY';
} else if (event.type === 'DEREGISTRATION') {
applicationGroups.removeApplication(event.application);
title += ' instance removed.';
options.tag = event.application.id + '-REGISTRY';
} else if (event.type === 'STATUS_CHANGE') {
refresh(event.application);
applicationGroups.addApplication(event.application, true);
title += ' instance is ' + event.to.status;
options.tag = event.application.id + '-STATUS';
options.icon = event.to.status !== 'UP' ? require('./img/error.png') : require('./img/ok.png');
options.body = event.from.status + ' --> ' + event.to.status + '\n' + options.body;
}
$rootScope.$apply();
Notification.notify(title, options);
});
$rootScope.$apply();
Notification.notify(title, options);
});
}
});
......@@ -7,13 +7,15 @@
"test": "karma start karma.conf.js",
"watch:js": "webpack -d --watch",
"watch:test": "karma start karma.conf.js --watch",
"dev-server": "webpack-dev-server --port 9000"
"dev-server": "webpack-dev-server --port 9000 --host 0.0.0.0"
},
"dependencies": {
"angular": "1.5.8",
"angular-resource": "1.5.8",
"angular-sanitize": "1.5.8",
"angular-ui-router": "0.3.1",
"es6-shim": "0.35.1",
"eventsource-polyfill": "0.9.6",
"font-awesome": "4.6.3",
"jquery": "3.1.1",
"js-yaml": "3.6.1",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment