Skip to content

Commit

Permalink
final code
Browse files Browse the repository at this point in the history
  • Loading branch information
Veera93 authored and Veera93 committed Nov 5, 2017
1 parent 92b5aaa commit 4a59829
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 37 deletions.
5 changes: 5 additions & 0 deletions client/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ a:hover {
.md-card-custom md-card-actions {
padding: 5px;
}

.md-card-custom img {
height: 200px;
overflow: hidden;
}
/* End Cards */

/* Forms */
Expand Down
Binary file added client/assets/img/landing/house2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/img/landing/house3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion client/components/landing/landing-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
app.controller('LandingController', ['$scope', 'HelperFactory', 'ValidationFactory',
function($scope, HelperFactory, ValidationFactory) {
$scope.stateData = {
loading: false
loading: false,
houseId: localStorage.getItem('houseId'),
house: false
}
$scope.init = function() {
var houseId = $scope.stateData.houseId
if (houseId) {
$scope.stateData.house = getHouseDetails(houseId)
}
}
$scope.init()
}])
})();
24 changes: 12 additions & 12 deletions client/components/landing/landing-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,42 @@
<div flex="100" layout="column">
<content-title-standard id="listings" icon="fa-home" text="Homes For Sale"></content-title-standard>
<div flex="100" layout="row">
<div flex="33">
<div flex="33" ng-if="stateData.house">
<md-card class="md-card-custom">
<img src="assets/img/landing/header.jpg" class="md-card-image" alt="image caption">
<md-card-content>
<h2>$104,000 <br><small>3 Bedrooms, 2,100 sqft</small></h2>
<p><i class='fa fa-map-marker'></i> Tonawanda, New York</p>
<h2>${{stateData.house[1]}}<br><small>{{stateData.house[6]}} Bedrooms, {{stateData.house[7]}} sqft</small></h2>
<p><i class='fa fa-map-marker'></i> {{stateData.house[2]}}</p>
</md-card-content>
<md-divider></md-divider>
<md-card-actions layout="row" layout-align="center center">
<md-button class="md-button-custom md-button-custom full-width md-accent" ng-click="navigation.goPurchase('1')">Purchase Home</md-button>
<md-button class="md-button-custom md-button-custom full-width md-accent" ng-click="navigation.goPurchase(stateData.houseId)">Purchase Home</md-button>
</md-card-actions>
</md-card>
</div>
<div flex="33">
<md-card class="md-card-custom">
<img src="assets/img/landing/header.jpg" class="md-card-image" alt="image caption">
<img src="assets/img/landing/house2.jpg" class="md-card-image" alt="image caption">
<md-card-content>
<h2>$104,000 <br><small>3 Bedrooms, 2,100 sqft</small></h2>
<p><i class='fa fa-map-marker'></i> Tonawanda, New York</p>
<h2>$387000 <br><small>5 Bedrooms, 3000 sqft</small></h2>
<p><i class='fa fa-map-marker'></i> Williamsville, New York</p>
</md-card-content>
<md-divider></md-divider>
<md-card-actions layout="row" layout-align="center center">
<md-button class="md-button-custom md-button-custom full-width md-accent" ng-click="navigation.goPurchase('2')">Purchase Home</md-button>
<md-button class="md-button-custom md-button-custom full-width md-accent">Purchase Home</md-button>
</md-card-actions>
</md-card>
</div>
<div flex="33">
<md-card class="md-card-custom">
<img src="assets/img/landing/header.jpg" class="md-card-image" alt="image caption">
<img src="assets/img/landing/house3.jpg" class="md-card-image" alt="image caption">
<md-card-content>
<h2>$104,000 <br><small>3 Bedrooms, 2,100 sqft</small></h2>
<p><i class='fa fa-map-marker'></i> Tonawanda, New York</p>
<h2>$405000 <br><small>6 Bedrooms, 4100 sqft</small></h2>
<p><i class='fa fa-map-marker'></i> Amherst, New York</p>
</md-card-content>
<md-divider></md-divider>
<md-card-actions layout="row" layout-align="center center">
<md-button class="md-button-custom md-button-custom full-width md-accent" ng-click="navigation.goPurchase('3')">Purchase Home</md-button>
<md-button class="md-button-custom md-button-custom full-width md-accent">Purchase Home</md-button>
</md-card-actions>
</md-card>
</div>
Expand Down
16 changes: 11 additions & 5 deletions client/components/purchase/purchase-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
function($scope, $location, HelperFactory, NavigationFactory, ValidationFactory) {
$scope.stateData = {
loading: false,
homeId: $location.search().id
submitted: false,
homeId: $location.search().id,
house: ['Rychard Hunt']
}
$scope.buyData = {
fullName: "",
emailAddress: "",
offer: ""
fullName: "Charlie",
emailAddress: "test@test.com",
offer: 0
}
$scope.canSubmit = function() {
if (!$scope.buyData.fullName || !ValidationFactory.isString($scope.buyData.fullName) || !ValidationFactory.checkStringLength($scope.buyData.fullName, 1, 25)) {
Expand All @@ -26,12 +28,16 @@
return true
}
$scope.submit = function() {

$scope.stateData.loading = true
addProposal($scope.stateData.homeId, $scope.buyData.fullName, $scope.buyData.offer, 5)
$scope.stateData.loading = false
$scope.stateData.submitted = true
}
$scope.init = function() {
if (!$scope.stateData.homeId) {
return NavigationFactory.goLanding()
}
$scope.stateData.house = getHouseDetails($scope.stateData.homeId)
}
$scope.init()
}])
Expand Down
21 changes: 16 additions & 5 deletions client/components/purchase/purchase-view.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
<site-outline>
<content-header-image
title="75 Lynbrook Ave."
subtitle="$127,000 | 3 Bedrooms | 1,024 Square Feet"
title="Home in {{stateData.house[2]}}"
subtitle="${{stateData.house[1]}} | {{stateData.house[6]}} Bedrooms | {{stateData.house[7]}} Square Feet"
image="assets/img/sell/header.jpg"
>
</content-header-image>
<content-padding-standard>
<div flex="100" flex-gt-sm="70" flex-offset-gt-sm="15">
<md-card>
<md-card ng-show="!stateData.submitted">
<md-card-title>
<md-card-title-text>
<span class="md-headline"><i class="fa fa-money"></i> <strong>Purchase Home</strong></span>
<span class="md-subtitle">This home is being sold by <strong>Charlie Campanella</strong> for $127,000</span>
<span class="md-subtitle">This home is being sold by <strong>{{stateData.house[0]}}</strong> for ${{stateData.house[1]}}</span>
</md-card-title-text>
</md-card-title>
<md-divider></md-divider>
<md-card-content>
<form class="custom-form" flex="100">
<input placeholder="Full Name" ng-model="buyData.fullName" maxlength="25" flex="100">
<input placeholder="Email Address" ng-model="buyData.emailAddress" maxlength="50" flex="100">
<input type="number" placeholder="Offer ($127,000+)" ng-model="buyData.offer" maxlength="7" flex="100">
<input type="number" placeholder="Offer (${{stateData.house[1]}}+)" ng-model="buyData.offer" maxlength="7" flex="100">
<br>
<md-button class="md-button-custom md-button-custom-padded full-width" ng-class="{'md-disabled': !canSubmit(), 'md-accent': canSubmit()}" ng-disabled="!canSubmit()" ng-click="submit()">Submit Purchase Offer</md-button>
</form>
</md-card-content>
</md-card>
<md-card ng-show="stateData.submitted">
<md-card-title>
<md-card-title-text>
<span class="md-headline"><i class="fa fa-star"></i> <strong>Offer Submitted!</strong></span>
</md-card-title-text>
</md-card-title>
<md-divider></md-divider>
<md-card-content>
You have successfully submitted your purchase offer! If the seller approves, your transaction will go through.
</md-card-content>
</md-card>
</div>
</content-padding-standard>
</site-outline>
21 changes: 13 additions & 8 deletions client/components/sell/sell-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
function($scope, HelperFactory, ValidationFactory) {
$scope.sellData = { // Data submitted to BlockChain and API
id: parseInt(HelperFactory.currentUnixTime()),
fullName: "",
emailAddress: "",
address: "",
price: "",
squareFeet: "",
bedroomCount: "",
imageUrl: ""
fullName: "Veera",
emailAddress: "veera@gmail.com",
address: "Buffalo",
price: 100000,
squareFeet: 2000,
bedroomCount: 5,
imageUrl: "http://bit.ly/2y2Rmqu"
}
$scope.stateData = {
loading: false
loading: false,
submitted: false
}
$scope.canSubmit = function() {
if (!$scope.sellData.fullName || !ValidationFactory.isString($scope.sellData.fullName) || !ValidationFactory.checkStringLength($scope.sellData.fullName, 1, 25)) {
Expand All @@ -39,6 +40,10 @@
}
$scope.submit = function() {
$scope.stateData.loading = true
setHouseDetails($scope.sellData.id, $scope.sellData.emailAddress, $scope.sellData.price, $scope.sellData.address, $scope.sellData.fullName, $scope.sellData.imageUrl, $scope.sellData.bedroomCount, $scope.sellData.squareFeet)
localStorage.setItem('houseId', $scope.sellData.id)
$scope.stateData.loading = false
$scope.stateData.submitted = true
}
}])
})();
13 changes: 12 additions & 1 deletion client/components/sell/sell-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</content-header-image>
<content-padding-standard>
<div flex="100" flex-gt-sm="70" flex-offset-gt-sm="15">
<md-card>
<md-card ng-show="!stateData.submitted">
<md-card-title>
<md-card-title-text>
<span class="md-headline"><i class="fa fa-info-circle"></i> <strong>Listing Details</strong></span>
Expand All @@ -28,6 +28,17 @@
</form>
</md-card-content>
</md-card>
<md-card ng-show="stateData.submitted">
<md-card-title>
<md-card-title-text>
<span class="md-headline"><i class="fa fa-star"></i> <strong>Listing Submitted!</strong></span>
</md-card-title-text>
</md-card-title>
<md-divider></md-divider>
<md-card-content>
You have successfully posted your listing. It is now available for viewing by potential buyers on the marketplace!
</md-card-content>
</md-card>
</div>
</content-padding-standard>
</site-outline>
Expand Down
29 changes: 24 additions & 5 deletions client/web3.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,44 @@ function customerFilter() {
events.watch(function(error, result){
if (!error){
if(result.event === "NewHouse") {
console.log("NewHouse:");
result.args.basePrice = result.args.basePrice.toNumber();
result.args.bedRooms = result.args.bedRooms.toNumber();
result.args.blockNo = result.args.blockNo.toNumber();
result.args.house = result.args.house.toNumber();
result.args.squareFeet = result.args.squareFeet.toNumber();
console.dir(result);
console.log("Block No.",result.args.blockNo)

console.log("Base Price ",result.args.basePrice)
console.log("Bed Rooms ",result.args.bedRooms)
console.log("House ",result.args.house)
console.log("Square Feet ",result.args.squareFeet)
console.log("Location ",result.args.location)
console.log("ownerEmail ",result.args.ownerEmail)
console.log("ownerName ",result.args.ownerName)
console.log("-----------------------------------------")
//console.dir(result);
} else if(result.event === "NewProposal") {
console.log("NewProposal:");
result.args.blockNo = result.args.blockNo.toNumber();
result.args.house = result.args.house.toNumber();
result.args.lifetime = result.args.lifetime.toNumber();
result.args.price = result.args.price.toNumber();
console.dir(result);
console.log("Block No ", result.args.blockNo);
console.log("House ", result.args.house);
console.log("Life Time ", result.args.lifetime);
console.log("Price ", result.args.price);
console.log("Buyer Name ", result.args.buyerName)
console.log("-----------------------------------------")
//console.dir(result);
} else if(result.event === "SoldHouse") {
console.log("SoldHouse: ");
result.args.blockNo = result.args.blockNo.toNumber();
result.args.house = result.args.house.toNumber();
console.dir(result);
console.log("Block No ", result.args.blockNo);
console.log("House ", result.args.house);
console.log("Owner ", result.args.oldOwner);
console.log("-----------------------------------------")
//console.dir(result);
}
}

Expand Down Expand Up @@ -135,7 +154,7 @@ function getProposalDetails(_houseId) {
function addProposal(_houseId, _buyerName, _price, _lifetime) {
var contractInstance = createInstanceBuyer();
var estimatedGas = 4700000;
var money = 101
var money = 100001

var txnObject = {
from: buyerweb3.eth.coinbase,
Expand Down

0 comments on commit 4a59829

Please sign in to comment.