Skip to content

Instantly share code, notes, and snippets.

View nbelyh's full-sized avatar

Nikolay Belykh nbelyh

View GitHub Profile
@nbelyh
nbelyh / WORKING-teams-sso-tab-sharepoint-rest-api.md
Last active March 28, 2021 14:33
Calling SharePoint REST API from a teams tab using SSO

0. Application registration permissions

1. get the token from teams

microsoftTeams.authentication.getAuthToken() => <teams_token>

0. Application registration permissions

Maybe there is still misunderstanding what is meant under "calling SharePoint rest api"? I need to access SharePoint REST API using endpoing like https://{tenant}/_api/..., not https://graph.microsoft.com/...

So I configured app registration (note that SharePoint is added both as "graph" and "non-graph")

Working scenario (calling SharePoint using GRAPH API)

@nbelyh
nbelyh / app-ngx-select.ts
Created September 21, 2017 23:54
"Fixed" simplified single-file version of the valor ngx-select
import { Component, Input, Output, EventEmitter, ElementRef, forwardRef, HostListener } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
const styles = `
.ui-select-toggle {
position: relative;
}
/* Fix caret going into new line in Firefox */
@nbelyh
nbelyh / log-page-name.js
Created September 3, 2017 15:28
VisioOnline: log active page name to console
Visio.run(function(ctx) {
var page = ctx.document.getActivePage();
page.load();
return ctx.sync().then(function() {
console.log(page.name)
})
});
@nbelyh
nbelyh / start-putty.js
Last active September 2, 2017 16:32
SVGPublish: sample script to open ssh:// hyperlinks. Supposed to work with conjunctions with custom script on the client side. Please see starting-putty-from-an-exported-html-diagram for details
diagram.selectionChanged.add(function(shapeId) {
if (shapeId) {
var shape = diagram.shapes[shapeId];
if (shape) {
var ip = shape.Props['IP Address'];
if (ip) {
var url = 'ssh://' + ip;
@nbelyh
nbelyh / connected-highlight.js
Created August 30, 2017 23:08
SvgPublish: connected shapes hilighting
d3
.selectAll(".vp-table")
.style("cursor", "pointer")
.on('click', function() {
d3.selectAll(".vp-table").selectAll("g").style("fill", null);
var id = $(this).attr('id');
var data = diagram.shapes[id];
@nbelyh
nbelyh / sample-sidebar.md
Last active September 2, 2017 22:38
SvgPublishSidebar: a basic sidebar header to get an idea.

A First Level Header

A Second Level Header

Now is the time for all good men to come to the aid of their country. This is just a regular paragraph.

Visio.run(function (ctx) {
var activePage = ctx.document.getActivePage();
var shape = activePage.shapes.getItem(0);
shape.view.highlight = { color: "#E7E7E7", width: 100 };
return ctx.sync();
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
@nbelyh
nbelyh / document_setActivePage.js
Last active August 28, 2017 19:36
VisioOnline: Document object setActivePage example. https://dev.office.com/reference/add-ins/visio/document.
Visio.run(function (ctx) {
var document = ctx.document;
var pageName = "Page-1";
document.setActivePage(pageName);
return ctx.sync();
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
@nbelyh
nbelyh / document_getActivePage.js
Last active August 28, 2017 19:36
VisioOnline: Document object getActivePage example. https://dev.office.com/reference/add-ins/visio/document.
Visio.run(function (ctx) {
var document = ctx.document;
var activePage = document.getActivePage();
activePage.load();
return ctx.sync().then(function () {
console.log("pageName: " +activePage.name);
});
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {