From 056deef19393d5e81caaf3258b85a06956db1427 Mon Sep 17 00:00:00 2001 From: Maksym Dudnik Date: Fri, 18 Aug 2023 14:33:39 +0300 Subject: [PATCH] using existing getOs --- .../device-gateway-command.component.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/device-gateway-command.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/device-gateway-command.component.ts index 9e7a99c692..d0d39a9280 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/device-gateway-command.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/device-gateway-command.component.ts @@ -22,6 +22,7 @@ import { TranslateService } from '@ngx-translate/core'; import { ActionNotificationShow } from '@core/notification/notification.actions'; import { DeviceService } from '@core/http/device.service'; import { helpBaseUrl } from '@shared/models/constants'; +import { getOS } from '@core/utils'; @Component({ @@ -60,16 +61,19 @@ export class DeviceGatewayCommandComponent implements OnInit { this.cd.detectChanges(); }); } - // @ts-ignore - const platform = window.navigator?.userAgentData?.platform || window.navigator.platform, - macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], - windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE']; - if (macosPlatforms.indexOf(platform) !== -1) { - this.tabIndex = 1; - } else if (windowsPlatforms.indexOf(platform) !== -1) { - this.tabIndex = 0; - } else if (/Linux/.test(platform)) { - this.tabIndex = 1; + const currentOS = getOS(); + switch (currentOS) { + case 'linux': + case 'android': + case 'macos': + case 'ios': + this.tabIndex = 1; + break; + case 'windows': + this.tabIndex = 0; + break; + default: + this.tabIndex = 1; } }