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

Commit

Permalink
Used number pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelCoding committed Mar 16, 2022
1 parent 373541e commit 82b1a69
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="item">
<span class="name">{{item.shopItem.name}}</span>
<div class="control">
<span class="price control-item">{{item.shopItem.price * item.quantity / 1000}} MC</span>
<span class="price control-item">{{(item.shopItem.price * item.quantity / 1000) | number}} MC</span>
<form [formGroup]="formGroup" class="number control-item">
<label><input (blur)="updateQuantityField()" formControlName="quantity" max="50" min="1" step="1"
type="number"></label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="title">
<h1>Cart ({{items.length}} Items)</h1>
<div class="control">
<span>Total {{cartMorphCoins}} MC</span>
<span>Total {{cartMorphCoins | number}} MC</span>
<span (click)="buy()" [className]="hasEnoughMorphCoins ? 'btn btn-success' : 'btn btn-disabled'">Buy</span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class HardwareShopCartComponent implements OnDestroy {
constructor(private hardwareShopService: HardwareShopService,
private walletAppService: WalletAppService) {
this.items = this.hardwareShopService.getCartItems();
this.cartMorphCoins = 'Loading...';
this.cartMorphCoins = 0;
setTimeout(() => this.cartMorphCoins = this.getTotalPrice(), 250);
this.subscriptions.add(
this.hardwareShopService.updateCartItems.subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div class="right">
<span *ngIf="!(morphCoins >= 0)">No wallet found.</span>
<span *ngIf="morphCoins >= 0">{{morphCoins / 1000}} MC</span>
<span *ngIf="morphCoins >= 0">{{(morphCoins / 1000) | number}} MC</span>
</div>

</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
</div>

<div class="footer">
<span>{{item.price / 1000}} MC</span>
<span>{{(item.price / 1000) | number}} MC</span>

<span (click)="removeFromCart(); $event.stopPropagation()" *ngIf="inCart" class="btn btn-error">Remove</span>
<span (click)="addToCart(); $event.stopPropagation()" *ngIf="!inCart" class="btn btn-success">Add</span>
</div>
</div>

<div #specificationsDiv *ngIf="specificationsVisible" [@expandCollapse] [style.columns]="getSpecificationsColumnCount(specificationsDiv.clientWidth)"
<div #specificationsDiv *ngIf="specificationsVisible" @expandCollapse [style.columns]="getSpecificationsColumnCount(specificationsDiv.clientWidth)"
class="specifications">
<h3>Technical specifications</h3>
<div *ngFor="let category of specifications | keyvalue: originalOrder" class="category">
Expand Down
13 changes: 7 additions & 6 deletions src/app/desktop/windows/terminal/terminal-states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {Device} from '../../../api/devices/device';
import {WindowDelegate} from '../../window/window-delegate';
import {File} from '../../../api/files/file';
import {BruteforceTerminalState, YesNoTerminalState} from "./TerminalStateImpls";
import {MinerComponent} from "../miner/miner.component";
import {formatNumber} from "@angular/common";


function escapeHtml(html: string) {
Expand Down Expand Up @@ -46,7 +46,7 @@ export abstract class CommandTerminalState implements TerminalState {

// Only successful and not-flagged commands will be shown in the protocol.
if (!this.commands[command].hideFromProtocol) {
if (args.length>0) {
if (args.length > 0) {
this.protocol.unshift(command + ' ' + args.join(' '));
} else {
this.protocol.unshift(command);
Expand Down Expand Up @@ -206,7 +206,7 @@ export class DefaultTerminalState extends CommandTerminalState {

working_dir: string | null = Path.ROOT; // UUID of the working directory

constructor(protected websocket: WebsocketService, private settings: SettingsService, private fileService: FileService,
constructor(private locale: string, protected websocket: WebsocketService, private settings: SettingsService, private fileService: FileService,
private domSanitizer: DomSanitizer, protected windowDelegate: WindowDelegate, protected activeDevice: Device,
protected terminal: TerminalAPI, public promptColor: string | null = null) {
super();
Expand Down Expand Up @@ -300,7 +300,7 @@ export class DefaultTerminalState extends CommandTerminalState {
power = Math.round(data['power'] * 100);
text =
'Wallet: ' + wallet + '<br>' +
'Mining Speed: ' + String(Number(miner.speed) * 60 * 60) + ' MC/h<br>' +
'Mining Speed: ' + String(formatNumber(Number(miner.speed) * 60 * 60, this.locale)) + ' MC/h<br>' +
'Power: ' + power + '%';
this.terminal.output(text);
});
Expand Down Expand Up @@ -829,7 +829,7 @@ export class DefaultTerminalState extends CommandTerminalState {

// The history is stored in reverse.
// Because of that this loop has to run in reverse.
for (let i = history.length-1; i >= 0; i--) {
for (let i = history.length - 1; i >= 0; i--) {
this.terminal.outputText(history[i]);
}
} else {
Expand Down Expand Up @@ -878,7 +878,7 @@ export class DefaultTerminalState extends CommandTerminalState {
if (uuid.match(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/) && key.match(/^[a-f0-9]{10}$/)) {
this.websocket.ms('currency', ['get'], {source_uuid: uuid, key: key}).subscribe({
next: (wallet) => {
this.terminal.outputText(new Intl.NumberFormat().format(wallet.amount / 1000) + ' morphcoin');
this.terminal.outputText(formatNumber(wallet.amount / 1000, this.locale) + ' morphcoin');
},
error: () => {
this.terminal.outputText('That file is not connected with a wallet');
Expand Down Expand Up @@ -1291,6 +1291,7 @@ export class DefaultTerminalState extends CommandTerminalState {
if (infoData['owner'] === this.websocket.account.uuid || partOwnerData['ok'] === true) {
this.terminal.pushState(
new DefaultTerminalState(
this.locale,
this.websocket,
this.settings,
this.fileService,
Expand Down
6 changes: 4 additions & 2 deletions src/app/desktop/windows/terminal/terminal.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SettingsService} from '../settings/settings.service';
import {Component, ElementRef, OnInit, SecurityContext, Type, ViewChild} from '@angular/core';
import {Component, ElementRef, Inject, LOCALE_ID, OnInit, SecurityContext, Type, ViewChild} from '@angular/core';
import {WindowComponent, WindowDelegate} from '../../window/window-delegate';
import {TerminalAPI, TerminalState} from './terminal-api';
import {DefaultTerminalState} from './terminal-states';
Expand Down Expand Up @@ -29,14 +29,16 @@ export class TerminalComponent extends WindowComponent implements OnInit, Termin
private settings: SettingsService,
private fileService: FileService,
private windowManager: WindowManager,
private domSanitizer: DomSanitizer
private domSanitizer: DomSanitizer,
@Inject(LOCALE_ID) private locale: string
) {
super();
}

ngOnInit() {
this.pushState(
new DefaultTerminalState(
this.locale,
this.websocket,
this.settings,
this.fileService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>

<div class="right">
<span *ngIf="wallet">{{wallet.amount / 1000}} MC</span>
<span *ngIf="wallet">{{(wallet.amount / 1000) | number}} MC</span>
</div>

</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<span>
Amount:
<span [ngClass]="{'green': moneyToCurrent, 'red': !moneyToCurrent}">
<span *ngIf="moneyToCurrent">+</span><span *ngIf="!moneyToCurrent">-</span>{{transaction.send_amount / 1000}} MC
<span *ngIf="moneyToCurrent">+</span><span *ngIf="!moneyToCurrent">-</span>{{(transaction.send_amount / 1000 | number)}} MC
</span>
</span>
<span>{{time}}</span>
Expand Down

0 comments on commit 82b1a69

Please sign in to comment.