luci-app-ttyd: add option for UNIX socket and URL override
[project/luci.git] / applications / luci-app-ttyd / htdocs / luci-static / resources / view / ttyd / term.js
1 'use strict';
2 'require view';
3 'require uci';
4
5 return view.extend({
6 load: function() {
7 return uci.load('ttyd');
8 },
9 render: function() {
10 var port = uci.get_first('ttyd', 'ttyd', 'port') || '7681',
11 ssl = uci.get_first('ttyd', 'ttyd', 'ssl') || '0',
12 url = uci.get_first('ttyd', 'ttyd', 'url_override');
13 if (port === '0')
14 return E('div', { class: 'alert-message warning' },
15 _('Random ttyd port (port=0) is not supported.<br />Change to a fixed port and try again.'));
16 return E('iframe', {
17 src: url || ((ssl === '1' ? 'https' : 'http') + '://' + window.location.hostname + ':' + port),
18 style: 'width: 100%; min-height: 500px; border: none; border-radius: 3px; resize: vertical;'
19 });
20 },
21 handleSaveApply: null,
22 handleSave: null,
23 handleReset: null
24 });