Manage your OneDrive using Radzen, MSGraph and Azure AD - Part I

This blog post demonstrates how to build with Radzen an Angular app that will access Microsoft OneDrive using Microsoft Graph API and Azure Active Directory authentication!

Creating the app and MSGraph data-source

Create a new Radzen application, add MSGraph data-source similar to our article and add Files.Read scopes/permissions.

ms-graph-datasource.png

Creating a page with Tree and DataGrid to browse OneDrive files and folders

  1. Create new page named OneDrive, drag and drop a Row and two Column component from Radzen toolbox. Set 3 and 9 for the size of first and second column. ms-graph-page1.png
  2. Call MSGraph data-source getDrives() method on page Load event and define two page properties getDrivesResult for the returned data and drive for the first drive in the collection. ms-graph-page2.png
  3. After getDrives() call invoke MSGraph data-source getDrivesRoot() method with ${drive.id} as parameter and define page property rootId to ${result.id}. ms-graph-page3.png
  4. Drag and drop Tree component from Radzen toolbox to the first column, bind it to getDrivesResult page property and define two levels using microsoft.graph.drive and microsoft.graph.driveItem schemas. Set owner.user.displayName for the first level Text property and name for the second level Text property. ms-graph-page4.png
  5. Call MSGraph data-source getDrivesItemsChildren() method on Tree component NodeExpand event with three parameters:
    • id = ${drive.id}.
    • driveItemId = ${event.level == 0 ? this.rootId : event.data.id}. Provide rootId or current node/item id depending on level.
    • $filter = file eq null. Filter drive items to return only folders. Execute ${event.children = result.value} after getDrivesItemsChildren() method call. ms-graph-page5.png
  6. Add new event handler to the Tree component NodeLoaded event and execute ${event.leaf = event.data.folder ? event.data.folder.childCount == 0 : false}. The tree node will not be expandable if there are no children. ms-graph-page6.png
  7. Add new event handler to the Tree component NodeSelect event, define selectedFolderId page property with value ${event.level == 0 ? this.rootId : event.data.id}, invoke getDrivesItemsChildren() method with two parameters:
    • id = ${drive.id}.
    • driveItemId = ${event.level == 0 ? this.rootId : event.data.id}. and set page property selectedItemChildren to ${result.value}. ms-graph-page7.png
  8. Drag and drop DataGrid component from Radzen toolbox to the second column, bind it to selectedItemChildren and define desired columns. Check AllowSorting and AllowFiltering. ms-graph-page8.png
  9. Run the application, login using your Microsoft credentials and browse your OneDrive files and folders. ms-graph-page9.png

Enjoy!

Leverage Radzen on LinkedIn

Yes, we are on LinkedIn and you should follow us!

Now, you have the opportunity to showcase your expertise by adding Radzen Blazor Studio and Radzen Blazor Components as skills to your LinkedIn profile. Present your skills to employers, collaborators, and clients.

All you have to do is go to our Products page on LinkedIn and click the + Add as skill button.

by Vladimir Enchev

Integration with 3rd party JavaScript libraries - Highcharts

This blog post demonstrates how to integrate a 3rd party JavaScript library in Radzen - the highly popular Highcharts!
Read more