React-Directory (#930)
* update docs * Update README.md * Update README.md * Support to IE11 * fine tunning, added Fade on Images * use CSS transitions * clean extra comments * react-carousel * Happy Birthday Web Part - new version * Update Docs * added spinner on loading image in carousel * React-Directory * Update README.md * Update README.md * update CSS * CSS update * added A-Z Index * Display WorkPhone on PersonaCard * update doc * Update code
|
@ -0,0 +1,25 @@
|
|||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
|
||||
[*]
|
||||
|
||||
# change these settings to your own preference
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# we recommend you to keep these unchanged
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[{package,bower}.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
|
@ -0,0 +1,32 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
solution
|
||||
temp
|
||||
*.sppkg
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# OSX
|
||||
.DS_Store
|
||||
|
||||
# Visual Studio files
|
||||
.ntvs_analysis.dat
|
||||
.vs
|
||||
bin
|
||||
obj
|
||||
|
||||
# Resx Generated Code
|
||||
*.resx.ts
|
||||
|
||||
# Styles Generated Code
|
||||
*.scss.ts
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"@microsoft/generator-sharepoint": {
|
||||
"version": "1.8.2",
|
||||
"libraryName": "react-directory",
|
||||
"libraryId": "5b62bc16-3a71-461d-be2f-16bfcb011e8a",
|
||||
"environment": "spo",
|
||||
"packageManager": "npm",
|
||||
"framework": "react",
|
||||
"isCreatingSolution": true,
|
||||
"isDomainIsolated": false,
|
||||
"componentType": "webpart"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
# React Directory Web Part
|
||||
|
||||
## Summary
|
||||
|
||||
Search People from Organization Directory and show live persona card on houver.
|
||||
|
||||
|
||||
##
|
||||
![directory](/samples/react-directory/assets/react-directory.jpg)
|
||||
|
||||
![directory](/samples/react-directory/assets/react-directory-teams1.jpg)
|
||||
|
||||
![directory](/samples/react-directory/assets/react-directory2.jpg)
|
||||
|
||||
![directory](/samples/react-directory/assets/react-directory-teams2.png)
|
||||
|
||||
![directory](/samples/react-directory/assets/react-directory21.png)
|
||||
|
||||
![directory](/samples/react-directory/assets/react-directory3.jpg)
|
||||
|
||||
![directory](/samples/react-directory/assets/react-directory6.png)
|
||||
|
||||
![directory](/samples/react-directory/assets/react-directory5.jpg)
|
||||
|
||||
|
||||
|
||||
## Used SharePoint Framework Version
|
||||
![drop](https://img.shields.io/badge/version-1.8.2-green.svg)
|
||||
|
||||
## Applies to
|
||||
|
||||
* [SharePoint Online](https:/dev.office.com/sharepoint)
|
||||
* [Microsoft Teams](https://products.office.com/en-US/microsoft-teams/group-chat-software)
|
||||
* [Office 365 tenant](https://dev.office.com/sharepoint/docs/spfx/set-up-your-development-environment)
|
||||
|
||||
|
||||
## WebPart Properties
|
||||
|
||||
Property |Type|Required| comments
|
||||
--------------------|----|--------|----------
|
||||
Web Part Title | Text| no|
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Solution
|
||||
The web part Use PnPjs library, Office-ui-fabric-react components
|
||||
|
||||
Solution|Author(s)
|
||||
--------|---------
|
||||
Directory Web Part|João Mendes
|
||||
|
||||
## Version history
|
||||
|
||||
Version|Date|Comments
|
||||
-------|----|--------
|
||||
1.0.0|July 29, 2019|Initial release
|
||||
|
||||
|
||||
## Disclaimer
|
||||
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||
|
||||
---
|
||||
|
||||
## Minimal Path to Awesome
|
||||
|
||||
- Clone this repository
|
||||
- in the command line run:
|
||||
- `npm install`
|
||||
- `gulp build`
|
||||
- `gulp bundle --ship`
|
||||
- `gulp package-solution --ship`
|
||||
- `Add to AppCatalog and deploy`
|
||||
|
||||
|
||||
|
||||
|
||||
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-directory" />
|
||||
|
After Width: | Height: | Size: 79 KiB |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 119 KiB |
After Width: | Height: | Size: 140 KiB |
After Width: | Height: | Size: 158 KiB |
After Width: | Height: | Size: 428 KiB |
After Width: | Height: | Size: 133 KiB |
After Width: | Height: | Size: 161 KiB |
After Width: | Height: | Size: 442 KiB |
|
@ -0,0 +1,78 @@
|
|||
resources:
|
||||
- repo: self
|
||||
trigger:
|
||||
- master
|
||||
- develop
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
demands:
|
||||
- npm
|
||||
- node.js
|
||||
|
||||
steps:
|
||||
#install node 10.x
|
||||
- task: NodeTool@0
|
||||
displayName: 'Use Node 10.x'
|
||||
inputs:
|
||||
versionSpec: 10.x
|
||||
checkLatest: true
|
||||
|
||||
#install nodejs modules with npm
|
||||
- task: Npm@1
|
||||
displayName: 'npm install'
|
||||
inputs:
|
||||
workingDir: '$(Build.SourcesDirectory)'
|
||||
verbose: false
|
||||
|
||||
#start unit tests
|
||||
- task: Npm@1
|
||||
displayName: 'npm test'
|
||||
inputs:
|
||||
command: custom
|
||||
customCommand: 'test'
|
||||
workingDir: '$(Build.SourcesDirectory)'
|
||||
verbose: false
|
||||
|
||||
# Publish Test Results to Azure Pipelines/TFS
|
||||
- task: PublishTestResults@2
|
||||
inputs:
|
||||
testResultsFiles: 'temp/test/junit/junit.xml'
|
||||
searchFolder: '$(Build.SourcesDirectory)'
|
||||
|
||||
# publish coverage test results
|
||||
- task: PublishCodeCoverageResults@1
|
||||
displayName: 'Publish Code Coverage Results $(Build.SourcesDirectory)/temp/test/cobertura-coverage.xml'
|
||||
inputs:
|
||||
codeCoverageTool: Cobertura
|
||||
summaryFileLocation: '$(Build.SourcesDirectory)/temp/test/cobertura-coverage.xml'
|
||||
reportDirectory: '$(Build.SourcesDirectory)/temp/test/'
|
||||
|
||||
#bundle code with gulp
|
||||
- task: Gulp@0
|
||||
displayName: 'gulp bundle'
|
||||
inputs:
|
||||
gulpFile: '$(Build.SourcesDirectory)/gulpfile.js'
|
||||
targets: bundle
|
||||
arguments: '--ship'
|
||||
continueOnError: true
|
||||
|
||||
#package solution with gulp
|
||||
- task: Gulp@0
|
||||
displayName: 'gulp package-solution'
|
||||
inputs:
|
||||
gulpFile: '$(Build.SourcesDirectory)/gulpfile.js'
|
||||
targets: 'package-solution'
|
||||
arguments: '--ship'
|
||||
|
||||
#copy files to artifact repository
|
||||
- task: CopyFiles@2
|
||||
displayName: 'Copy Files to: $(build.artifactstagingdirectory)/drop'
|
||||
inputs:
|
||||
Contents: '**\*.sppkg'
|
||||
TargetFolder: '$(build.artifactstagingdirectory)/drop'
|
||||
|
||||
#publish artifacts
|
||||
- task: PublishBuildArtifacts@1
|
||||
displayName: 'Publish Artifact: drop'
|
||||
inputs:
|
||||
PathtoPublish: '$(build.artifactstagingdirectory)/drop'
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||
"version": "2.0",
|
||||
"bundles": {
|
||||
"directory-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/directory/DirectoryWebPart.js",
|
||||
"manifest": "./src/webparts/directory/DirectoryWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"externals": {},
|
||||
"localizedResources": {
|
||||
"DirectoryWebPartStrings": "lib/webparts/directory/loc/{locale}.js",
|
||||
"ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js",
|
||||
"PropertyControlStrings": "node_modules/@pnp/spfx-property-controls/lib/loc/{locale}.js"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
|
||||
"deployCdnPath": "temp/deploy"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./temp/deploy/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "react-directory",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{"preset":"@voitanos/jest-preset-spfx-react16","rootDir":"../src","coverageReporters":["text","json","lcov","text-summary","cobertura"],"reporters":["default","jest-junit"]}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "Search Directory",
|
||||
"id": "5b62bc16-3a71-461d-be2f-16bfcb011e8a",
|
||||
"version": "1.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": true,
|
||||
"isDomainIsolated": false
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/react-directory.sppkg"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"initialPage": "https://localhost:5432/workbench",
|
||||
"api": {
|
||||
"port": 5432,
|
||||
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
'use strict';
|
||||
|
||||
// check if gulp dist was called
|
||||
if (process.argv.indexOf('dist') !== -1) {
|
||||
// add ship options to command call
|
||||
process.argv.push('--ship');
|
||||
}
|
||||
|
||||
const path = require('path');
|
||||
const gulp = require('gulp');
|
||||
const build = require('@microsoft/sp-build-web');
|
||||
const gulpSequence = require('gulp-sequence');
|
||||
|
||||
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||
|
||||
// Create clean distrubution package
|
||||
gulp.task('dist', gulpSequence('clean', 'bundle', 'package-solution'));
|
||||
// Create clean development package
|
||||
gulp.task('dev', gulpSequence('clean', 'bundle', 'package-solution'));
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Custom Framework Specific gulp tasks
|
||||
*/
|
||||
|
||||
|
||||
build.initialize(gulp);
|
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"name": "react-directory",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
"clean": "gulp clean",
|
||||
"preversion": "node ./tools/pre-version.js",
|
||||
"postversion": "gulp dist",
|
||||
"test": "./node_modules/.bin/jest --config ./config/jest.config.json",
|
||||
"test:watch": "./node_modules/.bin/jest --config ./config/jest.config.json --watchAll"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/sp-core-library": "1.8.2",
|
||||
"@microsoft/sp-lodash-subset": "1.8.2",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.8.2",
|
||||
"@microsoft/sp-property-pane": "1.8.2",
|
||||
"@microsoft/sp-webpart-base": "1.8.2",
|
||||
"@pnp/pnpjs": "^1.3.3",
|
||||
"@pnp/spfx-controls-react": "1.13.2",
|
||||
"@pnp/spfx-property-controls": "1.15.0",
|
||||
"@types/es6-promise": "0.0.33",
|
||||
"@types/jquery": "^3.3.30",
|
||||
"@types/react": "16.7.22",
|
||||
"@types/react-dom": "16.8.0",
|
||||
"@types/webpack-env": "1.13.1",
|
||||
"@uifabric/fluent-theme": "^0.16.9",
|
||||
"jquery": "^3.4.1",
|
||||
"office-ui-fabric-react": "^6.182.0",
|
||||
"react": "16.7.0",
|
||||
"react-dom": "16.7.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"@types/react": "16.7.22"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/rush-stack-compiler-3.3": "~0.2.x",
|
||||
"@microsoft/sp-build-web": "1.8.2",
|
||||
"@microsoft/sp-module-interfaces": "1.8.2",
|
||||
"@microsoft/sp-tslint-rules": "1.8.2",
|
||||
"@microsoft/sp-webpart-workbench": "1.8.2",
|
||||
"@types/chai": "3.4.34",
|
||||
"@types/mocha": "2.2.38",
|
||||
"@types/react": "^16.7.22",
|
||||
"@voitanos/jest-preset-spfx-react16": "^1.1.0",
|
||||
"ajv": "~5.2.2",
|
||||
"gulp": "~3.9.1",
|
||||
"gulp-sequence": "1.0.0",
|
||||
"jest": "^23.6.0",
|
||||
"jest-junit": "^6.3.0",
|
||||
"typescript": "~3.3.x"
|
||||
},
|
||||
"jest-junit": {
|
||||
"output": "temp/test/junit/junit.xml",
|
||||
"usePathForSuiteName": "true"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
export interface IProfileProperties {
|
||||
DisplayName: string;
|
||||
Email: string;
|
||||
Title: string;
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
import { WebPartContext } from "@microsoft/sp-webpart-base";
|
||||
import { graph } from "@pnp/graph";
|
||||
import { sp, PeoplePickerEntity, ClientPeoplePickerQueryParameters, SearchQuery, SearchResults, SearchProperty, SortDirection } from '@pnp/sp';
|
||||
import { PrincipalType } from "@pnp/sp/src/sitegroups";
|
||||
|
||||
|
||||
export class spservices {
|
||||
|
||||
|
||||
|
||||
constructor(private context: WebPartContext) {
|
||||
|
||||
sp.setup({
|
||||
spfxContext: this.context
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public async getUserProperties(user: string): Promise<any> {
|
||||
|
||||
try {
|
||||
let currentUserProperties: any = await sp.profiles.getPropertiesFor(user);
|
||||
return currentUserProperties;
|
||||
} catch (error) {
|
||||
Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* async GetUserProfileProperty
|
||||
user:string */
|
||||
public async getUserProfileProperty(user: string, property: string): Promise<string> {
|
||||
try {
|
||||
let UserProperty: string = await sp.profiles.getUserProfilePropertyFor(user, property);
|
||||
console.log(UserProperty);
|
||||
return UserProperty;
|
||||
} catch (error) {
|
||||
Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} searchUser
|
||||
* @memberof spservices
|
||||
*/
|
||||
public async getUsers(searchUser: string): Promise<PeoplePickerEntity[]> {
|
||||
try {
|
||||
let users: PeoplePickerEntity[] = await sp.profiles.clientPeoplePickerSearchUser({ QueryString: searchUser, MaximumEntitySuggestions: 100, PrincipalType: 1 });
|
||||
return users;
|
||||
} catch (error) {
|
||||
Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
public async searchUsers(searchString: string) {
|
||||
const s = `LastName:${searchString}* OR FirstName:${searchString}* OR Department:${searchString}`;
|
||||
const searchProperties: string[] = ["FirstName", "LastName", "PreferredName", "WorkEmail", "PictureURL", "WorkPhone", "MobilePhone", "JobTitle", "Department", "Skills", "PastProjects"];
|
||||
try {
|
||||
if (!searchString) return undefined;
|
||||
let users = await sp.searchWithCaching(<SearchQuery>{
|
||||
Querytext: s,
|
||||
RowLimit: 500,
|
||||
EnableInterleaving: true,
|
||||
SelectProperties: searchProperties,
|
||||
SourceId: 'b09a7990-05ea-4af9-81ef-edfab16c4e31',
|
||||
SortList: [{ "Property": "LastName", "Direction": SortDirection.Ascending }]
|
||||
|
||||
});
|
||||
|
||||
return users;
|
||||
} catch (error) {
|
||||
Promise.reject(error);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "fae479bf-405f-4f80-a086-eea22eff3d6f",
|
||||
"alias": "DirectoryWebPart",
|
||||
"componentType": "WebPart",
|
||||
|
||||
// The "*" signifies that the version should be taken from the package.json
|
||||
"version": "*",
|
||||
"manifestVersion": 2,
|
||||
|
||||
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||
"requiresCustomScript": false,
|
||||
"supportedHosts": ["SharePointWebPart","TeamsTab", "SharePointFullPage"],
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||
"group": { "default": "SPFx WebParts" },
|
||||
"title": { "default": "Search Directory" },
|
||||
"description": { "default": "Search Directory" },
|
||||
"officeFabricIconFontName": "ProfileSearch",
|
||||
"properties": {
|
||||
"title": "Directory"
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
import { Version } from '@microsoft/sp-core-library';
|
||||
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||
import { DisplayMode } from '@microsoft/sp-core-library';
|
||||
import {
|
||||
IPropertyPaneConfiguration,
|
||||
PropertyPaneTextField
|
||||
} from '@microsoft/sp-property-pane';
|
||||
|
||||
import * as strings from 'DirectoryWebPartStrings';
|
||||
import Directory from './components/Directory';
|
||||
import { IDirectoryProps } from './components/IDirectoryProps';
|
||||
|
||||
|
||||
export interface IDirectoryWebPartProps {
|
||||
title: string;
|
||||
}
|
||||
|
||||
export default class DirectoryWebPart extends BaseClientSideWebPart<IDirectoryWebPartProps> {
|
||||
|
||||
public render(): void {
|
||||
const element: React.ReactElement<IDirectoryProps> = React.createElement(
|
||||
Directory,
|
||||
{
|
||||
title: this.properties.title,
|
||||
context: this.context,
|
||||
displayMode: this.displayMode,
|
||||
updateProperty: (value: string) => {
|
||||
this.properties.title = value;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
|
||||
protected onDispose(): void {
|
||||
ReactDom.unmountComponentAtNode(this.domElement);
|
||||
}
|
||||
|
||||
protected get dataVersion(): Version {
|
||||
return Version.parse('1.0');
|
||||
}
|
||||
|
||||
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||
return {
|
||||
pages: [
|
||||
{
|
||||
header: {
|
||||
description: strings.PropertyPaneDescription
|
||||
},
|
||||
groups: [
|
||||
{
|
||||
groupName: strings.BasicGroupName,
|
||||
groupFields: [
|
||||
PropertyPaneTextField('title', {
|
||||
label: strings.TitleFieldLabel
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||
|
||||
|
||||
|
||||
|
||||
.directory {
|
||||
|
||||
|
||||
|
||||
|
||||
.pivotItem {
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
.pivotItem:hover {
|
||||
border-style: solid;
|
||||
border-width: 1.2;
|
||||
border-color: $ms-color-themeDark;
|
||||
}
|
||||
|
||||
|
||||
.container {
|
||||
max-width: 700px;
|
||||
margin: 0px auto;
|
||||
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.row {
|
||||
@include ms-Grid-row;
|
||||
@include ms-fontColor-white;
|
||||
background-color: $ms-color-themeDark;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.column {
|
||||
@include ms-Grid-col;
|
||||
@include ms-lg10;
|
||||
@include ms-xl8;
|
||||
@include ms-xlPush2;
|
||||
@include ms-lgPush1;
|
||||
}
|
||||
|
||||
.title {
|
||||
@include ms-font-xl;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.subTitle {
|
||||
@include ms-font-l;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.description {
|
||||
@include ms-font-l;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.button {
|
||||
// Our button
|
||||
text-decoration: none;
|
||||
height: 32px;
|
||||
|
||||
// Primary Button
|
||||
min-width: 80px;
|
||||
background-color: $ms-color-themePrimary;
|
||||
border-color: $ms-color-themePrimary;
|
||||
color: $ms-color-white;
|
||||
|
||||
// Basic Button
|
||||
outline: transparent;
|
||||
position: relative;
|
||||
font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: $ms-font-size-m;
|
||||
font-weight: $ms-font-weight-regular;
|
||||
border-width: 0;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
padding: 0 16px;
|
||||
|
||||
.label {
|
||||
font-weight: $ms-font-weight-semibold;
|
||||
font-size: $ms-font-size-m;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
margin: 0 4px;
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
import * as React from 'react';
|
||||
import styles from './Directory.module.scss';
|
||||
import { IDirectoryProps } from './IDirectoryProps';
|
||||
import { escape } from '@microsoft/sp-lodash-subset';
|
||||
import { PersonaCard } from './PersonaCard/PersonaCard';
|
||||
import { spservices } from '../../../SPServices/spservices';
|
||||
import { IDirectoryState } from './IDirectoryState';
|
||||
import { DisplayMode } from '@microsoft/sp-core-library';
|
||||
import * as strings from 'DirectoryWebPartStrings';
|
||||
import {
|
||||
Spinner,
|
||||
SpinnerSize,
|
||||
MessageBar,
|
||||
MessageBarType,
|
||||
SearchBox,
|
||||
Icon,
|
||||
Label,
|
||||
Pivot,
|
||||
PivotItem,
|
||||
PivotLinkFormat,
|
||||
PivotLinkSize
|
||||
}
|
||||
from 'office-ui-fabric-react';
|
||||
import { IProfileProperties } from '../../../SPServices/IProfileProperties';
|
||||
import { PeoplePickerEntity, Search, SearchResult } from '@pnp/sp';
|
||||
import { WebPartTitle } from "@pnp/spfx-controls-react/lib/WebPartTitle";
|
||||
import { Root } from '@pnp/graph';
|
||||
import { IUserProperties } from './PersonaCard/IUserProperties';
|
||||
|
||||
const az: string[] = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
|
||||
|
||||
export default class Directory extends React.Component<IDirectoryProps, IDirectoryState> {
|
||||
|
||||
private _services: spservices = null;
|
||||
|
||||
constructor(props: IDirectoryProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
users: [],
|
||||
isLoading: true,
|
||||
errorMessage: '',
|
||||
hasError: false,
|
||||
indexSelectedKey: 'A',
|
||||
searchString: ''
|
||||
};
|
||||
|
||||
this._services = new spservices(this.props.context);
|
||||
// Register event handlers
|
||||
this._searchUsers = this._searchUsers.bind(this);
|
||||
this._selectedIndex = this._selectedIndex.bind(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @memberof Directory
|
||||
*/
|
||||
public async componentDidMount() {
|
||||
await this._searchUsers('A');
|
||||
}
|
||||
|
||||
private async _searchUsers(searchText: string) {
|
||||
searchText = searchText ? searchText : 'A';
|
||||
this.setState({ isLoading: true, indexSelectedKey: searchText.substring(0, 1).toLocaleUpperCase() });
|
||||
|
||||
try {
|
||||
const users = await this._services.searchUsers(searchText);
|
||||
this.setState({ users: users && users.PrimarySearchResults ? users.PrimarySearchResults : null, isLoading: false, errorMessage: '', hasError: false });
|
||||
} catch (error) {
|
||||
this.setState({ errorMessage: error.message, hasError: true });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param {IDirectoryProps} prevProps
|
||||
* @param {IDirectoryState} prevState
|
||||
* @memberof Directory
|
||||
*/
|
||||
public componentDidUpdate(prevProps: IDirectoryProps, prevState: IDirectoryState): void {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @param {PivotItem} [item]
|
||||
* @param {React.MouseEvent<HTMLElement>} [ev]
|
||||
* @memberof Directory
|
||||
*/
|
||||
private _selectedIndex(item?: PivotItem, ev?: React.MouseEvent<HTMLElement>) {
|
||||
|
||||
this._searchUsers(item.props.itemKey);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @returns {React.ReactElement<IDirectoryProps>}
|
||||
* @memberof Directory
|
||||
*/
|
||||
public render(): React.ReactElement<IDirectoryProps> {
|
||||
const color = this.props.context.microsoftTeams ? 'white' : '';
|
||||
|
||||
return (
|
||||
<div className={styles.directory}>
|
||||
<WebPartTitle displayMode={this.props.displayMode}
|
||||
title={this.props.title}
|
||||
updateProperty={this.props.updateProperty} />
|
||||
|
||||
<div style={{ width: '100%', verticalAlign: 'middle', marginBottom: 40 }}>
|
||||
<SearchBox
|
||||
placeholder={strings.SearchPlaceHolder}
|
||||
styles={{ root: { minWidth: 180, width: 360, marginLeft: 'auto', marginRight: 'auto', marginBottom: 25 } }}
|
||||
onSearch={this._searchUsers}
|
||||
onClear={() => { this._searchUsers('A'); }}
|
||||
onChange={this._searchUsers} />
|
||||
<div>
|
||||
<Pivot
|
||||
styles={{ root: { paddingLeft: 10, paddingRight: 10, whiteSpace: 'normal', textAlign: 'center' } }}
|
||||
linkFormat={PivotLinkFormat.tabs}
|
||||
selectedKey={this.state.indexSelectedKey}
|
||||
onLinkClick={this._selectedIndex}
|
||||
linkSize={PivotLinkSize.normal}>
|
||||
{
|
||||
az.map((index) => {
|
||||
return (
|
||||
<PivotItem
|
||||
headerText={index}
|
||||
itemKey={index}
|
||||
key={index} >
|
||||
</PivotItem>
|
||||
);
|
||||
})
|
||||
}
|
||||
</Pivot>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
{
|
||||
!this.state.users || this.state.users.length == 0 ?
|
||||
<div style={{ marginLeft: 'auto', marginRight: 'auto', textAlign: 'center' }}>
|
||||
<Icon iconName={'ProfileSearch'} style={{ fontSize: '54px', color: color }} />
|
||||
<Label>
|
||||
<span style={{ marginLeft: 5, fontSize: '26px', color: color }}>{strings.DirectoryMessage}</span>
|
||||
</Label>
|
||||
</div>
|
||||
:
|
||||
this.state.isLoading ?
|
||||
<Spinner size={SpinnerSize.large} label={'searching ...'}></Spinner>
|
||||
:
|
||||
this.state.hasError ?
|
||||
<MessageBar messageBarType={MessageBarType.error}>{this.state.errorMessage}</MessageBar>
|
||||
:
|
||||
this.state.users.map((user: any) => {
|
||||
return (
|
||||
<PersonaCard
|
||||
context={this.props.context}
|
||||
profileProperties={{
|
||||
DisplayName: user.PreferredName,
|
||||
Title: user.JobTitle,
|
||||
PictureUrl: user.PictureURL,
|
||||
Email: user.WorkEmail,
|
||||
Department: user.Department,
|
||||
WorkPhone: user.WorkPhone
|
||||
}}>
|
||||
</PersonaCard>
|
||||
);
|
||||
})
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
import { WebPartContext } from "@microsoft/sp-webpart-base";
|
||||
import { DisplayMode } from '@microsoft/sp-core-library';
|
||||
export interface IDirectoryProps {
|
||||
title: string;
|
||||
displayMode: DisplayMode;
|
||||
context: WebPartContext;
|
||||
updateProperty: (value: string) => void;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import { IProfileProperties} from './../../../SPServices/IProfileProperties';
|
||||
import { PeoplePickerEntity, SearchResult, SearchResults } from '@pnp/pnpjs';
|
||||
export interface IDirectoryState {
|
||||
users:any;
|
||||
isLoading: boolean;
|
||||
errorMessage:string;
|
||||
hasError:boolean;
|
||||
indexSelectedKey: string;
|
||||
searchString:string;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import { WebPartContext } from "@microsoft/sp-webpart-base";
|
||||
import { ApplicationCustomizerContext } from "@microsoft/sp-application-base";
|
||||
import {IUserProperties} from './IUserProperties';
|
||||
import { PeoplePickerEntity, SearchResult , SearchResults} from '@pnp/pnpjs';
|
||||
|
||||
export interface IPersonaCardProps {
|
||||
context: WebPartContext | ApplicationCustomizerContext;
|
||||
profileProperties : IUserProperties;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export interface IPersonaCardState {
|
||||
livePersonaCard: any;
|
||||
pictureUrl:string;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
export interface IUserProperties {
|
||||
Department: string;
|
||||
MobilePhone?: String;
|
||||
PictureUrl: string;
|
||||
Title: string;
|
||||
DisplayName: string;
|
||||
Email:string;
|
||||
WorkPhone?: string;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||
|
||||
.personaContainer {
|
||||
display:inline-block;
|
||||
margin-top: 15px;
|
||||
margin-right: 15px;
|
||||
width: 350px;
|
||||
min-width: 300;
|
||||
vertical-align: top;
|
||||
}
|
||||
.documentCard {
|
||||
border-color: $ms-color-themeDark;
|
||||
border-top-width: 5px;
|
||||
width: 100%,
|
||||
}
|
||||
.persona {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.bottomColor {
|
||||
background-color: $ms-color-themeDark;
|
||||
height: 5px;
|
||||
margin-top: 10;
|
||||
width: 100%;
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
import * as React from 'react';
|
||||
import styles from './PersonaCard.module.scss';
|
||||
import { IPersonaCardProps } from './IPersonaCardProps';
|
||||
import { IPersonaCardState } from './IPersonaCardState';
|
||||
import { Version, Environment, EnvironmentType, ServiceScope, Log, Text } from "@microsoft/sp-core-library";
|
||||
import { SPComponentLoader } from "@microsoft/sp-loader";
|
||||
|
||||
import {
|
||||
Persona,
|
||||
PersonaCoin,
|
||||
PersonaInitialsColor,
|
||||
PersonaSize,
|
||||
IPersonaStyles,
|
||||
Label,
|
||||
DocumentCard,
|
||||
IDocumentCardStyles,
|
||||
DocumentCardType,
|
||||
Icon
|
||||
}
|
||||
from 'office-ui-fabric-react';
|
||||
|
||||
const EXP_SOURCE: string = "SPFxDirectory";
|
||||
const LIVE_PERSONA_COMPONENT_ID: string = "914330ee-2df2-4f6e-a858-30c23a812408";
|
||||
//const PROFILE_IMAGE_URL: string = 'https://outlook.office365.com/owa/service.svc/s/GetPersonaPhoto?email={0}&UA=0&size=HR96x96&sc=1564597822258';
|
||||
|
||||
export class PersonaCard extends React.Component<IPersonaCardProps, IPersonaCardState> {
|
||||
|
||||
constructor(props: IPersonaCardProps) {
|
||||
super(props);
|
||||
this.state = { livePersonaCard: undefined, pictureUrl: undefined };
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @memberof PersonaCard
|
||||
*/
|
||||
public async componentDidMount() {
|
||||
|
||||
const sharedLibrary = await this.loadSPComponentById(LIVE_PERSONA_COMPONENT_ID);
|
||||
const livePersonaCard: any = sharedLibrary.LivePersonaCard;
|
||||
this.setState( {livePersonaCard: livePersonaCard });
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param {IPersonaCardProps} prevProps
|
||||
* @param {IPersonaCardState} prevState
|
||||
* @memberof PersonaCard
|
||||
*/
|
||||
public componentDidUpdate(prevProps: IPersonaCardProps, prevState: IPersonaCardState): void {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @returns
|
||||
* @memberof PersonaCard
|
||||
*/
|
||||
private _LivePersonaCard() {
|
||||
|
||||
return React.createElement(this.state.livePersonaCard, {
|
||||
className: '',
|
||||
clientScenario: "PeopleWebPart",
|
||||
disableHover: false,
|
||||
hostAppPersonaInfo: {
|
||||
PersonaType: "User"
|
||||
},
|
||||
serviceScope: this.props.context.serviceScope,
|
||||
upn: this.props.profileProperties.Email,
|
||||
onCardOpen: () => {
|
||||
},
|
||||
onCardClose: () => {
|
||||
}
|
||||
}, this._PersonaCard());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @returns {JSX.Element}
|
||||
* @memberof PersonaCard
|
||||
*/
|
||||
private _PersonaCard(): JSX.Element {
|
||||
return (
|
||||
<DocumentCard className={styles.documentCard} type={DocumentCardType.normal} style={{maxWidth: 350}}>
|
||||
|
||||
<div className={styles.persona}>
|
||||
<Persona
|
||||
text={this.props.profileProperties.DisplayName}
|
||||
secondaryText={this.props.profileProperties.Title}
|
||||
tertiaryText={this.props.profileProperties.Department}
|
||||
imageUrl={this.props.profileProperties.PictureUrl}
|
||||
size={PersonaSize.size72}
|
||||
imageShouldFadeIn={false}
|
||||
imageShouldStartVisible={true}>
|
||||
<Label>
|
||||
{
|
||||
this.props.profileProperties.WorkPhone ?
|
||||
<div>
|
||||
<Icon iconName='Phone' style={{ fontSize: '12px' }}/>
|
||||
<span style={{ marginLeft: 5, fontSize: '12px' }}> {this.props.profileProperties.WorkPhone}</span>
|
||||
</div>
|
||||
:
|
||||
''
|
||||
}
|
||||
|
||||
</Label>
|
||||
</Persona>
|
||||
</div>
|
||||
|
||||
|
||||
</DocumentCard>
|
||||
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Load SPFx component by id, SPComponentLoader is used to load the SPFx components
|
||||
* @param componentId - componentId, guid of the component library
|
||||
*/
|
||||
private async loadSPComponentById(componentId: string): Promise<any> {
|
||||
try {
|
||||
const component: any = await SPComponentLoader.loadComponentById(componentId);
|
||||
return component;
|
||||
|
||||
} catch (error) {
|
||||
Promise.reject(error);
|
||||
Log.error(EXP_SOURCE, error, this.props.context.serviceScope);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @returns {React.ReactElement<IPersonaCardProps>}
|
||||
* @memberof PersonaCard
|
||||
*/
|
||||
public render(): React.ReactElement<IPersonaCardProps> {
|
||||
|
||||
return (
|
||||
<div className={styles.personaContainer}>
|
||||
{
|
||||
this.state.livePersonaCard ?
|
||||
this._LivePersonaCard()
|
||||
:
|
||||
this._PersonaCard()
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
define([], function() {
|
||||
return {
|
||||
SearchPlaceHolder: "Search for People",
|
||||
"PropertyPaneDescription": "Search People from Organization Directory",
|
||||
"BasicGroupName": "Properties",
|
||||
"TitleFieldLabel": "Web Part Title",
|
||||
"DirectoryMessage": "No users found in directory"
|
||||
}
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
declare interface IDirectoryWebPartStrings {
|
||||
SearchPlaceHolder: string;
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
TitleFieldLabel: string;
|
||||
DirectoryMessage: string;
|
||||
}
|
||||
|
||||
declare module 'DirectoryWebPartStrings' {
|
||||
const strings: IDirectoryWebPartStrings;
|
||||
export = strings;
|
||||
}
|
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* This script updates the package-solution version analogue to the
|
||||
* the package.json file.
|
||||
*/
|
||||
|
||||
if (process.env.npm_package_version === undefined) {
|
||||
|
||||
throw 'Package version cannot be evaluated';
|
||||
|
||||
}
|
||||
|
||||
// define path to package-solution file
|
||||
const solution = './config/package-solution.json',
|
||||
teams = './teams/manifest.json';
|
||||
|
||||
// require filesystem instance
|
||||
const fs = require('fs');
|
||||
|
||||
// get next automated package version from process variable
|
||||
const nextPkgVersion = process.env.npm_package_version;
|
||||
|
||||
// make sure next build version match
|
||||
const nextVersion = nextPkgVersion.indexOf('-') === -1 ?
|
||||
nextPkgVersion : nextPkgVersion.split('-')[0];
|
||||
|
||||
// Update version in SPFx package-solution if exists
|
||||
if (fs.existsSync(solution)) {
|
||||
|
||||
// read package-solution file
|
||||
const solutionFileContent = fs.readFileSync(solution, 'UTF-8');
|
||||
// parse file as json
|
||||
const solutionContents = JSON.parse(solutionFileContent);
|
||||
|
||||
// set property of version to next version
|
||||
solutionContents.solution.version = nextVersion + '.0';
|
||||
|
||||
// save file
|
||||
fs.writeFileSync(
|
||||
solution,
|
||||
// convert file back to proper json
|
||||
JSON.stringify(solutionContents, null, 2),
|
||||
'UTF-8');
|
||||
|
||||
}
|
||||
|
||||
// Update version in teams manifest if exists
|
||||
if (fs.existsSync(teams)) {
|
||||
|
||||
// read package-solution file
|
||||
const teamsManifestContent = fs.readFileSync(teams, 'UTF-8');
|
||||
// parse file as json
|
||||
const teamsContent = JSON.parse(teamsManifestContent);
|
||||
|
||||
// set property of version to next version
|
||||
teamsContent.version = nextVersion;
|
||||
|
||||
// save file
|
||||
fs.writeFileSync(
|
||||
teams,
|
||||
// convert file back to proper json
|
||||
JSON.stringify(teamsContent, null, 2),
|
||||
'UTF-8');
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json",
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true,
|
||||
"outDir": "lib",
|
||||
"inlineSources": false,
|
||||
"strictNullChecks": false,
|
||||
"noUnusedLocals": false,
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"es6-promise",
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"extends": "@microsoft/sp-tslint-rules/base-tslint.json",
|
||||
"rules": {
|
||||
"class-name": false,
|
||||
"export-name": false,
|
||||
"forin": false,
|
||||
"label-position": false,
|
||||
"member-access": true,
|
||||
"no-arg": false,
|
||||
"no-console": false,
|
||||
"no-construct": false,
|
||||
"no-duplicate-variable": true,
|
||||
"no-eval": false,
|
||||
"no-function-expression": true,
|
||||
"no-internal-module": true,
|
||||
"no-shadowed-variable": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-unnecessary-semicolons": true,
|
||||
"no-unused-expression": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-with-statement": true,
|
||||
"semicolon": true,
|
||||
"trailing-comma": false,
|
||||
"typedef": false,
|
||||
"typedef-whitespace": false,
|
||||
"use-named-parameter": true,
|
||||
"variable-name": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|