Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue26 #27

Merged
merged 5 commits into from
Jan 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,42 @@ import { WalletComponent } from './wallet/wallet.component';
import { ProfileComponent } from './profile/profile.component';
import { PagenotfoundComponent } from './pagenotfound/pagenotfound.component';
import { SteemconnectRedirectGuard } from './redirect/steemconnect-redirect.guard';
import {BuyPageComponent} from './buy-page/buy-page.component'
import {SellPageComponent} from './sell-page/sell-page.component';
import {PurchaseComponent} from './purchase/purchase.component';
import {RedirectComponent} from './redirect/redirect.component';
import {ChatPageComponent} from './chat-page/chat-page.component';
import { BuyPageComponent } from './buy-page/buy-page.component'
import { SellPageComponent } from './sell-page/sell-page.component';
import { PurchaseComponent } from './purchase/purchase.component';
import { RedirectComponent } from './redirect/redirect.component';
import { ChatPageComponent } from './chat-page/chat-page.component';

const appRoutes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'buy-online', component: BuyPageComponent},
{ path: 'sell-online', component: SellPageComponent },
{ path: 'post-trade', component: PostTradeComponent },
{ path: 'buy-online', component: BuyPageComponent },
{ path: 'sell-online', component: SellPageComponent },
{
path: 'post-trade',
children: [
{
path: ':id',
component: PostTradeComponent
},
{
path: '',
component: PostTradeComponent
},
]
},
{ path: 'notifications', component: NotificationsComponent },
{ path: 'wallet', component: WalletComponent },
{ path: 'profile', component: ProfileComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: 'purchase/:id', component: PurchaseComponent},
{path: 'chat/:id' , component: ChatPageComponent},
{ path: 'wallet', component: WalletComponent },
{ path: 'profile', component: ProfileComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: 'purchase/:id', component: PurchaseComponent },
{ path: 'chat/:id', component: ChatPageComponent },
{
path: 'steemconnect/redirect',
canActivate: [SteemconnectRedirectGuard],
component: RedirectComponent
},
{ path: '',
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { ChatPageComponent } from './chat-page/chat-page.component';
import { AuthInterceptor } from './../service/auth.intercepter';
import {MomentModule} from 'angular2-moment';
import {NgxAutoScrollModule} from 'ngx-auto-scroll';
import { TradePipePipe } from '../pipes/trade-pipe.pipe';

const config: SocketIoConfig = { url: 'http://swapsteem-api.herokuapp.com', options: {} };

Expand All @@ -60,7 +61,8 @@ const config: SocketIoConfig = { url: 'http://swapsteem-api.herokuapp.com', opti
BuySbdComponent,
SellSbdComponent,
SellSteemComponent,
ChatPageComponent
ChatPageComponent,
TradePipePipe
],
imports: [
NgxAutoScrollModule,
Expand Down
4 changes: 2 additions & 2 deletions src/app/buy/buy.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ <h6 class="buyHeading">Buy Steem Online In USA</h6>
<th class="">Price/Coin</th>
<th></th>
</tr>
<tr *ngFor = "let buySteem of buyDetails | async">
<tr *ngFor = "let buySteem of buyDetails | async | tradePipe: 'ad_status' : 'pause'">
<td>{{buySteem.createdby}}</td>
<td>{{buySteem.payment_methods}}</td>
<td>{{buySteem.ad_coin}}</td>
<td>{{buySteem.currency}}</td>
<td>{{buySteem.limit_from}} - {{buySteem.limit_to}}</td>
<td><span >{{calculatePrice(buySteem.ad_coin,buySteem.currency)}}</span></td>
<td><span >{{calculatePrice(buySteem.ad_coin,buySteem.currency, buySteem.margin)}}</span></td>
<td><button type="button" class="btn btn-success btn-sm badge badge-pill" (click)="buyTrade(buySteem)">Buy</button></td>
</tr>
</table>
Expand Down
60 changes: 30 additions & 30 deletions src/app/buy/buy.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
//import {take, tap} from 'rxjs/operators';
import {Observable} from 'rxjs';
import {APIService} from '../../service/api.service';
import { Observable } from 'rxjs';
import { APIService } from '../../service/api.service';
import { Router } from '@angular/router';
import {AdvertisementResponse} from '../module/advertisement';
import { AdvertisementResponse } from '../module/advertisement';

@Component({
selector: 'app-buy',
Expand All @@ -14,55 +14,55 @@ import {AdvertisementResponse} from '../module/advertisement';
export class BuyComponent implements OnInit {
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */

constructor(private http : HttpClient,
private purchaseSer : APIService,
private router : Router){}
buyDetails : Observable<AdvertisementResponse[]> ;
steemPrice : any;
sbdPrice : any;
constructor(private http: HttpClient,
private purchaseSer: APIService,
private router: Router) { }

buyDetails: Observable<AdvertisementResponse[]>;
steemPrice: any;
sbdPrice: any;

ngOnInit() {
this.buyDetails = this.purchaseSer.getBuyAds();
//this.buyDetails = this.http.get<AdvertisementResponse>('http://swapsteem-api.herokuapp.com/advertisements');
//this.buyDetails = this.http.get<Advertisement>('../../assets/sample-buy-online.json');
this.purchaseSer.getPrice().subscribe( data => {
this.purchaseSer.getPrice().subscribe(data => {
let resPrice = Object.values(data);
let calSteemPrice = Object.values(resPrice[0]);
let calSBDPrice = Object.values(resPrice[1])
this.steemPrice = calSteemPrice;
this.sbdPrice = calSBDPrice;

})
}
calculatePrice(from:String,to:String){
if(from=="STEEM"){
switch(to){
case "USD":
return this.steemPrice[0];
calculatePrice(from: string, to: string, margin: number) {
if (from == "STEEM") {
switch (to) {
case "USD":
return Math.round(this.steemPrice[0] * (1 + margin / 100) * 100) / 100;
case "INR":
return this.steemPrice[1];
return Math.round(this.steemPrice[1] * (1 + margin / 100) * 100) / 100;
case "KRW":
return this.steemPrice[2];
return Math.round(this.steemPrice[2] * (1 + margin / 100) * 100) / 100;
}

}
else if (from=="SBD"){
switch(to){
case "USD":
return this.sbdPrice[0];
else if (from == "SBD") {
switch (to) {
case "USD":
return Math.round(this.sbdPrice[0] * (1 + margin / 100) * 100) / 100;
case "INR":
return this.sbdPrice[1];
return Math.round(this.sbdPrice[1] * (1 + margin / 100) * 100) / 100;
case "KRW":
return this.steemPrice[2];
return Math.round(this.steemPrice[2] * (1 + margin / 100) * 100) / 100;
}

}
}

buyTrade(trade: AdvertisementResponse){
buyTrade(trade: AdvertisementResponse) {
//this.purchaseSer.selectTradeEvent(trade);
//console.log(trade);
this.router.navigate(['purchase/'+trade._id]);
this.router.navigate(['purchase/' + trade._id]);
}
}
78 changes: 38 additions & 40 deletions src/app/module/advertisement.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
export interface AdvertisementRequest {
createdby: string,
ad_type: string,
country: string,
payment_methods: string[],
currency: string,
margin: number,
limit_from: number,
limit_to: number,
restricted_amounts: string[],
ad_coin : string,
ad_coin_amount : number,
ad_status:string,
terms: string,
ad_details:{
minimum_volume: Number,
minimum_reputation_score: Number,
new_buyer_limit: Number,
track_liquidity: Boolean
},
security_details:{
identified_people_only: Boolean,
identify_user_before_continuing_trade:Boolean,
real_name_required:Boolean,
sms_verification_required: Boolean,
trusted_people_only: Boolean
}
createdby: string,
ad_type: string,
country: string,
payment_methods: string[],
currency: string,
margin: number,
limit_from: number,
limit_to: number,
restricted_amounts: string[],
ad_coin: string,
ad_coin_amount: number,
ad_status: string,
terms: string,
ad_details: {
minimum_volume: Number,
minimum_reputation_score: Number,
new_buyer_limit: Number,
track_liquidity: Boolean
},
security_details: {
identified_people_only: Boolean,
identify_user_before_continuing_trade: Boolean,
real_name_required: Boolean,
sms_verification_required: Boolean,
trusted_people_only: Boolean
}
}

export interface AdvertisementResponse {
_id : string
_id: string
createdby: string,
ad_type: string,
country: string,
payment_methods: string[],
currency: string,
margin: number,
limit_from: number,
ad_status:string,
ad_status: string,
limit_to: number,
restricted_amounts: string[],
ad_coin : string,
ad_coin_amount : number,
ad_coin: string,
ad_coin_amount: number,
terms: string,
__v : Number,
ad_details:{
minimum_volume_steem: string,
minimum_volume_sbd: string,
minimum_reputation_score: string,
new_buyer_limit_steem: string,
new_buyer_limit_sbd: string,
__v: Number,
ad_details: {
minimum_volume: Number,
minimum_reputation_score: Number,
new_buyer_limit: Number,
track_liquidity: Boolean
},
security_details:{
security_details: {
identified_people_only: Boolean,
identify_user_before_continuing_trade:Boolean,
real_name_required:Boolean,
identify_user_before_continuing_trade: Boolean,
real_name_required: Boolean,
sms_verification_required: Boolean,
trusted_people_only: Boolean
}
Expand Down
61 changes: 26 additions & 35 deletions src/app/post-trade/post-trade.component.html
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
<div class="box container">
<form #tradeForm ="ngForm" (ngSubmit)="onSubmit(tradeForm.value)" ngNativeValidate>
<form #tradeForm="ngForm" (ngSubmit)="onSubmit(tradeForm.value)" ngNativeValidate>
<div class="form-group col-md-4">
<label for="Country">Ad Type</label>
<select class="form-control" id="ad_type"
[(ngModel)] = "advertisement.ad_type"
name = "ad_type"
required>
<select class="form-control" id="ad_type" [(ngModel)]="advertisement.ad_type" name="ad_type" required>
<option *ngFor="let count of ad_type">{{count}}</option>
</select>
</div>

<div class="form-group col-md-4">
<label for="ad_coin">Ad Coin</label>
<select class="form-control" id="ad_coin"
name="ad_coin"
required
[(ngModel)]="advertisement.ad_coin">
<option *ngFor="let count of ad_coin">{{count}}</option>
</select>
<label for="ad_coin">Ad Coin</label>
<select class="form-control" id="ad_coin" name="ad_coin" required [(ngModel)]="advertisement.ad_coin">
<option *ngFor="let count of ad_coin">{{count}}</option>
</select>
</div>

<div class="form-group col-md-4">
<label for="Currency">Currency</label>
<select class="form-control" id="Currency"
[(ngModel)] = "advertisement.currency"
name = "currency"
required>
<option *ngFor="let count of currency">{{count}}</option>
</select>
</div>

<label for="Currency">Currency</label>
<select class="form-control" id="Currency" [(ngModel)]="advertisement.currency" name="currency" required>
<option *ngFor="let count of currency">{{count}}</option>
</select>
</div>
<div class="col-md-4 form-row mb-3">
<div class="col">
<label for="ad_coin_amount">Margin</label>
<input type="number" name="ad_coin_amount" id="ad_coin_amount" class="form-control" [(ngModel)]="advertisement.margin"
required>
</div>
</div>
<div class="form-group col-md-4">
<label for="payment_methods">Payment Methods</label>
<select class="form-control" id="payment_methods"
[(ngModel)] = "advertisement.payment_methods"
name = "payment_methods"
required>
<select class="form-control" id="payment_methods" [(ngModel)]="advertisement.payment_methods" name="payment_methods"
required>
<option *ngFor="let count of payment_methods">{{count}}</option>
</select>
</div>

<div class="col-md-4 form-row mb-3">
<div class="col">
<label for="ad_coin_amount">Ad Coin Amount</label>
<input type="number" name="ad_coin_amount" id="ad_coin_amount" class="form-control"
[(ngModel)] = "advertisement.ad_coin_amount"
required>
<input type="number" name="ad_coin_amount" id="ad_coin_amount" class="form-control" [(ngModel)]="advertisement.ad_coin_amount"
required>
</div>
</div>

Expand Down Expand Up @@ -75,12 +69,9 @@

<div class="form-group col-md-4">
<label for="terms">Terms</label>
<textarea class="form-control" id="terms" rows="3"
name="terms"
required
[(ngModel)]="advertisement.terms"></textarea>
<textarea class="form-control" id="terms" rows="3" name="terms" required [(ngModel)]="advertisement.terms"></textarea>
</div>
<!--
<!--
<div class="form-group col-md-4">
<label for="minimum_volume">Minimum Volume</label>
<input type="number" class="form-control" name="minimum_volume"
Expand All @@ -104,9 +95,9 @@
required
[(ngModel)] = "advertisement.ad_details.new_buyer_limit">
</div> -->

<button type="submit" class="col-sm-5 col-md-3 btn btn-success buttonLocation form-control ml-3 mt-3">
Publish Advertisement</button>
Publish Advertisement</button>
</form>
<div style="margin-bottom: 20px;"></div>
</div>
Loading