mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Supports updated JSON config (#134)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gocryptotrader-web",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"description": "Front-end interface for GoCryptoTrader",
|
||||
"homepage": "https://github.com/thrasher-/gocryptotrader",
|
||||
"author": {
|
||||
@@ -9,13 +9,11 @@
|
||||
"github": "https://github.com/gloriousCode/",
|
||||
"website": "https://www.gloriousedge.com"
|
||||
},
|
||||
"contributers": [
|
||||
{
|
||||
"name": "Maxime GRIS",
|
||||
"email": "maxime.gris@gmail.com",
|
||||
"github": "https://github.com/maximegris/"
|
||||
}
|
||||
],
|
||||
"contributers": [{
|
||||
"name": "Maxime GRIS",
|
||||
"email": "maxime.gris@gmail.com",
|
||||
"github": "https://github.com/maximegris/"
|
||||
}],
|
||||
"keywords": [
|
||||
"angular",
|
||||
"electron",
|
||||
@@ -97,4 +95,4 @@
|
||||
"webdriver-manager": "12.0.6",
|
||||
"zone.js": "0.8.26"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
<div *ngIf="settings !== null && ready">
|
||||
<button matTooltip="Save" (click)="saveSettings()" mat-fab color="accent" class="mat-fab mat-fab-bottom-right"><mat-icon >save</mat-icon></button>
|
||||
<mat-accordion>
|
||||
<!--WEBSOCKET SETTINGS-->
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
@@ -19,16 +20,48 @@
|
||||
<input matInput name="username" [(ngModel)]="settings.Webserver.AdminUsername" placeholder="Username">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="password" type="password" [(ngModel)]="settings.Webserver.AdminPassword" placeholder="Password">
|
||||
<input matInput name="password" type="password" [(ngModel)]="settings.Webserver.AdminPassword" placeholder="Password">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input type="number" matInput name="connection-limit" [(ngModel)]="settings.Webserver.WebsocketConnectionLimit" placeholder="Websocket connection limit">
|
||||
<input type="number" matInput name="connection-limit" [(ngModel)]="settings.Webserver.WebsocketConnectionLimit" placeholder="Websocket connection limit">
|
||||
</mat-form-field>
|
||||
<mat-checkbox name="allow-insecure-origin" [(ngModel)]="settings.Webserver.WebsocketAllowInsecureOrigin">Allow Insecure Websocket Origin</mat-checkbox>
|
||||
|
||||
|
||||
</form>
|
||||
</mat-expansion-panel>
|
||||
|
||||
|
||||
<!--CURRENCY SETTINGS-->
|
||||
<mat-expansion-panel *ngFor="let provider of settings.CurrencyConfig?.ForexProviders">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
{{provider.Name}}
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
Forex Providers
|
||||
<mat-icon>attach_money</mat-icon>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<form class="form-content">
|
||||
<mat-checkbox name="fpEnabled" [(ngModel)]="provider.Enabled">Enabled</mat-checkbox>
|
||||
<div mat-line></div>
|
||||
<mat-checkbox name="fpVerbose" [(ngModel)]="provider.Verbose" [disabled]="!provider.Enabled">Verbose</mat-checkbox>
|
||||
<div mat-line></div>
|
||||
<div mat-line></div>
|
||||
<mat-form-field>
|
||||
<input matInput name="fpPollingDelay" type="number" [(ngModel)]="provider.RESTPollingDelay" [disabled]="!provider.Enabled" placeholder="Polling Delay">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="fpKey" type="password" [(ngModel)]="provider.APIKey" [disabled]="!provider.Enabled" placeholder="APIKey">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="fpKeyLevel" [(ngModel)]="provider.APIKeyLvl" [disabled]="!provider.Enabled" placeholder="APIKey Level">
|
||||
</mat-form-field>
|
||||
<mat-checkbox name="fpPrimary" [(ngModel)]="provider.PrimaryProvider">Primary Provider</mat-checkbox>
|
||||
</form>
|
||||
|
||||
</mat-expansion-panel>
|
||||
|
||||
<!--SMS SETTINGS-->
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
@@ -40,23 +73,25 @@
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<form class="form-content">
|
||||
<mat-checkbox name="smsEnabled" [(ngModel)]="settings.SMSGlobal.Enabled">Enabled</mat-checkbox>
|
||||
<mat-checkbox name="smsEnabled" [(ngModel)]="settings.Communications.SMSGlobal.Enabled">Enabled</mat-checkbox>
|
||||
<div mat-line></div>
|
||||
<mat-checkbox name="smsVerbose" [(ngModel)]="settings.Communications.SMSGlobal.Verbose" [disabled]="!settings?.Communications.SMSGlobal.Enabled">Verbose</mat-checkbox>
|
||||
<div mat-line></div>
|
||||
<mat-form-field>
|
||||
<input matInput name="smsUsername" [(ngModel)]="settings.SMSGlobal.Username" [disabled]="!settings?.SMSGlobal.Enabled" placeholder="Username">
|
||||
<input matInput name="smsUsername" [(ngModel)]="settings.Communications.SMSGlobal.Username" [disabled]="!settings?.Communications.SMSGlobal.Enabled" placeholder="Username">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="smsPassword" type="password" [(ngModel)]="settings.SMSGlobal.Password" [disabled]="!settings?.SMSGlobal.Enabled" placeholder="Password">
|
||||
<input matInput name="smsPassword" type="password" [(ngModel)]="settings.Communications.SMSGlobal.Password" [disabled]="!settings?.Communications.SMSGlobal.Enabled" placeholder="Password">
|
||||
</mat-form-field>
|
||||
|
||||
<div *ngFor="let contact of settings.SMSGlobal?.Contacts">
|
||||
<mat-checkbox name="contactEnabled" [disabled]="!settings?.SMSGlobal.Enabled" [(ngModel)]="contact.Enabled">Enabled</mat-checkbox>
|
||||
|
||||
<div *ngFor="let contact of settings.Communications.SMSGlobal?.Contacts">
|
||||
<mat-checkbox name="contactEnabled" [disabled]="!settings?.Communications.SMSGlobal.Enabled" [(ngModel)]="contact.Enabled">Enabled</mat-checkbox>
|
||||
<div mat-line></div>
|
||||
<mat-form-field>
|
||||
<input matInput name="contactUsername" [(ngModel)]="contact.Name" [disabled]="!settings.SMSGlobal.Enabled || !contact.Enabled" placeholder="Contact Name" />
|
||||
<input matInput name="contactUsername" [(ngModel)]="contact.Name" [disabled]="!settings.Communications.SMSGlobal.Enabled || !contact.Enabled" placeholder="Contact Name" />
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="contactPassword" [(ngModel)]="contact.Number" [disabled]="!settings.SMSGlobal.Enabled || !contact.Enabled" placeholder="Contact Number" />
|
||||
<input matInput name="contactPassword" [(ngModel)]="contact.Number" [disabled]="!settings.Communications.SMSGlobal.Enabled || !contact.Enabled" placeholder="Contact Number" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</form>
|
||||
@@ -65,34 +100,118 @@
|
||||
</mat-action-row>
|
||||
</mat-expansion-panel>
|
||||
|
||||
|
||||
<!--SLACK SETTINGS-->
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Wallets
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
Wallet Address Settings
|
||||
<mat-icon>account_balance_wallet</mat-icon>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<div *ngFor="let wallet of settings.PortfolioAddresses?.Addresses">
|
||||
<mat-form-field class="long">
|
||||
<input matInput name="wallet-address" [(ngModel)]="wallet.Address" placeholder="Address" />
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="wallet-cointype" [(ngModel)]="wallet.CoinType" placeholder="Coin Type" />
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="wallet-description" [(ngModel)]="wallet.Description" placeholder="Description" />
|
||||
</mat-form-field>
|
||||
<button mat-button (click)="removeWallet(wallet)">REMOVE</button>
|
||||
</div>
|
||||
<mat-action-row>
|
||||
<button mat-button (click)="addWallet()">ADD</button>
|
||||
</mat-action-row>
|
||||
</mat-expansion-panel>
|
||||
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Slack Notifications
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
Notification Settings
|
||||
<mat-icon>apps</mat-icon>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<form class="form-content">
|
||||
<mat-checkbox name="slackEnabled" [(ngModel)]="settings.Communications.Slack.Enabled">Enabled</mat-checkbox>
|
||||
<div mat-line></div>
|
||||
<mat-checkbox name="slackVerbose" [disabled]="!settings?.Communications.Slack.Enabled" [(ngModel)]="settings.Communications.Slack.Verbose">Verbose</mat-checkbox>
|
||||
<div mat-line></div>
|
||||
<mat-form-field>
|
||||
<input matInput name="slackTargetChannel" [(ngModel)]="settings.Communications.Slack.TargetChannel" [disabled]="!settings?.Communications.Slack.Enabled" placeholder="Target Channel">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="slackVerificationToken" type="password" [(ngModel)]="settings.Communications.Slack.VerificationToken" [disabled]="!settings?.Communications.Slack.Enabled" placeholder="Verification Token">
|
||||
</mat-form-field>
|
||||
</form>
|
||||
</mat-expansion-panel>
|
||||
|
||||
<!--SMTP SETTINGS-->
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
SMTP Notifications
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
Notification Settings
|
||||
<mat-icon>mail_outline</mat-icon>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<form class="form-content">
|
||||
<mat-checkbox name="smtpEnabled" [(ngModel)]="settings.Communications.SMTP.Enabled">Enabled</mat-checkbox>
|
||||
<div mat-line></div>
|
||||
<mat-checkbox name="smtpVerbose" [disabled]="!settings?.Communications.SMTP.Enabled" [(ngModel)]="settings.Communications.SMTP.Verbose">Verbose</mat-checkbox>
|
||||
<div mat-line></div>
|
||||
<mat-form-field>
|
||||
<input matInput name="smtpHost" [(ngModel)]="settings.Communications.SMTP.Host" [disabled]="!settings?.Communications.SMTP.Enabled" placeholder="Host">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="smtpPort" type="nunber" [(ngModel)]="settings.Communications.SMTP.Port" [disabled]="!settings?.Communications.SMTP.Enabled" placeholder="Verification Token">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="smtpAccountName" [(ngModel)]="settings.Communications.SMTP.AccountName" [disabled]="!settings?.Communications.SMTP.Enabled" placeholder="Account Name">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<input matInput name="smtpPassword" type="password" [(ngModel)]="settings.Communications.SMTP.AccountPassword" [disabled]="!settings?.Communications.SMTP.Enabled" placeholder="Account Name">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<input matInput name="smtpRecipientList" [(ngModel)]="settings.Communications.SMTP.RecipientList" [disabled]="!settings?.Communications.SMTP.Enabled" placeholder="Recipient List (comma seperated)">
|
||||
</mat-form-field>
|
||||
</form>
|
||||
</mat-expansion-panel>
|
||||
|
||||
<!--TELEGRAM SETTINGS-->
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Telegram Notifications
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
Notification Settings
|
||||
<mat-icon>send</mat-icon>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<form class="form-content">
|
||||
<mat-checkbox name="telegramEnabled" [(ngModel)]="settings.Communications.Telegram.Enabled">Enabled</mat-checkbox>
|
||||
<div mat-line></div>
|
||||
<mat-checkbox name="telegramVerbose" [disabled]="!settings?.Communications.Telegram.Enabled" [(ngModel)]="settings.Communications.Telegram.Verbose">Verbose</mat-checkbox>
|
||||
<div mat-line></div>
|
||||
<mat-form-field>
|
||||
<input matInput name="slackVerificationToken" type="password" [(ngModel)]="settings.Communications.Telegram.VerificationToken" [disabled]="!settings?.Communications.Telegram.Enabled" placeholder="Verification Token">
|
||||
</mat-form-field>
|
||||
</form>
|
||||
</mat-expansion-panel>
|
||||
|
||||
<!--WALLET SETTINGS-->
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Wallets
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
Wallet Address Settings
|
||||
<mat-icon>account_balance_wallet</mat-icon>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<div *ngFor="let wallet of settings.PortfolioAddresses?.Addresses">
|
||||
<mat-form-field class="long">
|
||||
<input matInput name="wallet-address" [(ngModel)]="wallet.Address" placeholder="Address" />
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="wallet-cointype" [(ngModel)]="wallet.CoinType" placeholder="Coin Type" />
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput name="wallet-description" [(ngModel)]="wallet.Description" placeholder="Description" />
|
||||
</mat-form-field>
|
||||
<button mat-button (click)="removeWallet(wallet)">REMOVE</button>
|
||||
</div>
|
||||
<mat-action-row>
|
||||
<button mat-button (click)="addWallet()">ADD</button>
|
||||
</mat-action-row>
|
||||
</mat-expansion-panel>
|
||||
|
||||
<!--EXCHANGE SETTINGS-->
|
||||
<mat-expansion-panel *ngFor="let exchange of settings?.Exchanges">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
@@ -119,7 +238,7 @@
|
||||
<h4>
|
||||
Enabled currencies
|
||||
</h4>
|
||||
<p ><span *ngFor="let pair of exchange.Pairs | enabledCurrencies; let isLast=last">{{pair.Name}}{{isLast ? '' : ', '}}</span> </p>
|
||||
<p><span *ngFor="let pair of exchange.Pairs | enabledCurrencies; let isLast=last">{{pair.Name}}{{isLast ? '' : ', '}}</span> </p>
|
||||
<button mat-button [disabled]="!exchange.Enabled" (click)="openModal(exchange.Pairs)">CHANGE</button>
|
||||
</form>
|
||||
</mat-expansion-panel>
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { inherits } from "util";
|
||||
|
||||
export class Config {
|
||||
export class Config {
|
||||
Name: string;
|
||||
EncryptConfig?: number;
|
||||
Cryptocurrencies: string;
|
||||
CurrencyExchangeProvider: string;
|
||||
CurrencyPairFormat: CurrencyPairFormat;
|
||||
PortfolioAddresses: PortfolioAddresses;
|
||||
SMSGlobal: SMSGlobal;
|
||||
Webserver: Webserver;
|
||||
Exchanges: Exchange[];
|
||||
Communications: Communcations;
|
||||
CurrencyConfig: CurrencyConfig;
|
||||
|
||||
public isConfigCacheValid() : boolean {
|
||||
let dateStored = +new Date(window.localStorage['configDate']);
|
||||
@@ -25,28 +27,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
public setConfig(data: any) : void {
|
||||
var configData = <Config>data;
|
||||
this.Cryptocurrencies = configData.Cryptocurrencies
|
||||
this.CurrencyExchangeProvider = configData.CurrencyExchangeProvider
|
||||
this.Exchanges = configData.Exchanges
|
||||
this.CurrencyPairFormat = configData.CurrencyPairFormat
|
||||
this.EncryptConfig = configData.EncryptConfig
|
||||
this.Exchanges = configData.Exchanges
|
||||
this.Name = configData.Name
|
||||
this.PortfolioAddresses = configData.PortfolioAddresses
|
||||
this.SMSGlobal = configData.SMSGlobal
|
||||
this.Webserver = configData.Webserver
|
||||
if(configData.Exchanges.length > 0
|
||||
&& configData.Exchanges[0].Pairs
|
||||
&& configData.Exchanges[0].Pairs.length > 0) {
|
||||
console.log('Successfully retrieved well-formed pairs');
|
||||
return;
|
||||
}
|
||||
this.fromArrayToRedux();
|
||||
//Rewrite to cache on parsing to redux array
|
||||
this.saveToCache();
|
||||
public setConfig(data: any): void {
|
||||
var configData = <Config>data;
|
||||
this.Cryptocurrencies = configData.Cryptocurrencies;
|
||||
this.CurrencyExchangeProvider = configData.CurrencyExchangeProvider;
|
||||
this.Exchanges = configData.Exchanges;
|
||||
this.CurrencyPairFormat = configData.CurrencyPairFormat;
|
||||
this.EncryptConfig = configData.EncryptConfig;
|
||||
this.Exchanges = configData.Exchanges;
|
||||
this.Name = configData.Name;
|
||||
this.PortfolioAddresses = configData.PortfolioAddresses;
|
||||
this.Communications = configData.Communications;
|
||||
this.CurrencyConfig = configData.CurrencyConfig;
|
||||
this.Webserver = configData.Webserver;
|
||||
if (configData.Exchanges.length > 0
|
||||
&& configData.Exchanges[0].Pairs
|
||||
&& configData.Exchanges[0].Pairs.length > 0) {
|
||||
console.log('Successfully retrieved well-formed pairs');
|
||||
return;
|
||||
}
|
||||
this.fromArrayToRedux();
|
||||
//Rewrite to cache on parsing to redux array
|
||||
this.saveToCache();
|
||||
}
|
||||
|
||||
public saveToCache() : void {
|
||||
window.localStorage['config'] = JSON.stringify(this);
|
||||
@@ -135,18 +138,12 @@ export class CurrencyPairRedux {
|
||||
|
||||
}
|
||||
|
||||
export interface Contact {
|
||||
export class SMSGlobalContact {
|
||||
Name: string;
|
||||
Number: string;
|
||||
Enabled: boolean;
|
||||
}
|
||||
|
||||
export interface SMSGlobal {
|
||||
Enabled: boolean;
|
||||
Username: string;
|
||||
Password: string;
|
||||
Contacts: Contact[];
|
||||
}
|
||||
|
||||
export interface Webserver {
|
||||
Enabled: boolean;
|
||||
@@ -187,7 +184,72 @@ export class CurrencyPairRedux {
|
||||
RequestCurrencyPairFormat: RequestCurrencyPairFormat;
|
||||
ClientID: string;
|
||||
Pairs: CurrencyPairRedux[];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class Communcations {
|
||||
Slack: SlackCommunication;
|
||||
SMSGlobal: SMSGlobalCommunication;
|
||||
SMTP: SMTPCommunication;
|
||||
Telegram: TelegramCommunication;
|
||||
}
|
||||
|
||||
|
||||
export class SlackCommunication {
|
||||
Name: string;
|
||||
Enabled: boolean;
|
||||
Verbose: boolean;
|
||||
TargetChannel: string;
|
||||
VerificationToken: string;
|
||||
}
|
||||
|
||||
export class SMSGlobalCommunication {
|
||||
Name: string;
|
||||
Enabled: boolean;
|
||||
Verbose: boolean;
|
||||
Username: string;
|
||||
Password: string;
|
||||
Contacts: SMSGlobalContact[];
|
||||
}
|
||||
|
||||
export class SMTPCommunication {
|
||||
Name: string;
|
||||
Enabled: boolean;
|
||||
Verbose: boolean;
|
||||
Host: string;
|
||||
Port: number;
|
||||
AccountName: string;
|
||||
AccountPassword: string;
|
||||
RecipentList: string;
|
||||
}
|
||||
|
||||
export class TelegramCommunication {
|
||||
Name: string;
|
||||
Enabled: boolean;
|
||||
Verbose: boolean;
|
||||
VerificationToken: string;
|
||||
}
|
||||
|
||||
export class CurrencyConfig {
|
||||
ForexProviders: ForexProviders[];
|
||||
Cyptocurrencies: string;
|
||||
CurrencyPairFormat: CurrencyPairFormat;
|
||||
FiatDisplayCurrency: string;
|
||||
}
|
||||
|
||||
export class ForexProviders {
|
||||
Name: string;
|
||||
Enabled: boolean;
|
||||
Verbose: boolean;
|
||||
RESTPollingDelay: number;
|
||||
APIKey: string;
|
||||
PrimaryProvier: boolean;
|
||||
}
|
||||
|
||||
export class CurrencyPairFormat {
|
||||
Uppercase: boolean;
|
||||
Delimiter: string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user