diff --git a/src/backend/internal/access-list.js b/src/backend/internal/access-list.js
index 22b7aa0d..32d0f064 100644
--- a/src/backend/internal/access-list.js
+++ b/src/backend/internal/access-list.js
@@ -128,7 +128,7 @@ const internalAccessList = {
.then(row => {
if (row) {
if (typeof row.items !== 'undefined' && row.items) {
- row.items = internalAccessList.maskItems(row.items);
+ row = internalAccessList.maskItems(row);
}
return _.omit(row, omissions());
@@ -180,11 +180,14 @@ const internalAccessList = {
.then(access_data => {
let query = accessListModel
.query()
- .where('is_deleted', 0)
- .groupBy('id')
- .omit(['is_deleted'])
+ .select('access_list.*', accessListModel.raw('COUNT(proxy_hosts.id) as proxy_host_count'), accessListModel.raw('COUNT(items.id) as item_count'))
+ .leftJoinRelation('proxy_hosts')
+ .leftJoinRelation('items')
+ .where('access_list.is_deleted', 0)
+ .groupBy('access_list.id')
+ .omit(['access_list.is_deleted'])
.allowEager('[owner,items]')
- .orderBy('name', 'ASC');
+ .orderBy('access_list.name', 'ASC');
if (access_data.permission_visibility !== 'all') {
query.andWhere('owner_user_id', access.token.get('attrs').id);
@@ -207,7 +210,7 @@ const internalAccessList = {
if (rows) {
rows.map(function (row, idx) {
if (typeof row.items !== 'undefined' && row.items) {
- rows[idx].items = internalAccessList.maskItems(row.items);
+ rows[idx] = internalAccessList.maskItems(row);
}
});
}
diff --git a/src/backend/models/access_list.js b/src/backend/models/access_list.js
index 55ff3a33..ca8f21ae 100644
--- a/src/backend/models/access_list.js
+++ b/src/backend/models/access_list.js
@@ -33,6 +33,8 @@ class AccessList extends Model {
}
static get relationMappings () {
+ const ProxyHost = require('./proxy_host');
+
return {
owner: {
relation: Model.HasOneRelation,
@@ -56,6 +58,18 @@ class AccessList extends Model {
modify: function (qb) {
qb.omit(['id', 'created_on', 'modified_on']);
}
+ },
+ proxy_hosts: {
+ relation: Model.HasManyRelation,
+ modelClass: ProxyHost,
+ join: {
+ from: 'access_list.id',
+ to: 'proxy_host.access_list_id'
+ },
+ modify: function (qb) {
+ qb.where('proxy_host.is_deleted', 0);
+ qb.omit(['id', 'created_on', 'modified_on', 'is_deleted', 'meta']);
+ }
}
};
}
diff --git a/src/frontend/js/app/nginx/access/list/item.ejs b/src/frontend/js/app/nginx/access/list/item.ejs
index ccf89e4b..75906962 100644
--- a/src/frontend/js/app/nginx/access/list/item.ejs
+++ b/src/frontend/js/app/nginx/access/list/item.ejs
@@ -5,25 +5,17 @@
- <% domain_names.map(function(host) {
- %>
- <%- host %>
- <%
- });
- %>
+ <%- name %>
<%- i18n('str', 'created-on', {date: formatDbDate(created_on, 'Do MMMM YYYY')}) %>
|
- <%- forward_ip %>:<%- forward_port %>
+ <%- i18n('access-lists', 'item-count', {count: item_count}) %>
|
- <%- ssl_enabled && ssl_provider ? i18n('ssl', ssl_provider) : i18n('ssl', 'none') %>
- |
-
- <%- access_list_id ? access_list.name : i18n('str', 'public') %>
+ <%- i18n('access-lists', 'proxy-host-count', {count: proxy_host_count}) %>
|
<% if (canManage) { %>
@@ -31,10 +23,9 @@
|
-<% } %>
\ No newline at end of file
+<% } %>
diff --git a/src/frontend/js/app/nginx/access/list/item.js b/src/frontend/js/app/nginx/access/list/item.js
index 52a201e8..d6498d52 100644
--- a/src/frontend/js/app/nginx/access/list/item.js
+++ b/src/frontend/js/app/nginx/access/list/item.js
@@ -16,17 +16,17 @@ module.exports = Mn.View.extend({
events: {
'click @ui.edit': function (e) {
e.preventDefault();
- App.Controller.showNginxProxyForm(this.model);
+ App.Controller.showNginxAccessListForm(this.model);
},
'click @ui.delete': function (e) {
e.preventDefault();
- App.Controller.showNginxProxyDeleteConfirm(this.model);
+ App.Controller.showNginxAccessListDeleteConfirm(this.model);
}
},
templateContext: {
- canManage: App.Cache.User.canManage('proxy_hosts')
+ canManage: App.Cache.User.canManage('access_lists')
},
initialize: function () {
diff --git a/src/frontend/js/app/nginx/access/list/main.ejs b/src/frontend/js/app/nginx/access/list/main.ejs
index f2c64ea3..435b767d 100644
--- a/src/frontend/js/app/nginx/access/list/main.ejs
+++ b/src/frontend/js/app/nginx/access/list/main.ejs
@@ -1,9 +1,8 @@
|
- <%- i18n('str', 'source') %> |
- <%- i18n('str', 'destination') %> |
- <%- i18n('str', 'ssl') %> |
- <%- i18n('str', 'access') %> |
+ <%- i18n('str', 'name') %> |
+ <%- i18n('users', 'title') %> |
+ <%- i18n('proxy-hosts', 'title') %> |
<% if (canManage) { %>
|
<% } %>
diff --git a/src/frontend/js/app/nginx/access/main.js b/src/frontend/js/app/nginx/access/main.js
index dc31496b..21e54f0f 100644
--- a/src/frontend/js/app/nginx/access/main.js
+++ b/src/frontend/js/app/nginx/access/main.js
@@ -42,7 +42,7 @@ module.exports = Mn.View.extend({
onRender: function () {
let view = this;
- App.Api.Nginx.AccessLists.getAll(['owner'])
+ App.Api.Nginx.AccessLists.getAll(['owner', 'items'])
.then(response => {
if (!view.isDestroyed()) {
if (response && response.length) {
diff --git a/src/frontend/js/app/ui/main.ejs b/src/frontend/js/app/ui/main.ejs
index 853e111b..7c97cf7d 100644
--- a/src/frontend/js/app/ui/main.ejs
+++ b/src/frontend/js/app/ui/main.ejs
@@ -16,4 +16,4 @@
-
+
diff --git a/src/frontend/js/i18n/messages.json b/src/frontend/js/i18n/messages.json
index 34142f9c..3a452054 100644
--- a/src/frontend/js/i18n/messages.json
+++ b/src/frontend/js/i18n/messages.json
@@ -155,7 +155,9 @@
"delete-confirm": "Are you sure you want to delete this access list? Any hosts using it will need to be updated later.",
"public": "Publicly Accessible",
"help-title": "What is an Access List?",
- "help-content": "Access Lists provide authentication for the Proxy Hosts via Basic HTTP Authentication.\nYou can configure multiple usernames and passwords for a single Access List and then apply that to a Proxy Host.\nThis is most useful for forwarded web services that do not have authentication mechanisms built in."
+ "help-content": "Access Lists provide authentication for the Proxy Hosts via Basic HTTP Authentication.\nYou can configure multiple usernames and passwords for a single Access List and then apply that to a Proxy Host.\nThis is most useful for forwarded web services that do not have authentication mechanisms built in.",
+ "item-count": "{count} {count, select, 1{User} other{Users}}",
+ "proxy-host-count": "{count} {count, select, 1{Proxy Host} other{Proxy Hosts}}"
},
"users": {
"title": "Users",