Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding mgt-get #187

Merged
merged 7 commits into from
Oct 21, 2019
Merged

Adding mgt-get #187

merged 7 commits into from
Oct 21, 2019

Conversation

nmetulev
Copy link
Contributor

Closes #160

PR Type

  • Feature

Description of the changes

mgt-get allows you to make any GET query from Microsoft Graph directly in your HTML. The component does not provide a default UI and requires the developer to write a template.

Example

<mgt-get resource="/me/messages" version="beta" scopes="mail.read" max-pages="2">
  <template>
    emails: {{value.length}}
  </template>
  <template data-type="loading">
    loading
  </template>
</mgt-get>

Properties and Attributes

The only required attribute is resource. However, you can use several properties to change the behavior.

Property Attribute Description
resource resource The resource to get from Microsoft Graph (ex: /me)
scopes scopes Optional array of strings if using the property or a comma delimited scopes if using the attribute. The component will use these scopes (with a supported provider) to ensure the user has consented to the right permission
version version Optional API version to use when making the GET request. Default is v1.0.
maxPages max-pages Optional number of pages (for resources that support paging). Default is 3. Setting this value to 0 will GET all pages
response N/A The raw response from Microsoft Graph
error N/A The raw error from Microsoft Graph

Events

Event Detail Description
dataChange The detail contains the response and error objects Fired when the response or error change

Templates

The mgt-get component supports several templates that you can use to define the look and feel. To specify a template, include a <template> element inside a component and set the data-type value to one of the following.

Data type Data context Description
default a raw response from Microsoft Graph The default template is required to render the data coming from Microsoft Graph
error the raw error from Microsoft Graph This template will be used if there is an error making the request
loading N/A This template is used while the request is being made

Other information

This PR also adds support for using {{this}} in the templates to print the entire data context

@nmetulev nmetulev requested a review from vogtn October 18, 2019 16:33
request = request.middlewareOptions(prepScopes(...this.scopes));
}

response = await request.get();
Copy link
Contributor

@michael-hawker michael-hawker Oct 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the UI update at this point when this is set or wait until the rest of the pages are fetched? (Ah, saw after this is the local response, so no, eh? Do we want to change this?)

It'd be nice if the control could start loading at this point and show the first set of items while the rest are fetched?

Thinking from the XAML side of just having an Observable Collection, so items will be added in batches as the data is fetched and the UI updates as they come in?

@michael-hawker
Copy link
Contributor

FYI, have a prototype of this working for the .NET controls too see here.

@vogtn vogtn merged commit 12204b0 into master Oct 21, 2019
@nmetulev nmetulev mentioned this pull request Oct 28, 2019
14 tasks
@nmetulev nmetulev deleted the nmetulev/mgt-get branch December 13, 2019 22:28
shweaver-MSFT pushed a commit that referenced this pull request Jun 8, 2020
shweaver-MSFT pushed a commit that referenced this pull request Jun 10, 2020
shweaver-MSFT pushed a commit that referenced this pull request Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a component to make any Microsoft Graph query
3 participants