Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Natraj Yegnaraman committed Sep 18, 2019
1 parent 3265c15 commit 4bbb059
Show file tree
Hide file tree
Showing 14 changed files with 7,011 additions and 12 deletions.
40 changes: 28 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
Expand All @@ -20,7 +16,6 @@ lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output
Expand All @@ -44,9 +39,6 @@ jspm_packages/
# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

Expand All @@ -64,7 +56,6 @@ typings/

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand All @@ -79,10 +70,35 @@ typings/
.vuepress/dist

# Serverless directories
.serverless/
.serverless

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/
# generated directory
**/generated

# output directory
/out

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
msbuild.log
msbuild.err
msbuild.wrn
45 changes: 45 additions & 0 deletions QR Code.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>QR Code</Name>
<ProjectGuid>40ab02ad-8f3d-48b1-9a47-6543ce463fa6</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="0.*"/>
</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>
46 changes: 46 additions & 0 deletions QRCode/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<manifest>
<control namespace="RYR.PCFQRCodeComponent" constructor="PCFQRCode" version="1.0.0" display-name-key="QRCode" description-key="QRCode description" control-type="standard">
<!-- property node identifies a specific, configurable piece of data that the control expects from CDS -->
<property name="content" display-name-key="Content" description-key="Content for generating QR Code" of-type="SingleLine.Text" usage="bound" required="false" />
<property name="backgroundColour" display-name-key="Background Colour" description-key="Background Colour" of-type="SingleLine.Text" usage="bound" required="false" />
<property name="foregroundColour" display-name-key="Foreground Colour" description-key="Foreground Colour" of-type="SingleLine.Text" usage="bound" required="false" />
<property name="size" display-name-key="Size" description-key="Size" of-type="Whole.None" usage="bound" required="false" />
<property name="errorCorrection" display-name-key="Error correction" description-key="Error correction" of-type="Enum" usage="input" required="false">
<value name="L" display-name-key="L" description-key="L">L</value>
<value name="M" display-name-key="M" description-key="M">M</value>
<value name="Q" display-name-key="Q" description-key="Q">Q</value>
<value name="H" display-name-key="H" description-key="H">H</value>
</property>
<!--
Property node's of-type attribute can be of-type-group attribute.
Example:
<type-group name="numbers">
<type>Whole.None</type>
<type>Currency</type>
<type>FP</type>
<type>Decimal</type>
</type-group>
<property name="sampleProperty" display-name-key="Property_Display_Key" description-key="Property_Desc_Key" of-type-group="numbers" usage="bound" required="true" />
-->
<resources>
<code path="index.ts" order="1"/>
<!-- UNCOMMENT TO ADD MORE RESOURCES
<css path="css/QRCode.css" order="1" />
<resx path="strings/QRCode.1033.resx" version="1.0.0" />
-->
</resources>
<!-- UNCOMMENT TO ENABLE THE SPECIFIED API
<feature-usage>
<uses-feature name="Device.captureAudio" required="true" />
<uses-feature name="Device.captureImage" required="true" />
<uses-feature name="Device.captureVideo" required="true" />
<uses-feature name="Device.getBarcodeValue" required="true" />
<uses-feature name="Device.getCurrentPosition" required="true" />
<uses-feature name="Device.pickFile" required="true" />
<uses-feature name="Utility" required="true" />
<uses-feature name="WebAPI" required="true" />
</feature-usage>
-->
</control>
</manifest>
41 changes: 41 additions & 0 deletions QRCode/QRCode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as React from "react";
import * as ReactQRCode from "qrcode.react";

export interface IQRProps {
value: string;
fgColor: string;
bgColor: string;
size: number;
level: "L" | "M" | "Q" | "H" | undefined;
onContentChanged?: (content: string) => void;
}

export function QRCode(props: IQRProps) {
const noContent: React.CSSProperties = {
color: props.fgColor,
boxShadow: "0 0 5px rgba(0, 0, 0, .2)",
background: props.bgColor,
width: `${props.size}px`,
height: `${props.size}px`,
display: "inline-flex",
justifyContent: "center",
alignItems: "center"
};
if (!props.value) {
return (
<div style={noContent}>
<span>No Content</span>
</div>
);
} else {
return (
<ReactQRCode
value={props.value}
bgColor={props.bgColor}
fgColor={props.fgColor}
level={props.level}
size={props.size}
></ReactQRCode>
);
}
}
82 changes: 82 additions & 0 deletions QRCode/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { IInputs, IOutputs } from "./generated/ManifestTypes";
import { QRCode, IQRProps } from "./QRCode";
import * as React from "react";
import * as ReactDOM from "react-dom";

export class PCFQRCode
implements ComponentFramework.StandardControl<IInputs, IOutputs> {
private _container: HTMLDivElement;
private _context: ComponentFramework.Context<IInputs>;
private _content: string;
private _notifyOutputChanged: () => void;
private _props: IQRProps = {
value: "",
bgColor: "#FFFFFF",
fgColor: "#000000",
size: 128,
level: "L"
};
private onContentChanged(content: string) {
this._content = content;
this._notifyOutputChanged();
}
/**
* Empty constructor.
*/
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
) {
context.mode.trackContainerResize(true);

this._container = container;
this._context = context;
this._props.onContentChanged = this.onContentChanged.bind(this);
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 {
// Add code to update control view
this._props.value = context.parameters.content.raw || "";
this._props.bgColor =
context.parameters.backgroundColour.raw || "#FFFFFF";
this._props.fgColor =
context.parameters.foregroundColour.raw || "#000000";
this._props.size = context.parameters.size.raw || 128;
this._props.level = context.parameters.errorCorrection.raw || "L";
ReactDOM.render(React.createElement(QRCode, this._props), this._container);
}

/**
* 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 {};
}

/**
* 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
ReactDOM.unmountComponentAtNode(this._container);
}
}
2 changes: 2 additions & 0 deletions Solution/PCFQRCode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin
/obj
17 changes: 17 additions & 0 deletions Solution/PCFQRCode/Other/Customizations.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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 />
<EntityDataProviders />
<Languages>
<Language>1033</Language>
</Languages>
</ImportExportXml>
2 changes: 2 additions & 0 deletions Solution/PCFQRCode/Other/Relationships.xml
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 4bbb059

Please sign in to comment.