Updated react-officegraph to GA (#229)

* updated react office graph to GA

* uploaded src folder and the package folder

* updated readme

* again updated readme
This commit is contained in:
Gautam Sheth 2017-06-12 16:04:05 +05:30 committed by Vesa Juvonen
parent be13d78abe
commit 9d17034205
147 changed files with 152250 additions and 768 deletions

View File

@ -29,7 +29,7 @@ Sample SharePoint Framework Client-Side Web Part built using React showing docum
![Working with Web Part in the SharePoint Workbench](./assets/trending-in-sites-i-follow-preview.png)
## Used SharePoint Framework Version
![drop](https://img.shields.io/badge/drop-drop2-red.svg)
![drop](https://img.shields.io/badge/drop-ga-green.svg)
## Applies to
@ -40,12 +40,13 @@ Sample SharePoint Framework Client-Side Web Part built using React showing docum
Solution|Author(s)
--------|---------
react-officegraph|Waldek Mastykarz (MVP, Rencore, @waldekm)
react-officegraph|Waldek Mastykarz (MVP, Rencore, @waldekm), Gautam Sheth(SharePoint Consultant,Rapid Circle,@gautamdsheth)
## Version history
Version|Date|Comments
-------|----|--------
2.0 |May 31, 2017| GA release
1.3.0|September 20, 2016|Added the Trending in the sites I follow sample
1.2.0|September 20, 2016|Added the My recent documents sample
1.1.0|September 19, 2016|Added the Working with sample

View File

@ -1,15 +1,5 @@
{
"entries": [
{
"entry": "./lib/webparts/trendingInThisSite/TrendingInThisSiteWebPart.js",
"manifest": "./src/webparts/trendingInThisSite/TrendingInThisSiteWebPart.manifest.json",
"outputPath": "./dist/trending-in-this-site.bundle.js"
},
{
"entry": "./lib/webparts/workingWith/WorkingWithWebPart.js",
"manifest": "./src/webparts/workingWith/WorkingWithWebPart.manifest.json",
"outputPath": "./dist/working-with.bundle.js"
},
{
"entry": "./lib/webparts/myRecentDocuments/MyRecentDocumentsWebPart.js",
"manifest": "./src/webparts/myRecentDocuments/MyRecentDocumentsWebPart.manifest.json",
@ -19,21 +9,23 @@
"entry": "./lib/webparts/trendingInTheSitesIFollow/TrendingInTheSitesIFollowWebPart.js",
"manifest": "./src/webparts/trendingInTheSitesIFollow/TrendingInTheSitesIFollowWebPart.manifest.json",
"outputPath": "./dist/trending-in-the-sites-i-follow.bundle.js"
},
{
"entry": "./lib/webparts/trendingInThisSite/TrendingInThisSiteWebPart.js",
"manifest": "./src/webparts/trendingInThisSite/TrendingInThisSiteWebPart.manifest.json",
"outputPath": "./dist/trending-in-this-site.bundle.js"
},
{
"entry": "./lib/webparts/workingWith/WorkingWithWebPart.js",
"manifest": "./src/webparts/workingWith/WorkingWithWebPart.manifest.json",
"outputPath": "./dist/working-with.bundle.js"
}
],
"externals": {
"@microsoft/sp-client-base": "node_modules/@microsoft/sp-client-base/dist/sp-client-base.js",
"@microsoft/sp-client-preview": "node_modules/@microsoft/sp-client-preview/dist/sp-client-preview.js",
"@microsoft/sp-lodash-subset": "node_modules/@microsoft/sp-lodash-subset/dist/sp-lodash-subset.js",
"office-ui-fabric-react": "node_modules/office-ui-fabric-react/dist/office-ui-fabric-react.js",
"react": "node_modules/react/dist/react.min.js",
"react-dom": "node_modules/react-dom/dist/react-dom.min.js",
"react-dom/server": "node_modules/react-dom/dist/react-dom-server.min.js"
},
"externals": {},
"localizedResources": {
"trendingInThisSiteStrings": "webparts/trendingInThisSite/loc/{locale}.js",
"workingWithStrings": "webparts/workingWith/loc/{locale}.js",
"myRecentDocumentsStrings": "webparts/myRecentDocuments/loc/{locale}.js",
"trendingInTheSitesIFollowStrings": "webparts/trendingInTheSitesIFollow/loc/{locale}.js"
"trendingInTheSitesIFollowStrings": "webparts/trendingInTheSitesIFollow/loc/{locale}.js",
"trendingInThisSiteStrings": "webparts/trendingInThisSite/loc/{locale}.js",
"workingWithStrings": "webparts/workingWith/loc/{locale}.js"
}
}

View File

@ -0,0 +1,3 @@
{
"deployCdnPath": "temp/deploy"
}

View File

@ -1,6 +1,6 @@
{
"workingDir": "./temp/deploy/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "react-officegraph",
"container": "my-recent-documents",
"accessKey": "<!-- ACCESS KEY -->"
}

View File

@ -1,10 +1,10 @@
{
"solution": {
"name": "react-officegraph-client-side-solution",
"id": "ab9002a3-ee4e-4d42-8322-cd4fc0ee7570",
"name": "my-recent-documents-client-side-solution",
"id": "5800f751-4ee9-462d-bbc4-d4c305e93c73",
"version": "1.0.0.0"
},
"paths": {
"zippedPackage": "react-officegraph.spapp"
"zippedPackage": "solution/my-recent-documents.sppkg"
}
}

View File

@ -16,13 +16,11 @@
"export-name": false,
"forin": false,
"label-position": false,
"label-undefined": false,
"member-access": true,
"no-arg": false,
"no-console": false,
"no-construct": false,
"no-duplicate-case": true,
"no-duplicate-key": false,
"no-duplicate-variable": true,
"no-eval": false,
"no-function-expression": true,
@ -32,8 +30,6 @@
"no-unnecessary-semicolons": true,
"no-unused-expression": true,
"no-unused-imports": true,
"no-unused-variable": true,
"no-unreachable": true,
"no-use-before-declare": true,
"no-with-statement": true,
"semicolon": true,
@ -44,8 +40,7 @@
"valid-typeof": true,
"variable-name": false,
"whitespace": false,
"prefer-const": true,
"a11y-role": true
"prefer-const": true
}
}
}

View File

@ -0,0 +1,64 @@
{
"id": "65f773e5-a708-4b28-ac1f-0fb74e9f85da",
"alias": "TrendingInThisSiteWebPart",
"componentType": "WebPart",
"version": "0.0.1",
"manifestVersion": 2,
"preconfiguredEntries": [
{
"groupId": "65f773e5-a708-4b28-ac1f-0fb74e9f85da",
"group": {
"default": "Content rollup"
},
"title": {
"default": "Trending in this site"
},
"description": {
"default": "Shows documents trending in this site"
},
"officeFabricIconFontName": "Page",
"properties": {
"numberOfDocuments": 5
}
}
],
"loaderConfig": {
"entryModuleId": "trending-in-this-site.bundle",
"internalModuleBaseUrls": [
"https://localhost:4321/"
],
"scriptResources": {
"trending-in-this-site.bundle": {
"type": "path",
"path": "dist/trending-in-this-site.bundle.js"
},
"trendingInThisSiteStrings": {
"defaultPath": "lib/webparts/trendingInThisSite/loc/en-us.js",
"type": "localizedPath",
"paths": {}
},
"@microsoft/sp-core-library": {
"type": "component",
"version": "1.0.0",
"id": "7263c7d0-1d6a-45ec-8d85-d4d1d234171b"
},
"react": {
"type": "component",
"version": "15.5.4",
"id": "0d910c1c-13b9-4e1c-9aa4-b008c5e42d7d",
"failoverPath": "node_modules/react/dist/react.js"
},
"react-dom": {
"type": "component",
"version": "15.5.4",
"id": "aa0a46ec-1505-43cd-a44a-93f3a5aa460a",
"failoverPath": "node_modules/react-dom/dist/react-dom.js"
},
"@microsoft/sp-webpart-base": {
"type": "component",
"version": "1.0.0",
"id": "974a7777-0990-4136-8fa6-95d80114c2e0"
}
}
}
}

View File

@ -0,0 +1,70 @@
{
"id": "7dd7cf1a-0201-4ecb-87d1-df26ee53ba5f",
"alias": "TrendingInTheSitesIFollowWebPart",
"componentType": "WebPart",
"version": "0.0.1",
"manifestVersion": 2,
"preconfiguredEntries": [
{
"groupId": "7dd7cf1a-0201-4ecb-87d1-df26ee53ba5f",
"group": {
"default": "Content rollup"
},
"title": {
"default": "Trending in the sites I follow"
},
"description": {
"default": "Shows documents trending in the sites followed by the current user"
},
"officeFabricIconFontName": "Chart",
"properties": {
"title": "Trending in the sites I follow",
"numberOfDocuments": 5
}
}
],
"loaderConfig": {
"entryModuleId": "trending-in-the-sites-i-follow.bundle",
"internalModuleBaseUrls": [
"https://localhost:4321/"
],
"scriptResources": {
"trending-in-the-sites-i-follow.bundle": {
"type": "path",
"path": "dist/trending-in-the-sites-i-follow.bundle.js"
},
"trendingInTheSitesIFollowStrings": {
"defaultPath": "lib/webparts/trendingInTheSitesIFollow/loc/en-us.js",
"type": "localizedPath",
"paths": {}
},
"@microsoft/sp-core-library": {
"type": "component",
"version": "1.0.0",
"id": "7263c7d0-1d6a-45ec-8d85-d4d1d234171b"
},
"react": {
"type": "component",
"version": "15.5.4",
"id": "0d910c1c-13b9-4e1c-9aa4-b008c5e42d7d",
"failoverPath": "node_modules/react/dist/react.js"
},
"react-dom": {
"type": "component",
"version": "15.5.4",
"id": "aa0a46ec-1505-43cd-a44a-93f3a5aa460a",
"failoverPath": "node_modules/react-dom/dist/react-dom.js"
},
"@microsoft/sp-webpart-base": {
"type": "component",
"version": "1.0.0",
"id": "974a7777-0990-4136-8fa6-95d80114c2e0"
},
"@microsoft/sp-http": {
"type": "component",
"version": "1.0.0",
"id": "c07208f0-ea3b-4c1a-9965-ac1b825211a6"
}
}
}
}

View File

@ -0,0 +1,70 @@
{
"id": "a5a289e6-4d54-4ffa-a1d6-3c5fa9dff088",
"alias": "MyRecentDocumentsWebPart",
"componentType": "WebPart",
"version": "0.0.1",
"manifestVersion": 2,
"preconfiguredEntries": [
{
"groupId": "a5a289e6-4d54-4ffa-a1d6-3c5fa9dff088",
"group": {
"default": "Content rollup"
},
"title": {
"default": "My recent documents"
},
"description": {
"default": "Shows documents recently viewed or modified by the current user"
},
"officeFabricIconFontName": "Recent",
"properties": {
"title": "My recent documents",
"numberOfDocuments": 5
}
}
],
"loaderConfig": {
"entryModuleId": "my-recent-documents.bundle",
"internalModuleBaseUrls": [
"https://localhost:4321/"
],
"scriptResources": {
"my-recent-documents.bundle": {
"type": "path",
"path": "dist/my-recent-documents.bundle.js"
},
"myRecentDocumentsStrings": {
"defaultPath": "lib/webparts/myRecentDocuments/loc/en-us.js",
"type": "localizedPath",
"paths": {}
},
"@microsoft/sp-core-library": {
"type": "component",
"version": "1.0.0",
"id": "7263c7d0-1d6a-45ec-8d85-d4d1d234171b"
},
"react": {
"type": "component",
"version": "15.5.4",
"id": "0d910c1c-13b9-4e1c-9aa4-b008c5e42d7d",
"failoverPath": "node_modules/react/dist/react.js"
},
"react-dom": {
"type": "component",
"version": "15.5.4",
"id": "aa0a46ec-1505-43cd-a44a-93f3a5aa460a",
"failoverPath": "node_modules/react-dom/dist/react-dom.js"
},
"@microsoft/sp-webpart-base": {
"type": "component",
"version": "1.0.0",
"id": "974a7777-0990-4136-8fa6-95d80114c2e0"
},
"@microsoft/sp-http": {
"type": "component",
"version": "1.0.0",
"id": "c07208f0-ea3b-4c1a-9965-ac1b825211a6"
}
}
}
}

View File

@ -0,0 +1,70 @@
{
"id": "e23c0bf2-75eb-48f6-9f55-bafc043aab86",
"alias": "WorkingWithWebPart",
"componentType": "WebPart",
"version": "0.0.1",
"manifestVersion": 2,
"preconfiguredEntries": [
{
"groupId": "e23c0bf2-75eb-48f6-9f55-bafc043aab86",
"group": {
"default": "Productivity"
},
"title": {
"default": "Working with"
},
"description": {
"default": "Shows people with whom you communicate frequently"
},
"officeFabricIconFontName": "Group",
"properties": {
"title": "Recent contacts",
"numberOfPeople": 5
}
}
],
"loaderConfig": {
"entryModuleId": "working-with.bundle",
"internalModuleBaseUrls": [
"https://localhost:4321/"
],
"scriptResources": {
"working-with.bundle": {
"type": "path",
"path": "dist/working-with.bundle.js"
},
"workingWithStrings": {
"defaultPath": "lib/webparts/workingWith/loc/en-us.js",
"type": "localizedPath",
"paths": {}
},
"@microsoft/sp-core-library": {
"type": "component",
"version": "1.0.0",
"id": "7263c7d0-1d6a-45ec-8d85-d4d1d234171b"
},
"react": {
"type": "component",
"version": "15.5.4",
"id": "0d910c1c-13b9-4e1c-9aa4-b008c5e42d7d",
"failoverPath": "node_modules/react/dist/react.js"
},
"react-dom": {
"type": "component",
"version": "15.5.4",
"id": "aa0a46ec-1505-43cd-a44a-93f3a5aa460a",
"failoverPath": "node_modules/react-dom/dist/react-dom.js"
},
"@microsoft/sp-webpart-base": {
"type": "component",
"version": "1.0.0",
"id": "974a7777-0990-4136-8fa6-95d80114c2e0"
},
"@microsoft/sp-http": {
"type": "component",
"version": "1.0.0",
"id": "c07208f0-ea3b-4c1a-9965-ac1b825211a6"
}
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
export interface IActivity {
name: string;
date: string;
actorId: number;
actorName?: string;
actorPhotoUrl?: string;
}

View File

@ -0,0 +1,3 @@
"use strict";
//# sourceMappingURL=IActivity.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"webparts/IActivity.js","sourcesContent":[],"sourceRoot":"..\\..\\src"}

View File

@ -0,0 +1,6 @@
export interface IActorInformation {
id: number;
name: string;
email: string;
photoUrl: string;
}

View File

@ -0,0 +1,3 @@
"use strict";
//# sourceMappingURL=IActorInformation.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"webparts/IActorInformation.js","sourcesContent":[],"sourceRoot":"..\\..\\src"}

View File

@ -0,0 +1,11 @@
import { IActivity } from './IActivity';
export interface ITrendingDocument {
id: string;
title: string;
url: string;
webUrl?: string;
webTitle?: string;
previewImageUrl: string;
extension: string;
activity: IActivity;
}

View File

@ -0,0 +1,3 @@
"use strict";
//# sourceMappingURL=ITrendingDocument.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"webparts/ITrendingDocument.js","sourcesContent":[],"sourceRoot":"..\\..\\src"}

View File

@ -0,0 +1,39 @@
export interface ISearchQueryResponse {
PrimaryQueryResult: IPrimaryQueryResult;
}
export interface IPrimaryQueryResult {
RelevantResults?: IRelevantResults;
}
export interface IRelevantResults {
RowCount: number;
Table?: ITable;
}
export interface ITable {
Rows?: IRow[];
}
export interface IRow {
Cells: ICell[];
}
export interface ICell {
Key: string;
Value: string;
ValueType: string;
}
export interface IEdge {
ActorId: number;
ObjectId: number;
Properties: IEdgeProperties;
}
export interface IEdgeProperties {
Action: number;
Blob: any[];
BlobContent: string;
ObjectSource: number;
Time: string;
Weight: number;
}
export declare class SearchUtils {
static getValueFromResults(key: string, results: ICell[]): string;
static getPreviewImageUrl(result: ICell[], siteUrl: string): string;
static getActionName(actionId: number): string;
}

View File

@ -0,0 +1,44 @@
"use strict";
var SearchUtils = (function () {
function SearchUtils() {
}
SearchUtils.getValueFromResults = function (key, results) {
var value = undefined;
if (results && results.length > 0 && key) {
for (var i = 0; i < results.length; i++) {
var resultItem = results[i];
if (resultItem.Key === key) {
value = resultItem.Value;
break;
}
}
}
return value;
};
SearchUtils.getPreviewImageUrl = function (result, siteUrl) {
var uniqueID = SearchUtils.getValueFromResults('uniqueID', result);
var siteId = SearchUtils.getValueFromResults('siteID', result);
var webId = SearchUtils.getValueFromResults('webID', result);
var docId = SearchUtils.getValueFromResults('DocId', result);
if (uniqueID && siteId && webId && docId) {
return siteUrl + "/_layouts/15/getpreview.ashx?guidFile=" + uniqueID + "&guidSite=" + siteId + "&guidWeb=" + webId + "&docid=" + docId + "\n &metadatatoken=300x424x2&ClientType=CodenameOsloWeb&size=small";
}
else {
return '';
}
};
SearchUtils.getActionName = function (actionId) {
switch (actionId) {
case 1001:
return 'Viewed';
case 1003:
return 'Modified';
default:
return '';
}
};
return SearchUtils;
}());
exports.SearchUtils = SearchUtils;
//# sourceMappingURL=SearchUtils.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/SearchUtils.ts"],"names":[],"mappings":";AA0CA;IAAA;IAyCA,CAAC;IAxCe,+BAAmB,GAAjC,UAAkC,GAAW,EAAE,OAAgB;QAC7D,IAAI,KAAK,GAAW,SAAS,CAAC;QAE9B,EAAE,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;YACzC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAChD,IAAM,UAAU,GAAU,OAAO,CAAC,CAAC,CAAC,CAAC;gBACrC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;oBAC3B,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;oBACzB,KAAK,CAAC;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,CAAC,KAAK,CAAC;IACf,CAAC;IAEa,8BAAkB,GAAhC,UAAiC,MAAe,EAAE,OAAe;QAC/D,IAAM,QAAQ,GAAW,WAAW,CAAC,mBAAmB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC7E,IAAM,MAAM,GAAW,WAAW,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACzE,IAAM,KAAK,GAAW,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvE,IAAM,KAAK,GAAW,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvE,EAAE,CAAC,CAAC,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC;YACzC,MAAM,CAAI,OAAO,8CAAyC,QAAQ,kBAAa,MAAM,iBAAY,KAAK,eAAU,KAAK,2EACtD,CAAC;QAClE,CAAC;QACD,IAAI,CAAC,CAAC;YACJ,MAAM,CAAC,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAEa,yBAAa,GAA3B,UAA4B,QAAgB;QAC1C,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;YACjB,KAAK,IAAI;gBACP,MAAM,CAAC,QAAQ,CAAC;YAClB,KAAK,IAAI;gBACP,MAAM,CAAC,UAAU,CAAC;YACpB;gBACE,MAAM,CAAC,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IACH,kBAAC;AAAD,CAzCA,AAyCC,IAAA;AAzCY,kCAAW","file":"webparts/SearchUtils.js","sourcesContent":["export interface ISearchQueryResponse {\n PrimaryQueryResult: IPrimaryQueryResult;\n}\n\nexport interface IPrimaryQueryResult {\n RelevantResults?: IRelevantResults;\n}\n\nexport interface IRelevantResults {\n RowCount: number;\n Table?: ITable;\n}\n\nexport interface ITable {\n Rows?: IRow[];\n}\n\nexport interface IRow {\n Cells: ICell[];\n}\n\nexport interface ICell {\n Key: string;\n Value: string;\n ValueType: string;\n}\n\nexport interface IEdge {\n ActorId: number;\n ObjectId: number;\n Properties: IEdgeProperties;\n}\n\nexport interface IEdgeProperties {\n Action: number;\n Blob: any[];\n BlobContent: string;\n ObjectSource: number;\n Time: string;\n Weight: number;\n}\n\nexport class SearchUtils {\n public static getValueFromResults(key: string, results: ICell[]): string {\n let value: string = undefined;\n\n if (results && results.length > 0 && key) {\n for (let i: number = 0; i < results.length; i++) {\n const resultItem: ICell = results[i];\n if (resultItem.Key === key) {\n value = resultItem.Value;\n break;\n }\n }\n }\n\n return value;\n }\n\n public static getPreviewImageUrl(result: ICell[], siteUrl: string): string {\n const uniqueID: string = SearchUtils.getValueFromResults('uniqueID', result);\n const siteId: string = SearchUtils.getValueFromResults('siteID', result);\n const webId: string = SearchUtils.getValueFromResults('webID', result);\n const docId: string = SearchUtils.getValueFromResults('DocId', result);\n if (uniqueID && siteId && webId && docId) {\n return `${siteUrl}/_layouts/15/getpreview.ashx?guidFile=${uniqueID}&guidSite=${siteId}&guidWeb=${webId}&docid=${docId}\n &metadatatoken=300x424x2&ClientType=CodenameOsloWeb&size=small`;\n }\n else {\n return '';\n }\n }\n\n public static getActionName(actionId: number): string {\n switch (actionId) {\n case 1001:\n return 'Viewed';\n case 1003:\n return 'Modified';\n default:\n return '';\n }\n }\n}"],"sourceRoot":"..\\..\\src"}

View File

@ -0,0 +1,4 @@
export declare class Utils {
static getUserPhotoUrl(userEmail: string, siteUrl: string, size?: string): string;
static trim(s: string): string;
}

View File

@ -0,0 +1,21 @@
"use strict";
var Utils = (function () {
function Utils() {
}
Utils.getUserPhotoUrl = function (userEmail, siteUrl, size) {
if (size === void 0) { size = 'S'; }
return siteUrl + "/_layouts/15/userphoto.aspx?size=" + size + "&accountname=" + userEmail;
};
Utils.trim = function (s) {
if (s && s.length > 0) {
return s.replace(/^\s+|\s+$/gm, '');
}
else {
return s;
}
};
return Utils;
}());
exports.Utils = Utils;
//# sourceMappingURL=Utils.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/Utils.ts"],"names":[],"mappings":";AAAA;IAAA;IAaA,CAAC;IAZe,qBAAe,GAA7B,UAA8B,SAAiB,EAAE,OAAe,EAAE,IAAkB;QAAlB,qBAAA,EAAA,UAAkB;QAClF,MAAM,CAAI,OAAO,yCAAoC,IAAI,qBAAgB,SAAW,CAAC;IACvF,CAAC;IAEa,UAAI,GAAlB,UAAmB,CAAS;QAC1B,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,CAAC;YACJ,MAAM,CAAC,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IACH,YAAC;AAAD,CAbA,AAaC,IAAA;AAbY,sBAAK","file":"webparts/Utils.js","sourcesContent":["export class Utils {\n public static getUserPhotoUrl(userEmail: string, siteUrl: string, size: string = 'S'): string {\n return `${siteUrl}/_layouts/15/userphoto.aspx?size=${size}&accountname=${userEmail}`;\n }\n\n public static trim(s: string): string {\n if (s && s.length > 0) {\n return s.replace(/^\\s+|\\s+$/gm, '');\n }\n else {\n return s;\n }\n }\n}"],"sourceRoot":"..\\..\\src"}

View File

@ -0,0 +1,4 @@
export interface IMyRecentDocumentsWebPartProps {
numberOfDocuments: number;
title: string;
}

View File

@ -0,0 +1,3 @@
"use strict";
//# sourceMappingURL=IMyRecentDocumentsWebPartProps.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"webparts/myRecentDocuments/IMyRecentDocumentsWebPartProps.js","sourcesContent":[],"sourceRoot":"..\\..\\..\\src"}

View File

@ -0,0 +1 @@
.myRecentDocuments_8aec3ad1 .webPartTitle_8aec3ad1{margin-bottom:.7em;margin-left:.38em}.myRecentDocuments_8aec3ad1 .ms-DocumentCard{float:left;margin:.5em}.myRecentDocuments_8aec3ad1 .ms-Spinner{width:7em;margin:0 auto}

View File

@ -0,0 +1,5 @@
declare const styles: {
myRecentDocuments: string;
webPartTitle: string;
};
export default styles;

View File

@ -0,0 +1,12 @@
"use strict";
/* tslint:disable */
require('./MyRecentDocuments.module.css');
var styles = {
myRecentDocuments: 'myRecentDocuments_8aec3ad1',
webPartTitle: 'webPartTitle_8aec3ad1',
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = styles;
/* tslint:enable */
//# sourceMappingURL=MyRecentDocuments.module.scss.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/myRecentDocuments/MyRecentDocuments.module.scss.ts"],"names":[],"mappings":";AAAA,oBAAoB;AACpB,OAAO,CAAC,gCAAgC,CAAC,CAAC;AAC1C,IAAM,MAAM,GAAG;IACb,iBAAiB,EAAE,4BAA4B;IAC/C,YAAY,EAAE,uBAAuB;CACtC,CAAC;;AAEF,kBAAe,MAAM,CAAC;AACtB,mBAAmB","file":"webparts/myRecentDocuments/MyRecentDocuments.module.scss.js","sourcesContent":["/* tslint:disable */\r\nrequire('./MyRecentDocuments.module.css');\r\nconst styles = {\r\n myRecentDocuments: 'myRecentDocuments_8aec3ad1',\r\n webPartTitle: 'webPartTitle_8aec3ad1',\r\n};\r\n\r\nexport default styles;\r\n/* tslint:enable */"],"sourceRoot":"..\\..\\..\\src"}

View File

@ -0,0 +1,9 @@
import { Version } from '@microsoft/sp-core-library';
import { BaseClientSideWebPart, IPropertyPaneConfiguration, IWebPartContext } from '@microsoft/sp-webpart-base';
import { IMyRecentDocumentsWebPartProps } from './IMyRecentDocumentsWebPartProps';
export default class MyRecentDocumentsWebPart extends BaseClientSideWebPart<IMyRecentDocumentsWebPartProps> {
constructor(context: IWebPartContext);
render(): void;
protected readonly dataVersion: Version;
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration;
}

View File

@ -0,0 +1,66 @@
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var sp_core_library_1 = require("@microsoft/sp-core-library");
var React = require("react");
var ReactDom = require("react-dom");
var sp_webpart_base_1 = require("@microsoft/sp-webpart-base");
var MyRecentDocuments_1 = require("./components/MyRecentDocuments");
var strings = require("myRecentDocumentsStrings");
var MyRecentDocumentsWebPart = (function (_super) {
__extends(MyRecentDocumentsWebPart, _super);
function MyRecentDocumentsWebPart(context) {
return _super.call(this) || this;
}
MyRecentDocumentsWebPart.prototype.render = function () {
var element = React.createElement(MyRecentDocuments_1.default, {
numberOfDocuments: this.properties.numberOfDocuments,
title: this.properties.title,
httpClient: this.context.spHttpClient,
siteUrl: this.context.pageContext.web.absoluteUrl
});
ReactDom.render(element, this.domElement);
};
Object.defineProperty(MyRecentDocumentsWebPart.prototype, "dataVersion", {
get: function () {
return sp_core_library_1.Version.parse('1.0');
},
enumerable: true,
configurable: true
});
MyRecentDocumentsWebPart.prototype.getPropertyPaneConfiguration = function () {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.ViewGroupName,
groupFields: [
sp_webpart_base_1.PropertyPaneTextField('title', {
label: strings.TitleFieldLabel
}),
sp_webpart_base_1.PropertyPaneSlider('numberOfDocuments', {
label: strings.NumberOfDocumentsFieldLabel,
min: 1,
max: 10,
step: 1
})
]
}
]
}
]
};
};
return MyRecentDocumentsWebPart;
}(sp_webpart_base_1.BaseClientSideWebPart));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = MyRecentDocumentsWebPart;
//# sourceMappingURL=MyRecentDocumentsWebPart.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/myRecentDocuments/MyRecentDocumentsWebPart.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAqD;AACrD,6BAA+B;AAC/B,oCAAsC;AACtC,8DAMoC;AAIpC,oEAA4F;AAC5F,kDAAoD;AAGpD;IAAsD,4CAAqD;IAEzG,kCAAmB,OAAwB;eACzC,iBAAO;IACT,CAAC;IAEM,yCAAM,GAAb;QACE,IAAM,OAAO,GAAgD,KAAK,CAAC,aAAa,CAAC,2BAAiB,EAAE;YAClG,iBAAiB,EAAE,IAAI,CAAC,UAAU,CAAC,iBAAiB;YACpD,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK;YAC5B,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;YACrC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW;SAClD,CAAC,CAAC;QAEH,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,sBAAc,iDAAW;aAAzB;YACE,MAAM,CAAC,yBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;;;OAAA;IAES,+DAA4B,GAAtC;QACE,MAAM,CAAC;YACL,KAAK,EAAE;gBACL;oBACE,MAAM,EAAE;wBACN,WAAW,EAAE,OAAO,CAAC,uBAAuB;qBAC7C;oBACD,MAAM,EAAE;wBACN;4BACE,SAAS,EAAE,OAAO,CAAC,aAAa;4BAChC,WAAW,EAAE;gCACX,uCAAqB,CAAC,OAAO,EAAE;oCAC7B,KAAK,EAAE,OAAO,CAAC,eAAe;iCAC/B,CAAC;gCACF,oCAAkB,CAAC,mBAAmB,EAAE;oCACtC,KAAK,EAAE,OAAO,CAAC,2BAA2B;oCAC1C,GAAG,EAAE,CAAC;oCACN,GAAG,EAAE,EAAE;oCACP,IAAI,EAAE,CAAC;iCACR,CAAC;6BACH;yBACF;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IACH,+BAAC;AAAD,CAhDA,AAgDC,CAhDqD,uCAAqB,GAgD1E","file":"webparts/myRecentDocuments/MyRecentDocumentsWebPart.js","sourcesContent":["import { Version } from '@microsoft/sp-core-library';\r\nimport * as React from 'react';\r\nimport * as ReactDom from 'react-dom';\r\nimport {\r\n BaseClientSideWebPart,\r\n IPropertyPaneConfiguration,\r\n IWebPartContext,\r\n PropertyPaneSlider, \r\n PropertyPaneTextField\r\n} from '@microsoft/sp-webpart-base';\r\nimport { escape } from '@microsoft/sp-lodash-subset';\r\n\r\n\r\nimport MyRecentDocuments, { IMyRecentDocumentsProps } from './components/MyRecentDocuments';\r\nimport * as strings from 'myRecentDocumentsStrings';\r\nimport { IMyRecentDocumentsWebPartProps } from './IMyRecentDocumentsWebPartProps';\r\n\r\nexport default class MyRecentDocumentsWebPart extends BaseClientSideWebPart<IMyRecentDocumentsWebPartProps> {\r\n\r\n public constructor(context: IWebPartContext) {\r\n super();\r\n }\r\n\r\n public render(): void {\r\n const element: React.ReactElement<IMyRecentDocumentsProps> = React.createElement(MyRecentDocuments, {\r\n numberOfDocuments: this.properties.numberOfDocuments,\r\n title: this.properties.title,\r\n httpClient: this.context.spHttpClient,\r\n siteUrl: this.context.pageContext.web.absoluteUrl\r\n });\r\n\r\n ReactDom.render(element, this.domElement);\r\n }\r\n\r\n protected get dataVersion(): Version {\r\n return Version.parse('1.0');\r\n }\r\n\r\n protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {\r\n return {\r\n pages: [\r\n {\r\n header: {\r\n description: strings.PropertyPaneDescription\r\n },\r\n groups: [\r\n {\r\n groupName: strings.ViewGroupName,\r\n groupFields: [\r\n PropertyPaneTextField('title', {\r\n label: strings.TitleFieldLabel\r\n }),\r\n PropertyPaneSlider('numberOfDocuments', {\r\n label: strings.NumberOfDocumentsFieldLabel,\r\n min: 1,\r\n max: 10,\r\n step: 1\r\n })\r\n ]\r\n }\r\n ]\r\n }\r\n ]\r\n };\r\n }\r\n}\r\n"],"sourceRoot":"..\\..\\..\\src"}

View File

@ -0,0 +1,21 @@
{
"$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json",
"id": "a5a289e6-4d54-4ffa-a1d6-3c5fa9dff088",
"alias": "MyRecentDocumentsWebPart",
"componentType": "WebPart",
"version": "0.0.1",
"manifestVersion": 2,
"preconfiguredEntries": [{
"groupId": "a5a289e6-4d54-4ffa-a1d6-3c5fa9dff088",
"group": { "default": "Content rollup" },
"title": { "default": "My recent documents" },
"description": { "default": "Shows documents recently viewed or modified by the current user" },
"officeFabricIconFontName": "Recent",
"properties": {
"title": "My recent documents",
"numberOfDocuments": 5
}
}]
}

View File

@ -0,0 +1,21 @@
import * as React from 'react';
import { IMyRecentDocumentsWebPartProps } from '../IMyRecentDocumentsWebPartProps';
import { SPHttpClient } from '@microsoft/sp-http';
import { ITrendingDocument } from '../../ITrendingDocument';
export interface IMyRecentDocumentsProps extends IMyRecentDocumentsWebPartProps {
httpClient: SPHttpClient;
siteUrl: string;
}
export interface IMyRecentDocumentsState {
myDocuments: ITrendingDocument[];
loading: boolean;
error: string;
}
export default class MyRecentDocuments extends React.Component<IMyRecentDocumentsProps, IMyRecentDocumentsState> {
constructor(props: IMyRecentDocumentsProps, state: IMyRecentDocumentsState);
componentDidMount(): void;
componentDidUpdate(prevProps: IMyRecentDocumentsProps, prevState: IMyRecentDocumentsState, prevContext: any): void;
render(): JSX.Element;
private loadMyDocuments(siteUrl, numberOfDocuments);
private getActorsInfo(actorId, siteUrl);
}

View File

@ -0,0 +1,187 @@
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var React = require("react");
var office_ui_fabric_react_1 = require("office-ui-fabric-react");
var MyRecentDocuments_module_scss_1 = require("../MyRecentDocuments.module.scss");
var sp_http_1 = require("@microsoft/sp-http");
var SearchUtils_1 = require("../../SearchUtils");
var Utils_1 = require("../../Utils");
var MyRecentDocuments = (function (_super) {
__extends(MyRecentDocuments, _super);
function MyRecentDocuments(props, state) {
var _this = _super.call(this, props) || this;
_this.state = {
myDocuments: [],
loading: true,
error: null
};
return _this;
}
MyRecentDocuments.prototype.componentDidMount = function () {
this.loadMyDocuments(this.props.siteUrl, this.props.numberOfDocuments);
};
MyRecentDocuments.prototype.componentDidUpdate = function (prevProps, prevState, prevContext) {
if (this.props.numberOfDocuments !== prevProps.numberOfDocuments ||
this.props.siteUrl !== prevProps.siteUrl && (this.props.numberOfDocuments && this.props.siteUrl)) {
this.loadMyDocuments(this.props.siteUrl, this.props.numberOfDocuments);
}
};
MyRecentDocuments.prototype.render = function () {
var loading = this.state.loading ? React.createElement("div", { style: { margin: '0 auto' } },
React.createElement(office_ui_fabric_react_1.Spinner, { label: 'Loading...' })) : React.createElement("div", null);
var error = this.state.error ? React.createElement("div", null,
React.createElement("strong", null, "Error: "),
" ",
this.state.error) : React.createElement("div", null);
var documents = this.state.myDocuments.map(function (doc, i) {
var iconUrl = "https://spoprod-a.akamaihd.net/files/odsp-next-prod_ship-2016-08-15_20160815.002/odsp-media/images/filetypes/32/" + doc.extension + ".png";
return (React.createElement(office_ui_fabric_react_1.DocumentCard, { onClickHref: doc.url, key: doc.id },
React.createElement(office_ui_fabric_react_1.DocumentCardPreview, { previewImages: [
{
previewImageSrc: doc.previewImageUrl,
iconSrc: iconUrl,
width: 318,
height: 196,
accentColor: '#ce4b1f'
}
] }),
React.createElement(office_ui_fabric_react_1.DocumentCardTitle, { title: doc.title }),
React.createElement(office_ui_fabric_react_1.DocumentCardActivity, { activity: doc.activity.name + " " + doc.activity.date, people: [
{ name: doc.activity.actorName, profileImageSrc: doc.activity.actorPhotoUrl }
] })));
});
return (React.createElement("div", { className: MyRecentDocuments_module_scss_1.default.myRecentDocuments },
React.createElement("div", { className: office_ui_fabric_react_1.css('ms-font-xl', MyRecentDocuments_module_scss_1.default.webPartTitle) }, this.props.title),
loading,
error,
documents,
React.createElement("div", { style: { clear: 'both' } })));
};
MyRecentDocuments.prototype.loadMyDocuments = function (siteUrl, numberOfDocuments) {
var _this = this;
var myDocuments = [];
this.props.httpClient.get(siteUrl + "/_api/search/query?querytext='*'&properties='GraphQuery:actor(me\\,or(action\\:1001\\,action\\:1003)),GraphRankingModel:{\"features\"\\:[{\"function\"\\:\"EdgeTime\"}]}'&selectproperties='Author,AuthorOwsUser,DocId,DocumentPreviewMetadata,Edges,EditorOwsUser,FileExtension,FileType,HitHighlightedProperties,HitHighlightedSummary,LastModifiedTime,LikeCountLifetime,ListID,ListItemID,OriginalPath,Path,Rank,SPWebUrl,SecondaryFileExtension,ServerRedirectedURL,SiteTitle,Title,ViewCountLifetime,siteID,uniqueID,webID'&rowlimit=" + numberOfDocuments + "&ClientType='MyRecentDocuments'&RankingModelId='0c77ded8-c3ef-466d-929d-905670ea1d72'", sp_http_1.SPHttpClient.configurations.v1, {
headers: {
'Accept': 'application/json;odata=nometadata',
'odata-version': ''
}
})
.then(function (response) {
return response.json();
})
.then(function (response) {
if (!response ||
!response.PrimaryQueryResult ||
!response.PrimaryQueryResult.RelevantResults ||
response.PrimaryQueryResult.RelevantResults.RowCount === 0) {
return Promise.resolve();
}
var actorId = undefined;
for (var i = 0; i < response.PrimaryQueryResult.RelevantResults.Table.Rows.length; i++) {
var row = response.PrimaryQueryResult.RelevantResults.Table.Rows[i];
var edges = JSON.parse(SearchUtils_1.SearchUtils.getValueFromResults('Edges', row.Cells));
if (edges.length < 1) {
continue;
}
// we can get multiple edges back so let's show the information from the latest one
var latestEdge = edges[0];
if (edges.length > 1) {
var latestEdgeDate = new Date(latestEdge.Properties.Time);
for (var i_1 = 1; i_1 < edges.length; i_1++) {
var edgeDate = new Date(edges[i_1].Properties.Time);
if (edgeDate > latestEdgeDate) {
latestEdge = edges[i_1];
latestEdgeDate = edgeDate;
}
}
}
if (!actorId) {
// since all edges that we're retrieving are personal (I viewed, I modified)
// we only need to get the actor ID once because it's the same on all edges (me)
actorId = latestEdge.ActorId;
}
var cells = row.Cells;
var date = new Date(latestEdge.Properties.Time);
var dateString = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();
myDocuments.push({
id: SearchUtils_1.SearchUtils.getValueFromResults('DocId', cells),
url: SearchUtils_1.SearchUtils.getValueFromResults('ServerRedirectedURL', cells),
title: SearchUtils_1.SearchUtils.getValueFromResults('Title', cells),
previewImageUrl: SearchUtils_1.SearchUtils.getPreviewImageUrl(cells, siteUrl),
extension: SearchUtils_1.SearchUtils.getValueFromResults('FileType', cells),
activity: {
actorId: latestEdge.ActorId,
date: dateString,
name: SearchUtils_1.SearchUtils.getActionName(latestEdge.Properties.Action)
}
});
}
return _this.getActorsInfo(actorId, siteUrl);
}).
then(function (actorInformation) {
if (actorInformation) {
for (var i = 0; i < myDocuments.length; i++) {
if (myDocuments[i].activity.actorId !== actorInformation.id) {
continue;
}
myDocuments[i].activity.actorName = actorInformation.name;
myDocuments[i].activity.actorPhotoUrl = actorInformation.photoUrl;
}
}
_this.setState({
loading: false,
error: null,
myDocuments: myDocuments
});
}, function (error) {
_this.setState({
loading: false,
error: error,
myDocuments: []
});
});
};
MyRecentDocuments.prototype.getActorsInfo = function (actorId, siteUrl) {
var _this = this;
if (!actorId) {
return Promise.resolve();
}
return new Promise(function (resolve, reject) {
_this.props.httpClient.get(siteUrl + "/_api/search/query?querytext='WorkId:" + actorId + "'&selectproperties='DocId,Title,WorkEmail'&ClientType='MyRecentDocuments'&SourceId='b09a7990-05ea-4af9-81ef-edfab16c4e31'", sp_http_1.SPHttpClient.configurations.v1, {
headers: {
'Accept': 'application/json;odata=nometadata',
'odata-version': ''
}
})
.then(function (response) {
return response.json();
})
.then(function (response) {
if (!response ||
!response.PrimaryQueryResult ||
!response.PrimaryQueryResult.RelevantResults ||
response.PrimaryQueryResult.RelevantResults.RowCount === 0) {
return Promise.resolve();
}
var cells = response.PrimaryQueryResult.RelevantResults.Table.Rows[0].Cells;
resolve({
email: SearchUtils_1.SearchUtils.getValueFromResults('WorkEmail', cells),
id: parseInt(SearchUtils_1.SearchUtils.getValueFromResults('DocId', cells)),
name: SearchUtils_1.SearchUtils.getValueFromResults('Title', cells),
photoUrl: Utils_1.Utils.getUserPhotoUrl(SearchUtils_1.SearchUtils.getValueFromResults('WorkEmail', cells), siteUrl)
});
}, function (error) {
reject(error);
});
});
};
return MyRecentDocuments;
}(React.Component));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = MyRecentDocuments;
//# sourceMappingURL=MyRecentDocuments.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
define([], function() {
return {
"PropertyPaneDescription": "Manage the settings of this Web Part",
"ViewGroupName": "View",
"NumberOfDocumentsFieldLabel": "Number of documents to show",
"TitleFieldLabel": "Web Part Title (displayed in the body)"
}
});

View File

@ -0,0 +1,10 @@
/// <reference types="mocha" />
"use strict";
var chai_1 = require("chai");
describe('MyRecentDocumentsWebPart', function () {
it('should do something', function () {
chai_1.assert.ok(true);
});
});
//# sourceMappingURL=MyRecentDocuments.test.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/myRecentDocuments/tests/MyRecentDocuments.test.ts"],"names":[],"mappings":"AAAA,+BAA+B;;AAE/B,6BAA8B;AAE9B,QAAQ,CAAC,0BAA0B,EAAE;IACnC,EAAE,CAAC,qBAAqB,EAAE;QACxB,aAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","file":"webparts/myRecentDocuments/tests/MyRecentDocuments.test.js","sourcesContent":["/// <reference types=\"mocha\" />\r\n\r\nimport { assert } from 'chai';\r\n\r\ndescribe('MyRecentDocumentsWebPart', () => {\r\n it('should do something', () => {\r\n assert.ok(true);\r\n });\r\n});\r\n"],"sourceRoot":"..\\..\\..\\..\\src"}

View File

@ -0,0 +1,4 @@
export interface ITrendingInTheSitesIFollowWebPartProps {
title: string;
numberOfDocuments: number;
}

View File

@ -0,0 +1,3 @@
"use strict";
//# sourceMappingURL=ITrendingInTheSitesIFollowWebPartProps.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"webparts/trendingInTheSitesIFollow/ITrendingInTheSitesIFollowWebPartProps.js","sourcesContent":[],"sourceRoot":"..\\..\\..\\src"}

View File

@ -0,0 +1 @@
.trendingInTheSitesIFollow_e41074f2 .webPartTitle_e41074f2{margin-bottom:.7em;margin-left:.38em}.trendingInTheSitesIFollow_e41074f2 .ms-DocumentCard{float:left;margin:.5em}.trendingInTheSitesIFollow_e41074f2 .ms-Spinner{width:7em;margin:0 auto}

View File

@ -0,0 +1,5 @@
declare const styles: {
trendingInTheSitesIFollow: string;
webPartTitle: string;
};
export default styles;

View File

@ -0,0 +1,12 @@
"use strict";
/* tslint:disable */
require('./TrendingInTheSitesIFollow.module.css');
var styles = {
trendingInTheSitesIFollow: 'trendingInTheSitesIFollow_e41074f2',
webPartTitle: 'webPartTitle_e41074f2',
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = styles;
/* tslint:enable */
//# sourceMappingURL=TrendingInTheSitesIFollow.module.scss.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/trendingInTheSitesIFollow/TrendingInTheSitesIFollow.module.scss.ts"],"names":[],"mappings":";AAAA,oBAAoB;AACpB,OAAO,CAAC,wCAAwC,CAAC,CAAC;AAClD,IAAM,MAAM,GAAG;IACb,yBAAyB,EAAE,oCAAoC;IAC/D,YAAY,EAAE,uBAAuB;CACtC,CAAC;;AAEF,kBAAe,MAAM,CAAC;AACtB,mBAAmB","file":"webparts/trendingInTheSitesIFollow/TrendingInTheSitesIFollow.module.scss.js","sourcesContent":["/* tslint:disable */\r\nrequire('./TrendingInTheSitesIFollow.module.css');\r\nconst styles = {\r\n trendingInTheSitesIFollow: 'trendingInTheSitesIFollow_e41074f2',\r\n webPartTitle: 'webPartTitle_e41074f2',\r\n};\r\n\r\nexport default styles;\r\n/* tslint:enable */"],"sourceRoot":"..\\..\\..\\src"}

View File

@ -0,0 +1,9 @@
import { Version } from '@microsoft/sp-core-library';
import { BaseClientSideWebPart, IPropertyPaneConfiguration, IWebPartContext } from '@microsoft/sp-webpart-base';
import { ITrendingInTheSitesIFollowWebPartProps } from './ITrendingInTheSitesIFollowWebPartProps';
export default class TrendingInTheSitesIFollowWebPart extends BaseClientSideWebPart<ITrendingInTheSitesIFollowWebPartProps> {
constructor(context: IWebPartContext);
render(): void;
protected readonly dataVersion: Version;
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration;
}

View File

@ -0,0 +1,66 @@
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var sp_core_library_1 = require("@microsoft/sp-core-library");
var React = require("react");
var ReactDom = require("react-dom");
var sp_webpart_base_1 = require("@microsoft/sp-webpart-base");
var strings = require("trendingInTheSitesIFollowStrings");
var TrendingInTheSitesIFollow_1 = require("./components/TrendingInTheSitesIFollow");
var TrendingInTheSitesIFollowWebPart = (function (_super) {
__extends(TrendingInTheSitesIFollowWebPart, _super);
function TrendingInTheSitesIFollowWebPart(context) {
return _super.call(this) || this;
}
TrendingInTheSitesIFollowWebPart.prototype.render = function () {
var element = React.createElement(TrendingInTheSitesIFollow_1.default, {
title: this.properties.title,
numberOfDocuments: this.properties.numberOfDocuments,
httpClient: this.context.spHttpClient,
siteUrl: this.context.pageContext.web.absoluteUrl
});
ReactDom.render(element, this.domElement);
};
Object.defineProperty(TrendingInTheSitesIFollowWebPart.prototype, "dataVersion", {
get: function () {
return sp_core_library_1.Version.parse('1.0');
},
enumerable: true,
configurable: true
});
TrendingInTheSitesIFollowWebPart.prototype.getPropertyPaneConfiguration = function () {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.ViewGroupName,
groupFields: [
sp_webpart_base_1.PropertyPaneTextField('title', {
label: strings.TitleFieldLabel
}),
sp_webpart_base_1.PropertyPaneSlider('numberOfDocuments', {
label: strings.NumberOfDocumentsFieldLabel,
min: 1,
max: 10,
step: 1
})
]
}
]
}
]
};
};
return TrendingInTheSitesIFollowWebPart;
}(sp_webpart_base_1.BaseClientSideWebPart));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = TrendingInTheSitesIFollowWebPart;
//# sourceMappingURL=TrendingInTheSitesIFollowWebPart.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/trendingInTheSitesIFollow/TrendingInTheSitesIFollowWebPart.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAqD;AACrD,6BAA+B;AAC/B,oCAAsC;AACtC,8DAOoC;AAGpC,0DAA4D;AAC5D,oFAAoH;AAGpH;IAA8D,oDAA6D;IAEzH,0CAAmB,OAAwB;eACzC,iBAAO;IACT,CAAC;IAEM,iDAAM,GAAb;QACE,IAAM,OAAO,GAAwD,KAAK,CAAC,aAAa,CAAC,mCAAyB,EAAE;YAClH,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK;YAC5B,iBAAiB,EAAE,IAAI,CAAC,UAAU,CAAC,iBAAiB;YACpD,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;YACrC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW;SAClD,CAAC,CAAC;QAEH,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,sBAAc,yDAAW;aAAzB;YACE,MAAM,CAAC,yBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;;;OAAA;IAES,uEAA4B,GAAtC;QACE,MAAM,CAAC;YACL,KAAK,EAAE;gBACL;oBACE,MAAM,EAAE;wBACN,WAAW,EAAE,OAAO,CAAC,uBAAuB;qBAC7C;oBACD,MAAM,EAAE;wBACN;4BACE,SAAS,EAAE,OAAO,CAAC,aAAa;4BAChC,WAAW,EAAE;gCACX,uCAAqB,CAAC,OAAO,EAAE;oCAC7B,KAAK,EAAE,OAAO,CAAC,eAAe;iCAC/B,CAAC;gCACF,oCAAkB,CAAC,mBAAmB,EAAE;oCACtC,KAAK,EAAE,OAAO,CAAC,2BAA2B;oCAC1C,GAAG,EAAE,CAAC;oCACN,GAAG,EAAE,EAAE;oCACP,IAAI,EAAE,CAAC;iCACR,CAAC;6BACH;yBACF;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IACH,uCAAC;AAAD,CAhDA,AAgDC,CAhD6D,uCAAqB,GAgDlF","file":"webparts/trendingInTheSitesIFollow/TrendingInTheSitesIFollowWebPart.js","sourcesContent":["import { Version } from '@microsoft/sp-core-library';\r\nimport * as React from 'react';\r\nimport * as ReactDom from 'react-dom';\r\nimport {\r\n BaseClientSideWebPart,\r\n IPropertyPaneConfiguration,\r\n PropertyPaneTextField,\r\n IWebPartContext,\r\n PropertyPaneSlider\r\n\r\n} from '@microsoft/sp-webpart-base';\r\nimport { escape } from '@microsoft/sp-lodash-subset';\r\n\r\nimport * as strings from 'trendingInTheSitesIFollowStrings';\r\nimport TrendingInTheSitesIFollow, { ITrendingInTheSitesIFollowProps } from './components/TrendingInTheSitesIFollow';\r\nimport { ITrendingInTheSitesIFollowWebPartProps } from './ITrendingInTheSitesIFollowWebPartProps';\r\n\r\nexport default class TrendingInTheSitesIFollowWebPart extends BaseClientSideWebPart<ITrendingInTheSitesIFollowWebPartProps> {\r\n\r\n public constructor(context: IWebPartContext) {\r\n super();\r\n }\r\n\r\n public render(): void {\r\n const element: React.ReactElement<ITrendingInTheSitesIFollowProps> = React.createElement(TrendingInTheSitesIFollow, {\r\n title: this.properties.title,\r\n numberOfDocuments: this.properties.numberOfDocuments,\r\n httpClient: this.context.spHttpClient,\r\n siteUrl: this.context.pageContext.web.absoluteUrl\r\n });\r\n\r\n ReactDom.render(element, this.domElement);\r\n }\r\n\r\n protected get dataVersion(): Version {\r\n return Version.parse('1.0');\r\n }\r\n\r\n protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {\r\n return {\r\n pages: [\r\n {\r\n header: {\r\n description: strings.PropertyPaneDescription\r\n },\r\n groups: [\r\n {\r\n groupName: strings.ViewGroupName,\r\n groupFields: [\r\n PropertyPaneTextField('title', {\r\n label: strings.TitleFieldLabel\r\n }),\r\n PropertyPaneSlider('numberOfDocuments', {\r\n label: strings.NumberOfDocumentsFieldLabel,\r\n min: 1,\r\n max: 10,\r\n step: 1\r\n })\r\n ]\r\n }\r\n ]\r\n }\r\n ]\r\n };\r\n }\r\n}\r\n"],"sourceRoot":"..\\..\\..\\src"}

View File

@ -0,0 +1,21 @@
{
"$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json",
"id": "7dd7cf1a-0201-4ecb-87d1-df26ee53ba5f",
"alias": "TrendingInTheSitesIFollowWebPart",
"componentType": "WebPart",
"version": "0.0.1",
"manifestVersion": 2,
"preconfiguredEntries": [{
"groupId": "7dd7cf1a-0201-4ecb-87d1-df26ee53ba5f",
"group": { "default": "Content rollup" },
"title": { "default": "Trending in the sites I follow" },
"description": { "default": "Shows documents trending in the sites followed by the current user" },
"officeFabricIconFontName": "Chart",
"properties": {
"title": "Trending in the sites I follow",
"numberOfDocuments": 5
}
}]
}

View File

@ -0,0 +1,22 @@
import * as React from 'react';
import { ITrendingInTheSitesIFollowWebPartProps } from '../ITrendingInTheSitesIFollowWebPartProps';
import { SPHttpClient } from '@microsoft/sp-http';
import { ITrendingDocument } from '../../ITrendingDocument';
export interface ITrendingInTheSitesIFollowProps extends ITrendingInTheSitesIFollowWebPartProps {
httpClient: SPHttpClient;
siteUrl: string;
}
export interface ITrendingInTheSitesIFollowState {
trendingDocuments: ITrendingDocument[];
loading: boolean;
error: string;
}
export default class TrendingInTheSitesIFollow extends React.Component<ITrendingInTheSitesIFollowProps, ITrendingInTheSitesIFollowState> {
constructor(props: ITrendingInTheSitesIFollowProps, state: ITrendingInTheSitesIFollowState);
componentDidMount(): void;
componentDidUpdate(prevProps: ITrendingInTheSitesIFollowProps, prevState: ITrendingInTheSitesIFollowState, prevContext: any): void;
render(): JSX.Element;
private loadDocuments(siteUrl, numberOfDocuments);
private getSitesIFollow(siteUrl);
private getTrendingDocuments(sitesIFollow, siteUrl, numberOfDocuments);
}

View File

@ -0,0 +1,214 @@
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var React = require("react");
var office_ui_fabric_react_1 = require("office-ui-fabric-react");
var TrendingInTheSitesIFollow_module_scss_1 = require("../TrendingInTheSitesIFollow.module.scss");
var sp_http_1 = require("@microsoft/sp-http");
var SearchUtils_1 = require("../../SearchUtils");
var Utils_1 = require("../../Utils");
var TrendingInTheSitesIFollow = (function (_super) {
__extends(TrendingInTheSitesIFollow, _super);
function TrendingInTheSitesIFollow(props, state) {
var _this = _super.call(this, props) || this;
_this.state = {
trendingDocuments: [],
loading: true,
error: null
};
return _this;
}
TrendingInTheSitesIFollow.prototype.componentDidMount = function () {
this.loadDocuments(this.props.siteUrl, this.props.numberOfDocuments);
};
TrendingInTheSitesIFollow.prototype.componentDidUpdate = function (prevProps, prevState, prevContext) {
if (this.props.numberOfDocuments !== prevProps.numberOfDocuments ||
this.props.siteUrl !== prevProps.siteUrl && (this.props.numberOfDocuments && this.props.siteUrl)) {
this.loadDocuments(this.props.siteUrl, this.props.numberOfDocuments);
}
};
TrendingInTheSitesIFollow.prototype.render = function () {
var loading = this.state.loading ? React.createElement("div", { style: { margin: '0 auto' } },
React.createElement(office_ui_fabric_react_1.Spinner, { label: 'Loading...' })) : React.createElement("div", null);
var error = this.state.error ? React.createElement("div", null,
React.createElement("strong", null, "Error: "),
" ",
this.state.error) : React.createElement("div", null);
var documents = this.state.trendingDocuments.map(function (doc, i) {
var iconUrl = "https://spoprod-a.akamaihd.net/files/odsp-next-prod_ship-2016-08-15_20160815.002/odsp-media/images/filetypes/32/" + doc.extension + ".png";
return (React.createElement(office_ui_fabric_react_1.DocumentCard, { onClickHref: doc.url, key: doc.id },
React.createElement(office_ui_fabric_react_1.DocumentCardPreview, { previewImages: [
{
previewImageSrc: doc.previewImageUrl,
iconSrc: iconUrl,
width: 318,
height: 196,
accentColor: '#ce4b1f'
}
] }),
React.createElement(office_ui_fabric_react_1.DocumentCardTitle, { title: doc.title }),
React.createElement(office_ui_fabric_react_1.DocumentCardLocation, { location: doc.webTitle, locationHref: doc.webUrl }),
React.createElement(office_ui_fabric_react_1.DocumentCardActivity, { activity: doc.activity.name + " " + doc.activity.date, people: [
{ name: doc.activity.actorName, profileImageSrc: doc.activity.actorPhotoUrl }
] })));
});
return (React.createElement("div", { className: TrendingInTheSitesIFollow_module_scss_1.default.trendingInTheSitesIFollow },
React.createElement("div", { className: office_ui_fabric_react_1.css('ms-font-xl', TrendingInTheSitesIFollow_module_scss_1.default.webPartTitle) }, this.props.title),
loading,
error,
documents,
React.createElement("div", { style: { clear: 'both' } })));
};
TrendingInTheSitesIFollow.prototype.loadDocuments = function (siteUrl, numberOfDocuments) {
var _this = this;
this.setState({
loading: true,
error: undefined,
trendingDocuments: []
});
var trendingDocuments = [];
this.getSitesIFollow(siteUrl)
.then(function (sitesIFollow) {
return _this.getTrendingDocuments(sitesIFollow, siteUrl, numberOfDocuments);
})
.then(function (trendingDocuments) {
_this.setState({
loading: false,
error: undefined,
trendingDocuments: trendingDocuments
});
}, function (error) {
_this.setState({
loading: false,
error: error,
trendingDocuments: []
});
});
return;
};
TrendingInTheSitesIFollow.prototype.getSitesIFollow = function (siteUrl) {
var _this = this;
return new Promise(function (resolve, reject) {
_this.props.httpClient.get(siteUrl + "/_api/social.following/my/followed(types=4)", sp_http_1.SPHttpClient.configurations.v1, {
headers: {
'Accept': 'application/json;odata=nometadata',
'odata-version': ''
}
})
.then(function (response) {
return response.json();
})
.then(function (sitesIFollowInfo) {
var sitesIFollow = [];
for (var i = 0; i < sitesIFollowInfo.value.length; i++) {
sitesIFollow.push(sitesIFollowInfo.value[i].Uri);
}
resolve(sitesIFollow);
}, function (error) {
reject(error);
});
});
};
TrendingInTheSitesIFollow.prototype.getTrendingDocuments = function (sitesIFollow, siteUrl, numberOfDocuments) {
var _this = this;
return new Promise(function (resolve, reject) {
if (sitesIFollow.length === 0) {
return resolve([]);
}
var query = '(';
for (var i = 0; i < sitesIFollow.length; i++) {
if (query.length > 1) {
query += ' OR ';
}
query += "Path:\"" + sitesIFollow[i] + "\"";
}
query += ') AND (IsDocument:1)';
var postData = JSON.stringify({
'request': {
'__metadata': {
'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
},
'Querytext': query,
'SelectProperties': {
'results': ['Author', 'AuthorOwsUser', 'DocId', 'DocumentPreviewMetadata', 'Edges', 'EditorOwsUser', 'FileExtension', 'FileType', 'HitHighlightedProperties', 'HitHighlightedSummary', 'LastModifiedTime', 'LikeCountLifetime', 'ListID', 'ListItemID', 'OriginalPath', 'Path', 'Rank', 'SPWebUrl', 'SecondaryFileExtension', 'ServerRedirectedURL', 'SiteTitle', 'Title', 'ViewCountLifetime', 'siteID', 'uniqueID', 'webID']
},
'ClientType': 'TrendingInTheSitesIFollow',
'BypassResultTypes': 'true',
'RowLimit': numberOfDocuments,
'StartRow': '0',
'RankingModelId': '0c77ded8-c3ef-466d-929d-905670ea1d72',
'Properties': {
'results': [{
'Name': 'IncludeExternalContent',
'Value': {
'BoolVal': 'True',
'QueryPropertyValueTypeIndex': 3
}
}, {
'Name': 'GraphQuery',
'Value': {
'StrVal': 'actor(ME,action:1021)',
'QueryPropertyValueTypeIndex': 1
}
}]
}
}
});
_this.props.httpClient.post(siteUrl + "/_api/search/postquery", sp_http_1.SPHttpClient.configurations.v1, {
headers: {
'Accept': 'application/json;odata=nometadata',
'Content-type': 'application/json;odata=verbose',
'odata-version': ''
},
body: postData
})
.then(function (response) {
return response.json();
})
.then(function (response) {
if (!response ||
!response.PrimaryQueryResult ||
!response.PrimaryQueryResult.RelevantResults ||
response.PrimaryQueryResult.RelevantResults.RowCount === 0) {
resolve([]);
return;
}
var trendingDocuments = [];
for (var i = 0; i < response.PrimaryQueryResult.RelevantResults.Table.Rows.length; i++) {
var row = response.PrimaryQueryResult.RelevantResults.Table.Rows[i];
var cells = row.Cells;
var editorInfo = SearchUtils_1.SearchUtils.getValueFromResults('EditorOwsUser', cells).split('|');
var modifiedDate = new Date(SearchUtils_1.SearchUtils.getValueFromResults('LastModifiedTime', cells).replace('.0000000', ''));
var dateString = (modifiedDate.getMonth() + 1) + '/' + modifiedDate.getDate() + '/' + modifiedDate.getFullYear();
trendingDocuments.push({
id: SearchUtils_1.SearchUtils.getValueFromResults('DocId', cells),
url: SearchUtils_1.SearchUtils.getValueFromResults('ServerRedirectedURL', cells),
webUrl: SearchUtils_1.SearchUtils.getValueFromResults('SPWebUrl', cells),
webTitle: SearchUtils_1.SearchUtils.getValueFromResults('SiteTitle', cells),
title: SearchUtils_1.SearchUtils.getValueFromResults('Title', cells),
previewImageUrl: SearchUtils_1.SearchUtils.getPreviewImageUrl(cells, siteUrl),
extension: SearchUtils_1.SearchUtils.getValueFromResults('FileType', cells),
activity: {
actorId: -1,
actorName: Utils_1.Utils.trim(editorInfo[1]),
actorPhotoUrl: Utils_1.Utils.getUserPhotoUrl(Utils_1.Utils.trim(editorInfo[0]), siteUrl),
date: dateString,
name: 'Modified'
}
});
}
resolve(trendingDocuments);
}, function (error) {
reject(error);
});
});
};
return TrendingInTheSitesIFollow;
}(React.Component));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = TrendingInTheSitesIFollow;
//# sourceMappingURL=TrendingInTheSitesIFollow.js.map

View File

@ -0,0 +1,8 @@
define([], function() {
return {
"PropertyPaneDescription": "Manage the settings of this Web Part",
"ViewGroupName": "View",
"NumberOfDocumentsFieldLabel": "Number of documents to show",
"TitleFieldLabel": "Web Part Title (displayed in the body)"
}
});

View File

@ -0,0 +1,10 @@
/// <reference types="mocha" />
"use strict";
var chai_1 = require("chai");
describe('TrendingInTheSitesIFollowWebPart', function () {
it('should do something', function () {
chai_1.assert.ok(true);
});
});
//# sourceMappingURL=TrendingInTheSitesIFollow.test.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/trendingInTheSitesIFollow/tests/TrendingInTheSitesIFollow.test.ts"],"names":[],"mappings":"AAAA,+BAA+B;;AAE/B,6BAA8B;AAE9B,QAAQ,CAAC,kCAAkC,EAAE;IAC3C,EAAE,CAAC,qBAAqB,EAAE;QACxB,aAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","file":"webparts/trendingInTheSitesIFollow/tests/TrendingInTheSitesIFollow.test.js","sourcesContent":["/// <reference types=\"mocha\" />\r\n\r\nimport { assert } from 'chai';\r\n\r\ndescribe('TrendingInTheSitesIFollowWebPart', () => {\r\n it('should do something', () => {\r\n assert.ok(true);\r\n });\r\n});\r\n"],"sourceRoot":"..\\..\\..\\..\\src"}

View File

@ -0,0 +1,3 @@
export interface ITrendingInThisSiteWebPartProps {
numberOfDocuments: number;
}

View File

@ -0,0 +1,3 @@
"use strict";
//# sourceMappingURL=ITrendingInThisSiteWebPartProps.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"webparts/trendingInThisSite/ITrendingInThisSiteWebPartProps.js","sourcesContent":[],"sourceRoot":"..\\..\\..\\src"}

View File

@ -0,0 +1 @@
.trendingInThisSite_2a33a9c5 .container_2a33a9c5{max-width:700px;margin:0 auto;box-shadow:0 2px 4px 0 rgba(0,0,0,.2),0 25px 50px 0 rgba(0,0,0,.1)}.trendingInThisSite_2a33a9c5 .row_2a33a9c5{padding:20px}.trendingInThisSite_2a33a9c5 .listItem_2a33a9c5{max-width:715px;margin:5px auto 5px auto;box-shadow:0 0 4px 0 rgba(0,0,0,.2),0 25px 50px 0 rgba(0,0,0,.1)}.trendingInThisSite_2a33a9c5 .button_2a33a9c5{text-decoration:none}.trendingInThisSite_2a33a9c5 [class*='ms-DocumentCard ']{float:left;margin:.5em}.trendingInThisSite_2a33a9c5 [class=ms-Spinner]{width:7em;margin:0 auto}

View File

@ -0,0 +1,8 @@
declare const styles: {
trendingInThisSite: string;
container: string;
row: string;
listItem: string;
button: string;
};
export default styles;

View File

@ -0,0 +1,15 @@
"use strict";
/* tslint:disable */
require('./TrendingInThisSite.module.css');
var styles = {
trendingInThisSite: 'trendingInThisSite_2a33a9c5',
container: 'container_2a33a9c5',
row: 'row_2a33a9c5',
listItem: 'listItem_2a33a9c5',
button: 'button_2a33a9c5',
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = styles;
/* tslint:enable */
//# sourceMappingURL=TrendingInThisSite.module.scss.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/trendingInThisSite/TrendingInThisSite.module.scss.ts"],"names":[],"mappings":";AAAA,oBAAoB;AACpB,OAAO,CAAC,iCAAiC,CAAC,CAAC;AAC3C,IAAM,MAAM,GAAG;IACb,kBAAkB,EAAE,6BAA6B;IACjD,SAAS,EAAE,oBAAoB;IAC/B,GAAG,EAAE,cAAc;IACnB,QAAQ,EAAE,mBAAmB;IAC7B,MAAM,EAAE,iBAAiB;CAC1B,CAAC;;AAEF,kBAAe,MAAM,CAAC;AACtB,mBAAmB","file":"webparts/trendingInThisSite/TrendingInThisSite.module.scss.js","sourcesContent":["/* tslint:disable */\r\nrequire('./TrendingInThisSite.module.css');\r\nconst styles = {\r\n trendingInThisSite: 'trendingInThisSite_2a33a9c5',\r\n container: 'container_2a33a9c5',\r\n row: 'row_2a33a9c5',\r\n listItem: 'listItem_2a33a9c5',\r\n button: 'button_2a33a9c5',\r\n};\r\n\r\nexport default styles;\r\n/* tslint:enable */"],"sourceRoot":"..\\..\\..\\src"}

View File

@ -0,0 +1,9 @@
import { Version } from '@microsoft/sp-core-library';
import { BaseClientSideWebPart, IPropertyPaneConfiguration, IWebPartContext } from '@microsoft/sp-webpart-base';
import { ITrendingInThisSiteWebPartProps } from './ITrendingInThisSiteWebPartProps';
export default class TrendingInThisSiteWebPart extends BaseClientSideWebPart<ITrendingInThisSiteWebPartProps> {
constructor(context: IWebPartContext);
render(): void;
protected readonly dataVersion: Version;
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration;
}

View File

@ -0,0 +1,61 @@
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var React = require("react");
var ReactDom = require("react-dom");
var sp_core_library_1 = require("@microsoft/sp-core-library");
var sp_webpart_base_1 = require("@microsoft/sp-webpart-base");
var strings = require("trendingInThisSiteStrings");
var TrendingInThisSite_1 = require("./components/TrendingInThisSite");
var TrendingInThisSiteWebPart = (function (_super) {
__extends(TrendingInThisSiteWebPart, _super);
function TrendingInThisSiteWebPart(context) {
return _super.call(this) || this;
}
TrendingInThisSiteWebPart.prototype.render = function () {
var element = React.createElement(TrendingInThisSite_1.default, {
numberOfDocuments: this.properties.numberOfDocuments,
siteUrl: this.context.pageContext.web.absoluteUrl
});
ReactDom.render(element, this.domElement);
};
Object.defineProperty(TrendingInThisSiteWebPart.prototype, "dataVersion", {
get: function () {
return sp_core_library_1.Version.parse('1.0');
},
enumerable: true,
configurable: true
});
TrendingInThisSiteWebPart.prototype.getPropertyPaneConfiguration = function () {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.ViewGroupName,
groupFields: [
sp_webpart_base_1.PropertyPaneSlider('numberOfDocuments', {
label: strings.NumberOfDocumentsFieldLabel,
min: 1,
max: 10,
step: 1
})
]
}
]
}
]
};
};
return TrendingInThisSiteWebPart;
}(sp_webpart_base_1.BaseClientSideWebPart));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = TrendingInThisSiteWebPart;
//# sourceMappingURL=TrendingInThisSiteWebPart.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/trendingInThisSite/TrendingInThisSiteWebPart.ts"],"names":[],"mappings":";;;;;;AAAA,6BAA+B;AAC/B,oCAAsC;AACtC,8DAAqD;AACrD,8DAMoC;AAIpC,mDAAqD;AAErD,sEAA+F;AAE/F;IAAuD,6CAAsD;IAE3G,mCAAmB,OAAwB;eACzC,iBAAO;IACT,CAAC;IAEM,0CAAM,GAAb;QACE,IAAM,OAAO,GAAiD,KAAK,CAAC,aAAa,CAAC,4BAAkB,EAAE;YACpG,iBAAiB,EAAE,IAAI,CAAC,UAAU,CAAC,iBAAiB;YACpD,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW;SAClD,CAAC,CAAC;QAEH,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,sBAAc,kDAAW;aAAzB;YACE,MAAM,CAAC,yBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;;;OAAA;IAES,gEAA4B,GAAtC;QACE,MAAM,CAAC;YACL,KAAK,EAAE;gBACL;oBACE,MAAM,EAAE;wBACN,WAAW,EAAE,OAAO,CAAC,uBAAuB;qBAC7C;oBACD,MAAM,EAAE;wBACN;4BACE,SAAS,EAAE,OAAO,CAAC,aAAa;4BAChC,WAAW,EAAE;gCACX,oCAAkB,CAAC,mBAAmB,EAAE;oCACtC,KAAK,EAAE,OAAO,CAAC,2BAA2B;oCAC1C,GAAG,EAAE,CAAC;oCACN,GAAG,EAAE,EAAE;oCACP,IAAI,EAAE,CAAC;iCACR,CAAC;6BACH;yBACF;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IACH,gCAAC;AAAD,CA3CA,AA2CC,CA3CsD,uCAAqB,GA2C3E","file":"webparts/trendingInThisSite/TrendingInThisSiteWebPart.js","sourcesContent":["import * as React from 'react';\r\nimport * as ReactDom from 'react-dom';\r\nimport { Version } from '@microsoft/sp-core-library';\r\nimport {\r\n BaseClientSideWebPart,\r\n IPropertyPaneConfiguration,\r\n PropertyPaneTextField,\r\n IWebPartContext,\r\n PropertyPaneSlider\r\n} from '@microsoft/sp-webpart-base';\r\nimport { escape } from '@microsoft/sp-lodash-subset';\r\n\r\nimport styles from './TrendingInThisSite.module.scss';\r\nimport * as strings from 'trendingInThisSiteStrings';\r\nimport { ITrendingInThisSiteWebPartProps } from './ITrendingInThisSiteWebPartProps';\r\nimport TrendingInThisSite, { ITrendingInThisSiteProps } from './components/TrendingInThisSite';\r\n\r\nexport default class TrendingInThisSiteWebPart extends BaseClientSideWebPart<ITrendingInThisSiteWebPartProps> {\r\n\r\n public constructor(context: IWebPartContext) {\r\n super();\r\n }\r\n\r\n public render(): void {\r\n const element: React.ReactElement<ITrendingInThisSiteProps> = React.createElement(TrendingInThisSite, {\r\n numberOfDocuments: this.properties.numberOfDocuments,\r\n siteUrl: this.context.pageContext.web.absoluteUrl\r\n });\r\n\r\n ReactDom.render(element, this.domElement);\r\n }\r\n\r\n protected get dataVersion(): Version {\r\n return Version.parse('1.0');\r\n }\r\n\r\n protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {\r\n return {\r\n pages: [\r\n {\r\n header: {\r\n description: strings.PropertyPaneDescription\r\n },\r\n groups: [\r\n {\r\n groupName: strings.ViewGroupName,\r\n groupFields: [\r\n PropertyPaneSlider('numberOfDocuments', {\r\n label: strings.NumberOfDocumentsFieldLabel,\r\n min: 1,\r\n max: 10,\r\n step: 1\r\n })\r\n ]\r\n }\r\n ]\r\n }\r\n ]\r\n };\r\n }\r\n}\r\n"],"sourceRoot":"..\\..\\..\\src"}

View File

@ -0,0 +1,20 @@
{
"$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json",
"id": "65f773e5-a708-4b28-ac1f-0fb74e9f85da",
"alias": "TrendingInThisSiteWebPart",
"componentType": "WebPart",
"version": "0.0.1",
"manifestVersion": 2,
"preconfiguredEntries": [{
"groupId": "65f773e5-a708-4b28-ac1f-0fb74e9f85da",
"group": { "default": "Content rollup" },
"title": { "default": "Trending in this site" },
"description": { "default": "Shows documents trending in this site" },
"officeFabricIconFontName": "Page",
"properties": {
"numberOfDocuments": 5
}
}]
}

View File

@ -0,0 +1,37 @@
import * as React from 'react';
import { ITrendingInThisSiteWebPartProps } from '../ITrendingInThisSiteWebPartProps';
export interface ITrendingInThisSiteProps extends ITrendingInThisSiteWebPartProps {
siteUrl: string;
}
export interface ITrendingInThisSiteState {
trendingDocuments: ITrendingDocument[];
loading: boolean;
error: string;
}
export interface ITrendingDocument {
id: string;
title: string;
url: string;
previewImageUrl: string;
lastModifiedByPhotoUrl: string;
lastModifiedByName: string;
lastModifiedTime: string;
extension: string;
}
export default class TrendingInThisSite extends React.Component<ITrendingInThisSiteProps, ITrendingInThisSiteState> {
constructor(props: ITrendingInThisSiteProps, state: ITrendingInThisSiteState);
componentDidMount(): void;
componentDidUpdate(prevProps: ITrendingInThisSiteProps, prevState: ITrendingInThisSiteState, prevContext: any): void;
render(): JSX.Element;
private getValueFromResults(key, results);
private trim(s);
private getPreviewImageUrl(result, siteUrl);
private getUserPhotoUrl(userEmail, siteUrl);
private request<T>(url, method?, headers?, data?);
private getSiteMembers(siteUrl);
private getActors(siteMembers, requestDigest, siteUrl);
private getTrendingContent(siteUrl, actors, requestDigest);
private loadTrendingContent(siteUrl, numberOfDocuments);
private handleError(err);
private getRequestDigest(siteUrl);
}

View File

@ -0,0 +1,360 @@
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var React = require("react");
var office_ui_fabric_react_1 = require("office-ui-fabric-react");
var TrendingInThisSite_module_scss_1 = require("../TrendingInThisSite.module.scss");
var TrendingInThisSite = (function (_super) {
__extends(TrendingInThisSite, _super);
function TrendingInThisSite(props, state) {
var _this = _super.call(this, props) || this;
_this.state = {
trendingDocuments: [],
loading: true,
error: null
};
return _this;
}
TrendingInThisSite.prototype.componentDidMount = function () {
this.loadTrendingContent(this.props.siteUrl, this.props.numberOfDocuments);
};
TrendingInThisSite.prototype.componentDidUpdate = function (prevProps, prevState, prevContext) {
if (this.props.numberOfDocuments !== prevProps.numberOfDocuments ||
this.props.siteUrl !== prevProps.siteUrl && (this.props.numberOfDocuments && this.props.siteUrl)) {
this.loadTrendingContent(this.props.siteUrl, this.props.numberOfDocuments);
}
};
TrendingInThisSite.prototype.render = function () {
var loading = this.state.loading ? React.createElement("div", { style: { margin: '0 auto' } },
React.createElement(office_ui_fabric_react_1.Spinner, { label: 'Loading...' })) : React.createElement("div", null);
var error = this.state.error ? React.createElement("div", null,
React.createElement("strong", null, "Error:"),
" ",
this.state.error) : React.createElement("div", null);
var documents = this.state.trendingDocuments.map(function (doc, i) {
var iconUrl = "https://spoprod-a.akamaihd.net/files/odsp-next-prod_ship-2016-08-15_20160815.002/odsp-media/images/filetypes/32/" + doc.extension + ".png";
return (React.createElement(office_ui_fabric_react_1.DocumentCard, { onClickHref: doc.url, key: doc.id },
React.createElement(office_ui_fabric_react_1.DocumentCardPreview, { previewImages: [
{
previewImageSrc: doc.previewImageUrl,
iconSrc: iconUrl,
width: 318,
height: 196,
accentColor: '#ce4b1f'
}
] }),
React.createElement(office_ui_fabric_react_1.DocumentCardTitle, { title: doc.title }),
React.createElement(office_ui_fabric_react_1.DocumentCardActivity, { activity: 'Modified ' + doc.lastModifiedTime, people: [
{ name: doc.lastModifiedByName, profileImageSrc: doc.lastModifiedByPhotoUrl }
] })));
});
return (React.createElement("div", { className: TrendingInThisSite_module_scss_1.default.trendingInThisSite },
loading,
error,
documents,
React.createElement("div", { style: { clear: 'both' } })));
};
TrendingInThisSite.prototype.getValueFromResults = function (key, results) {
var value = '';
if (results != null && results.length > 0 && key != null) {
for (var i = 0; i < results.length; i++) {
var resultItem = results[i];
if (resultItem.Key === key) {
value = resultItem.Value;
break;
}
}
}
return value;
};
TrendingInThisSite.prototype.trim = function (s) {
if (s != null && s.length > 0) {
return s.replace(/^\s+|\s+$/gm, '');
}
else {
return s;
}
};
TrendingInThisSite.prototype.getPreviewImageUrl = function (result, siteUrl) {
var uniqueID = this.getValueFromResults('uniqueID', result);
var siteId = this.getValueFromResults('siteID', result);
var webId = this.getValueFromResults('webID', result);
var docId = this.getValueFromResults('DocId', result);
if (uniqueID !== null && siteId !== null && webId !== null && docId !== null) {
return siteUrl + "/_layouts/15/getpreview.ashx?guidFile=" + uniqueID + "&guidSite=" + siteId + "&guidWeb=" + webId + "&docid=" + docId + "\n &metadatatoken=300x424x2&ClientType=CodenameOsloWeb&size=small";
}
else {
return '';
}
};
TrendingInThisSite.prototype.getUserPhotoUrl = function (userEmail, siteUrl) {
return siteUrl + "/_layouts/15/userphoto.aspx?size=S&accountname=" + userEmail;
};
TrendingInThisSite.prototype.request = function (url, method, headers, data) {
if (method === void 0) { method = 'GET'; }
if (headers === void 0) { headers = null; }
if (data === void 0) { data = null; }
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (this.readyState === 4) {
if (this.status === 200) {
resolve(this.response);
}
else if (this.status >= 400) {
reject({
message: this.response['odata.error'].message.value,
statusText: this.statusText,
status: this.status
});
}
}
};
xhr.open(method, url, true);
if (headers === null) {
xhr.setRequestHeader('Accept', 'application/json;odata=nometadata');
}
else {
for (var header in headers) {
if (headers.hasOwnProperty(header)) {
xhr.setRequestHeader(header, headers[header]);
}
}
}
xhr.responseType = 'json';
xhr.send(data);
});
};
TrendingInThisSite.prototype.getSiteMembers = function (siteUrl) {
var component = this;
return new Promise(function (resolve, reject) {
component.request(siteUrl + "/_api/Web/AssociatedMemberGroup/Users?$select=Email").then(function (members) {
var siteMembers = [];
for (var i = 0; i < members.value.length; i++) {
siteMembers.push(members.value[i].Email);
}
resolve(siteMembers);
}, function (error) {
reject(error);
});
});
};
TrendingInThisSite.prototype.getActors = function (siteMembers, requestDigest, siteUrl) {
var component = this;
var query = '';
siteMembers.forEach(function (member) {
if (query.length > 0) {
query += ' OR ';
}
query += "UserName:" + member;
});
var postData = JSON.stringify({
'request': {
'__metadata': {
'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
},
'Querytext': query,
'SelectProperties': {
'results': ['DocId', 'WorkEmail']
},
'RowLimit': '100',
'StartRow': '0',
'SourceId': 'b09a7990-05ea-4af9-81ef-edfab16c4e31'
}
});
return new Promise(function (resolve, reject) {
component.request(siteUrl + "/_api/search/postquery", 'POST', {
'Accept': 'application/json;odata=nometadata',
'Content-Type': 'application/json;odata=verbose',
'X-RequestDigest': requestDigest
}, postData).then(function (data) {
if (data && data.PrimaryQueryResult && data.PrimaryQueryResult.RelevantResults) {
var actors_1 = [];
data.PrimaryQueryResult.RelevantResults.Table.Rows.forEach(function (row) {
var actorId = component.getValueFromResults('DocId', row.Cells);
if (actorId != null && actorId.length > 0) {
actors_1.push(actorId);
}
});
resolve(actors_1);
}
else {
reject();
}
}, function (error) {
reject(error);
});
});
};
TrendingInThisSite.prototype.getTrendingContent = function (siteUrl, actors, requestDigest) {
var component = this;
var gq = '';
if (actors.length > 1) {
actors.forEach(function (actor) {
if (gq.length > 0) {
gq += ',';
}
gq += "actor(" + actor + ",action:1020)";
});
gq += ',and(actor(me,action:1021),actor(me,or(action:1021,action:1036,action:1037,action:1039)))';
gq = "or(" + gq + ")";
}
else {
gq = "or(actor(" + actors[0] + ",action:1020),and(actor(me,action:1021),actor(me,or(action:1021,action:1036,action:1037,action:1039))))";
}
siteUrl = siteUrl.replace(':443/', '/');
var postData = JSON.stringify({
'request': {
'__metadata': {
'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
},
'Querytext': 'path:' + siteUrl,
'SelectProperties': {
'results': ['Author', 'AuthorOwsUser', 'DocId', 'DocumentPreviewMetadata', 'Edges', 'EditorOwsUser', 'FileExtension', 'FileType', 'HitHighlightedProperties', 'HitHighlightedSummary', 'LastModifiedTime', 'LikeCountLifetime', 'ListID', 'ListItemID', 'OriginalPath', 'Path', 'Rank', 'SPWebUrl', 'SecondaryFileExtension', 'ServerRedirectedURL', 'SiteTitle', 'Title', 'ViewCountLifetime', 'siteID', 'uniqueID', 'webID']
},
'ClientType': 'TrendingInThisSite',
'BypassResultTypes': 'true',
'RowLimit': component.props.numberOfDocuments.toString(),
'StartRow': '0',
'RankingModelId': '0c77ded8-c3ef-466d-929d-905670ea1d72',
'Properties': {
'results': [{
'Name': 'IncludeExternalContent',
'Value': {
'BoolVal': 'True',
'QueryPropertyValueTypeIndex': 3
}
}, {
'Name': 'GraphQuery',
'Value': {
'StrVal': gq,
'QueryPropertyValueTypeIndex': 1
}
}, {
'Name': 'GraphRankingModel',
'Value': {
'StrVal': '{"features":[{"function":"EdgeWeight"}],"featureCombination":"sum","actorCombination":"sum"}',
'QueryPropertyValueTypeIndex': 1
}
}]
}
}
});
return new Promise(function (resolve, reject) {
component.request(siteUrl + "/_api/search/postquery", 'POST', {
'Accept': 'application/json;odata=nometadata',
'Content-Type': 'application/json;odata=verbose',
'X-RequestDigest': requestDigest
}, postData).then(function (data) {
var trendingContent = [];
if (data.PrimaryQueryResult && data.PrimaryQueryResult.RelevantResults &&
data.PrimaryQueryResult.RelevantResults.Table.Rows.length > 0) {
data.PrimaryQueryResult.RelevantResults.Table.Rows.forEach(function (row) {
var cells = row.Cells;
var editorInfo = component.getValueFromResults('EditorOwsUser', cells).split('|');
var modifiedDate = new Date(component.getValueFromResults('LastModifiedTime', cells).replace('.0000000', ''));
var dateString = (modifiedDate.getMonth() + 1) + '/' + modifiedDate.getDate() + '/' + modifiedDate.getFullYear();
trendingContent.push({
id: component.getValueFromResults('DocId', cells),
url: component.getValueFromResults('ServerRedirectedURL', cells),
title: component.getValueFromResults('Title', cells),
previewImageUrl: component.getPreviewImageUrl(cells, siteUrl),
lastModifiedTime: dateString,
lastModifiedByName: component.trim(editorInfo[1]),
lastModifiedByPhotoUrl: component.getUserPhotoUrl(component.trim(editorInfo[0]), siteUrl),
extension: component.getValueFromResults('FileType', cells)
});
});
}
resolve(trendingContent);
}, function (error) {
reject(error);
});
});
};
TrendingInThisSite.prototype.loadTrendingContent = function (siteUrl, numberOfDocuments) {
var component = this;
var requestDigest = null;
component.getRequestDigest(siteUrl)
.then(function (digest) {
requestDigest = digest;
}, function (err) {
component.handleError(err);
})
.then(function () {
return component.getSiteMembers(siteUrl);
}, function (err) {
component.handleError(err);
})
.then(function (siteMembers) {
return component.getActors(siteMembers, requestDigest, siteUrl);
}, function (err) {
component.handleError(err);
})
.then(function (actors) {
return component.getTrendingContent(siteUrl, actors, requestDigest);
}, function (err) {
component.handleError(err);
})
.then(function (trendingDocuments) {
component.setState(function (previousState, curProps) {
previousState.trendingDocuments.length = 0;
return previousState;
});
trendingDocuments.forEach(function (result) {
component.setState(function (previousState, curProps) {
previousState.trendingDocuments.push(result);
return previousState;
});
});
component.setState(function (previousState, curProps) {
previousState.loading = false;
return previousState;
});
}, function (err) {
component.handleError(err);
});
};
TrendingInThisSite.prototype.handleError = function (err) {
if (err.responseJSON && err.responseJSON.error) {
this.setState(function (previousState, curProps) {
previousState.error = "The following error has occured while running the query: " + err.responseJSON.error.message.value;
return previousState;
});
}
else if (err.responseJSON && err.responseJSON["odata.error"]) {
this.setState(function (previousState, curProps) {
previousState.error = "The following error has occured while running the query: " + err.responseJSON["odata.error"].message.value;
return previousState;
});
}
else {
this.setState(function (previousState, curProps) {
previousState.error = "An unexpected error occured while running the query";
return previousState;
});
}
this.setState(function (previousState, curProps) {
previousState.loading = false;
return previousState;
});
};
TrendingInThisSite.prototype.getRequestDigest = function (siteUrl) {
var component = this;
return new Promise(function (resolve, reject) {
component.request(siteUrl + "/_api/contextinfo", 'POST').then(function (data) {
resolve(data.FormDigestValue);
}, function (error) {
reject(error);
});
});
};
return TrendingInThisSite;
}(React.Component));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = TrendingInThisSite;
//# sourceMappingURL=TrendingInThisSite.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
define([], function() {
return {
"PropertyPaneDescription": "Manage the settings of this Web Part",
"ViewGroupName": "View",
"NumberOfDocumentsFieldLabel": "Number of documents to show"
}
});

View File

@ -0,0 +1,10 @@
/// <reference types="mocha" />
"use strict";
var chai_1 = require("chai");
describe('TrendingInThisSiteWebPart', function () {
it('should do something', function () {
chai_1.assert.ok(true);
});
});
//# sourceMappingURL=TrendingInThisSite.test.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/trendingInThisSite/tests/TrendingInThisSite.test.ts"],"names":[],"mappings":"AAAA,+BAA+B;;AAE/B,6BAA8B;AAE9B,QAAQ,CAAC,2BAA2B,EAAE;IACpC,EAAE,CAAC,qBAAqB,EAAE;QACxB,aAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","file":"webparts/trendingInThisSite/tests/TrendingInThisSite.test.js","sourcesContent":["/// <reference types=\"mocha\" />\r\n\r\nimport { assert } from 'chai';\r\n\r\ndescribe('TrendingInThisSiteWebPart', () => {\r\n it('should do something', () => {\r\n assert.ok(true);\r\n });\r\n});\r\n"],"sourceRoot":"..\\..\\..\\..\\src"}

View File

@ -0,0 +1,4 @@
export interface IWorkingWithWebPartProps {
numberOfPeople: number;
title: string;
}

View File

@ -0,0 +1,3 @@
"use strict";
//# sourceMappingURL=IWorkingWithWebPartProps.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"webparts/workingWith/IWorkingWithWebPartProps.js","sourcesContent":[],"sourceRoot":"..\\..\\..\\src"}

View File

@ -0,0 +1 @@
.workingWith_cca48a75 .webPartTitle_cca48a75{margin-bottom:1em}.workingWith_cca48a75 .ms-Spinner{width:7em;margin:0 auto}.workingWith_cca48a75 .ms-Persona{cursor:pointer}

View File

@ -0,0 +1,5 @@
declare const styles: {
workingWith: string;
webPartTitle: string;
};
export default styles;

View File

@ -0,0 +1,12 @@
"use strict";
/* tslint:disable */
require('./WorkingWith.module.css');
var styles = {
workingWith: 'workingWith_cca48a75',
webPartTitle: 'webPartTitle_cca48a75',
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = styles;
/* tslint:enable */
//# sourceMappingURL=WorkingWith.module.scss.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/workingWith/WorkingWith.module.scss.ts"],"names":[],"mappings":";AAAA,oBAAoB;AACpB,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACpC,IAAM,MAAM,GAAG;IACb,WAAW,EAAE,sBAAsB;IACnC,YAAY,EAAE,uBAAuB;CACtC,CAAC;;AAEF,kBAAe,MAAM,CAAC;AACtB,mBAAmB","file":"webparts/workingWith/WorkingWith.module.scss.js","sourcesContent":["/* tslint:disable */\r\nrequire('./WorkingWith.module.css');\r\nconst styles = {\r\n workingWith: 'workingWith_cca48a75',\r\n webPartTitle: 'webPartTitle_cca48a75',\r\n};\r\n\r\nexport default styles;\r\n/* tslint:enable */"],"sourceRoot":"..\\..\\..\\src"}

View File

@ -0,0 +1,9 @@
import { Version } from '@microsoft/sp-core-library';
import { BaseClientSideWebPart, IPropertyPaneConfiguration, IWebPartContext } from '@microsoft/sp-webpart-base';
import { IWorkingWithWebPartProps } from './IWorkingWithWebPartProps';
export default class WorkingWithWebPart extends BaseClientSideWebPart<IWorkingWithWebPartProps> {
constructor(context: IWebPartContext);
render(): void;
protected readonly dataVersion: Version;
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration;
}

View File

@ -0,0 +1,66 @@
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var React = require("react");
var ReactDom = require("react-dom");
var sp_core_library_1 = require("@microsoft/sp-core-library");
var sp_webpart_base_1 = require("@microsoft/sp-webpart-base");
var strings = require("workingWithStrings");
var WorkingWith_1 = require("./components/WorkingWith");
var WorkingWithWebPart = (function (_super) {
__extends(WorkingWithWebPart, _super);
function WorkingWithWebPart(context) {
return _super.call(this) || this;
}
WorkingWithWebPart.prototype.render = function () {
var element = React.createElement(WorkingWith_1.default, {
numberOfPeople: this.properties.numberOfPeople,
title: this.properties.title,
httpClient: this.context.spHttpClient,
siteUrl: this.context.pageContext.web.absoluteUrl
});
ReactDom.render(element, this.domElement);
};
Object.defineProperty(WorkingWithWebPart.prototype, "dataVersion", {
get: function () {
return sp_core_library_1.Version.parse('1.0');
},
enumerable: true,
configurable: true
});
WorkingWithWebPart.prototype.getPropertyPaneConfiguration = function () {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.ViewGroupName,
groupFields: [
sp_webpart_base_1.PropertyPaneTextField('title', {
label: strings.TitleFieldLabel
}),
sp_webpart_base_1.PropertyPaneSlider('numberOfPeople', {
label: strings.NumberOfPeopleFieldLabel,
min: 1,
max: 10,
step: 1
})
]
}
]
}
]
};
};
return WorkingWithWebPart;
}(sp_webpart_base_1.BaseClientSideWebPart));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = WorkingWithWebPart;
//# sourceMappingURL=WorkingWithWebPart.js.map

View File

@ -0,0 +1,28 @@
import * as React from 'react';
import { IWorkingWithWebPartProps } from '../IWorkingWithWebPartProps';
import { SPHttpClient } from '@microsoft/sp-http';
export interface IWorkingWithProps extends IWorkingWithWebPartProps {
httpClient: SPHttpClient;
siteUrl: string;
}
export interface IPerson {
name: string;
email: string;
jobTitle: string;
department: string;
photoUrl: string;
profileUrl: string;
}
export interface IWorkingWithState {
loading: boolean;
people: IPerson[];
error: string;
}
export default class WorkingWith extends React.Component<IWorkingWithProps, IWorkingWithState> {
constructor(props: IWorkingWithProps, state: IWorkingWithState);
componentDidMount(): void;
componentDidUpdate(prevProps: IWorkingWithProps, prevState: IWorkingWithState, prevContext: any): void;
render(): JSX.Element;
private navigateTo(url);
private loadPeople(siteUrl, numberOfPeople);
}

View File

@ -0,0 +1,107 @@
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var React = require("react");
var WorkingWith_module_scss_1 = require("../WorkingWith.module.scss");
var sp_http_1 = require("@microsoft/sp-http");
var SearchUtils_1 = require("../../SearchUtils");
var Utils_1 = require("../../Utils");
var office_ui_fabric_react_1 = require("office-ui-fabric-react");
var WorkingWith = (function (_super) {
__extends(WorkingWith, _super);
function WorkingWith(props, state) {
var _this = _super.call(this, props) || this;
_this.state = {
people: [],
loading: true,
error: null
};
return _this;
}
WorkingWith.prototype.componentDidMount = function () {
this.loadPeople(this.props.siteUrl, this.props.numberOfPeople);
};
WorkingWith.prototype.componentDidUpdate = function (prevProps, prevState, prevContext) {
if (this.props.numberOfPeople !== prevProps.numberOfPeople ||
this.props.siteUrl !== prevProps.siteUrl && (this.props.numberOfPeople && this.props.siteUrl)) {
this.loadPeople(this.props.siteUrl, this.props.numberOfPeople);
}
};
WorkingWith.prototype.render = function () {
var _this = this;
var loading = this.state.loading ? React.createElement("div", { style: { margin: '0 auto' } },
React.createElement(office_ui_fabric_react_1.Spinner, { label: 'Loading...' })) : React.createElement("div", null);
var error = this.state.error ? React.createElement("div", null,
React.createElement("strong", null, "Error: "),
" ",
this.state.error) : React.createElement("div", null);
var people = this.state.people.map(function (person, i) {
return (React.createElement(office_ui_fabric_react_1.Persona, { primaryText: person.name, secondaryText: person.jobTitle, tertiaryText: person.department, imageUrl: person.photoUrl, size: office_ui_fabric_react_1.PersonaSize.large, presence: office_ui_fabric_react_1.PersonaPresence.none, onClick: function () { _this.navigateTo(person.profileUrl); }, key: person.email }));
});
return (React.createElement("div", { className: WorkingWith_module_scss_1.default.workingWith },
React.createElement("div", { className: office_ui_fabric_react_1.css('ms-font-xl', WorkingWith_module_scss_1.default.webPartTitle) }, this.props.title),
loading,
error,
people));
};
WorkingWith.prototype.navigateTo = function (url) {
window.open(url, '_blank');
};
WorkingWith.prototype.loadPeople = function (siteUrl, numberOfPeople) {
var _this = this;
this.props.httpClient.get(siteUrl + "/_api/search/query?querytext='*'&properties='GraphQuery:actor(me\\,action\\:1019)'&selectproperties='Title,WorkEmail,JobTitle,Department,Path'&rowlimit=" + numberOfPeople, sp_http_1.SPHttpClient.configurations.v1, {
headers: {
'Accept': 'application/json;odata=nometadata',
'odata-version': ''
}
})
.then(function (response) {
return response.json();
})
.then(function (response) {
if (!response ||
!response.PrimaryQueryResult ||
!response.PrimaryQueryResult.RelevantResults ||
response.PrimaryQueryResult.RelevantResults.RowCount === 0) {
_this.setState({
loading: false,
error: null,
people: []
});
return;
}
var people = [];
for (var i = 0; i < response.PrimaryQueryResult.RelevantResults.Table.Rows.length; i++) {
var personRow = response.PrimaryQueryResult.RelevantResults.Table.Rows[i];
var email = SearchUtils_1.SearchUtils.getValueFromResults('WorkEmail', personRow.Cells);
people.push({
name: SearchUtils_1.SearchUtils.getValueFromResults('Title', personRow.Cells),
email: email,
jobTitle: SearchUtils_1.SearchUtils.getValueFromResults('JobTitle', personRow.Cells),
department: SearchUtils_1.SearchUtils.getValueFromResults('Department', personRow.Cells),
photoUrl: Utils_1.Utils.getUserPhotoUrl(email, siteUrl, 'L'),
profileUrl: SearchUtils_1.SearchUtils.getValueFromResults('Path', personRow.Cells)
});
}
_this.setState({
loading: false,
error: null,
people: people
});
}, function (error) {
_this.setState({
loading: false,
error: error,
people: []
});
});
};
return WorkingWith;
}(React.Component));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = WorkingWith;
//# sourceMappingURL=WorkingWith.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
define([], function() {
return {
"PropertyPaneDescription": "Manage the settings of this Web Part",
"ViewGroupName": "View",
"NumberOfPeopleFieldLabel": "Number of people to show",
"TitleFieldLabel": "Web Part Title (displayed in the body)"
}
});

View File

@ -0,0 +1,10 @@
/// <reference types="mocha" />
"use strict";
var chai_1 = require("chai");
describe('WorkingWithWebPart', function () {
it('should do something', function () {
chai_1.assert.ok(true);
});
});
//# sourceMappingURL=WorkingWith.test.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webparts/workingWith/tests/WorkingWith.test.ts"],"names":[],"mappings":"AAAA,+BAA+B;;AAE/B,6BAA8B;AAE9B,QAAQ,CAAC,oBAAoB,EAAE;IAC7B,EAAE,CAAC,qBAAqB,EAAE;QACxB,aAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","file":"webparts/workingWith/tests/WorkingWith.test.js","sourcesContent":["/// <reference types=\"mocha\" />\r\n\r\nimport { assert } from 'chai';\r\n\r\ndescribe('WorkingWithWebPart', () => {\r\n it('should do something', () => {\r\n assert.ok(true);\r\n });\r\n});\r\n"],"sourceRoot":"..\\..\\..\\..\\src"}

View File

@ -1,30 +1,34 @@
{
"name": "react-officegraph",
"version": "1.3.0",
"version": "2.0.0",
"private": true,
"engines": {
"node": ">=0.10.0"
},
"author": {
"name": "Waldek Mastykarz",
"url": "http://www.rencore.com"
"name": "Waldek Mastykarz,Gautam Sheth",
"url": "http://www.rencore.com,http://www.rapidcircle.com"
},
"dependencies": {
"@microsoft/sp-client-base": "~0.2.0",
"@microsoft/sp-client-preview": "~0.2.0",
"office-ui-fabric-react": "0.36.0",
"react": "0.14.8",
"react-dom": "0.14.8"
"@microsoft/sp-client-base": "~1.0.0",
"@microsoft/sp-core-library": "~1.0.0",
"@microsoft/sp-webpart-base": "~1.0.0",
"@types/webpack-env": ">=1.12.1 <1.14.0",
"office-ui-fabric-react": "4.1.1",
"react": "^15.5.0",
"react-dom": "15.5.4"
},
"devDependencies": {
"@microsoft/sp-build-web": "~0.5.0",
"@microsoft/sp-module-interfaces": "~0.2.0",
"@microsoft/sp-webpart-workbench": "~0.2.0",
"gulp": "~3.9.1"
"@microsoft/sp-build-web": "~1.0.0",
"@microsoft/sp-module-interfaces": "~1.0.0",
"@microsoft/sp-webpart-workbench": "~1.0.0",
"gulp": "~3.9.1",
"@types/chai": ">=3.4.34 <3.6.0",
"@types/mocha": ">=2.2.33 <2.6.0"
},
"scripts": {
"build": "gulp bundle",
"clean": "gulp nuke",
"clean": "gulp clean",
"test": "gulp test"
}
}

Some files were not shown because too many files have changed in this diff Show More