feat: Update download file name in detail page

Add detail resource name and detail id in download file name, such as ,`instance-fd3ec1bb-9423-4537-b74e-8f967ed011c7-volumes-all-2021-09-13 16_15_20.csv` means downlaod all the volumes in instance fd3ec1bb-9423-4537-b74e-8f967ed011c7 detail page

Change-Id: Ied8e9ae5104b821866d44137679cccafc0f69656
This commit is contained in:
Jingwei.Zhang 2021-09-13 16:53:23 +08:00
parent 61f21da7e6
commit 5d69f66eac
4 changed files with 20 additions and 3 deletions

View File

@ -31,6 +31,7 @@ export default class index extends Component {
total: PropTypes.number,
getValueRenderFunc: PropTypes.func.isRequired,
resourceName: PropTypes.string,
extraName: PropTypes.string,
getData: PropTypes.func,
totalMax: PropTypes.number,
};
@ -41,6 +42,7 @@ export default class index extends Component {
total: 0,
totalMax: 10000,
resourceName: '',
extraName: '',
getData: () =>
Promise.resolve({
data: {
@ -171,10 +173,11 @@ export default class index extends Component {
getFileName = (all) => {
const timeStr = toLocalTimeFilter(new Date().getTime());
const { resourceName } = this.props;
const { resourceName, extraName } = this.props;
const name = extraName ? `${extraName}-${resourceName}` : resourceName;
return all
? `${resourceName}-${t('all')}-${timeStr}.csv`
: `${resourceName}-${timeStr}.csv`;
? `${name}-${t('all')}-${timeStr}.csv`
: `${name}-${timeStr}.csv`;
};
exportCurrentData = (event, all) => {

View File

@ -74,6 +74,7 @@ export default class BaseTable extends React.Component {
alwaysUpdate: PropTypes.bool,
emptyText: PropTypes.oneOfType([PropTypes.string || PropTypes.func]),
resourceName: PropTypes.string,
detailName: PropTypes.string,
expandable: PropTypes.object,
showTimeFilter: PropTypes.bool,
timeFilter: PropTypes.any,
@ -102,6 +103,7 @@ export default class BaseTable extends React.Component {
hideSearch: false,
hideCustom: false,
resourceName: '',
detailName: '',
expandable: undefined,
showTimeFilter: false,
isPageByBack: false,
@ -784,6 +786,7 @@ export default class BaseTable extends React.Component {
data,
columns,
resourceName,
detailName,
getDownloadData,
onClickAction,
onCancelAction,
@ -800,6 +803,7 @@ export default class BaseTable extends React.Component {
total,
getValueRenderFunc,
resourceName,
extraName: detailName,
getData: getDownloadData,
onBeginDownload: onClickAction,
onFinishDownload: onCancelAction,

View File

@ -140,6 +140,14 @@ export default class BaseList extends React.Component {
return !!detail;
}
get detailName() {
if (!this.inDetailPage) {
return '';
}
const { detailName } = this.props;
return detailName;
}
get shouldRefreshDetail() {
return true;
}
@ -462,6 +470,7 @@ export default class BaseList extends React.Component {
const { autoRefresh, tableHeight } = this.state;
return {
resourceName: this.name,
detailName: this.detailName,
data: this.getDataSource(),
// data:data,
columns: this.getColumns(),

View File

@ -369,6 +369,7 @@ export default class DetailBase extends React.Component {
<tabItem.component
{...this.props}
detail={this.detailData}
detailName={`${this.name}-${this.id}`}
refreshDetail={this.refreshDetailByTab}
/>
) : (