Added portal-FE-os components
[portal.git] / portal-FE-os / src / app / shared / interceptors / header-interceptor.ts
  * 
  */
 
- .search-div {
-    margin-bottom: -14px;
-  }
+import {
+    HttpEvent,
+    HttpInterceptor,
+    HttpHandler,
+    HttpRequest,
+    HttpHeaders,
+} from '@angular/common/http';
+import { Observable } from 'rxjs';
+import { v4 as uuid } from 'uuid';
+import { Injectable } from '@angular/core';
+declare const getWebJunctionXSRFToken: any;
 
-  .search-res-dialog{
-    position: fixed;
-      background: white;
-      box-shadow: rgba(0, 0, 0, 0.247059) 0px 5px 6px 0px;
-      top: 2.5em;
-      border-radius: 0.25rem;
-      padding: 20px;
-      opacity: 1;
-      z-index: 1;
-  }
-  .searchUl {
-    list-style: none; 
-    border-bottom: 1px solid #bbb; 
-    padding-bottom: 20px;
-    padding-left: 4px;
+@Injectable()
+export class HeaderInterceptor implements HttpInterceptor {
+    intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
+        // Clone the request to add the new header
+        // HttpHeader object immutable - copy values
+        const headerSettings: { [name: string]: string | string[]; } = {};
+        headerSettings['X-ECOMP-RequestID'] = uuid();
+        const requestType = req.params.get('requestType');
+       
+        if(requestType!=null && requestType==='fileUpload'){
+          //headerSettings['Content-Type'] = 'multipart/form-data';
+        }else if(requestType!=null && requestType==='downloadWidgetFile'){
+           headerSettings['X-Widgets-Type'] = 'all';
+           headerSettings['Content-Type'] = 'application/octet-stream';
+        }else{
+            headerSettings['Content-Type'] = 'application/json';
+        }
+        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);
     }
-    .searchLiHeader {
-      font-weight: bold; 
-      color: #0574ac; 
-      font-size: 16px;
-      padding-bottom: 10px;
-      line-height: 1.5;
-      font-family: Omnes-ECOMP-W02,Arial;
-      
-      }
-      .searchLiItems{
-        cursor: pointer;
-        font-weight: normal; 
-        font-size: 12px;
-        color: #444444;
-        font-family: Omnes-ECOMP-W02,Arial;
-        }
\ No newline at end of file
+}
\ No newline at end of file