Getting the Angular 2 Router Working for an Office Addin

 

I have simple Angular 2 Office Addin and attempting to use the Angular 2 Router to route between two components. My two components are called ViewOne and ViewTwo.

Here’s what the UI for the Office Addin looks like:

office-addin-angular2-router-pushState-cameron-dwyer-01-addin-ui

When the using the Router to navigate, the following errors related to the this._history.pushState function are thrown to the JavaScript console

office-addin-angular2-router-pushState-cameron-dwyer-02-zone-js-error

The error message text is:

EXCEPTION: Error: Uncaught (in promise): TypeError: this_history.pushState is not a function

The same page displays without any error if it is not running as an Office Addin (rather if I just run the same router code on a standalone web page).

My best guess is that this error is due to the Office Addin framework and the fact that the Angular 2 app is running inside a sandbox iframe. I have tried running the same Angular app in a sandbox iframe on an otherwise generic html page however and I can’t reproduce the error so I think it is unique to something within the Office Addin framework.

This particular error has to do with the Angular 2 app trying to push the URL change to the web browsers history (to support back/forward navigation). In an Office Addin this doesn’t really make much sense as the Addin isn’t in control of the whole page so we wouldn’t want the Addin taking over the browsers URL history anyway.

In order to stop the Angular 2 router trying to make this call to the browser you can use a custom location strategy. In my case I was already using the HashLocationStrategy (rather than the default HTML5 routing strategy).

I went to the Angular 2 GitHub repo and found the source code for the HashLocationStrategy and created a new class in my Angular 2 app called CustomHashLocationStrategy. I just dumped all the source code into the new file, changed the name of the class and removed the two lines of code that try to update the web browsers history as shown below.

office-addin-angular2-router-pushState-cameron-dwyer-03-location-strategy

Now when bootstrapping my Angular 2 app I use my new CustomHashLocationStrategy instead of the HashLocationStrategy. Here’s what that change looks like in code.

Before (click for full size image):

office-addin-angular2-router-pushState-cameron-dwyer-04-bootstrap-before

After (click for full size image):

office-addin-angular2-router-pushState-cameron-dwyer-04b-bootstrap-after

After this change I can now navigate between the 2 routes without any errors being thrown to the console.

office-addin-angular2-router-pushState-cameron-dwyer-05-addin-ui-working

The code shown in this article in the Angular 2 Router in RC1. I also had the same issue using the “Router-Deprecated” in RC1, the same solutions worked for me using the deprecated router.

I also tested that this fix worked across Chrome, IE, Edge and Windows Desktop Office Client.

 

Further reading:

http://stackoverflow.com/questions/36182807/angular-2-routed-apps-hosted-in-iframes

https://www.illucit.com/blog/2016/05/angular2-release-candidate-1-rc1-changes/

https://angular.io/docs/ts/latest/guide/router.html

Solving issues Scaling Remote Desktop on High DPI screens (Surface Pro)

The high density (DPI or Dots Per Inch) of modern screens such as a Surface Pro can cause numerous issues when trying to use Remote Desktop Connection (RDC) to remotely connect to another machine. Add an external monitor to the mix and you’ll be pulling your hair out before long at all.

These are the typical issues you can expect to run into:

  • Can’t get the remote desktop to fill up the entire screen
  • Remote desktop is tiny and you can’t make it any bigger
  • Text and images in remote desktop are really small
  • Mouse cursor in remote desktop is very small or very large
  • Blurry text in remote desktop
  • Blurry images in remote desktop
  • Can’t move remote desktop between screens without issues (e.g. between Surface screen and external monitor)

windows-dpi-scaling-remote-desktop-cameron-dwyer-01-small-remote-desktop

Screenshot (click to enlarge): Remote Desktop Connection on Surface Pro 4, trying to maximize the remote desktop just pushes it to the top right corner of the Surface screen, the icons and text are so small you can hardly read them.

 

windows-dpi-scaling-remote-desktop-cameron-dwyer-2-small-remote-desktop-full-screen

Screenshot (click to enlarge): Remote Desktop Connection on Surface Pro 4, if you try to put the remote desktop into full screen mode, you end up with the same tiny text and images just centred on the Surface screen with a black background around it.

 

windows-dpi-scaling-remote-desktop-cameron-dwyer-03-blurry-text-large-fonts-small-cursor

Screenshot (click to enlarge): Remote Desktop Connection on Surface Pro 4 opened on an external monitor. Trying to show the Remote Desktop on an external monitor is often affected by; Blurry text/images/fonts (such as the Word ribbon), some really oversized text (such as the window title), tiny mouse cursor (or reverse, sometimes I get a massive cursor)

 

Almost all the symptoms above are due to differences in DPI and resolutions between:

  • The host machine
  • The remote machine session
  • The host screen and the external screen

I have transitioned across to using a Surface Pro 4 as my main work machine, I don’t do much development work directly on the Surface, rather I have a few virtual machines running on servers in the office and in Azure. As soon as I tried to RDC to these virtual machines I immediately started running into these problems.

The closest thing I have found to a silver bullet that addresses most of these issues in one hit is to stop using the Remote Desktop Connection client that comes built into Windows 10. Instead I now use a separate free product that Microsoft has available called Remote Desktop Connection Manager.

Remote Desktop Connection Manager has the added benefits of:

  • A navigation list of machines you regularly connect to make it super fast to open and switch between connections
  • Persistence of connection credentials
  • Lots more configuration options (compared to the standard RDC)

windows-dpi-scaling-remote-desktop-cameron-dwyer-04-desktop-connection-manager

Screenshot (click to enlarge): Remote Desktop Connection Manager layout

 

windows-dpi-scaling-remote-desktop-cameron-dwyer-05-remote-desktop-scaled-correctly

Screenshot (click to enlarge): Connecting using Remote Desktop Connection Manager I now get the remote desktop completely filling up my Surface screen, and at a resolution and DPI that is useable. Text, images and cursor all appear crisp and as expected! Extending out to an external monitor is much more successful than with the standard RDC. Again in full screen mode, the remote desktop takes up the entire screen and scaling happens without leaving you with blurry text, images and cursor.

 

windows-dpi-scaling-remote-desktop-cameron-dwyer-06-session-full-screen

Screenshot (click to enlarge): Remote Desktop Connection Manager full screen option is a bit hidden away under the Session menu

 

windows-dpi-scaling-remote-desktop-cameron-dwyer-07-display-options

Screenshot (click to enlarge): Remote Desktop Connection Manager also provides a much richer set of configuration options regarding the display if it doesn’t just work for you immediately as well.

 

One important thing to note is that some scaling of the remote desktop occurs when the remote session is established. This only happens when you disconnect and reconnect. So if you have a session open on one of your screens (e.g. Surface screen) and then move that across to an external monitor it may not fill up the whole external screen when you try to go full screen. If you disconnect and reconnect while on the external monitor you will now be able to go full screen on the external monitor. Remote Desktop Connection Manager has a quick way of doing this (just right-click and select Reconnect server).

 

windows-dpi-scaling-remote-desktop-cameron-dwyer-08-reconnect-session

Screenshot: Reconnect server option

 

The handling of DPI and associated scaling behaviour is different based on the version of the operating system. I have been using Remote Desktop Connection Manager from my Windows 10 Surface Pro 4 connecting to a mix of Windows Server 2012 and Windows 10 virtual machines. You may not have as much success if you add other operating system versions into the mix.

While it’s not perfect (I still find problems now and then and taking screenshot of remote connections usually come out smaller or larger than you would expect), its a lot better than just using the standard remote desktop connection client built into Windows.

 

Further reading:

https://blogs.msdn.microsoft.com/rds/2013/12/16/resolution-and-scaling-level-updates-in-rdp-8-1/

https://blogs.msdn.microsoft.com/rds/2015/06/29/zoom-windows-10-remote-desktop-connections-to-older-versions-of-windows-to-improve-your-experience-on-a-hi-dpi-client-display/

Light up your Outlook Mailboxes with advanced Email Tracking features

I’m preparing to head down to Melbourne for the The Digital Workplace Conference (the new Australian SharePoint Conference). This will be the first conference since the 7.3 release of OnePlaceMail and OnePlaceLive. I’m pretty excited about the new Email Tracking features which goes well beyond simply allowing users to transfer email and attachment from Outlook to SharePoint. This goes to a whole new level. Save an email to SharePoint (or Office 365) and all other recipients of the email can see in real time that you have file it to SharePoint and can open up the location in SharePoint. No more having multiple people trying the file the same email to SharePoint to find that someone has already save it there. Or worse, people saving it to different locations in SharePoint and having the files duplicated.

If you haven’t checked out the OnePlace Solutions suite in the last few months you may have also missed the suggested and predictive email filing capabilities that analyze the filing patterns of users and will suggest or predict locations in SharePoint that are likely locations you would want to save the email. If you’re not going to make it to see us at the Melbourne conference (or simply can’t wait that long to see what I’m talking about) here’s a short video on the Email Tracking feature. See for yourself how just one feature can make the Digital Workplace so much easier for a user, then imagine a whole suite of products packed with features like this, then come and see me at the conference!

 

 

Outlook Add-in Ribbon Commands: Resolution to Manifest XML Schema Errors

While taking a look at the new Outlook Addin Ribbon Commands I came across these schema validation errors trying to deploy the addin once I added the VersionOverrides element. In particular I was getting this error message:

Failed to deploy the manifest file to the Exchange server.  This app can’t be installed. The manifest file doesn’t conform to the schema definition. The element ‘Resources’ in namespace ‘http://schemas.microsoft.com/office/mailappversionoverrides’ has invalid child element ‘Images’ in namespace ‘http://schemas.microsoft.com/office/officeappbasictypes/1.0′. List of possible elements expected: ‘ShortStrings, LongStrings’ in namespace ‘http://schemas.microsoft.com/office/officeappbasictypes/1.0′... The element ‘Resources’ in namespace ‘http://schemas.microsoft.com/office/mailappversionoverrides’ has invalid child element ‘Images’ in namespace ‘http://schemas.microsoft.com/office/officeappbasictypes/1.0′. List of possible elements expected: ‘ShortStrings, LongStrings’ in namespace ‘http://schemas.microsoft.com/office/officeappbasictypes/1.0′.

 

After a bit of trial and error I discovered that the issue was to do with the order of child elements within the Resources element. It appears that there is a strict order that must be adhered to.

Here’s the code that was causing the error. Notice that I was defining Urls before Images.

 

image

 

I simply swapped this around to define Images first, then Urls and the xml then passed the validation check and I was on my way. Here’s the working code:

image

 

2 Simple Techniques for Creating SharePoint Views Grouped by Date Columns

Here are 2 techniques for creating views in SharePoint when you want to group on dates. Throughout this article I’ll be using the example of email that have been saved to SharePoint where the email date has been stored in a SharePoint column called “Email Date”. The Email Date is saved with both a date and time component.

sharepoint-views-date-group-by-cameron-dwyer-01-email-date-column

Here’s the All Documents view of the library showing the Email Date column

sharepoint-views-date-group-by-cameron-dwyer-02-all-documents

If we try to use the Email Date column to group by in the view

sharepoint-views-date-group-by-cameron-dwyer-03-group-by-email-date

The view creates a group for each different day (the time component is ignored)

sharepoint-views-date-group-by-cameron-dwyer-03-view-grouped-by-date

2 Level Grouping: by Year and then by Month

This view is going to get very busy with a grouping for each day, so how about we split it up a bit by creating 2 levels of grouping, firstly by year and then by month.

Unfortunately we can’t just use the existing Email Date column to achieve this, instead we will create two calculated columns to use for the groupings (one for year and another for month).

To create the year column:

Create as a calculated column
Set the returned data type as Single line of text (this gives better formatting control and the year will still sort properly as text)
Set the formula to =TEXT([Email Date], “yyyy”)

sharepoint-views-date-group-by-cameron-dwyer-04-calculated-year-column

To create the month column:

Create as a calculated column
Set the returned data type as Single line of text (this gives better formatting control and by padding a single digit month with 0 will still sort properly as text)
Set the formula to =TEXT([Email Date],”mm (mmmm)”)

sharepoint-views-date-group-by-cameron-dwyer-04-calculated-month-column

Now if we create a new view (based on the All Documents view) and add two levels of grouping based on our new calculated columns

sharepoint-views-date-group-by-cameron-dwyer-05-view-group-by-year-then-month

Our new view now renders in SharePoint giving collapsible grouping at both the Year and Month levels

sharepoint-views-date-group-by-cameron-dwyer-06-view-result-group-by-year-then-month

This is now a lot easier to navigate and drill down, and it’s quite nice to see the counts against each grouping as well. In this example I set the groups (both Year and Month) to sort in descending order. This means that the latest will be at the top (notice 2016 is above 2015, and within 2016, February is above January).

Faking a 3 Level Grouping: by Year/Month Combined and then by Day

SharePoint has a limitation in that you can only create two levels of grouping. If we want to have a third level (under month) that grouped together all the email from the same day then we can’t just go and add a third level of grouping. What we can do instead though is create a slightly more complex calculated column that combines both the year and month and use it as our top level grouping. So let’s do that now by creating a Year/Month column:

Create as a calculated column
Set the returned data type as Single line of text (this gives better formatting control and we can carefully craft the text so it still sorts year/month properly as text)
Set the formula to =TEXT([Email Date],”yyyy-mm (mmmm)”)

sharepoint-views-date-group-by-cameron-dwyer-07-calculated-column-year-month

We are also going the need a calculated column to group on the specific day, so I’ll create the Day column

Create as a calculated column
Set the returned data type as Single line of text
Set the formula to =TEXT([Email Date],”dd (ddd, d mmm yyyy)”)

sharepoint-views-date-group-by-cameron-dwyer-08-calculated-column-day

Now we create our new view (based on the All Documents view) and add groupings based on the Year/Month column and the Day column. Again we will sort descending to get the latest at the top.

sharepoint-views-date-group-by-cameron-dwyer-09-view-settings-group-year-month-day

The resulting SharePoint view gives us the year/month breakdown at the first level and we can then drill down to a specific day within the month.

sharepoint-views-date-group-by-cameron-dwyer-10-view-group-by-year-month-day

I’m sure you can now go forward and add your own tweaks and formatting changes to get better date categorized views out of SharePoint.

 

The modern digital workplace must focus on the user

modern-digital-workplace-cameron-dwyer

I was recently interviewed by the team at LiveTiles to get my thoughts on the modern digital workplace.

  • What does the digital workplace mean to me?
  • What do I see as the benefits and challenges of the digital workplace?
  • What trends have I seen and what do I think the future holds for the digital workplace?

Read the answers to these questions and more in the full article What to expect from the modern workplace.

The problem now isn’t digitizing information, the problem is how to get the right information to the right people at the right time [with] the right tool.”

 

Neat trick to enable LTE on Surface Pro 4 (for Windows Phone users)

Microsoft Surface Pro 4 doesn’t have built in LTE capability (at the time of writing this). What this means is that your Surface Pro 4 can’t connect to the internet on its own. It needs to connect to a wireless network/hotspot, or use a USB adaptor to provide access to the internet (e.g. physical Ethernet connection).

I’ve read a few articles dismissing the Surface Pro 4 because the lack of LTE (or SIM card). I don’t really find it an issue, why? Because of a neat little trick that the Surface can do with my Windows Phone.

Most smartphones these days support tethering (also called internet sharing, or wireless hotspot). This effectively shares the internet connection that your phone has with other devices. Other devices connect to your phone (which acts as a wireless hotspot) and then get access to the internet (which you can secure with a password). Ok, boring blurb over, you already knew that you could get out to the internet by using your phone right?

Here’s what you are probably used to:

  • Pull out your phone
  • Unlock your phone
  • Navigate into the phone settings area
  • Find the tethering/internet sharing settings
  • Turn tethering/internet sharing on
  • Now back on your Surface, if you’ve set up the Wi-Fi connection to your phone to auto connect you should find the connection is made automatically after a few seconds and you’re on the internet

But this process is just so clunky and slow.

So here’s the neat trick that your Windows Phone, teamed up with your Surface is capable of:

  • Leave your phone alone – in your pocket, bag, backpack, desk drawer (wherever as long as it within a reasonable range)
  • On your Surface, simply click on the Wi-Fi icon in the task tray to show any available Wi-Fi connections. You should see your phone listed (even though the tethering is not enabled on your phone). You can see my NOKIA Lumia phone in the list below and it shows as “Mobile hotspot, off”

microsoft-surface-pro-LTE-SIM-01-select-phone-hotspot-cameron-dwyer

  • Now I just select the NOKIA Lumia option in the list and click Connect

microsoft-surface-pro-LTE-SIM-02-enable-tethering-automatically-cameron-dwyer

  • Without touching my phone, the Surface is able to turn on the hotspot/tethering feature of the phone and connect to it.

microsoft-surface-pro-LTE-SIM-03-connected-cameron-dwyer

 

I would also suggest changing the connection to your phone to set it as a metered connection. This will prevent Windows from performing costly data transfers such as downloading updates.

So do I care that my Surface Pro 4 doesn’t have LTE (SIM card)? Not at all, because I’ve always got my phone close by and I can now share its internet connection with just 2 clicks. It’s a pretty cool integration that makes a world of difference.

I’ve only tried this on a Surface Pro 4 (Windows 10) and Nokia Lumia 930 (Windows 10), although the articles below suggest that this feature also works on Windows 8.1.

Further Reading

http://www.neowin.net/forum/topic/1229889-windows-can-now-control-internet-sharing-on-windows-phone/

http://www.surfaceforums.net/threads/automatic-tethering-to-windows-phone.6305/

Photos from Microsoft Ignite Australia (Gold Coast)

Windows Phone 10–Continuum and Remote Desktop Combo is Huge

Being a Windows Phone user I was pretty excited when the Continuum feature started getting demonstrated. But the sceptic inside me kept nagging at me that it’s probably going to be more gimmick than substance. A chance conversation at Microsoft Ignite Australia has changed my opinion and got me excited again.

A reminder about what Continuum is:

Continuum for Windows phones lets you turn your phone into a PC-like experience by connecting an external display, keyboard, and mouse using the new Microsoft Display Dock. The experience on the phone (start screen, calls etc) remains completely independent of the PC-like experience on the external display.

Microsoft-Display-Dock-continuum

The Continuum magic is only supported by the new Universal Windows Apps (primarily Microsoft Apps to start with, e.g. Office/Mail/Calendar). This is the bit that the sceptic in me initially thought great feature, but who’s going to build the apps to support it.

The phone (via the dock) is capable of driving a single HDMI display and apps scale up to use a high resolution on the external monitor.

The real light bulb moment happened during a conversation when it was mentioned that a remote desktop app that supported Continuum was not only in the pipeline but I was able to get a demonstration. This is epic, as my development machines are all virtual (some on premises at the office and others in Azure). What this would mean for me is that I could plug my phone in to get the Continuum PC like experience, then start a remote desktop session to one of my development machines and start coding with very much the same experience I would have on a beefy laptop. The only drawback from the specs of been reading is that you can’t drive 2 external displays from the dock (but for those occasions that you would use it you’re probably not carrying around dual displays!)

Also worth noting is the demo kit that I saw was using the wireless dock. No cords at all; phone, dock, mouse, keyboard, display all in close proximity but not a cord in sight.

Update (16 Dec 2015)

A Microsoft forum moderator has posted this information

“We’ve heard a lot of buzz around being able to connect to a remote desktop from Continuum for phone. We are excited to share that the Remote Desktop Universal Windows Platform (UWP) app will be released very soon in Technical Preview. We are very interested in hearing more from remote desktop users to help prioritize investments in this much-requested app. How do you intend to use it on Continuum for phone? What apps will you run and what tasks will you do? In what environments or scenarios will you use it?”

http://www.winbeta.org/news/remote-desktop-universal-windows-10-app-will-be-released-very-soon

Further Reading:

http://www.windowscentral.com/how-continuum-windows-10-mobile-works-lumia-950

http://www.slashgear.com/microsoft-display-dock-hands-on-continuum-could-be-huge-06408536/

Update (13 Jan 2016) – The Preview of Remote Desktop Universal App is Here

Remote Desktop Preview now available on Windows 10 Mobile and Continuum

How to Dock Windows Left & Right using Multiple Monitors

Here’s a quick tip that one of my colleagues showed my this week that makes working with multiple monitors a lot easier. Thanks to @FreeRangeEggs for this tip.

 

The Problem

You’ve got 2 windows (A and B) and you want to dock them side by side on monitor 1.

cameron-dwyer-windows-doc-multi-monitor-01-window-a-b

Its easy to dock window A to the left on monitor 1. Just drag the window to the left of the monitor and it will “snap” or dock to the left side and fill up half the screen.

cameron-dwyer-windows-doc-multi-monitor-02-drag-window-a-left

But now if we try to do the same with windows B, instead of docking the the right of monitor 1, the window just glides across onto monitor 2.

cameron-dwyer-windows-doc-multi-monitor-03-drag-window-b-rightcameron-dwyer-windows-doc-multi-monitor-04-window-pushes-across-monitor

The Solution

So how do we get window B to dock to the right side of monitor 1? First select window B then use the keyboard shortcut WINDOWS KEY + RIGHT ARROW.

cameron-dwyer-windows-doc-multi-monitor-05-win-plus-right

Simple as that.

Note: You can also use WINDOWS KEY + LEFT ARROW to dock to the left side of the current monitor. This can help you do the reverse (that is, if you are on monitor 2 and want to dock a window to the left side)

Follow

Get every new post delivered to your Inbox.

Join 170 other followers

%d bloggers like this: