diff --git a/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.html b/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.html deleted file mode 100644 index 80f8ed02..00000000 --- a/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.html +++ /dev/null @@ -1,19 +0,0 @@ -
-
-
-
-

{{addon.name}}

-
-
- -
-
- - -
{{addon.name}}
- - -
-
-
\ No newline at end of file diff --git a/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.scss b/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.scss deleted file mode 100644 index 4a3c385d..00000000 --- a/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.scss +++ /dev/null @@ -1,26 +0,0 @@ -@import "../../../variables.scss"; - -.container { - padding: 0.5em; - background-color: $dark-4; - color: $white-1; - - .header { - display: flex; - flex-direction: row; - margin-bottom: 0.5em; - - .icon { - background-color: $dark-2; - width: 40px; - height: 40px; - margin-right: 0.5em; - background-size: contain; - background-repeat: none; - } - } - - p { - margin: 0; - } -} diff --git a/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.spec.ts b/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.spec.ts deleted file mode 100644 index 36e519de..00000000 --- a/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AddonContextMenuComponent } from './addon-context-menu.component'; - -describe('AddonContextMenuComponent', () => { - let component: AddonContextMenuComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ AddonContextMenuComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(AddonContextMenuComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.ts b/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.ts deleted file mode 100644 index 056817f0..00000000 --- a/wowup-electron/src/app/components/addon-context-menu/addon-context-menu.component.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core'; -import { MatMenuTrigger } from '@angular/material/menu'; -import { MyAddonsListItem } from 'app/business-objects/my-addons-list-item'; -import { Addon } from 'app/entities/addon'; - -@Component({ - selector: 'app-addon-context-menu', - templateUrl: './addon-context-menu.component.html', - styleUrls: ['./addon-context-menu.component.scss'] -}) -export class AddonContextMenuComponent implements OnInit, AfterViewInit { - @Input('addon') addon: MyAddonsListItem; - @Input('xPos') xPos: number; - @Input('yPos') yPos: number; - - @ViewChild(MatMenuTrigger) contextMenu: MatMenuTrigger; - - constructor() { } - - ngOnInit(): void { - } - - ngAfterViewInit(): void { - console.log(this.contextMenu); - this.contextMenu.openMenu(); - } - -} diff --git a/wowup-electron/src/app/models/wowup/column-state.ts b/wowup-electron/src/app/models/wowup/column-state.ts index d029fc39..7b7b3403 100644 --- a/wowup-electron/src/app/models/wowup/column-state.ts +++ b/wowup-electron/src/app/models/wowup/column-state.ts @@ -2,4 +2,5 @@ export interface ColumnState { name: string; display: string; visible: boolean; + allowToggle?: boolean; } \ No newline at end of file diff --git a/wowup-electron/src/app/pages/home/home.module.ts b/wowup-electron/src/app/pages/home/home.module.ts index c1a08197..9a40c9e8 100644 --- a/wowup-electron/src/app/pages/home/home.module.ts +++ b/wowup-electron/src/app/pages/home/home.module.ts @@ -18,7 +18,6 @@ import { PotentialAddonTableColumnComponent } from 'app/components/potential-add import { PotentialAddonStatusColumnComponent } from 'app/components/potential-addon-status-column/potential-addon-status-column.component'; import { MyAddonsAddonCellComponent } from 'app/components/my-addons-addon-cell/my-addons-addon-cell.component'; import { MyAddonsStatusCellComponent } from 'app/components/my-addons-status-cell/my-addons-status-cell.component'; -import { AddonContextMenuComponent } from 'app/components/addon-context-menu/addon-context-menu.component'; import { ProgressSpinnerComponent } from 'app/components/progress-spinner/progress-spinner.component'; import { DownloadCountPipe } from 'app/pipes/download-count.pipe'; import { TelemetryDialogComponent } from 'app/components/telemetry-dialog/telemetry-dialog.component'; @@ -33,7 +32,6 @@ import { TelemetryDialogComponent } from 'app/components/telemetry-dialog/teleme ExternalLinkDirective, MyAddonsAddonCellComponent, MyAddonsStatusCellComponent, - AddonContextMenuComponent, PotentialAddonStatusColumnComponent, ProgressSpinnerComponent, PotentialAddonTableColumnComponent, diff --git a/wowup-electron/src/app/pages/my-addons/my-addons.component.html b/wowup-electron/src/app/pages/my-addons/my-addons.component.html index 82eb2a85..adc30671 100644 --- a/wowup-electron/src/app/pages/my-addons/my-addons.component.html +++ b/wowup-electron/src/app/pages/my-addons/my-addons.component.html @@ -38,12 +38,14 @@ Status
- update + + update -
{{element.statusText}}
+
+ {{element.statusText}}

{{element.statusText}}

@@ -89,19 +91,8 @@
- -
-

Visible Columns

- -
- - {{column.display}} -
-
-
- -
+
@@ -113,9 +104,11 @@
- Ignore + Ignore - Auto + Auto Update @@ -133,8 +126,18 @@ - - \ No newline at end of file +
+
+ + +
+
Show Columns
+
+ + + {{column.display}} + +
+
\ No newline at end of file diff --git a/wowup-electron/src/app/pages/my-addons/my-addons.component.ts b/wowup-electron/src/app/pages/my-addons/my-addons.component.ts index 8fc892e3..78ea0d5f 100644 --- a/wowup-electron/src/app/pages/my-addons/my-addons.component.ts +++ b/wowup-electron/src/app/pages/my-addons/my-addons.component.ts @@ -8,7 +8,6 @@ import { AddonService } from 'app/services/addons/addon.service'; import { SessionService } from 'app/services/session/session.service'; import { GridApi, GridOptions } from 'ag-grid-community'; import { Overlay, OverlayRef } from '@angular/cdk/overlay'; -import { TemplatePortal } from '@angular/cdk/portal'; import { ColumnState } from 'app/models/wowup/column-state'; import { MatCheckboxChange } from '@angular/material/checkbox'; import { MyAddonsListItem } from 'app/business-objects/my-addons-list-item'; @@ -26,10 +25,8 @@ import { MatRadioChange } from '@angular/material/radio'; }) export class MyAddonsComponent implements OnInit, OnDestroy { - @ViewChild('columnMenu') columnMenu: TemplateRef; - @ViewChild('addonMenu') addonMenu: TemplateRef; - @ViewChild(MatMenuTrigger) - contextMenu: MatMenuTrigger; + @ViewChild('addonContextMenuTrigger') contextMenu: MatMenuTrigger; + @ViewChild('columnContextMenuTrigger') columnContextMenu: MatMenuTrigger; private readonly _displayAddonsSrc = new BehaviorSubject([]); @@ -39,24 +36,13 @@ export class MyAddonsComponent implements OnInit, OnDestroy { contextMenuPosition = { x: '0px', y: '0px' }; - gridOptions: GridOptions = { - suppressMovableColumns: true, - suppressDragLeaveHidesColumns: true, - } - - defaultColDef = { - wrapText: true, - sortable: true, - autoHeight: true, - }; - columns: ColumnState[] = [ { name: 'addon', display: 'Addon', visible: true }, { name: 'status', display: 'Status', visible: true }, - { name: 'latestVersion', display: 'Latest Version', visible: true }, - { name: 'gameVersion', display: 'Game Version', visible: true }, - { name: 'provider', display: 'Provider', visible: true }, - { name: 'author', display: 'Author', visible: true }, + { name: 'latestVersion', display: 'Latest Version', visible: true, allowToggle: true }, + { name: 'gameVersion', display: 'Game Version', visible: true, allowToggle: true }, + { name: 'provider', display: 'Provider', visible: true, allowToggle: true }, + { name: 'author', display: 'Author', visible: true, allowToggle: true }, ] public get displayedColumns(): string[] { @@ -142,20 +128,22 @@ export class MyAddonsComponent implements OnInit, OnDestroy { this.enableControls = true; } - onHeaderContext({ x, y }: MouseEvent) { - this.showContextMenu(x, y, this.columnMenu, this.displayedColumns); + onHeaderContext(event: MouseEvent) { + event.preventDefault(); + this.contextMenuPosition.x = event.clientX + 'px'; + this.contextMenuPosition.y = event.clientY + 'px'; + this.columnContextMenu.menuData = { 'columns': this.columns.filter(col => col.allowToggle) }; + this.columnContextMenu.menu.focusFirstItem('mouse'); + this.columnContextMenu.openMenu(); } onCellContext(event: MouseEvent, listItem: MyAddonsListItem) { - console.log(listItem) event.preventDefault(); this.contextMenuPosition.x = event.clientX + 'px'; this.contextMenuPosition.y = event.clientY + 'px'; this.contextMenu.menuData = { 'listItem': listItem }; this.contextMenu.menu.focusFirstItem('mouse'); this.contextMenu.openMenu(); - - // this.showContextMenu(event.x, event.y, this.addonMenu, addon); } onUpdateAddon(listItem: MyAddonsListItem) { @@ -185,7 +173,7 @@ export class MyAddonsComponent implements OnInit, OnDestroy { this.addonService.saveAddon(listItem.addon); } - onClickAutoUpdateAddon(evt: MatCheckboxChange, addon: Addon){ + onClickAutoUpdateAddon(evt: MatCheckboxChange, addon: Addon) { addon.autoUpdateEnabled = evt.checked; this.addonService.saveAddon(addon); } @@ -195,61 +183,6 @@ export class MyAddonsComponent implements OnInit, OnDestroy { this.addonService.saveAddon(addon); } - onGridReady(params) { - this.gridApi = params.api; - this.gridApi.sizeColumnsToFit(); - - // simple resize debouncer - let resizeTime = 0; - this.gridApi.addEventListener('columnResized', () => { - clearTimeout(resizeTime); - resizeTime = window.setTimeout(() => { - this.gridApi?.resetRowHeights(); - }, 100); - }); - } - - private showContextMenu(x: number, y: number, template: TemplateRef, data: any) { - this.closeContext(); - - const positionStrategy = this.overlay.position() - .flexibleConnectedTo({ x, y }) - .withPositions([ - { - originX: 'end', - originY: 'bottom', - overlayX: 'end', - overlayY: 'top', - } - ]); - - this.overlayRef = this.overlay.create({ - positionStrategy, - scrollStrategy: this.overlay.scrollStrategies.close() - }); - - this.overlayRef.attach(new TemplatePortal(template, this.viewContainerRef, { - $implicit: data - })); - - this.sub = fromEvent(document, 'click') - .pipe( - filter(event => { - const clickTarget = event.target as HTMLElement; - return !!this.overlayRef && !this.overlayRef.overlayElement.contains(clickTarget); - }), - take(1) - ).subscribe(() => this.closeContext()) - } - - private closeContext() { - this.sub && this.sub.unsubscribe(); - if (this.overlayRef) { - this.overlayRef.dispose(); - this.overlayRef = null; - } - } - private loadAddons(clientType: WowClientType, rescan = false) { this.isBusy = true; this.enableControls = false;