Skip to content

Commit e22f87d

Browse files
authored
Merge pull request #975 from thegamingninja/feature/more-access-ips
Improved Access List Form
2 parents 6202f4f + d333732 commit e22f87d

File tree

5 files changed

+51
-17
lines changed

5 files changed

+51
-17
lines changed

frontend/js/app/nginx/access/form.ejs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646

4747
<!-- Authorization -->
4848
<div class="tab-pane" id="auth">
49+
<p>
50+
Basic Authorization via
51+
<a target="_blank" href="https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html">
52+
Nginx HTTP Basic Authentication
53+
</a>
54+
</p>
4955
<div class="row">
5056
<div class="col-sm-6 col-md-6">
5157
<div class="form-group">
@@ -60,10 +66,19 @@
6066
</div>
6167

6268
<div class="items"><!-- items --></div>
69+
<div class="btn-list justify-content-end">
70+
<button type="button" class="btn btn-teal auth_add"><%- i18n('access-lists', 'auth-add') %></button>
71+
</div>
6372
</div>
6473

6574
<!-- Access -->
6675
<div class="tab-pane" id="access">
76+
<p>
77+
IP Address Whitelist/Blacklist via
78+
<a target="_blank" href="https://nginx.org/en/docs/http/ngx_http_access_module.html">
79+
Nginx HTTP Access
80+
</a>
81+
</p>
6782
<div class="clients"><!-- clients --></div>
6883
<div class="row">
6984
<div class="col-sm-3 col-md-3">
@@ -78,6 +93,9 @@
7893
</div>
7994
</div>
8095
<div class="text-muted">Note that the <code>allow</code> and <code>deny</code> directives will be applied in the order they are defined.</div>
96+
<div class="btn-list justify-content-end">
97+
<button type="button" class="btn btn-teal access_add"><%- i18n('access-lists', 'access-add') %></button>
98+
</div>
8199
</div>
82100

83101
</div>

frontend/js/app/nginx/access/form.js

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ module.exports = Mn.View.extend({
2525
form: 'form',
2626
buttons: '.modal-footer button',
2727
cancel: 'button.cancel',
28-
save: 'button.save'
28+
save: 'button.save',
29+
access_add: 'button.access_add',
30+
auth_add: 'button.auth_add'
2931
},
3032

3133
regions: {
@@ -105,27 +107,34 @@ module.exports = Mn.View.extend({
105107
alert(err.message);
106108
this.ui.buttons.prop('disabled', false).removeClass('btn-disabled');
107109
});
110+
},
111+
'click @ui.access_add': function (e) {
112+
e.preventDefault();
113+
114+
let clients = this.model.get('clients');
115+
clients.push({});
116+
this.showChildView('clients_region', new ClientsView({
117+
collection: new Backbone.Collection(clients)
118+
}));
119+
},
120+
'click @ui.auth_add': function (e) {
121+
e.preventDefault();
122+
123+
let items = this.model.get('items');
124+
items.push({});
125+
this.showChildView('items_region', new ItemsView({
126+
collection: new Backbone.Collection(items)
127+
}));
108128
}
109129
},
110130

111131
onRender: function () {
112132
let items = this.model.get('items');
113133
let clients = this.model.get('clients');
114134

115-
// Add empty items to the end of the list. This is cheating but hey I don't have the time to do it right
116-
let items_to_add = 5 - items.length;
117-
if (items_to_add) {
118-
for (let i = 0; i < items_to_add; i++) {
119-
items.push({});
120-
}
121-
}
122-
123-
let clients_to_add = 4 - clients.length;
124-
if (clients_to_add) {
125-
for (let i = 0; i < clients_to_add; i++) {
126-
clients.push({});
127-
}
128-
}
135+
// Ensure at least one field is shown initally
136+
if (!items.length) items.push({});
137+
if (!clients.length) clients.push({});
129138

130139
this.showChildView('items_region', new ItemsView({
131140
collection: new Backbone.Collection(items)

frontend/js/app/nginx/access/form/client.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
</div>
99
<div class="col-sm-9 col-md-9">
1010
<div class="form-group">
11-
<input type="text" name="address[]" class="form-control" value="<%- typeof address !== 'undefined' ? address : '' %>" value="">
11+
<input type="text" name="address[]" placeholder="IP / Subnet" class="form-control" value="<%- typeof address !== 'undefined' ? address : '' %>" value="">
1212
</div>
1313
</div>

frontend/js/i18n/messages.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@
210210
"access": "Access",
211211
"satisfy": "Satisfy",
212212
"satisfy-any": "Satisfy Any",
213-
"pass-auth": "Pass Auth to Host"
213+
"pass-auth": "Pass Auth to Host",
214+
"access-add": "Add",
215+
"auth-add": "Add"
214216
},
215217
"users": {
216218
"title": "Users",

frontend/scss/tabler-extra.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ $pink: #f66d9b;
2525
padding: 0;
2626
}
2727

28+
/* For some reason this class doesn't have 'display: flex' when it should. https://preview.tabler.io/docs/buttons.html#list-of-buttons */
29+
.btn-list {
30+
display: flex;
31+
}
32+
2833
/* Teal Outline Buttons */
2934
.btn-outline-teal {
3035
color: $teal;

0 commit comments

Comments
 (0)