Skip to content

Commit a0c085f

Browse files
new contract and filter room
1 parent 23ad442 commit a0c085f

File tree

8 files changed

+383
-247
lines changed

8 files changed

+383
-247
lines changed

app/api/rooms.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module.exports = (API, redis) => {
8585
if (param.page && !isNaN(param.page) && +param.page > 0) {
8686
skip = limit * (param.page - 1)
8787
}
88-
88+
console.log(findPram);
8989
async.parallel({
9090
count: function (count_callback) {
9191
db.rooms.count(findPram).then(function (count) {

app/modules/db/index.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,16 @@ var schemas = {
271271
default: '',
272272
},
273273
limit_time_min: {
274-
type: String,
275-
default: '',
274+
type: Number,
275+
default: 0,
276276
},
277277
limit_time_max: {
278-
type: String,
279-
default: '',
278+
type: Number,
279+
default: 0,
280280
},
281281
people_count: {
282-
type: String,
283-
default: '',
282+
type: Number,
283+
default: 0,
284284
},
285285
startTimeCheckIn: {
286286
type: String,
@@ -299,24 +299,24 @@ var schemas = {
299299
default: '',
300300
},
301301
children_count: {
302-
type: String,
303-
default: '',
302+
type: Number,
303+
default: 0,
304304
},
305305
bedroom_count: {
306-
type: String,
307-
default: '',
306+
type: Number,
307+
default: 0,
308308
},
309309
bed_count: {
310-
type: String,
311-
default: '',
310+
type: Number,
311+
default: 0,
312312
},
313313
bathroom_count: {
314-
type: String,
315-
default: '',
314+
type: Number,
315+
default: 0,
316316
},
317317
bathroom: {
318-
type: String,
319-
default: '',
318+
type: Number,
319+
default: 0,
320320
},
321321
description: {
322322
type: String,

build_contract.js

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ deploy(source, function (tx, _interface, _bytecode, source, solc_version) {
134134
'module.exports = {_address: _address,_contract_fixed: _contract_fixed,_name: _name,_symbol: _symbol,_abi: _abi,_bytecode:_bytecode,_version:_version};');
135135
console.log('Deploy Contract Success:\n\tAddress: ' + tx.contractAddress + '\n\tBlockHash: ' + tx.blockHash + '\n\tblockNumber: ' + tx.blockNumber);
136136
console.log('== END ==');
137+
console.info('[info] Please verify source https://ropsten.etherscan.io/verifyContract2?a=' + tx.contractAddress );
137138

138139
process.exit(0);
139140
});

web/src/views/AddRoom/AddRoom.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
var map2 = false;
3-
var geocode =false;
43
var marker_home = false;
54
var reactiveAddRoom = Ractive.extend({
65
oninit: function () {

web/src/views/App/App.html

+6-10
Original file line numberDiff line numberDiff line change
@@ -456,23 +456,19 @@
456456

457457
<div role="menu" class="block-tbx dropdown-menu">
458458

459-
<form>
459+
<form id="сount_guest" action="#" onsubmit="return false;">
460460

461461
<div class="txls">Взрослые</div>
462462
<div class="quantity">
463-
<input type="number" min="1" max="9" step="1" value="1"></div>
463+
<input type="number" name="people_count" min="1" max="9" step="1" value="1"></div>
464464

465-
<div class="txls">Дети (2-12 лет)</div>
465+
<div class="txls">Дети</div>
466466
<div class="quantity">
467-
<input type="number" min="1" max="9" step="1" value="1"></div>
468-
469-
<div class="txls">Младенцы</div>
470-
<div class="quantity">
471-
<input type="number" min="1" max="9" step="1" value="1"></div>
467+
<input type="number" name="children_count" min="0" max="9" step="1" value="0"></div>
472468

473469
<div class="otx">
474-
<a class="fll" href="#">Отменить</a>
475-
<a class="flr" href="#">Применить</a>
470+
<a class="fll">Отменить</a>
471+
<a class="flr pointer" on-click="update_filter:сount_guest">Применить</a>
476472
</div>
477473

478474
</form>

web/src/views/App/App.js

+32-48
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
2+
var geocode =false;
13
var reactiveApp = Ractive.extend({
24
oninit: function () {
5+
36
console.log('reactiveApp oninit');
4-
procent = 0.30;
5-
if (location.hash.replace('#', '').split('-')[0] && location.hash.replace('#', '').split('-')[0] != '')
7+
procent = 0.23;
8+
if (location.hash.replace('#', '').split('-')[0] && location.hash.replace('#', '').split('-')[0] != '') {
69
ABAB.setPage(location.hash.replace('#', '').split('-')[0], location.hash.replace('#', '').split('-')[1], true);
10+
procent = 0.30;
11+
}
712
else
813
ABAB.setPage('Rooms');
914

@@ -66,7 +71,23 @@ if (localStorage.getItem('auth')) {
6671
localStorage.removeItem('auth');
6772
}
6873
}
74+
ractiveComponent['rootApp'].on('update_filter', function (e,id) {
75+
var formarr = $('#'+id).serializeArray();
76+
var form_obj = {};
77+
for (var i in formarr) {
78+
if (form_obj[formarr[i].name] && typeof form_obj[formarr[i].name] === 'string') {
79+
form_obj[formarr[i].name] = [form_obj[formarr[i].name], formarr[i].value];
80+
} else if (form_obj[formarr[i].name] && typeof form_obj[formarr[i].name] === 'object') {
81+
form_obj[formarr[i].name].push(formarr[i].value);
82+
} else
83+
form_obj[formarr[i].name] = formarr[i].value
84+
}
85+
form_obj.people_count = {$gte:form_obj.people_count};
86+
form_obj.children_count = {$gte:form_obj.children_count};
87+
ABAB.event['update_filter'](form_obj,true);
88+
});
6989
ractiveComponent['rootApp'].on('location_input_scan', function () {
90+
7091
console.log($('#location_input_scan').val());
7192
});
7293
ractiveComponent['rootApp'].on('auth_start', function () {
@@ -217,53 +238,16 @@ $('#location_input_scan').flexdatalist({
217238
}, {"address.country": {'$regex': json.city, '$options': 'i'}}]
218239
};
219240
}
220-
API('GetRooms', {page: 1, find: find}, true, function (res) {
221-
222-
ractiveComponent['reactive-RoomsApp'].set('rooms', res.rooms);
223-
ractiveComponent['reactive-RoomsApp'].set('rooms_count', res.count);
224-
225-
if (window.map && window.geocode && window.geocode) {
226-
geocode = res.rooms.map(function (room, i) {
227-
if (room.location[0] && room.location[1]) {
228-
var infowindow = new google.maps.InfoWindow({
229-
content: '<div id="content">' +
230-
'<div id="siteNotice">' +
231-
'</div>' +
232-
'<h1 id="firstHeading" class="firstHeading">' + room.title + '</h1>' +
233-
'<div id="bodyContent">' +
234-
'<p><b>' + room.title + '</b></p>' +
235-
'<p>Transaction: <a href="' + ractiveComponent['reactive-RoomsApp'].get('blockchain_url') + 'tx/' + room.txHash + '" target="_blank">' +
236-
room.txHash + '</a>' +
237-
'<br>' +
238-
'(last update ' + room.update_at.split('T')[0] + ').</p>' +
239-
'</div>' +
240-
'</div>',
241-
maxWidth: 250
242-
});
243-
var marker = new google.maps.Marker({
244-
position: {lat: room.location[0] * 1, lng: room.location[1] * 1},
245-
// label: ''
246-
animation: google.maps.Animation.DROP,
247-
map: map
248-
249-
});
250-
marker.addListener('click', function () {
251-
infowindow.open(map, marker);
252-
});
253-
return marker;
254-
}
255-
else return false;
256-
});
257-
new MarkerClusterer(map, markers,
258-
{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
259-
260-
geocode.geocode({address: json.city + ',' + json.country}, function (results, status) {
261-
map.setCenter({lng: results[0].geometry.location.lng(), lat: results[0].geometry.location.lat()});
262-
map.setZoom(8);
263-
});
241+
if(json && json.city && json.city === 'Russia') json.city = 'Москва';
242+
geocode.geocode({address: (json.city || '') + ',' + (json.country || '')}, function (results, status) {
243+
console.log(results);
244+
if(results.length >0) {
245+
map.setCenter({lng: results[0].geometry.location.lng(), lat: results[0].geometry.location.lat()});
246+
map.setZoom(8);
247+
}else{
248+
console.warn('[map geocode] address not fount:',json)
264249
}
265250
});
251+
ABAB.event['update_filter'](find,true);
266252

267-
268-
console.log(data.value);
269253
});

0 commit comments

Comments
 (0)