Skip to content
Snippets Groups Projects
Commit 10015c91 authored by Mathis Neumann's avatar Mathis Neumann
Browse files

show button if changelogs are available instead of applying them directly

parent 0518deb7
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ const observables = [
export default Ember.Controller.extend({
graphingService: Ember.inject.service(),
changelogQueue: Ember.inject.service(),
init() {
this.debug('initializing controller');
......@@ -31,4 +32,9 @@ export default Ember.Controller.extend({
this.debug('creating graph', filteredInstances);
return this.get('graphingService').createGraph(filteredInstances); // TODO: update instead of complete recalculation?
}),
actions: {
applyQueueUpdates() {
this.get('changelogQueue').apply();
}
}
});
\ No newline at end of file
import Ember from 'ember';
export default Ember.Service.extend({
changelogParser: Ember.inject.service(),
_private: {
queue: Ember.A()
},
reset() {
this.get('_private.queue').clear();
},
append(changelogs){
const queue = this.get('_private.queue');
queue.pushObjects(changelogs);
},
apply() {
this.get('changelogParser').parse(this.get('_private.queue'));
this.reset();
},
available: Ember.computed('empty', function() {
return !this.get('empty');
}),
empty: Ember.computed('_private.queue.[]', function() {
return this.get('_private.queue.length') === 0;
})
});
\ No newline at end of file
import Ember from 'ember';
export default Ember.Service.extend({
changelogQueue: Ember.inject.service(),
shouldClose: false,
changelogParser: Ember.inject.service(),
init() {
this._super(...arguments);
this.debug('session', this.get('systemId'));
......@@ -11,7 +11,7 @@ export default Ember.Service.extend({
this.set('shouldClose', false);
this.debug('setting up websocket', systemId);
const socket = new WebSocket(`ws://localhost:8080/v1/changelogstream/${systemId}`);
const socket = new WebSocket(`ws://localhost:8080/v1/changelogstream/${systemId}`); // TODO: from environment!
this.set('socket', socket);
socket.onopen = this.get('events.onOpen').bind(this);
......@@ -33,6 +33,7 @@ export default Ember.Service.extend({
window.onbeforeunload = this.get('disconnect').bind(this);
},
disconnect() {
this.get('changelogQueue').reset();
this.debug('disconnect');
this.set('shouldClose', true);
this.get('socket').close();
......@@ -49,12 +50,12 @@ export default Ember.Service.extend({
},
onMessage(message) {
const changelogsJson = message.data;
this.debug('new changelog received', changelogsJson);
this.debug('new changelogs received', changelogsJson);
try {
const changelog = JSON.parse(changelogsJson);
this.get('changelogParser').parse(changelog);
const changelogs = JSON.parse(changelogsJson);
this.get('changelogQueue').append(changelogs);
} catch (e) {
console.error('could not parse changelog json', e, changelogsJson);
console.error('could not parse changelogs json', e, changelogsJson);
}
}
}
......
{{#architecture-viewer graph=graphModel}}
<button {{action 'applyQueueUpdates'}} type="button" class="btn {{if changelogQueue.empty 'btn-default' 'btn-warning'}}" disabled={{ changelogQueue.empty }} title="Updates are possible when the deployment changed and new information is ready to get visualized!">
<i class="glyphicon glyphicon-refresh"></i> Apply Updates
</button>
{{!-- show entity details in sidebar if subroute (details) is used --}}
{{outlet}}
{{/architecture-viewer}}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment