633ad138360b823c3229cae91b294c9a04492d4e
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / apps / dlux / dlux-web / src / common / config / env.module.js
1 define(['angular'], function (angular) {
2   'use strict';
3
4   var config = angular.module('config', [])
5     .constant('ENV', {
6
7       baseURL: '',
8       adSalPort: '8080',
9       mdSalPort: '8181',
10       mdSalSecuredPort: '8443',
11       configEnv: 'ENV_PROD',
12       getBaseURL: function (salType) {
13         if (salType !== undefined) {
14           var urlPrefix = '';
15           if (this.configEnv === 'ENV_DEV') {
16             urlPrefix = this.baseURL;
17           } else {
18             urlPrefix = window.location.protocol + '//' + window.location.hostname + ':';
19           }
20
21           if (salType === 'AD_SAL') {
22             return urlPrefix + this.adSalPort;
23           } else if (salType === 'MD_SAL') {
24             var basePort = this.mdSalPort;
25             if (window.location.protocol === 'https:') {
26                 basePort = this.mdSalSecuredPort;
27             }
28             return urlPrefix + basePort;
29           }
30         }
31         //default behavior
32         return '';
33       }
34     });
35
36   return config;
37 });