Add XDS-agent tarball download feature
[src/xds/xds-server.git] / webapp / src / app / common / utils.service.ts
diff --git a/webapp/src/app/common/utils.service.ts b/webapp/src/app/common/utils.service.ts
new file mode 100644 (file)
index 0000000..291ffd3
--- /dev/null
@@ -0,0 +1,23 @@
+import { Injectable } from '@angular/core';
+
+@Injectable()
+export class UtilsService {
+    constructor() { }
+
+    getOSName(lowerCase?: boolean): string {
+        let OSName = "Unknown OS";
+        if (navigator.appVersion.indexOf("Linux") !== -1) {
+            OSName = "Linux";
+        } else if (navigator.appVersion.indexOf("Win") !== -1) {
+            OSName = "Windows";
+        } else if (navigator.appVersion.indexOf("Mac") !== -1) {
+            OSName = "MacOS";
+        } else if (navigator.appVersion.indexOf("X11") !== -1) {
+            OSName = "UNIX";
+        }
+        if (lowerCase) {
+            return OSName.toLowerCase();
+        }
+        return OSName;
+    }
+}
\ No newline at end of file