Skip to content

Commit c756fda

Browse files
committed
Merged PR 85066: Persistent State - add user state APIs
Add support for users to reset their user state by using `Report.resetUserState()`.
1 parent e3a6adf commit c756fda

File tree

4 files changed

+140
-25
lines changed

4 files changed

+140
-25
lines changed

dist/powerbi-client.d.ts

+27
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,33 @@ declare module "report" {
11661166
* ```
11671167
*/
11681168
resetTheme(): Promise<void>;
1169+
/**
1170+
* Reset user's filters, slicers, and other data view changes to the default state of the report
1171+
*
1172+
* ```javascript
1173+
* report.resetPersistentFilters();
1174+
* ```
1175+
*/
1176+
resetPersistentFilters(): Promise<void>;
1177+
/**
1178+
* Save user's filters, slicers, and other data view changes of the report
1179+
*
1180+
* ```javascript
1181+
* report.savePersistentFilters();
1182+
* ```
1183+
*/
1184+
savePersistentFilters(): Promise<void>;
1185+
/**
1186+
* Returns if there are user's filters, slicers, or other data view changes applied on the report.
1187+
* If persistent filters is disable, returns false.
1188+
*
1189+
* ```javascript
1190+
* report.arePersistentFiltersApplied();
1191+
* ```
1192+
*
1193+
* @returns {Promise<boolean>}
1194+
*/
1195+
arePersistentFiltersApplied(): Promise<boolean>;
11691196
/**
11701197
* @hidden
11711198
*/

dist/powerbi.js

+42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/powerbi.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/report.ts

+70-24
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ export class Report extends embed.Embed implements IReportNode, IFilterable {
104104
*/
105105
render(config?: IReportLoadConfiguration): Promise<void> {
106106
return this.service.hpm.post<models.IError[]>(`/report/render`, config, { uid: this.config.uniqueId }, this.iframe.contentWindow)
107-
.then(response => {
108-
return response.body;
109-
})
110-
.catch(response => {
111-
throw response.body;
112-
});
107+
.then(response => {
108+
return response.body;
109+
})
110+
.catch(response => {
111+
throw response.body;
112+
});
113113
}
114114

115115
/**
@@ -128,12 +128,12 @@ export class Report extends embed.Embed implements IReportNode, IFilterable {
128128
};
129129

130130
return this.service.hpm.post<models.IPage>(`/report/addPage`, request, { uid: this.config.uniqueId }, this.iframe.contentWindow)
131-
.then(response => {
132-
var page = response.body;
133-
return new Page(this, page.name, page.displayName, page.isActive, page.visibility, page.defaultSize, page.defaultDisplayOption);
134-
}, response => {
135-
throw response.body;
136-
});
131+
.then(response => {
132+
var page = response.body;
133+
return new Page(this, page.name, page.displayName, page.isActive, page.visibility, page.defaultSize, page.defaultDisplayOption);
134+
}, response => {
135+
throw response.body;
136+
});
137137
}
138138

139139
/**
@@ -147,13 +147,13 @@ export class Report extends embed.Embed implements IReportNode, IFilterable {
147147
* @returns {Promise<void>}
148148
*/
149149
deletePage(pageName?: string): Promise<void> {
150-
return this.service.hpm.delete<models.IError[]>(`/report/pages/${pageName}`, { }, { uid: this.config.uniqueId }, this.iframe.contentWindow)
151-
.then(response => {
152-
return response.body;
153-
})
154-
.catch(response => {
155-
throw response.body;
156-
});
150+
return this.service.hpm.delete<models.IError[]>(`/report/pages/${pageName}`, {}, { uid: this.config.uniqueId }, this.iframe.contentWindow)
151+
.then(response => {
152+
return response.body;
153+
})
154+
.catch(response => {
155+
throw response.body;
156+
});
157157
}
158158

159159
/**
@@ -176,9 +176,9 @@ export class Report extends embed.Embed implements IReportNode, IFilterable {
176176

177177
return this.service.hpm.get<models.IFilter[]>(`/report/filters`, { uid: this.config.uniqueId }, this.iframe.contentWindow)
178178
.then(response => response.body,
179-
response => {
180-
throw response.body;
181-
});
179+
response => {
180+
throw response.body;
181+
});
182182
}
183183

184184
/**
@@ -451,7 +451,7 @@ export class Report extends embed.Embed implements IReportNode, IFilterable {
451451
})
452452
.catch(response => {
453453
throw response.body;
454-
});
454+
});
455455
}
456456

457457
/**
@@ -501,6 +501,52 @@ export class Report extends embed.Embed implements IReportNode, IFilterable {
501501
return this.applyThemeInternal(<models.IReportTheme>{});
502502
}
503503

504+
/**
505+
* Reset user's filters, slicers, and other data view changes to the default state of the report
506+
*
507+
* ```javascript
508+
* report.resetPersistentFilters();
509+
* ```
510+
*/
511+
resetPersistentFilters(): Promise<void> {
512+
return this.service.hpm.delete<models.IError[]>(`/report/userState`, null, { uid: this.config.uniqueId }, this.iframe.contentWindow)
513+
.catch(response => {
514+
throw response.body;
515+
});
516+
}
517+
518+
/**
519+
* Save user's filters, slicers, and other data view changes of the report
520+
*
521+
* ```javascript
522+
* report.savePersistentFilters();
523+
* ```
524+
*/
525+
savePersistentFilters(): Promise<void> {
526+
return this.service.hpm.post<models.IError[]>(`/report/userState`, null, { uid: this.config.uniqueId }, this.iframe.contentWindow)
527+
.catch(response => {
528+
throw response.body;
529+
});
530+
}
531+
532+
/**
533+
* Returns if there are user's filters, slicers, or other data view changes applied on the report.
534+
* If persistent filters is disable, returns false.
535+
*
536+
* ```javascript
537+
* report.arePersistentFiltersApplied();
538+
* ```
539+
*
540+
* @returns {Promise<boolean>}
541+
*/
542+
arePersistentFiltersApplied(): Promise<boolean> {
543+
return this.service.hpm.get<boolean>(`/report/isUserStateApplied`, { uid: this.config.uniqueId }, this.iframe.contentWindow)
544+
.then(response => response.body,
545+
response => {
546+
throw response.body;
547+
});
548+
}
549+
504550
/**
505551
* @hidden
506552
*/
@@ -530,7 +576,7 @@ export class Report extends embed.Embed implements IReportNode, IFilterable {
530576

531577
return mode;
532578
}
533-
579+
534580
/**
535581
* @hidden
536582
*/

0 commit comments

Comments
 (0)