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
10 changes: 8 additions & 2 deletions assets/function-app.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,14 @@ if ($item -ne $null) {
# Log
Write-Host "Setting NoCrawl to $value...";

# Set the no crawl property
Set-PnPWeb -NoCrawl:$value;
# See if we are setting turning it off
if($value -eq "true") {
# Set the no crawl property
Set-PnPWeb -NoCrawl:$true;
} else {
# Set the no crawl property
Set-PnPWeb -NoCrawl:$false;
}

# Log
Write-Host "Disabling custom scripts...";
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"datatables.net": "^2.3.2",
"datatables.net-bs5": "^2.3.2",
"dattatable": "^2.11.45",
"gd-sprest-bs": "^10.15.15",
"gd-sprest-bs": "^10.15.16",
"jquery": "^3.7.1",
"moment": "^2.30.1"
},
Expand Down
2 changes: 1 addition & 1 deletion spfx/config/package-solution.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"solution": {
"name": "site-admin-tool",
"id": "9c7bcdac-024d-4ffe-b63a-cef526bc1930",
"version": "0.9.7.5",
"version": "0.9.7.6",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,
Expand Down
58 changes: 58 additions & 0 deletions src/ds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ export interface ISensitivityLabel {
name: string;
}

/**
* User Information
*/
export interface IUserInfo {
email: string;
name: string;
type: string;
}

/**
* Request Types
*/
Expand Down Expand Up @@ -381,6 +390,55 @@ export class DataSource {
});
}

// Loads the admins/owners of the site
static loadAdminsOwners(siteUrl: string): PromiseLike<{ admins: IUserInfo[], owners: IUserInfo[] }> {
// Return a promise
return new Promise((resolve, reject) => {
let errorFl = false;
let web = Web(siteUrl);

// Get the admins
let admins: IUserInfo[] = [];
web.SiteUserInfoList().Items().query({
Filter: "IsSiteAdmin eq 1"
}).execute(users => {
// Add the admins
users.results.forEach(user => {
admins.push({
email: user["EMail"] || user["UserName"],
name: user.Title,
type: "Site Admin"
});
});
}, () => {
// Set the flag
errorFl = true;
});

// Get the owners
let owners: IUserInfo[] = [];
web.AssociatedOwnerGroup().Users().execute(users => {
// Add the owners
users.results.forEach(user => {
owners.push({
email: user.Email || user.LoginName,
name: user.Title,
type: "Site Owner"
});
});
}, () => {
// Set the flag
errorFl = true;
}, true);

// Wait for the requests to complete
web.done(() => {
// Complete the request
errorFl ? reject() : resolve({ admins, owners })
});
});
}

// Returns the group id from the login name
static getGroupId(loginName: string): string {
// Get the group id from the login name
Expand Down
96 changes: 95 additions & 1 deletion src/loadForm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LoadingDialog, Modal } from "dattatable";
import { Dashboard, LoadingDialog, Modal, DataTable } from "dattatable";
import { Components, Search } from "gd-sprest-bs";
import { DataSource } from "./ds";
import { PageGenerator } from "./page-generator";
Expand Down Expand Up @@ -30,6 +30,16 @@ export class LoadForm {
Components.TooltipGroup({
el,
tooltips: [
{
content: "Views the owners/admins of the site.",
btnProps: {
text: "View Admins/Owners",
onClick: () => {
// Load the admins/owners of the site
this.viewAdminsOwners();
}
}
},
{
content: "Validates that you are an admin for the site entered.",
btnProps: {
Expand Down Expand Up @@ -292,4 +302,88 @@ export class LoadForm {
)
}
}

// Views the admins/owners of the site
private viewAdminsOwners() {
// Ensure the popover is hidden
this._popover.hide();

// Validate the form
if (this._form.isValid()) {
let ctrl = this._form.getControl("url");
let url = this._form.getValues()["url"];

// Show a loading dialog
LoadingDialog.setHeader("Validating Site");
LoadingDialog.setBody("This will close after the site url is validated...");
LoadingDialog.show();

// Load the admins/owners
DataSource.loadAdminsOwners(typeof (url) === "string" ? url : url.value).then(
// Success
users => {
// Clear the modal
Modal.clear();

// Set the header
Modal.setHeader("Site Admins/Owners");

// Set the body
new DataTable({
el: Modal.BodyElement,
rows: users.admins.concat(users.owners),
columns: [
{
name: "type",
title: "User Type"
},
{
name: "name",
title: "Name"
},
{
name: "email",
title: "Email"
}
]
});

// Render the footer
Components.TooltipGroup({
el: Modal.FooterElement,
tooltips: [
{
content: "Closes the form.",
btnProps: {
text: "Close",
onClick: () => {
// Hide the modal
Modal.hide();
}
}
}
]
});

// Close the dialog
LoadingDialog.hide();

// Show the modal
Modal.show();
},

// Error
() => {
// Close the dialog
LoadingDialog.hide();

// Update the validation
ctrl.updateValidation(ctrl.el, {
isValid: false,
invalidMessage: "Unable to load the web information. Please check the url: " + url
});
}
);
}
}
}