Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move admin templates to compiled handlebars #1255

Merged
merged 2 commits into from
Nov 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
/js/tests/*
/js/vendor/*
/js/simplewebrtc.js
/js/**/templates.js
/karma.conf.js
/tests/*
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ install-npm-deps:
install-npm-deps-dev:
npm install --deps

build-js-templates:
handlebars -n OCA.VideoCalls.Admin.Templates js/admin/templates/ -f js/admin/templates.js

dev-setup: install-npm-deps-dev

appstore: clean install-deps
Expand Down Expand Up @@ -78,3 +81,4 @@ appstore: clean install-deps
openssl dgst -sha512 -sign $(cert_dir)/$(app_name).key $(build_dir)/$(app_name)-$(version).tar.gz | openssl base64; \
fi


25 changes: 12 additions & 13 deletions js/admin/signaling-server.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
/* global OC, OCP, OCA, $, _, Handlebars */
/* global OC, OCP, OCA, $, _ */

(function(OC, OCP, OCA, $, _, Handlebars) {
(function(OC, OCP, OCA, $, _) {
'use strict';

OCA.VideoCalls = OCA.VideoCalls || {};
OCA.VideoCalls.Admin = OCA.VideoCalls.Admin || {};
OCA.VideoCalls.Admin.SignalingServer = {

TEMPLATE: '<div class="signaling-server">' +
' <input type="text" class="server" placeholder="wss://signaling.example.org" value="{{server}}" aria-label="' + t('spreed', 'Signaling server URL') + '">' +
' <input type="checkbox" id="verify{{seed}}" name="verify{{seed}}" class="checkbox verify" value="1" {{#if verify}} checked="checked"{{/if}}>' +
' <label for="verify{{seed}}">' + t('spreed', 'Validate SSL certificate') + '</label>' +
' <a class="icon icon-delete" title="' + t('spreed', 'Delete server') + '"></a>' +
' <a class="icon icon-add" title="' + t('spreed', 'Add new server') + '"></a>' +
' <span class="icon icon-checkmark-color hidden" title="' + t('spreed', 'Saved') + '"></span>' +
'</div>',
$list: undefined,
$secret: undefined,
template: undefined,
seed: 0,

init: function() {
this.template = Handlebars.compile(this.TEMPLATE);
this.template = OCA.VideoCalls.Admin.Templates['signaling-server'];
this.$list = $('div.signaling-servers');
this.$secret = $('#signaling_secret');
this.renderList();
Expand Down Expand Up @@ -134,7 +126,14 @@

renderServer: function(server) {
server.seed = this.seed++;
var $template = $(this.template(server));
var $template = $(this.template(_.extend(
{
signalingServerURLTXT: t('spreed', 'Signaling server URL'),
validatingSSLTXT: t('spreed', 'Validate SSL certificate'),
deleteTXT: t('spreed', 'Delete server'),
addNewTXT: t('spreed', 'Add new server'),
savedTXT: t('spreed', 'Saved')
}, server)));

$template.find('a.icon-add').on('click', this.addNewTemplate.bind(this));
$template.find('a.icon-delete').on('click', this.deleteServer.bind(this));
Expand All @@ -146,7 +145,7 @@
};


})(OC, OCP, OCA, $, _, Handlebars);
})(OC, OCP, OCA, $, _);

$(document).ready(function(){
OCA.VideoCalls.Admin.SignalingServer.init();
Expand Down
20 changes: 9 additions & 11 deletions js/admin/stun-server.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
/* global OC, OCP, OCA, $, _, Handlebars */
/* global OC, OCP, OCA, $, _ */

(function(OC, OCP, OCA, $, _, Handlebars) {
(function(OC, OCP, OCA, $, _) {
'use strict';

OCA.VideoCalls = OCA.VideoCalls || {};
OCA.VideoCalls.Admin = OCA.VideoCalls.Admin || {};
OCA.VideoCalls.Admin.StunServer = {

TEMPLATE: '<div class="stun-server">' +
' <input type="text" name="stun_server" placeholder="stunserver:port" value="{{server}}" aria-label="' + t('spreed', 'STUN server URL') + '" />' +
' <a class="icon icon-delete" title="' + t('spreed', 'Delete server') + '"></a>' +
' <a class="icon icon-add" title="' + t('spreed', 'Add new server') + '"></a>' +
' <span class="icon icon-checkmark-color hidden" title="' + t('spreed', 'Saved') + '"></span>' +
'</div>',
$list: undefined,
template: undefined,

init: function() {
this.template = Handlebars.compile(this.TEMPLATE);
this.template = OCA.VideoCalls.Admin.Templates['stun-server'];
this.$list = $('div.stun-servers');
this.renderList();
},
Expand Down Expand Up @@ -115,7 +109,11 @@

renderServer: function(server) {
var $template = $(this.template({
server: server
server: server,
stunTXT: t('spreed', 'STUN server URL'),
deleteTXT: t('spreed', 'Delete server'),
newTXT: t('spreed', 'Add new server'),
savedTXT: t('spreed', 'Saved'),
}));

$template.find('a.icon-add').on('click', this.addNewTemplate.bind(this));
Expand All @@ -128,7 +126,7 @@
};


})(OC, OCP, OCA, $, _, Handlebars);
})(OC, OCP, OCA, $, _);

$(document).ready(function(){
OCA.VideoCalls.Admin.StunServer.init();
Expand Down
82 changes: 82 additions & 0 deletions js/admin/templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions js/admin/templates/signaling-server.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="signaling-server">
<input type="text" class="server" placeholder="wss://signaling.example.org" value="{{server}}" aria-label="{{signalingServerURLTXT}}">
<input type="checkbox" id="verify{{seed}}" name="verify{{seed}}" class="checkbox verify" value="1" {{#if verify}} checked="checked"{{/if}}>
<label for="verify{{seed}}">{{validatingSSLTXT}}</label>
<a class="icon icon-delete" title="{{deleteTXT}}"></a>
<a class="icon icon-add" title="{{addNewTXT}}"></a>
<span class="icon icon-checkmark-color hidden" title="{{savedTXT}}"></span>
</div>
6 changes: 6 additions & 0 deletions js/admin/templates/stun-server.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="stun-server">
<input type="text" name="stun_server" placeholder="stunserver:port" value="{{server}}" aria-label="{{stunTXT}}" />
<a class="icon icon-delete" title="{{deleteTXT}}"></a>
<a class="icon icon-add" title="{{newTXT}}"></a>
<span class="icon icon-checkmark-color hidden" title="{{savedTXT}}"></span>
</div>
15 changes: 15 additions & 0 deletions js/admin/templates/turn-server.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="turn-server">
<input type="text" class="server" placeholder="turn.example.org" value="{{server}}" aria-label="{{turnTXT}}">
<input type="text" class="secret" placeholder="{{sharedSecretTXT}}" value="{{secret}}" aria-label="{{sharedSecretDescTXT}}">
<select class="protocols" title="{{protocolsTXT}}">
{{#select protocols}}
<option value="udp,tcp">{{UDPTCPTXT}}</option>
<option value="udp">{{UDPTXT}}</option>
<option value="tcp">{{TCPTXT}}</option>
{{/select}}
</select>
<a class="icon icon-category-monitoring" title="{{testTXT}}"></a>
<a class="icon icon-delete" title="{{deleteTXT}}"></a>
<a class="icon icon-add" title="{{newTXT}}"></a>
<span class="icon icon-checkmark-color hidden" title="{{savedTXT}}"></span>
</div>
32 changes: 15 additions & 17 deletions js/admin/turn-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,12 @@
OCA.VideoCalls.Admin = OCA.VideoCalls.Admin || {};
OCA.VideoCalls.Admin.TurnServer = {

TEMPLATE: '<div class="turn-server">' +
' <input type="text" class="server" placeholder="turn.example.org" value="{{server}}" aria-label="' + t('spreed', 'TURN server URL') + '">' +
' <input type="text" class="secret" placeholder="' + t('spreed', 'Shared secret') + '" value="{{secret}}" aria-label="' + t('spreed', 'TURN server shared secret') + '">' +
' <select class="protocols" title="' + t('spreed', 'TURN server protocols') + '">' +
' {{#select protocols}}' +
' <option value="udp,tcp">' + t('spreed', 'UDP and TCP') + '</option>' +
' <option value="udp">' + t('spreed', 'UDP only') + '</option>' +
' <option value="tcp">' + t('spreed', 'TCP only') + '</option>' +
' {{/select}}' +
' </select>' +
' <a class="icon icon-category-monitoring" title="' + t('spreed', 'Test server') + '"></a>' +
' <a class="icon icon-delete" title="' + t('spreed', 'Delete server') + '"></a>' +
' <a class="icon icon-add" title="' + t('spreed', 'Add new server') + '"></a>' +
' <span class="icon icon-checkmark-color hidden" title="' + t('spreed', 'Saved') + '"></span>' +
'</div>',
$list: undefined,
template: undefined,

init: function() {
Handlebars.registerHelper('select', this._handlebarSelectOption);
this.template = Handlebars.compile(this.TEMPLATE);
this.template = OCA.VideoCalls.Admin.Templates['turn-server'];
this.$list = $('div.turn-servers');
this.renderList();

Expand Down Expand Up @@ -264,7 +249,20 @@
},

renderServer: function(server) {
var $template = $(this.template(server));
var $template = $(this.template(_.extend(
{
turnTXT: t('spreed', 'TURN server URL'),
sharedSecretTXT: t('spreed', 'Shared secret'),
sharedSecretDescTXT: t('spreed', 'TURN server shared secret'),
UDPTCPTXT: t('spreed', 'UDP and TCP'),
UDPTXT: t('spreed', 'UDP only'),
TCPTXT: t('spreed', 'TCP only'),
testTXT: t('spreed', 'Test server'),
deleteTXT: t('spreed', 'Delete server'),
newTXT: t('spreed', 'Add new server'),
savedTXT: t('spreed', 'Saved'),
protocolsTXT: t('spreed', 'TURN server protocols'),
},server)));

$template.find('a.icon-add').on('click', this.addNewTemplate.bind(this));
$template.find('a.icon-delete').on('click', this.deleteServer.bind(this));
Expand Down
2 changes: 1 addition & 1 deletion templates/settings/admin/signaling-server.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/** @var array $_ */
/** @var \OCP\IL10N $l */
script('spreed', ['admin/signaling-server']);
script('spreed', ['admin/signaling-server', 'admin/templates']);
style('spreed', ['settings-admin']);
?>

Expand Down
2 changes: 1 addition & 1 deletion templates/settings/admin/stun-server.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/** @var array $_ */
/** @var \OCP\IL10N $l */
script('spreed', ['admin/stun-server']);
script('spreed', ['admin/stun-server', 'admin/templates']);
style('spreed', ['settings-admin']);
?>

Expand Down
2 changes: 1 addition & 1 deletion templates/settings/admin/turn-server.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/** @var array $_ */
/** @var \OCP\IL10N $l */
script('spreed', ['admin/turn-server']);
script('spreed', ['admin/turn-server', 'admin/templates']);
script('spreed', ['admin/sha1']);
style('spreed', ['settings-admin']);
?>
Expand Down