nexus site path corrected
[portal.git] / ecomp-portal-FE / client / app / services / utils / utils.service.js
1 /*-
2  * ================================================================================
3  * eCOMP Portal
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20
21 'use strict';
22
23 (function () {
24     class UtilsService {
25         constructor($log) {
26             this.$log = $log;
27         }
28
29         isRunningInLocalDevEnv() {
30             var myHostName;
31             myHostName = location.host;
32             let myDebugServer = "www.mytesturl.com"
33
34             if ((myHostName.includes(myDebugServer) || myHostName.includes("localhost"))) {
35                 return true;
36             } else {
37                 return false;
38             }
39         }
40
41         isValidJSON(json) {
42             try {
43                 var checkJSON = JSON.parse(JSON.stringify(json));
44                 if (checkJSON && typeof checkJSON === 'object' && checkJSON !== null) {
45                     // this.$log.debug('UtilsService::isValidJSON: JSON is valid! REMOVE THIS BEFORE COMMIT');
46                     return true;
47                 }
48             } catch (err) {
49                 this.$log.error('UtilsService::isValidJSON: json passed is not valid: '+ err);
50                 return false;
51             }
52         }
53
54     }
55     UtilsService.$inject = ['$log'];
56     angular.module('ecompApp').service('utilsService', UtilsService)
57 })();