Skip to content

Commit

Permalink
Merge updates from integration into fix/ODD-1110-rpd before merge back
Browse files Browse the repository at this point in the history
  • Loading branch information
RayPlante committed Dec 5, 2023
2 parents db9643b + 88138d1 commit 61f8147
Show file tree
Hide file tree
Showing 31 changed files with 21,601 additions and 109 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- 'python/**'
- 'scripts/*.py'
- 'scripts/**/*.py'
- 'oar-metadata'
jobs:
testall_python:
runs-on: ubuntu-20.04
Expand Down
49 changes: 28 additions & 21 deletions angular/src/app/_helpers/fakeBackendInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,44 @@ export class FakeBackendInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// array in local storage for registered users

const sampleData: any = require('../../assets/science-theme/BiometricsScienceTheme.json');
const sampleRecord: any = require('../../assets/science-theme/DNAScienceTheme.json');

const biometricsData1: any = require('../../assets/science-theme/SDB-300.json');
const biometricsData2: any = require('../../assets/science-theme/SDB-301.json');
const biometricsData3: any = require('../../assets/science-theme/SDB-302.json');
const dna1: any = require('../../assets/science-theme/dna1.json');
const dna2: any = require('../../assets/science-theme/dna2.json');
const dna3: any = require('../../assets/science-theme/dna3.json');
const dna4: any = require('../../assets/science-theme/dna4.json');
const dna5: any = require('../../assets/science-theme/dna5.json');

const testdata: any = {
PageSize: 1,
ResultCount: 8,
ResultData: [biometricsData1,biometricsData2,biometricsData3,dna1,dna2,dna3,dna4,dna5]
}
// const sampleData: any = require('../../assets/science-theme/BiometricsScienceTheme.json');
// const sampleRecord: any = require('../../assets/science-theme/DNAScienceTheme.json');

// const biometricsData1: any = require('../../assets/science-theme/SDB-300.json');
// const biometricsData2: any = require('../../assets/science-theme/SDB-301.json');
// const biometricsData3: any = require('../../assets/science-theme/SDB-302.json');
// const dna1: any = require('../../assets/science-theme/dna1.json');
// const dna2: any = require('../../assets/science-theme/dna2.json');
// const dna3: any = require('../../assets/science-theme/dna3.json');
// const dna4: any = require('../../assets/science-theme/dna4.json');
// const dna5: any = require('../../assets/science-theme/dna5.json');
const rpa: any = require('../../assets/sample-data/rpa.json');
// const rpa: any = require('../../assets/sample-data/global_cart.json');

// const testdata: any = {
// PageSize: 1,
// ResultCount: 8,
// ResultData: [biometricsData1,biometricsData2,biometricsData3,dna1,dna2,dna3,dna4,dna5]
// }

// wrap in delayed observable to simulate server api call
return of(null).pipe(mergeMap(() => {
console.log("request.url", request.url);

// RPA
if (request.url.indexOf('/rpa') > -1 && request.method === 'GET') {
return of(new HttpResponse({ status: 200, body: rpa }));
}

// metrics
// if (request.url.indexOf('usagemetrics/files') > -1 && request.method === 'GET') {
// return of(new HttpResponse({ status: 200, body: metricsRecordDetails }));
// }

if (request.url.indexOf('isPartOf.@id=ark:/88434/mds9911') > -1 && request.method === 'GET') {
// console.log("Getting forensics")
return of(new HttpResponse({ status: 200, body: testdata }));
}
// if (request.url.indexOf('isPartOf.@id=ark:/88434/mds9911') > -1 && request.method === 'GET') {
// // console.log("Getting forensics")
// return of(new HttpResponse({ status: 200, body: testdata }));
// }

if (request.url.indexOf('usagemetrics/files') > -1 && request.method === 'GET')
{
Expand Down
5 changes: 4 additions & 1 deletion angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { isPlatformBrowser } from '@angular/common';
export class AppComponent {
title = 'PDR Resource Landing Page';
gaCode: string;
ga4Code: string = null;
inBrowser: boolean = false;

constructor(private gaService: GoogleAnalyticsService,
Expand All @@ -30,7 +31,9 @@ export class AppComponent {
// Applies to components only.
if(this.inBrowser){
this.gaCode = this.cfg.get("gaCode", "") as string;
this.gaService.appendGaTrackingCode(this.gaCode);
this.ga4Code = this.cfg.get("ga4Code", "") as string;

this.gaService.appendGaTrackingCode(this.gaCode, this.ga4Code);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions angular/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ enableProdMode();
AppErrorHandler,
{ provide: ErrorHandler, useClass: AppErrorHandler },
GoogleAnalyticsService,
// fakeBackendProvider,
DatePipe
],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
Expand Down
9 changes: 8 additions & 1 deletion angular/src/app/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ export interface LPSConfig {
*/
gaCode?: string;

/**
* Google Analytics 4 code
*/
ga4Code?: string;

/**
* other parameters are allowed
*/
Expand All @@ -198,7 +203,8 @@ export class AppConfig implements LPSConfig {
editEnabled: boolean;
status: string;
appVersion: string;
gaCode : string;
gaCode: string;
ga4Code: string;

/**
* create an AppConfig directly from an LPSConfig object
Expand Down Expand Up @@ -261,6 +267,7 @@ export class AppConfig implements LPSConfig {

// Set default Google Analytic code to dev
if (! this.gaCode) this.gaCode = "UA-115121490-8";
if (! this.ga4Code) this.ga4Code = "G-B91GVV0J5B";

if (typeof (this.editEnabled) === "undefined") this.editEnabled = false;
}
Expand Down
30 changes: 21 additions & 9 deletions angular/src/app/datacart/bundleplan/bundleplan.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, Output, Inject, PLATFORM_ID, EventEmitter } from '@angular/core';
import { Component, OnInit, Input, Output, Inject, PLATFORM_ID, EventEmitter, SimpleChanges } from '@angular/core';
import { ZipData } from '../../shared/download-service/zipData';
import { TreeNode } from 'primeng/api';
import { DownloadService } from '../../shared/download-service/download-service.service';
Expand Down Expand Up @@ -100,12 +100,7 @@ export class BundleplanComponent implements OnInit {
}

ngOnInit() {
if(this.inBrowser) {
this.dataCartStatus = DataCartStatus.openCartStatus();

this.dataCart = this.cartService.getCart(this.cartName);
// watch this cart?
}
this.cartInit();

this.downloadService.watchDownloadProcessStatus().subscribe(
value => {
Expand All @@ -116,6 +111,23 @@ export class BundleplanComponent implements OnInit {
);
}

ngOnChanges(changes: SimpleChanges): void {
//Called before any other lifecycle hook. Use it to inject dependencies, but avoid any serious work here.
//Add '${implements OnChanges}' to the class.
if (changes.cartName) {
this.cartInit();
}
}

cartInit() {
if(this.inBrowser) {
this.dataCartStatus = DataCartStatus.openCartStatus();

this.dataCart = this.cartService.getCart(this.cartName);
// watch this cart?
}
}

/**
* Set the overall status to complete
*/
Expand All @@ -127,7 +139,7 @@ export class BundleplanComponent implements OnInit {

if (this.dataCart && this.downloadFiles) {
let title = (this.dataCart.isGlobalCart()) ? "Global Data Cart"
: this.downloadFiles[0].resTitle.substring(0,20)+"...";
: this.downloadFiles[0].resTitle? this.downloadFiles[0].resTitle.substring(0,20)+"..." : "No title...";
this.dataCartStatus.setDownloadCompleted(this.dataCart.getName(), title);
}

Expand Down Expand Up @@ -166,7 +178,7 @@ export class BundleplanComponent implements OnInit {
updateDownloadPercentage(percentage: number){
if (this.dataCart && this.downloadFiles) {
let title = (this.dataCart.isGlobalCart()) ? "Global Data Cart"
: this.downloadFiles[0].resTitle.substring(0,20)+"...";
: this.downloadFiles[0].resTitle? this.downloadFiles[0].resTitle.substring(0,20)+"..." : "No title...";

this.dataCartStatus.updateDownloadPercentage(this.dataCart.getName(), percentage, title);
}
Expand Down
44 changes: 43 additions & 1 deletion angular/src/app/datacart/cart.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { Observable } from 'rxjs';
import { DataCart } from '../datacart/cart';
import { HttpClientModule, HttpClient, HttpHeaders, HttpRequest, HttpEventType, HttpResponse } from '@angular/common/http';
import { AppConfig } from '../config/config';

interface CartLookup {
/**
Expand All @@ -19,8 +21,19 @@ interface CartLookup {
export class CartService {
public CART_CONSTANTS: any = CartConstants.cartConst;
carts : CartLookup = {};
rpaBackend: string;
portalBase: string;

constructor() { }
constructor(
private http: HttpClient,
private cfg: AppConfig,) {
this.rpaBackend = cfg.get("APIs.rpaBackend", "/unconfigured");
if (this.rpaBackend == "/unconfigured")
throw new Error("APIs.rpaBackend endpoint not configured!");

if (! this.rpaBackend.endsWith("/")) this.rpaBackend += "/"
this.portalBase = cfg.get("locations.portalBase", "/unconfigured");
}

/**
* return the cart instance with the given name. This is normally an EDIID for a
Expand All @@ -32,6 +45,35 @@ export class CartService {
return this.carts[name];
}

public getRpaCart(id: string, cartName: string) : Observable<any> {
let backend: string = this.rpaBackend + id;

return new Observable<any>(subscriber => {
return this._getRpaCart(backend).subscribe(
(result) => {
let data = {};
result.metadata.forEach((d) =>{
let key = cartName+'/'+d.filePath;
d['key'] = key;
d["isSelected"] = true;
data[key] = d;
})
let out: DataCart = new DataCart(cartName, data, null, 0);
subscriber.next(out);
subscriber.complete();
}, (err) =>{
console.log("err", err);
subscriber.next(null);
subscriber.complete();
}
)
})
}

public _getRpaCart(url: string) : Observable<any> {
return this.http.get(url);
}

/**
* return the instance of the global cart which can contain data files from many datasets
*/
Expand Down
6 changes: 6 additions & 0 deletions angular/src/app/datacart/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class DataCart {
let out: DataCart = new DataCart(id, data, store, (md != null) ? parseMD(md).updated : 0);
if (saveneeded)
out.save();

return out;
}

Expand Down Expand Up @@ -280,6 +281,11 @@ export class DataCart {
*/
public getName() : string { return this.cartName; }

/**
* Set the name of this cart
*/
public setName(cartName: string) { this.cartName = cartName; }

/**
* return true if this cart serves as the global data cart
*/
Expand Down
19 changes: 13 additions & 6 deletions angular/src/app/datacart/cartcontrol/cartcontrol.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ export class CartcontrolComponent implements OnInit, OnChanges {
}

ngOnInit() {
this.cartInit();
}

ngOnChanges(changes: SimpleChanges) {
// cart name should not change
// if (changes.cartName && this.datacart)
// this.cartName = this.datacart.getName();
if (changes.cartName) {
this.cartInit();
}
}

cartInit() {
if (this.cartName) {
this.datacart = this.cartService.getCart(this.cartName);
this.updateCounts();
Expand All @@ -46,12 +59,6 @@ export class CartcontrolComponent implements OnInit, OnChanges {
});
}
}

ngOnChanges(changes: SimpleChanges) {
// cart name should not change
if (changes.cartName && this.datacart)
this.cartName = this.datacart.getName();
}

updateCounts() : void {
if (! this.datacart) return;
Expand Down
6 changes: 3 additions & 3 deletions angular/src/app/datacart/datacart.component.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Top control panel -->
<app-cartcontrol [cartName]="dataCart.getName()" (onDownloadSelected)="downloadSelectedFiles($event)"
<app-cartcontrol [cartName]="datacartName" (onDownloadSelected)="downloadSelectedFiles($event)"
(onRemoveSelected)="removeSelectedFiles($event)"
(onRemoveDownloaded)="remvoeDownloadedFiles($event)">
</app-cartcontrol>

<!-- Bundle plan -->
<app-bundleplan #bundler [cartName]="dataCart.getName()"
<app-bundleplan #bundler [cartName]="datacartName"
(outputOverallStatus)="updateCartOperationalStatus($event)">
</app-bundleplan>

<!-- Tree table -->
<app-treetable [cartName]="dataCart.getName()"></app-treetable>
<app-treetable [cartName]="datacartName" [forceReload]="forceReload"></app-treetable>
39 changes: 33 additions & 6 deletions angular/src/app/datacart/datacart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export class DatacartComponent implements OnInit, AfterViewInit {
zipData: ZipData[] = [];

overallStatus: string = "";
datacartName: string = "";
forceReload: boolean = false;

@ViewChild('bundler', { static: true })
bundler : BundleplanComponent;
Expand All @@ -50,18 +52,43 @@ export class DatacartComponent implements OnInit, AfterViewInit {
@Inject(PLATFORM_ID) private platformId: Object )
{
this.inBrowser = isPlatformBrowser(platformId);

this.route.params.subscribe(params => {
let cartName = params['cartname'];
let id: string = "";
if(cartName == 'rpa'){
if(this.inBrowser) {
this.route.queryParams.subscribe(params => {
console.log("param", params);
id = params["id"];
})

this.cartService.getRpaCart(id, cartName).subscribe((result: DataCart) => {
let dataCart01 = result;
this.dataCart = this.cartService.getCart(cartName);
this.dataCart.contents = dataCart01.contents;
this.datacartName = cartName;
this.forceReload = true;

//Trigger propagateSelectionUp and propagateSelectionDown
//so all check boxes will be checked
setTimeout(() => {
this.dataCart.save();
}, 0);
})
}
}else{
this.datacartName = cartName;
this.dataCart = this.cartService.getCart(cartName);
this.datacartName = this.dataCart.getName();
}
});
}

/**
* Get the params OnInit
*/
ngOnInit(): void {
let currentUrl = this.router.url;

this.route.params.subscribe(params => {
let cartName = params['cartname'];
this.dataCart = this.cartService.getCart(cartName);
});
}

/**
Expand Down
Loading

0 comments on commit 61f8147

Please sign in to comment.