mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-12 12:01:37 -04:00
Fix Arc Postgres refresh (#11074)
This commit is contained in:
@@ -7,22 +7,23 @@ import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import * as loc from '../../../localizedConstants';
|
||||
import { IconPathHelper, cssStyles, ResourceType } from '../../../constants';
|
||||
import { KeyValueContainer, InputKeyValue, LinkKeyValue, TextKeyValue } from '../../components/keyValueContainer';
|
||||
import { KeyValueContainer, InputKeyValue, TextKeyValue, KeyValue } from '../../components/keyValueContainer';
|
||||
import { DashboardPage } from '../../components/dashboardPage';
|
||||
import { ControllerModel } from '../../../models/controllerModel';
|
||||
import { PostgresModel } from '../../../models/postgresModel';
|
||||
|
||||
export class PostgresPropertiesPage extends DashboardPage {
|
||||
private loading?: azdata.LoadingComponent;
|
||||
private keyValueContainer?: KeyValueContainer;
|
||||
|
||||
constructor(protected modelView: azdata.ModelView, private _controllerModel: ControllerModel, private _postgresModel: PostgresModel) {
|
||||
super(modelView);
|
||||
|
||||
this.disposables.push(this._postgresModel.onServiceUpdated(
|
||||
() => this.eventuallyRunOnInitialized(() => this.refresh())));
|
||||
() => this.eventuallyRunOnInitialized(() => this.handleServiceUpdated())));
|
||||
|
||||
this.disposables.push(this._controllerModel.onRegistrationsUpdated(
|
||||
() => this.eventuallyRunOnInitialized(() => this.refresh())));
|
||||
() => this.eventuallyRunOnInitialized(() => this.handleRegistrationsUpdated())));
|
||||
}
|
||||
|
||||
protected get title(): string {
|
||||
@@ -47,8 +48,14 @@ export class PostgresPropertiesPage extends DashboardPage {
|
||||
CSSStyles: { ...cssStyles.title, 'margin-bottom': '25px' }
|
||||
}).component());
|
||||
|
||||
this.keyValueContainer = new KeyValueContainer(this.modelView.modelBuilder, []);
|
||||
content.addItem(this.keyValueContainer.container);
|
||||
this.keyValueContainer = new KeyValueContainer(this.modelView.modelBuilder, this.getProperties());
|
||||
this.loading = this.modelView.modelBuilder.loadingComponent()
|
||||
.withItem(this.keyValueContainer.container)
|
||||
.withProperties<azdata.LoadingComponentProperties>({
|
||||
loading: !this._postgresModel.serviceLastUpdated && !this._controllerModel.registrationsLastUpdated
|
||||
}).component();
|
||||
|
||||
content.addItem(this.loading);
|
||||
this.initialized = true;
|
||||
return root;
|
||||
}
|
||||
@@ -63,6 +70,7 @@ export class PostgresPropertiesPage extends DashboardPage {
|
||||
refreshButton.onDidClick(async () => {
|
||||
refreshButton.enabled = false;
|
||||
try {
|
||||
this.loading!.loading = true;
|
||||
await Promise.all([
|
||||
this._postgresModel.refresh(),
|
||||
this._controllerModel.refresh()
|
||||
@@ -80,20 +88,31 @@ export class PostgresPropertiesPage extends DashboardPage {
|
||||
]).component();
|
||||
}
|
||||
|
||||
private refresh() {
|
||||
private getProperties(): KeyValue[] {
|
||||
const endpoint: { ip?: string, port?: number } = this._postgresModel.endpoint;
|
||||
const connectionString = `postgresql://postgres@${endpoint.ip}:${endpoint.port}`;
|
||||
const registration = this._controllerModel.getRegistration(ResourceType.postgresInstances, this._postgresModel.namespace, this._postgresModel.name);
|
||||
|
||||
this.keyValueContainer?.refresh([
|
||||
return [
|
||||
new InputKeyValue(loc.coordinatorEndpoint, connectionString),
|
||||
new InputKeyValue(loc.postgresAdminUsername, 'postgres'),
|
||||
new TextKeyValue(loc.status, this._postgresModel.service?.status?.state ?? 'Unknown'),
|
||||
new LinkKeyValue(loc.dataController, this._controllerModel.namespace ?? '', _ => vscode.window.showInformationMessage('TODO: Go to data controller')),
|
||||
// TODO: Make this a LinkKeyValue that opens the controller dashboard
|
||||
new TextKeyValue(loc.dataController, this._controllerModel.namespace ?? ''),
|
||||
new TextKeyValue(loc.nodeConfiguration, this._postgresModel.configuration),
|
||||
new TextKeyValue(loc.postgresVersion, this._postgresModel.service?.spec?.engine?.version?.toString() ?? ''),
|
||||
new TextKeyValue(loc.resourceGroup, registration?.resourceGroupName ?? ''),
|
||||
new TextKeyValue(loc.subscriptionId, registration?.subscriptionId ?? '')
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
private handleRegistrationsUpdated() {
|
||||
this.keyValueContainer?.refresh(this.getProperties());
|
||||
this.loading!.loading = false;
|
||||
}
|
||||
|
||||
private handleServiceUpdated() {
|
||||
this.keyValueContainer?.refresh(this.getProperties());
|
||||
this.loading!.loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user