mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Add Azure properties back to Arc dashboards (#12010)
* Add Azure properties back to dashboards * remove
This commit is contained in:
@@ -5,11 +5,12 @@
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as azurecore from 'azurecore';
|
||||
import * as loc from '../../../localizedConstants';
|
||||
import { DashboardPage } from '../../components/dashboardPage';
|
||||
import { IconPathHelper, cssStyles, iconSize, ResourceType, Endpoints } from '../../../constants';
|
||||
import { ControllerModel } from '../../../models/controllerModel';
|
||||
import { resourceTypeToDisplayName, getResourceTypeIcon, parseInstanceName } from '../../../common/utils';
|
||||
import { resourceTypeToDisplayName, getResourceTypeIcon, parseInstanceName, getConnectionModeDisplayText } from '../../../common/utils';
|
||||
|
||||
export class ControllerDashboardOverviewPage extends DashboardPage {
|
||||
|
||||
@@ -19,6 +20,10 @@ export class ControllerDashboardOverviewPage extends DashboardPage {
|
||||
private _arcResourcesTable!: azdata.DeclarativeTableComponent;
|
||||
private _propertiesContainer!: azdata.PropertiesContainerComponent;
|
||||
|
||||
private _openInAzurePortalButton!: azdata.ButtonComponent;
|
||||
|
||||
private _azurecoreApi: azurecore.IExtension;
|
||||
|
||||
private controllerProperties = {
|
||||
instanceName: '-',
|
||||
resourceGroupName: '-',
|
||||
@@ -32,6 +37,8 @@ export class ControllerDashboardOverviewPage extends DashboardPage {
|
||||
constructor(modelView: azdata.ModelView, private _controllerModel: ControllerModel) {
|
||||
super(modelView);
|
||||
|
||||
this._azurecoreApi = vscode.extensions.getExtension(azurecore.extension.name)?.exports;
|
||||
|
||||
this.disposables.push(
|
||||
this._controllerModel.onRegistrationsUpdated(() => this.eventuallyRunOnInitialized(() => this.handleRegistrationsUpdated())),
|
||||
this._controllerModel.onEndpointsUpdated(() => this.eventuallyRunOnInitialized(() => this.handleEndpointsUpdated())));
|
||||
@@ -160,22 +167,20 @@ export class ControllerDashboardOverviewPage extends DashboardPage {
|
||||
}
|
||||
}));
|
||||
|
||||
const openInAzurePortalButton = this.modelView.modelBuilder.button().withProperties<azdata.ButtonProperties>({
|
||||
this._openInAzurePortalButton = this.modelView.modelBuilder.button().withProperties<azdata.ButtonProperties>({
|
||||
label: loc.openInAzurePortal,
|
||||
iconPath: IconPathHelper.openInTab,
|
||||
enabled: false
|
||||
enabled: !!this._controllerModel.controllerConfig
|
||||
}).component();
|
||||
|
||||
this.disposables.push(
|
||||
openInAzurePortalButton.onDidClick(async () => {
|
||||
this._openInAzurePortalButton.onDidClick(async () => {
|
||||
const config = this._controllerModel.controllerConfig;
|
||||
if (config) {
|
||||
/* TODO CHGAGNON CONFIG
|
||||
vscode.env.openExternal(vscode.Uri.parse(
|
||||
`https://portal.azure.com/#resource/subscriptions/${config.subscriptionId}/resourceGroups/${config.resourceGroupName}/providers/Microsoft.AzureData/${ResourceType.dataControllers}/${config.instanceName}`));
|
||||
*/
|
||||
`https://portal.azure.com/#resource/subscriptions/${config.spec.settings.azure.subscription}/resourceGroups/${config.spec.settings.azure.resourceGroup}/providers/Microsoft.AzureData/${ResourceType.dataControllers}/${config.metadata.name}`));
|
||||
} else {
|
||||
vscode.window.showErrorMessage(loc.couldNotFindRegistration(this._controllerModel.namespace, 'controller'));
|
||||
vscode.window.showErrorMessage(loc.couldNotFindControllerRegistration);
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -183,18 +188,21 @@ export class ControllerDashboardOverviewPage extends DashboardPage {
|
||||
[
|
||||
{ component: newInstance },
|
||||
{ component: refreshButton, toolbarSeparatorAfter: true },
|
||||
{ component: openInAzurePortalButton }
|
||||
{ component: this._openInAzurePortalButton }
|
||||
]
|
||||
).component();
|
||||
}
|
||||
|
||||
private handleRegistrationsUpdated(): void {
|
||||
const config = this._controllerModel.controllerConfig;
|
||||
if (this._openInAzurePortalButton) {
|
||||
this._openInAzurePortalButton.enabled = !!config;
|
||||
}
|
||||
this.controllerProperties.instanceName = config?.metadata.name || this.controllerProperties.instanceName;
|
||||
this.controllerProperties.resourceGroupName = /* TODO CHGAGNON RG */ this.controllerProperties.resourceGroupName;
|
||||
this.controllerProperties.location = /* TODO CHGAGNON LOCATION */ this.controllerProperties.location;
|
||||
this.controllerProperties.subscriptionId = /* TODO CHGAGNON LOCATION */ this.controllerProperties.subscriptionId;
|
||||
this.controllerProperties.connectionMode = /* TODO CHGAGNON MODE getConnectionModeDisplayText(config?.connectionMode) || */ this.controllerProperties.connectionMode;
|
||||
this.controllerProperties.resourceGroupName = config?.spec.settings.azure.resourceGroup || this.controllerProperties.resourceGroupName;
|
||||
this.controllerProperties.location = this._azurecoreApi.getRegionDisplayName(config?.spec.settings.azure.location) || this.controllerProperties.location;
|
||||
this.controllerProperties.subscriptionId = config?.spec.settings.azure.subscription || this.controllerProperties.subscriptionId;
|
||||
this.controllerProperties.connectionMode = getConnectionModeDisplayText(config?.spec.settings.azure.connectionMode) || this.controllerProperties.connectionMode;
|
||||
this.controllerProperties.instanceNamespace = config?.metadata.namespace || this.controllerProperties.instanceNamespace;
|
||||
this.refreshDisplayedProperties();
|
||||
|
||||
|
||||
@@ -7,8 +7,9 @@ import * as azdata from 'azdata';
|
||||
import * as azdataExt from 'azdata-ext';
|
||||
import * as vscode from 'vscode';
|
||||
import * as loc from '../../../localizedConstants';
|
||||
import * as azurecore from 'azurecore';
|
||||
import { DashboardPage } from '../../components/dashboardPage';
|
||||
import { IconPathHelper, cssStyles, Endpoints } from '../../../constants';
|
||||
import { IconPathHelper, cssStyles, Endpoints, ResourceType } from '../../../constants';
|
||||
import { ControllerModel } from '../../../models/controllerModel';
|
||||
import { getDatabaseStateDisplayText, promptForResourceDeletion } from '../../../common/utils';
|
||||
import { MiaaModel } from '../../../models/miaaModel';
|
||||
@@ -25,8 +26,10 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
|
||||
private _grafanaLink!: azdata.HyperlinkComponent;
|
||||
private _databasesTable!: azdata.DeclarativeTableComponent;
|
||||
private _databasesMessage!: azdata.TextComponent;
|
||||
private _openInAzurePortalButton!: azdata.ButtonComponent;
|
||||
|
||||
private readonly _azdataApi: azdataExt.IExtension;
|
||||
private readonly _azurecoreApi: azurecore.IExtension;
|
||||
|
||||
private _instanceProperties = {
|
||||
resourceGroup: '-',
|
||||
@@ -42,6 +45,7 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
|
||||
constructor(modelView: azdata.ModelView, private _controllerModel: ControllerModel, private _miaaModel: MiaaModel) {
|
||||
super(modelView);
|
||||
this._azdataApi = vscode.extensions.getExtension(azdataExt.extension.name)?.exports;
|
||||
this._azurecoreApi = vscode.extensions.getExtension(azurecore.extension.name)?.exports;
|
||||
|
||||
this._instanceProperties.miaaAdmin = this._miaaModel.username || this._instanceProperties.miaaAdmin;
|
||||
this.disposables.push(
|
||||
@@ -226,46 +230,43 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
|
||||
}
|
||||
}));
|
||||
|
||||
const openInAzurePortalButton = this.modelView.modelBuilder.button().withProperties<azdata.ButtonProperties>({
|
||||
this._openInAzurePortalButton = this.modelView.modelBuilder.button().withProperties<azdata.ButtonProperties>({
|
||||
label: loc.openInAzurePortal,
|
||||
iconPath: IconPathHelper.openInTab
|
||||
iconPath: IconPathHelper.openInTab,
|
||||
enabled: !!this._controllerModel.controllerConfig
|
||||
}).component();
|
||||
|
||||
this.disposables.push(
|
||||
openInAzurePortalButton.onDidClick(async () => {
|
||||
/* TODO chgagnon enable open in Azure
|
||||
const r = this._controllerModel.getRegistration(ResourceType.sqlManagedInstances, this._miaaModel.info.namespace, this._miaaModel.info.name);
|
||||
if (r) {
|
||||
this._openInAzurePortalButton.onDidClick(async () => {
|
||||
const config = this._controllerModel.controllerConfig;
|
||||
if (config) {
|
||||
vscode.env.openExternal(vscode.Uri.parse(
|
||||
`https://portal.azure.com/#resource/subscriptions/${r.subscriptionId}/resourceGroups/${r.resourceGroupName}/providers/Microsoft.AzureData/${ResourceType.sqlManagedInstances}/${r.instanceName}`));
|
||||
`https://portal.azure.com/#resource/subscriptions/${config.spec.settings.azure.subscription}/resourceGroups/${config.spec.settings.azure.resourceGroup}/providers/Microsoft.AzureData/${ResourceType.sqlManagedInstances}/${this._miaaModel.info.name}`));
|
||||
} else {
|
||||
vscode.window.showErrorMessage(loc.couldNotFindRegistration(this._miaaModel.info.namespace, this._miaaModel.info.name));
|
||||
vscode.window.showErrorMessage(loc.couldNotFindControllerRegistration);
|
||||
}
|
||||
*/
|
||||
}));
|
||||
|
||||
return this.modelView.modelBuilder.toolbarContainer().withToolbarItems(
|
||||
[
|
||||
{ component: deleteButton },
|
||||
{ component: refreshButton, toolbarSeparatorAfter: true },
|
||||
{ component: openInAzurePortalButton }
|
||||
{ component: this._openInAzurePortalButton }
|
||||
]
|
||||
).component();
|
||||
}
|
||||
|
||||
private handleRegistrationsUpdated(): void {
|
||||
// TODO chgagnon
|
||||
/*
|
||||
const reg = this._controllerModel.getRegistration(ResourceType.sqlManagedInstances, this._miaaModel.info.namespace || '', this._miaaModel.info.name);
|
||||
if (reg) {
|
||||
this._instanceProperties.resourceGroup = reg.resourceGroupName || '-';
|
||||
this._instanceProperties.dataController = this._controllerModel.controllerConfig?.metadata.name || '-';
|
||||
this._instanceProperties.region = reg.region || '-';
|
||||
this._instanceProperties.subscriptionId = reg.subscriptionId || '-';
|
||||
this._instanceProperties.vCores = reg.vCores || '';
|
||||
this.refreshDisplayedProperties();
|
||||
const config = this._controllerModel.controllerConfig;
|
||||
if (this._openInAzurePortalButton) {
|
||||
this._openInAzurePortalButton.enabled = !!config;
|
||||
}
|
||||
*/
|
||||
this._instanceProperties.resourceGroup = config?.spec.settings.azure.resourceGroup || this._instanceProperties.resourceGroup;
|
||||
this._instanceProperties.dataController = config?.metadata.name || this._instanceProperties.dataController;
|
||||
this._instanceProperties.region = this._azurecoreApi.getRegionDisplayName(config?.spec.settings.azure.location) || this._instanceProperties.region;
|
||||
this._instanceProperties.subscriptionId = config?.spec.settings.azure.subscription || this._instanceProperties.subscriptionId;
|
||||
// this._instanceProperties.vCores = reg.vCores || '';
|
||||
this.refreshDisplayedProperties();
|
||||
}
|
||||
|
||||
private handleMiaaConfigUpdated(): void {
|
||||
|
||||
Reference in New Issue
Block a user