forked from Azure/azure-iot-explorer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the QR code generating bits for mobile app
- Loading branch information
Showing
12 changed files
with
194 additions
and
14 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.qrCodeGeneration { | ||
text-align: center; | ||
.storeLinks { | ||
padding-top: 20px; | ||
} | ||
.qrCode { | ||
padding:5px; | ||
background-color: white; | ||
width: 200px; | ||
height: 200px; | ||
border-radius: 8px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/app/devices/deviceIdentity/components/__snapshots__/qrGenerationView.spec.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`DeviceModules matches snapshot 1`] = ` | ||
<Component | ||
expanded={false} | ||
label="deviceIdentity.qrCode.label" | ||
tooltipText="deviceIdentity.qrCode.toolTip" | ||
> | ||
<div | ||
className="qrCodeGeneration" | ||
> | ||
<section | ||
className="storeLinks" | ||
> | ||
<StyledLinkBase | ||
href="https://play.google.com/store/apps/details?id=com.iot_pnp" | ||
target="_blank" | ||
> | ||
<img | ||
src="images/qrCodes/playstore.png" | ||
/> | ||
</StyledLinkBase> | ||
<StyledLinkBase | ||
href="https://apps.apple.com/app/iot-plug-and-play/id1563783687" | ||
target="_blank" | ||
> | ||
<img | ||
src="images/qrCodes/appstore.png" | ||
/> | ||
</StyledLinkBase> | ||
</section> | ||
<section> | ||
<div | ||
className="qrCode" | ||
> | ||
<Memo(QRCode) | ||
size={200} | ||
value="eyJkZXZpY2VJZCI6InNvbWVfZGV2aWNlIiwiZGV2aWNlS2V5IjoiaW52YWxpZF9kZXZpY2Vfa2V5IiwiaG9zdE5hbWUiOiJpbnZhbGlkX2hvc3QifQ==" | ||
/> | ||
</div> | ||
</section> | ||
</div> | ||
</Component> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/app/devices/deviceIdentity/components/qrGenerationView.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/*********************************************************** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License | ||
**********************************************************/ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { QrGenerationView } from './qrGenerationView'; | ||
|
||
describe('DeviceModules', () => { | ||
it('matches snapshot', () => { | ||
expect(shallow( | ||
<QrGenerationView | ||
deviceId="some_device" | ||
deviceKey="invalid_device_key" | ||
hostName="invalid_host" | ||
/> | ||
)).toMatchSnapshot(); | ||
}); | ||
}); |
58 changes: 58 additions & 0 deletions
58
src/app/devices/deviceIdentity/components/qrGenerationView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*********************************************************** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License | ||
**********************************************************/ | ||
import * as React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Link } from '@fluentui/react'; | ||
import QRCode from 'react-qr-code'; | ||
import { CollapsibleSection } from '../../../shared/components/collapsibleSection'; | ||
import '../../../css/_qrGeneration.scss'; | ||
import { ResourceKeys } from '../../../../localization/resourceKeys'; | ||
|
||
const QR_SIZE = 200; | ||
|
||
export interface QrGenerationDataProps { | ||
hostName: string; | ||
deviceId: string; | ||
deviceKey: string; | ||
} | ||
export const QrGenerationView: React.FC<QrGenerationDataProps> = (props: QrGenerationDataProps) => { | ||
const { t } = useTranslation(); | ||
const { deviceId, deviceKey, hostName } = props; | ||
const connection = Buffer.from(JSON.stringify({ | ||
deviceId, | ||
deviceKey, | ||
hostName | ||
})).toString('base64'); | ||
|
||
return ( | ||
<CollapsibleSection | ||
expanded={false} | ||
label={t(ResourceKeys.deviceIdentity.qrCode.label)} | ||
tooltipText={t(ResourceKeys.deviceIdentity.qrCode.toolTip)} | ||
> | ||
<div className="qrCodeGeneration"> | ||
<section className="storeLinks"> | ||
<Link | ||
href="https://play.google.com/store/apps/details?id=com.iot_pnp" | ||
target="_blank" | ||
> | ||
<img src="images/qrCodes/playstore.png" /> | ||
</Link> | ||
<Link | ||
href="https://apps.apple.com/app/iot-plug-and-play/id1563783687" | ||
target="_blank" | ||
> | ||
<img src="images/qrCodes/appstore.png" /> | ||
</Link> | ||
</section> | ||
<section> | ||
<div className="qrCode"> | ||
<QRCode value={connection} size={QR_SIZE} /> | ||
</div> | ||
</section> | ||
</div> | ||
</CollapsibleSection> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters