Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature](ui) web profile download use plain text #34705

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ public Object profile(@PathVariable(value = ID) String id) {
return ResponseEntityBuilder.ok(profile);
}

@RequestMapping(path = "/query_profile/text/{" + ID + "}", method = RequestMethod.GET)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when this API will be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

web use download

HappenLee marked this conversation as resolved.
Show resolved Hide resolved
public Object profileText(@PathVariable(value = ID) String id) {
String queryProfileStr = ProfileManager.getInstance().getProfile(id);
if (queryProfileStr == null) {
return "query id " + id + " not found";
}
return queryProfileStr;
}

@RequestMapping(path = "/query_profile", method = RequestMethod.GET)
public Object query() {
Map<String, Object> result = Maps.newHashMap();
Expand Down
24 changes: 24 additions & 0 deletions ui/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@ export function queryProfile<T>(data: any): Promise<Result<T>> {
return request(LocalUrl, data);
}

//query_profileText
export function queryProfileText(data: any): Promise<string> {
let LocalUrl = '/rest/v1/query_profile/';
if (data.path) {
LocalUrl = `/rest/v1/query_profile/text/${data.path}`;
}
const headers = new Headers();
headers.append('Accept', 'text/plain');

return fetch(LocalUrl, {
method: 'GET',
headers: headers
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.text();
})
.catch(error => {
console.error('Error fetching data:', error);
return '';
});
}
//session
export function getSession<T>(data: any): Promise<Result<T>> {
return request('/rest/v1/session', data);
Expand Down
23 changes: 6 additions & 17 deletions ui/src/pages/query-profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React, { useEffect, useRef, useState } from 'react';
import { Button, Col, Row, Typography, Space } from 'antd';
import { queryProfile } from 'Src/api/api';
import { queryProfile,queryProfileText } from 'Src/api/api';
import Table from 'Src/components/table';
import { useHistory } from 'react-router-dom';
import { Result } from '@src/interfaces/http.interface';
Expand Down Expand Up @@ -70,24 +70,13 @@ export default function QueryProfile(params: any) {
<Button
size="small"
onClick={() => {
queryProfile<any>({
queryProfileText<any>({
path: row['Profile ID'],
}).then((profileDetailRes) => {
if (
profileDetailRes &&
profileDetailRes.msg ===
'success'
) {
if (
!profileDetailRes.data
.column_names
) {
download(
profileDetailRes.data,
row['Profile ID']
);
}
}
download(
profileDetailRes,
row['Profile ID']
);
});
}}
>
Expand Down
Loading