mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { ModelViewBase } from './modelViewBase';
|
||||
import { ModelViewBase, ModelSourceType } from './modelViewBase';
|
||||
import { ApiWrapper } from '../../common/apiWrapper';
|
||||
import { AzureResourceFilterComponent } from './azureResourceFilterComponent';
|
||||
import { AzureModelsTable } from './azureModelsTable';
|
||||
@@ -92,11 +92,13 @@ export class AzureModelsComponent extends ModelViewBase implements IDataComponen
|
||||
}
|
||||
|
||||
public addComponents(formBuilder: azdata.FormBuilder) {
|
||||
this.removeComponents(formBuilder);
|
||||
if (this.azureFilterComponent?.accountIsValid) {
|
||||
this.addAzureComponents(formBuilder);
|
||||
} else {
|
||||
this.addAzureSignInComponents(formBuilder);
|
||||
if (this.modelSourceType === ModelSourceType.Azure) {
|
||||
this.removeComponents(formBuilder);
|
||||
if (this.azureFilterComponent?.accountIsValid) {
|
||||
this.addAzureComponents(formBuilder);
|
||||
} else {
|
||||
this.addAzureSignInComponents(formBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +168,7 @@ export class AzureModelsComponent extends ModelViewBase implements IDataComponen
|
||||
* Loads the data in the components
|
||||
*/
|
||||
public async loadData(): Promise<void> {
|
||||
await this.onLoaded();
|
||||
await this.azureFilterComponent?.loadData();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,18 +48,26 @@ export class AzureResourceFilterComponent extends ModelViewBase implements IData
|
||||
width: componentWidth
|
||||
}).component();
|
||||
|
||||
this._accounts.onValueChanged(async () => {
|
||||
await this.onAccountSelected();
|
||||
this._accounts.onValueChanged(async (newValue) => {
|
||||
if (newValue.selected !== (<azdata.CategoryValue>this._accounts.value)?.name) {
|
||||
await this.onAccountSelected();
|
||||
}
|
||||
});
|
||||
|
||||
this._subscriptions.onValueChanged(async () => {
|
||||
await this.onSubscriptionSelected();
|
||||
this._subscriptions.onValueChanged(async (newValue) => {
|
||||
if (newValue.selected !== (<azdata.CategoryValue>this._subscriptions.value)?.name) {
|
||||
await this.onSubscriptionSelected();
|
||||
}
|
||||
});
|
||||
this._groups.onValueChanged(async () => {
|
||||
await this.onGroupSelected();
|
||||
this._groups.onValueChanged(async (newValue) => {
|
||||
if (newValue.selected !== (<azdata.CategoryValue>this._groups.value)?.name) {
|
||||
await this.onGroupSelected();
|
||||
}
|
||||
});
|
||||
this._workspaces.onValueChanged(async () => {
|
||||
await this.onWorkspaceSelectedChanged();
|
||||
this._workspaces.onValueChanged(async (newValue) => {
|
||||
if (newValue.selected !== (<azdata.CategoryValue>this._workspaces.value)?.name) {
|
||||
await this.onWorkspaceSelectedChanged();
|
||||
}
|
||||
});
|
||||
|
||||
this._form = this._modelBuilder.formContainer().withFormItems([{
|
||||
@@ -174,6 +182,7 @@ export class AzureResourceFilterComponent extends ModelViewBase implements IData
|
||||
}
|
||||
|
||||
private async onGroupSelected(): Promise<void> {
|
||||
let currentWorkspace = this._workspaces.value;
|
||||
this._azureWorkspaces = await this.listWorkspaces(this.account, this.subscription, this.group);
|
||||
if (this._azureWorkspaces && this._azureWorkspaces.length > 0) {
|
||||
let values = this._azureWorkspaces.map(s => { return { displayName: s.name || '', name: s.id || '' }; });
|
||||
@@ -183,7 +192,9 @@ export class AzureResourceFilterComponent extends ModelViewBase implements IData
|
||||
this._workspaces.values = [];
|
||||
this._workspaces.value = undefined;
|
||||
}
|
||||
this.onWorkspaceSelectedChanged();
|
||||
if (currentWorkspace !== this._workspaces.value) {
|
||||
this.onWorkspaceSelectedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private onWorkspaceSelectedChanged(): void {
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as azdata from 'azdata';
|
||||
|
||||
import * as constants from '../../../common/constants';
|
||||
import { DataInfoComponent } from '../../dataInfoComponent';
|
||||
import { ModelActionType, ModelViewBase } from '../modelViewBase';
|
||||
import { ModelActionType, ModelViewBase, ModelSourceType } from '../modelViewBase';
|
||||
import { CurrentModelsTable } from './currentModelsTable';
|
||||
import { ApiWrapper } from '../../../common/apiWrapper';
|
||||
import { IPageView, IComponentSettings } from '../../interfaces';
|
||||
@@ -139,18 +139,20 @@ export class CurrentModelsComponent extends ModelViewBase implements IPageView {
|
||||
}
|
||||
|
||||
public addComponents(formBuilder: azdata.FormBuilder) {
|
||||
this._formBuilder = formBuilder;
|
||||
if (this._tableSelectionComponent && this._dataTable && this._tableDataCountContainer && this._labelContainer && this._subheadingContainer) {
|
||||
formBuilder.addFormItem({ title: '', component: this._subheadingContainer });
|
||||
this._tableSelectionComponent.addComponents(formBuilder);
|
||||
formBuilder.addFormItem({ title: '', component: this._tableDataCountContainer });
|
||||
this._dataTable.addComponents(formBuilder);
|
||||
if (this.modelSourceType === ModelSourceType.RegisteredModels) {
|
||||
this._formBuilder = formBuilder;
|
||||
if (this._tableSelectionComponent && this._dataTable && this._tableDataCountContainer && this._labelContainer && this._subheadingContainer) {
|
||||
formBuilder.addFormItem({ title: '', component: this._subheadingContainer });
|
||||
this._tableSelectionComponent.addComponents(formBuilder);
|
||||
formBuilder.addFormItem({ title: '', component: this._tableDataCountContainer });
|
||||
this._dataTable.addComponents(formBuilder);
|
||||
|
||||
if (this._dataTable.isEmpty) {
|
||||
formBuilder.addFormItem({ title: '', component: this._labelContainer });
|
||||
}
|
||||
if (this._tableDataCountComponent) {
|
||||
this._tableDataCountComponent.value = constants.getDataCount(this._dataTable.modelCounts);
|
||||
if (this._dataTable.isEmpty) {
|
||||
formBuilder.addFormItem({ title: '', component: this._labelContainer });
|
||||
}
|
||||
if (this._tableDataCountComponent) {
|
||||
this._tableDataCountComponent.value = constants.getDataCount(this._dataTable.modelCounts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { CurrentModelsComponent } from './currentModelsComponent';
|
||||
|
||||
import { ModelViewBase, RegisterModelEventName } from '../modelViewBase';
|
||||
import { ModelViewBase, RegisterModelEventName, ModelSourceType } from '../modelViewBase';
|
||||
import * as constants from '../../../common/constants';
|
||||
import { ApiWrapper } from '../../../common/apiWrapper';
|
||||
import { DialogView } from '../../dialogView';
|
||||
@@ -33,6 +33,7 @@ export class ManageModelsDialog extends ModelViewBase {
|
||||
editable: true,
|
||||
selectable: false
|
||||
});
|
||||
this.currentLanguagesTab.modelSourceType = ModelSourceType.RegisteredModels;
|
||||
|
||||
let registerModelButton = this._apiWrapper.createButton(constants.registerModelTitle);
|
||||
registerModelButton.onClick(async () => {
|
||||
|
||||
@@ -21,6 +21,7 @@ export class ModelBrowsePage extends ModelViewBase implements IPageView, IDataCo
|
||||
|
||||
private _form: azdata.FormContainer | undefined;
|
||||
private _title: string = constants.localModelPageTitle;
|
||||
private _currentModelSourceType: ModelSourceType | undefined;
|
||||
private _formBuilder: azdata.FormBuilder | undefined;
|
||||
public localModelsComponent: LocalModelsComponent | undefined;
|
||||
public azureModelsComponent: AzureModelsComponent | undefined;
|
||||
@@ -76,28 +77,32 @@ export class ModelBrowsePage extends ModelViewBase implements IPageView, IDataCo
|
||||
*/
|
||||
public async refresh(): Promise<void> {
|
||||
if (this._formBuilder) {
|
||||
if (this.modelSourceType === ModelSourceType.Local) {
|
||||
if (this.localModelsComponent && this.azureModelsComponent && this.registeredModelsComponent) {
|
||||
this.azureModelsComponent.removeComponents(this._formBuilder);
|
||||
this.registeredModelsComponent.removeComponents(this._formBuilder);
|
||||
await this.localModelsComponent.refresh();
|
||||
this.localModelsComponent.addComponents(this._formBuilder);
|
||||
}
|
||||
if (this._currentModelSourceType !== this.modelSourceType) {
|
||||
this._currentModelSourceType = this.modelSourceType;
|
||||
|
||||
} else if (this.modelSourceType === ModelSourceType.Azure) {
|
||||
if (this.localModelsComponent && this.azureModelsComponent && this.registeredModelsComponent) {
|
||||
this.localModelsComponent.removeComponents(this._formBuilder);
|
||||
await this.azureModelsComponent.refresh();
|
||||
this.azureModelsComponent.addComponents(this._formBuilder);
|
||||
this.registeredModelsComponent.removeComponents(this._formBuilder);
|
||||
}
|
||||
if (this.modelSourceType === ModelSourceType.Local) {
|
||||
if (this.localModelsComponent && this.azureModelsComponent && this.registeredModelsComponent) {
|
||||
this.azureModelsComponent.removeComponents(this._formBuilder);
|
||||
this.registeredModelsComponent.removeComponents(this._formBuilder);
|
||||
await this.localModelsComponent.refresh();
|
||||
this.localModelsComponent.addComponents(this._formBuilder);
|
||||
}
|
||||
|
||||
} else if (this.modelSourceType === ModelSourceType.RegisteredModels) {
|
||||
if (this.localModelsComponent && this.azureModelsComponent && this.registeredModelsComponent) {
|
||||
this.localModelsComponent.removeComponents(this._formBuilder);
|
||||
this.azureModelsComponent.removeComponents(this._formBuilder);
|
||||
await this.registeredModelsComponent.refresh();
|
||||
this.registeredModelsComponent.addComponents(this._formBuilder);
|
||||
} else if (this.modelSourceType === ModelSourceType.Azure) {
|
||||
if (this.localModelsComponent && this.azureModelsComponent && this.registeredModelsComponent) {
|
||||
this.localModelsComponent.removeComponents(this._formBuilder);
|
||||
this.registeredModelsComponent.removeComponents(this._formBuilder);
|
||||
await this.azureModelsComponent.refresh();
|
||||
this.azureModelsComponent.addComponents(this._formBuilder);
|
||||
}
|
||||
|
||||
} else if (this.modelSourceType === ModelSourceType.RegisteredModels) {
|
||||
if (this.localModelsComponent && this.azureModelsComponent && this.registeredModelsComponent) {
|
||||
this.localModelsComponent.removeComponents(this._formBuilder);
|
||||
this.azureModelsComponent.removeComponents(this._formBuilder);
|
||||
await this.registeredModelsComponent.refresh();
|
||||
this.registeredModelsComponent.addComponents(this._formBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user