i18n and improvements

This commit is contained in:
Jamie Curnow
2018-07-18 16:55:09 +10:00
parent d49c3ba3af
commit b6cff5a7d8
34 changed files with 314 additions and 412 deletions

View File

@ -1,13 +1,13 @@
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><% if (typeof id !== 'undefined') { %>Edit<% } else { %>New<% } %> Proxy Host</h5>
<h5 class="modal-title"><%- i18n('proxy-hosts', 'form-title', {id: id}) %></h5>
<button type="button" class="close cancel" aria-label="Close" data-dismiss="modal">&nbsp;</button>
</div>
<div class="modal-body has-tabs">
<form>
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="nav-item"><a href="#details" aria-controls="tab1" role="tab" data-toggle="tab" class="nav-link active"><i class="fe fe-zap"></i> Details</a></li>
<li role="presentation" class="nav-item"><a href="#ssl-options" aria-controls="tab2" role="tab" data-toggle="tab" class="nav-link"><i class="fe fe-shield"></i> SSL</a></li>
<li role="presentation" class="nav-item"><a href="#details" aria-controls="tab1" role="tab" data-toggle="tab" class="nav-link active"><i class="fe fe-zap"></i> <%- i18n('all-hosts', 'details') %></a></li>
<li role="presentation" class="nav-item"><a href="#ssl-options" aria-controls="tab2" role="tab" data-toggle="tab" class="nav-link"><i class="fe fe-shield"></i> <%- i18n('all-hosts', 'SSL') %></a></li>
</ul>
<div class="tab-content">
<!-- Details -->
@ -16,19 +16,19 @@
<div class="col-sm-12 col-md-12">
<div class="form-group">
<label class="form-label">Domain Names <span class="form-required">*</span></label>
<label class="form-label"><%- i18n('all-hosts', 'domain-names') %> <span class="form-required">*</span></label>
<input type="text" name="domain_names" class="form-control" id="input-domains" value="<%- domain_names.join(',') %>" required>
</div>
</div>
<div class="col-sm-8 col-md-8">
<div class="form-group">
<label class="form-label">Forward IP <span class="form-required">*</span></label>
<label class="form-label"><%- i18n('proxy-hosts', 'forward-ip') %><span class="form-required">*</span></label>
<input type="text" name="forward_ip" class="form-control text-monospace" placeholder="000.000.000.000" value="<%- forward_ip %>" autocomplete="off" maxlength="15" required>
</div>
</div>
<div class="col-sm-4 col-md-4">
<div class="form-group">
<label class="form-label">Forward Port <span class="form-required">*</span></label>
<label class="form-label"><%- i18n('proxy-hosts', 'forward-port') %> <span class="form-required">*</span></label>
<input name="forward_port" type="number" class="form-control text-monospace" placeholder="80" value="<%- forward_port %>" required>
</div>
</div>
@ -43,7 +43,7 @@
<label class="custom-switch">
<input type="checkbox" class="custom-switch-input" name="ssl_enabled" value="1"<%- ssl_enabled ? ' checked' : '' %>>
<span class="custom-switch-indicator"></span>
<span class="custom-switch-description">Enable SSL</span>
<span class="custom-switch-description"><%- i18n('all-hosts', 'enable-ssl') %></span>
</label>
</div>
</div>
@ -52,21 +52,21 @@
<label class="custom-switch">
<input type="checkbox" class="custom-switch-input" name="ssl_forced" value="1"<%- ssl_forced ? ' checked' : '' %><%- ssl_enabled ? '' : ' disabled' %>>
<span class="custom-switch-indicator"></span>
<span class="custom-switch-description">Force SSL</span>
<span class="custom-switch-description"><%- i18n('all-hosts', 'force-ssl') %></span>
</label>
</div>
</div>
<div class="col-sm-12 col-md-12">
<div class="form-group">
<label class="form-label">Certificate Provider</label>
<label class="form-label"><%- i18n('all-hosts', 'cert-provider') %></label>
<div class="selectgroup w-100">
<label class="selectgroup-item">
<input type="radio" name="ssl_provider" value="letsencrypt" class="selectgroup-input"<%- ssl_provider !== 'other' ? ' checked' : '' %>>
<span class="selectgroup-button">Let's Encrypt</span>
<span class="selectgroup-button"><%- i18n('all-hosts', 'letsencrypt') %></span>
</label>
<label class="selectgroup-item">
<input type="radio" name="ssl_provider" value="other" class="selectgroup-input"<%- ssl_provider === 'other' ? ' checked' : '' %>>
<span class="selectgroup-button">Other</span>
<span class="selectgroup-button"><%- i18n('all-hosts', 'other-ssl') %></span>
</label>
</div>
</div>
@ -75,7 +75,7 @@
<!-- Lets encrypt -->
<div class="col-sm-12 col-md-12 letsencrypt-ssl">
<div class="form-group">
<label class="form-label">Email Address for Let's Encrypt <span class="form-required">*</span></label>
<label class="form-label"><%- i18n('all-hosts', 'letsencrypt-email') %> <span class="form-required">*</span></label>
<input name="meta[letsencrypt_email]" type="email" class="form-control" placeholder="" value="<%- getLetsencryptEmail() %>" required>
</div>
</div>
@ -84,7 +84,7 @@
<label class="custom-switch">
<input type="checkbox" class="custom-switch-input" name="meta[letsencrypt_agree]" value="1" required<%- getLetsencryptAgree() ? ' checked' : '' %>>
<span class="custom-switch-indicator"></span>
<span class="custom-switch-description">I Agree to the <a href="https://letsencrypt.org/repository/" target="_blank">Let's Encrypt Terms of Service</a> <span class="form-required">*</span></span>
<span class="custom-switch-description"><%= i18n('all-hosts', 'letsencrypt-agree', {url: 'https://letsencrypt.org/repository/'}) %> <span class="form-required">*</span></span>
</label>
</div>
</div>
@ -92,19 +92,19 @@
<!-- Other -->
<div class="col-sm-12 col-md-12 other-ssl">
<div class="form-group">
<div class="form-label">Certificate</div>
<div class="form-label"><%- i18n('all-hosts', 'other-certificate') %></div>
<div class="custom-file">
<input type="file" class="custom-file-input" name="meta[other_ssl_certificate]">
<label class="custom-file-label">Choose file</label>
<label class="custom-file-label"><%- i18n('str', 'choose-file') %></label>
</div>
</div>
</div>
<div class="col-sm-12 col-md-12 other-ssl">
<div class="form-group">
<div class="form-label">Certificate Key</div>
<div class="form-label"><%- i18n('all-hosts', 'other-certificate-key') %></div>
<div class="custom-file">
<input type="file" class="custom-file-input" name="meta[other_ssl_certificate_key]">
<label class="custom-file-label">Choose file</label>
<label class="custom-file-label"><%- i18n('str', 'choose-file') %></label>
</div>
</div>
</div>
@ -116,7 +116,7 @@
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary cancel" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-teal save">Save</button>
<button type="button" class="btn btn-secondary cancel" data-dismiss="modal"><%- i18n('str', 'cancel') %></button>
<button type="button" class="btn btn-teal save"><%- i18n('str', 'save') %></button>
</div>
</div>

View File

@ -2,12 +2,9 @@
const _ = require('underscore');
const Mn = require('backbone.marionette');
const template = require('./form.ejs');
const Controller = require('../../controller');
const Cache = require('../../cache');
const Api = require('../../api');
const App = require('../../main');
const ProxyHostModel = require('../../../models/proxy-host');
const template = require('./form.ejs');
require('jquery-serializejson');
require('jquery-mask-plugin');
@ -80,11 +77,11 @@ module.exports = Mn.View.extend({
// Process
this.ui.buttons.prop('disabled', true).addClass('btn-disabled');
let method = Api.Nginx.ProxyHosts.create;
let method = App.Api.Nginx.ProxyHosts.create;
if (this.model.get('id')) {
// edit
method = Api.Nginx.ProxyHosts.update;
method = App.Api.Nginx.ProxyHosts.update;
data.id = this.model.get('id');
}
@ -92,8 +89,8 @@ module.exports = Mn.View.extend({
.then(result => {
view.model.set(result);
App.UI.closeModal(function () {
if (method === Api.Nginx.ProxyHosts.create) {
Controller.showNginxProxy();
if (method === App.Api.Nginx.ProxyHosts.create) {
App.Controller.showNginxProxy();
}
});
})
@ -106,7 +103,7 @@ module.exports = Mn.View.extend({
templateContext: {
getLetsencryptEmail: function () {
return typeof this.meta.letsencrypt_email !== 'undefined' ? this.meta.letsencrypt_email : Cache.User.get('email');
return typeof this.meta.letsencrypt_email !== 'undefined' ? this.meta.letsencrypt_email : App.Cache.User.get('email');
},
getLetsencryptAgree: function () {

View File

@ -1,10 +1,10 @@
<div class="card">
<div class="card-status bg-success"></div>
<div class="card-header">
<h3 class="card-title">Proxy Hosts</h3>
<h3 class="card-title"><%- i18n('proxy-hosts', 'title') %></h3>
<div class="card-options">
<% if (showAddButton) { %>
<a href="#" class="btn btn-outline-success btn-sm ml-2 add-item">Add Proxy Host</a>
<a href="#" class="btn btn-outline-success btn-sm ml-2 add-item"><%- i18n('proxy-hosts', 'add') %></a>
<% } %>
</div>
</div>

View File

@ -1,14 +1,12 @@
'use strict';
const Mn = require('backbone.marionette');
const App = require('../../main');
const ProxyHostModel = require('../../../models/proxy-host');
const Api = require('../../api');
const Cache = require('../../cache');
const Controller = require('../../controller');
const ListView = require('./list/main');
const ErrorView = require('../../error/main');
const template = require('./main.ejs');
const EmptyView = require('../../empty/main');
const template = require('./main.ejs');
module.exports = Mn.View.extend({
id: 'nginx-proxy',
@ -27,18 +25,18 @@ module.exports = Mn.View.extend({
events: {
'click @ui.add': function (e) {
e.preventDefault();
Controller.showNginxProxyForm();
App.Controller.showNginxProxyForm();
}
},
templateContext: {
showAddButton: Cache.User.canManage('proxy_hosts')
showAddButton: App.Cache.User.canManage('proxy_hosts')
},
onRender: function () {
let view = this;
Api.Nginx.ProxyHosts.getAll(['owner', 'access_list'])
App.Api.Nginx.ProxyHosts.getAll(['owner', 'access_list'])
.then(response => {
if (!view.isDestroyed()) {
if (response && response.length) {
@ -46,16 +44,16 @@ module.exports = Mn.View.extend({
collection: new ProxyHostModel.Collection(response)
}));
} else {
let manage = Cache.User.canManage('proxy_hosts');
let manage = App.Cache.User.canManage('proxy_hosts');
view.showChildView('list_region', new EmptyView({
title: 'There are no Proxy Hosts',
subtitle: manage ? 'Why don\'t you create one?' : 'And you don\'t have permission to create one.',
link: manage ? 'Add Proxy Host' : null,
title: App.i18n('proxy-hosts', 'empty'),
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
link: manage ? App.i18n('proxy-hosts', 'add') : null,
btn_color: 'success',
permission: 'proxy_hosts',
action: function () {
Controller.showNginxProxyForm();
App.Controller.showNginxProxyForm();
}
}));
}
@ -66,7 +64,7 @@ module.exports = Mn.View.extend({
code: err.code,
message: err.message,
retry: function () {
Controller.showNginxProxy();
App.Controller.showNginxProxy();
}
}));