@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a very basic "Realtime" log to DarkConsole

Summary: Ref T12568. This begins building toward a more useful realtime debugging console for Leader/Aphlict/general realtime stuff.

Test Plan: {F4911521}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12568

Differential Revision: https://secure.phabricator.com/D17701

+210 -3
+2
src/__phutil_library_map__.php
··· 349 349 'DarkConsoleEventPlugin' => 'applications/console/plugin/DarkConsoleEventPlugin.php', 350 350 'DarkConsoleEventPluginAPI' => 'applications/console/plugin/event/DarkConsoleEventPluginAPI.php', 351 351 'DarkConsolePlugin' => 'applications/console/plugin/DarkConsolePlugin.php', 352 + 'DarkConsoleRealtimePlugin' => 'applications/console/plugin/DarkConsoleRealtimePlugin.php', 352 353 'DarkConsoleRequestPlugin' => 'applications/console/plugin/DarkConsoleRequestPlugin.php', 353 354 'DarkConsoleServicesPlugin' => 'applications/console/plugin/DarkConsoleServicesPlugin.php', 354 355 'DarkConsoleStartupPlugin' => 'applications/console/plugin/DarkConsoleStartupPlugin.php', ··· 5144 5145 'DarkConsoleEventPlugin' => 'DarkConsolePlugin', 5145 5146 'DarkConsoleEventPluginAPI' => 'PhabricatorEventListener', 5146 5147 'DarkConsolePlugin' => 'Phobject', 5148 + 'DarkConsoleRealtimePlugin' => 'DarkConsolePlugin', 5147 5149 'DarkConsoleRequestPlugin' => 'DarkConsolePlugin', 5148 5150 'DarkConsoleServicesPlugin' => 'DarkConsolePlugin', 5149 5151 'DarkConsoleStartupPlugin' => 'DarkConsolePlugin',
+26
src/applications/console/plugin/DarkConsoleRealtimePlugin.php
··· 1 + <?php 2 + 3 + final class DarkConsoleRealtimePlugin extends DarkConsolePlugin { 4 + 5 + public function getName() { 6 + return pht('Realtime'); 7 + } 8 + 9 + public function getColor() { 10 + return null; 11 + } 12 + 13 + public function getDescription() { 14 + return pht('Debugging console for real-time notifications.'); 15 + } 16 + 17 + public function renderPanel() { 18 + return phutil_tag( 19 + 'div', 20 + array( 21 + 'id' => 'dark-console-realtime-log', 22 + 'class' => 'dark-console-log-frame', 23 + )); 24 + } 25 + 26 + }
+14
webroot/rsrc/css/aphront/dark-console.css
··· 217 217 .dark-console-panel-error-details { 218 218 display: none; 219 219 } 220 + 221 + .dark-console-log-frame { 222 + height: 500px; 223 + overflow: auto; 224 + background: #303030; 225 + border: 1px solid #202020; 226 + margin: 4px; 227 + } 228 + 229 + .dark-console-log-message { 230 + background: #404040; 231 + padding: 8px; 232 + margin: 2px; 233 + }
+10 -3
webroot/rsrc/js/application/aphlict/behavior-aphlict-listen.js
··· 114 114 config.websocketURI, 115 115 config.subscriptions); 116 116 117 - client 118 - .setHandler(onAphlictMessage) 119 - .start(); 117 + var start_client = function() { 118 + client 119 + .setHandler(onAphlictMessage) 120 + .start(); 121 + }; 122 + 123 + // Don't start the client until other behaviors have had a chance to 124 + // initialize. In particular, we want to capture events into the log for 125 + // the DarkConsole "Realtime" panel. 126 + setTimeout(start_client, 0); 120 127 121 128 JX.Stratcom.listen( 122 129 'quicksand-redraw',
+74
webroot/rsrc/js/core/behavior-dark-console.js webroot/rsrc/js/core/darkconsole/behavior-dark-console.js
··· 6 6 * javelin-dom 7 7 * javelin-request 8 8 * phabricator-keyboard-shortcut 9 + * phabricator-darklog 10 + * phabricator-darkmessage 9 11 */ 10 12 11 13 JX.behavior('dark-console', function(config, statics) { ··· 246 248 247 249 var div = JX.$N('div', {className: 'dark-console-panel-core'}, JX.$H(html)); 248 250 JX.DOM.setContent(statics.el.panel, div); 251 + 252 + var params = { 253 + panel: tclass 254 + }; 255 + 256 + JX.Stratcom.invoke('darkconsole.draw', null, params); 249 257 } 250 258 251 259 function install_shortcut() { ··· 286 294 config.color = statics.root.getAttribute('data-console-color'); 287 295 } 288 296 add_request(config); 297 + 298 + 299 + /* -( Realtime Panel )----------------------------------------------------- */ 300 + 301 + 302 + if (!statics.realtime) { 303 + statics.realtime = true; 304 + 305 + var realtime_log = new JX.DarkLog(); 306 + var realtime_id = 'dark-console-realtime-log'; 307 + 308 + JX.Stratcom.listen('darkconsole.draw', null, function(e) { 309 + var data = e.getData(); 310 + if (data.panel != 'DarkConsoleRealtimePlugin') { 311 + return; 312 + } 313 + 314 + var node = JX.$(realtime_id); 315 + realtime_log.setNode(node); 316 + }); 317 + 318 + // If the panel is initially visible, try rendering. 319 + try { 320 + var node = JX.$(realtime_id); 321 + realtime_log.setNode(node); 322 + } catch (exception) { 323 + // Ignore. 324 + } 325 + 326 + var leader_log = function(event_name, type, is_leader, details) { 327 + var parts = []; 328 + if (is_leader === true) { 329 + parts.push('+'); 330 + } else if (is_leader === false) { 331 + parts.push('-'); 332 + } else { 333 + parts.push('~'); 334 + } 335 + 336 + parts.push('[Leader/' + event_name + ']'); 337 + 338 + if (type) { 339 + parts.push('(' + type + ')'); 340 + } 341 + 342 + if (details) { 343 + parts.push(details); 344 + } 345 + 346 + parts = parts.join(' '); 347 + 348 + var message = new JX.DarkMessage() 349 + .setMessage(parts); 350 + 351 + realtime_log.addMessage(message); 352 + }; 353 + 354 + JX.Leader.listen('onReceiveBroadcast', function(message, is_leader) { 355 + var json = JX.JSON.stringify(message.data); 356 + leader_log('onReceiveBroadcast', message.type, is_leader, json); 357 + }); 358 + 359 + JX.Leader.listen('onBecomeLeader', function() { 360 + leader_log('onBecomeLeader'); 361 + }); 362 + } 289 363 290 364 });
+47
webroot/rsrc/js/core/darkconsole/DarkLog.js
··· 1 + /** 2 + * @provides phabricator-darklog 3 + * @javelin 4 + */ 5 + 6 + JX.install('DarkLog', { 7 + 8 + construct: function() { 9 + this._messages = []; 10 + }, 11 + 12 + members: { 13 + _node: null, 14 + _messages: null, 15 + 16 + addMessage: function(message) { 17 + var node = message.getNode(); 18 + 19 + this._messages.push(message); 20 + if (this._node) { 21 + this._append([node]); 22 + } 23 + 24 + return this; 25 + }, 26 + 27 + setNode: function(node) { 28 + var nodes = []; 29 + for (var ii = 0; ii < this._messages.length; ii++) { 30 + nodes.push(this._messages[ii].getNode()); 31 + } 32 + 33 + this._node = node; 34 + this._append(nodes); 35 + 36 + return this; 37 + }, 38 + 39 + _append: function(nodes) { 40 + for (var ii = 0; ii < nodes.length; ii++) { 41 + this._node.appendChild(nodes[ii]); 42 + } 43 + } 44 + 45 + } 46 + 47 + });
+37
webroot/rsrc/js/core/darkconsole/DarkMessage.js
··· 1 + /** 2 + * @provides phabricator-darkmessage 3 + * @javelin 4 + */ 5 + 6 + JX.install('DarkMessage', { 7 + 8 + construct: function() { 9 + 10 + }, 11 + 12 + members: { 13 + _node: null, 14 + _message: null, 15 + 16 + setMessage: function(message) { 17 + this._message = message; 18 + 19 + JX.DOM.setContent(this.getNode(), message); 20 + 21 + return this; 22 + }, 23 + 24 + getNode: function() { 25 + if (!this._node) { 26 + this._node = JX.$N( 27 + 'div', 28 + { 29 + className: 'dark-console-log-message' 30 + }); 31 + } 32 + 33 + return this._node; 34 + } 35 + } 36 + 37 + });