Skip to content

Commit

Permalink
Merge pull request #106 from rwilson504/BrowserInfo
Browse files Browse the repository at this point in the history
Browser info
  • Loading branch information
rwilson504 authored Jul 18, 2020
2 parents 2a6a5c3 + c2c2368 commit 959d0b2
Show file tree
Hide file tree
Showing 26 changed files with 6,659 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CanvasFileUploader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ The default configuration will display a standard HTML file input control.
## Configure Using Canvas Button and Label
The standard HTML file input may not meet your needs for look/feel of your application. This component was designed to allow you to interact with it utilizing the already available Canvas controls that you are used to. Below is a demonstration on how to configure the Component utilizing a Canvas Button, Text Box, and Toggle control.

**Note for Firefox:** For this to work in Firefox you will need to add https://pa-content.azureedge.net to the list of exception for the popup blocker.

![Canvas Controls For Upload](./images/CanvasComponentUpload.png)

* To begin open the App -> OnStart function and set a variable for triggering the file browser to false.
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ Is an image component that will allow you to rotate the image which is not somet
[More...](./RotationalImage/README.md)
[Download Latest](https://github.com/rwilson504/PCFControls/releases/latest/download/RotationalImageComponent_managed.zip)

## Runtime Info

![Runtime Info](./RuntimeInfo/images/RuntimeInfo.png)

This component will allow you to get additional information about the browser and device running your Canvas App is running in.

[More...](./RuntimeImage/README.md)
[Download Latest](https://github.com/rwilson504/PCFControls/releases/latest/download/RuntimeInfoComponent_managed.zip)

## Custom Grid/Subgrid Using Office-UI-Fabric DetailsList

![DetailsList Grid Control](https://github.com/rwilson504/Blogger/blob/master/Office-Fabric-UI-DetailsList-PCF/office-fabric-ui-detailslist.gif?raw=true)
Expand Down
14 changes: 14 additions & 0 deletions RuntimeInfo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules

# generated directory
**/generated

# output directory
/out

# msbuild output directories
/bin
/obj
38 changes: 38 additions & 0 deletions RuntimeInfo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
RUNTIME INFO
================

This component will allow you to get additional information about the browser and device running your Canvas App is running in.

![RuntimeInfo](./images/RuntimeInfo.png)

## Installation/Usage

* Make sure you have enabled PCF components for Canvas apps in your environment. For instructions on that [Click Here](https://docs.microsoft.com/en-us/powerapps/developer/component-framework/component-framework-for-canvas-apps)

* In the Power Apps Editor ribbon navigate to **Insert -> Custom -> Import Components**
![Import Component](./images/ImportComponent.png)

* On the Import Component screen select the **Code** tab and Import the **RAW! Runtime Info**
![Import Component](./images/ImportComponentFromCode.png)

* Open the **Code components** area in the Insert panel and add the **RAW! Runtime Info** component to the form. The control itself will just be a blank space on the form. It is suggested you rename the Component you dropped on the form to make it easier to access.

![Rename Component](./images/EditComponentName.png)

![Rename Component](./images/EditComponentNameUpdateName.png)

* This component does not need any properties to be set. Instead it has a output properties which provide you with the details of the browser/device your Canvas app is running in. For additional details on the values which can be returned with these properties check out the [UAParser.js](https://github.com/faisalman/ua-parser-js) website which this component is build off of.
* Browser
* BrowserVersion
* Engine
* EngineVersion
* DeviceModel
* DeviceType
* DeviceVendor
* OperatingSystem
* OperatingSystemVersion
* CPUArchitecture
* UserAgent

* Once the control is on the for you can utilize the output parameters withing controls, functions, variables, etc.
![Component Outputs](./images/UtilizePropertyInTextField.png)
45 changes: 45 additions & 0 deletions RuntimeInfo/RuntimeInfo.pcfproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PowerAppsTargetsPath>$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\PowerApps</PowerAppsTargetsPath>
</PropertyGroup>

<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Pcf.props" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Pcf.props')"/>

<PropertyGroup>
<Name>RuntimeInfo</Name>
<ProjectGuid>031f9111-8394-4483-8db8-8cffac36460d</ProjectGuid>
<OutputPath>$(MSBuildThisFileDirectory)out\controls</OutputPath>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<!--Remove TargetFramework when this is available in 16.1-->
<TargetFramework>net462</TargetFramework>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.PowerApps.MSBuild.Pcf" Version="1.*"/>
</ItemGroup>

<ItemGroup>
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\.gitignore"/>
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\bin\**"/>
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\obj\**"/>
<ExcludeDirectories Include="$(OutputPath)\**"/>
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.pcfproj"/>
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.pcfproj.user"/>
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.sln"/>
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\node_modules\**"/>
</ItemGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\**" Exclude="@(ExcludeDirectories)"/>
</ItemGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Pcf.targets" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Pcf.targets')"/>

</Project>
20 changes: 20 additions & 0 deletions RuntimeInfo/RuntimeInfo/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<control namespace="RAW" constructor="RuntimeInfo" version="0.0.7" display-name-key="RAW! Runtime Info" description-key="Allows you to get some of the runtime information for the current running app." control-type="standard">
<!-- property node identifies a specific, configurable piece of data that the control expects from CDS -->
<property name="UserAgent" display-name-key="UserAgent" description-key="Provides the User Agent string" usage="output" of-type="SingleLine.Text" required="false" />
<property name="Browser" display-name-key="Browser" description-key="Browser Name" usage="output" of-type="SingleLine.Text" required="false" />
<property name="BrowserVersion" display-name-key="BrowserVersion" description-key="Browser Version" usage="output" of-type="SingleLine.Text" required="false" />
<property name="OperatingSystem" display-name-key="OperatingSystem" description-key="Operating System" usage="output" of-type="SingleLine.Text" required="false" />
<property name="OperatingSystemVersion" display-name-key="OperatingSystemVersion" description-key="Operating System Version" usage="output" of-type="SingleLine.Text" required="false" />
<property name="DeviceModel" display-name-key="DeviceModel" description-key="Device Model" usage="output" of-type="SingleLine.Text" required="false" />
<property name="DeviceType" display-name-key="DeviceModel" description-key="Device Model" usage="output" of-type="SingleLine.Text" required="false" />
<property name="DeviceVendor" display-name-key="DeviceVendor" description-key="Device Vendor" usage="output" of-type="SingleLine.Text" required="false" />
<property name="Engine" display-name-key="Engine" description-key="Engine Name" usage="output" of-type="SingleLine.Text" required="false" />
<property name="EngineVersion" display-name-key="EngineVersion" description-key="Engine Version" usage="output" of-type="SingleLine.Text" required="false" />
<property name="CPUArchitecture" display-name-key="CPUArchitecture" description-key="CPU Architecture" usage="output" of-type="SingleLine.Text" required="false" />
<resources>
<code path="index.ts" order="1" />
</resources>
</control>
</manifest>
1 change: 1 addition & 0 deletions RuntimeInfo/RuntimeInfo/browser-info.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'browser-info';
68 changes: 68 additions & 0 deletions RuntimeInfo/RuntimeInfo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import {IInputs, IOutputs} from "./generated/ManifestTypes";
import {UAParser} from 'ua-parser-js';
export class RuntimeInfo implements ComponentFramework.StandardControl<IInputs, IOutputs> {

private _uaResults: IUAParser.IResult;
private _notifyOutputChanged: () => void;

constructor()
{

}

/**
* Used to initialize the control instance. Controls can kick off remote server calls and other initialization actions here.
* Data-set values are not initialized here, use updateView.
* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to property names defined in the manifest, as well as utility functions.
* @param notifyOutputChanged A callback method to alert the framework that the control has new outputs ready to be retrieved asynchronously.
* @param state A piece of data that persists in one session for a single user. Can be set at any point in a controls life cycle by calling 'setControlState' in the Mode interface.
* @param container If a control is marked control-type='standard', it will receive an empty div element within which it can render its content.
*/
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement)
{
this._notifyOutputChanged = notifyOutputChanged;
}


/**
* Called when any value in the property bag has changed. This includes field values, data-sets, global values such as container height and width, offline status, control metadata values such as label, visible, etc.
* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to names defined in the manifest, as well as utility functions
*/
public updateView(context: ComponentFramework.Context<IInputs>): void
{
let ua = new UAParser();
this._uaResults = ua.getResult();

this._notifyOutputChanged();
}

/**
* It is called by the framework prior to a control receiving new data.
* @returns an object based on nomenclature defined in manifest, expecting object[s] for property marked as “bound” or “output”
*/
public getOutputs(): IOutputs
{
return {
UserAgent: this._uaResults.ua || '',
Browser: this._uaResults.browser.name || '',
BrowserVersion: this._uaResults.browser.version || '',
Engine: this._uaResults.engine.name || '',
EngineVersion: this._uaResults.engine.version || '',
OperatingSystem: this._uaResults.os.name || '',
OperatingSystemVersion: this._uaResults.os.version || '',
DeviceModel: this._uaResults.device.model || '',
DeviceType: this._uaResults.device.type || '',
DeviceVendor: this._uaResults.device.vendor || '',
CPUArchitecture: this._uaResults.cpu.architecture || ''
};
}

/**
* Called when the control is to be removed from the DOM tree. Controls should use this call for cleanup.
* i.e. cancelling any pending remote calls, removing listeners, etc.
*/
public destroy(): void
{
// Add code to cleanup control if necessary
}
}
5 changes: 5 additions & 0 deletions RuntimeInfo/Solution/RuntimeInfoComponent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# msbuild output directories
/bin
/obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PowerAppsTargetsPath>$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\PowerApps</PowerAppsTargetsPath>
</PropertyGroup>

<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.props" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.props')" />

<PropertyGroup>
<ProjectGuid>d33d6ff1-df82-46ee-acaa-637acc509723</ProjectGuid>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<!--Remove TargetFramework when this is available in 16.1-->
<TargetFramework>net462</TargetFramework>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<SolutionRootPath>src</SolutionRootPath>
</PropertyGroup>


<PropertyGroup>
<SolutionPackageType>Both</SolutionPackageType>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="Microsoft.PowerApps.MSBuild.Solution" Version="1.*" />
</ItemGroup>

<ItemGroup>
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\.gitignore" />
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\bin\**" />
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\obj\**" />
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.cdsproj" />
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.cdsproj.user" />
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.sln" />
</ItemGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\**" Exclude="@(ExcludeDirectories)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\RuntimeInfo.pcfproj" />
</ItemGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.targets" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.targets')" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<ImportExportXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Entities />
<Roles />
<Workflows />
<FieldSecurityProfiles />
<Templates />
<EntityMaps />
<EntityRelationships />
<OrganizationSettings />
<optionsets />
<CustomControls />
<SolutionPluginAssemblies />
<EntityDataProviders />
<Languages>
<Language>1033</Language>
</Languages>
</ImportExportXml>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<EntityRelationships xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
Loading

0 comments on commit 959d0b2

Please sign in to comment.