Commit ea6b3db8 authored by Ash Ittuveetil's avatar Ash Ittuveetil
Browse files

Updated code for including Entitlements V2,Storage API. Fixed...

Updated code for including Entitlements V2,Storage API. Fixed issues/enhancement 119,121,122,123,141,147,148,151
parent 2501f058
Pipeline #64214 failed with stages
in 2 minutes and 37 seconds
......@@ -9,6 +9,7 @@ import { environment} from 'src/environments/environment';
import jwt_decode from "jwt-decode";
import { CommonService} from 'src/app/common/common.service';
import { PlatformLocation } from '@angular/common';
import { errorMonitor } from 'events';
@Injectable({
providedIn: 'root'
......@@ -35,11 +36,17 @@ export class AuthService {
public legal_endpoint_url="";
public storage_endpoint_url="";
public workflow_endpoint_url="";
public schema_endpoint_url=""
public data_partition="";
public scope="";
public logout_uri="";
public tennant_id="";
httpOptions_token={};
public eds_acl={};
public eds_legal={};
public eds_payload={};
public eds_workflow_host="";
constructor(private router: Router, private http: HttpClient,public cmnSrv:CommonService) {
console.log("inside auth",router.url);
this.userSubject = new BehaviorSubject<User>(null);
......@@ -60,6 +67,7 @@ export class AuthService {
this.search_endpoint_url=this.config_params["api_endpoints"]["search_endpoint"];
this.storage_endpoint_url=this.config_params["api_endpoints"]["storage_endpoint"];
this.workflow_endpoint_url=this.config_params["api_endpoints"]["workflow_endpoint"];
this.schema_endpoint_url=this.config_params["api_endpoints"]["schema_endpoint"];
this.data_partition=this.config_params.data_partition;
this.scope=this.config_params.scope;
if(this.cloud_provider_name=='azure'){
......@@ -76,7 +84,10 @@ export class AuthService {
}),
};
this.eds_acl=AppConfig.settings.eds.acl;
this.eds_legal=AppConfig.settings.eds.legal;
this.eds_payload=AppConfig.settings.eds.Payload;
this.eds_workflow_host=AppConfig.settings.common.eds_workflow_host;
this.check_code();
}
......@@ -105,11 +116,28 @@ export class AuthService {
let errorMessage = '';
if (error.error instanceof ErrorEvent) {
// client-side error
errorMessage = `Error: ${error.error.message}`;
if(error.error != null){
if(error.error.message !=undefined){
errorMessage = `Error: ${error.error.message}`;
}
else{
errorMessage = `Error: ${error.error}`;
}
}
} else {
// server-side error
// errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}\nError: ${error.error}`;
errorMessage = `Error: ${error.error.message}`;
if(error.error !=null){
if(error.error.message !=undefined){
errorMessage = `Error: ${error.error.message}`;
}
else{
errorMessage = `Error: ${error.error}`;
}
}
}
//console.log("inside error handler3");
if (error.status == 0) {
......@@ -137,12 +165,18 @@ export class AuthService {
}
if (error.status == 404) {
if(error["error"]["message"] != undefined){
errorMessage=error["error"]["message"];
if(error.erro !=null){
if(error["error"]["message"] != undefined){
errorMessage=error["error"]["message"];
}
else{
errorMessage=error["error"]
}
}
else{
errorMessage=error["error"]
errorMessage= error["message"]
}
}
if(error.status == 409){
if(error["error"]["message"] != undefined){
......
......@@ -17,6 +17,7 @@ export class CommonService {
userGuideLink='';
bkgndColor='';
bkgndColorDash='';
externalDataSources;
filterByValue(array, string) {
return array.filter(o =>
......
import { TestBed } from '@angular/core/testing';
import { ExcelService } from './excel.service';
describe('ExcelService', () => {
let service: ExcelService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ExcelService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import { Cell, Workbook } from 'exceljs';
import * as fs from 'file-saver';
interface GroupMergeCellDTO {
group_index: number;
group_merge_qtd: number;
products?: ProductMergeCellDTO[];
}
interface ProductMergeCellDTO {
prod_index: number;
prod_merge_qtd: number;
}
@Injectable({
providedIn: 'root'
})
export class ExcelService {
private headers = [
"#",
"Group Name",
"Product Family",
"IBX",
"POF Qty",
"POF",
"POE",
"Attributes",
"POE Qty",
"Sls Qty"
];
DATA_EXAMPLE = [
{
group_name: "GROUP 1",
product_family: "Product family X",
ibx: "IBX 1",
products: [
{
quantity: 5,
product_name: "Product A",
elements: [
{
element_name: "Element M",
description: "Some description",
quantity: 2,
sales_quantity: 0
},
{
element_name: "Element N",
description: "Some description",
quantity: 1,
sales_quantity: 0
}
]
},
{
quantity: 2,
product_name: "Product B",
elements: [
{
element_name: "Element J",
description: "Some description",
quantity: 1,
sales_quantity: 2
},
{
element_name: "Element K",
description: "Some description",
quantity: 1,
sales_quantity: 0
},
{
element_name: "Element L",
description: "Some description",
quantity: 1,
sales_quantity: 0
}
]
}
]
},
{
group_name: "GROUP 2",
product_family: "Product family Y",
ibx: "IBX 2",
products: [
{
quantity: 5,
product_name: "Product AZ",
elements: [
{
element_name: "Element A",
description: "Some description",
quantity: 2,
sales_quantity: 0
},
{
element_name: "Element B",
description: "Some description",
quantity: 1,
sales_quantity: 0
}
]
}
]
}
];
constructor() { }
generateExcel() {
//Excel Title, Header, Data
const title = 'Car Sell Report';
const header = ["Year", "Month", "Make", "Model", "Quantity", "Pct"]
const data = [
[2007, 1, "Volkswagen ", "Volkswagen Passat", 1267, 10],
[2007, 1, "Toyota ", "Toyota Rav4", 819, 6.5],
[2007, 1, "Toyota ", "Toyota Avensis", 787, 6.2],
[2007, 1, "Volkswagen ", "Volkswagen Golf", 720, 5.7],
[2007, 1, "Toyota ", "Toyota Corolla", 691, 5.4],
[2007, 1, "Peugeot ", "Peugeot 307", 481, 3.8],
[2008, 1, "Toyota ", "Toyota Prius", 217, 2.2],
[2008, 1, "Skoda ", "Skoda Octavia", 216, 2.2],
[2008, 1, "Peugeot ", "Peugeot 308", 135, 1.4],
[2008, 2, "Ford ", "Ford Mondeo", 624, 5.9],
[2008, 2, "Volkswagen ", "Volkswagen Passat", 551, 5.2],
[2008, 2, "Volkswagen ", "Volkswagen Golf", 488, 4.6],
[2008, 2, "Volvo ", "Volvo V70", 392, 3.7],
[2008, 2, "Toyota ", "Toyota Auris", 342, 3.2],
[2008, 2, "Volkswagen ", "Volkswagen Tiguan", 340, 3.2],
[2008, 2, "Toyota ", "Toyota Avensis", 315, 3],
[2008, 2, "Nissan ", "Nissan Qashqai", 272, 2.6],
[2008, 2, "Nissan ", "Nissan X-Trail", 271, 2.6],
[2008, 2, "Mitsubishi ", "Mitsubishi Outlander", 257, 2.4],
[2008, 2, "Toyota ", "Toyota Rav4", 250, 2.4],
[2008, 2, "Ford ", "Ford Focus", 235, 2.2],
[2008, 2, "Skoda ", "Skoda Octavia", 225, 2.1],
[2008, 2, "Toyota ", "Toyota Yaris", 222, 2.1],
[2008, 2, "Honda ", "Honda CR-V", 219, 2.1],
[2008, 2, "Audi ", "Audi A4", 200, 1.9],
[2008, 2, "BMW ", "BMW 3-serie", 184, 1.7],
[2008, 2, "Toyota ", "Toyota Prius", 165, 1.6],
[2008, 2, "Peugeot ", "Peugeot 207", 144, 1.4]
];
//Create workbook and worksheet
let workbook = new Workbook();
let worksheet = workbook.addWorksheet('Car Data');
//Add Row and formatting
let titleRow = worksheet.addRow([title]);
titleRow.font = { name: 'Comic Sans MS', family: 4, size: 16, underline: 'double', bold: true }
worksheet.addRow([]);
// let subTitleRow = worksheet.addRow(['Date : ' + this.datePipe.transform(new Date(), 'medium')])
//Add Image
// let logo = workbook.addImage({
// base64: logoFile.logoBase64,
// extension: 'png',
// });
// worksheet.addImage(logo, 'E1:F3');
worksheet.mergeCells('A1:D2');
//Blank Row
worksheet.addRow([]);
//Add Header Row
let headerRow = worksheet.addRow(header);
// Cell Style : Fill and Border
headerRow.eachCell((cell, number) => {
cell.fill = {
type: 'pattern',
pattern: 'solid',
fgColor: { argb: 'FFFFFF00' },
bgColor: { argb: 'FF0000FF' }
}
cell.border = { top: { style: 'thin' }, left: { style: 'thin' }, bottom: { style: 'thin' }, right: { style: 'thin' } }
})
// worksheet.addRows(data);
// Add Data and Conditional Formatting
data.forEach(d => {
let row = worksheet.addRow(d);
let qty = row.getCell(5);
let color = 'FF99FF99';
if (+qty.value < 500) {
color = 'FF9999'
}
qty.fill = {
type: 'pattern',
pattern: 'solid',
fgColor: { argb: color }
}
}
);
worksheet.getColumn(3).width = 30;
worksheet.getColumn(4).width = 30;
worksheet.addRow([]);
//Footer Row
let footerRow = worksheet.addRow(['This is system generated excel sheet.']);
footerRow.getCell(1).fill = {
type: 'pattern',
pattern: 'solid',
fgColor: { argb: 'FFCCFFE5' }
};
footerRow.getCell(1).border = { top: { style: 'thin' }, left: { style: 'thin' }, bottom: { style: 'thin' }, right: { style: 'thin' } }
//Merge Cells
worksheet.mergeCells(`A${footerRow.number}:F${footerRow.number}`);
//Generate Excel File with given name
workbook.xlsx.writeBuffer().then((data) => {
let blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
fs.saveAs(blob, 'CarData.xlsx');
})
}
public exportToExcelSearch(headers,data){
// create a workbook with a worksheet
const workbook = new Workbook();
workbook.creator = "Our Team";
workbook.created = new Date(Date.now());
const worksheet = workbook.addWorksheet("sheet1");
// Adding Header Row
worksheet.addRow(headers).eachCell((cell, number) => {
cell.fill = {
type: "pattern",
pattern: "solid",
fgColor: { argb: "4167B8" },
bgColor: { argb: "" }
};
cell.font = {
bold: true,
color: { argb: "FFFFFF" },
size: 12
};
cell.border = {
top: { style: 'thin' },
left: { style: 'thin' },
bottom: { style: 'thin' },
right: { style: 'thin' }
};
});
let tempHead=[];
headers.forEach(element => {
if(element=="Id"){
tempHead.push(".Id")
}
else if(element=="Legal Tag"){
tempHead.push("..Legal Tag")
}
else{
tempHead.push(element)
}
});
// Adding legal Data
for(var i=0;i<data.length;i++){
let temp=[];
for(var j=0;j<tempHead.length;j++){
temp.push(data[i][tempHead[j]])
}
worksheet.addRow(temp)
}
// Generate & Save Excel File
workbook.xlsx.writeBuffer().then(data => {
let blob = new Blob([data], {
type:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
});
fs.saveAs(blob, "SearchData" + ".xlsx");
});
}
public exportToExcel(headers,subHeaders,data): void {
// const { product_groups } = checklist
// Here I’m trying to calculate how many lines I need to merge into the group lines
const group_merge_cells_data: GroupMergeCellDTO[] = [];
// create a workbook with a worksheet
const workbook = new Workbook();
workbook.creator = "Our Team";
workbook.created = new Date(Date.now());
const worksheet = workbook.addWorksheet("sheet1");
// Adding Header Row
worksheet.addRow(headers).eachCell((cell, number) => {
cell.fill = {
type: "pattern",
pattern: "solid",
fgColor: { argb: "4167B8" },
bgColor: { argb: "" }
};
cell.font = {
bold: true,
color: { argb: "FFFFFF" },
size: 12
};
cell.border = {
top: { style: 'thin' },
left: { style: 'thin' },
bottom: { style: 'thin' },
right: { style: 'thin' }
};
});
const subHeader = [];
for(var i=0;i<subHeaders.length;i++){
subHeader[i+3]=subHeaders[i];
}
let subrow=worksheet.addRow(subHeader).eachCell((cell, number) => {
cell.fill = {
type: "pattern",
pattern: "solid",
fgColor: { argb: "4167B8" },
bgColor: { argb: "" }
};
cell.font = {
bold: true,
color: { argb: "FFFFFF" },
size: 12,
};
cell.border = {
top: { style: 'thin' },
left: { style: 'thin' },
bottom: { style: 'thin' },
right: { style: 'thin' },
};
});
let subcount=subHeader.length;
let cellcount=2+subcount;
worksheet.mergeCells("C1:J1");
worksheet.mergeCells("A1:A2");
worksheet.mergeCells("B1:B2")
// Adding legal Data
data.forEach((legal, i) => {
worksheet.addRow([
legal.name,
legal.description,
legal["properties"]["countryOfOrigin"],
legal["properties"]["contractId"],
legal["properties"]["expirationDate"],
legal["properties"]["originator"],
legal["properties"]["dataType"],
legal["properties"]["securityClassification"],
legal["properties"]["personalData"],
legal["properties"]["exportClassification"]
]);
});
// Generate & Save Excel File
workbook.xlsx.writeBuffer().then(data => {
let blob = new Blob([data], {
type:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
});
fs.saveAs(blob, "LegalTagList" + ".xlsx");
});
}
}
......@@ -19,12 +19,16 @@ export class RestAPILayerService {
search_endpoint_url=this.auth.search_endpoint_url;
legal_endpoint_url=this.auth.legal_endpoint_url;
workflow_endpoint_url=this.auth.workflow_endpoint_url;
schema_endpoint_url=this.auth.schema_endpoint_url;
// --------host points-------
entitlementHost=AppConfig.settings.common.entitlement_host;
legalHost=AppConfig.settings.common.legal_host;
search_host=AppConfig.settings.common.search_host;
storage_host=AppConfig.settings.common.storage_host;
workflow_host=AppConfig.settings.common.workflow_host;
schema_host=AppConfig.settings.common.schema_host;
eds_workflow_host=this.auth.eds_workflow_host;
access_token=this.auth.getTokenSession();
authorization = this.auth.authorization;
data_partition=this.auth.data_partition;
......@@ -258,17 +262,37 @@ export class RestAPILayerService {
//------------------------- Storage APIs-------------------------------------------
getStorageKindList(): Observable<any> {
this.param = 'query/kinds'
// getStorageKindList(): Observable<any> {
// this.param = 'query/kinds'
// // this.param = 'ResetPassword?GUID='+guid+'&password='+pwd;
// return this.http.get<any>(this.storage_endpoint_url + this.storage_host+this.param, this.httpOptions).pipe(
// map(this.extractData),
// );
// }
getSchemaKindList(): Observable<any> {
this.param = 'schema'
// this.param = 'ResetPassword?GUID='+guid+'&password='+pwd;
return this.http.get<any>(this.storage_endpoint_url + this.storage_host+this.param, this.httpOptions).pipe(
return this.http.get<any>(this.schema_endpoint_url + this.schema_host+this.param, this.httpOptions).pipe(
map(this.extractData),
);
}
getStorageKindList(data): Observable<any> {
this.param = 'query'
// this.param = 'ResetPassword?GUID='+guid+'&password='+pwd;
return this.http.post<any>(this.search_endpoint_url + this.search_host+this.param,data, this.httpOptions).pipe(
map(this.extractData),
);
}
//------------------------- Search APIs-------------------------------------------
SearchWells(data): Observable<any> {
this.param = 'query'
......@@ -282,6 +306,18 @@ export class RestAPILayerService {
);
}
// SearchWells(id): Observable<any> {
// this.param = 'records/'+id;
// let errorData={
// 'api':this.param,
// }
// return this.http.get<any>(this.storage_endpoint_url +this.storage_host+ this.param, this.httpOptions).pipe(
// map(this.extractData),
// catchError(this.auth.errorHandler<any>('addProduct',errorData))
// );
// }
getSearchSchema(kind) {
this.param = 'schemas/'+kind;
......@@ -419,4 +455,41 @@ getConnectionSourceDataJob(data){
catchError(this.auth.errorHandler<any>('addProduct',errorData))
);
}
postConnectionSourceRegistry(data){
this.param = 'workflow/Osdu_ingest/workflowRun'
let errorData={