diff --git a/app/assets/javascripts/admin/controllers/admin-logs-screened-ip-addresses.js.es6 b/app/assets/javascripts/admin/controllers/admin-logs-screened-ip-addresses.js.es6 index a5eb32ae57d..595a6285720 100644 --- a/app/assets/javascripts/admin/controllers/admin-logs-screened-ip-addresses.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-logs-screened-ip-addresses.js.es6 @@ -11,8 +11,7 @@ export default Ember.Controller.extend({ show: debounce(function() { this.set("loading", true); ScreenedIpAddress.findAll(this.get("filter")).then(result => { - this.set("model", result); - this.set("loading", false); + this.setProperties({ model: result, loading: false }); }); }, 250).observes("filter"), @@ -35,8 +34,9 @@ export default Ember.Controller.extend({ }, cancel(record) { - if (this.get("savedIpAddress") && record.get("editing")) { - record.set("ip_address", this.get("savedIpAddress")); + const savedIpAddress = this.get("savedIpAddress"); + if (savedIpAddress && record.get("editing")) { + record.set("ip_address", savedIpAddress); } record.set("editing", false); }, @@ -46,9 +46,7 @@ export default Ember.Controller.extend({ record.set("editing", false); record .save() - .then(() => { - this.set("savedIpAddress", null); - }) + .then(() => this.set("savedIpAddress", null)) .catch(e => { if (e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors) { bootbox.alert( @@ -84,7 +82,7 @@ export default Ember.Controller.extend({ .catch(e => { bootbox.alert( I18n.t("generic_error_with_reason", { - error: "http: " + e.status + " - " + e.body + error: `http: ${e.status} - ${e.body}` }) ); }); @@ -98,25 +96,24 @@ export default Ember.Controller.extend({ }, rollUp() { - const self = this; return bootbox.confirm( I18n.t("admin.logs.screened_ips.roll_up_confirm"), I18n.t("no_value"), I18n.t("yes_value"), - function(confirmed) { + confirmed => { if (confirmed) { - self.set("loading", true); - return ScreenedIpAddress.rollUp().then(function(results) { + this.set("loading", true); + return ScreenedIpAddress.rollUp().then(results => { if (results && results.subnets) { if (results.subnets.length > 0) { - self.send("show"); + this.send("show"); bootbox.alert( I18n.t("admin.logs.screened_ips.rolled_up_some_subnets", { subnets: results.subnets.join(", ") }) ); } else { - self.set("loading", false); + this.set("loading", false); bootbox.alert( I18n.t("admin.logs.screened_ips.rolled_up_no_subnet") ); diff --git a/app/assets/javascripts/admin/templates/logs/screened-ip-addresses.hbs b/app/assets/javascripts/admin/templates/logs/screened-ip-addresses.hbs index 4e1def35b39..c5819da7912 100644 --- a/app/assets/javascripts/admin/templates/logs/screened-ip-addresses.hbs +++ b/app/assets/javascripts/admin/templates/logs/screened-ip-addresses.hbs @@ -1,26 +1,38 @@ -

{{i18n 'admin.logs.screened_ips.description'}}

+

{{i18n "admin.logs.screened_ips.description"}}

- {{text-field value=filter class="ip-address-input" placeholderKey="admin.logs.screened_ips.form.filter" autocorrect="off" autocapitalize="off"}} - {{d-button class="btn-default" action=(action "rollUp") title="admin.logs.screened_ips.roll_up.title" label="admin.logs.screened_ips.roll_up.text"}} - {{d-button class="btn-default" action=(action "exportScreenedIpList") icon="download" title="admin.export_csv.button_title.screened_ip" label="admin.export_csv.button_text"}} + {{text-field + value=filter + class="ip-address-input" + placeholderKey="admin.logs.screened_ips.form.filter" + autocorrect="off" + autocapitalize="off"}} + {{d-button + class="btn-default" + action=(action "rollUp") + title="admin.logs.screened_ips.roll_up.title" + label="admin.logs.screened_ips.roll_up.text"}} + {{d-button + class="btn-default" + action=(action "exportScreenedIpList") + icon="download" + title="admin.export_csv.button_title.screened_ip" + label="admin.export_csv.button_text"}}
- {{screened-ip-address-form action=(action "recordAdded")}} + + {{screened-ip-address-form action=(action "recordAdded")}}
- - {{#conditional-loading-spinner condition=loading}} {{#if model.length}} - - +
- - - - - + + + + + @@ -47,34 +59,64 @@ {{/if}} {{item.actionName}} - - - + + {{/each}}
{{i18n 'admin.logs.ip_address'}}{{i18n 'admin.logs.action'}}{{i18n 'admin.logs.match_count'}}{{i18n 'admin.logs.created_at'}}{{i18n 'admin.logs.last_match_at'}}{{i18n "admin.logs.ip_address"}}{{i18n "admin.logs.action"}}{{i18n "admin.logs.match_count"}}{{i18n "admin.logs.created_at"}}{{i18n "admin.logs.last_match_at"}}
{{i18n 'admin.logs.match_count'}}
{{item.match_count}}
{{i18n 'admin.logs.created_at'}}
{{age-with-tooltip item.created_at}}
+
{{i18n "admin.logs.match_count"}}
+ {{item.match_count}} +
+
{{i18n "admin.logs.created_at"}}
+ {{age-with-tooltip item.created_at}} +
{{#if item.last_match_at}} -
{{i18n 'admin.logs.last_match_at'}} {{age-with-tooltip item.last_match_at}}
+
+ {{i18n "admin.logs.last_match_at"}} + {{age-with-tooltip item.last_match_at}} +
{{/if}}
{{#unless item.editing}} - {{d-button class="btn-default" action=(action "destroy") actionParam=item icon="far-trash-alt" class="btn-danger"}} - {{d-button class="btn-default"action=(action "edit") actionParam=item icon="pencil-alt"}} + {{d-button + class="btn-default" + action=(action "destroy") + actionParam=item + icon="far-trash-alt" + class="btn-danger"}} + {{d-button + class="btn-default" + action=(action "edit") + actionParam=item + icon="pencil-alt"}} {{#if item.isBlocked}} - {{d-button class="btn-default" action=(action "allow") actionParam=item icon="check" label="admin.logs.screened_ips.actions.do_nothing"}} + {{d-button + class="btn-default" + action=(action "allow") + actionParam=item + icon="check" + label="admin.logs.screened_ips.actions.do_nothing"}} {{else}} - {{d-button class="btn-default" action=(action "block") actionParam=item icon="ban" label="admin.logs.screened_ips.actions.block"}} + {{d-button + class="btn-default" + action=(action "block") + actionParam=item + icon="ban" + label="admin.logs.screened_ips.actions.block"}} {{/if}} {{else}} - {{d-button class="btn-default" action=(action "save") actionParam=item label="admin.logs.save"}} - {{i18n 'cancel'}} + {{d-button + class="btn-default" + action=(action "save") + actionParam=item + label="admin.logs.save"}} + {{i18n "cancel"}} {{/unless}}
- {{else}} - {{i18n 'search.no_results'}} + {{i18n "search.no_results"}} {{/if}} {{/conditional-loading-spinner}}