PnPjs Version 3 Sample

This commit is contained in:
Julie Turner 2022-02-22 19:57:47 +00:00
parent e7ac8f3a02
commit e63eaf76a5
4 changed files with 28493 additions and 39 deletions

View File

@ -3,7 +3,7 @@
"plusBeta": true,
"isCreatingSolution": true,
"environment": "spo",
"version": "1.14.0-beta.4",
"version": "1.14.0",
"libraryName": "spfx-pnp-js-example",
"libraryId": "d20ceaf6-094b-4086-b7a0-85761bc8be23",
"packageManager": "npm",
@ -11,4 +11,4 @@
"isDomainIsolated": false,
"componentType": "webpart"
}
}
}

28449
samples/react-pnp-js-sample/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,8 @@
"@microsoft/sp-office-ui-fabric-core": "1.14.0",
"@microsoft/sp-property-pane": "1.14.0",
"@microsoft/sp-webpart-base": "1.14.0",
"@pnp/logging": "^3.0.0",
"@pnp/sp": "^3.0.0",
"@pnp/logging": "^3.0.2",
"@pnp/sp": "^3.0.2",
"office-ui-fabric-react": "7.174.1",
"react": "16.13.1",
"react-dom": "16.13.1"
@ -31,4 +31,4 @@
"ajv": "~5.2.2",
"gulp": "~4.0.2"
}
}
}

View File

@ -42,40 +42,45 @@ export default class PnPjsExample extends React.Component<IPnPjsExampleProps, II
}
public render(): React.ReactElement<IAsyncAwaitPnPJsProps> {
// calculate total of file sizes
const totalDocs: number = this.state.items.length > 0
? this.state.items.reduce<number>((acc: number, item: IFile) => {
return (acc + Number(item.Size));
}, 0)
: 0;
return (
<div className={styles.pnPjsExample}>
<Label>Welcome to PnP JS Version 3 Demo!</Label>
<PrimaryButton onClick={this._updateTitles}>Update Item Titles</PrimaryButton>
<Label>List of documents:</Label>
<table width="100%">
<tr>
<td><strong>Title</strong></td>
<td><strong>Name</strong></td>
<td><strong>Size (KB)</strong></td>
</tr>
{this.state.items.map((item, idx) => {
return (
<tr key={idx}>
<td>{item.Title}</td>
<td>{item.Name}</td>
<td>{(item.Size / 1024).toFixed(2)}</td>
</tr>
);
})}
<tr>
<td></td>
<td><strong>Total:</strong></td>
<td><strong>{(totalDocs / 1024).toFixed(2)}</strong></td>
</tr>
</table>
</div >
);
try {
// calculate total of file sizes
const totalDocs: number = this.state.items.length > 0
? this.state.items.reduce<number>((acc: number, item: IFile) => {
return (acc + Number(item.Size));
}, 0)
: 0;
return (
<div className={styles.pnPjsExample}>
<Label>Welcome to PnP JS Version 3 Demo!</Label>
<PrimaryButton onClick={this._updateTitles}>Update Item Titles</PrimaryButton>
<Label>List of documents:</Label>
<table width="100%">
<tr>
<td><strong>Title</strong></td>
<td><strong>Name</strong></td>
<td><strong>Size (KB)</strong></td>
</tr>
{this.state.items.map((item, idx) => {
return (
<tr key={idx}>
<td>{item.Title}</td>
<td>{item.Name}</td>
<td>{(item.Size / 1024).toFixed(2)}</td>
</tr>
);
})}
<tr>
<td></td>
<td><strong>Total:</strong></td>
<td><strong>{(totalDocs / 1024).toFixed(2)}</strong></td>
</tr>
</table>
</div >
);
} catch (err) {
Logger.write(`${this.LOG_SOURCE} (render) - ${JSON.stringify(err)} - `, LogLevel.Error);
}
return null;
}
private _readAllFilesSize = async (): Promise<void> => {