From 36cbceb68227df67c70b7b338430a72d7532fced Mon Sep 17 00:00:00 2001 From: jliddev Date: Wed, 19 Aug 2020 15:03:58 -0500 Subject: [PATCH] Fix CORS, use curren addon scraping grid fixes --- wowup-electron/main.ts | 2 +- wowup-electron/src/app/app.module.ts | 2 + .../addon-status-column.component.html | 1 + .../addon-status-column.component.scss | 0 .../addon-status-column.component.spec.ts | 25 +++++++++ .../addon-status-column.component.ts | 29 ++++++++++ .../addon-table-column.component.scss | 4 +- .../app/core/services/addons/addon.service.ts | 15 ++--- wowup-electron/src/app/home/home.module.ts | 4 +- .../app/my-addons/my-addons.component.html | 56 ++----------------- .../app/my-addons/my-addons.component.scss | 55 +++++++++--------- .../src/app/my-addons/my-addons.component.ts | 25 +++++++-- wowup-electron/src/styles.scss | 36 +++++++++++- 13 files changed, 152 insertions(+), 102 deletions(-) create mode 100644 wowup-electron/src/app/components/addon-status-column/addon-status-column.component.html create mode 100644 wowup-electron/src/app/components/addon-status-column/addon-status-column.component.scss create mode 100644 wowup-electron/src/app/components/addon-status-column/addon-status-column.component.spec.ts create mode 100644 wowup-electron/src/app/components/addon-status-column/addon-status-column.component.ts diff --git a/wowup-electron/main.ts b/wowup-electron/main.ts index 3cd85a91..35214efa 100644 --- a/wowup-electron/main.ts +++ b/wowup-electron/main.ts @@ -3,7 +3,7 @@ import * as path from 'path'; import * as url from 'url'; import { release, arch } from 'os'; -// app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors'); +app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors'); const appVersion = require('./package.json').version; const USER_AGENT = `WowUp-Client/${appVersion} (${release()}; ${arch()}; +https://wowup.io)`; diff --git a/wowup-electron/src/app/app.module.ts b/wowup-electron/src/app/app.module.ts index 8f6666b5..32a4b91a 100644 --- a/wowup-electron/src/app/app.module.ts +++ b/wowup-electron/src/app/app.module.ts @@ -22,6 +22,7 @@ import { DetailModule } from './detail/detail.module'; import { AppComponent } from './app.component'; import { DefaultHeadersInterceptor } from './core/interceptors/default-headers.interceptor'; import { AddonTableColumnComponent } from './components/addon-table-column/addon-table-column.component'; +import { AddonStatusColumnComponent } from './components/addon-status-column/addon-status-column.component'; // AoT requires an exported function for factories export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader { @@ -32,6 +33,7 @@ export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader { declarations: [ AppComponent, AddonTableColumnComponent, + AddonStatusColumnComponent, ], imports: [ BrowserModule, diff --git a/wowup-electron/src/app/components/addon-status-column/addon-status-column.component.html b/wowup-electron/src/app/components/addon-status-column/addon-status-column.component.html new file mode 100644 index 00000000..d0b19d38 --- /dev/null +++ b/wowup-electron/src/app/components/addon-status-column/addon-status-column.component.html @@ -0,0 +1 @@ +

Up to Date

diff --git a/wowup-electron/src/app/components/addon-status-column/addon-status-column.component.scss b/wowup-electron/src/app/components/addon-status-column/addon-status-column.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/wowup-electron/src/app/components/addon-status-column/addon-status-column.component.spec.ts b/wowup-electron/src/app/components/addon-status-column/addon-status-column.component.spec.ts new file mode 100644 index 00000000..889cb329 --- /dev/null +++ b/wowup-electron/src/app/components/addon-status-column/addon-status-column.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AddonStatusColumnComponent } from './addon-status-column.component'; + +describe('AddonStatusColumnComponent', () => { + let component: AddonStatusColumnComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AddonStatusColumnComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AddonStatusColumnComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/wowup-electron/src/app/components/addon-status-column/addon-status-column.component.ts b/wowup-electron/src/app/components/addon-status-column/addon-status-column.component.ts new file mode 100644 index 00000000..095e9073 --- /dev/null +++ b/wowup-electron/src/app/components/addon-status-column/addon-status-column.component.ts @@ -0,0 +1,29 @@ +import { Component, OnInit } from '@angular/core'; +import { ICellRendererAngularComp } from 'ag-grid-angular'; +import { ICellRendererParams, IAfterGuiAttachedParams } from 'ag-grid-community'; +import { Addon } from 'app/core/entities/addon'; + +@Component({ + selector: 'app-addon-status-column', + templateUrl: './addon-status-column.component.html', + styleUrls: ['./addon-status-column.component.scss'] +}) +export class AddonStatusColumnComponent implements ICellRendererAngularComp { + public addon: Addon; + + constructor() { } + + refresh(params: any): boolean { + throw new Error("Method not implemented."); + } + + agInit(params: ICellRendererParams): void { + this.addon = params.data; + console.log(this.addon) + } + + afterGuiAttached?(params?: IAfterGuiAttachedParams): void { + throw new Error("Method not implemented."); + } + +} diff --git a/wowup-electron/src/app/components/addon-table-column/addon-table-column.component.scss b/wowup-electron/src/app/components/addon-table-column/addon-table-column.component.scss index 3d3e8d31..5bfc700d 100644 --- a/wowup-electron/src/app/components/addon-table-column/addon-table-column.component.scss +++ b/wowup-electron/src/app/components/addon-table-column/addon-table-column.component.scss @@ -11,7 +11,7 @@ display: flex; flex-direction: column; justify-content: center; - margin-right: 0.5em; + margin-right: 11px; flex-shrink: 0; .addon-logo { @@ -22,5 +22,7 @@ .addon-title { font-weight: bold; font-size: 1.1em; + // word-break: break-all; + white-space: normal; } } diff --git a/wowup-electron/src/app/core/services/addons/addon.service.ts b/wowup-electron/src/app/core/services/addons/addon.service.ts index fe0ae3db..207b59bc 100644 --- a/wowup-electron/src/app/core/services/addons/addon.service.ts +++ b/wowup-electron/src/app/core/services/addons/addon.service.ts @@ -72,18 +72,11 @@ export class AddonService { try { let addon: Addon; - const response = await this._wowupApiService.scanAddon({ - channelType: AddonChannelType.Stable, - clientType, - folderName: folder.name, - tocMetaData: folder.tocMetaData - }); + if (folder.toc.curseProjectId) { + addon = await this.getCurseAddonById(folder, clientType); + } else { - // if (folder.toc.curseProjectId) { - // addon = await this.getCurseAddonById(folder, clientType); - // } else { - - // } + } if (!addon) { continue; diff --git a/wowup-electron/src/app/home/home.module.ts b/wowup-electron/src/app/home/home.module.ts index 96605d1a..f618ffa9 100644 --- a/wowup-electron/src/app/home/home.module.ts +++ b/wowup-electron/src/app/home/home.module.ts @@ -13,6 +13,7 @@ import { GetAddonsComponent } from 'app/get-addons/get-addons.component'; import { OptionsComponent } from 'app/options/options.component'; import { ExternalLinkDirective } from 'app/core/directives/external-link.directive'; import { AddonTableColumnComponent } from 'app/components/addon-table-column/addon-table-column.component'; +import { AddonStatusColumnComponent } from 'app/components/addon-status-column/addon-status-column.component'; @NgModule({ declarations: [ @@ -25,7 +26,8 @@ import { AddonTableColumnComponent } from 'app/components/addon-table-column/add ], imports: [ AgGridModule.withComponents([ - AddonTableColumnComponent + AddonTableColumnComponent, + AddonStatusColumnComponent ]), CommonModule, SharedModule, diff --git a/wowup-electron/src/app/my-addons/my-addons.component.html b/wowup-electron/src/app/my-addons/my-addons.component.html index 2e93788d..bc250a7f 100644 --- a/wowup-electron/src/app/my-addons/my-addons.component.html +++ b/wowup-electron/src/app/my-addons/my-addons.component.html @@ -1,4 +1,4 @@ -
+
@@ -18,57 +18,9 @@
-
- +
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Addon -
-
- -
-
-
{{element.name}}
-
{{element.installedVersion}}
-
-
-
Status {{element.name}} Latest Version {{element.latestVersion}} Game Version {{element.gameVersion}} Author {{element.author}}
\ No newline at end of file diff --git a/wowup-electron/src/app/my-addons/my-addons.component.scss b/wowup-electron/src/app/my-addons/my-addons.component.scss index 0e7bcf7a..ace1b905 100644 --- a/wowup-electron/src/app/my-addons/my-addons.component.scss +++ b/wowup-electron/src/app/my-addons/my-addons.component.scss @@ -26,36 +26,31 @@ width: 100%; } - .addon-table { - tr { - &:hover { - background-color: $dark-1; - } - } - - .addon-column { - padding-top: 0.5em; - padding-bottom: 0.5em; - - .addon-logo-container { - background-color: $dark-2; - width: 40px; - height: 40px; - display: flex; - flex-direction: column; - justify-content: center; - margin-right: 0.5em; - flex-shrink: 0; - - .addon-logo { - width: 100%; - } - } - - .addon-title { - font-weight: bold; - font-size: 1.1em; - } + tr { + &:hover { + background-color: $dark-1; } } + + .addon-logo-container { + background-color: $dark-2; + width: 40px; + height: 40px; + display: flex; + flex-direction: column; + justify-content: center; + margin-right: 0.5em; + flex-shrink: 0; + + .addon-logo { + width: 100%; + } + } + + .addon-title { + font-weight: bold; + font-size: 1.1em; + word-break: break-all; + white-space: pre-wrap; + } } diff --git a/wowup-electron/src/app/my-addons/my-addons.component.ts b/wowup-electron/src/app/my-addons/my-addons.component.ts index 470a8750..acf961d1 100644 --- a/wowup-electron/src/app/my-addons/my-addons.component.ts +++ b/wowup-electron/src/app/my-addons/my-addons.component.ts @@ -6,6 +6,7 @@ import { first, tap } from 'rxjs/operators'; import { from, BehaviorSubject } from 'rxjs'; import { Addon } from 'app/core/entities/addon'; import { AddonTableColumnComponent } from 'app/components/addon-table-column/addon-table-column.component'; +import { AddonStatusColumnComponent } from 'app/components/addon-status-column/addon-status-column.component'; @Component({ selector: 'app-my-addons', @@ -16,6 +17,8 @@ export class MyAddonsComponent implements OnInit { private readonly _displayAddonsSrc = new BehaviorSubject([]); + private gridApi; + public displayedColumns: string[] = [ 'addon', 'status', @@ -33,12 +36,20 @@ export class MyAddonsComponent implements OnInit { headerName: 'Addon', field: 'value', cellRendererFramework: AddonTableColumnComponent, - autoHeight: true + autoHeight: true, + suppressSizeToFit: true, + width: 400 }, - { headerName: 'Status', field: '' }, - { headerName: 'Model', field: 'latestVersion' }, + { + headerName: 'Status', + field: 'value', + cellRendererFramework: AddonStatusColumnComponent, + width: 80, + suppressSizeToFit: true, + }, + { headerName: 'Latest Version', field: 'latestVersion', cellClass: 'cell-wrap-text ' }, { headerName: 'Game Version', field: 'gameVersion' }, - { headerName: 'Author', field: 'author' } + { headerName: 'Author', field: 'author', cellClass: 'cell-wrap-text' } ]; public dataSource = [ @@ -85,6 +96,12 @@ export class MyAddonsComponent implements OnInit { this.busy = false; } + onGridReady(params) { + this.gridApi = params.api; + this.gridApi.sizeColumnsToFit(); + + } + private loadAddons(rescan: boolean = false) { this.busy = true; diff --git a/wowup-electron/src/styles.scss b/wowup-electron/src/styles.scss index 4acb8472..0d5292cd 100644 --- a/wowup-electron/src/styles.scss +++ b/wowup-electron/src/styles.scss @@ -50,6 +50,17 @@ body { color: $white-3 !important; } +.d-flex { + display: flex; +} + +.flex-col { + flex-direction: column; +} + +.flex-grow-1 { + flex-grow: 1; +} .row { display: flex; flex-direction: row; @@ -63,7 +74,7 @@ body { @include ag-theme-balham( ( // use theme parameters where possible - foreground-color: $white-1, + foreground-color: $white-1, background-color: $dark-3, row-hover-color: $dark-1, header-background-color: $dark-2, @@ -72,10 +83,31 @@ body { borders: true, borders-critical: false, borders-secondary: false, - border-color: red, + border-color: transparent, secondary-border-color: blue, row-border-color: green, cell-horizontal-border: red ) ); + + .ag-row { + border-top: 1px solid rgba(255, 255, 255, 0.12) !important; + } +} + +.addon-table { + width: 100%; + height: 100%; + + .cell-break-all { + word-break: break-all; + } + .cell-wrap-text { + white-space: normal; + } + // .addon-title { + // font-weight: bold; + // font-size: 1.1em; + + // } }