Show interface ids instead of interface names (#380)
* Show interface ids instead of interface names * Resolve comment
This commit is contained in:
Родитель
3a465dea8e
Коммит
8727c20ea4
|
@ -34,10 +34,15 @@ export class InterfaceLabelNode implements INode {
|
||||||
"get",
|
"get",
|
||||||
))).data;
|
))).data;
|
||||||
TelemetryClient.sendEvent(Constants.IoTHubAILoadInterfacesTreeDoneEvent, { Result: "Success" });
|
TelemetryClient.sendEvent(Constants.IoTHubAILoadInterfacesTreeDoneEvent, { Result: "Success" });
|
||||||
if (!interfaces || !interfaces.interfaces || Object.keys(interfaces.interfaces).length === 0) {
|
let interfaceIds = [];
|
||||||
|
const reportedInterfaces = Utility.getReportedInterfacesFromDigitalTwin(interfaces);
|
||||||
|
if (reportedInterfaces) {
|
||||||
|
interfaceIds = Object.values(reportedInterfaces);
|
||||||
|
}
|
||||||
|
if (interfaceIds.length === 0) {
|
||||||
return [new InfoNode("No Interfaces")];
|
return [new InfoNode("No Interfaces")];
|
||||||
}
|
}
|
||||||
return Object.keys(interfaces.interfaces).map((name) => new InterfaceNode(name, context.asAbsolutePath(path.join("resources", `interface.svg`))));
|
return interfaceIds.map((name) => new InterfaceNode(name, context.asAbsolutePath(path.join("resources", `interface.svg`))));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
TelemetryClient.sendEvent(Constants.IoTHubAILoadInterfacesTreeDoneEvent, { Result: "Fail", Message: err.message });
|
TelemetryClient.sendEvent(Constants.IoTHubAILoadInterfacesTreeDoneEvent, { Result: "Fail", Message: err.message });
|
||||||
if (err.response && err.response.status === 400) {
|
if (err.response && err.response.status === 400) {
|
||||||
|
|
|
@ -125,6 +125,7 @@ export class Constants {
|
||||||
public static StateKeyIoTHubID = "iothubid";
|
public static StateKeyIoTHubID = "iothubid";
|
||||||
public static IoTHubAILoadInterfacesTreeStartEvent = "AZ.LoadInterfacesTree.Start";
|
public static IoTHubAILoadInterfacesTreeStartEvent = "AZ.LoadInterfacesTree.Start";
|
||||||
public static IoTHubAILoadInterfacesTreeDoneEvent = "AZ.LoadInterfacesTree.Done";
|
public static IoTHubAILoadInterfacesTreeDoneEvent = "AZ.LoadInterfacesTree.Done";
|
||||||
|
public static modelDiscoveryInterfaceName = "urn_azureiot_ModelDiscovery_DigitalTwin";
|
||||||
|
|
||||||
public static DeleteLabel = "Delete";
|
public static DeleteLabel = "Delete";
|
||||||
public static DeleteMessage = "Are you sure you want to delete"; public static readonly DISTRIBUTED_TWIN_NAME: string = "azureiot*com^dtracing^1";
|
public static DeleteMessage = "Are you sure you want to delete"; public static readonly DISTRIBUTED_TWIN_NAME: string = "azureiot*com^dtracing^1";
|
||||||
|
|
|
@ -434,6 +434,17 @@ export class Utility {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static getReportedInterfacesFromDigitalTwin(interfaces) {
|
||||||
|
return interfaces &&
|
||||||
|
interfaces.interfaces &&
|
||||||
|
interfaces.interfaces[Constants.modelDiscoveryInterfaceName] &&
|
||||||
|
interfaces.interfaces[Constants.modelDiscoveryInterfaceName].properties &&
|
||||||
|
interfaces.interfaces[Constants.modelDiscoveryInterfaceName].properties.modelInformation &&
|
||||||
|
interfaces.interfaces[Constants.modelDiscoveryInterfaceName].properties.modelInformation.reported &&
|
||||||
|
interfaces.interfaces[Constants.modelDiscoveryInterfaceName].properties.modelInformation.reported.value &&
|
||||||
|
interfaces.interfaces[Constants.modelDiscoveryInterfaceName].properties.modelInformation.reported.value.interfaces;
|
||||||
|
}
|
||||||
|
|
||||||
private static tryGetStringFromCharCode(source) {
|
private static tryGetStringFromCharCode(source) {
|
||||||
if (source instanceof Uint8Array) {
|
if (source instanceof Uint8Array) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"outDir": "out",
|
"outDir": "out",
|
||||||
"lib": [
|
"lib": [
|
||||||
"es6"
|
"es2017"
|
||||||
],
|
],
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"rootDir": "."
|
"rootDir": "."
|
||||||
|
|
Загрузка…
Ссылка в новой задаче