Remove properties widget height calculations (#10152)

* Remove height calculations

* Remove custom height setting

* Fix compile errors
This commit is contained in:
Charles Gagnon
2020-04-24 11:36:45 -07:00
committed by GitHub
parent 1e8a9c47cb
commit a018058169
11 changed files with 43 additions and 44 deletions

View File

@@ -14,7 +14,7 @@ const DefaultLoadingCompletedMessage = nls.localize('loadingCompletedMessage', "
@Component({ @Component({
selector: 'loading-spinner', selector: 'loading-spinner',
template: ` template: `
<div class="loading-spinner-container" *ngIf="loading"> <div class="loading-spinner-container">
<div class="loading-spinner codicon in-progress" *ngIf="loading" [title]="_loadingMessage" #spinnerElement></div> <div class="loading-spinner codicon in-progress" *ngIf="loading" [title]="_loadingMessage" #spinnerElement></div>
</div> </div>
` `

View File

@@ -3,6 +3,11 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
loading-spinner {
width: 100%;
display: inline-block;
}
loading-spinner .loading-spinner-container { loading-spinner .loading-spinner-container {
display: flex; display: flex;
flex-direction: row; flex-direction: row;

View File

@@ -3,6 +3,19 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
properties-container {
display: block;
}
properties-container .grid-container {
width: 100%;
display: grid;
}
properties-container .property {
display:flex;
}
properties-container .twoColumns.grid-container { properties-container .twoColumns.grid-container {
grid-template-columns: 50% 50%; grid-template-columns: 50% 50%;
} }

View File

@@ -4,9 +4,9 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
--> -->
<div class="grid-container {{gridDisplayLayout}}" style="position: absolute; height: 100%; width: 100%;" [style.display]="_loading ? 'none':'grid'"> <div class="grid-container {{gridDisplayLayout}}">
<ng-template ngFor let-item [ngForOf]="propertyItems"> <ng-template ngFor let-item [ngForOf]="propertyItems">
<div class="property {{propertyLayout}}" style="display:flex"> <div class="property {{propertyLayout}}">
<div class="propertyName">{{item.displayName}}</div> <div class="propertyName">{{item.displayName}}</div>
<div class="splitter">:</div> <div class="splitter">:</div>
<div class="propertyValue">{{item.value}}</div> <div class="propertyValue">{{item.value}}</div>

View File

@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/propertiesContainer'; import 'vs/css!./media/propertiesContainer';
import { Component, Inject, forwardRef, ChangeDetectorRef, OnInit, ElementRef, OnDestroy } from '@angular/core'; import { Component, Inject, forwardRef, ChangeDetectorRef, OnInit, OnDestroy } from '@angular/core';
import { EventType, addDisposableListener } from 'vs/base/browser/dom'; import * as DOM from 'vs/base/browser/dom';
import { Disposable } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
enum GridDisplayLayout { enum GridDisplayLayout {
@@ -23,10 +23,6 @@ export interface PropertyItem {
value: string; value: string;
} }
const collapseHeight = 25;
const horizontalPropertyHeight = 28;
const verticalPropertyHeight = 46;
@Component({ @Component({
selector: 'properties-container', selector: 'properties-container',
templateUrl: decodeURI(require.toUrl('./propertiesContainer.component.html')) templateUrl: decodeURI(require.toUrl('./propertiesContainer.component.html'))
@@ -34,18 +30,16 @@ const verticalPropertyHeight = 46;
export class PropertiesContainer extends Disposable implements OnInit, OnDestroy { export class PropertiesContainer extends Disposable implements OnInit, OnDestroy {
public gridDisplayLayout = GridDisplayLayout.twoColumns; public gridDisplayLayout = GridDisplayLayout.twoColumns;
public propertyLayout = PropertyLayoutDirection.row; public propertyLayout = PropertyLayoutDirection.row;
public height: number;
private _propertyItems: PropertyItem[] = []; private _propertyItems: PropertyItem[] = [];
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef
@Inject(forwardRef(() => ElementRef)) el: ElementRef
) { ) {
super(); super();
} }
ngOnInit() { ngOnInit() {
this._register(addDisposableListener(window, EventType.RESIZE, () => this.layoutPropertyItems())); this._register(DOM.addDisposableListener(window, DOM.EventType.RESIZE, () => this.layoutPropertyItems()));
this._changeRef.detectChanges(); this._changeRef.detectChanges();
} }
@@ -61,15 +55,12 @@ export class PropertiesContainer extends Disposable implements OnInit, OnDestroy
if (window.innerWidth >= 1366) { if (window.innerWidth >= 1366) {
this.gridDisplayLayout = GridDisplayLayout.twoColumns; this.gridDisplayLayout = GridDisplayLayout.twoColumns;
this.propertyLayout = PropertyLayoutDirection.row; this.propertyLayout = PropertyLayoutDirection.row;
this.height = Math.ceil(this.propertyItems.length / 2) * horizontalPropertyHeight + collapseHeight;
} else if (window.innerWidth < 1366 && window.innerWidth >= 1024) { } else if (window.innerWidth < 1366 && window.innerWidth >= 1024) {
this.gridDisplayLayout = GridDisplayLayout.twoColumns; this.gridDisplayLayout = GridDisplayLayout.twoColumns;
this.propertyLayout = PropertyLayoutDirection.column; this.propertyLayout = PropertyLayoutDirection.column;
this.height = Math.ceil(this.propertyItems.length / 2) * verticalPropertyHeight + collapseHeight;
} else if (window.innerWidth < 1024) { } else if (window.innerWidth < 1024) {
this.gridDisplayLayout = GridDisplayLayout.oneColumn; this.gridDisplayLayout = GridDisplayLayout.oneColumn;
this.propertyLayout = PropertyLayoutDirection.column; this.propertyLayout = PropertyLayoutDirection.column;
this.height = this.propertyItems.length * verticalPropertyHeight + collapseHeight;
} }
this._changeRef.detectChanges(); this._changeRef.detectChanges();

View File

@@ -0,0 +1,9 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
modelview-properties-container properties-container {
display: inline-block;
width: 100%;
}

View File

@@ -3,6 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/propertiesContainer';
import { import {
Component, Input, Inject, ChangeDetectorRef, forwardRef, Component, Input, Inject, ChangeDetectorRef, forwardRef,
ViewChild, ElementRef, OnDestroy ViewChild, ElementRef, OnDestroy

View File

@@ -21,7 +21,6 @@ import { DASHBOARD_BORDER } from 'vs/workbench/common/theme';
import { IColorTheme } from 'vs/platform/theme/common/themeService'; import { IColorTheme } from 'vs/platform/theme/common/themeService';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry'; import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { PropertiesWidgetComponent } from 'sql/workbench/contrib/dashboard/browser/widgets/properties/propertiesWidget.component';
@Component({ @Component({
selector: 'dashboard-home-container', selector: 'dashboard-home-container',
@@ -30,8 +29,7 @@ import { PropertiesWidgetComponent } from 'sql/workbench/contrib/dashboard/brows
<div class="fullsize" style="display: flex; flex-direction: column"> <div class="fullsize" style="display: flex; flex-direction: column">
<div> <div>
<div #propertiesContainer> <div #propertiesContainer>
<dashboard-widget-wrapper #propertiesClass *ngIf="properties" [collapsable]="true" [bottomCollapse]="true" [toggleMore]="false" [_config]="properties" <dashboard-widget-wrapper #propertiesClass *ngIf="properties" [collapsable]="true" [bottomCollapse]="true" [toggleMore]="false" [_config]="properties" class="properties">
class="properties" [style.height.px]="_propertiesClass?.collapsed ? '30' : getHeight()">
</dashboard-widget-wrapper> </dashboard-widget-wrapper>
</div> </div>
<widget-content style="flex: 1" [scrollContent]="false" [widgets]="widgets" [originalConfig]="tab.originalConfig" [context]="tab.context"> <widget-content style="flex: 1" [scrollContent]="false" [widgets]="widgets" [originalConfig]="tab.originalConfig" [context]="tab.context">
@@ -45,8 +43,6 @@ export class DashboardHomeContainer extends DashboardWidgetContainer {
@ViewChild('propertiesClass') private _propertiesClass: DashboardWidgetWrapper; @ViewChild('propertiesClass') private _propertiesClass: DashboardWidgetWrapper;
@ViewChild('propertiesContainer') private _propertiesContainer: ElementRef; @ViewChild('propertiesContainer') private _propertiesContainer: ElementRef;
private height = 75; // default initial height
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) _cd: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) _cd: ChangeDetectorRef,
@Inject(forwardRef(() => CommonServiceInterface)) protected dashboardService: DashboardServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) protected dashboardService: DashboardServiceInterface,
@@ -85,14 +81,6 @@ export class DashboardHomeContainer extends DashboardWidgetContainer {
})); }));
} }
public getHeight(): number {
if (this._propertiesClass && (<PropertiesWidgetComponent>this._propertiesClass.component).height) {
this.height = (<PropertiesWidgetComponent>this._propertiesClass.component).height;
}
return this.height;
}
private updateTheme(theme: IColorTheme): void { private updateTheme(theme: IColorTheme): void {
const border = theme.getColor(DASHBOARD_BORDER); const border = theme.getColor(DASHBOARD_BORDER);
if (theme.getColor(contrastBorder)) { if (theme.getColor(contrastBorder)) {

View File

@@ -17,5 +17,5 @@
<ng-template component-host> <ng-template component-host>
</ng-template> </ng-template>
</ng-template> </ng-template>
<span #bottomActionbar class="bottomActionbar"></span> <span #bottomActionbar class="bottomActionbar {{collapsed ? 'collapsed' : ''}}"></span>
</div> </div>

View File

@@ -40,17 +40,18 @@ dashboard-widget-wrapper .noTitle {
} }
dashboard-widget-wrapper .actionbar { dashboard-widget-wrapper .actionbar {
flex: 0 0 auto;
align-self: end; align-self: end;
} }
dashboard-widget-wrapper .bottomActionbar { dashboard-widget-wrapper .bottomActionbar {
flex: 0 0 auto;
align-self: center; align-self: center;
margin-top: -27px;
display: none; display: none;
} }
dashboard-widget-wrapper .bottomActionbar.collapsed {
margin-top: -27px;
}
dashboard-widget-wrapper .bottomActionbar .actions-container .action-item a.action-label.codicon-chevron-up { dashboard-widget-wrapper .bottomActionbar .actions-container .action-item a.action-label.codicon-chevron-up {
padding-left: 5px; padding-left: 5px;
} }

View File

@@ -16,7 +16,6 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { subscriptionToDisposable } from 'sql/base/browser/lifecycle'; import { subscriptionToDisposable } from 'sql/base/browser/lifecycle';
import { PropertiesContainer, PropertyItem } from 'sql/base/browser/ui/propertiesContainer/propertiesContainer.component'; import { PropertiesContainer, PropertyItem } from 'sql/base/browser/ui/propertiesContainer/propertiesContainer.component';
import { convertSizeToNumber } from 'sql/base/browser/dom';
export interface PropertiesConfig { export interface PropertiesConfig {
properties: Array<Property>; properties: Array<Property>;
@@ -53,8 +52,8 @@ const dashboardRegistry = Registry.as<IDashboardRegistry>(DashboardExtensions.Da
@Component({ @Component({
selector: 'properties-widget', selector: 'properties-widget',
template: ` template: `
<loading-spinner [loading]="_loading" [loadingMessage]="loadingMessage" [loadingCompletedMessage]="loadingCompletedMessage"></loading-spinner> <loading-spinner *ngIf="_loading" [loading]="_loading" [loadingMessage]="loadingMessage" [loadingCompletedMessage]="loadingCompletedMessage"></loading-spinner>
<properties-container></properties-container>` <properties-container [style.display]="_loading ? 'none' : ''"></properties-container>`
}) })
export class PropertiesWidgetComponent extends DashboardWidget implements IDashboardWidget, OnInit { export class PropertiesWidgetComponent extends DashboardWidget implements IDashboardWidget, OnInit {
@ViewChild(PropertiesContainer) private _propertiesContainer: PropertiesContainer; @ViewChild(PropertiesContainer) private _propertiesContainer: PropertiesContainer;
@@ -207,10 +206,6 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
value: propertyObject value: propertyObject
}; };
}); });
if (this._inited) {
this._changeRef.detectChanges();
}
} }
private getConditionResult(item: FlavorProperties, conditionItem: ConditionProperties): boolean { private getConditionResult(item: FlavorProperties, conditionItem: ConditionProperties): boolean {
@@ -248,8 +243,4 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
} }
return val; return val;
} }
public get height(): number {
return convertSizeToNumber(this._propertiesContainer.height);
}
} }