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