Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. import * as pnp from 'sp-pnp-js';
  2.  
  3. import { Version } from '@microsoft/sp-core-library';
  4. import {
  5. BaseClientSideWebPart,
  6. IPropertyPaneConfiguration,
  7. PropertyPaneTextField
  8. } from '@microsoft/sp-webpart-base';
  9. import { escape } from '@microsoft/sp-lodash-subset';
  10.  
  11. import styles from './GetUserProfileProperties.module.scss';
  12. import * as strings from 'getUserProfilePropertiesStrings';
  13. import { IGetUserProfilePropertiesWebPartProps } from './IGetUserProfilePropertiesWebPartProps';
  14.  
  15. export default class GetUserProfilePropertiesWebPart extends BaseClientSideWebPart<IGetUserProfilePropertiesWebPartProps> {
  16.  
  17. private GetUserProperties(): void {
  18.  
  19. pnp.sp.profiles.myProperties.get().then(function(result) {
  20. var userProperties = result.UserProfileProperties;
  21. var userPropertyValues = "";
  22. userProperties.forEach(function(property) {
  23. userPropertyValues += property.Key + " - " + property.Value + "<br/>";
  24. });
  25. document.getElementById("spUserProfileProperties").innerHTML = userPropertyValues;
  26. }).catch(function(error) {
  27. console.log("Error: " + error);
  28. });
  29.  
  30. }
  31.  
  32. public render(): void {
  33.  
  34. this.domElement.innerHTML = `
  35. <div class="${styles.helloWorld}">
  36. <div class="${styles.container}">
  37. <div class="ms-Grid-row ms-bgColor-themeDark ms-fontColor-white ${styles.row}">
  38. <div class="ms-Grid-col ms-u-lg10 ms-u-xl8 ms-u-xlPush2 ms-u-lgPush1">
  39. <span class="ms-font-xl ms-fontColor-white" style="font-size:28px">Welcome to SharePoint Framework Development using PnP JS Library</span>
  40.  
  41. <p class="ms-font-l ms-fontColor-white" style="text-align: left">Demo : Retrieve User Profile Properties</p>
  42. </div>
  43. </div>
  44. <div class="ms-Grid-row ms-bgColor-themeDark ms-fontColor-white ${styles.row}">
  45. <div style="background-color:Black;color:white;text-align: center;font-weight: bold;font-size:18px;">User Profile Details</div>
  46. <br>
  47. <div id="spUserProfileProperties" />
  48. </div>
  49. </div>
  50. </div>`;
  51. this.GetUserProperties();
  52. }
  53.  
  54. protected get dataVersion(): Version {
  55. return Version.parse('1.0');
  56. }
  57.  
  58. protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
  59. return {
  60. pages: [
  61. {
  62. header: {
  63. description: strings.PropertyPaneDescription
  64. },
  65. groups: [
  66. {
  67. groupName: strings.BasicGroupName,
  68. groupFields: [
  69. PropertyPaneTextField('description', {
  70. label: strings.DescriptionFieldLabel
  71. })
  72. ]
  73. }
  74. ]
  75. }
  76. ]
  77. };
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement