Show More
@@ -1,60 +1,62 b'' | |||||
1 | // # Copyright (C) 2010-2016 RhodeCode GmbH |
|
1 | // # Copyright (C) 2010-2016 RhodeCode GmbH | |
2 | // # |
|
2 | // # | |
3 | // # This program is free software: you can redistribute it and/or modify |
|
3 | // # This program is free software: you can redistribute it and/or modify | |
4 | // # it under the terms of the GNU Affero General Public License, version 3 |
|
4 | // # it under the terms of the GNU Affero General Public License, version 3 | |
5 | // # (only), as published by the Free Software Foundation. |
|
5 | // # (only), as published by the Free Software Foundation. | |
6 | // # |
|
6 | // # | |
7 | // # This program is distributed in the hope that it will be useful, |
|
7 | // # This program is distributed in the hope that it will be useful, | |
8 | // # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
8 | // # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9 | // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
9 | // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
10 | // # GNU General Public License for more details. |
|
10 | // # GNU General Public License for more details. | |
11 | // # |
|
11 | // # | |
12 | // # You should have received a copy of the GNU Affero General Public License |
|
12 | // # You should have received a copy of the GNU Affero General Public License | |
13 | // # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
13 | // # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
14 | // # |
|
14 | // # | |
15 | // # This program is dual-licensed. If you wish to learn more about the |
|
15 | // # This program is dual-licensed. If you wish to learn more about the | |
16 | // # AppEnlight Enterprise Edition, including its added features, Support |
|
16 | // # AppEnlight Enterprise Edition, including its added features, Support | |
17 | // # services, and proprietary license terms, please see |
|
17 | // # services, and proprietary license terms, please see | |
18 | // # https://rhodecode.com/licenses/ |
|
18 | // # https://rhodecode.com/licenses/ | |
19 |
|
19 | |||
20 | angular.module('appenlight.components.channelstream', []) |
|
20 | angular.module('appenlight.components.channelstream', []) | |
21 | .component('channelstream', { |
|
21 | .component('channelstream', { | |
22 | controller: ChannelstreamController, |
|
22 | controller: ChannelstreamController, | |
23 | bindings: { |
|
23 | bindings: { | |
24 | config: '=' |
|
24 | config: '=' | |
25 | } |
|
25 | } | |
26 | }); |
|
26 | }); | |
27 |
|
27 | |||
28 | ChannelstreamController.$inject = ['$rootScope', 'stateHolder', 'userSelfPropertyResource']; |
|
28 | ChannelstreamController.$inject = ['$rootScope', 'stateHolder', 'userSelfPropertyResource']; | |
29 |
|
29 | |||
30 | function ChannelstreamController($rootScope, stateHolder, userSelfPropertyResource){ |
|
30 | function ChannelstreamController($rootScope, stateHolder, userSelfPropertyResource){ | |
31 | if (stateHolder.AeUser.id === null){ |
|
31 | if (stateHolder.AeUser.id === null){ | |
32 | return |
|
32 | return | |
33 | } |
|
33 | } | |
34 | userSelfPropertyResource.get({key: 'websocket'}, function (data) { |
|
34 | userSelfPropertyResource.get({key: 'websocket'}, function (data) { | |
35 | stateHolder.websocket = new ReconnectingWebSocket(this.config.ws_url + '/ws?conn_id=' + data.conn_id); |
|
35 | stateHolder.websocket = new ReconnectingWebSocket(this.config.ws_url + '/ws?conn_id=' + data.conn_id); | |
36 | stateHolder.websocket.onopen = function (event) { |
|
36 | stateHolder.websocket.onopen = function (event) { | |
37 | console.log('open'); |
|
37 | console.log('open'); | |
38 | }; |
|
38 | }; | |
39 | stateHolder.websocket.onmessage = function (event) { |
|
39 | stateHolder.websocket.onmessage = function (event) { | |
40 | var data = JSON.parse(event.data); |
|
40 | var data = JSON.parse(event.data); | |
41 |
|
|
41 | $scope.$apply(function (scope) { | |
42 | console.log('channelstream-message', message); |
|
42 | _.each(data, function (message) { | |
43 | if(typeof message.message.topic !== 'undefined'){ |
|
43 | console.log('channelstream-message', message); | |
44 | $rootScope.$broadcast( |
|
44 | if(typeof message.message.topic !== 'undefined'){ | |
45 | 'channelstream-message.'+message.message.topic, message); |
|
45 | $rootScope.$broadcast( | |
46 | } |
|
46 | 'channelstream-message.'+message.message.topic, message); | |
47 |
|
|
47 | } | |
48 | $rootScope.$broadcast('channelstream-message', message); |
|
48 | else{ | |
49 | } |
|
49 | $rootScope.$broadcast('channelstream-message', message); | |
|
50 | } | |||
|
51 | }); | |||
50 | }); |
|
52 | }); | |
51 | }; |
|
53 | }; | |
52 | stateHolder.websocket.onclose = function (event) { |
|
54 | stateHolder.websocket.onclose = function (event) { | |
53 | console.log('closed'); |
|
55 | console.log('closed'); | |
54 | }; |
|
56 | }; | |
55 |
|
57 | |||
56 | stateHolder.websocket.onerror = function (event) { |
|
58 | stateHolder.websocket.onerror = function (event) { | |
57 | console.log('error'); |
|
59 | console.log('error'); | |
58 | }; |
|
60 | }; | |
59 | }.bind(this)); |
|
61 | }.bind(this)); | |
60 | } |
|
62 | } |
General Comments 0
You need to be logged in to leave comments.
Login now