Fix CORS, use curren addon scraping

grid fixes
This commit is contained in:
jliddev
2020-08-19 15:03:58 -05:00
parent b11ac3eaba
commit 36cbceb682
13 changed files with 152 additions and 102 deletions

View File

@@ -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)`;

View File

@@ -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,

View File

@@ -0,0 +1 @@
<p>Up to Date</p>

View File

@@ -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<AddonStatusColumnComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddonStatusColumnComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddonStatusColumnComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -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.");
}
}

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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,

View File

@@ -1,4 +1,4 @@
<div class="tab-container">
<div class="tab-container d-flex flex-col">
<div class="control-container">
<div class="select-container ">
<mat-form-field>
@@ -18,57 +18,9 @@
</div>
</div>
<div class="table-container">
<ag-grid-angular style="width: 100%; height: 500px;" class="ag-theme-balham" [gridOptions]="gridOptions" [rowData]="displayAddons$ | async"
[columnDefs]="columnDefs">
<div class="table-container flex-grow-1">
<ag-grid-angular class="ag-theme-balham addon-table" [gridOptions]="gridOptions" [rowData]="displayAddons$ | async"
[columnDefs]="columnDefs" (gridReady)="onGridReady($event)">
</ag-grid-angular>
<table mat-table [dataSource]="displayAddons$ | async" class="addon-table mat-elevation-z8">
<!--- Note that these columns can be defined in any order.
The actual rendered columns are set as a property on the row definition" -->
<!-- Position Column -->
<ng-container matColumnDef="addon">
<th mat-header-cell *matHeaderCellDef>Addon</th>
<td mat-cell *matCellDef="let element">
<div class="addon-column row align-items-center">
<div class="addon-logo-container">
<img class="addon-logo" [src]="element.thumbnailUrl" />
</div>
<div>
<div class="addon-title">{{element.name}}</div>
<div>{{element.installedVersion}}</div>
</div>
</div>
</td>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef>Status</th>
<td mat-cell *matCellDef="let element"> {{element.name}} </td>
</ng-container>
<!-- Weight Column -->
<ng-container matColumnDef="latest-version">
<th mat-header-cell *matHeaderCellDef>Latest Version</th>
<td mat-cell *matCellDef="let element"> {{element.latestVersion}} </td>
</ng-container>
<!-- Symbol Column -->
<ng-container matColumnDef="game-version">
<th mat-header-cell *matHeaderCellDef>Game Version</th>
<td mat-cell *matCellDef="let element"> {{element.gameVersion}} </td>
</ng-container>
<ng-container matColumnDef="author">
<th mat-header-cell *matHeaderCellDef>Author</th>
<td mat-cell *matCellDef="let element"> {{element.author}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</div>
</div>

View File

@@ -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;
}
}

View File

@@ -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<Addon[]>([]);
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;

View File

@@ -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;
// }
}