Skip to content

Commit

Permalink
update to use standard pydt-player-avatar, swagger client
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Rosack committed Dec 12, 2018
1 parent ab278a7 commit 366a8c3
Show file tree
Hide file tree
Showing 49 changed files with 29 additions and 2,255 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "playyourdamnturn",
"productName": "Play Your Damn Turn Client",
"version": "1.3.1",
"version": "1.3.2",
"description": "Desktop Client to assist with playing your damn turns.",
"author": "playyourdamnturn.com",
"main": "main.js",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"scripts": {
"clean": "rm -rf dist app/ui_compiled",
"build": "webpack --progress --profile --colors --display-error-details --display-cached",
"build-prod": "bash -c \"npm run clean; webpack --colors\"",
"build-prod": "npm run lint && bash -c \"npm run clean; webpack --colors\"",
"watch": "webpack --watch --progress --profile --colors --display-error-details --display-cached",
"electron": "electron app",
"pack": "bash -c \"npm run build-prod; build --dir\"",
Expand Down Expand Up @@ -65,7 +65,7 @@
"ngx-bootstrap": "^3.0.1",
"node-sass": "^4.9.3",
"pako": "^1.0.6",
"pydt-shared": "^1.2.2",
"pydt-shared": "^1.2.3",
"raw-loader": "0.5.1",
"resolve-url-loader": "^3.0.0",
"rxjs": "^6.3.3",
Expand Down
17 changes: 2 additions & 15 deletions ui/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ import { CustomFormsModule } from 'ng2-validation';
import { ModalModule } from 'ngx-bootstrap/modal';
import { ProgressbarModule } from 'ngx-bootstrap/progressbar';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { ProfileCacheService, PydtSharedModule } from 'pydt-shared';
import { ApiModule, Configuration, PydtSharedModule, ProfileCacheService } from 'pydt-shared';
import { AppComponent } from './app.component';
import { routing } from './app.routing';
import { AuthComponent } from './auth/auth.component';
import { GameComponent } from './home/game.component';
import { HomeComponent } from './home/home.component';
import { GamePlayerComponent } from './home/player.component';
import { PlayTurnComponent } from './playTurn/playTurn.component';
import { PlayTurnState } from './playTurn/playTurnState.service';
import { RollbarErrorHandler, rollbarFactory, RollbarService } from './rollbarErrorHandler';
import { AuthService } from './shared/authService';
import { PydtHttpInterceptor } from './shared/pydtHttpInterceptor';
import { ApiModule, Configuration, UserService } from './swagger/api';

export function configFactory() {
return new Configuration({
Expand All @@ -46,25 +44,14 @@ export function configFactory() {
AuthComponent,
HomeComponent,
GameComponent,
GamePlayerComponent,
PlayTurnComponent
],
providers: [
ProfileCacheService,
{ provide: ErrorHandler, useClass: RollbarErrorHandler },
{ provide: RollbarService, useFactory: rollbarFactory },
AuthService,
{ provide: HTTP_INTERCEPTORS, useClass: PydtHttpInterceptor, multi: true },
{
provide: ProfileCacheService,
useFactory: (userService: UserService) => {
return new ProfileCacheService({
userSteamProfiles: (steamIds: string) => {
return userService.steamProfiles(steamIds);
}
});
},
deps: [UserService]
},
PlayTurnState
],
bootstrap: [AppComponent]
Expand Down
3 changes: 1 addition & 2 deletions ui/auth/auth.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';

import { UserService } from 'pydt-shared';
import { AuthService } from '../shared/authService';
import { UserService } from '../swagger/api';

@Component({
selector: 'pydt-auth',
Expand Down
2 changes: 1 addition & 1 deletion ui/home/game.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="panel-body">
<div class="row" style="padding-left:13px;padding-right:13px;">
<div *ngFor="let player of gamePlayers; let i = index;" class="col-{{game.slots}}-slots" style="padding-left:2px; padding-right:2px;">
<pydt-player [game]="game" [player]="player" [gamePlayerProfiles]="gamePlayerProfiles" [civDef]="civDefs[i]"></pydt-player>
<pydt-player-avatar [game]="game" [player]="player" [gamePlayerProfiles]="gamePlayerProfiles" [civDef]="civDefs[i]"></pydt-player-avatar>
</div>
</div>
<div *ngIf="newDiscoursePost">
Expand Down
11 changes: 5 additions & 6 deletions ui/home/game.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Component, EventEmitter, Input, OnInit, Output, OnDestroy } from '@angular/core';
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { Router } from '@angular/router';
import * as countdown from 'countdown';
import * as app from 'electron';
import { CivDef, GAMES, PcsProfileMap } from 'pydt-shared';

import { CivDef, Game, GamePlayer, GAMES, SteamProfileMap } from 'pydt-shared';
import { PlayTurnState } from '../playTurn/playTurnState.service';
import { Game, GamePlayer } from '../swagger/api';


@Component({
selector: 'pydt-game',
Expand All @@ -14,7 +13,7 @@ import { Game, GamePlayer } from '../swagger/api';
})
export class GameComponent implements OnInit, OnDestroy {
@Input() game: Game;
@Input() gamePlayerProfiles: PcsProfileMap;
@Input() gamePlayerProfiles: SteamProfileMap;
@Input() yourTurn: boolean;
@Input() discoursePostNumber: number;
@Output() smackRead = new EventEmitter<number>();
Expand All @@ -40,7 +39,7 @@ export class GameComponent implements OnInit, OnDestroy {
this.civDefs.push(null);
}
}

this.updateDateHandle = setInterval(() => this.now = new Date(), 30 * 1000);
}

Expand Down
9 changes: 4 additions & 5 deletions ui/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { Router } from '@angular/router';
import * as awsIot from 'aws-iot-device-sdk';
import * as app from 'electron';
import { difference } from 'lodash';
import { ProfileCacheService, CIV6_GAME } from 'pydt-shared';
import { CIV6_GAME, Game, ProfileCacheService, SteamProfile, UserService } from 'pydt-shared';
import { Observable, Subscription, timer } from 'rxjs';
import { map } from 'rxjs/operators';
import { AuthService } from '../shared/authService';
import { DiscourseInfo } from '../shared/discourseInfo';
import { Game, SteamProfile, UserService } from '../swagger/api';
import { map } from 'rxjs/operators';

const POLL_INTERVAL: number = 600 * 1000;
const TOAST_INTERVAL: number = 14.5 * 60 * 1000;
Expand Down Expand Up @@ -103,9 +102,9 @@ export class HomeComponent implements OnInit, OnDestroy {
}));
}

this.discourseInfo = await DiscourseInfo.getDiscourseInfo();

try {
this.discourseInfo = await DiscourseInfo.getDiscourseInfo();

this.games = await req.toPromise();
this.games.forEach(x => x.gameType = x.gameType || CIV6_GAME.id);
this.setSortedTurns();
Expand Down
11 changes: 0 additions & 11 deletions ui/home/player.component.css

This file was deleted.

9 changes: 0 additions & 9 deletions ui/home/player.component.html

This file was deleted.

63 changes: 0 additions & 63 deletions ui/home/player.component.ts

This file was deleted.

15 changes: 7 additions & 8 deletions ui/playTurn/playTurn.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, NgZone, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import * as app from 'electron';
import * as fs from 'fs-extra';
import * as mkdirp from 'mkdirp';
import * as pako from 'pako';
import * as path from 'path';

import { GAMES, GameService, PlatformSaveLocation } from 'pydt-shared';
import { PydtSettings } from '../shared/pydtSettings';
import { GameService } from '../swagger/api';
import { PlayTurnState } from './playTurnState.service';
import { GAMES, PlatformSaveLocation } from 'pydt-shared';
import { HttpErrorResponse } from '@angular/common/http';


@Component({
selector: 'pydt-home',
Expand Down Expand Up @@ -105,7 +104,7 @@ export class PlayTurnComponent implements OnInit {

await this.ngZone.run(async () => {
let data = new Uint8Array(xhr.response);

try {
data = pako.ungzip(new Uint8Array(xhr.response));
} catch (e) {
Expand All @@ -115,11 +114,11 @@ export class PlayTurnComponent implements OnInit {
await fs.writeFile(this.saveFileToPlay, new Buffer(data));
});

await new Promise(resolve => setTimeout(resolve, 500));
await new Promise(sleepResolve => setTimeout(sleepResolve, 500));

await this.ngZone.run(async () => {
const settings = await PydtSettings.getSettings();

if (settings.launchCiv) {
app.ipcRenderer.send('opn-url', this.civGame.steamRunUrl);
}
Expand Down Expand Up @@ -151,7 +150,7 @@ export class PlayTurnComponent implements OnInit {
this.saveFileToUpload = arg;
app.ipcRenderer.removeListener('new-save-detected', newSaveDetected);
});
}
};

setTimeout(() => {
app.ipcRenderer.send('start-chokidar', this.saveDir);
Expand Down
2 changes: 1 addition & 1 deletion ui/playTurn/playTurnState.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Game } from '../swagger/api';
import { Game } from 'pydt-shared';

@Injectable()
export class PlayTurnState {
Expand Down
2 changes: 1 addition & 1 deletion ui/shared/authService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { Configuration } from '../swagger/api';
import * as storage from 'electron-json-storage';
import { Configuration } from 'pydt-shared';

@Injectable()
export class AuthService {
Expand Down
4 changes: 0 additions & 4 deletions ui/swagger/api/.gitignore

This file was deleted.

23 changes: 0 additions & 23 deletions ui/swagger/api/.swagger-codegen-ignore

This file was deleted.

1 change: 0 additions & 1 deletion ui/swagger/api/.swagger-codegen/VERSION

This file was deleted.

34 changes: 0 additions & 34 deletions ui/swagger/api/api.module.ts

This file was deleted.

9 changes: 0 additions & 9 deletions ui/swagger/api/api/api.ts

This file was deleted.

Loading

0 comments on commit 366a8c3

Please sign in to comment.