-
Notifications
You must be signed in to change notification settings - Fork 530
Expand file tree
/
Copy pathNetSimStatusPanel.js
More file actions
76 lines (65 loc) · 2.16 KB
/
Copy pathNetSimStatusPanel.js
File metadata and controls
76 lines (65 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* @overview UI component: The small expandable box above the visualization,
* used to show debug and diagnostic information.
*/
require('../utils'); // For Function.prototype.inherits()
import $ from 'jquery';
var i18n = require('@cdo/netsim/locale');
var NetSimPanel = require('./NetSimPanel.js');
var markup = require('./NetSimStatusPanel.html.ejs');
var NetSimUtils = require('./NetSimUtils');
/**
* Generator and controller for connection status panel
* in left column, displayed while connected.
* @param {jQuery} rootDiv
* @param {Object} callbacks
* @param {function} callbacks.disconnectCallback - method to call when disconnect button
* is clicked.
* @constructor
* @augments NetSimPanel
*/
var NetSimStatusPanel = (module.exports = function (rootDiv, callbacks) {
/**
* @type {function}
* @private
*/
this.disconnectCallback_ = callbacks.disconnectCallback;
// Superclass constructor
NetSimPanel.call(this, rootDiv, {
className: 'netsim_status_panel',
panelTitle: 'Status',
userToggleable: false,
beginMinimized: true,
});
});
NetSimStatusPanel.inherits(NetSimPanel);
/**
* @param {Object} [data]
* @param {string} [data.remoteNodeName] - Display name of remote node.
* @param {string} [data.myHostname] - Hostname of local node
* @param {number} [data.myAddress] - Local node address assigned by router
* @param {string} [data.shareLink] - URL for sharing private shard
*/
NetSimStatusPanel.prototype.render = function (data) {
data = data || {};
// Capture title before we render the wrapper panel.
this.setPanelTitle(data.remoteNodeName);
// Render boilerplate panel stuff
NetSimStatusPanel.superPrototype.render.call(this);
// Put our own content into the panel body
var newMarkup = $(
markup({
myHostname: data.myHostname,
myAddress: data.myAddress,
shareLink: data.shareLink,
})
);
this.getBody().html(newMarkup);
// Add a button to the panel header
this.addButton(
i18n.disconnectButton({caret: '<i class="fa-solid fa-caret-left"></i>'}),
this.disconnectCallback_
);
// Button that takes you to the next level.
NetSimUtils.makeContinueButton(this);
};