This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Install-Module MSOnline | |
$users = ipcsv ./CreateDemoUsers.csv; | |
Connect-MsolService | |
$users | ForEach-Object { | |
Write-Host "Adding $($_.DisplayName)..." -foregroundcolor green; | |
$user = $_.psobject.properties | % { $ht = @{} } { $ht[$_.Name] = $_.Value } { $ht }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import * as ReactDom from 'react-dom'; | |
import { Version } from '@microsoft/sp-core-library'; | |
import { | |
BaseClientSideWebPart, | |
IPropertyPaneConfiguration, | |
WebPartContext | |
} from '@microsoft/sp-webpart-base'; | |
import * as strings from 'MyWebPartStrings'; | |
import MyComponent from './components/MyComponent'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ctx = SP.ClientContext.get_current(); | |
this.user = ctx.get_web().get_currentUser(); | |
this.alerts = this.user.get_alerts(); | |
ctx.load(this.user); | |
ctx.load(this.alerts); | |
ctx.executeQueryAsync(()=> { | |
var enumerator = this.alerts.getEnumerator(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ctx = SP.ClientContext.get_current(); | |
this.user = ctx.get_web().get_currentUser(); | |
this.alerts = this.user.get_alerts(); | |
this.list = ctx.get_web().get_lists().getByTitle('Documents'); | |
ctx.load(this.user); | |
ctx.load(this.alerts); | |
ctx.load(this.list); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//the final REST call is made to get the file information after it has been fully uploaded (especially the file list item id) | |
function getFileInformation(libraryPath, fileName, resolve, reject) { | |
let endpoint = String.format("{0}/_api/sp.appcontextsite(@target)/web/getfilebyserverrelativeurl(@libraryPath)/ListItemAllFields?@target='{3}'&@libraryPath='/sites/assetdatabase/{1}/{2}'", | |
utils.getSpContaxtUrlParams().appWebUrl, libraryPath, fileName, utils.getSpContaxtUrlParams().hostWebUrl); | |
const headers = { | |
"Accept": "application/json; odata=verbose" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Helper method - depending on what chunk of data we are dealing with, we need to use the correct REST method... | |
function getUploadMethod(offset, length, total) { | |
if (offset + length + 1 > total) { | |
return 'finishupload'; | |
} else if (offset === 0) { | |
return 'startupload'; | |
} else if (offset < total) { | |
return 'continueupload'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getWebRequestExecutorFactory(appWebUrl, hostWebUrl, spLanguage) { | |
let context = new window.SP.ClientContext(appWebUrl); | |
const factory = new window.SP.ProxyWebRequestExecutorFactory(appWebUrl); | |
context.set_webRequestExecutorFactory(factory); | |
return context; | |
} | |
const jsomContext = (appWebUrl, hostWebUrl, spLanguage) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this method sends the REST request using the SP RequestExecutor.js | |
function executeAsync(endPointUrl, data, requestHeaders) { | |
return new Promise((resolve, reject) => { | |
// remember that utils script we created? | |
let executor = new SP.RequestExecutor(utils.getSpContaxtUrlParams().appWebUrl); | |
// Send the request. | |
executor.executeAsync({ | |
url: endPointUrl, | |
method: "POST", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import utils from './utils'; | |
if (!ArrayBuffer.prototype.slice) { | |
ArrayBuffer.prototype.slice = function (begin, end) { | |
let len = this.byteLength; | |
begin = (begin|0) || 0; | |
end = end === (void 0) ? len : (end|0); | |
// Handle negative values. | |
if (begin < 0) begin = Math.max(begin + len, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDocumentQueryStrings() { | |
const sections = document.URL.split('?'); | |
return sections.length > 1 ? sections[1].split('&') : []; | |
} | |
function S4() { | |
return (((1 + Math.random())*0x10000)|0).toString(16).substring(1); | |
} |