Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
Created an for user to choose days how much back he wants to see hist…
Browse files Browse the repository at this point in the history
…ory in graph (#113)

* Ready

* Package lock file
  • Loading branch information
sjaanus authored and Viktor Gullmark committed Jan 14, 2019
1 parent 7e24718 commit 87e475f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
Expand Up @@ -8,6 +8,7 @@ import { ChartSeries, ChartSeriesEntry } from '../../../shared/interfaces/chart.
import { Player } from '../../../shared/interfaces/player.interface';
import { AccountService } from '../../../shared/providers/account.service';
import { IncomeService } from '../../../shared/providers/income.service';
import { SettingsService } from '../../../shared/providers/settings.service';
import { PartyService } from '../../../shared/providers/party.service';


Expand Down Expand Up @@ -46,7 +47,8 @@ export class IncomeComponent implements OnInit, OnDestroy {
selectedColorScheme: string;

constructor(
private partyService: PartyService
private partyService: PartyService,
private settingService: SettingsService,
) {
}

Expand Down Expand Up @@ -104,17 +106,17 @@ export class IncomeComponent implements OnInit, OnDestroy {
updateGraph(player: Player) {
const playerObj = Object.assign({}, player);

if (this.isSummary) {
const oneDayAgo = (Date.now() - (24 * 60 * 60 * 1000));
playerObj.netWorthSnapshots = playerObj.netWorthSnapshots.filter(x => x.timestamp > oneDayAgo);
if (playerObj.netWorthSnapshots.length === 0) {
playerObj.netWorthSnapshots = [{
timestamp: 0,
value: 0,
items: []
}];
}
const netWorthHistoryDays = this.settingService.get('netWorthHistoryDays');
const daysAgo = (Date.now() - (netWorthHistoryDays * 24 * 60 * 60 * 1000));
playerObj.netWorthSnapshots = playerObj.netWorthSnapshots.filter(x => x.timestamp > daysAgo);
if (playerObj.netWorthSnapshots.length === 0) {
playerObj.netWorthSnapshots = [{
timestamp: 0,
value: 0,
items: []
}];
}

const entry: ChartSeries = {
name: playerObj.character.name + ' (' + moment(playerObj.netWorthSnapshots[0].timestamp).fromNow() + ')',
series: playerObj.netWorthSnapshots.map(snapshot => {
Expand Down
15 changes: 15 additions & 0 deletions ExilenceClient/src/app/authorize/settings/settings.component.html
Expand Up @@ -199,6 +199,21 @@ <h3 class="mat-h4 page-header new-section">Calculations</h3>
<mat-option value="24">24 hours</mat-option>
</mat-select>
</mat-form-field>
<h3 class="mat-h4 page-header new-section">History</h3>
<mat-divider class="divider"></mat-divider>
<p class="setting-desc-text">
Choose how much days back in history the "Net worth graph" shows
</p>
<mat-form-field>
<mat-label>Net worth history for</mat-label>
<mat-select #fontSize value="{{netWorthHistoryDays}}" (selectionChange)="toggleNetWorthHistoryDays($event)">
<mat-option value="1">1 day</mat-option>
<mat-option value="2">2 days</mat-option>
<mat-option value="3">3 days</mat-option>
<mat-option value="7">7 days</mat-option>
<mat-option value="14">14 days</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>

Expand Down
Expand Up @@ -30,6 +30,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
uploaded = false;
itemValueTreshold = 1;
gainHours = 1;
netWorthHistoryDays = 14;

// temporary arrays
modifierKeys = [
Expand Down Expand Up @@ -113,6 +114,8 @@ export class SettingsComponent implements OnInit, OnDestroy {
this.settingsService.get('itemValueTreshold') !== undefined ? this.settingsService.get('itemValueTreshold') : 1;
this.gainHours =
this.settingsService.get('gainHours') !== undefined ? this.settingsService.get('gainHours') : 3;
this.netWorthHistoryDays =
this.settingsService.get('netWorthHistoryDays') !== undefined ? this.settingsService.get('netWorthHistoryDays') : 14;
if (!this.sessionIdValid || this.sessionId === '') {
this.selectedIndex = 1;
}
Expand Down Expand Up @@ -191,6 +194,10 @@ export class SettingsComponent implements OnInit, OnDestroy {
this.settingsService.set('gainHours', +event.value);
}

toggleNetWorthHistoryDays(event) {
this.settingsService.set('netWorthHistoryDays', +event.value);
}

toggleAlwaysOnTop() {
if (this.alwaysOnTop) {
// set window on top
Expand Down
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 87e475f

Please sign in to comment.