(@fuse/services/platform) Added platform checker service

This commit is contained in:
Sercan Yemen 2022-05-24 14:38:50 +03:00
parent 099e745a36
commit 878a6bf191
5 changed files with 73 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
import { FuseConfirmationModule } from '@fuse/services/confirmation';
import { FuseLoadingModule } from '@fuse/services/loading';
import { FuseMediaWatcherModule } from '@fuse/services/media-watcher/media-watcher.module';
import { FusePlatformModule } from '@fuse/services/platform/platform.module';
import { FuseSplashScreenModule } from '@fuse/services/splash-screen/splash-screen.module';
import { FuseUtilsModule } from '@fuse/services/utils/utils.module';
@ -12,6 +13,7 @@ import { FuseUtilsModule } from '@fuse/services/utils/utils.module';
FuseConfirmationModule,
FuseLoadingModule,
FuseMediaWatcherModule,
FusePlatformModule,
FuseSplashScreenModule,
FuseUtilsModule
],

View File

@ -0,0 +1 @@
export * from '@fuse/services/platform/public-api';

View File

@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { FusePlatformService } from '@fuse/services/platform/platform.service';
@NgModule({
providers: [
FusePlatformService
]
})
export class FusePlatformModule
{
/**
* Constructor
*/
constructor(private _fusePlatformService: FusePlatformService)
{
}
}

View File

@ -0,0 +1,52 @@
import { Injectable } from '@angular/core';
import { Platform } from '@angular/cdk/platform';
@Injectable({
providedIn: 'root'
})
export class FusePlatformService
{
osName = 'os-unknown';
/**
* Constructor
*/
constructor(private _platform: Platform)
{
if ( !this._platform.isBrowser )
{
return;
}
if ( navigator.userAgent.includes('Win') )
{
this.osName = 'os-windows';
}
if ( navigator.userAgent.includes('Mac') )
{
this.osName = 'os-mac';
}
if ( navigator.userAgent.includes('X11') )
{
this.osName = 'os-unix';
}
if ( navigator.userAgent.includes('Linux') )
{
this.osName = 'os-linux';
}
if ( this._platform.IOS )
{
this.osName = 'os-ios';
}
if ( this._platform.ANDROID )
{
this.osName = 'os-android';
}
}
}

View File

@ -0,0 +1 @@
export * from '@fuse/services/platform/platform.service';