[PORTAL-7] Rebase
[portal.git] / ecomp-portal-FE-os / client / src / services / support / session / session.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 'use strict';
21
22 (function () {
23     class SessionService {
24         constructor($q, $log, $http, conf,uuid,$sce) {
25             this.$q = $q;
26             this.$log = $log;
27             this.$http = $http;
28             this.conf = conf;
29             this.uuid = uuid;
30             this.$sce = $sce;
31         }
32         
33         logout(appStr) {
34             this.$log.info('SessionService::logout from App');
35             let deferred = this.$q.defer();
36             this.$log.info('SessionService appStr: ', appStr);
37            
38                         var eaccessPattern = '\https?\:\/\/[^/]+/[^/]+/[^/]+';
39             var standardPattern = '\https?\:\/\/[^/]+/[^/]+';
40             
41            
42             var contextUrl = appStr.match(new RegExp(standardPattern));
43             var logoutUrl  = contextUrl + '/logout.htm' ;
44             this.$sce.trustAsResourceUrl(logoutUrl);
45                         console.log('logoutUrl ' + logoutUrl);
46                         //window.open(logoutUrl, '_blank','width=100,height=100');
47                         jQuery('#reg-logout-div').append("<iframe style='display:none' src='" + logoutUrl + "' />");
48
49
50            /*
51             this.$http({
52                 method: "POST",
53                 url: logoutUrl,
54                 cache: false
55             }).then( res => {
56                 // If response comes back as a redirected HTML page which IS NOT a success
57                 this.$log.info(res);
58                 if (Object.keys(res).length === 0) {
59                     deferred.reject("ecomp::session-service::logout Failed");
60                 } else {
61                     this.$log.debug('query results: ', res);
62                     this.$log.info('ecomp::session-service::logout Succeeded');
63                     deferred.resolve(res);
64                 }
65             }).catch( status => {
66                 this.$log.error('query error: ',status);
67                 deferred.reject(status);
68             });
69             return deferred.promise;    
70             */       
71         }
72
73     }
74     SessionService.$inject = ['$q', '$log', '$http', 'conf','uuid4','$sce'];
75     angular.module('ecompApp').service('sessionService', SessionService)
76 })();