Skip to content
Snippets Groups Projects
Commit 7e9ed7c6 authored by Zoltan Runyo's avatar Zoltan Runyo
Browse files

ICSHWI-11790: Get ongoing command using 'Operation list' endpoint

parent ad48f993
No related branches found
No related tags found
2 merge requests!270Merging develop branch to master in order to create RC,!263Deployment API clean-up ICSHWI-11790 (FE modifications)
Pipeline #137321 passed
......@@ -344,23 +344,27 @@ export function unpackDeployment(deployment) {
return d;
}
export function unpackOngoingCommand(command) {
if (command) {
return { ...command };
}
return null;
export function unpackOngoingOperations(input) {
const { operations: operationsList, ...rest } = input;
const output = { ...rest, operationsList };
return output.totalCount > 0 ? output.operationsList[0] : null;
}
export function useOngoingCommand(iocId) {
const api = useContext(apiContext);
const method = useCallAndUnpack(
api.apis.Deployments.ongoingCommandByIoc,
unpackOngoingCommand
api.apis.Deployments.listOperations,
unpackOngoingOperations
);
const boundMethod = useCallback(method.bind(null, { ioc_id: iocId }), [
iocId
]);
return useAsync({ fcn: boundMethod, call: false });
const boundMethod = useCallback(
method.bind(null, { ioc_id: iocId, type: "COMMAND", status: "ONGOING" }),
[iocId]
);
return useAsync({
fcn: boundMethod,
call: false,
init: emptyOperationsListResponse
});
}
const emptyOperationsListResponse = {
......
......@@ -8,15 +8,17 @@ export const TYPE_COMMAND = "command";
function watchId(watchedId, storageKey) {
let watchedIds = JSON.parse(localStorage.getItem(storageKey));
if (watchedIds) {
if (!watchedIds.includes(watchedId)) {
localStorage.setItem(
storageKey,
JSON.stringify([watchedId].concat(watchedIds))
);
if (watchedId) {
if (watchedIds) {
if (!watchedIds.includes(watchedId)) {
localStorage.setItem(
storageKey,
JSON.stringify([watchedId].concat(watchedIds))
);
}
} else {
localStorage.setItem(storageKey, JSON.stringify([watchedId]));
}
} else {
localStorage.setItem(storageKey, JSON.stringify([watchedId]));
}
}
......
......@@ -37,9 +37,9 @@ export function IOCDetailsView({ ioc, getIOC, loading }) {
useOperationsSearch();
const [
ongoingCommand,
getOngoingCommand /* reset*/,
getOngoingCommand,
,
ongoingCommandLoading
/* reset*/ ongoingCommandLoading
] = useOngoingCommand(ioc.id);
const jobLazyParams = useCallback(() => {
......
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