Skip to content

Commit

Permalink
estela-web: Handle updated response format when deleting data
Browse files Browse the repository at this point in the history
  • Loading branch information
mgonnav committed Dec 14, 2023
1 parent 5d014c1 commit 8af58b1
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 79 deletions.
10 changes: 3 additions & 7 deletions estela-web/src/pages/JobDataListPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { RouteComponentProps } from "react-router-dom";

import "./styles.scss";
import { ApiService } from "../../services";
import {
ApiProjectsSpidersJobsDataListRequest,
ApiProjectsSpidersJobsDataDeleteRequest,
DeleteJobData,
} from "../../services/api";
import { ApiProjectsSpidersJobsDataListRequest, ApiProjectsSpidersJobsDataDeleteRequest } from "../../services/api";
import { resourceNotAllowedNotification, dataDeletedNotification, Spin } from "../../shared";

const { Content } = Layout;
Expand Down Expand Up @@ -59,9 +55,9 @@ export class JobDataListPage extends Component<RouteComponentProps<RouteParams>,
type: this.type,
};
this.apiService.apiProjectsSpidersJobsDataDelete(request).then(
(response: DeleteJobData) => {
() => {
this.setState({ data: [], count: 0, current: 0, loaded: true });
dataDeletedNotification(response.count);
dataDeletedNotification();
},
(error: unknown) => {
error;
Expand Down
6 changes: 3 additions & 3 deletions estela-web/src/pages/JobDataPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
ApiProjectsSpidersJobsDataListRequest,
ApiProjectsSpidersJobsDataDeleteRequest,
ApiProjectsSpidersJobsDataDownloadRequest,
DeleteJobData,
InlineResponse2006,
InlineResponse2008,
} from "../../services/api";
Expand Down Expand Up @@ -43,8 +42,8 @@ const deleteSpiderJobData = (type_: string, projectId: string, spiderId: string,
type: type_,
};
return apiService.apiProjectsSpidersJobsDataDelete(request).then(
(response: DeleteJobData) => {
dataDeletedNotification(response.count);
() => {
dataDeletedNotification();
return true;
},
(error: unknown) => {
Expand Down Expand Up @@ -656,6 +655,7 @@ export function JobLogsData({ projectId, spiderId, jobId }: JobsDataProps) {
const [count, setCount] = useState(0);
const [loaded, setLoaded] = useState(false);
const [logs, setLogs] = useState<Dictionary[]>([]);

useEffect(() => {
getData("logs", 1, projectId, spiderId, jobId).then((response) => {
let data: Dictionary[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ models/Activity.ts
models/AuthToken.ts
models/ChangePassword.ts
models/CoverageStats.ts
models/DeleteJobData.ts
models/Deploy.ts
models/DeployCreate.ts
models/DeployUpdate.ts
Expand Down
12 changes: 4 additions & 8 deletions estela-web/src/services/api/generated-api/apis/ApiApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import {
ChangePassword,
ChangePasswordFromJSON,
ChangePasswordToJSON,
DeleteJobData,
DeleteJobDataFromJSON,
DeleteJobDataToJSON,
Deploy,
DeployFromJSON,
DeployToJSON,
Expand Down Expand Up @@ -2071,7 +2068,7 @@ export class ApiApi extends runtime.BaseAPI {

/**
*/
async apiProjectsSpidersJobsDataDeleteRaw(requestParameters: ApiProjectsSpidersJobsDataDeleteRequest): Promise<runtime.ApiResponse<DeleteJobData>> {
async apiProjectsSpidersJobsDataDeleteRaw(requestParameters: ApiProjectsSpidersJobsDataDeleteRequest): Promise<runtime.ApiResponse<void>> {
if (requestParameters.jid === null || requestParameters.jid === undefined) {
throw new runtime.RequiredError('jid','Required parameter requestParameters.jid was null or undefined when calling apiProjectsSpidersJobsDataDelete.');
}
Expand Down Expand Up @@ -2106,14 +2103,13 @@ export class ApiApi extends runtime.BaseAPI {
query: queryParameters,
});

return new runtime.JSONApiResponse(response, (jsonValue) => DeleteJobDataFromJSON(jsonValue));
return new runtime.VoidApiResponse(response);
}

/**
*/
async apiProjectsSpidersJobsDataDelete(requestParameters: ApiProjectsSpidersJobsDataDeleteRequest): Promise<DeleteJobData> {
const response = await this.apiProjectsSpidersJobsDataDeleteRaw(requestParameters);
return await response.value();
async apiProjectsSpidersJobsDataDelete(requestParameters: ApiProjectsSpidersJobsDataDeleteRequest): Promise<void> {
await this.apiProjectsSpidersJobsDataDeleteRaw(requestParameters);
}

/**
Expand Down
57 changes: 0 additions & 57 deletions estela-web/src/services/api/generated-api/models/DeleteJobData.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export interface SpiderJobUpdate {
* @memberof SpiderJobUpdate
*/
dataExpiryDays?: number;
/**
* Proxy Usage data.
* @type {string}
* @memberof SpiderJobUpdate
*/
proxyUsageData?: string;
}

/**
Expand Down Expand Up @@ -108,6 +114,7 @@ export function SpiderJobUpdateFromJSONTyped(json: any, ignoreDiscriminator: boo
'requestCount': !exists(json, 'request_count') ? undefined : json['request_count'],
'dataStatus': !exists(json, 'data_status') ? undefined : json['data_status'],
'dataExpiryDays': !exists(json, 'data_expiry_days') ? undefined : json['data_expiry_days'],
'proxyUsageData': !exists(json, 'proxy_usage_data') ? undefined : json['proxy_usage_data'],
};
}

Expand All @@ -127,6 +134,7 @@ export function SpiderJobUpdateToJSON(value?: SpiderJobUpdate | null): any {
'request_count': value.requestCount,
'data_status': value.dataStatus,
'data_expiry_days': value.dataExpiryDays,
'proxy_usage_data': value.proxyUsageData,
};
}

Expand Down
1 change: 0 additions & 1 deletion estela-web/src/services/api/generated-api/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export * from './Activity';
export * from './AuthToken';
export * from './ChangePassword';
export * from './CoverageStats';
export * from './DeleteJobData';
export * from './Deploy';
export * from './DeployCreate';
export * from './DeployUpdate';
Expand Down
4 changes: 2 additions & 2 deletions estela-web/src/shared/notifications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export const resourceNotAllowedNotification = (): void => {
history.push("/");
};

export const dataDeletedNotification = (n: number): void => {
export const dataDeletedNotification = (): void => {
notification.open({
message: "Data Successfully Deleted",
description: `${n} Items have been deleted`,
description: "All items have been deleted",
});
};

Expand Down

0 comments on commit 8af58b1

Please sign in to comment.