CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

Simple Build for dotnet new react

I created a sample ASP.NET Core app with React. 

dotnet new react

 

 

Then it took a couple of hours to get the build to work. Here is my working azure-pipelines.yml:

 

Resources:

Svenska i Office 365 Admin

Svenskt gränssnitt i Office 365 är inte självklart. Här är en lista på översättningar som jag stött på som går att härleda, men som inte är helt etablerade i svenskan.

  • Compliance – efterlevnad
  • Policy – princip
  • Retention – kvarhållning

 

My list of _layouts pages

There are many resources on the internet that list _layouts/15 urls in SharePoint. Some are outdated, some are too short, some are to long. Here is my list of the urls, that I am going to update when I need. All the urls start with [Your-Tenant].sharepoint.com/sites/[Your-Site]/_layouts/15/

Here we go:

  • viewlsts.aspx – Site Contents, Modern View
  • viewlsts.aspx?view=14 – Site Contents, Classic View
  • appinv.aspx – Grant Permissions to an App
  • appregnew.aspx – Register a new SharePoint Application
  • appprincipals.aspx – List Registered Add-Ins
  • CreateGroup.aspx – Create Site page (Team and Communication)
  • TA_AllAppPrincipals.aspx – List all app principals

SPFx Samples

Here is my list of repositories that provide examples of SPFx solutions.

SwiftKey from the Chuvash point of view

SwiftKey is a keyboard app for iOS and Android, it adds a new virtual keyboard and it provides the Chuvash one among others.

Here is my review of Swiftkey from the perspective of a person who writes in Chuvash on the mobile.

IMG_0095

Positive things

  • The fact that it has the Chuvash keyboard map is awesome. There is no official Chuvash keyboard in iOS, Android, MacOS, Windows (well you can add Chuvash, but you won’t get the Chuvash letters). Only Linux has the built-in Chuvash keyboard.
  • It has a built-in Chuvash dictionary, so that can provide suggestions. It also can learn from your typing. Although there is an issue  with the suggestions, see below.
  • The Chuvash characters with diacritics are right: Unicode and Cyrillic, not their look-alikes from the Latin set. It is important: if people use the same characters, they can find more on Google.

Negative things

Actually I don’t want to call it negative things, many of them are just missing features. I hope with that review I can get in contact with the Swiftkey team and improve the app.

  • Chuvash letters with diacritics are “hidden” behind their “siblings” without diacritics. To get ӗ you have to long-press е then е and ӗ will pop up. The Chuvash letters should be in the front. Some typical Russian letters can be moved to the back, e.g. ц, щ, ж, д, г etc. Those “Russian” letters are used in Russian loanwords. See the proposal of the keymap below.
  • There are “too many” characters, the keyboard buttons are too small on the mobile. This issue is the same for the Russian keyboard. Since Chuvash has fewer Core Chuvash letters, we could take the rare ones to the back, it would be okay to long-press to get them: г, д, ж, з, щ etc.
  • One character is used a lot, it is a simple hyphen “-“. It is between words and small additions to express questions, wondering, nice asking: -и?, ши?, -ҫкӗ, -ха etc. Also in the “collection words”: сӗтел-пукан (furnitures), сас-хура (rumors). It is heavily used and having the hyphen somewhere in the front, would make typing a lot faster in Chuvash.
  • Swiftkey should be at least tri-lingual, not bi-lingual. It is limited to 2 languages only on the iOS (on Android you can add up to five languages). Consider a typical Chuvash guy who needs to write in Russian in his daily life. He also writes in Chuvash in social networks. Occasionally, he has to input latin letters (domain names, e-mail etc), meaning he needs the third language – English.
  • The dictionary used for the suggestions seems to use a mix of Cyrillic diacritics and their latin look-alikes: ӑӗҫ. They are not treated as the same letters, therefore many right words are excluded from the suggestions. A solution for that would be a simple find and replace of three letters (the capitals and versals): Latin A with breve to Cyrillic A with breve, Latin E with breve to Cyrillic E with breve. Latin C with cedilla to the Cyrillic C with Cedilla. But even Latin Y with diaresis should be replaced with Cyrillic y with double acute.

Keymap proposal

Since many “Russian” letters are not used a lot, they could be brought back and accessed by long-pressing the keys. I would suggest, keep the existing keymaps (Russian Compact, Russian Phonetic, Russian Full), but also add a new keymap: “Chuvash Compact”. Here are the three rows of characters.

  • Top row (10 chars) : й ӳ у к е н ӗ ш ӑ х
  • Middle row (10 chars): ҫ ы в а п р о л – э
  • Bottom row (8 chars): я ч с м и т ь ю

The “long-pressed” characters:

  • к: к г (why: simplified: they represent allophones in Chuvash)
  • е: е ё (ё to type some Russian loanwords)
  • ш: ш ж (why: simplified: they represent allophones in Chuvash)
  • х: х ф (historically ф was transformed to х or хв, still not very common letter)
  • ҫ: ҫ щ (why: simplified: they represent allophones in Chuvash)
  • п: п б (why: simplified: they represent allophones in Chuvash)
  • -: – ! (why: hyphen is used a lot in the words, the exclamation mark is used often after onomatopoetic words)
  • с: с з (why: simplified: they represent allophones in Chuvash)
  • т: т д (why: simplified: they represent allophones in Chuvash)
  • ь: ь ъ (to type some Russian loanwords)

cv_compact

Solpanelexperimentet

Ett litet projekt, ett experiment som jag håller på under min föräldralediga tid: Barnvagssolpanel.

Jag har en liten solpanel på 10W som jag fäster på barnvagnen. Med den laddar jag mina batteripack, och med dem min mobil. Jag vill mäta hur mycket energi jag kan samla in under sommarensolpanel.jpg

Utrustning

Solpanel på 10W av märket Exibel köpt på Clas Ohlson. Den ska ge upp till 1,5A i direkt ljus.

USB-doktorn. No-brand-produkt. Den visar spänning, ström, tid och kapacitet. USB-anslutningen är lite lös och kan glappa ibland. Den i sig förbrukar lite ström. Av någon anledning backar den flera mAh tillbaka efter man nått 3000 mAh varje gång man ansluter sladden igen.

En svart powerbank från Clas Ohlson på 2600mAh = 9,62Wh. Blir laddad så fort solen skiner. I direkt solljus blir det 4,92v x 0,82A = 4W.

En silverfärgad powerbank från Clas Ohlson på 3350mAh = 12,1Wh. Den fungerar mycket sämre, ofta laddar den inte alls, trots att den funkar från eluttaget. I skiftande strömförhållanden lägger den av. Är det på grund av någon elektronisk skyddspärr?

Resultatet

Jag skriver upp det jag uppmätt i ett räkneark: Barnvagnssol.

Iakttaganden

Ladda powerbank först

iPhone är inte bra att ladda direkt från solpanelen. Mjukvaran som styr laddningen i telefonen stoppar den när spänningen varierar. Ofta dyker det upp en ruta: tillbehör som inte stöds. Däremot är batteripack riktiga slukare, det finns ingen reglerande mjukvara. I rakt solljus går det att få ut nästan 1A (0,97A som jag mätt som bäst).

Utan förbrukning – ingen laddning

Under soliga dagar kommer in mycket energi. När jag har laddat alla mobiler, powerbanks jag har tar det stopp. Om man inte kan ladda något, kan man inte dra nytta av energin. Synd att det inte går att ladda datorbatterier (16,5v på min dator) och elcykelbatteriet (36v) från solen. Det går såklart men det kräver utrustning: speciella kontakter och spänningsomvandlare.

My PowerShell Profile

Screen Shot 2016-06-13 at 20.52.26

It has been a while I last worked with PowerShell. I had my custom profile where I had my own prompt and some other customizations. Now I cannot find it anymore. I’ll start with the new one and I am saving it on my blog, so it will be easier to find in future:

Function Prompt {
    $PromptData="PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
    $host.ui.RawUI.WindowTitle=$PromptData
       +'-'+(Get-Date).tostring()
    # .Link# http://go.microsoft.com/fwlink/?LinkID=225750
    # .ExternalHelp System.Management.Automation.dll-help.xml
}

The prompt function comes from the scripting guy blog.

To customize your profile, just open it in a text editor (in my case: code)

code $profile

Update 2018-04-10

You can also include these lines:

$path1 = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\"
$path2 = "15"
Add-Type -Path  "$path1\$path2\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path  "$path1\$path2\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

VS Code
Now we can run VS Code to create ps1 scripts and run selections as we did it in PowerShell ISE.

Update Field.JSLink using JSOM or REST

Today I have just a little code snippet to share. This code snippet shows how to update the JSLink property for an existing field using JSOM and REST. For REST I use sharepoint-utilities.

var updateJsLinkCsom = function(config) {
	var ctx = SP.ClientContext.get_current();
	var web = ctx.get_web();
	var lists = web.get_lists();
	var list = lists.getByTitle(config.listTitle)
	var fields = list.get_fields();
	var field = fields.getByInternalNameOrTitle(config.fieldTitle)
	field.set_jsLink(config.jsLink)
	field.update()
	ctx.executeQueryAsync()
};
var updateJsLinkRest = function(config) {
	SP.SOD.registerSod('sputils.js', '<your cdn endpoint>/sputils.min.js')
	SP.SOD.executeFunc('sputils.js', '', function() {
		var url = _spPageContextInfo.webAbsoluteUrl
			+ '/_api/web/lists/getbytitle(\''
			+ config.listTitle + '\')/fields/getbyinternalnameortitle(\''+ config.fieldTitle + '\')';
		var payload = {'__metadata': {'type': 'SP.Field'}, 'JSLink': config.jsLink};
	    var config = {'headers' : {'X-HTTP-Method': 'MERGE' }};
		sputils.rest.post(url, payload, config);
	});
};
var config = {
	listTitle: '<your list title>',
	fieldTitle: '<your field title>',
	jsLink: '~site/<your jslink>'
};
updateJsLinkCsom(config);
updateJsLinkRest(config);

A couple of notes, to update a field we need:

  • A POST request
  • with a header ‘X-HTTP-Method’: ‘MERGE’
  • with __metadata: { type: SP.Field } and JSLink property in the payload
  • and X-RequestDigest‘ header (but it is nicely handled by sharepoint-utilities)

Trigger SP2010 Workflows using JSOM

Today I found out how to start workflows in JSOM (JavaScript Object Model in SharePoint). Nothing special, but since it is not documented, it took me a while to find a solution. Here is the code which I want to keep as simple as possible.

What you need to start a SP2010 Workflow for a list item or a document in JSOM, you need to load SP.WorkflowServices.js and you need to create the manager and get the service, then you can trigger a workflow using the workflow name, the list guid and the guid of the list item:

var ctx = SP.ClientContext.get_current();
var workflowServicesManager =
	SP.WorkflowServices.WorkflowServicesManager.newObject(ctx,
		ctx.get_web());
var service = workflowServicesManager.getWorkflowInteropService();
service.startWorkflow(workflowName, null,
	listGuid, plainItem.guid, initiationParams);

Here is the code to trigger a workflow for multiple items:

//fire the workflows
function fire2010WorkflowForListItems(ctx, listGuid, plainItems) {
	var workflowServicesManager =
		SP.WorkflowServices.WorkflowServicesManager.newObject(ctx,
			ctx.get_web());
	var service = workflowServicesManager.getWorkflowInteropService();
	for(var i = 0; i &lt; plainItems.length; i++) {
		var plainItem = plainItems[i];
		console.log('scheduling workflow for id: ', plainItem.id);
		service.startWorkflow(options.workflowName, null,
			listGuid, plainItem.guid, options.initiationParams);
	}
	console.log('now executing...');
	ctx.executeQueryAsync(function() {
		console.info('yes, workflows completed for '
			+ items.length + ' items');
	}, function() {
		console.error('it didnt go well');
	});
}

 

The code above is inspired from this gist and sharepoint stackexchange. It is a simplified version that only works for list item workflows and SharePoint 2010 workflows.
Here is an example how you can get multiple items and batch start a workflow:

//just a couple of variables
var options = {
	workflowName: 'Behörigheter',
	listName: 'Documents',
	initiationParams: {}
};
//load list items
function startWorfklows() {
	//Start 2010 Workflow for a List Item
	var ctx = SP.ClientContext.get_current();
	var web = ctx.get_web();
	var lists = web.get_lists();
	var list = lists.getByTitle(options.listName);
	ctx.load(list);
	var items = list.getItems(new SP.CamlQuery());
	ctx.load(items);
	ctx.executeQueryAsync(function() {
		var listGuid = list.get_id() + '';
		var en = items.getEnumerator();
		var plainItems = [];
		while (en.moveNext()) {
			var it = en.get_current();
			//do not take checked out files, it won't work
			if (!it.get_item('CheckoutUser')) {
				plainItems.push({id: it.get_id(), guid: it.get_item('GUID') + '' });
			}
		}
		fire2010WorkflowForListItems(ctx, listGuid, plainItems);
	}, function() {
		alert('boom');
	});
}

//Load Worfklow Js dependency
var wfScript = 'SP.WorkflowServices.js'
SP.SOD.registerSod(wfScript,
	_spPageContextInfo.webAbsoluteUrl + '/_layouts/15/SP.WorkflowServices.js');
SP.SOD.executeFunc(wfScript, '', startWorfklows);

Why I needed it

I created a simple workflow that is triggered on Item Added and Item Updated. Unfortunately there are already thousands of items in the document library. To trigger them manually is nothing good. But a simple javascript solution did exactly what I wanted.

Create and download a file in javascript

Phew, I spent a lot of time to get this to work:

  • Create a text based file in javascript – a simple csv or txt
  • Download a file in Chrome and Internet Explorer
  • Make Excel understand Unicode characters (å ä ö and many more) in csv directly.

I found many solutions on the Internet that I used to find out a solution that works for me

A deep diving jsfiddle about unicode encodings, bom, line endings: http://jsfiddle.net/kimiliini/HM4rW (unfortunately, does not work in IE). There I learned one important thing: we need a BOM in order to make Excel understand that it is not just ASCII. The BOM (byte order mark) for utf-8 is %ef%bb%bf for utf-8. Without this bom you’ll see the right characters in a text editor (except Notepad of course), but if you open the csv file directly in Excel, you’ll see wrong letters.
Other good resources are FileSaver.js: https://github.com/eligrey/FileSaver.js and download.js: http://danml.com/download.html and a discussion on that github repository issue: https://github.com/mholt/PapaParse/issues/175

This is my solution that is tested in Chrome and IE10:

function downloadContent(options) {
	if (!options || !options.content) {
		throw 'You have at least to provide content to download';
	}
	options.filename = options.filename || 'tolle.txt';
	options.type = options.type || 'text/plain;charset=utf-8';
	options.bom = options.bom || decodeURIComponent('%ef%bb%bf');

	if (window.navigator.msSaveBlob) {
		var blob = new Blob([options.bom + options.content],
                 {type: options.type });
		window.navigator.msSaveBlob(blob, options.filename);
	}
	else {
		var link = document.createElement('a');
		var content = options.bom + options.content;
		var uriScheme = ['data:', options.type, ','].join('');
		link.href = uriScheme + content;
		link.download = options.filename;
//FF requires the link in actual DOM
                document.body.appendChild(link);
		link.click();
		document.body.removeChild(link);
	}
}

//test
var separator = ';';
downloadContent({
	type: 'text/csv;charset=utf-8',
	filename: 'tolle.csv',
	content: ['ASCII', separator,
		'Åbäcka sig', separator,
		'to się podoba: żźćąęłć',
		separator, 'Яшлӑхӑма туйаймарӑм'].join('')
});

Safari

So it works on the latest Chrome (tested with 50 on Windows, Mac and Linux), Firefox (tested with 46 on Windows), Internet Explorer (tested with 11 on Windows 7). Unfortunately in Safari on a Mac, the link is opened directly in the web browser. You have to press Cmd – S to trigger Save As manually.

Part of SharePoint Utilities

I submitted this code to sputils (SharePoint Utilities) on github.

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Coder, Speaker, Author

Office 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Cameron Dwyer

Office 365, SharePoint, Azure, OnePlace Solutions & Life's Other Little Wonders

paul.tavares

Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

DevOps, Cloud and Blockchain Consultant

SPJoel

SharePoint for everyone

SharePointRyan

Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

blksthl

Mostly what I know about SharePoint - CommunicoCuspis

SharePointDiver

SharePoint på ren svenska