summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/LogoutController.java57
-rw-r--r--ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/LogoutControllerTest.java45
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.html2
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.ts21
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.ts2
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.ts6
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.ts2
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.ts1
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts34
9 files changed, 66 insertions, 104 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/LogoutController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/LogoutController.java
index bbd08c45..d41bf239 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/LogoutController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/LogoutController.java
@@ -37,20 +37,16 @@
*/
package org.onap.portalapp.controller.core;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
-import org.onap.portalsdk.core.domain.User;
-import org.onap.portalsdk.core.logging.aspect.MetricsLog;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
-import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
-import org.onap.portalsdk.core.web.support.UserUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;
@Controller
@@ -59,8 +55,6 @@ public class LogoutController extends UnRestrictedBaseController {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LogoutController.class);
- private User user;
-
/**
*
* invalidates the current application session, then redirects to portal logout
@@ -72,53 +66,12 @@ public class LogoutController extends UnRestrictedBaseController {
public ModelAndView globalLogout(HttpServletRequest request) {
ModelAndView modelView = null;
try {
- chatRoomLogout(request);
request.getSession().invalidate();
- String portalUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);
- String portalDomain = portalUrl.substring(0, portalUrl.lastIndexOf('/'));
- String redirectUrl = portalDomain + "/logout.htm";
- modelView = new ModelAndView("redirect:" + redirectUrl);
+ Map<String, Object> model = new HashMap<>();
+ return new ModelAndView("login", "model", model);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "Logout failed", e);
}
return modelView;
}
-
- /**
- *
- * invalidates the current session (application logout) and redirects user to
- * Portal.
- *
- * @param request
- * @return modelView
- */
- @RequestMapping(value = { "/app_logout.htm" }, method = RequestMethod.GET)
- public ModelAndView appLogout(HttpServletRequest request) {
- ModelAndView modelView = null;
- try {
- chatRoomLogout(request);
- modelView = new ModelAndView(
- "redirect:" + PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL));
- UserUtils.clearUserSession(request);
- request.getSession().invalidate();
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "Application Logout failed", e);
- }
- return modelView;
- }
-
- @MetricsLog
- public void chatRoomLogout(HttpServletRequest request) {
- request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
- setUser(UserUtils.getUserSession(request));
- }
-
- public User getUser() {
- return user;
- }
-
- public void setUser(User user) {
- this.user = user;
- }
-
}
diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/LogoutControllerTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/LogoutControllerTest.java
index 8883cfa8..71d7277a 100644
--- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/LogoutControllerTest.java
+++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/LogoutControllerTest.java
@@ -37,9 +37,6 @@
*/
package org.onap.portalapp.controller.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -111,46 +108,4 @@ public class LogoutControllerTest {
.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL)).thenReturn("http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/login.htm");
logoutController.globalLogout(mockedRequest);
}
-
- @Test
- public void globalLogoutExceptionTest(){
- PowerMockito.mockStatic(PortalApiProperties.class);
- PowerMockito.mockStatic(PortalApiConstants.class);
- Mockito.when(PortalApiProperties
- .getProperty(PortalApiConstants.ECOMP_REDIRECT_URL)).thenReturn("http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/login.htm");
- assertNull(logoutController.globalLogout(mockedRequest));
- }
-
- @Test
- public void appLogoutTest(){
- ModelAndView actualModelView = new ModelAndView("redirect:http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/login.htm");
- PowerMockito.mockStatic(PortalApiProperties.class);
- PowerMockito.mockStatic(PortalApiConstants.class);
- PowerMockito.mockStatic(RequestContextHolder.class);
- ServletRequestAttributes ServletRequestAttributes = new ServletRequestAttributes(mockedRequest);
- Mockito.when(RequestContextHolder.currentRequestAttributes()).thenReturn(ServletRequestAttributes);
- Mockito.when(PortalApiProperties
- .getProperty(PortalApiConstants.ECOMP_REDIRECT_URL)).thenReturn("http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/login.htm");
- ModelAndView expectedModelView = logoutController.appLogout(mockedRequest);
- assertEquals(actualModelView.getViewName(), expectedModelView.getViewName());
- }
-
- @Test
- public void appLogoutExceptionTest(){
- PowerMockito.mockStatic(PortalApiProperties.class);
- PowerMockito.mockStatic(PortalApiConstants.class);
- Mockito.when(PortalApiProperties
- .getProperty(PortalApiConstants.ECOMP_REDIRECT_URL)).thenReturn("http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/login.htm");
- assertNull(logoutController.appLogout(mockedRequest));
- }
-
- @Test
- public void getUserTest(){
- User expectedUser = new User();
- expectedUser.setActive(false);
- user.setActive(false);
- logoutController.setUser(user);
- User actualUser = logoutController.getUser();
- assertEquals(expectedUser.getActive(), actualUser.getActive());
- }
}
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.html
index 04701ca7..59ab1c4e 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.html
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.html
@@ -22,7 +22,7 @@
<div>userId:</div>{{userId}}</span></div>
<br/>
<div id="reg-logout-div" style="padding-top: 8px">
- <a href="logout.htm" id="allLogout" class="btn btn-primary">
+ <a href="{{logOutURL}}" id="allLogout" class="btn btn-primary">
Log out
</a>
</div>
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.ts
index 7bf5c649..16dc6544 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.ts
@@ -41,6 +41,7 @@ import { HeaderService } from '../../../shared/services/header/header.service';
import { UserService } from 'src/app/shared/services/user/user.service';
import { User } from 'src/app/shared/services/user/user';
import { CookieService } from 'ngx-cookie-service';
+import { environment } from 'src/environments/environment';
@Component({
selector: 'app-header',
@@ -57,9 +58,18 @@ export class HeaderComponent implements OnInit {
userName;
appName:string;
showHeader:boolean = true;
+ logOutURL = environment.baseUrl;
- constructor(public router: Router,public headerService: HeaderService,public cookieService: CookieService) {
+ constructor(public router: Router,public headerService: HeaderService,public cookieService: CookieService) {
+
+ if(window.location.pathname.split('/').length > 3) {
+ var portNum = ( window.location.port === '' || window.location.port === '0' ) ? '' : ':'+ window.location.port;
+ this.logOutURL = window.location.protocol + "//" + window.location.hostname + portNum + window.location.pathname.substring(0, this.nthIndex(window.location.pathname, "/", 2) + 0) + '/logout.htm';
+ } else {
+ this.logOutURL = environment.baseUrl + 'logout.htm';
+ }
+
this.router.events.subscribe(val => {
if (
@@ -103,4 +113,13 @@ export class HeaderComponent implements OnInit {
onLoggedout() {
localStorage.removeItem('isLoggedin');
}
+
+ nthIndex(str, pat, n) {
+ var L = str.length, i = -1;
+ while (n-- && i++ < L) {
+ i = str.indexOf(pat, i);
+ if (i < 0) break;
+ }
+ return i;
+ }
}
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.ts
index 2a8561e6..25f5109c 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.ts
@@ -114,7 +114,7 @@ export class ColumnListComponent implements OnInit {
}
ngOnInit() {
-
+ this.showSpinner = true;
this.displayTable = true;
this._columnService.getColumnList()
.subscribe((response) => {
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.ts
index fc34cccd..e3bab3bb 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.ts
@@ -76,16 +76,20 @@ export class FormFieldsComponent implements OnInit {
}
ngOnInit() {
+ this.showSpinner = true;
this._formFieldsService.getListOfFormFields()
.subscribe((responseFormFields) => {
+ this.showSpinner = true;
for (let m = 0; m < responseFormFields.length; m++) {
responseFormFields[m]["orderSeq"] = m + 1;
this.formFieldsListObj.push(responseFormFields[m]);
}
-
+ this.showSpinner = false;
this._formFieldsService.getFormFieldGroupsData(this.reportId1)
.subscribe((responseGroupsData) => {
+ this.showSpinner = true;
this.Groups = JSON.parse(responseGroupsData["formFieldGroupsJSON"]);
+ this.showSpinner = false;
});
});
}
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.ts
index 47ec2383..a90a1f8e 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.ts
@@ -22,7 +22,7 @@ export class LogComponent implements OnInit {
}
ngOnInit() {
-
+ this.showSpinner = true;
if(this.reportType === "Dashboard")
{
this.stepNo= "3";
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.ts
index 62c7d7a4..897aa03e 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.ts
@@ -46,6 +46,7 @@ export class SQLComponent implements OnInit {
}
ngOnInit() {
+ this.showSpinner = true;
this.showSaveSQLDialog = false;
this.SQLPostResponse = true;
this.ValidatePostResponse = {};
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts
index 50973763..1539877c 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts
@@ -42,9 +42,22 @@ import {
HttpHandler,
HttpRequest,
HttpHeaders,
+ HttpErrorResponse
} from '@angular/common/http';
-import { Observable } from 'rxjs';
+import { Observable, throwError} from 'rxjs';
import { v4 as uuid } from 'uuid';
+import { catchError } from 'rxjs/internal/operators/catchError';
+import { environment } from '../../../environments/environment';
+
+function nthIndex(str, pat, n) {
+ var L = str.length, i = -1;
+ while (n-- && i++ < L) {
+ i = str.indexOf(pat, i);
+ if (i < 0) break;
+ }
+ return i;
+}
+
export class HeaderInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const headerSettings: { [name: string]: string | string[]; } = {};
@@ -58,6 +71,23 @@ export class HeaderInterceptor implements HttpInterceptor {
const newHeader = new HttpHeaders(headerSettings);
const clonedRequest = req.clone({ headers: newHeader, withCredentials: true });
// Pass the cloned request instead of the original request to the next handle
- return next.handle(clonedRequest);
+ //return next.handle(clonedRequest);
+ var url = '';
+ return next.handle(clonedRequest).pipe(
+ catchError(error => {
+ if ( error instanceof HttpErrorResponse ) {
+ if ( error.status === 0 ) { // If 0(302) Redirect to Login Page
+ if(window.location.pathname.split('/').length > 3) {
+ var portNum = ( window.location.port === '' || window.location.port === '0' ) ? '' : ':'+ window.location.port;
+ url = window.location.protocol + "//" + window.location.hostname + portNum + window.location.pathname.substring(0, nthIndex(window.location.pathname, "/", 2) + 0) + '/login.htm';
+ window.open( url, '_self' );
+ } else {
+ window.open( environment.baseUrl + 'login.htm', '_self' );
+ }
+ }
+ }
+ return throwError(error);
+ })
+ );
}
} \ No newline at end of file