diff --git a/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpiration.tsx b/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpiration.tsx
index 0a7290d42..838e5e4e1 100644
--- a/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpiration.tsx
+++ b/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpiration.tsx
@@ -5,7 +5,9 @@ import { ListView, IViewField, SelectionMode, GroupOrder, IGrouping } from "@pnp
import { IApplications, IApplication, IFormattedApplication } from '../../../models/IApplication';
import { IGraphAppSecretExpirationState } from './GraphAppSecretExpirationState';
import * as moment from 'moment';
-import { DefaultButton, Spinner, mergeStyles } from '@fluentui/react';
+import { DefaultButton, Spinner, mergeStyles, SearchBox } from '@fluentui/react';
+import { Pagination } from "@pnp/spfx-controls-react/lib/pagination";
+import * as strings from 'GraphAppSecretExpirationWebPartStrings';
const stackItemHidden = mergeStyles({
display: 'none',
@@ -57,9 +59,13 @@ export default class GraphAppSecretExpiration extends React.Component {
-
- if (app.passwordCredentials.length > 0) {
- app.passwordCredentials.forEach(pswd => {
- let daysBeforeExpiration = moment.duration((moment(pswd.endDateTime)).diff(today, 'days'), 'days').asDays();
- let formatedApp: IFormattedApplication = {
- applicationId: app.appId,
- displayName: app.displayName,
- type: "Secret",
- expirationDate: (moment(pswd.endDateTime)).format('DD-MMM-YYYY'),
- daysLeft: daysBeforeExpiration > 0 ? daysBeforeExpiration : 0
- };
- displayedApplication.push(formatedApp);
- });
- }
- if (app.keyCredentials.length > 0) {
- app.keyCredentials.forEach(keyCred => {
- let daysBeforeExpiration = moment.duration((moment(keyCred.endDateTime)).diff(today, 'days'), 'days').asDays();
- let formatedApp: IFormattedApplication = {
- applicationId: app.appId,
- displayName: app.displayName,
- type: "Certificate",
- expirationDate: (moment(keyCred.endDateTime)).format('DD-MMM-YYYY'),
- daysLeft: daysBeforeExpiration > 0 ? daysBeforeExpiration : 0
- };
- displayedApplication.push(formatedApp);
- });
- }
+ app.passwordCredentials.forEach(pswd => {
+ let daysBeforeExpiration = moment.duration((moment(pswd.endDateTime)).diff(today, 'days'), 'days').asDays();
+ let formatedApp: IFormattedApplication = {
+ applicationId: app.appId,
+ displayName: app.displayName,
+ type: "Secret",
+ expirationDate: (moment(pswd.endDateTime)).format('DD-MMM-YYYY'),
+ daysLeft: daysBeforeExpiration > 0 ? daysBeforeExpiration : 0
+ };
+ displayedApplication.push(formatedApp);
+ });
+ app.keyCredentials.forEach(keyCred => {
+ let daysBeforeExpiration = moment.duration((moment(keyCred.endDateTime)).diff(today, 'days'), 'days').asDays();
+ let formatedApp: IFormattedApplication = {
+ applicationId: app.appId,
+ displayName: app.displayName,
+ type: "Certificate",
+ expirationDate: (moment(keyCred.endDateTime)).format('DD-MMM-YYYY'),
+ daysLeft: daysBeforeExpiration > 0 ? daysBeforeExpiration : 0
+ };
+ displayedApplication.push(formatedApp);
+ });
});
this.setState({
- applications: displayedApplication
+ applications: displayedApplication,
+ filteredApplications: displayedApplication
});
} catch (error) {
console.log(error);
}
}
+ private _getPage(selectedPage: number) {
+ this.setState({
+ page: selectedPage
+ });
+ }
+
+ private _filterApplication = (value, clear: boolean) => {
+ let searchResult: IFormattedApplication[] = [];
+ if (clear) {
+ this.state.applications.forEach(app => {
+ if (this._filterByProperties(app, value)) {
+ searchResult.push(app);
+ }
+ });
+ this.setState({
+ filteredApplications: searchResult,
+ filterValue: value
+ });
+ } else {
+ this.setState({
+ filteredApplications: this.state.applications,
+ filterValue: value,
+ page: 1
+ });
+ }
+
+ }
+
+ private _filterByProperties(application: IFormattedApplication, filterValue) {
+ if (application.applicationId.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0) {
+ return true;
+ } else if (application.displayName.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0) {
+ return true;
+ } else if (application.expirationDate.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0) {
+ return true;
+ } else if (application.type.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
private _groupView = () => {
if (this.state.groupByFields.length === 0) {
let groupByFields: IGrouping[] = [
@@ -177,21 +221,31 @@ export default class GraphAppSecretExpiration extends React.ComponentApplication list :
-
+
+ this._filterApplication(text, false)} onClear={() => this._filterApplication("", true)} value={this.state.filterValue} />
+ this._getPage(page)}
+ limiter={3} // Optional - default value 3
+ hideFirstPageJump // Optional
+ hideLastPageJump // Optional
+ limiterIcon={"Emoji12"} // Optional
+ />
);
diff --git a/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpirationState.ts b/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpirationState.ts
index be2897a91..567efe0e2 100644
--- a/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpirationState.ts
+++ b/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpirationState.ts
@@ -3,7 +3,11 @@ import { IApplications, IApplication,IPasswordCredential,IKeyCredential,IFormatt
export interface IGraphAppSecretExpirationState {
applications: IFormattedApplication[];
+ filteredApplications: IFormattedApplication[];
+ filterValue: string;
+ searchFilter: string;
groupByFields: IGrouping[];
+ page: number;
error: string;
loading: boolean;
}
\ No newline at end of file