+ {loading}
+ {error}
+ {documents}
+
+
+ );
+ }
+
+ private getValueFromResults(key: string, results: ISearchResultValue[]): string {
+ let value: string = '';
+
+ if (results != null && results.length > 0 && key != null) {
+ for (let i: number = 0; i < results.length; i++) {
+ const resultItem: ISearchResultValue = results[i];
+ if (resultItem.Key === key) {
+ value = resultItem.Value;
+ break;
+ }
+ }
+ }
+
+ return value;
+ }
+
+ private trim(s: string): string {
+ if (s != null && s.length > 0) {
+ return s.replace(/^\s+|\s+$/gm, '');
+ }
+ else {
+ return s;
+ }
+ }
+
+ private getPreviewImageUrl(result: ISearchResultValue[], siteUrl: string): string {
+ const uniqueID: string = this.getValueFromResults('uniqueID', result);
+ const siteId: string = this.getValueFromResults('siteID', result);
+ const webId: string = this.getValueFromResults('webID', result);
+ const docId: string = 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}
+ &metadatatoken=300x424x2&ClientType=CodenameOsloWeb&size=small`;
+ }
+ else {
+ return '';
+ }
+ }
+
+ private getUserPhotoUrl(userEmail: string, siteUrl: string): string {
+ return `${siteUrl}/_layouts/15/userphoto.aspx?size=S&accountname=${userEmail}`;
+ }
+
+ private request