![]()
-
+
diff --git a/frontend/src/app/shared/components/layout/header/header.component.ts b/frontend/src/app/shared/components/layout/header/header.component.ts
index 3306d03da..4cdd47ca3 100644
--- a/frontend/src/app/shared/components/layout/header/header.component.ts
+++ b/frontend/src/app/shared/components/layout/header/header.component.ts
@@ -1,15 +1,11 @@
import {Component, OnDestroy, OnInit} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';
-import {UtmModulesService} from '../../../../app-module/shared/services/utm-modules.service';
import {AccountService} from '../../../../core/auth/account.service';
-import {LoginService} from '../../../../core/login/login.service';
import {User} from '../../../../core/user/user.model';
-import {NavBehavior} from '../../../behaviors/nav.behavior';
import {ThemeChangeBehavior} from '../../../behaviors/theme-change.behavior';
import {ADMIN_ROLE} from '../../../constants/global.constant';
import {AppThemeLocationEnum} from '../../../enums/app-theme-location.enum';
-import {ActiveAdModuleActiveService} from '../../../services/active-modules/active-ad-module.service';
-import {UtmRunModeService} from '../../../services/active-modules/utm-run-mode.service';
+import {CheckForUpdatesService} from '../../../services/updates/check-for-updates.service';
@Component({
selector: 'app-header',
@@ -23,15 +19,12 @@ export class HeaderComponent implements OnInit, OnDestroy {
place = AppThemeLocationEnum;
logoImage: string;
altImage: string;
+ currentVersion: any;
- constructor(private loginService: LoginService,
- private accountService: AccountService,
- private adModuleActiveService: ActiveAdModuleActiveService,
+ constructor(private accountService: AccountService,
public sanitizer: DomSanitizer,
- private moduleService: UtmModulesService,
- private navBehavior: NavBehavior,
- private utmRunModeService: UtmRunModeService,
- private themeChangeBehavior: ThemeChangeBehavior) {
+ private themeChangeBehavior: ThemeChangeBehavior,
+ private checkForUpdatesService: CheckForUpdatesService) {
}
ngOnInit() {
@@ -43,6 +36,14 @@ export class HeaderComponent implements OnInit, OnDestroy {
this.accountService.identity().then(account => {
this.user = account;
});
+
+ this.getVersionInfo();
+ }
+
+ getVersionInfo() {
+ this.checkForUpdatesService.getVersion().subscribe(response => {
+ this.currentVersion = response.body;
+ });
}
ngOnDestroy() {
diff --git a/frontend/src/app/shared/components/layout/header/shared/components/utm-version-info/utm-version-info.component.ts b/frontend/src/app/shared/components/layout/header/shared/components/utm-version-info/utm-version-info.component.ts
index a198db502..37cada592 100644
--- a/frontend/src/app/shared/components/layout/header/shared/components/utm-version-info/utm-version-info.component.ts
+++ b/frontend/src/app/shared/components/layout/header/shared/components/utm-version-info/utm-version-info.component.ts
@@ -1,5 +1,4 @@
-import {Component, OnDestroy, OnInit} from '@angular/core';
-import {CheckForUpdatesService} from '../../../../../../services/updates/check-for-updates.service';
+import {Component, Input, OnInit} from '@angular/core';
import {VersionInfo} from '../../../../../../types/updates/updates.type';
@Component({
@@ -7,23 +6,9 @@ import {VersionInfo} from '../../../../../../types/updates/updates.type';
templateUrl: './utm-version-info.component.html',
styleUrls: ['./utm-version-info.component.css']
})
-export class UtmVersionInfoComponent implements OnInit, OnDestroy {
- currentVersion: VersionInfo;
+export class UtmVersionInfoComponent implements OnInit {
+ @Input('version') currentVersion: VersionInfo;
- constructor(private checkForUpdatesService: CheckForUpdatesService) {
- }
-
- ngOnInit() {
- this.getVersionInfo();
- }
-
- ngOnDestroy() {
- }
-
- getVersionInfo() {
- this.checkForUpdatesService.getVersion().subscribe(response => {
- this.currentVersion = response.body;
- });
- }
+ ngOnInit() {}
}
diff --git a/frontend/src/app/shared/util/custom-form-validators.ts b/frontend/src/app/shared/util/custom-form-validators.ts
new file mode 100644
index 000000000..b82b574d6
--- /dev/null
+++ b/frontend/src/app/shared/util/custom-form-validators.ts
@@ -0,0 +1,86 @@
+import {AbstractControl, ValidationErrors, ValidatorFn} from '@angular/forms';
+
+export class IpFormsValidators {
+
+ static ipOrCidr(): ValidatorFn {
+ return (control: AbstractControl): ValidationErrors | null => {
+ if (!control.value) {
+ return null;
+ }
+
+ const value = control.value.trim();
+
+ if (value.includes('/')) {
+ return IpFormsValidators.validateCIDR(value) ? null : { invalidCidr: true };
+ }
+
+ const isValidIPv4 = IpFormsValidators.validateIPv4(value);
+ const isValidIPv6 = IpFormsValidators.validateIPv6(value);
+
+ return (isValidIPv4 || isValidIPv6) ? null : { invalidIp: true };
+ };
+ }
+
+ private static validateIPv4(ip: string): boolean {
+ const ipv4Regex = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
+ const match = ip.match(ipv4Regex);
+
+ if (!match) {
+ return false;
+ }
+
+ for (let i = 1; i <= 4; i++) {
+ const octet = parseInt(match[i], 10);
+ if (octet < 0 || octet > 255) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private static validateIPv6(ip: string): boolean {
+ // tslint:disable-next-line:max-line-length
+ const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
+
+ return ipv6Regex.test(ip);
+ }
+
+ private static validateCIDR(cidr: string): boolean {
+ const parts = cidr.split('/');
+
+ if (parts.length !== 2) {
+ return false;
+ }
+
+ const [ip, prefix] = parts;
+ const prefixNum = parseInt(prefix, 10);
+
+ const isIPv4 = ip.includes('.') && !ip.includes(':');
+ const isIPv6 = ip.includes(':');
+
+ if (isIPv4) {
+ if (!IpFormsValidators.validateIPv4(ip)) {
+ return false;
+ }
+
+ if (isNaN(prefixNum) || prefixNum < 0 || prefixNum > 32) {
+ return false;
+ }
+ } else if (isIPv6) {
+
+ if (!IpFormsValidators.validateIPv6(ip)) {
+ return false;
+ }
+
+ if (isNaN(prefixNum) || prefixNum < 0 || prefixNum > 128) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/version.yml b/version.yml
index 8a353c437..f633540cf 100644
--- a/version.yml
+++ b/version.yml
@@ -1 +1 @@
-version: 10.9.3
\ No newline at end of file
+version: 10.9.5
\ No newline at end of file