Skip to content
Snippets Groups Projects
Commit 55d688bb authored by Andrew Kapuscinski's avatar Andrew Kapuscinski
Browse files

WS-848: display SDM ID and SRDP status on list of calibratables page

parent 2cbf1a4a
No related branches found
No related tags found
1 merge request!727WS-848: display SDM ID and SRDP status on list of calibratables page
Pipeline #4069 passed
......@@ -28,11 +28,12 @@
<tr>
<th>Request</th>
<th>Execution Status</th>
<th>Fileset ID</th>
<th>SDM ID</th>
<th>Bands</th>
<th>Array Configuration</th>
<th>Observation Start Time</th>
<th>Observation End Time</th>
<th>SRDP</th>
<th>Operation</th>
</tr>
</thead>
......@@ -49,11 +50,18 @@
</button>
</td>
<td>{{ request.current_execution ? request.current_execution.state : "" }}</td>
<td>{{ getMetadata(request).fileset_id }}</td>
<td>{{ getMetadata(request).sdm_id }}</td>
<td>{{ getMetadata(request).bands }}</td>
<td>{{ getMetadata(request).array_config }}</td>
<td>{{ getMetadata(request).obs_start_time }}</td>
<td>{{ getMetadata(request).obs_end_time }}</td>
<td>
<div class="form-check">
<input (change)="toggleSRDPCompatibility(request.id, request.versions[0].version_number, getMetadata(request).is_srdp)" class="form-check-input" type="checkbox" value="" id="srdp-compatible-checkbox" [checked]="getMetadata(request).is_srdp">
</div>
</td>
<td>
</td>
</tr>
</tbody>
</table>
......@@ -103,4 +103,17 @@ export class ListOfCalibratablesComponent implements OnInit {
.togglePauseCapability(this.stdCalibrationCapability, pauseAction)
.subscribe(togglePauseCapabilityObservable);
}
public toggleSRDPCompatibility(request_id: string, version_id: number, isSRDP: boolean): void {
const toggleSRDPCompatibilityObservable = {
next: (request) => {
},
error: (error) => {
console.error("Error when toggling SRDP-Compatibility:" + error);
},
};
this.capabilityRequestService
.toggleSRDPCompatibility(request_id, version_id, isSRDP)
.subscribe(toggleSRDPCompatibilityObservable)
}
}
......@@ -208,4 +208,16 @@ export class CapabilityRequestService {
// Open URL in new tab
window.open(statusPageUrl, "_blank");
}
/**
* Toggles SRDP Compatibility to true and false
* @param request_id Given request ID
* @param version_id Given version ID
* @param isAlreadySRDP The current status of SRDP-Compatability
*/
public toggleSRDPCompatibility(request_id: string, version_id: number, isAlreadySRDP: boolean): Observable<any> {
const url = `/capability/request/${request_id}/version/${version_id}/srdp_compatible`;
let toggleSRDP = isAlreadySRDP ? false : true
return this.httpClient.post<any>(url, JSON.stringify(toggleSRDP));
}
}
......@@ -20,6 +20,7 @@ import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Observable } from "rxjs";
import { Capability } from "../model/capability";
import {environment} from "../../../environments/environment";
@Injectable({
providedIn: "root",
......
......@@ -166,6 +166,13 @@ def capability_version_routes(config: Configurator):
request_method="POST",
)
# Update the workflow metadata
config.add_route(
name="change_srdp_compatibility_version_metadata",
pattern="capability/request/{capability_request_id}/version/{version_id}/srdp_compatible",
request_method="POST",
)
def capability_execution_routes(config: Configurator):
"""
......
......@@ -19,7 +19,14 @@
File containing definitions for the capability version routes of the Workspaces REST API
"""
from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound, HTTPPreconditionFailed
import requests
from pycapo import CapoConfig
from pyramid.httpexceptions import (
HTTPBadRequest,
HTTPInternalServerError,
HTTPNotFound,
HTTPPreconditionFailed,
)
from pyramid.request import Request
from pyramid.response import Response
from pyramid.view import view_config
......@@ -240,3 +247,37 @@ def edit_version_metadata(request: Request) -> Response:
else:
no_versions_msg = f"Capability request {capability_request_id} version {version_id} not found."
return HTTPNotFound(detail=no_versions_msg)
@view_config(route_name="change_srdp_compatibility_version_metadata", renderer="json")
def change_srdp_compatibility_version_metadata(request: Request) -> Response:
"""
Pyramid view that accepts a request to change the SRDP-Compatibility status of a specific version of a capability request
URL: capability/request/{capability_request_id}/version/{version_id}/srdp_compatible
:param request: GET request
:return: 200 OK response with SRDP-Compatibility status of specified version of request with given ID
or 404 response (HTTPNotFound) if capability request with given ID does not exist
or 412 response (HTTPPreconditionFailed) if capability request with given ID has no versions
or 500 response (HTTPInternalServerError) if request to archive is_srdp endpoint fails
"""
capability_request_id = request.matchdict["capability_request_id"]
version_id = request.matchdict["version_id"]
if version := request.capability_info.lookup_version(capability_request_id, version_id):
settings = CapoConfig().settings("edu.nrao.workspaces.ProductFetcherSettings")
archive_url = settings.locatorServiceUrlPrefix
# split the locatorServiceUrlPrefix to get url without /location?
archive_url = archive_url.split("/location?")
version.parameters["metadata"]["is_srdp"] = request.json_body
change_srdp_url = archive_url[0] + f"/is_srdp?locator={version.parameters['product_locator']}"
r = requests.post(change_srdp_url, json=request.json_body)
if r.status_code != requests.codes.ok:
srdp_change_failed_msg = f"SRDP-Compatibility change failed: {r.status_code}"
return HTTPInternalServerError(detail=srdp_change_failed_msg)
request.capability_info.save_version(version)
return request.json_body
else:
no_versions_msg = f"Capability request {capability_request_id} version {version_id} not found."
return HTTPNotFound(detail=no_versions_msg)
......@@ -83,6 +83,7 @@ def capability_routes() -> RouteList:
"submit_capability_version",
"add_file_to_latest",
"get_execution_from_workflow_id",
"change_srdp_compatibility_version_metadata",
]
......
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