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:
parent
61f21da7e6
commit
5d69f66eac
@ -31,6 +31,7 @@ export default class index extends Component {
|
|||||||
total: PropTypes.number,
|
total: PropTypes.number,
|
||||||
getValueRenderFunc: PropTypes.func.isRequired,
|
getValueRenderFunc: PropTypes.func.isRequired,
|
||||||
resourceName: PropTypes.string,
|
resourceName: PropTypes.string,
|
||||||
|
extraName: PropTypes.string,
|
||||||
getData: PropTypes.func,
|
getData: PropTypes.func,
|
||||||
totalMax: PropTypes.number,
|
totalMax: PropTypes.number,
|
||||||
};
|
};
|
||||||
@ -41,6 +42,7 @@ export default class index extends Component {
|
|||||||
total: 0,
|
total: 0,
|
||||||
totalMax: 10000,
|
totalMax: 10000,
|
||||||
resourceName: '',
|
resourceName: '',
|
||||||
|
extraName: '',
|
||||||
getData: () =>
|
getData: () =>
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
data: {
|
data: {
|
||||||
@ -171,10 +173,11 @@ export default class index extends Component {
|
|||||||
|
|
||||||
getFileName = (all) => {
|
getFileName = (all) => {
|
||||||
const timeStr = toLocalTimeFilter(new Date().getTime());
|
const timeStr = toLocalTimeFilter(new Date().getTime());
|
||||||
const { resourceName } = this.props;
|
const { resourceName, extraName } = this.props;
|
||||||
|
const name = extraName ? `${extraName}-${resourceName}` : resourceName;
|
||||||
return all
|
return all
|
||||||
? `${resourceName}-${t('all')}-${timeStr}.csv`
|
? `${name}-${t('all')}-${timeStr}.csv`
|
||||||
: `${resourceName}-${timeStr}.csv`;
|
: `${name}-${timeStr}.csv`;
|
||||||
};
|
};
|
||||||
|
|
||||||
exportCurrentData = (event, all) => {
|
exportCurrentData = (event, all) => {
|
||||||
|
@ -74,6 +74,7 @@ export default class BaseTable extends React.Component {
|
|||||||
alwaysUpdate: PropTypes.bool,
|
alwaysUpdate: PropTypes.bool,
|
||||||
emptyText: PropTypes.oneOfType([PropTypes.string || PropTypes.func]),
|
emptyText: PropTypes.oneOfType([PropTypes.string || PropTypes.func]),
|
||||||
resourceName: PropTypes.string,
|
resourceName: PropTypes.string,
|
||||||
|
detailName: PropTypes.string,
|
||||||
expandable: PropTypes.object,
|
expandable: PropTypes.object,
|
||||||
showTimeFilter: PropTypes.bool,
|
showTimeFilter: PropTypes.bool,
|
||||||
timeFilter: PropTypes.any,
|
timeFilter: PropTypes.any,
|
||||||
@ -102,6 +103,7 @@ export default class BaseTable extends React.Component {
|
|||||||
hideSearch: false,
|
hideSearch: false,
|
||||||
hideCustom: false,
|
hideCustom: false,
|
||||||
resourceName: '',
|
resourceName: '',
|
||||||
|
detailName: '',
|
||||||
expandable: undefined,
|
expandable: undefined,
|
||||||
showTimeFilter: false,
|
showTimeFilter: false,
|
||||||
isPageByBack: false,
|
isPageByBack: false,
|
||||||
@ -784,6 +786,7 @@ export default class BaseTable extends React.Component {
|
|||||||
data,
|
data,
|
||||||
columns,
|
columns,
|
||||||
resourceName,
|
resourceName,
|
||||||
|
detailName,
|
||||||
getDownloadData,
|
getDownloadData,
|
||||||
onClickAction,
|
onClickAction,
|
||||||
onCancelAction,
|
onCancelAction,
|
||||||
@ -800,6 +803,7 @@ export default class BaseTable extends React.Component {
|
|||||||
total,
|
total,
|
||||||
getValueRenderFunc,
|
getValueRenderFunc,
|
||||||
resourceName,
|
resourceName,
|
||||||
|
extraName: detailName,
|
||||||
getData: getDownloadData,
|
getData: getDownloadData,
|
||||||
onBeginDownload: onClickAction,
|
onBeginDownload: onClickAction,
|
||||||
onFinishDownload: onCancelAction,
|
onFinishDownload: onCancelAction,
|
||||||
|
@ -140,6 +140,14 @@ export default class BaseList extends React.Component {
|
|||||||
return !!detail;
|
return !!detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get detailName() {
|
||||||
|
if (!this.inDetailPage) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
const { detailName } = this.props;
|
||||||
|
return detailName;
|
||||||
|
}
|
||||||
|
|
||||||
get shouldRefreshDetail() {
|
get shouldRefreshDetail() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -462,6 +470,7 @@ export default class BaseList extends React.Component {
|
|||||||
const { autoRefresh, tableHeight } = this.state;
|
const { autoRefresh, tableHeight } = this.state;
|
||||||
return {
|
return {
|
||||||
resourceName: this.name,
|
resourceName: this.name,
|
||||||
|
detailName: this.detailName,
|
||||||
data: this.getDataSource(),
|
data: this.getDataSource(),
|
||||||
// data:data,
|
// data:data,
|
||||||
columns: this.getColumns(),
|
columns: this.getColumns(),
|
||||||
|
@ -369,6 +369,7 @@ export default class DetailBase extends React.Component {
|
|||||||
<tabItem.component
|
<tabItem.component
|
||||||
{...this.props}
|
{...this.props}
|
||||||
detail={this.detailData}
|
detail={this.detailData}
|
||||||
|
detailName={`${this.name}-${this.id}`}
|
||||||
refreshDetail={this.refreshDetailByTab}
|
refreshDetail={this.refreshDetailByTab}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
Loading…
Reference in New Issue
Block a user