Merge pull request #174 from gloriousCode/master

Fix build errors, warnings, vulnerabilities, linting for front-end
This commit is contained in:
Adrian Gallagher
2018-08-17 08:22:58 +10:00
committed by GitHub
23 changed files with 4337 additions and 5837 deletions

9739
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,105 +1,104 @@
{
"name": "gocryptotrader-web",
"version": "0.4.0",
"description": "Front-end interface for GoCryptoTrader",
"homepage": "https://github.com/thrasher-/gocryptotrader",
"author": {
"name": "Scott",
"email": "scott@gloriousedge.com",
"github": "https://github.com/gloriousCode/",
"website": "https://www.gloriousedge.com"
},
"contributors": [
{
"name": "Maxime GRIS",
"email": "maxime.gris@gmail.com",
"github": "https://github.com/maximegris/"
}
],
"keywords": [
"angular",
"electron",
"typescript",
"sass",
"bitcoin",
"exchange"
],
"main": "main.js",
"private": true,
"scripts": {
"postinstall": "npx electron-builder install-app-deps",
"ng": "ng",
"start": "node hooks/environments/set_profile.js && npm-run-all -p ng:serve electron:serve",
"build": "node hooks/environments/set_profile.js && ng build && npm run electron:tsc",
"build:prod": "node hooks/environments/set_profile.js && ng build --prod && npm run electron:tsc",
"lint": "tslint -c tslint.json src/**/*{.ts,.tsx} main.ts",
"lint:fix": "tslint --fix -c tslint.json src/**/*{.ts,.tsx} main.ts",
"ng:serve": "ng serve -o",
"electron:tsc": "tsc main.ts",
"electron:serve": "wait-on http-get://localhost:4200/ && npm run electron:tsc && electron . --serve",
"electron:local": "npm run build:prod && electron .",
"electron:linux": "npm run build:prod && npx electron-builder build --linux",
"electron:windows": "npm run build:prod && npx electron-builder build --windows",
"electron:mac": "npm run build:prod && npx electron-builder build --mac",
"test": "karma start ./karma.conf.js",
"pree2e:build": "webdriver-manager update --gecko false && npm run ng serve",
"pree2e:protractor": "wait-on http-get://localhost:4200/ && protractor ./protractor.conf.js",
"e2e": "npm-run-all -p -r pree2e:build pree2e:protractor",
"start:web": "ng serve --o"
},
"dependencies": {
"node-sass": "^4.9.2",
"rxjs-compat": "^6.2.1",
"rxjs-tslint": "^0.1.5"
},
"devDependencies": {
"@amcharts/amcharts3-angular": "^2.1.1",
"@angular-devkit/build-angular": "~0.6.8",
"@angular/animations": "^6.0.9",
"@angular/cdk": "^6.4.0",
"@angular/cli": "^6.0.8",
"@angular/common": "^6.0.9",
"@angular/compiler": "^6.0.9",
"@angular/compiler-cli": "^6.0.9",
"@angular/core": "^6.0.9",
"@angular/forms": "^6.0.9",
"@angular/http": "^6.0.9",
"@angular/language-service": "^6.0.9",
"@angular/material": "^6.4.0",
"@angular/platform-browser": "^6.0.9",
"@angular/platform-browser-dynamic": "^6.0.9",
"@angular/router": "^6.0.9",
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^2.0.1",
"@types/core-js": "^0.9.46",
"@types/jasmine": "^2.8.8",
"@types/jasminewd2": "^2.0.3",
"@types/node": "^7.0.67",
"codelyzer": "^4.4.2",
"core-js": "^2.5.7",
"cross-env": "^5.2.0",
"dotenv": "^6.0.0",
"electron": "^1.8.7",
"electron-builder": "^20.15.3",
"electron-reload": "^1.2.5",
"fs-extra": "^5.0.0",
"jasmine-core": "^2.99.1",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^2.0.4",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^1.4.3",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^1.2.0",
"npm-run-all": "^4.1.3",
"npx": "^10.2.0",
"protractor": "^5.3.2",
"replace": "^0.3.0",
"rxjs": "^6.2.1",
"ts-node": "^4.1.0",
"tslint": "^5.11.0",
"typescript": "^2.7.2",
"wait-on": "^2.1.0",
"webdriver-manager": "^12.0.6",
"zone.js": "^0.8.26"
"name": "gocryptotrader-web",
"version": "0.4.1",
"description": "Front-end interface for GoCryptoTrader",
"homepage": "https://github.com/thrasher-/gocryptotrader",
"author": {
"name": "Scott",
"email": "scott@gloriousedge.com",
"github": "https://github.com/gloriousCode/",
"website": "https://www.gloriousedge.com"
},
"contributors": [
{
"name": "Maxime GRIS",
"email": "maxime.gris@gmail.com",
"github": "https://github.com/maximegris/"
}
],
"keywords": [
"angular",
"electron",
"typescript",
"sass",
"bitcoin",
"exchange"
],
"main": "main.js",
"private": true,
"scripts": {
"postinstall": "node patch-zone-js.js",
"ng": "ng",
"start": "node hooks/environments/set_profile.js && npm-run-all -p ng:serve electron:serve",
"build": "node hooks/environments/set_profile.js && ng build && npm run electron:tsc",
"build:prod": "node hooks/environments/set_profile.js && ng build --prod && npm run electron:tsc",
"lint": "tslint --project tslint.json src/**/*{.ts,.tsx} main.ts",
"lint:fix": "tslint --fix --project tslint.json src/**/*{.ts,.tsx} main.ts",
"ng:serve": "ng serve -o",
"electron:tsc": "tsc main.ts",
"electron:serve": "wait-on http-get://localhost:4200/ && npm run electron:tsc && electron . --serve",
"electron:local": "npm run build:prod && electron .",
"electron:linux": "npm run build:prod && electron-builder build --linux",
"electron:windows": "npm run build:prod && electron-builder build --windows",
"electron:mac": "npm run build:prod && electron-builder build --mac",
"test": "ng test --karma-config ./karma.conf.js",
"pree2e:build": "webdriver-manager update --gecko false && npm run ng serve",
"pree2e:protractor": "wait-on http-get://localhost:4200/ && protractor ./protractor.conf.js",
"e2e": "npm-run-all -p -r pree2e:build pree2e:protractor",
"start:web": "ng serve --o"
},
"dependencies": {
"node-sass": "^4.9.2",
"rxjs-compat": "^6.2.1",
"rxjs-tslint": "^0.1.5"
},
"devDependencies": {
"@amcharts/amcharts3-angular": "^2.1.1",
"@angular-devkit/build-angular": "~0.6.8",
"@angular/animations": "^6.1.2",
"@angular/cdk": "^6.4.0",
"@angular/cli": "^6.0.8",
"@angular/common": "^6.1.2",
"@angular/compiler": "^6.1.2",
"@angular/compiler-cli": "^6.1.2",
"@angular/core": "^6.1.2",
"@angular/forms": "^6.1.2",
"@angular/http": "^6.1.2",
"@angular/language-service": "^6.1.2",
"@angular/material": "^6.4.0",
"@angular/platform-browser": "^6.1.2",
"@angular/platform-browser-dynamic": "^6.1.2",
"@angular/router": "^6.1.2",
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^2.0.1",
"@types/es6-collections": "^0.5.31",
"@types/jasmine": "^2.8.8",
"@types/jasminewd2": "^2.0.3",
"@types/node": "^7.0.67",
"codelyzer": "^4.4.2",
"core-js": "^2.5.7",
"cross-env": "^5.2.0",
"dotenv": "^6.0.0",
"electron": "^2.0.7",
"electron-builder": "^20.27.1",
"electron-reload": "^1.2.5",
"fs-extra": "^5.0.0",
"jasmine-core": "^2.99.1",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^3.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^1.4.3",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^1.2.0",
"npm-run-all": "^4.1.3",
"protractor": "^5.4.0",
"replace": "^1.0.0",
"rxjs": "^6.2.2",
"ts-node": "^4.1.0",
"tslint": "^5.11.0",
"typescript": "^2.9.2",
"wait-on": "^2.1.0",
"webdriver-manager": "^12.0.6",
"zone.js": "^0.8.26"
}
}

13
web/patch-zone-js.js Normal file
View File

@@ -0,0 +1,13 @@
const fs = require('fs');
const f = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';
fs.readFile(f, 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
var result = data.replace(/node: false/g, 'node: {crypto: true, stream: true, fs: \'empty\'}');
fs.writeFile(f, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});

View File

@@ -17,7 +17,10 @@ export class AppComponent implements OnInit {
private ws: WebsocketResponseHandlerService;
public isConnected = false;
constructor(public electronService: ElectronService, sidebarService: SidebarService, private router: Router, private websocketHandler: WebsocketResponseHandlerService) {
constructor(public electronService: ElectronService,
sidebarService: SidebarService,
private router: Router,
private websocketHandler: WebsocketResponseHandlerService) {
if (electronService.isElectron()) {
console.log('Mode electron');

View File

@@ -44,7 +44,7 @@ import { SettingsComponent, EnabledCurrenciesDialogueComponent } from './pages/s
// Shared
import { NavbarComponent } from './shared/navbar/navbar.component';
import { AllEnabledCurrencyTickersComponent } from './shared/all-updates-ticker/all-updates-ticker.component';
import { ThemePickerComponent } from './shared/theme-picker/theme-picker';
import { ThemePickerComponent } from './shared/theme-picker/theme-picker.component';
import {IterateMapPipe, EnabledCurrenciesPipe} from './shared/classes/pipes';
// services
import { WebsocketService } from './services/websocket/websocket.service';

View File

@@ -5,6 +5,28 @@ import { Config, CurrencyPairRedux, Wallet } from './../../shared/classes/config
import { MatSnackBar, MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
import { WalletComponent } from '../wallet/wallet.component';
@Component({
selector: 'app-dialog-overview-example-dialog',
template: '<h4>Enabled Currencies</h4><div *ngFor="let currency of data.pairs">'
+ '<mat-checkbox name="{{currency.Name}}2" [(ngModel)]="currency.Enabled">{{currency.Name}}</mat-checkbox>'
+ '</div><button mat-raised-button color="primary" (click)="close()">DONE</button>',
})
export class EnabledCurrenciesDialogueComponent {
constructor(
public dialogRef: MatDialogRef<EnabledCurrenciesDialogueComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) { }
onNoClick(): void {
this.dialogRef.close();
}
public close(): void {
this.dialogRef.close();
}
}
@Component({
selector: 'app-settings',
templateUrl: './settings.component.html',
@@ -18,10 +40,13 @@ export class SettingsComponent implements OnInit {
private snackBar: MatSnackBar;
private dialogue;
constructor(private websocketHandler: WebsocketResponseHandlerService, snackBar: MatSnackBar, public dialog: MatDialog) {
constructor(private websocketHandler: WebsocketResponseHandlerService,
snackBar: MatSnackBar,
public dialog: MatDialog) {
this.ws = websocketHandler;
this.snackBar = snackBar;
}
ngOnInit() {
this.ws.shared.subscribe(msg => {
if (msg.event === WebSocketMessageType.GetConfig) {
@@ -82,25 +107,6 @@ export class SettingsComponent implements OnInit {
}
}
@Component({
selector: 'app-dialog-overview-example-dialog',
template: '<h4>Enabled Currencies</h4><div *ngFor="let currency of data.pairs"><mat-checkbox name="{{currency.Name}}2" [(ngModel)]="currency.Enabled">{{currency.Name}}</mat-checkbox></div><button mat-raised-button color="primary" (click)="close()">DONE</button>',
})
export class EnabledCurrenciesDialogueComponent {
constructor(
public dialogRef: MatDialogRef<EnabledCurrenciesDialogueComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) { }
onNoClick(): void {
this.dialogRef.close();
}
public close(): void {
this.dialogRef.close();
}
}

View File

@@ -28,18 +28,23 @@ export class WalletComponent implements OnInit {
this.ws.shared.subscribe(msg => {
if (msg.event === WebSocketMessageType.GetPortfolio) {
this.wallet = <Wallet>msg.data;
console.log(msg.data);
this.attachIcon(this.wallet.coin_totals);
this.attachIcon(this.wallet.coins_offline);
this.attachIcon(this.wallet.coins_online);
console.log('wallet: ' + msg.data);
console.log('message: ' + JSON.stringify(msg));
console.log('data: ' + this.wallet);
this.attachIcon(this.wallet.offline_summary.BTC);
this.attachIcon(this.wallet.offline_summary.ETH);
this.attachIcon(this.wallet.offline_summary.LTC);
if (this.wallet != null && this.wallet.coin_totals != null) {
this.attachIcon(this.wallet.coin_totals);
this.attachIcon(this.wallet.coins_offline);
this.attachIcon(this.wallet.coins_online);
this.attachIcon(this.wallet.online_summary.BTC);
this.attachIcon(this.wallet.online_summary.ETH);
this.attachIcon(this.wallet.online_summary.LTC);
this.attachIcon(this.wallet.offline_summary.BTC);
this.attachIcon(this.wallet.offline_summary.ETH);
this.attachIcon(this.wallet.offline_summary.LTC);
this.attachIcon(this.wallet.online_summary.BTC);
this.attachIcon(this.wallet.online_summary.ETH);
this.attachIcon(this.wallet.online_summary.LTC);
}
}
});
}

View File

@@ -1,17 +1,17 @@
import {inject, TestBed} from '@angular/core/testing';
import {HttpModule} from '@angular/http';
import {StyleManagerComponent} from './style-manager.component';
import {StyleManagerService} from './style-manager.service';
describe('StyleManager', () => {
let styleManager: StyleManagerComponent;
let styleManager: StyleManagerService;
beforeEach(() => TestBed.configureTestingModule({
imports: [HttpModule],
providers: [StyleManagerComponent]
providers: [StyleManagerService]
}));
beforeEach(inject([StyleManagerComponent], (sm: StyleManagerComponent) => {
beforeEach(inject([StyleManagerService], (sm: StyleManagerService) => {
styleManager = sm;
}));

View File

@@ -25,8 +25,12 @@ export class WebsocketResponseHandlerService {
this.isConnected = this.ws.isConnected;
}, 2000);
const websocketResponseMessage = JSON.parse(response.data);
const websocketResponseData = websocketResponseMessage.Data === undefined ? websocketResponseMessage.data : websocketResponseMessage.Data;
const websocketResponseEvent = websocketResponseMessage.Event === undefined ? websocketResponseMessage.event : websocketResponseMessage.Event;
const websocketResponseData = websocketResponseMessage.Data === undefined
? websocketResponseMessage.data
: websocketResponseMessage.Data;
const websocketResponseEvent = websocketResponseMessage.Event === undefined
? websocketResponseMessage.event
: websocketResponseMessage.Event;
const responseMessage = new WebSocketMessage();
responseMessage.event = websocketResponseEvent;

View File

@@ -52,7 +52,7 @@ export class WebsocketService {
}, 400);
if (ws.readyState !== WebSocket.OPEN) {
new Error('Failed to send message to websocket after 10 attempts');
throw new Error('Failed to send message to websocket after 10 attempts');
this.isConnected = false;
}
}

View File

@@ -1,6 +1,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AllEnabledCurrencyTickersComponent } from './all-enabled-currency-tickers.component';
import { AllEnabledCurrencyTickersComponent } from './all-updates-ticker.component';
describe('AllEnabledCurrencyTickersComponent', () => {
let component: AllEnabledCurrencyTickersComponent;

View File

@@ -1,5 +1,11 @@
import { inherits } from 'util';
export class CurrencyPairRedux {
Name: string;
ParsedName: string;
Enabled: boolean;
}
export class Config {
Name: string;
EncryptConfig?: number;
@@ -113,11 +119,6 @@ export class Config {
}
}
export class CurrencyPairRedux {
Name: string;
ParsedName: string;
Enabled: boolean;
}
export interface CurrencyPairFormat {
Uppercase: boolean;

View File

@@ -1,3 +1,11 @@
export class WebSocketMessageType {
public static Auth = 'auth';
public static GetConfig = 'GetConfig';
public static SaveConfig = 'SaveConfig';
public static GetPortfolio = 'GetPortfolio';
public static TickerUpdate = 'ticker_update';
}
export class WebSocketMessage {
public event: string;
public data: any;
@@ -23,11 +31,3 @@ export class WebSocketMessage {
return response;
}
}
export class WebSocketMessageType {
public static Auth = 'auth';
public static GetConfig = 'GetConfig';
public static SaveConfig = 'SaveConfig';
public static GetPortfolio = 'GetPortfolio';
public static TickerUpdate = 'ticker_update';
}

View File

@@ -1,5 +1,12 @@
import { Component, OnInit } from '@angular/core';
export class MyOrders {
public count: number;
public total: number;
public price: number;
public amount: number;
}
@Component({
selector: 'app-my-orders',
templateUrl: './my-orders.component.html',
@@ -25,11 +32,3 @@ export class MyOrdersComponent implements OnInit {
this.orders.push(item);
}
}
export class MyOrders {
public count: number;
public total: number;
public price: number;
public amount: number;
}

View File

@@ -1,5 +1,12 @@
import { Component, OnInit } from '@angular/core';
export class Order {
public count: number;
public total: number;
public price: number;
public amount: number;
}
@Component({
selector: 'app-orders',
templateUrl: './orders.component.html',
@@ -49,11 +56,3 @@ export class OrdersComponent implements OnInit {
}
}
export class Order {
public count: number;
public total: number;
public price: number;
public amount: number;
}

View File

@@ -7,11 +7,10 @@ import {CommonModule} from '@angular/common';
@Component({
selector: 'app-theme-picker',
templateUrl: 'theme-picker.html',
styleUrls: ['theme-picker.scss'],
templateUrl: 'theme-picker.component.html',
styleUrls: ['theme-picker.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
host: {'aria-hidden': 'true'},
})
export class ThemePickerComponent {
currentTheme;

View File

@@ -1,5 +1,11 @@
import { Component, OnInit } from '@angular/core';
export class TradeHistoryOrder {
public price: number;
public time: Date;
public amount: number;
}
@Component({
selector: 'app-trade-history',
templateUrl: './trade-history.component.html',
@@ -45,12 +51,4 @@ export class TradeHistoryComponent implements OnInit {
this.orders.push(item);
this.orders.push(item);
}
}
export class TradeHistoryOrder {
public price: number;
public time: Date;
public amount: number;
}

View File

@@ -18,38 +18,6 @@
* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
// import 'core-js/es6/symbol';
// import 'core-js/es6/object';
// import 'core-js/es6/function';
// import 'core-js/es6/parse-int';
// import 'core-js/es6/parse-float';
// import 'core-js/es6/number';
// import 'core-js/es6/math';
// import 'core-js/es6/string';
// import 'core-js/es6/date';
// import 'core-js/es6/array';
// import 'core-js/es6/regexp';
// import 'core-js/es6/map';
// import 'core-js/es6/set';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following to support `@angular/animation`. */
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
/** ALL Firefox browsers require the following to support `@angular/animation`. **/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/***************************************************************************************************
* Zone JS is required by Angular itself.
*/
@@ -59,9 +27,3 @@ import 'zone.js/dist/zone-mix'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
/**
* Date, currency, decimal and percent pipes.
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
*/
// import 'intl'; // Run `npm install --save intl`.

View File

@@ -13,7 +13,7 @@
],
"lib": [
"es2017",
"dom"
"dom",
]
}
}

View File

@@ -22,8 +22,7 @@
"eofline": true,
"forin": true,
"import-blacklist": [
true,
"rxjs/Rx"
true
],
"import-spacing": true,
"indent": [