Skip to content
Snippets Groups Projects
Commit 3375c785 authored by Sam Kagan's avatar Sam Kagan
Browse files

Added QL-product link to SECI products

parent 361ea05c
No related branches found
No related tags found
2 merge requests!32Merge 2.4.4 UI to main,!27WS-2901: Added QL-product link to SECI products
......@@ -51,6 +51,7 @@ export class Product {
completed: boolean;
configurations: Array<ProductConfiguration>;
epoch: number;
epochHalf: number;
extraInfoForJobName: string;
fileNames: Array<string>;
futureProductId: number;
......
......@@ -43,6 +43,21 @@
<span *ngIf="!product.futureProductId">- none -</span>
</div>
<div class="mt-2" *ngIf="type.name === 'se_continuum_imaging'">
<strong>Associated Quicklook Product:</strong>
<a target="_blank" *ngIf="quicklookProduct$ | async as qp; else noQuicklook" [routerLink]="['/products']" [queryParams]="{pattern: qp.id, type: 'quicklook'}">
{{qp.name}}
</a>
<ng-template #noQuicklook>
<em *ngIf="(loadingQlProduct$ | async) === true">
Loading...
</em>
<span *ngIf="(loadingQlProduct$ | async) === false">
Not Found
</span>
</ng-template>
</div>
<div class="mt-2" *ngIf="product.versions.length > 0">
<h5 class="pb-2 m-0">
<fa-icon [icon]="faList"></fa-icon>
......
import {Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges} from '@angular/core';
import {Product, ProductType} from "../../../model/product";
import {FormControl, FormGroup} from "@angular/forms";
import {Observable, Subject, Subscription} from "rxjs";
import {Observable, Subject, Subscription, BehaviorSubject} from "rxjs";
import {ProductsService} from "../../../services/products.service";
import {JobsService} from "../../../services/jobs.service";
import {faChevronCircleRight, faCubes, faEdit, faFileCode, faList} from "@fortawesome/free-solid-svg-icons";
......@@ -19,6 +19,10 @@ export class ProductDetailsComponent implements OnInit, OnChanges, OnDestroy {
private ngUnsubscribe = new Subject();
@Input() product: Product;
private quicklookProduct = new BehaviorSubject<Product | null>(null);
quicklookProduct$ = this.quicklookProduct.asObservable();
private loadingQlProduct = new BehaviorSubject<boolean>(true);
loadingQlProduct$ = this.loadingQlProduct.asObservable();
type: ProductType;
......@@ -64,10 +68,11 @@ export class ProductDetailsComponent implements OnInit, OnChanges, OnDestroy {
ngOnChanges(changes: SimpleChanges): void {
if (changes.hasOwnProperty('product')) {
if (changes.product.currentValue.preRequisites.length > 0 &&
changes.product.currentValue.preRequisites[0].requiredProduct.versions.length > 0) {
let defaultVersion = changes.product.currentValue.preRequisites[0].requiredProduct.versions[0].versionNumber;
for (let version of changes.product.currentValue.preRequisites[0].requiredProduct.versions) {
const currProduct: Product = changes.product.currentValue;
if (currProduct.preRequisites.length > 0 &&
currProduct.preRequisites[0].requiredProduct.versions.length > 0) {
let defaultVersion = currProduct.preRequisites[0].requiredProduct.versions[0].versionNumber;
for (let version of currProduct.preRequisites[0].requiredProduct.versions) {
if (version.status === 'QA_ACCEPTED' && defaultVersion < version.versionNumber) {
defaultVersion = version.versionNumber;
}
......@@ -75,15 +80,27 @@ export class ProductDetailsComponent implements OnInit, OnChanges, OnDestroy {
this.jobFormGroup.get('version').setValue(defaultVersion);
}
// product.preRequisites[0].requiredProduct.versions.reverse()
this.productConfig = this.productService.getProductConfig(changes.product.currentValue.id, 'configurations');
this.mergedConfig = this.productService.getProductConfig(changes.product.currentValue.id, 'merged');
const productType = Product.getTypeFromName(changes.product.currentValue.typeName);
this.productConfig = this.productService.getProductConfig(currProduct.id, 'configurations');
this.mergedConfig = this.productService.getProductConfig(currProduct.id, 'merged');
const productType = Product.getTypeFromName(currProduct.typeName);
if (productType) {
this.type = productType;
this.queues$ = this.productService.getPageInfo(productType.id).pipe(takeUntil(this.ngUnsubscribe)).subscribe((queues: Array<string>) => {
this.queues = queues;
this.jobFormGroup.get('queue').setValue(queues[0]);
});
// Assumption: No Image Product will have > 1 minitile
// Checked on dev on 12/9/2024
if (currProduct.minitiles.length == 1) {
this.loadingQlProduct.next(true);
this.productService.getImageProductBy('quicklook', currProduct.minitiles[0].name, parseFloat(currProduct.phaseCenterRA), parseFloat(currProduct.phaseCenterDec), currProduct.epoch, currProduct.epochHalf).pipe(takeUntil(this.ngUnsubscribe)).subscribe(
quicklookProduct => {
this.quicklookProduct.next(quicklookProduct);
this.loadingQlProduct.next(false);
},
error => this.loadingQlProduct.next(false)
);
}
this.typeConfig = this.productService.getProductTypeConfig(productType.id);
}
}
......
......@@ -21,6 +21,7 @@ class HostComponent {
completed: false,
configurations: [],
epoch: 1,
epochHalf: 2,
extraInfoForJobName: "",
fileNames: ["PPR.xml"],
id: 18469,
......@@ -38,6 +39,7 @@ class HostComponent {
completed: false,
configurations: [],
epoch: 1,
epochHalf: 2,
extraInfoForJobName: "",
fileNames: ["PPR.xml"],
id: 987654,
......
......@@ -258,6 +258,7 @@ describe('ProductsComponent', () => {
completed: false,
configurations: [],
epoch: 1,
epochHalf: 2,
extraInfoForJobName: "T13t02.T13t08.T12t08",
fileNames: ["PPR.xml"],
id: 18469,
......@@ -308,6 +309,7 @@ describe('ProductsComponent', () => {
completed: false,
configurations: [],
epoch: 1,
epochHalf: 2,
extraInfoForJobName: "T13t02.T13t08.T12t08",
fileNames: ["PPR.xml"],
id: 18469,
......
......@@ -53,6 +53,7 @@ describe('ProductsService', () => {
completed: false,
configurations: [],
epoch: 1,
epochHalf: 2,
extraInfoForJobName: "JobName1",
fileNames: [],
id: 1,
......@@ -71,6 +72,7 @@ describe('ProductsService', () => {
completed: false,
configurations: [],
epoch: 1,
epochHalf: 2,
extraInfoForJobName: "JobName2",
fileNames: [],
id: 2,
......@@ -117,6 +119,7 @@ describe('ProductsService', () => {
completed: false,
configurations: [],
epoch: 1,
epochHalf: 2,
extraInfoForJobName: "JobName1",
fileNames: [],
id: 1,
......
......@@ -61,6 +61,24 @@ export class ProductsService {
}));
}
public getImageProductBy(productTypeName: string, minitileName: string, phaseCenterRA: number, phaseCenterDec: number, epoch: number, epochHalf: number): Observable<Product> {
let params = new HttpParams()
.append("productTypeName", productTypeName)
.append("minitileName", minitileName)
.append("phaseCenterRA", phaseCenterRA.toString())
.append("phaseCenterDec", phaseCenterDec.toString())
.append("epoch", epoch.toString())
.append("epochHalf", epochHalf.toString());
return this.http.get<Product>(
`${this.configService.config.url}${this.endPoint}byTypeTilePhaseCenter`,
{
params: params,
observe: "response",
}
)
.pipe(map(response => response.body));
}
public getProductConfig(id: number, type: string): Observable<object> {
return this.http.get<object>(this.configService.config.url + this.endPoint + 'byId/' + id + '/' + type, {observe: "response"}).pipe(
map(response => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment