##// END OF EJS Templates
favicon: added favicon notifications
ergo -
r882:d869b56a default
parent child Browse files
Show More
@@ -0,0 +1,7 b''
1 <link rel="import" href="../../../../../../bower_components/polymer/polymer.html">
2
3 <dom-module id="rhodecode-favicon">
4 <template>
5 </template>
6 <script src="rhodecode-favicon.js"></script>
7 </dom-module>
@@ -0,0 +1,20 b''
1 Polymer({
2 is: 'rhodecode-favicon',
3 properties: {
4 favicon: Object,
5 counter: {
6 type: Number,
7 observer: '_handleCounter'
8 }
9 },
10
11 ready: function () {
12 this.favicon = new Favico({
13 type: 'rectangle',
14 animation: 'none'
15 });
16 },
17 _handleCounter: function (newVal, oldVal) {
18 this.favicon.badge(this.counter);
19 }
20 });
@@ -1,190 +1,191 b''
1 {
1 {
2 "dirs": {
2 "dirs": {
3 "css": {
3 "css": {
4 "src":"rhodecode/public/css",
4 "src":"rhodecode/public/css",
5 "dest":"rhodecode/public/css"
5 "dest":"rhodecode/public/css"
6 },
6 },
7 "js": {
7 "js": {
8 "src": "rhodecode/public/js/src",
8 "src": "rhodecode/public/js/src",
9 "dest": "rhodecode/public/js",
9 "dest": "rhodecode/public/js",
10 "bower": "bower_components",
10 "bower": "bower_components",
11 "node_modules": "node_modules"
11 "node_modules": "node_modules"
12 }
12 }
13 },
13 },
14 "copy": {
14 "copy": {
15 "main": {
15 "main": {
16 "expand": true,
16 "expand": true,
17 "cwd": "bower_components",
17 "cwd": "bower_components",
18 "src": "webcomponentsjs/webcomponents-lite.js",
18 "src": "webcomponentsjs/webcomponents-lite.js",
19 "dest": "<%= dirs.js.dest %>/vendors"
19 "dest": "<%= dirs.js.dest %>/vendors"
20 }
20 }
21 },
21 },
22 "concat": {
22 "concat": {
23 "polymercss": {
23 "polymercss": {
24 "src": [
24 "src": [
25 "<%= dirs.js.src %>/components/root-styles-prefix.html",
25 "<%= dirs.js.src %>/components/root-styles-prefix.html",
26 "<%= dirs.css.src %>/style-polymer.css",
26 "<%= dirs.css.src %>/style-polymer.css",
27 "<%= dirs.js.src %>/components/root-styles-suffix.html"
27 "<%= dirs.js.src %>/components/root-styles-suffix.html"
28 ],
28 ],
29 "dest": "<%= dirs.js.dest %>/src/components/root-styles.gen.html",
29 "dest": "<%= dirs.js.dest %>/src/components/root-styles.gen.html",
30 "nonull": true
30 "nonull": true
31 },
31 },
32 "dist": {
32 "dist": {
33 "src": [
33 "src": [
34 "<%= dirs.js.src %>/jquery-1.11.1.min.js",
34 "<%= dirs.js.src %>/jquery-1.11.1.min.js",
35 "<%= dirs.js.src %>/logging.js",
35 "<%= dirs.js.src %>/logging.js",
36 "<%= dirs.js.src %>/bootstrap.js",
36 "<%= dirs.js.src %>/bootstrap.js",
37 "<%= dirs.js.src %>/mousetrap.js",
37 "<%= dirs.js.src %>/mousetrap.js",
38 "<%= dirs.js.src %>/moment.js",
38 "<%= dirs.js.src %>/moment.js",
39 "<%= dirs.js.node_modules %>/appenlight-client/appenlight-client.min.js",
39 "<%= dirs.js.node_modules %>/appenlight-client/appenlight-client.min.js",
40 "<%= dirs.js.node_modules %>/favico.js/favico-0.3.10.min.js",
40 "<%= dirs.js.src %>/i18n_utils.js",
41 "<%= dirs.js.src %>/i18n_utils.js",
41 "<%= dirs.js.src %>/deform.js",
42 "<%= dirs.js.src %>/deform.js",
42 "<%= dirs.js.src %>/plugins/jquery.pjax.js",
43 "<%= dirs.js.src %>/plugins/jquery.pjax.js",
43 "<%= dirs.js.src %>/plugins/jquery.dataTables.js",
44 "<%= dirs.js.src %>/plugins/jquery.dataTables.js",
44 "<%= dirs.js.src %>/plugins/flavoured_checkbox.js",
45 "<%= dirs.js.src %>/plugins/flavoured_checkbox.js",
45 "<%= dirs.js.src %>/plugins/jquery.auto-grow-input.js",
46 "<%= dirs.js.src %>/plugins/jquery.auto-grow-input.js",
46 "<%= dirs.js.src %>/plugins/jquery.autocomplete.js",
47 "<%= dirs.js.src %>/plugins/jquery.autocomplete.js",
47 "<%= dirs.js.src %>/plugins/jquery.debounce.js",
48 "<%= dirs.js.src %>/plugins/jquery.debounce.js",
48 "<%= dirs.js.src %>/plugins/jquery.mark.js",
49 "<%= dirs.js.src %>/plugins/jquery.mark.js",
49 "<%= dirs.js.src %>/plugins/jquery.timeago.js",
50 "<%= dirs.js.src %>/plugins/jquery.timeago.js",
50 "<%= dirs.js.src %>/plugins/jquery.timeago-extension.js",
51 "<%= dirs.js.src %>/plugins/jquery.timeago-extension.js",
51 "<%= dirs.js.src %>/select2/select2.js",
52 "<%= dirs.js.src %>/select2/select2.js",
52 "<%= dirs.js.src %>/codemirror/codemirror.js",
53 "<%= dirs.js.src %>/codemirror/codemirror.js",
53 "<%= dirs.js.src %>/codemirror/codemirror_loadmode.js",
54 "<%= dirs.js.src %>/codemirror/codemirror_loadmode.js",
54 "<%= dirs.js.src %>/codemirror/codemirror_hint.js",
55 "<%= dirs.js.src %>/codemirror/codemirror_hint.js",
55 "<%= dirs.js.src %>/codemirror/codemirror_overlay.js",
56 "<%= dirs.js.src %>/codemirror/codemirror_overlay.js",
56 "<%= dirs.js.src %>/codemirror/codemirror_placeholder.js",
57 "<%= dirs.js.src %>/codemirror/codemirror_placeholder.js",
57 "<%= dirs.js.dest %>/mode/meta.js",
58 "<%= dirs.js.dest %>/mode/meta.js",
58 "<%= dirs.js.dest %>/mode/meta_ext.js",
59 "<%= dirs.js.dest %>/mode/meta_ext.js",
59 "<%= dirs.js.dest %>/rhodecode/i18n/select2/translations.js",
60 "<%= dirs.js.dest %>/rhodecode/i18n/select2/translations.js",
60 "<%= dirs.js.src %>/rhodecode/utils/array.js",
61 "<%= dirs.js.src %>/rhodecode/utils/array.js",
61 "<%= dirs.js.src %>/rhodecode/utils/string.js",
62 "<%= dirs.js.src %>/rhodecode/utils/string.js",
62 "<%= dirs.js.src %>/rhodecode/utils/pyroutes.js",
63 "<%= dirs.js.src %>/rhodecode/utils/pyroutes.js",
63 "<%= dirs.js.src %>/rhodecode/utils/ajax.js",
64 "<%= dirs.js.src %>/rhodecode/utils/ajax.js",
64 "<%= dirs.js.src %>/rhodecode/utils/autocomplete.js",
65 "<%= dirs.js.src %>/rhodecode/utils/autocomplete.js",
65 "<%= dirs.js.src %>/rhodecode/utils/colorgenerator.js",
66 "<%= dirs.js.src %>/rhodecode/utils/colorgenerator.js",
66 "<%= dirs.js.src %>/rhodecode/utils/ie.js",
67 "<%= dirs.js.src %>/rhodecode/utils/ie.js",
67 "<%= dirs.js.src %>/rhodecode/utils/os.js",
68 "<%= dirs.js.src %>/rhodecode/utils/os.js",
68 "<%= dirs.js.src %>/rhodecode/utils/topics.js",
69 "<%= dirs.js.src %>/rhodecode/utils/topics.js",
69 "<%= dirs.js.src %>/rhodecode/widgets/multiselect.js",
70 "<%= dirs.js.src %>/rhodecode/widgets/multiselect.js",
70 "<%= dirs.js.src %>/rhodecode/init.js",
71 "<%= dirs.js.src %>/rhodecode/init.js",
71 "<%= dirs.js.src %>/rhodecode/codemirror.js",
72 "<%= dirs.js.src %>/rhodecode/codemirror.js",
72 "<%= dirs.js.src %>/rhodecode/comments.js",
73 "<%= dirs.js.src %>/rhodecode/comments.js",
73 "<%= dirs.js.src %>/rhodecode/constants.js",
74 "<%= dirs.js.src %>/rhodecode/constants.js",
74 "<%= dirs.js.src %>/rhodecode/files.js",
75 "<%= dirs.js.src %>/rhodecode/files.js",
75 "<%= dirs.js.src %>/rhodecode/followers.js",
76 "<%= dirs.js.src %>/rhodecode/followers.js",
76 "<%= dirs.js.src %>/rhodecode/menus.js",
77 "<%= dirs.js.src %>/rhodecode/menus.js",
77 "<%= dirs.js.src %>/rhodecode/notifications.js",
78 "<%= dirs.js.src %>/rhodecode/notifications.js",
78 "<%= dirs.js.src %>/rhodecode/permissions.js",
79 "<%= dirs.js.src %>/rhodecode/permissions.js",
79 "<%= dirs.js.src %>/rhodecode/pjax.js",
80 "<%= dirs.js.src %>/rhodecode/pjax.js",
80 "<%= dirs.js.src %>/rhodecode/pullrequests.js",
81 "<%= dirs.js.src %>/rhodecode/pullrequests.js",
81 "<%= dirs.js.src %>/rhodecode/settings.js",
82 "<%= dirs.js.src %>/rhodecode/settings.js",
82 "<%= dirs.js.src %>/rhodecode/select2_widgets.js",
83 "<%= dirs.js.src %>/rhodecode/select2_widgets.js",
83 "<%= dirs.js.src %>/rhodecode/tooltips.js",
84 "<%= dirs.js.src %>/rhodecode/tooltips.js",
84 "<%= dirs.js.src %>/rhodecode/users.js",
85 "<%= dirs.js.src %>/rhodecode/users.js",
85 "<%= dirs.js.src %>/rhodecode/appenlight.js",
86 "<%= dirs.js.src %>/rhodecode/appenlight.js",
86 "<%= dirs.js.src %>/rhodecode.js"
87 "<%= dirs.js.src %>/rhodecode.js"
87 ],
88 ],
88 "dest": "<%= dirs.js.dest %>/scripts.js",
89 "dest": "<%= dirs.js.dest %>/scripts.js",
89 "nonull": true
90 "nonull": true
90 }
91 }
91 },
92 },
92 "crisper": {
93 "crisper": {
93 "dist": {
94 "dist": {
94 "options": {
95 "options": {
95 "cleanup": false,
96 "cleanup": false,
96 "onlySplit": true
97 "onlySplit": true
97 },
98 },
98 "src": "<%= dirs.js.dest %>/rhodecode-components.html",
99 "src": "<%= dirs.js.dest %>/rhodecode-components.html",
99 "dest": "<%= dirs.js.dest %>/rhodecode-components.js"
100 "dest": "<%= dirs.js.dest %>/rhodecode-components.js"
100 }
101 }
101 },
102 },
102 "less": {
103 "less": {
103 "development": {
104 "development": {
104 "options": {
105 "options": {
105 "compress": false,
106 "compress": false,
106 "yuicompress": false,
107 "yuicompress": false,
107 "optimization": 0
108 "optimization": 0
108 },
109 },
109 "files": {
110 "files": {
110 "<%= dirs.css.dest %>/style.css": "<%= dirs.css.src %>/main.less",
111 "<%= dirs.css.dest %>/style.css": "<%= dirs.css.src %>/main.less",
111 "<%= dirs.css.dest %>/style-polymer.css": "<%= dirs.css.src %>/polymer.less"
112 "<%= dirs.css.dest %>/style-polymer.css": "<%= dirs.css.src %>/polymer.less"
112 }
113 }
113 },
114 },
114 "production": {
115 "production": {
115 "options": {
116 "options": {
116 "compress": true,
117 "compress": true,
117 "yuicompress": true,
118 "yuicompress": true,
118 "optimization": 2
119 "optimization": 2
119 },
120 },
120 "files": {
121 "files": {
121 "<%= dirs.css.dest %>/style.css": "<%= dirs.css.src %>/main.less",
122 "<%= dirs.css.dest %>/style.css": "<%= dirs.css.src %>/main.less",
122 "<%= dirs.css.dest %>/style-polymer.css": "<%= dirs.css.src %>/polymer.less"
123 "<%= dirs.css.dest %>/style-polymer.css": "<%= dirs.css.src %>/polymer.less"
123 }
124 }
124 },
125 },
125 "components": {
126 "components": {
126 "files": [
127 "files": [
127 {
128 {
128 "cwd": "<%= dirs.js.src %>/components/",
129 "cwd": "<%= dirs.js.src %>/components/",
129 "dest": "<%= dirs.js.src %>/components/",
130 "dest": "<%= dirs.js.src %>/components/",
130 "src": [
131 "src": [
131 "**/*.less"
132 "**/*.less"
132 ],
133 ],
133 "expand": true,
134 "expand": true,
134 "ext": ".css"
135 "ext": ".css"
135 }
136 }
136 ]
137 ]
137 }
138 }
138 },
139 },
139 "watch": {
140 "watch": {
140 "less": {
141 "less": {
141 "files": [
142 "files": [
142 "<%= dirs.css.src %>/**/*.less",
143 "<%= dirs.css.src %>/**/*.less",
143 "<%= dirs.js.src %>/components/**/*.less"
144 "<%= dirs.js.src %>/components/**/*.less"
144 ],
145 ],
145 "tasks": [
146 "tasks": [
146 "less:development",
147 "less:development",
147 "less:components",
148 "less:components",
148 "concat:polymercss",
149 "concat:polymercss",
149 "vulcanize",
150 "vulcanize",
150 "crisper",
151 "crisper",
151 "concat:dist"
152 "concat:dist"
152 ]
153 ]
153 },
154 },
154 "js": {
155 "js": {
155 "files": [
156 "files": [
156 "!<%= dirs.js.src %>/components/root-styles.gen.html",
157 "!<%= dirs.js.src %>/components/root-styles.gen.html",
157 "<%= dirs.js.src %>/**/*.js",
158 "<%= dirs.js.src %>/**/*.js",
158 "<%= dirs.js.src %>/components/**/*.html"
159 "<%= dirs.js.src %>/components/**/*.html"
159 ],
160 ],
160 "tasks": [
161 "tasks": [
161 "less:components",
162 "less:components",
162 "concat:polymercss",
163 "concat:polymercss",
163 "vulcanize",
164 "vulcanize",
164 "crisper",
165 "crisper",
165 "concat:dist"
166 "concat:dist"
166 ]
167 ]
167 }
168 }
168 },
169 },
169 "jshint": {
170 "jshint": {
170 "rhodecode": {
171 "rhodecode": {
171 "src": "<%= dirs.js.src %>/rhodecode/**/*.js",
172 "src": "<%= dirs.js.src %>/rhodecode/**/*.js",
172 "options": {
173 "options": {
173 "jshintrc": ".jshintrc"
174 "jshintrc": ".jshintrc"
174 }
175 }
175 }
176 }
176 },
177 },
177 "vulcanize": {
178 "vulcanize": {
178 "default": {
179 "default": {
179 "options": {
180 "options": {
180 "abspath": "",
181 "abspath": "",
181 "inlineScripts": true,
182 "inlineScripts": true,
182 "inlineCss": true,
183 "inlineCss": true,
183 "stripComments": true
184 "stripComments": true
184 },
185 },
185 "files": {
186 "files": {
186 "<%= dirs.js.dest %>/rhodecode-components.html": "<%= dirs.js.src %>/components/shared-components.html"
187 "<%= dirs.js.dest %>/rhodecode-components.html": "<%= dirs.js.src %>/components/shared-components.html"
187 }
188 }
188 }
189 }
189 }
190 }
190 }
191 }
@@ -1,15 +1,18 b''
1 <link rel="import" href="../../../../../../bower_components/polymer/polymer.html">
1 <link rel="import" href="../../../../../../bower_components/polymer/polymer.html">
2 <link rel="import" href="../channelstream-connection/channelstream-connection.html">
2 <link rel="import" href="../channelstream-connection/channelstream-connection.html">
3 <link rel="import" href="../rhodecode-toast/rhodecode-toast.html">
4 <link rel="import" href="../rhodecode-favicon/rhodecode-favicon.html">
3
5
4 <dom-module id="rhodecode-app">
6 <dom-module id="rhodecode-app">
5 <template>
7 <template>
8 <rhodecode-favicon></rhodecode-favicon>
6 <rhodecode-toast id="notifications"></rhodecode-toast>
9 <rhodecode-toast id="notifications"></rhodecode-toast>
7 <channelstream-connection
10 <channelstream-connection
8 id="channelstream-connection"
11 id="channelstream-connection"
9 on-channelstream-listen-message="receivedMessage"
12 on-channelstream-listen-message="receivedMessage"
10 on-channelstream-connected="handleConnected"
13 on-channelstream-connected="handleConnected"
11 on-channelstream-subscribed="handleSubscribed">
14 on-channelstream-subscribed="handleSubscribed">
12 </channelstream-connection>
15 </channelstream-connection>
13 </template>
16 </template>
14 <script src="rhodecode-app.js"></script>
17 <script src="rhodecode-app.js"></script>
15 </dom-module>
18 </dom-module>
@@ -1,132 +1,137 b''
1 ccLog = Logger.get('RhodeCodeApp');
1 ccLog = Logger.get('RhodeCodeApp');
2 ccLog.setLevel(Logger.OFF);
2 ccLog.setLevel(Logger.OFF);
3
3
4 var rhodeCodeApp = Polymer({
4 var rhodeCodeApp = Polymer({
5 is: 'rhodecode-app',
5 is: 'rhodecode-app',
6 attached: function () {
6 attached: function () {
7 ccLog.debug('rhodeCodeApp created');
7 ccLog.debug('rhodeCodeApp created');
8 $.Topic('/notifications').subscribe(this.handleNotifications.bind(this));
8 $.Topic('/notifications').subscribe(this.handleNotifications.bind(this));
9 $.Topic('/favicon/update').subscribe(this.faviconUpdate.bind(this));
9 $.Topic('/connection_controller/subscribe').subscribe(
10 $.Topic('/connection_controller/subscribe').subscribe(
10 this.subscribeToChannelTopic.bind(this));
11 this.subscribeToChannelTopic.bind(this));
11 // this event can be used to coordinate plugins to do their
12 // this event can be used to coordinate plugins to do their
12 // initialization before channelstream is kicked off
13 // initialization before channelstream is kicked off
13 $.Topic('/__MAIN_APP__').publish({});
14 $.Topic('/__MAIN_APP__').publish({});
14
15
15 for (var i = 0; i < alertMessagePayloads.length; i++) {
16 for (var i = 0; i < alertMessagePayloads.length; i++) {
16 $.Topic('/notifications').publish(alertMessagePayloads[i]);
17 $.Topic('/notifications').publish(alertMessagePayloads[i]);
17 }
18 }
18 this.kickoffChannelstreamPlugin();
19 this.kickoffChannelstreamPlugin();
19 },
20 },
20
21
21 /** proxy to channelstream connection */
22 /** proxy to channelstream connection */
22 getChannelStreamConnection: function () {
23 getChannelStreamConnection: function () {
23 return this.$['channelstream-connection'];
24 return this.$['channelstream-connection'];
24 },
25 },
25
26
26 handleNotifications: function (data) {
27 handleNotifications: function (data) {
27 this.$['notifications'].handleNotification(data);
28 this.$['notifications'].handleNotification(data);
28 },
29 },
29
30
31 faviconUpdate: function (data) {
32 this.$$('rhodecode-favicon').counter = data.count;
33 },
34
30 /** opens connection to ws server */
35 /** opens connection to ws server */
31 kickoffChannelstreamPlugin: function (data) {
36 kickoffChannelstreamPlugin: function (data) {
32 ccLog.debug('kickoffChannelstreamPlugin');
37 ccLog.debug('kickoffChannelstreamPlugin');
33 var channels = ['broadcast'];
38 var channels = ['broadcast'];
34 var addChannels = this.checkViewChannels();
39 var addChannels = this.checkViewChannels();
35 for (var i = 0; i < addChannels.length; i++) {
40 for (var i = 0; i < addChannels.length; i++) {
36 channels.push(addChannels[i]);
41 channels.push(addChannels[i]);
37 }
42 }
38 if (window.CHANNELSTREAM_SETTINGS && CHANNELSTREAM_SETTINGS.enabled){
43 if (window.CHANNELSTREAM_SETTINGS && CHANNELSTREAM_SETTINGS.enabled){
39 var channelstreamConnection = this.getChannelStreamConnection();
44 var channelstreamConnection = this.getChannelStreamConnection();
40 channelstreamConnection.connectUrl = CHANNELSTREAM_URLS.connect;
45 channelstreamConnection.connectUrl = CHANNELSTREAM_URLS.connect;
41 channelstreamConnection.subscribeUrl = CHANNELSTREAM_URLS.subscribe;
46 channelstreamConnection.subscribeUrl = CHANNELSTREAM_URLS.subscribe;
42 channelstreamConnection.websocketUrl = CHANNELSTREAM_URLS.ws + '/ws';
47 channelstreamConnection.websocketUrl = CHANNELSTREAM_URLS.ws + '/ws';
43 channelstreamConnection.longPollUrl = CHANNELSTREAM_URLS.longpoll + '/listen';
48 channelstreamConnection.longPollUrl = CHANNELSTREAM_URLS.longpoll + '/listen';
44 // some channels might already be registered by topic
49 // some channels might already be registered by topic
45 for (var i = 0; i < channels.length; i++) {
50 for (var i = 0; i < channels.length; i++) {
46 channelstreamConnection.push('channels', channels[i]);
51 channelstreamConnection.push('channels', channels[i]);
47 }
52 }
48 // append any additional channels registered in other plugins
53 // append any additional channels registered in other plugins
49 $.Topic('/connection_controller/subscribe').processPrepared();
54 $.Topic('/connection_controller/subscribe').processPrepared();
50 channelstreamConnection.connect();
55 channelstreamConnection.connect();
51 }
56 }
52 },
57 },
53
58
54 checkViewChannels: function () {
59 checkViewChannels: function () {
55 var channels = []
60 var channels = []
56 // subscribe to PR repo channel for PR's'
61 // subscribe to PR repo channel for PR's'
57 if (templateContext.pull_request_data.pull_request_id) {
62 if (templateContext.pull_request_data.pull_request_id) {
58 var channelName = '/repo$' + templateContext.repo_name + '$/pr/' +
63 var channelName = '/repo$' + templateContext.repo_name + '$/pr/' +
59 String(templateContext.pull_request_data.pull_request_id);
64 String(templateContext.pull_request_data.pull_request_id);
60 channels.push(channelName);
65 channels.push(channelName);
61 }
66 }
62 return channels;
67 return channels;
63 },
68 },
64
69
65 /** subscribes users from channels in channelstream */
70 /** subscribes users from channels in channelstream */
66 subscribeToChannelTopic: function (channels) {
71 subscribeToChannelTopic: function (channels) {
67 var channelstreamConnection = this.$['channelstream-connection'];
72 var channelstreamConnection = this.$['channelstream-connection'];
68 var toSubscribe = channelstreamConnection.calculateSubscribe(channels);
73 var toSubscribe = channelstreamConnection.calculateSubscribe(channels);
69 ccLog.debug('subscribeToChannelTopic', toSubscribe);
74 ccLog.debug('subscribeToChannelTopic', toSubscribe);
70 if (toSubscribe.length > 0) {
75 if (toSubscribe.length > 0) {
71 // if we are connected then subscribe
76 // if we are connected then subscribe
72 if (channelstreamConnection.connected) {
77 if (channelstreamConnection.connected) {
73 channelstreamConnection.subscribe(toSubscribe);
78 channelstreamConnection.subscribe(toSubscribe);
74 }
79 }
75 // not connected? just push channels onto the stack
80 // not connected? just push channels onto the stack
76 else {
81 else {
77 for (var i = 0; i < toSubscribe.length; i++) {
82 for (var i = 0; i < toSubscribe.length; i++) {
78 channelstreamConnection.push('channels', toSubscribe[i]);
83 channelstreamConnection.push('channels', toSubscribe[i]);
79 }
84 }
80 }
85 }
81 }
86 }
82 },
87 },
83
88
84 /** publish received messages into correct topic */
89 /** publish received messages into correct topic */
85 receivedMessage: function (event) {
90 receivedMessage: function (event) {
86 for (var i = 0; i < event.detail.length; i++) {
91 for (var i = 0; i < event.detail.length; i++) {
87 var message = event.detail[i];
92 var message = event.detail[i];
88 if (message.message.topic) {
93 if (message.message.topic) {
89 ccLog.debug('publishing', message.message.topic);
94 ccLog.debug('publishing', message.message.topic);
90 $.Topic(message.message.topic).publish(message);
95 $.Topic(message.message.topic).publish(message);
91 }
96 }
92 else if (message.type === 'presence'){
97 else if (message.type === 'presence'){
93 $.Topic('/connection_controller/presence').publish(message);
98 $.Topic('/connection_controller/presence').publish(message);
94 }
99 }
95 else {
100 else {
96 ccLog.warn('unhandled message', message);
101 ccLog.warn('unhandled message', message);
97 }
102 }
98 }
103 }
99 },
104 },
100
105
101 handleConnected: function (event) {
106 handleConnected: function (event) {
102 var channelstreamConnection = this.$['channelstream-connection'];
107 var channelstreamConnection = this.$['channelstream-connection'];
103 channelstreamConnection.set('channelsState',
108 channelstreamConnection.set('channelsState',
104 event.detail.channels_info);
109 event.detail.channels_info);
105 channelstreamConnection.set('userState', event.detail.state);
110 channelstreamConnection.set('userState', event.detail.state);
106 channelstreamConnection.set('channels', event.detail.channels);
111 channelstreamConnection.set('channels', event.detail.channels);
107 this.propagageChannelsState();
112 this.propagageChannelsState();
108 },
113 },
109 handleSubscribed: function (event) {
114 handleSubscribed: function (event) {
110 var channelstreamConnection = this.$['channelstream-connection'];
115 var channelstreamConnection = this.$['channelstream-connection'];
111 var channelInfo = event.detail.channels_info;
116 var channelInfo = event.detail.channels_info;
112 var channelKeys = Object.keys(event.detail.channels_info);
117 var channelKeys = Object.keys(event.detail.channels_info);
113 for (var i = 0; i < channelKeys.length; i++) {
118 for (var i = 0; i < channelKeys.length; i++) {
114 var key = channelKeys[i];
119 var key = channelKeys[i];
115 channelstreamConnection.set(['channelsState', key], channelInfo[key]);
120 channelstreamConnection.set(['channelsState', key], channelInfo[key]);
116 }
121 }
117 channelstreamConnection.set('channels', event.detail.channels);
122 channelstreamConnection.set('channels', event.detail.channels);
118 this.propagageChannelsState();
123 this.propagageChannelsState();
119 },
124 },
120 /** propagates channel states on topics */
125 /** propagates channel states on topics */
121 propagageChannelsState: function (event) {
126 propagageChannelsState: function (event) {
122 var channelstreamConnection = this.$['channelstream-connection'];
127 var channelstreamConnection = this.$['channelstream-connection'];
123 var channel_data = channelstreamConnection.channelsState;
128 var channel_data = channelstreamConnection.channelsState;
124 var channels = channelstreamConnection.channels;
129 var channels = channelstreamConnection.channels;
125 for (var i = 0; i < channels.length; i++) {
130 for (var i = 0; i < channels.length; i++) {
126 var key = channels[i];
131 var key = channels[i];
127 $.Topic('/connection_controller/channel_update').publish(
132 $.Topic('/connection_controller/channel_update').publish(
128 {channel: key, state: channel_data[key]}
133 {channel: key, state: channel_data[key]}
129 );
134 );
130 }
135 }
131 }
136 }
132 });
137 });
@@ -1,38 +1,40 b''
1 Polymer({
1 Polymer({
2 is: 'rhodecode-toast',
2 is: 'rhodecode-toast',
3 properties: {
3 properties: {
4 toasts: {
4 toasts: {
5 type: Array,
5 type: Array,
6 value: function(){
6 value: function(){
7 return []
7 return []
8 }
8 }
9 }
9 }
10 },
10 },
11 observers: [
11 observers: [
12 '_changedToasts(toasts.splices)'
12 '_changedToasts(toasts.splices)'
13 ],
13 ],
14 _changedToasts: function(newValue, oldValue){
14 _changedToasts: function(newValue, oldValue){
15 this.$['p-toast'].notifyResize();
15 this.$['p-toast'].notifyResize();
16 $.Topic('/favicon/update').publish({count: this.toasts.length});
16 },
17 },
17 dismissNotifications: function(){
18 dismissNotifications: function(){
18 this.$['p-toast'].close();
19 this.$['p-toast'].close();
20 $.Topic('/favicon/update').publish({count: 0});
19 },
21 },
20 handleClosed: function(){
22 handleClosed: function(){
21 this.splice('toasts', 0);
23 this.splice('toasts', 0);
22 },
24 },
23 open: function(){
25 open: function(){
24 this.$['p-toast'].open();
26 this.$['p-toast'].open();
25 },
27 },
26 handleNotification: function(data){
28 handleNotification: function(data){
27 if (!templateContext.rhodecode_user.notification_status && !data.message.force) {
29 if (!templateContext.rhodecode_user.notification_status && !data.message.force) {
28 // do not act if notifications are disabled
30 // do not act if notifications are disabled
29 return
31 return
30 }
32 }
31 this.push('toasts',{
33 this.push('toasts',{
32 level: data.message.level,
34 level: data.message.level,
33 message: data.message.message
35 message: data.message.message
34 });
36 });
35 this.open();
37 this.open();
36 },
38 },
37 _gettext: _gettext
39 _gettext: _gettext
38 });
40 });
@@ -1,8 +1,9 b''
1 /__MAIN_APP__ - launched when rhodecode-app element is attached to DOM
1 /__MAIN_APP__ - launched when rhodecode-app element is attached to DOM
2 /plugins/__REGISTER__ - launched after the onDomReady() code from rhodecode.js is executed
2 /plugins/__REGISTER__ - launched after the onDomReady() code from rhodecode.js is executed
3 /ui/plugins/code/anchor_focus - launched when rc starts to scroll on load to anchor on PR/Codeview
3 /ui/plugins/code/anchor_focus - launched when rc starts to scroll on load to anchor on PR/Codeview
4 /ui/plugins/code/comment_form_built - launched when injectInlineForm() is executed and the form object is created
4 /ui/plugins/code/comment_form_built - launched when injectInlineForm() is executed and the form object is created
5 /notifications - shows new event notifications
5 /notifications - shows new event notifications
6 /connection_controller/subscribe - subscribes user to new channels
6 /connection_controller/subscribe - subscribes user to new channels
7 /connection_controller/presence - receives presence change messages
7 /connection_controller/presence - receives presence change messages
8 /connection_controller/channel_update - receives channel states
8 /connection_controller/channel_update - receives channel states
9 /favicon/update - notify state change for favicon
General Comments 0
You need to be logged in to leave comments. Login now