mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-08 19:45:08 +00:00
(@fuse/services/platform) Added platform checker service
This commit is contained in:
parent
099e745a36
commit
878a6bf191
|
@ -4,6 +4,7 @@ import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
|
||||||
import { FuseConfirmationModule } from '@fuse/services/confirmation';
|
import { FuseConfirmationModule } from '@fuse/services/confirmation';
|
||||||
import { FuseLoadingModule } from '@fuse/services/loading';
|
import { FuseLoadingModule } from '@fuse/services/loading';
|
||||||
import { FuseMediaWatcherModule } from '@fuse/services/media-watcher/media-watcher.module';
|
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 { FuseSplashScreenModule } from '@fuse/services/splash-screen/splash-screen.module';
|
||||||
import { FuseUtilsModule } from '@fuse/services/utils/utils.module';
|
import { FuseUtilsModule } from '@fuse/services/utils/utils.module';
|
||||||
|
|
||||||
|
@ -12,6 +13,7 @@ import { FuseUtilsModule } from '@fuse/services/utils/utils.module';
|
||||||
FuseConfirmationModule,
|
FuseConfirmationModule,
|
||||||
FuseLoadingModule,
|
FuseLoadingModule,
|
||||||
FuseMediaWatcherModule,
|
FuseMediaWatcherModule,
|
||||||
|
FusePlatformModule,
|
||||||
FuseSplashScreenModule,
|
FuseSplashScreenModule,
|
||||||
FuseUtilsModule
|
FuseUtilsModule
|
||||||
],
|
],
|
||||||
|
|
1
src/@fuse/services/platform/index.ts
Normal file
1
src/@fuse/services/platform/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from '@fuse/services/platform/public-api';
|
17
src/@fuse/services/platform/platform.module.ts
Normal file
17
src/@fuse/services/platform/platform.module.ts
Normal 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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
52
src/@fuse/services/platform/platform.service.ts
Normal file
52
src/@fuse/services/platform/platform.service.ts
Normal 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';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
1
src/@fuse/services/platform/public-api.ts
Normal file
1
src/@fuse/services/platform/public-api.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from '@fuse/services/platform/platform.service';
|
Loading…
Reference in New Issue
Block a user