Use tooltip to show connection state (#362)

* Use tooltip to show connection state; Show running status even when module is disconnected

* Not show tooltip on Edge deivce
This commit is contained in:
Jun Han 2019-08-07 21:25:41 -05:00 коммит произвёл GitHub
Родитель 0726474519
Коммит 1788fb7d0c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -13,6 +13,7 @@ export class DeviceItem extends TreeItem implements QuickPickItem {
public description: string) {
super(deviceId);
this.contextValue = "device";
this.tooltip = this.connectionState;
this.collapsibleState = TreeItemCollapsibleState.Collapsed;
}
}

Просмотреть файл

@ -16,13 +16,14 @@ export class ModuleItem extends TreeItem {
public readonly contextValue: string) {
super(moduleId);
this.deviceId = deviceItem.deviceId;
this.tooltip = connectionState;
this.command = {
command: "azure-iot-toolkit.getModule",
title: "",
arguments: [this],
};
if (connectionState === "Connected") {
this.description = runtimeStatus ? `${connectionState} (${runtimeStatus})` : connectionState;
if (runtimeStatus) {
this.description = runtimeStatus;
}
}
}

Просмотреть файл

@ -200,12 +200,12 @@ export class Utility {
const moduleId = module.moduleId.substring(1);
if (desiredTwin.systemModules && desiredTwin.systemModules[moduleId]) {
return new ModuleItem(deviceItem, module.moduleId, module.connectionString, module.connectionState,
isConnected && reportedTwin ? this.getModuleRuntimeStatus(moduleId, reportedTwin.systemModules) : undefined, iconPath, "edge-module");
reportedTwin ? this.getModuleRuntimeStatus(moduleId, reportedTwin.systemModules) : undefined, iconPath, "edge-module");
}
} else {
if (desiredTwin.modules && desiredTwin.modules[module.moduleId]) {
return new ModuleItem(deviceItem, module.moduleId, module.connectionString, module.connectionState,
isConnected && reportedTwin ? this.getModuleRuntimeStatus(module.moduleId, reportedTwin.modules) : undefined, iconPath, "edge-module");
reportedTwin ? this.getModuleRuntimeStatus(module.moduleId, reportedTwin.modules) : undefined, iconPath, "edge-module");
}
}
const moduleType = module.moduleId.startsWith("$") ? "edge-module" : "module";
@ -292,13 +292,11 @@ export class Utility {
return deviceList.map((device) => {
const isConnected = device.connectionState.toString() === "Connected";
const state: string = isConnected ? "on" : "off";
if (isConnected) {
device.description = device.connectionState.toString();
}
let deviceType: string;
if (edgeDeviceIdSet.has(device.deviceId)) {
deviceType = "edge";
device.contextValue = "edge";
device.tooltip = "";
} else {
deviceType = "device";
}