BDC Dashboard updates (#6888)

* BDC Dashboard updates

* PR comments
This commit is contained in:
Charles Gagnon
2019-08-22 17:14:59 -07:00
committed by GitHub
parent 82a8f09709
commit faabcb43f9
16 changed files with 446 additions and 295 deletions

View File

@@ -6,6 +6,33 @@
'use strict';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
export enum Endpoint {
gateway = 'gateway',
sparkHistory = 'spark-history',
yarnUi = 'yarn-ui',
appProxy = 'app-proxy',
mgmtproxy = 'mgmtproxy',
managementProxy = 'management-proxy',
logsui = 'logsui',
metricsui = 'metricsui',
controller = 'controller',
sqlServerMaster = 'sql-server-master',
webhdfs = 'webhdfs',
livy = 'livy'
}
export enum Service {
sql = 'sql',
hdfs = 'hdfs',
spark = 'spark',
control = 'control',
gateway = 'gateway',
app = 'app'
}
export function generateGuid(): string {
let hexValues: string[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];
@@ -41,3 +68,144 @@ export function showErrorMessage(error: any, prefixText?: string): void {
vscode.window.showErrorMessage(text);
}
}
/**
* Gets the localized text to display for a corresponding state
* @param state The state to get the display text for
*/
export function getStateDisplayText(state?: string): string {
state = state || '';
switch (state.toLowerCase()) {
case 'creating':
return localize('state.creating', "Creating");
case 'waiting':
return localize('state.waiting', "Waiting");
case 'ready':
return localize('state.ready', "Ready");
case 'deleting':
return localize('state.deleting', "Deleting");
case 'waitingfordeletion':
return localize('state.waitingForDeletion', "Waiting For Deletion");
case 'deleted':
return localize('state.deleted', "Deleted");
case 'upgrading':
return localize('state.upgrading', "Upgrading");
case 'waitingforupgrade':
return localize('state.waitingForUpgrade', "Waiting For Upgrade");
case 'error':
return localize('state.error', "Error");
case 'running':
return localize('state.running', "Running");
default:
return state;
}
}
/**
* Gets the localized text to display for a corresponding endpoint
* @param serviceName The endpoint name to get the display text for
* @param description The backup description to use if we don't have our own
*/
export function getEndpointDisplayText(endpointName?: string, description?: string): string {
endpointName = endpointName || '';
switch (endpointName.toLowerCase()) {
case Endpoint.appProxy:
return localize('endpoint.appproxy', "Application Proxy");
case Endpoint.controller:
return localize('endpoint.controller', "Controller");
case Endpoint.gateway:
return localize('endpoint.gateway', "HDFS/Spark Gateway");
case Endpoint.managementProxy:
return localize('endpoint.managementproxy', "Management Proxy");
case Endpoint.mgmtproxy:
return localize('endpoint.mgmtproxy', "Management Proxy");
case Endpoint.sqlServerMaster:
return localize('endpoint.sqlServerEndpoint', "SQL Server Master Instance");
case Endpoint.metricsui:
return localize('endpoint.grafana', "Metrics Dashboard");
case Endpoint.logsui:
return localize('endpoint.kibana', "Log Search Dashboard");
case Endpoint.yarnUi:
return localize('endpoint.yarnHistory', "Spark Resource Management");
case Endpoint.sparkHistory:
return localize('endpoint.sparkHistory', "Spark Job Monitoring");
case Endpoint.webhdfs:
return localize('endpoint.webhdfs', "HDFS File System Proxy");
case Endpoint.livy:
return localize('endpoint.livy', "Spark Proxy");
default:
// Default is to use the description if one was given, otherwise worst case just fall back to using the
// original service name
return description && description.length > 0 ? description : endpointName;
}
}
/**
* Gets the localized text to display for a corresponding service
* @param serviceName The service name to get the display text for
*/
export function getServiceNameDisplayText(serviceName?: string): string {
serviceName = serviceName || '';
switch (serviceName.toLowerCase()) {
case Service.sql:
return localize('service.sql', "SQL Server");
case Service.hdfs:
return localize('service.hdfs', "HDFS");
case Service.spark:
return localize('service.spark', "Spark");
case Service.control:
return localize('service.control', "Control");
case Service.gateway:
return localize('service.gateway', "Gateway");
case Service.app:
return localize('service.app', "App");
default:
return serviceName;
}
}
/**
* Gets the localized text to display for a corresponding health status
* @param healthStatus The health status to get the display text for
*/
export function getHealthStatusDisplayText(healthStatus?: string) {
healthStatus = healthStatus || '';
switch (healthStatus.toLowerCase()) {
case 'healthy':
return localize('bdc.healthy', "Healthy");
case 'unhealthy':
return localize('bdc.unhealthy', "Unhealthy");
default:
return healthStatus;
}
}
/**
* Returns the status icon for the corresponding health status
* @param healthStatus The status to check
*/
export function getHealthStatusIcon(healthStatus?: string): string {
healthStatus = healthStatus || '';
switch (healthStatus.toLowerCase()) {
case 'healthy':
return '✔️';
default:
// Consider all non-healthy status' as errors
return '⚠️';
}
}
/**
* Returns the status dot string which will be a • for all non-healthy states
* @param healthStatus The status to check
*/
export function getHealthStatusDot(healthStatus?: string): string {
healthStatus = healthStatus || '';
switch (healthStatus.toLowerCase()) {
case 'healthy':
return '';
default:
// Display status dot for all non-healthy status'
return '•';
}
}