mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Functional redirection hosts
This commit is contained in:
parent
c20a46264c
commit
52fcc90b1c
@ -1,32 +1,37 @@
|
||||
<td class="text-center">
|
||||
<div class="avatar d-block" style="background-image: url(<%- avatar || '/images/default-avatar.jpg' %>)">
|
||||
<span class="avatar-status <%- is_disabled ? 'bg-red' : 'bg-green' %>"></span>
|
||||
<div class="avatar d-block" style="background-image: url(<%- owner.avatar || '/images/default-avatar.jpg' %>)" title="Owned by <%- owner.name %>">
|
||||
<span class="avatar-status <%- owner.is_disabled ? 'bg-red' : 'bg-green' %>"></span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div><%- name %></div>
|
||||
<div>
|
||||
<% domain_names.map(function(host) {
|
||||
%>
|
||||
<span class="tag"><%- host %></span>
|
||||
<%
|
||||
});
|
||||
%>
|
||||
</div>
|
||||
<div class="small text-muted">
|
||||
Created: <%- formatDbDate(created_on, 'Do MMMM YYYY') %>
|
||||
<%- i18n('str', 'created-on', {date: formatDbDate(created_on, 'Do MMMM YYYY')}) %>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div><%- email %></div>
|
||||
<div class="text-monospace"><%- forward_domain_name %></div>
|
||||
</td>
|
||||
<td>
|
||||
<div><%- roles.join(', ') %></div>
|
||||
<div><%- ssl_enabled && ssl_provider ? i18n('ssl', ssl_provider) : i18n('ssl', 'none') %></div>
|
||||
</td>
|
||||
<% if (canManage) { %>
|
||||
<td class="text-center">
|
||||
<div class="item-action dropdown">
|
||||
<a href="#" data-toggle="dropdown" class="icon"><i class="fe fe-more-vertical"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" class="edit-user dropdown-item"><i class="dropdown-icon fe fe-edit"></i> Edit Details</a>
|
||||
<a href="#" class="edit-permissions dropdown-item"><i class="dropdown-icon fe fe-shield"></i> Edit Permissions</a>
|
||||
<a href="#" class="set-password dropdown-item"><i class="dropdown-icon fe fe-lock"></i> Set Password</a>
|
||||
<% if (!isSelf()) { %>
|
||||
<a href="#" class="login dropdown-item"><i class="dropdown-icon fe fe-log-in"></i> Sign in as User</a>
|
||||
<a href="#" class="edit dropdown-item"><i class="dropdown-icon fe fe-edit"></i> <%- i18n('str', 'edit') %></a>
|
||||
<a href="#" class="logs dropdown-item"><i class="dropdown-icon fe fe-book"></i> <%- i18n('str', 'logs') %></a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a href="#" class="delete-user dropdown-item"><i class="dropdown-icon fe fe-trash-2"></i> Delete User</a>
|
||||
<% } %>
|
||||
<a href="#" class="delete dropdown-item"><i class="dropdown-icon fe fe-trash-2"></i> <%- i18n('str', 'delete') %></a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<% } %>
|
||||
|
@ -1,69 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
const Mn = require('backbone.marionette');
|
||||
const Controller = require('../../../controller');
|
||||
const Api = require('../../../api');
|
||||
const Cache = require('../../../cache');
|
||||
const Tokens = require('../../../tokens');
|
||||
const template = require('./item.ejs');
|
||||
const Mn = require('backbone.marionette');
|
||||
const App = require('../../../main');
|
||||
const template = require('./item.ejs');
|
||||
|
||||
module.exports = Mn.View.extend({
|
||||
template: template,
|
||||
tagName: 'tr',
|
||||
|
||||
ui: {
|
||||
edit: 'a.edit-user',
|
||||
permissions: 'a.edit-permissions',
|
||||
password: 'a.set-password',
|
||||
login: 'a.login',
|
||||
delete: 'a.delete-user'
|
||||
edit: 'a.edit',
|
||||
delete: 'a.delete'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click @ui.edit': function (e) {
|
||||
e.preventDefault();
|
||||
Controller.showUserForm(this.model);
|
||||
},
|
||||
|
||||
'click @ui.permissions': function (e) {
|
||||
e.preventDefault();
|
||||
Controller.showUserPermissions(this.model);
|
||||
},
|
||||
|
||||
'click @ui.password': function (e) {
|
||||
e.preventDefault();
|
||||
Controller.showUserPasswordForm(this.model);
|
||||
App.Controller.showNginxRedirectionForm(this.model);
|
||||
},
|
||||
|
||||
'click @ui.delete': function (e) {
|
||||
e.preventDefault();
|
||||
Controller.showUserDeleteConfirm(this.model);
|
||||
},
|
||||
|
||||
'click @ui.login': function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (Cache.User.get('id') !== this.model.get('id')) {
|
||||
this.ui.login.prop('disabled', true).addClass('btn-disabled');
|
||||
|
||||
Api.Users.loginAs(this.model.get('id'))
|
||||
.then(res => {
|
||||
Tokens.addToken(res.token, res.user.nickname || res.user.name);
|
||||
window.location = '/';
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(err => {
|
||||
alert(err.message);
|
||||
this.ui.login.prop('disabled', false).removeClass('btn-disabled');
|
||||
});
|
||||
}
|
||||
App.Controller.showNginxRedirectionDeleteConfirm(this.model);
|
||||
}
|
||||
},
|
||||
|
||||
templateContext: {
|
||||
isSelf: function () {
|
||||
return Cache.User.get('id') === this.id;
|
||||
}
|
||||
canManage: App.Cache.User.canManage('redirection_hosts')
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
|
@ -1,10 +1,12 @@
|
||||
<thead>
|
||||
<th width="30"> </th>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Roles</th>
|
||||
<th> </th>
|
||||
<th width="30"> </th>
|
||||
<th><%- i18n('str', 'source') %></th>
|
||||
<th><%- i18n('str', 'destination') %></th>
|
||||
<th><%- i18n('str', 'ssl') %></th>
|
||||
<% if (canManage) { %>
|
||||
<th> </th>
|
||||
<% } %>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- items -->
|
||||
<!-- items -->
|
||||
</tbody>
|
||||
|
@ -1,8 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const Mn = require('backbone.marionette');
|
||||
const ItemView = require('./item');
|
||||
const template = require('./main.ejs');
|
||||
const Mn = require('backbone.marionette');
|
||||
const App = require('../../../main');
|
||||
const ItemView = require('./item');
|
||||
const template = require('./main.ejs');
|
||||
|
||||
const TableBody = Mn.CollectionView.extend({
|
||||
tagName: 'tbody',
|
||||
@ -21,6 +22,10 @@ module.exports = Mn.View.extend({
|
||||
}
|
||||
},
|
||||
|
||||
templateContext: {
|
||||
canManage: App.Cache.User.canManage('redirection_hosts')
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this.showChildView('body', new TableBody({
|
||||
collection: this.collection
|
||||
|
@ -25,7 +25,7 @@ module.exports = Mn.View.extend({
|
||||
events: {
|
||||
'click @ui.add': function (e) {
|
||||
e.preventDefault();
|
||||
App.Controller.showNginxProxyForm();
|
||||
App.Controller.showNginxRedirectionForm();
|
||||
}
|
||||
},
|
||||
|
||||
@ -36,24 +36,24 @@ module.exports = Mn.View.extend({
|
||||
onRender: function () {
|
||||
let view = this;
|
||||
|
||||
App.Api.Nginx.ProxyHosts.getAll(['owner', 'access_list'])
|
||||
App.Api.Nginx.RedirectionHosts.getAll(['owner'])
|
||||
.then(response => {
|
||||
if (!view.isDestroyed()) {
|
||||
if (response && response.length) {
|
||||
view.showChildView('list_region', new ListView({
|
||||
collection: new ProxyHostModel.Collection(response)
|
||||
collection: new RedirectionHostModel.Collection(response)
|
||||
}));
|
||||
} else {
|
||||
let manage = App.Cache.User.canManage('proxy_hosts');
|
||||
let manage = App.Cache.User.canManage('redirection_hosts');
|
||||
|
||||
view.showChildView('list_region', new EmptyView({
|
||||
title: App.i18n('proxy-hosts', 'empty'),
|
||||
title: App.i18n('redirection-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',
|
||||
link: manage ? App.i18n('redirection-hosts', 'add') : null,
|
||||
btn_color: 'yellow',
|
||||
permission: 'redirection_hosts',
|
||||
action: function () {
|
||||
App.Controller.showNginxProxyForm();
|
||||
App.Controller.showNginxRedirectionForm();
|
||||
}
|
||||
}));
|
||||
}
|
||||
@ -64,7 +64,7 @@ module.exports = Mn.View.extend({
|
||||
code: err.code,
|
||||
message: err.message,
|
||||
retry: function () {
|
||||
App.Controller.showNginxProxy();
|
||||
App.Controller.showNginxRedirection();
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -64,7 +64,7 @@ module.exports = Mn.View.extend({
|
||||
}
|
||||
|
||||
view.model.set(result);
|
||||
App.App.UI.closeModal(function () {
|
||||
App.UI.closeModal(function () {
|
||||
if (method === App.Api.Users.create) {
|
||||
// Show permissions dialog immediately
|
||||
App.Controller.showUserPermissions(view.model);
|
||||
|
@ -85,6 +85,8 @@
|
||||
},
|
||||
"redirection-hosts": {
|
||||
"title": "Redirection Hosts",
|
||||
"empty": "There are no Redirection Hosts",
|
||||
"add": "Add Redirection Host",
|
||||
"form-title": "{id, select, undefined{New} other{Edit}} Redirection Host",
|
||||
"forward-domain": "Forward Domain",
|
||||
"preserve-path": "Preserve Path",
|
||||
|
Loading…
Reference in New Issue
Block a user