diff --git a/src/@fuse/fuse.module.ts b/src/@fuse/fuse.module.ts index 5886f7a4..91390c11 100644 --- a/src/@fuse/fuse.module.ts +++ b/src/@fuse/fuse.module.ts @@ -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 ], diff --git a/src/@fuse/services/platform/index.ts b/src/@fuse/services/platform/index.ts new file mode 100644 index 00000000..2eea68d4 --- /dev/null +++ b/src/@fuse/services/platform/index.ts @@ -0,0 +1 @@ +export * from '@fuse/services/platform/public-api'; diff --git a/src/@fuse/services/platform/platform.module.ts b/src/@fuse/services/platform/platform.module.ts new file mode 100644 index 00000000..ae3d0f54 --- /dev/null +++ b/src/@fuse/services/platform/platform.module.ts @@ -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) + { + } +} diff --git a/src/@fuse/services/platform/platform.service.ts b/src/@fuse/services/platform/platform.service.ts new file mode 100644 index 00000000..a8267070 --- /dev/null +++ b/src/@fuse/services/platform/platform.service.ts @@ -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'; + } + } + +} diff --git a/src/@fuse/services/platform/public-api.ts b/src/@fuse/services/platform/public-api.ts new file mode 100644 index 00000000..05d0e32e --- /dev/null +++ b/src/@fuse/services/platform/public-api.ts @@ -0,0 +1 @@ +export * from '@fuse/services/platform/platform.service';