diff --git a/src/reports/dlp.ts b/src/reports/dlp.ts index c5da566..d7fd69c 100644 --- a/src/reports/dlp.ts +++ b/src/reports/dlp.ts @@ -52,6 +52,7 @@ export class DLP { private static _elSubNav: HTMLElement = null; private static _items: IDLPItem[] = []; private static _loadOneDrive: boolean = false; + private static _maxItemCount: number = 0; private static _stopFl: boolean = false; // Gets the form fields to display @@ -79,6 +80,9 @@ export class DLP { // See if we are stopping this process if (this._stopFl) { return; } + // See if we are skipping large lists + if (this._maxItemCount > 0 && lib.ItemCount > this._maxItemCount) { return; } + // Update the dialog this._elSubNav.children[0].innerHTML = `${siteText} [Analyzing Library ${++counter} of ${libraries.length}]: ${lib.Title}`; @@ -540,6 +544,7 @@ export class DLP { static run(el: HTMLElement, auditOnly: boolean, values: { [key: string]: string }, onClose: () => void) { let data: IWebItem[] = []; this._loadOneDrive = values["LoadOneDrive"] == "true"; + this._maxItemCount = parseInt(values["SkipLargeLists"]) || 0; this._stopFl = false; // Clear the items @@ -586,7 +591,7 @@ export class DLP { web.Lists().query({ Filter: `Hidden eq false and BaseTemplate eq ${SPTypes.ListTemplateType.DocumentLibrary} or BaseTemplate eq ${SPTypes.ListTemplateType.MySiteDocumentLibrary} or BaseTemplate eq ${SPTypes.ListTemplateType.PageLibrary}`, GetAllItems: true, - Select: ["Id", "Title"], + Select: ["Id", "Title", "ItemCount"], Top: 5000 }).execute(libs => { // Add the libraries to analyze diff --git a/src/reports/searchAgents.ts b/src/reports/searchAgents.ts index 7ebe0c5..9250f00 100644 --- a/src/reports/searchAgents.ts +++ b/src/reports/searchAgents.ts @@ -24,6 +24,7 @@ export class SearchAgents { private static _elSubNav: HTMLElement = null; private static _items: IAgentItem[] = null; private static _loadOneDrive: boolean = null; + private static _maxItemCount: number = 0; private static _stopFl: boolean = false; // Analyzes a library @@ -92,6 +93,9 @@ export class SearchAgents { // See if we are stopping this process if (this._stopFl) { return; } + // See if we are skipping large lists + if (this._maxItemCount > 0 && lib.ItemCount > this._maxItemCount) { return; } + // Show a dialog this._elSubNav.children[0].innerHTML = `${siteText} - [Analyzing Library ${++ctrList} of ${libs.length}]: ${lib.Title}`; @@ -218,6 +222,7 @@ export class SearchAgents { // Runs the report static run(el: HTMLElement, auditOnly: boolean, values: { [key: string]: any }, onClose: () => void) { this._loadOneDrive = values["LoadOneDrive"] == "true"; + this._maxItemCount = parseInt(values["SkipLargeLists"]) || 0; this._stopFl = false; // Show a loading dialog diff --git a/src/reports/sensitivityLabels.ts b/src/reports/sensitivityLabels.ts index e39ccf1..4ee3fa2 100644 --- a/src/reports/sensitivityLabels.ts +++ b/src/reports/sensitivityLabels.ts @@ -50,6 +50,7 @@ export class SensitivityLabels { private static _filterLabels: string[] = []; private static _items: ISensitivityLabelItem[] = []; private static _loadOneDrive: boolean = false; + private static _maxItemCount: number = 0; private static _stopFl: boolean = false; // Analyzes the libraries @@ -66,6 +67,9 @@ export class SensitivityLabels { // See if we are stopping this process if (this._stopFl) { return; } + // See if we are skipping large lists + if (this._maxItemCount > 0 && lib.ItemCount > this._maxItemCount) { return; } + // Update the dialog this._elSubNav.children[0].innerHTML = `${siteText} [Analyzing Library ${++counter} of ${libraries.length}]: ${lib.Title}`; @@ -460,6 +464,7 @@ export class SensitivityLabels { static run(el: HTMLElement, auditOnly: boolean, values: { [key: string]: string }, onClose: () => void) { let data: IWebItem[] = []; this._loadOneDrive = values["LoadOneDrive"] == "true"; + this._maxItemCount = parseInt(values["SkipLargeLists"]) || 0; this._stopFl = false; // Clear the items @@ -529,7 +534,7 @@ export class SensitivityLabels { Filter: filter, Expand: ["RootFolder"], GetAllItems: true, - Select: ["Id", "Title", "RootFolder/ServerRelativeUrl"], + Select: ["Id", "ItemCount", "Title", "RootFolder/ServerRelativeUrl"], Top: 5000 }).execute(libs => { // Add the libraries to analyze diff --git a/src/reports/uniquePermissions.ts b/src/reports/uniquePermissions.ts index de4d768..f6f3e2d 100644 --- a/src/reports/uniquePermissions.ts +++ b/src/reports/uniquePermissions.ts @@ -33,6 +33,7 @@ export class UniquePermissions { private static _elSubNav: HTMLElement = null; private static _items: IPermission[] = []; private static _loadOneDrive: boolean = false; + private static _maxItemCount: number = 0; private static _stopFl: boolean = false; // Analyzes a list @@ -333,6 +334,7 @@ export class UniquePermissions { // Runs the report static run(el: HTMLElement, auditOnly: boolean, values: { [key: string]: string }, onClose: () => void) { this._loadOneDrive = values["LoadOneDrive"] == "true"; + this._maxItemCount = parseInt(values["SkipLargeLists"]) || 0; this._stopFl = false; // Show a loading dialog @@ -378,7 +380,7 @@ export class UniquePermissions { web.Lists().query({ Filter: "Hidden eq false", Expand: ["DefaultDisplayFormUrl", "DefaultViewFormUrl", "RootFolder"], - Select: ["BaseTemplate", "Id", "Title", "HasUniqueRoleAssignments", "RootFolder/ServerRelativeUrl"] + Select: ["BaseTemplate", "Id", "ItemCount", "Title", "HasUniqueRoleAssignments", "RootFolder/ServerRelativeUrl"] }).execute(lists => { let ctrList = 0; @@ -390,6 +392,9 @@ export class UniquePermissions { // See if we are stopping this process if (this._stopFl) { return; } + // See if we are skipping large lists + if (this._maxItemCount > 0 && list.ItemCount > this._maxItemCount) { return; } + // Update the dialog this._elSubNav.children[0].innerHTML = `${siteText} - [Analyzing Library ${++ctrList} of ${lists.results.length}]: ${list.Title}`; diff --git a/src/tabs/reports.ts b/src/tabs/reports.ts index 2d759f1..4e454bb 100644 --- a/src/tabs/reports.ts +++ b/src/tabs/reports.ts @@ -231,6 +231,33 @@ export class ReportsTab { } } + // See if this is a report is analyzing lists + switch (this._selectedReport) { + case ReportTypes.DLP: + case ReportTypes.SearchAgents: + case ReportTypes.SearchDocs: + case ReportTypes.SensitivityLabels: + case ReportTypes.UniquePermissions: + // Add a control to skip large lists/libraries + this._form.appendControls([{ + name: "SkipLargeLists", + label: "Skip Large Lists", + description: "Skips lists/libraries that have more than the items specified.", + type: Components.FormControlTypes.Dropdown, + items: [ + { text: "All Lists", value: "0", isSelected: true }, + { text: ">500 Items", value: "500" }, + { text: ">1000 Items", value: "1000" }, + { text: ">5000 Items", value: "1000" }, + { text: ">10000 Items", value: "10000" }, + { text: ">25000 Items", value: "25000" }, + { text: ">50000 Items", value: "50000" }, + { text: ">100000 Items", value: "100000" }, + ] + } as Components.IFormControlPropsDropdown]); + break; + } + // Add the controls switch (this._selectedReport) { case ReportTypes.DLP: @@ -292,6 +319,7 @@ export class ReportsTab { // Set the form values let formValues = this._form.getValues(); formValues["LoadOneDrive"] = this._loadOneDrive ? "true" : "false"; + formValues["SkipLargeLists"] = formValues["SkipLargeLists"]?.value || "0"; // See if we are targeting a sub-web if (DataSource.WebOnly) {