Renaming to english

This commit is contained in:
Nedim Uka
2019-05-15 15:27:10 +02:00
parent 9fdfce49ed
commit 27fa721627
16 changed files with 153 additions and 131 deletions

View File

@@ -3,8 +3,15 @@
The purpose of this project is to build a web application that enables subscribing to notifications when new products are published on various ad based marketplaces. The MVP will be only based on OLX.ba The purpose of this project is to build a web application that enables subscribing to notifications when new products are published on various ad based marketplaces. The MVP will be only based on OLX.ba
Create postgres docker image
docker build -t marketalerts .
Run postgres image with: Run postgres image with:
docker run --name pg_test -d -p 5432:5432 marketalerts docker run --name pg_test -d -p 5432:5432 marketalerts
Run with: Run migrations in app folder
npx sequelize db:migrate
Run app with:
$ npm install
$ npm start $ npm start

View File

@@ -2,26 +2,26 @@ const db = require('../models/index');
const { currentRERequest } = require('../helpers/url'); const { currentRERequest } = require('../helpers/url');
const { regions } = require('../helpers/codes'); const { regions } = require('../helpers/codes');
const gradovi = regions(); const cities = regions();
const getGrad = (req,res) => { const getCity = (req,res) => {
const nextStep = req.query.nextStep || '/'; const nextStep = req.query.nextStep || '/';
res.render('grad', { res.render('city', {
nextStep, nextStep,
gradovi cities
}); });
} }
const postGrad = async (req, res) => { const postCity = async (req, res) => {
const request = await currentRERequest(req); const request = await currentRERequest(req);
const nextStep = req.query.nextStep || `/mjesto/${request.uniqueId}`; const nextStep = req.query.nextStep || `/mjesto/${request.uniqueId}`;
request.city = req.body.grad; request.city = req.body.city;
await request.save(); await request.save();
res.redirect(nextStep) res.redirect(nextStep)
} }
module.exports = { module.exports = {
getGrad, getCity,
postGrad postCity
}; };

View File

@@ -1,7 +0,0 @@
const getDobrodosli = (req,res) => {
res.render('dobrodosli', { nextStep: '/vrstanekretnine' } );
}
module.exports = {
getDobrodosli
};

View File

@@ -2,25 +2,24 @@ const db = require('../models/index');
const { currentRERequest } = require('../helpers/url'); const { currentRERequest } = require('../helpers/url');
const { places } = require('../helpers/codes'); const { places } = require('../helpers/codes');
const getMjesto = async (req,res) => { const getNeighborhood = async (req,res) => {
let request = await currentRERequest(req); let request = await currentRERequest(req);
const mjesta = places(request.city); const neighborhoods = places(request.city);
const nextStep = req.query.nextStep || '/'; const nextStep = req.query.nextStep || '/';
res.render('mjesto', { res.render('neighborhood', {
nextStep, nextStep,
mjesta neighborhoods
}); });
} }
const postMjesto = async (req, res) => { const postgNeighborhood = async (req, res) => {
let request = await currentRERequest(req); let request = await currentRERequest(req);
request.place = req.body.mjesto; request.neighborhood = req.body.neighborhood;
console.log("AAA ", req.body);
await request.save(); await request.save();
res.send("Result is " + JSON.stringify(request)); res.send("Result is " + JSON.stringify(request));
} }
module.exports = { module.exports = {
getMjesto, getNeighborhood,
postMjesto postgNeighborhood
}; };

View File

@@ -1,25 +1,24 @@
const db = require('../models/index'); const db = require('../models/index');
const vrsteNekretnina = [ const realEstateTypes = [
{ ime: "Kuća", id: "kuca" }, { ime: "Kuća", id: "kuca" },
{ ime: "Stan", id: "stan" }, { ime: "Stan", id: "stan" },
{ ime: "Vikendica", id: "vikendica" } { ime: "Vikendica", id: "vikendica" }
]; ];
const getVrstaNekretnine = (req,res) => { const getRealEstateTypes = (req,res) => {
const nextStep = req.query.nextStep; const nextStep = req.query.nextStep;
res.render('vrsta_nekretnine', { res.render('real_estate_type', {
nextStep, nextStep,
vrste: vrsteNekretnina realEstateTypes: realEstateTypes
}); });
} }
const postVrstaNekretnine = (req, res) => { const postRealEstateTypes = (req, res) => {
let nextStep = req.query.nextStep; let nextStep = req.query.nextStep;
db.RealEstateRequest.create({ db.RealEstateRequest.create({
realEstateType: req.body.vrsta realEstateType: req.body.realestatetype
}).then( (result) => { }).then( (result) => {
nextStep = nextStep || `/grad/${result.uniqueId}`; nextStep = nextStep || `/grad/${result.uniqueId}`;
res.redirect(nextStep); res.redirect(nextStep);
@@ -30,6 +29,6 @@ const postVrstaNekretnine = (req, res) => {
} }
module.exports = { module.exports = {
getVrstaNekretnine, getRealEstateTypes,
postVrstaNekretnine postRealEstateTypes
}; };

View File

@@ -0,0 +1,7 @@
const getWelcome = (req,res) => {
res.render('welcome', { nextStep: '/vrstanekretnine' } );
}
module.exports = {
getWelcome
};

View File

@@ -5,7 +5,6 @@ const currentRERequest = async (req) => {
if(!uniqueId) return null; if(!uniqueId) return null;
const request = await db.RealEstateRequest.findOne({ where: {uniqueId} }); const request = await db.RealEstateRequest.findOne({ where: {uniqueId} });
console.log("Request ", request);
return request; return request;
} }

View File

@@ -1,8 +1,8 @@
.dobrodosli-center-button { .welcome-center-button {
width: 100%; width: 100%;
} }
.dobrodosli-big-logo { .welcome-big-logo {
font-size: 200pt; font-size: 200pt;
background-image: url(./images/logo.png); background-image: url(./images/logo.png);
background-size: contain; background-size: contain;

31
app/views/city.ejs Normal file
View File

@@ -0,0 +1,31 @@
<div class="row center-align">
<h2>U kojoj regiji tražite nekretninu?</h2>
</div>
<form method="POST" id="form-city">
<div class="row center-align">
<ul class="collection with-header">
<% for(const city of cities) { %>
<li class="collection-item" >
<div id="<%= city.id %>" ><%= city.ime %>
<a href="#!" class="secondary-content">
<i class="material-icons">send</i>
</a>
</div>
</li>
<% } %>
</ul>
<input type="hidden" name="city" id="city" />
</div>
</form>
<script>
$(document).ready( () => {
$(".collection-item").click( (e) => {
const clickedId = $(e.target).attr("id");
$("#city").val(clickedId);
$("#form-city").submit();
});
});
</script>

View File

@@ -1,25 +0,0 @@
<div class="row center-align">
<h2>U kojoj regiji tražite nekretninu?</h2>
</div>
<form method="POST" id="form-grad">
<div class="row center-align">
<ul class="collection with-header">
<% for(const grad of gradovi) { %>
<li class="collection-item" > <div id="<%= grad.id %>" ><%= grad.ime %><a href="#!" class="secondary-content"><i class="material-icons">send</i></a></div></li>
<% } %>
</ul>
<input type="hidden" name="grad" id="grad" />
</div>
</form>
<script>
$(document).ready( () => {
$(".collection-item").click( (e) => {
const clickedId = $(e.target).attr("id");
$("#grad").val(clickedId);
$("#form-grad").submit();
});
});
</script>

View File

@@ -1,25 +0,0 @@
<div class="row center-align">
<h2>U kojem mjestu tražite nekretninu?</h2>
</div>
<form method="POST" id="form-mjesto">
<div class="row center-align">
<ul class="collection with-header">
<% for(const mjesto of mjesta) { %>
<li class="collection-item" > <div id="<%= mjesto.id %>" ><%= mjesto.ime %><a href="#!" class="secondary-content"><i class="material-icons">send</i></a></div></li>
<% } %>
</ul>
<input type="hidden" name="mjesto" id="mjesto" />
</div>
</form>
<script>
$(document).ready( () => {
$(".collection-item").click( (e) => {
const clickedId = $(e.target).attr("id");
$("#mjesto").val(clickedId);
$("#form-mjesto").submit();
});
});
</script>

View File

@@ -0,0 +1,31 @@
<div class="row center-align">
<h2>U kojem mjestu tražite nekretninu?</h2>
</div>
<form method="POST" id="form-neighborhood">
<div class="row center-align">
<ul class="collection with-header">
<% for(const neighborhood of neighborhoods) { %>
<li class="collection-item" >
<div id="<%= neighborhood.id %>" ><%= neighborhood.ime %>
<a href="#!" class="secondary-content">
<i class="material-icons">send</i>
</a>
</div>
</li>
<% } %>
</ul>
<input type="hidden" name="neighborhood" id="neighborhoods" />
</div>
</form>
<script>
$(document).ready( () => {
$(".collection-item").click( (e) => {
const clickedId = $(e.target).attr("id");
$("#neighborhood").val(clickedId);
$("#form-neighborhood").submit();
});
});
</script>

View File

@@ -0,0 +1,35 @@
<div class="row center-align">
<h2>Koju nekretninu tražite?</h2>
</div>
<form method="POST" id="form-real-estate-type">
<div class="row center-align">
<ul class="collection with-header">
<% for(const realEstatetype of realEstateTypes) { %>
<li class="collection-item" >
<div id="<%= realEstatetype.id %>" ><%= realEstatetype.ime %>
<a href="#!" class="secondary-content">
<i class="material-icons">send</i>
</a>
</div>
</li>
<% } %>
</ul>
<input type="hidden" name="realestatetype" id="realestatetype" />
</div>
</form>
<script>
$(document).ready( () => {
$(".collection-item").click( (e) => {
const clickedId = $(e.target).attr("id");
$("#realestatetype").val(clickedId);
$("#form-real-estate-type").submit();
});
});
</script>

View File

@@ -1,29 +0,0 @@
<div class="row center-align">
<h2>Koju nekretninu tražite?</h2>
</div>
<form method="POST" id="form-vrsta">
<div class="row center-align">
<ul class="collection with-header">
<% for(let vrsta of vrste) { %>
<li class="collection-item" > <div id="<%= vrsta.id %>" ><%= vrsta.ime %><a href="#!" class="secondary-content"><i class="material-icons">send</i></a></div></li>
<% } %>
</ul>
<input type="hidden" name="vrsta" id="vrsta" />
</div>
</form>
<script>
$(document).ready( () => {
$(".collection-item").click( (e) => {
const clickedId = $(e.target).attr("id");
$("#vrsta").val(clickedId);
$("#form-vrsta").submit();
});
});
</script>

View File

@@ -1,7 +1,7 @@
<!-- --> <!-- -->
<div class="row center-align"> <div class="row center-align">
<span class="dobrodosli-big-logo">🤙</span> <span class="welcome-big-logo">🤙</span>
</div> </div>
<div class="row center-align"> <div class="row center-align">
<div>Sve nekretnine dostupne u oglasima.</div> <div>Sve nekretnine dostupne u oglasima.</div>
@@ -10,7 +10,7 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col s6 push-s3"> <div class="col s6 push-s3">
<a href="<%= nextStep %>" class="dobrodosli-center-button waves-effect waves-light btn"> <a href="<%= nextStep %>" class="welcome-center-button waves-effect waves-light btn">
Javi mi Javi mi
</a> </a>
</div> </div>

View File

@@ -1,7 +1,7 @@
const dobrodosli = require('./app/controllers/dobrodosli').getDobrodosli; const welcome = require('./app/controllers/welcome').getWelcome;
const { getVrstaNekretnine, postVrstaNekretnine} = require('./app/controllers/vrsta_nekretnine'); const { getRealEstateTypes, postRealEstateTypes} = require('./app/controllers/real_estate_types');
const { getGrad, postGrad } = require('./app/controllers/grad'); const { getCity, postCity } = require('./app/controllers/city');
const { getMjesto, postMjesto } = require('./app/controllers/mjesto'); const { getNeighborhood, postgNeighborhood } = require('./app/controllers/neighborhoods');
let express = require("express"); let express = require("express");
const path = require("path"); const path = require("path");
@@ -108,18 +108,18 @@ app.post("/api/payforalert", function(request, response) {
}); });
}); });
app.get('/', dobrodosli); app.get('/', welcome);
app.get('/vrstanekretnine/:request_id', getVrstaNekretnine); app.get('/vrstanekretnine/:request_id', getRealEstateTypes);
app.get('/vrstanekretnine', getVrstaNekretnine); app.get('/vrstanekretnine', getRealEstateTypes);
app.post('/vrstanekretnine/:request_id', postVrstaNekretnine); app.post('/vrstanekretnine/:request_id', postRealEstateTypes);
app.post('/vrstanekretnine', postVrstaNekretnine); app.post('/vrstanekretnine', postRealEstateTypes);
app.get('/grad/:request_id', getGrad); app.get('/grad/:request_id', getCity);
app.post('/grad/:request_id', postGrad); app.post('/grad/:request_id', postCity);
app.get('/mjesto/:request_id', getMjesto); app.get('/mjesto/:request_id', getNeighborhood);
app.post('/mjesto/:request_id', postMjesto); app.post('/mjesto/:request_id', postgNeighborhood);
app.use('/assets', express.static('./app/public')) app.use('/assets', express.static('./app/public'))