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",
|
||||
))).data;
|
||||
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 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) {
|
||||
TelemetryClient.sendEvent(Constants.IoTHubAILoadInterfacesTreeDoneEvent, { Result: "Fail", Message: err.message });
|
||||
if (err.response && err.response.status === 400) {
|
||||
|
|
|
@ -125,6 +125,7 @@ export class Constants {
|
|||
public static StateKeyIoTHubID = "iothubid";
|
||||
public static IoTHubAILoadInterfacesTreeStartEvent = "AZ.LoadInterfacesTree.Start";
|
||||
public static IoTHubAILoadInterfacesTreeDoneEvent = "AZ.LoadInterfacesTree.Done";
|
||||
public static modelDiscoveryInterfaceName = "urn_azureiot_ModelDiscovery_DigitalTwin";
|
||||
|
||||
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";
|
||||
|
|
|
@ -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) {
|
||||
if (source instanceof Uint8Array) {
|
||||
try {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"target": "es6",
|
||||
"outDir": "out",
|
||||
"lib": [
|
||||
"es6"
|
||||
"es2017"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"rootDir": "."
|
||||
|
|
Загрузка…
Ссылка в новой задаче