Hook up MIAA dashboard overview (#10890)

* Hook up MIAA dashboard overview

* Fix merge conflicts

* Fix links

* Remove extra &
This commit is contained in:
Charles Gagnon
2020-06-15 11:25:31 -07:00
committed by GitHub
parent ff8b03aa5e
commit d9e70731f4
16 changed files with 335 additions and 126 deletions

View File

@@ -5,24 +5,72 @@
import * as azdata from 'azdata';
import * as vscode from 'vscode';
import { SqlInstanceRouterApi } from '../controller/generated/v1/api/sqlInstanceRouterApi';
import { HybridSqlNsNameGetResponse } from '../controller/generated/v1/model/hybridSqlNsNameGetResponse';
import { Authentication } from '../controller/generated/v1/api';
export type DatabaseModel = { name: string, status: string };
export class MiaaModel {
private _sqlInstanceRouter: SqlInstanceRouterApi;
private _status: HybridSqlNsNameGetResponse | undefined;
private readonly _onPasswordUpdated = new vscode.EventEmitter<string>();
private readonly _onStatusUpdated = new vscode.EventEmitter<HybridSqlNsNameGetResponse>();
private readonly _onDatabasesUpdated = new vscode.EventEmitter<DatabaseModel[]>();
public onPasswordUpdated = this._onPasswordUpdated.event;
public onStatusUpdated = this._onStatusUpdated.event;
public onDatabasesUpdated = this._onDatabasesUpdated.event;
public passwordLastUpdated?: Date;
constructor(public connectionProfile: azdata.IConnectionProfile, private _name: string) {
constructor(public connectionProfile: azdata.IConnectionProfile, controllerUrl: string, auth: Authentication, private _namespace: string, private _name: string) {
this._sqlInstanceRouter = new SqlInstanceRouterApi(controllerUrl);
this._sqlInstanceRouter.setDefaultAuthentication(auth);
}
/** Returns the service's name */
/**
* The name of this instance
*/
public get name(): string {
return this._name;
}
/**
* The namespace of this instance
*/
public get namespace(): string {
return this._namespace;
}
/**
* The status of this instance
*/
public get status(): string {
return this._status?.status || '';
}
/**
* The cluster endpoint of this instance
*/
public get clusterEndpoint(): string {
return this._status?.cluster_endpoint || '';
}
public get databases(): DatabaseModel[] {
return [
{ name: 'contosoMI54', status: 'online' },
{ name: 'contosoMI56', status: 'online' },
{ name: 'contosoMI58', status: 'online' },
];
}
/** Refreshes the model */
public async refresh() {
await Promise.all([
]);
public async refresh(): Promise<void> {
this._sqlInstanceRouter.apiV1HybridSqlNsNameGet(this._namespace, this._name).then(response => {
this._status = response.body;
this._onStatusUpdated.fire(this._status);
this._onDatabasesUpdated.fire(this.databases);
});
}
}