Skip to content
Merged
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
2 changes: 1 addition & 1 deletion spfx/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"externals": {
"main-lib": {
"globalName": "main-lib",
"path": "../dist/site-admin.js"
"path": "../dist/site-admin.min.js"
}
},
"localizedResources": {
Expand Down
275 changes: 155 additions & 120 deletions spfx/src/webparts/siteAdmin/SiteAdminWebPart.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Version } from '@microsoft/sp-core-library';
import { DisplayMode, Version } from '@microsoft/sp-core-library';
import {
IPropertyPaneConfiguration, IPropertyPaneGroup,
PropertyPaneButton, PropertyPaneDropdown, PropertyPaneHorizontalRule,
Expand Down Expand Up @@ -67,10 +67,10 @@ export interface ISiteAdminWebPartProps {
MaxStorageDescription: string;
ReportsDocRententionYears: string;
ReportsDLPFileExt: string;
ReportsDLPGroups: string;
ReportsDocSearchFileExt: string;
ReportsDocSearchKeywords: string;
ReportsDocSearchRegexPatterns: string;
ReportsOversharedGroups: string;
SensitivityLabelFileExt: string;
SiteAttestation: boolean;
SiteAttestationText: string;
Expand Down Expand Up @@ -202,10 +202,10 @@ declare const SiteAdmin: {
reportProps?: {
docRententionYears?: string;
dlpFileExt?: string;
dlpGroups?: string[];
docSearchFileExt?: string;
docSearchKeywords?: string;
docSearchRegexPatterns?: string;
oversharedGroups?: string[];
sensitivityLabelFileExt?: string;
}
searchProps?: {
Expand Down Expand Up @@ -237,127 +237,38 @@ declare const SiteAdmin: {
};

export default class SiteAdminWebPart extends BaseClientSideWebPart<ISiteAdminWebPartProps> {
private _hasRendered: boolean = false;

public render(): void {
const propValues = (this.properties as any);
const siteProps: {
[key: string]: {
description: string;
disabled: boolean;
label: string;
}
} = {};
const webProps: {
[key: string]: {
description: string;
disabled: boolean;
label: string;
}
} = {};
// Do nothing if we have already rendered the webpart
if (this._hasRendered) { return; }

// Parse the site properties
for (let i = 0; i < this._siteProps.length; i++) {
const propName = this._siteProps[i];
const key = propName.replace("SiteProp", "");
// See if the page is in edit mode
if (this.displayMode === DisplayMode.Edit) {
// Don't render the application
this.domElement.classList.add("bs");
this.domElement.innerHTML = `
<p>The page is in edit mode and will not render the application.</p>
<input type="button" class="btn btn-primary" value="Configure SPARK WebPart" />
`;
this.domElement.querySelector("input")?.addEventListener("click", () => {
// Open the property pane
this.context.propertyPane.open();
});

// Add the property
siteProps[key] = {
description: propValues[propName + "Description"],
disabled: propValues[propName],
label: propValues[propName + "Label"]
};
// Set the flag
this._hasRendered = true;
return;
}

// Parse the web properties
for (let i = 0; i < this._webProps.length; i++) {
const propName = this._webProps[i];
const key = propName.replace("WebProp", "");
// Render the app
if (!this._hasRendered) {
// Render the app
this.renderApp();

// Add the property
webProps[key] = {
description: propValues[propName + "Description"],
disabled: propValues[propName],
label: propValues[propName + "Label"]
};
// Set the flag
this._hasRendered = true;
}

// Determine the size
let maxStorageSize = this.properties.MaxStorage;
if (maxStorageSize) {
// See if this is in TB
if (maxStorageSize.toString().indexOf("TB") > 0) {
// Remove the TB and convert to a number
maxStorageSize = parseInt(maxStorageSize.toString().replace("TB", ""));
}
// Else, see if this is in GB
else if (maxStorageSize.toString().indexOf("GB") > 0) {
// Remove the GB, and convert to a number in TB
maxStorageSize = parseInt(maxStorageSize.toString().replace("GB", "")) / 1000;
}
}

// Render the solution
SiteAdmin.render({
auditOnly: this.properties.AuditOnly,
context: this.context,
el: this.domElement,
disableSensitivityLabelOverride: this.properties.DisableSensitivityLabelOverride ? true : false,
hideCreateSiteBtn: this.properties.HideCreateSiteBtn ? true : false,
hideLoadAdminOwnerBtn: this.properties.HideLoadAdminOwnerBtn ? true : false,
hideLoadOneDriveBtn: this.properties.HideLoadOneDriveBtn ? true : false,
hideReports: {
dlp: this.properties.HideReportDLP ? true : false,
docRetention: this.properties.HideReportDocRetention ? true : false,
externalShares: this.properties.HideReportExternalShares ? true : false,
externalUsers: this.properties.HideReportExternalUsers ? true : false,
permissions: this.properties.HideReportPermissions ? true : false,
retention: this.properties.HideReportRetention ? true : false,
searchAgents: this.properties.HideReportSearchAgents ? true : false,
searchDocs: this.properties.HideReportSearchDocs ? true : false,
searchEEEU: this.properties.HideReportSearchEEEU ? true : false,
searchProp: this.properties.HideReportSearchProp ? true : false,
searchUsers: this.properties.HideReportSearchUsers ? true : false,
sensitivityLabels: this.properties.HideReportSensitivityLabels ? true : false,
sharingLinks: this.properties.HideReportSharingLinks ? true : false,
uniquePermissions: this.properties.HideReportUniquePermissions ? true : false
},
hideTabs: {
appPermissions: this.properties.HideAppPermissionsTab ? true : false,
auditTools: this.properties.HideAuditToolsTab ? true : false,
features: this.properties.HideFeaturesTab ? true : false,
lists: this.properties.HideListsTab ? true : false,
management: this.properties.HideManagementTab ? true : false,
search: this.properties.HideSearchTab ? true : false,
webs: this.properties.HideWebsTab ? true : false
},
imageReferences,
maxBatchSize: this.properties.MaxBatchSize,
maxRequests: this.properties.MaxRequests,
maxStorageDesc: this.properties.MaxStorageDescription,
maxStorageSize,
reportProps: {
dlpFileExt: this.properties.ReportsDLPFileExt,
dlpGroups: (this.properties.ReportsDLPGroups || "").split(",").map(group => group.trim()),
docRententionYears: this.properties.ReportsDocRententionYears,
docSearchFileExt: this.properties.ReportsDocSearchFileExt,
docSearchKeywords: this.properties.ReportsDocSearchKeywords,
docSearchRegexPatterns: this.properties.ReportsDocSearchRegexPatterns,
sensitivityLabelFileExt: this.properties.SensitivityLabelFileExt
},
searchProps: {
description: this.properties.WebPropSearchPropertyDescription,
key: this.properties.WebPropSearchPropertyKey,
label: this.properties.WebPropSearchPropertyLabel,
managedProperty: this.properties.WebPropSearchPropertyManagedProperty,
reportName: this.properties.WebPropSearchPropertyReportName,
tabName: this.properties.WebPropSearchPropertyTabName,
values: this.properties.WebPropSearchPropertyValues
},
siteAttestation: this.properties.SiteAttestation,
siteAttestationText: this.properties.SiteAttestationText,
siteProps,
title: this.properties.AppTitle,
webProps
});
}

protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
Expand Down Expand Up @@ -664,12 +575,12 @@ export default class SiteAdminWebPart extends BaseClientSideWebPart<ISiteAdminWe
rows: 6,
value: this.properties.ReportsDLPFileExt
}),
PropertyPaneTextField("ReportsDLPGroups", {
label: strings.ReportsDLPGroups,
PropertyPaneTextField("ReportsOversharedGroups", {
label: strings.ReportsOversharedGroups,
description: "A CSV formatted string containing the group names to indicate a file being overshared. Do not include Everyone or EEEU, as they are the default groups to indicate oversharing.",
multiline: true,
rows: 6,
value: this.properties.ReportsDLPGroups
value: this.properties.ReportsOversharedGroups
}),
PropertyPaneDropdown("ReportsDocRententionYears", {
label: strings.ReportsDocRententionYears,
Expand Down Expand Up @@ -906,4 +817,128 @@ export default class SiteAdminWebPart extends BaseClientSideWebPart<ISiteAdminWe
]
};
}

private renderApp(): void {
// Set the properties for the app
const propValues = (this.properties as any);
const siteProps: {
[key: string]: {
description: string;
disabled: boolean;
label: string;
}
} = {};
const webProps: {
[key: string]: {
description: string;
disabled: boolean;
label: string;
}
} = {};

// Parse the site properties
for (let i = 0; i < this._siteProps.length; i++) {
const propName = this._siteProps[i];
const key = propName.replace("SiteProp", "");

// Add the property
siteProps[key] = {
description: propValues[propName + "Description"],
disabled: propValues[propName],
label: propValues[propName + "Label"]
};
}

// Parse the web properties
for (let i = 0; i < this._webProps.length; i++) {
const propName = this._webProps[i];
const key = propName.replace("WebProp", "");

// Add the property
webProps[key] = {
description: propValues[propName + "Description"],
disabled: propValues[propName],
label: propValues[propName + "Label"]
};
}

// Determine the size
let maxStorageSize = this.properties.MaxStorage;
if (maxStorageSize) {
// See if this is in TB
if (maxStorageSize.toString().indexOf("TB") > 0) {
// Remove the TB and convert to a number
maxStorageSize = parseInt(maxStorageSize.toString().replace("TB", ""));
}
// Else, see if this is in GB
else if (maxStorageSize.toString().indexOf("GB") > 0) {
// Remove the GB, and convert to a number in TB
maxStorageSize = parseInt(maxStorageSize.toString().replace("GB", "")) / 1000;
}
}

// Render the solution
SiteAdmin.render({
auditOnly: this.properties.AuditOnly,
context: this.context,
el: this.domElement,
disableSensitivityLabelOverride: this.properties.DisableSensitivityLabelOverride ? true : false,
hideCreateSiteBtn: this.properties.HideCreateSiteBtn ? true : false,
hideLoadAdminOwnerBtn: this.properties.HideLoadAdminOwnerBtn ? true : false,
hideLoadOneDriveBtn: this.properties.HideLoadOneDriveBtn ? true : false,
hideReports: {
dlp: this.properties.HideReportDLP ? true : false,
docRetention: this.properties.HideReportDocRetention ? true : false,
externalShares: this.properties.HideReportExternalShares ? true : false,
externalUsers: this.properties.HideReportExternalUsers ? true : false,
permissions: this.properties.HideReportPermissions ? true : false,
retention: this.properties.HideReportRetention ? true : false,
searchAgents: this.properties.HideReportSearchAgents ? true : false,
searchDocs: this.properties.HideReportSearchDocs ? true : false,
searchEEEU: this.properties.HideReportSearchEEEU ? true : false,
searchProp: this.properties.HideReportSearchProp ? true : false,
searchUsers: this.properties.HideReportSearchUsers ? true : false,
sensitivityLabels: this.properties.HideReportSensitivityLabels ? true : false,
sharingLinks: this.properties.HideReportSharingLinks ? true : false,
uniquePermissions: this.properties.HideReportUniquePermissions ? true : false
},
hideTabs: {
appPermissions: this.properties.HideAppPermissionsTab ? true : false,
auditTools: this.properties.HideAuditToolsTab ? true : false,
features: this.properties.HideFeaturesTab ? true : false,
lists: this.properties.HideListsTab ? true : false,
management: this.properties.HideManagementTab ? true : false,
search: this.properties.HideSearchTab ? true : false,
webs: this.properties.HideWebsTab ? true : false
},
imageReferences,
maxBatchSize: this.properties.MaxBatchSize,
maxRequests: this.properties.MaxRequests,
maxStorageDesc: this.properties.MaxStorageDescription,
maxStorageSize,
reportProps: {
dlpFileExt: this.properties.ReportsDLPFileExt,
docRententionYears: this.properties.ReportsDocRententionYears,
docSearchFileExt: this.properties.ReportsDocSearchFileExt,
docSearchKeywords: this.properties.ReportsDocSearchKeywords,
docSearchRegexPatterns: this.properties.ReportsDocSearchRegexPatterns,
oversharedGroups: (this.properties.ReportsOversharedGroups || "").split(",").map(group => group.trim()),
sensitivityLabelFileExt: this.properties.SensitivityLabelFileExt
},
searchProps: {
description: this.properties.WebPropSearchPropertyDescription,
key: this.properties.WebPropSearchPropertyKey,
label: this.properties.WebPropSearchPropertyLabel,
managedProperty: this.properties.WebPropSearchPropertyManagedProperty,
reportName: this.properties.WebPropSearchPropertyReportName,
tabName: this.properties.WebPropSearchPropertyTabName,
values: this.properties.WebPropSearchPropertyValues
},
siteAttestation: this.properties.SiteAttestation,
siteAttestationText: this.properties.SiteAttestationText,
siteProps,
title: this.properties.AppTitle,
webProps
});
}
}
2 changes: 1 addition & 1 deletion spfx/src/webparts/siteAdmin/loc/en-us.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ define([], function () {
"MaxStorage": "Max Storage Allowed",
"MaxStorageDescription": "Max Storage Description",
"ReportsDLPFileExt": "DLP Default File Extensions",
"ReportsDLPGroups": "DLP Oversharing Groups",
"ReportsDocRententionYears": "Document Retention Default Years",
"ReportsDocSearchFileExt": "Document Search Default File Extensions",
"ReportsDocSearchKeywords": "Document Search Default Keywords",
"ReportsDocSearchRegexPatterns": "Document Search Default Regex Patterns",
"ReportsOversharedGroups": "Overshared Groups",
"SensitivityLabelFileExt": "Sensitivity Label File Extensions",
"SitePropAttestationDate": "Site Attestation Date",
"SitePropAttestationUser": "Site Attestation User",
Expand Down
2 changes: 1 addition & 1 deletion spfx/src/webparts/siteAdmin/loc/mystrings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ declare interface ISiteAdminWebPartStrings {
MaxStorage: string;
MaxStorageDescription: string;
ReportsDLPFileExt: string;
ReportsDLPGroups: string;
ReportsDocRententionYears: string;
ReportsDocSearchFileExt: string;
ReportsDocSearchKeywords: string;
ReportsDocSearchRegexPatterns: string;
ReportsOversharedGroups: string;
SensitivityLabelFileExt: string;
SitePropAttestationDate: string;
SitePropAttestationUser: string;
Expand Down
2 changes: 1 addition & 1 deletion src/reports/dlp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class DLP {
let analyzeFile = true;

// See if the file extensions are provided
if (fileExtensions) {
if (fileExtensions && fileExtensions.length > 0) {
// Default the flag
analyzeFile = false

Expand Down
3 changes: 3 additions & 0 deletions src/reports/searchAgents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export class SearchAgents {
WebUrl: web.Url
});
}

// Return the stop flag
return this._stopFl;
})
}).then(() => { resolve(); });
});
Expand Down
3 changes: 3 additions & 0 deletions src/reports/searchDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ export class SearchDocs {

// Ensure the process is running
worker.start();

// Return the stop floag
return this._stopFl;
}).then(() => {
// Set the flag
allFilesLoaded = true;
Expand Down
Loading
Loading