Skip to content

Commit

Permalink
adpot fluent team plugin for json schema from
Browse files Browse the repository at this point in the history
  • Loading branch information
YingXue committed Mar 9, 2023
1 parent 2dac53a commit 7c24bde
Show file tree
Hide file tree
Showing 21 changed files with 7,408 additions and 445 deletions.
405 changes: 389 additions & 16 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azure-iot-explorer",
"version": "0.15.7",
"version": "0.15.8",
"description": "This project welcomes contributions and suggestions. Most contributions require you to agree to a\r Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\r the rights to use your contribution. For details, visit https://cla.microsoft.com.",
"main": "host/electron.js",
"build": {
Expand Down Expand Up @@ -74,6 +74,8 @@
"@azure/msal-node": "1.14.6",
"@fluentui/react": "8.101.2",
"@microsoft/applicationinsights-web": "2.8.4",
"@rjsf/fluent-ui": "5.2.1",
"@rjsf/validator-ajv8": "5.2.1",
"azure-iot-common": "1.12.14",
"azure-iothub": "1.16.1",
"body-parser": "1.20.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ describe('DigitalTwinComponentList', () => {
expect(wrapper.find(Announced)).toHaveLength(0);

const list = wrapper.find('.component-list');
expect((list.props() as any).items[0].interfaceId).toEqual('dtmi:__DeviceManagement:DeviceInformation;1'); // tslint:disable-line:no-any
expect((list.props() as any).items[1].interfaceId).toEqual('dtmi:__Client:SDKInformation;1'); // tslint:disable-line:no-magic-numbers, no-any
expect((list.props() as any).items[2].interfaceId).toEqual('dtmi:__Contoso:EnvironmentalSensor;1'); // tslint:disable-line:no-magic-numbers, no-any
expect((list.props() as any).items[0].modelId).toEqual('dtmi:__DeviceManagement:DeviceInformation;1'); // tslint:disable-line:no-any
expect((list.props() as any).items[1].modelId).toEqual('dtmi:__Client:SDKInformation;1'); // tslint:disable-line:no-magic-numbers, no-any
expect((list.props() as any).items[2].modelId).toEqual('dtmi:__Contoso:EnvironmentalSensor;1'); // tslint:disable-line:no-magic-numbers, no-any

// tslint:disable-next-line: no-magic-numbers
expect(wrapper.find(PivotItem)).toHaveLength(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import './digitalTwinDetail.scss';
interface ModelContent {
link: string;
componentName: string;
interfaceId: string;
modelId: string;
}

export const DigitalTwinComponentList: React.FC = () => {
Expand All @@ -40,16 +40,16 @@ export const DigitalTwinComponentList: React.FC = () => {
let link = `${url}${ROUTE_PARTS.DIGITAL_TWINS_DETAIL}/${ROUTE_PARTS.INTERFACES}/` +
`?${ROUTE_PARAMS.DEVICE_ID}=${encodeURIComponent(deviceId)}` +
`&${ROUTE_PARAMS.COMPONENT_NAME}=${nameToId.componentName}` +
`&${ROUTE_PARAMS.INTERFACE_ID}=${nameToId.interfaceId}`;
`&${ROUTE_PARAMS.INTERFACE_ID}=${nameToId.modelId}`;
if (moduleId) {
link += `&${ROUTE_PARAMS.MODULE_ID}=${moduleId}`;
}

if (nameToId.componentName === DEFAULT_COMPONENT_FOR_DIGITAL_TWIN && nameToId.interfaceId === modelId) {
if (nameToId.componentName === DEFAULT_COMPONENT_FOR_DIGITAL_TWIN && nameToId.modelId === modelId) {
return{
componentName: t(ResourceKeys.digitalTwin.pivot.defaultComponent),
interfaceId: nameToId.interfaceId,
link
link,
modelId: nameToId.modelId
};
}
else {
Expand Down Expand Up @@ -92,7 +92,7 @@ export const DigitalTwinComponentList: React.FC = () => {
<Label
key={column.key}
>
{item.interfaceId}
{item.modelId}
</Label>
);
default:
Expand Down
8 changes: 4 additions & 4 deletions src/app/devices/pnp/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getDeviceIdFromQueryString, getModuleIdentityIdFromQueryString } from '
import { ROUTE_PARAMS } from '../../constants/routes';
import { getDeviceTwinAction, getModuleTwinAction } from './actions';
import { ModelDefinition } from '../../api/models/modelDefinition';
import { ComponentAndInterfaceId, JsonSchemaAdaptor } from '../../shared/utils/jsonSchemaAdaptor';
import { ComponentToModelId, JsonSchemaAdaptor } from '../../shared/utils/jsonSchemaAdaptor';
import { DEFAULT_COMPONENT_FOR_DIGITAL_TWIN } from '../../constants/devices';

export const getBackUrl = (path: string, search: string) => {
Expand All @@ -30,20 +30,20 @@ export const dispatchGetTwinAction = (search: string, dispatch: (action: any) =>
}
};

export const getComponentNameAndInterfaceIdArray = (modelDefinition: ModelDefinition): ComponentAndInterfaceId[] => {
export const getComponentNameAndInterfaceIdArray = (modelDefinition: ModelDefinition): ComponentToModelId[] => {
if (!modelDefinition) {
return [];
}
const jsonSchemaAdaptor = new JsonSchemaAdaptor(modelDefinition);
const components = jsonSchemaAdaptor.getComponentNameAndInterfaceIdArray();
const components = jsonSchemaAdaptor.getComponentNameToModelIdMapping();
// check if model contains no-component items
if (jsonSchemaAdaptor.getNonWritableProperties().length +
jsonSchemaAdaptor.getWritableProperties().length +
jsonSchemaAdaptor.getCommands().length +
jsonSchemaAdaptor.getTelemetry().length > 0) {
components.unshift({
componentName: DEFAULT_COMPONENT_FOR_DIGITAL_TWIN,
interfaceId: modelDefinition['@id']
modelId: modelDefinition['@id']
});
}
return components;
Expand Down
Loading

0 comments on commit 7c24bde

Please sign in to comment.