Fix hard coded port 8181 for HTTPS scenrio
[dlux.git] / dlux-web / 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: '@@baseURL',
8       adSalPort: '@@adSalPort',
9       mdSalPort: '@@mdSalPort',
10       mdSalSecuredPort: '@@mdSalSecuredPort',
11       configEnv: '@@configEnv',
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 });