diff --git a/packages/manager/apps/dedicated/client/app/network-security/network-security.html b/packages/manager/apps/dedicated/client/app/network-security/network-security.html
index 8a1db42cdc82..674132cfd9c2 100644
--- a/packages/manager/apps/dedicated/client/app/network-security/network-security.html
+++ b/packages/manager/apps/dedicated/client/app/network-security/network-security.html
@@ -15,6 +15,8 @@
+
+
{
@@ -34,20 +37,28 @@ export default class ScrubbingCenterController extends AbstractCursorDatagridCon
this.getAllEvents();
}
this.isServiceSelected = false;
- this.isLoading = false;
}
createItemsPromise({ cursor }) {
const params = {
after: this.after,
- subnets: this.selectedIp,
};
+ if (this.selectedIp) {
+ params.subnets = this.selectedIp;
+ }
const pageSize = this.PAGE_SIZE;
- return this.networkSecurityService.getEventsList({
- cursor,
- params,
- pageSize,
- });
+ return this.networkSecurityService
+ .getEventsList({
+ cursor,
+ params,
+ pageSize,
+ })
+ .catch(() => {
+ this.Alerter.error(
+ this.$translate.instant('network_security_dashboard_events_error'),
+ 'network_security_dashboard_alert',
+ );
+ });
}
getAllEvents() {
@@ -79,13 +90,15 @@ export default class ScrubbingCenterController extends AbstractCursorDatagridCon
}
selectService() {
+ this.selectedIp = null;
+ this.isEmpty = false;
+ this.isServiceSelected = false;
+ this.model = null;
if (this.service) {
this.pageSize = 10;
this.page = 1;
this.autocomplete = [];
this.ipsList = [];
- this.selectedIp = '';
- this.ipsList = null;
this.ipSelected = null;
this.results = null;
this.isServiceSelected = true;
@@ -98,21 +111,44 @@ export default class ScrubbingCenterController extends AbstractCursorDatagridCon
)
.then((data) => {
this.ipsList = data.map(({ ipBlock }) => ipBlock);
+ this.isEmpty = !this.ipsList.length;
this.selectedIp = this.ipsList;
this.getAllEvents();
});
} else {
- this.isServiceSelected = false;
+ this.getAllEvents();
}
}
checkSelectedIp(value) {
+ let isValid = true;
if (!value) {
return null;
}
- this.selectedIp = value;
- return this.getAllEvents();
+ if (value.indexOf('/') === -1 && !ipaddr.isValid(value)) {
+ isValid = false;
+ } else if (value.indexOf('/') > -1) {
+ const ip = value.split('/');
+ if (!ipaddr.isValid(ip[0]) || !isNaN(ip[1])) {
+ isValid = false;
+ }
+ }
+
+ this.isValid = isValid;
+
+ if (isValid) {
+ this.selectedIp = value;
+ if (value.indexOf('/') === -1) {
+ if (value.indexOf('.') > -1) {
+ this.selectedIp = `${value}/32`;
+ } else if (value.indexOf(':') > -1) {
+ this.selectedIp = `${value}/128`;
+ }
+ this.model = this.selectedIp;
+ }
+ }
+ return isValid ? this.getAllEvents() : null;
}
static displayAction(row) {
@@ -131,6 +167,7 @@ export default class ScrubbingCenterController extends AbstractCursorDatagridCon
}
onReset() {
+ this.isValid = true;
this.selectedIp = null;
this.getAllEvents();
}
diff --git a/packages/manager/apps/dedicated/client/app/network-security/scrubbing-center/scrubbing-center.html b/packages/manager/apps/dedicated/client/app/network-security/scrubbing-center/scrubbing-center.html
index d199aefaf443..fb3245aad4cb 100644
--- a/packages/manager/apps/dedicated/client/app/network-security/scrubbing-center/scrubbing-center.html
+++ b/packages/manager/apps/dedicated/client/app/network-security/scrubbing-center/scrubbing-center.html
@@ -36,6 +36,9 @@
data-placeholder="{{:: 'network_security_dashboard_select_ip' | translate}}"
data-ng-if="!$ctrl.isServiceSelected"
>
+
+ {{ 'network_security_dashboard_invalid_ip' | translate}}
+
@@ -54,15 +57,19 @@
-
-
-
+