mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 01:25:37 -05:00
Add refresh support to Arc Postgres pages (#10607)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { Authentication } from '../controller/auth';
|
||||
import { EndpointsRouterApi, EndpointModel, RegistrationRouterApi, RegistrationResponse, TokenRouterApi } from '../controller/generated/v1/api';
|
||||
|
||||
@@ -10,9 +11,16 @@ export class ControllerModel {
|
||||
private _endpointsRouter: EndpointsRouterApi;
|
||||
private _tokenRouter: TokenRouterApi;
|
||||
private _registrationRouter: RegistrationRouterApi;
|
||||
private _endpoints!: EndpointModel[];
|
||||
private _namespace!: string;
|
||||
private _registrations!: RegistrationResponse[];
|
||||
private _endpoints?: EndpointModel[];
|
||||
private _namespace?: string;
|
||||
private _registrations?: RegistrationResponse[];
|
||||
|
||||
private readonly _onEndpointsUpdated = new vscode.EventEmitter<EndpointModel[]>();
|
||||
private readonly _onRegistrationsUpdated = new vscode.EventEmitter<RegistrationResponse[]>();
|
||||
public onEndpointsUpdated = this._onEndpointsUpdated.event;
|
||||
public onRegistrationsUpdated = this._onRegistrationsUpdated.event;
|
||||
public endpointsLastUpdated?: Date;
|
||||
public registrationsLastUpdated?: Date;
|
||||
|
||||
constructor(controllerUrl: string, auth: Authentication) {
|
||||
this._endpointsRouter = new EndpointsRouterApi(controllerUrl);
|
||||
@@ -29,33 +37,36 @@ export class ControllerModel {
|
||||
await Promise.all([
|
||||
this._endpointsRouter.apiV1BdcEndpointsGet().then(response => {
|
||||
this._endpoints = response.body;
|
||||
this.endpointsLastUpdated = new Date();
|
||||
this._onEndpointsUpdated.fire(this._endpoints);
|
||||
}),
|
||||
this._tokenRouter.apiV1TokenPost().then(async response => {
|
||||
this._namespace = response.body.namespace!;
|
||||
this._registrations = (await this._registrationRouter.apiV1RegistrationListResourcesNsGet(this._namespace)).body;
|
||||
this.registrationsLastUpdated = new Date();
|
||||
this._onRegistrationsUpdated.fire(this._registrations);
|
||||
})
|
||||
]).then(async _ => {
|
||||
this._registrations = (await this._registrationRouter.apiV1RegistrationListResourcesNsGet(this._namespace)).body;
|
||||
});
|
||||
]);
|
||||
}
|
||||
|
||||
public endpoints(): EndpointModel[] {
|
||||
public endpoints(): EndpointModel[] | undefined {
|
||||
return this._endpoints;
|
||||
}
|
||||
|
||||
public endpoint(name: string): EndpointModel | undefined {
|
||||
return this._endpoints.find(e => e.name === name);
|
||||
return this._endpoints?.find(e => e.name === name);
|
||||
}
|
||||
|
||||
public namespace(): string {
|
||||
public namespace(): string | undefined {
|
||||
return this._namespace;
|
||||
}
|
||||
|
||||
public registrations(): RegistrationResponse[] {
|
||||
public registrations(): RegistrationResponse[] | undefined {
|
||||
return this._registrations;
|
||||
}
|
||||
|
||||
public registration(type: string, namespace: string, name: string): RegistrationResponse | undefined {
|
||||
return this._registrations.find(r => {
|
||||
return this._registrations?.find(r => {
|
||||
// Resources deployed outside the controller's namespace are named in the format 'namespace_name'
|
||||
let instanceName = r.instanceName!;
|
||||
const parts: string[] = instanceName.split('_');
|
||||
|
||||
Reference in New Issue
Block a user