Merge branch 'project-fixes' into 'master'
Project fixes See merge request saburly/marketalarm/web!26
This commit was merged in pull request #26.
This commit is contained in:
9
app/config/appConfig.js
Normal file
9
app/config/appConfig.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const APP_PORT = process.env.APP_PORT || 5000;
|
||||
const APP_BASE_URL = process.env.APP_BASE_URL || "http://localhost";
|
||||
|
||||
const APP_URL = `${APP_BASE_URL}:${APP_PORT}`;
|
||||
|
||||
module.exports = {
|
||||
APP_PORT,
|
||||
APP_URL
|
||||
};
|
||||
@@ -1,32 +1,31 @@
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { getRealEstateTypeEnum } = require('../helpers/enums');
|
||||
const { currentRERequest } = require("../helpers/url");
|
||||
const { getRealEstateTypeEnum } = require("../helpers/enums");
|
||||
|
||||
const getGardenSize = (req,res) => {
|
||||
const getGardenSize = (req, res) => {
|
||||
const title = "Koliko okućnice tražite ?";
|
||||
|
||||
const title = "Koliko okućnice tražite ?"
|
||||
|
||||
const unit = " m2"
|
||||
const unit = " m2";
|
||||
const rangeFrom = {
|
||||
min : 10,
|
||||
max : 3000,
|
||||
value : 0,
|
||||
step : 10
|
||||
}
|
||||
min: 10,
|
||||
max: 3000,
|
||||
value: 0,
|
||||
step: 10
|
||||
};
|
||||
|
||||
const rangeTo = {
|
||||
min : 10,
|
||||
max : 3000,
|
||||
value : 100,
|
||||
step : 10
|
||||
}
|
||||
min: 10,
|
||||
max: 3000,
|
||||
value: 100,
|
||||
step: 10
|
||||
};
|
||||
|
||||
res.render('gardenSize', { rangeFrom, rangeTo, unit, title });
|
||||
res.render("gardenSize", { rangeFrom, rangeTo, unit, title });
|
||||
};
|
||||
|
||||
const postGardenSize = async (req, res) => {
|
||||
const request = await currentRERequest(req);
|
||||
|
||||
const nextStepPage = req.query.nextStep || 'cijena';
|
||||
const nextStepPage = req.query.nextStep || "cijena";
|
||||
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
||||
|
||||
const realEstateType = getRealEstateTypeEnum(request.realEstateType);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const getGoAgain = async (req,res) => {
|
||||
const getGoAgain = async (req, res) => {
|
||||
const title = "Želite li pretražiti još jednu nekretninu ?";
|
||||
res.render('goAgain', {title});
|
||||
res.render("goAgain", { title });
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { getMunicipalitiesForRegion, getMunicipalityName } = require('../helpers/codes');
|
||||
const { currentRERequest } = require("../helpers/url");
|
||||
const {
|
||||
getMunicipalitiesForRegion,
|
||||
getMunicipalityName
|
||||
} = require("../helpers/codes");
|
||||
|
||||
const getMunicipality = async (req, res) => {
|
||||
|
||||
const title = "U kojem mjestu tražite nekretninu?"
|
||||
const title = "U kojem mjestu tražite nekretninu?";
|
||||
let request = await currentRERequest(req);
|
||||
const municipalities = getMunicipalitiesForRegion(request.region);
|
||||
|
||||
res.render('municipality', { municipalities, title });
|
||||
res.render("municipality", { municipalities, title });
|
||||
};
|
||||
|
||||
const postMunicipality = async (req, res) => {
|
||||
|
||||
const request = await currentRERequest(req);
|
||||
const nextStepParam = req.query.nextStep ? "?nextStep=" + req.query.nextStep : "";
|
||||
const nextStepUrl = `/${'naselje'}/${request.uniqueId}/${getMunicipalityName(request.region, req.body.municipality)}${nextStepParam}`;
|
||||
const nextStepParam = req.query.nextStep
|
||||
? "?nextStep=" + req.query.nextStep
|
||||
: "";
|
||||
const nextStepUrl = `/${"naselje"}/${request.uniqueId}/${getMunicipalityName(
|
||||
request.region,
|
||||
req.body.municipality
|
||||
)}${nextStepParam}`;
|
||||
|
||||
request.municipality = req.body.municipality;
|
||||
await request.save();
|
||||
|
||||
@@ -1,41 +1,37 @@
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { currentRERequest } = require("../helpers/url");
|
||||
|
||||
const getNeighborhood = async (req, res) => {
|
||||
const title = "U kojem naselju tražite nekretninu?";
|
||||
const municipality = req.params.municipality;
|
||||
const nextStep = req.query.nextStep || "/";
|
||||
|
||||
const title = "U kojem naselju tražite nekretninu?"
|
||||
const municipality = req.params.municipality
|
||||
const nextStep = req.query.nextStep || '/';
|
||||
|
||||
res.render('neighborhoodMap', {
|
||||
nextStep,
|
||||
municipality,
|
||||
title
|
||||
});
|
||||
|
||||
res.render("neighborhoodMap", {
|
||||
nextStep,
|
||||
municipality,
|
||||
title
|
||||
});
|
||||
};
|
||||
|
||||
const postNeighborhood = async (req, res) => {
|
||||
let request = await currentRERequest(req);
|
||||
const northWest = [req.body.west, req.body.north];
|
||||
const northEast = [req.body.east, req.body.north];
|
||||
const southEast = [req.body.east, req.body.south];
|
||||
const southWest = [req.body.west, req.body.south];
|
||||
let request = await currentRERequest(req);
|
||||
const northWest = [req.body.west, req.body.north];
|
||||
const northEast = [req.body.east, req.body.north];
|
||||
const southEast = [req.body.east, req.body.south];
|
||||
const southWest = [req.body.west, req.body.south];
|
||||
|
||||
request.bounding_box = {
|
||||
type: 'Polygon', coordinates: [
|
||||
[northWest, northEast, southEast,
|
||||
southWest, northWest]
|
||||
]
|
||||
};
|
||||
await request.save();
|
||||
request.bounding_box = {
|
||||
type: "Polygon",
|
||||
coordinates: [[northWest, northEast, southEast, southWest, northWest]]
|
||||
};
|
||||
await request.save();
|
||||
|
||||
const nextStepPage = req.query.nextStep || 'povrsina';
|
||||
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
||||
const nextStepPage = req.query.nextStep || "povrsina";
|
||||
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
||||
|
||||
res.redirect(nextStepUrl);
|
||||
res.redirect(nextStepUrl);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getNeighborhood,
|
||||
postNeighborhood
|
||||
};
|
||||
getNeighborhood,
|
||||
postNeighborhood
|
||||
};
|
||||
|
||||
@@ -1,32 +1,30 @@
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { currentRERequest } = require("../helpers/url");
|
||||
|
||||
const getPrice = (req,res) => {
|
||||
const getPrice = (req, res) => {
|
||||
const title = "Koja Vam okvirna cijena odgovara ?";
|
||||
|
||||
const title = "Koja Vam okvirna cijena odgovara ?"
|
||||
|
||||
const unit = " KM"
|
||||
const unit = " KM";
|
||||
const rangeFrom = {
|
||||
min : 1000,
|
||||
max : 250000,
|
||||
value : 0,
|
||||
step : 1000
|
||||
}
|
||||
min: 1000,
|
||||
max: 250000,
|
||||
value: 0,
|
||||
step: 1000
|
||||
};
|
||||
|
||||
const rangeTo = {
|
||||
min : 1000,
|
||||
max : 250000,
|
||||
value : 50000,
|
||||
step : 1000
|
||||
}
|
||||
min: 1000,
|
||||
max: 250000,
|
||||
value: 50000,
|
||||
step: 1000
|
||||
};
|
||||
|
||||
|
||||
res.render('price', {rangeFrom, rangeTo, unit, title });
|
||||
res.render("price", { rangeFrom, rangeTo, unit, title });
|
||||
};
|
||||
|
||||
const postPrice = async (req, res) => {
|
||||
const request = await currentRERequest(req);
|
||||
|
||||
const nextStepPage = req.query.nextStep || 'pregled';
|
||||
const nextStepPage = req.query.nextStep || "pregled";
|
||||
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
||||
|
||||
request.priceMin = req.body.from;
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { getRegionName, getMunicipalityName } = require('../helpers/codes');
|
||||
const { realEstateTypes, sizes, gardenSizes, prices, getEnumTypeTitle, getRealEstateTypeEnum } = require('../helpers/enums');
|
||||
const { currentRERequest } = require("../helpers/url");
|
||||
const { getRegionName, getMunicipalityName } = require("../helpers/codes");
|
||||
const {
|
||||
realEstateTypes,
|
||||
sizes,
|
||||
gardenSizes,
|
||||
prices,
|
||||
getEnumTypeTitle,
|
||||
getRealEstateTypeEnum
|
||||
} = require("../helpers/enums");
|
||||
|
||||
const getQueryReview = async (req,res) => {
|
||||
|
||||
const title = "Da li je ovo to što ste tražili ?"
|
||||
const getQueryReview = async (req, res) => {
|
||||
const title = "Da li je ovo to što ste tražili ?";
|
||||
const request = await currentRERequest(req);
|
||||
const nextStep = req.query.nextStep;
|
||||
|
||||
@@ -12,63 +18,73 @@ const getQueryReview = async (req,res) => {
|
||||
return null;
|
||||
}
|
||||
|
||||
const {
|
||||
realEstateType,
|
||||
region,
|
||||
municipality,
|
||||
sizeMin,
|
||||
sizeMax,
|
||||
gardenSizeMin,
|
||||
gardenSizeMax,
|
||||
priceMin,
|
||||
priceMax } = request.dataValues;
|
||||
const {
|
||||
realEstateType,
|
||||
region,
|
||||
municipality,
|
||||
sizeMin,
|
||||
sizeMax,
|
||||
gardenSizeMin,
|
||||
gardenSizeMax,
|
||||
priceMin,
|
||||
priceMax
|
||||
} = request.dataValues;
|
||||
|
||||
const realEstateTypeObject = getRealEstateTypeEnum(realEstateType);
|
||||
const enableGardenSizeEdit = realEstateTypeObject ? realEstateTypeObject.hasGardenSize : false;
|
||||
const enableGardenSizeEdit = realEstateTypeObject
|
||||
? realEstateTypeObject.hasGardenSize
|
||||
: false;
|
||||
|
||||
const realEstateTypeTitle = realEstateType ? getEnumTypeTitle(realEstateTypes, realEstateType) : null;
|
||||
const realEstateTypeTitle = realEstateType
|
||||
? getEnumTypeTitle(realEstateTypes, realEstateType)
|
||||
: null;
|
||||
const regionName = region ? getRegionName(region) : null;
|
||||
const municipalityName = (region && municipality) ? getMunicipalityName(region, municipality) : null;
|
||||
const municipalityName =
|
||||
region && municipality ? getMunicipalityName(region, municipality) : null;
|
||||
const sizeTitle = sizeMin ? sizeMin + "-" + sizeMax + " m2" : null;
|
||||
const gardenSizeTitle = gardenSizeMin ? gardenSizeMin + "-" + gardenSizeMax + " m2" : null;
|
||||
const priceTitle = priceMin ? priceMin + "-" + priceMax + " KM" : null;
|
||||
const gardenSizeTitle = gardenSizeMin
|
||||
? gardenSizeMin + "-" + gardenSizeMax + " m2"
|
||||
: null;
|
||||
const priceTitle = priceMin ? priceMin + "-" + priceMax + " KM" : null;
|
||||
|
||||
const uniqueId = request.dataValues.uniqueId ? request.dataValues.uniqueId : '';
|
||||
const uniqueId = request.dataValues.uniqueId
|
||||
? request.dataValues.uniqueId
|
||||
: "";
|
||||
|
||||
const queryData = [
|
||||
{
|
||||
id: 'realEstateType',
|
||||
id: "realEstateType",
|
||||
title: realEstateTypeTitle,
|
||||
url: `/vrstanekretnine/${uniqueId}?nextStep=pregled`,
|
||||
url: `/vrstanekretnine/${uniqueId}?nextStep=pregled`
|
||||
},
|
||||
{
|
||||
id: 'region',
|
||||
id: "region",
|
||||
title: regionName,
|
||||
url: `/grad/${uniqueId}?nextStep=mjesto`,
|
||||
url: `/grad/${uniqueId}?nextStep=mjesto`
|
||||
},
|
||||
{
|
||||
id: 'municipality',
|
||||
id: "municipality",
|
||||
title: municipalityName,
|
||||
url: `/mjesto/${uniqueId}?nextStep=pregled`,
|
||||
url: `/mjesto/${uniqueId}?nextStep=pregled`
|
||||
},
|
||||
{
|
||||
id: 'size',
|
||||
id: "size",
|
||||
title: sizeTitle,
|
||||
url: `/povrsina/${uniqueId}?nextStep=pregled`,
|
||||
url: `/povrsina/${uniqueId}?nextStep=pregled`
|
||||
},
|
||||
{
|
||||
id: 'gardenSize',
|
||||
id: "gardenSize",
|
||||
title: gardenSizeTitle,
|
||||
url: enableGardenSizeEdit ? `/okucnica/${uniqueId}?nextStep=pregled` : '',
|
||||
url: enableGardenSizeEdit ? `/okucnica/${uniqueId}?nextStep=pregled` : ""
|
||||
},
|
||||
{
|
||||
id: 'price',
|
||||
id: "price",
|
||||
title: priceTitle,
|
||||
url: `/cijena/${uniqueId}?nextStep=pregled`
|
||||
}
|
||||
];
|
||||
|
||||
res.render('queryReview', {
|
||||
res.render("queryReview", {
|
||||
nextStep,
|
||||
queryData,
|
||||
title
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { isValidEmail } = require('../helpers/email');
|
||||
const { sendTemplatedEmail} = require('../helpers/awsEmail');
|
||||
const { currentRERequest } = require("../helpers/url");
|
||||
const { isValidEmail } = require("../helpers/email");
|
||||
const { sendTemplatedEmail } = require("../helpers/awsEmail");
|
||||
|
||||
const getQuerySubmit = async (req, res) => {
|
||||
|
||||
const title = "Upišite vaš e-mail"
|
||||
const title = "Upišite vaš e-mail";
|
||||
const nextStep = req.query.nextStep;
|
||||
const error = req.query.error;
|
||||
|
||||
res.render('querySubmit', {
|
||||
res.render("querySubmit", {
|
||||
nextStep,
|
||||
error,
|
||||
title
|
||||
@@ -17,25 +16,23 @@ const getQuerySubmit = async (req, res) => {
|
||||
|
||||
const postQuerySubmit = async (req, res) => {
|
||||
const request = await currentRERequest(req);
|
||||
const nextStep = req.query.nextStep || '/ponovo';
|
||||
const nextStep = req.query.nextStep || "/ponovo";
|
||||
|
||||
const emailInput = req.body.email;
|
||||
const emailConfirmInput = req.body.confirm;
|
||||
let error = "Greška ! Unesite validan email";
|
||||
|
||||
if (!isValidEmail(emailInput) || !isValidEmail(emailConfirmInput)) {
|
||||
|
||||
error = "Greška ! Unesite validan email";
|
||||
res.render('querySubmit', {
|
||||
res.render("querySubmit", {
|
||||
error
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (emailInput !== emailConfirmInput) {
|
||||
|
||||
error = "Greška ! Unešeni emailovi nisu isti";
|
||||
res.render('querySubmit', {
|
||||
res.render("querySubmit", {
|
||||
error
|
||||
});
|
||||
return;
|
||||
@@ -45,7 +42,7 @@ const postQuerySubmit = async (req, res) => {
|
||||
request.subscribed = true;
|
||||
await request.save();
|
||||
sendTemplatedEmail(req.body.email, request);
|
||||
res.redirect(nextStep);
|
||||
res.redirect(nextStep);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,42 +1,39 @@
|
||||
const db = require('../models/index');
|
||||
const db = require("../models/index");
|
||||
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { realEstateTypes, getRealEstateTypeEnum } = require('../helpers/enums');
|
||||
const { currentRERequest } = require("../helpers/url");
|
||||
const { realEstateTypes, getRealEstateTypeEnum } = require("../helpers/enums");
|
||||
|
||||
|
||||
const getRealEstateTypes = (req,res) => {
|
||||
const title = "Koju nekretninu tražite?"
|
||||
res.render('realEstateType', { realEstateTypes, title });
|
||||
const getRealEstateTypes = (req, res) => {
|
||||
const title = "Koju nekretninu tražite?";
|
||||
res.render("realEstateType", { realEstateTypes, title });
|
||||
};
|
||||
|
||||
const postRealEstateTypes = async (req, res) => {
|
||||
const request = await currentRERequest(req);
|
||||
|
||||
const nextStepPage = req.query.nextStep || 'grad';
|
||||
const nextStepPage = req.query.nextStep || "grad";
|
||||
|
||||
if (request && request.uniqueId) {
|
||||
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
||||
request.realEstateType = req.body.realestatetype;
|
||||
if (!getRealEstateTypeEnum(request.realEstateType).hasGardenSize){
|
||||
if (!getRealEstateTypeEnum(request.realEstateType).hasGardenSize) {
|
||||
request.gardenSize = null;
|
||||
}
|
||||
await request.save();
|
||||
|
||||
res.redirect(nextStepUrl)
|
||||
res.redirect(nextStepUrl);
|
||||
} else {
|
||||
db.RealEstateRequest.create({
|
||||
realEstateType: req.body.realestatetype
|
||||
}).then( (result) => {
|
||||
const nextStepUrl = `/${nextStepPage}/${result.uniqueId}`;
|
||||
res.redirect(nextStepUrl);
|
||||
}).catch( (e) => {
|
||||
res.send(e);
|
||||
});
|
||||
})
|
||||
.then(result => {
|
||||
const nextStepUrl = `/${nextStepPage}/${result.uniqueId}`;
|
||||
res.redirect(nextStepUrl);
|
||||
})
|
||||
.catch(e => {
|
||||
res.send(e);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
const { allMarketAlertsByRequest } = require("../helpers/db/dbHelper");
|
||||
|
||||
const {allMarketAlertsByRequest} = require('../helpers/db/dbHelper');
|
||||
const getRealEstates = async (req, res) => {
|
||||
const request = req.params["request_id"];
|
||||
const realEstates = await allMarketAlertsByRequest(request);
|
||||
|
||||
const getRealEstates = async (req,res) => {
|
||||
console.log("Enter get realestates");
|
||||
const request = req.params['request_id'];
|
||||
console.log(req.params['request_id']);
|
||||
const realEstates = await allMarketAlertsByRequest(request);
|
||||
console.log(realEstates);
|
||||
const title = "Ovo su nekretnine koje smo pronašli za vas";
|
||||
res.render("realEstates", { realEstates, title });
|
||||
};
|
||||
|
||||
const title = "Ovo su nekretnine koje smo pronašli za vas"
|
||||
res.render('realEstates', {realEstates, title } );
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getRealEstates
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getRealEstates
|
||||
};
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { getRegions } = require('../helpers/codes');
|
||||
const { currentRERequest } = require("../helpers/url");
|
||||
const { getRegions } = require("../helpers/codes");
|
||||
|
||||
const regions = getRegions();
|
||||
|
||||
const getRegion = (req,res) => {
|
||||
const title = "U kojoj regiji tražite nekretninu?"
|
||||
res.render('region', { regions, title });
|
||||
const getRegion = (req, res) => {
|
||||
const title = "U kojoj regiji tražite nekretninu?";
|
||||
res.render("region", { regions, title });
|
||||
};
|
||||
|
||||
const postRegion = async (req, res) => {
|
||||
const request = await currentRERequest(req);
|
||||
|
||||
const nextStepQueryParam = req.query.nextStep ? '?nextStep=pregled' : '';
|
||||
const nextStepPage = req.query.nextStep || 'mjesto';
|
||||
const nextStepQueryParam = req.query.nextStep ? "?nextStep=pregled" : "";
|
||||
const nextStepPage = req.query.nextStep || "mjesto";
|
||||
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}${nextStepQueryParam}`;
|
||||
|
||||
request.region = req.body.region;
|
||||
request.municipality = null;
|
||||
await request.save();
|
||||
|
||||
res.redirect(nextStepUrl)
|
||||
res.redirect(nextStepUrl);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { sizes, getRealEstateTypeEnum } = require('../helpers/enums');
|
||||
const { currentRERequest } = require("../helpers/url");
|
||||
const { sizes, getRealEstateTypeEnum } = require("../helpers/enums");
|
||||
|
||||
const getSize = (req,res) => {
|
||||
|
||||
const title = "Od koliko kvadrata tražite nekretninu ?"
|
||||
const unit = " m2"
|
||||
const getSize = (req, res) => {
|
||||
const title = "Od koliko kvadrata tražite nekretninu ?";
|
||||
const unit = " m2";
|
||||
const rangeFrom = {
|
||||
min : 10,
|
||||
max : 250,
|
||||
value : 0,
|
||||
step : 10
|
||||
}
|
||||
min: 10,
|
||||
max: 250,
|
||||
value: 0,
|
||||
step: 10
|
||||
};
|
||||
|
||||
const rangeTo = {
|
||||
min : 10,
|
||||
max : 250,
|
||||
value : 50,
|
||||
step : 10
|
||||
}
|
||||
min: 10,
|
||||
max: 250,
|
||||
value: 50,
|
||||
step: 10
|
||||
};
|
||||
|
||||
res.render('size', { rangeFrom, rangeTo, unit, title });
|
||||
res.render("size", { rangeFrom, rangeTo, unit, title });
|
||||
};
|
||||
|
||||
const postSize = async (req, res) => {
|
||||
@@ -27,7 +26,8 @@ const postSize = async (req, res) => {
|
||||
|
||||
const realEstateType = getRealEstateTypeEnum(request.realEstateType);
|
||||
|
||||
const nextStep = realEstateType && realEstateType.hasGardenSize ? 'okucnica' : 'cijena';
|
||||
const nextStep =
|
||||
realEstateType && realEstateType.hasGardenSize ? "okucnica" : "cijena";
|
||||
const nextStepPage = req.query.nextStep || nextStep;
|
||||
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
||||
request.sizeMin = req.body.from;
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { currentRERequest } = require("../helpers/url");
|
||||
|
||||
const getUnsubscribe = async (req, res) => {
|
||||
const title = "Uspješno ste se odjavili";
|
||||
const request = await currentRERequest(req);
|
||||
request.subscribed = false;
|
||||
await request.save();
|
||||
|
||||
const title = "Uspješno ste se odjavili"
|
||||
const request = await currentRERequest(req);
|
||||
request.subscribed = false;
|
||||
await request.save();
|
||||
|
||||
res.render('unsubscribe', { nextStep: '/vrstanekretnine', title });
|
||||
res.render("unsubscribe", { nextStep: "/vrstanekretnine", title });
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
getUnsubscribe
|
||||
};
|
||||
getUnsubscribe
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const getWelcome = (req,res) => {
|
||||
const title = "Koju nekretninu tražite?"
|
||||
res.render('welcome', { nextStep: '/vrstanekretnine', title } );
|
||||
const getWelcome = (req, res) => {
|
||||
const title = "Koju nekretninu tražite?";
|
||||
res.render("welcome", { nextStep: "/vrstanekretnine", title });
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const dotenv = require("dotenv").config();
|
||||
const { APP_URL } = require("../config/appConfig");
|
||||
const { getRealEstateTypeEnum } = require("./enums");
|
||||
const { getRegionName, getMunicipalityName } = require("./codes");
|
||||
const { allRERequestByUiid } = require("./db/dbHelper");
|
||||
@@ -57,9 +57,7 @@ const getGreetingsEmailHTML = realestateRequest => {
|
||||
realestateRequest.realEstateType
|
||||
);
|
||||
const gardenSize = realEstateType.hasGardenSize
|
||||
? `<div><strong>Kvadratura okućnice: Od ${
|
||||
realestateRequest.gardenSizeMin
|
||||
} do ${realestateRequest.gardenSizeMax} m2 </strong></div>`
|
||||
? `<div><strong>Kvadratura okućnice: Od ${realestateRequest.gardenSizeMin} do ${realestateRequest.gardenSizeMax} m2 </strong></div>`
|
||||
: ``;
|
||||
|
||||
return `<h1> Zdravo,
|
||||
@@ -85,15 +83,15 @@ const getGreetingsEmailHTML = realestateRequest => {
|
||||
<div>
|
||||
|
||||
</div>
|
||||
<div><strong> Ako želis prestati dobijati obavještenja za ovu pretragu klikni ${
|
||||
process.env.APP_URL
|
||||
}/odjava/${realestateRequest.uniqueId} </strong></div>
|
||||
<div><strong>Ako želiš promijeniti uslove pretrage klikni ${
|
||||
process.env.APP_URL
|
||||
}/pregled/${realestateRequest.uniqueId} </strong></div>
|
||||
<h4> Tvoj,
|
||||
Javimi tim.
|
||||
</h4>`;
|
||||
<div><strong> Ako želis prestati dobijati obavještenja za ovu pretragu klikni ${APP_URL}/odjava/${
|
||||
realestateRequest.uniqueId
|
||||
} </strong></div>
|
||||
<div><strong>Ako želiš promijeniti uslove pretrage klikni ${APP_URL}/pregled/${
|
||||
realestateRequest.uniqueId
|
||||
} </strong></div>
|
||||
<h4> Tvoj,
|
||||
Javimi tim.
|
||||
</h4>`;
|
||||
};
|
||||
|
||||
const getGreetingsEmaiTextVersion = realestateRequest => {
|
||||
@@ -101,40 +99,27 @@ const getGreetingsEmaiTextVersion = realestateRequest => {
|
||||
realestateRequest.realEstateType
|
||||
);
|
||||
const gardenSize = realEstateType.hasGardenSize
|
||||
? "Kvadratura okućnice od " +
|
||||
realestateRequest.gardenSizeMin +
|
||||
" do " +
|
||||
realestateRequest.gardenSizeMax
|
||||
? `Kvadratura okućnice od ${realestateRequest.gardenSizeMin} do ${realestateRequest.gardenSizeMax}`
|
||||
: "";
|
||||
|
||||
const text =
|
||||
"Zdravo, \n Naručio/la si da ti javimo ako se nekretnina pojavi u oglasima \n Ovo je tražena nekretnina: \n , Tip nekretnine: " +
|
||||
realestateRequest.realEstateType +
|
||||
"\n Područje" +
|
||||
getRegionName(realestateRequest.region) +
|
||||
"\n Mjesto " +
|
||||
getMunicipalityName(
|
||||
realestateRequest.region,
|
||||
realestateRequest.municipality
|
||||
) +
|
||||
"\n Kvadratura nekretnine Od " +
|
||||
realestateRequest.sizeMin +
|
||||
" do " +
|
||||
realestateRequest.sizeMaX +
|
||||
+gardenSize;
|
||||
"\n Cijena od " +
|
||||
realestateRequest.priceMin +
|
||||
" do " +
|
||||
realestateRequest.priceMax +
|
||||
"\n Ako želis prestati dobijati obavještenja za ovu pretragu klikni" +
|
||||
process.env.APP_URL +
|
||||
"/odjava/" +
|
||||
realestateRequest.uniqueId +
|
||||
"\n Ako želiš promijeniti uslove pretrage klikni " +
|
||||
process.env.APP_URL +
|
||||
"/odpregled/" +
|
||||
realestateRequest.uniqueId +
|
||||
"\n Tvoj,\n Javimi tim";
|
||||
const text = `Zdravo, \n Naručio/la si da ti javimo ako se nekretnina pojavi u oglasima
|
||||
\n Ovo je tražena nekretnina: \n , Tip nekretnine: ${
|
||||
realestateRequest.realEstateType
|
||||
} \n Područje ${getRegionName(
|
||||
realestateRequest.region
|
||||
)} \n Mjesto ${getMunicipalityName(
|
||||
realestateRequest.region,
|
||||
realestateRequest.municipality
|
||||
)}
|
||||
\n Kvadratura nekretnine Od ${realestateRequest.sizeMin} do ${
|
||||
realestateRequest.sizeMaX
|
||||
} ${gardenSize} \n Cijena od ${realestateRequest.priceMin} do ${
|
||||
realestateRequest.priceMax
|
||||
} \n Ako želis prestati dobijati obavještenja za ovu pretragu klikni
|
||||
${APP_URL}/odjava/${
|
||||
realestateRequest.uniqueId
|
||||
}\n Ako želiš promijeniti uslove pretrage klikni
|
||||
${APP_URL}/odpregled/${realestateRequest.uniqueId}\n Tvoj,\n Javimi tim`;
|
||||
|
||||
return text;
|
||||
};
|
||||
@@ -165,7 +150,7 @@ const sendBulkEmail = async marketAlerts => {
|
||||
realEstateType: RERequest.realEstateType,
|
||||
region: RERequest.region,
|
||||
municipality: RERequest.municipality,
|
||||
requestUrl: `${process.env.APP_URL}/nekretnine/${RERequest.uniqueId}`
|
||||
requestUrl: `${APP_URL}/nekretnine/${RERequest.uniqueId}`
|
||||
};
|
||||
});
|
||||
|
||||
@@ -213,8 +198,6 @@ const sendBulkEmail = async marketAlerts => {
|
||||
ReplacementTemplateData: repData
|
||||
});
|
||||
}
|
||||
console.log("AWS EMAIL : Bulk email replacement data:");
|
||||
console.log(destinations);
|
||||
|
||||
var params = {
|
||||
Destinations: destinations,
|
||||
@@ -229,15 +212,12 @@ const sendBulkEmail = async marketAlerts => {
|
||||
.sendBulkTemplatedEmail(params)
|
||||
.promise();
|
||||
const awsResult = await sendPromise;
|
||||
console.log("AWS SES bulk email response");
|
||||
console.log(awsResult);
|
||||
} catch (e) {
|
||||
console.log("Could not send bulk email", e);
|
||||
}
|
||||
};
|
||||
|
||||
const redirectUrl = marketAlertId =>
|
||||
`${process.env.APP_URL}/redirect/${marketAlertId}`;
|
||||
const redirectUrl = marketAlertId => `${APP_URL}/redirect/${marketAlertId}`;
|
||||
const toAWSArray = urlArray => {
|
||||
let arrayString = "";
|
||||
urlArray.forEach(element => {
|
||||
@@ -250,11 +230,11 @@ const toAWSArray = urlArray => {
|
||||
};
|
||||
|
||||
const getNotificationEmailHtml = () => {
|
||||
return `<h2> Zdravo,
|
||||
return `<h2> Zdravo,
|
||||
Pronašli smo nekretninu koju ste tražili. </h2>
|
||||
<h3> Ovo su tražene nekretnine: </h3>
|
||||
<h3> Ovo su tražene nekretnine: </h3>
|
||||
<div>
|
||||
<div>{{#each marketAlertUrl}}<li><a href="{{url}}">{{title}}</a></li><br />{{/each}}<div/>
|
||||
<div>{{#each marketAlertUrl}}<li><a href="{{url}}">{{title}}</a></li><br />{{/each}}<div/>
|
||||
<div/>
|
||||
<div>Kompletan spisak nekretnina možete pegledati ovdije: <a href="{{requestUrl}}">Nekretnine</a> <div>
|
||||
</div>`;
|
||||
|
||||
1811
app/helpers/codes.js
1811
app/helpers/codes.js
File diff suppressed because it is too large
Load Diff
@@ -1,375 +1,364 @@
|
||||
const fetch = require('node-fetch');
|
||||
const cheerio = require('cheerio');
|
||||
const { allRERequest, findPointInsideBoundingBox } = require('../db/dbHelper');
|
||||
const { getRealEstateTypeEnum } = require('../enums');
|
||||
const { getRegion, getMunicipality } = require('../codes')
|
||||
const fetch = require("node-fetch");
|
||||
const cheerio = require("cheerio");
|
||||
const { allRERequest, findPointInsideBoundingBox } = require("../db/dbHelper");
|
||||
const { getRealEstateTypeEnum } = require("../enums");
|
||||
const { getRegion, getMunicipality } = require("../codes");
|
||||
const Promise = require("bluebird");
|
||||
|
||||
module.exports = class OlxCrawler {
|
||||
//TODO figure best way to handle paging
|
||||
constructor(hrefs = []) {
|
||||
this.hrefs = hrefs;
|
||||
}
|
||||
//TODO figure best way to handle paging
|
||||
constructor(hrefs = []) {
|
||||
this.hrefs = hrefs;
|
||||
}
|
||||
|
||||
async indexPages(urls) {
|
||||
const indexers = [];
|
||||
async indexPages(urls) {
|
||||
const indexers = [];
|
||||
|
||||
urls.forEach(url => {
|
||||
indexers.push(new Indexer(url));
|
||||
});
|
||||
urls.forEach(url => {
|
||||
indexers.push(new Indexer(url));
|
||||
});
|
||||
|
||||
return Promise.map(indexers, function (indexer) {
|
||||
return indexer.indexWithPagination();
|
||||
}).then(async (results) => {
|
||||
return results
|
||||
})
|
||||
}
|
||||
return Promise.map(indexers, function(indexer) {
|
||||
return indexer.indexWithPagination();
|
||||
}).then(async results => {
|
||||
return results;
|
||||
});
|
||||
}
|
||||
|
||||
async crawl() {
|
||||
console.log("OLX CRAWLER: start crawl");
|
||||
async crawl() {
|
||||
const filteredResults = [];
|
||||
const realestateRequests = await allRERequest();
|
||||
const urls = this.createRequestUrls(realestateRequests);
|
||||
let results = await this.indexPages(
|
||||
urls,
|
||||
this.fromPage,
|
||||
this.toPage,
|
||||
this.maxResults
|
||||
);
|
||||
const flatResults = results.flat();
|
||||
if (flatResults) {
|
||||
for (const finalResult of flatResults) {
|
||||
if (null !== finalResult) {
|
||||
if (
|
||||
finalResult.lat !== undefined &&
|
||||
finalResult.lat !== null &&
|
||||
finalResult.lat !== ""
|
||||
) {
|
||||
const pointInsideBoundingBox = await findPointInsideBoundingBox(
|
||||
[finalResult.lng, finalResult.lat],
|
||||
finalResult.email,
|
||||
finalResult.uuid
|
||||
);
|
||||
|
||||
const filteredResults = [];
|
||||
const realestateRequests = await allRERequest();
|
||||
console.log("OLX CRAWLER: found " + realestateRequests.length + "subscribed RealEstateRequests");
|
||||
const urls = this.createRequestUrls(realestateRequests);
|
||||
let results = await this.indexPages(urls, this.fromPage, this.toPage, this.maxResults);
|
||||
console.log("Final crawler results");
|
||||
const flatResults = results.flat();
|
||||
console.log(flatResults);
|
||||
if (flatResults) {
|
||||
console.log(flatResults.length);
|
||||
|
||||
for (const finalResult of flatResults) {
|
||||
|
||||
if (null !== finalResult) {
|
||||
if (finalResult.lat !== undefined && finalResult.lat !== null && finalResult.lat !== "") {
|
||||
const pointInsideBoundingBox = await findPointInsideBoundingBox([finalResult.lng, finalResult.lat], finalResult.email, finalResult.uuid);
|
||||
|
||||
|
||||
if (pointInsideBoundingBox[0].length !== 0) {
|
||||
finalResult.hasLocation = true
|
||||
filteredResults.push(finalResult);
|
||||
} else {
|
||||
finalResult.hasLocation = false
|
||||
filteredResults.push(finalResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pointInsideBoundingBox[0].length !== 0) {
|
||||
finalResult.hasLocation = true;
|
||||
filteredResults.push(finalResult);
|
||||
} else {
|
||||
finalResult.hasLocation = false;
|
||||
filteredResults.push(finalResult);
|
||||
}
|
||||
|
||||
console.log("OLX CRAWLER: number of olx crawler results, after geo location filtering: " + filteredResults.length);
|
||||
return filteredResults;
|
||||
}
|
||||
}
|
||||
return []
|
||||
}
|
||||
return filteredResults;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
createRequestUrls(realestateRequests) {
|
||||
const urls = [];
|
||||
|
||||
for (const request of realestateRequests) {
|
||||
const realsestateType =
|
||||
"kategorija=" +
|
||||
getRealEstateTypeEnum(request.realEstateType).olxCategory;
|
||||
const region = "kanton=" + getRegion(request.region).olxid;
|
||||
const municipality =
|
||||
"grad%5B%5D=" +
|
||||
getMunicipality(request.region, request.municipality).olxid;
|
||||
const sizeMin = "kvadrata_min=" + request.sizeMin;
|
||||
const sizeMax = "kvadrata_max=" + request.sizeMax;
|
||||
const priceMin = "od=" + request.priceMin;
|
||||
const priceMax = "do=" + request.priceMax;
|
||||
|
||||
const olxUrl = {
|
||||
url: `https://www.olx.ba/pretraga?${realsestateType}&id=2&stanje=0&vrstapregleda=tabela&sort_order=desc&${region}&${municipality}&${priceMin}&${priceMax}&vrsta=samoprodaja&${sizeMin}&${sizeMax}&stranica=`,
|
||||
email: request.email,
|
||||
uuid: request.uniqueId,
|
||||
hrefs: this.hrefs
|
||||
};
|
||||
urls.push(olxUrl);
|
||||
}
|
||||
|
||||
createRequestUrls(realestateRequests) {
|
||||
const urls = []
|
||||
|
||||
for (const request of realestateRequests) {
|
||||
const realsestateType = "kategorija=" + getRealEstateTypeEnum(request.realEstateType).olxCategory;
|
||||
const region = "kanton=" + getRegion(request.region).olxid;
|
||||
const municipality = "grad%5B%5D=" + getMunicipality(request.region, request.municipality).olxid;
|
||||
const sizeMin = "kvadrata_min=" + request.sizeMin;
|
||||
const sizeMax = "kvadrata_max=" + request.sizeMax;
|
||||
const priceMin = "od=" + request.priceMin;
|
||||
const priceMax = "do=" + request.priceMax;
|
||||
|
||||
const olxUrl = {
|
||||
url: `https://www.olx.ba/pretraga?${realsestateType}&id=2&stanje=0&vrstapregleda=tabela&sort_order=desc&${region}&${municipality}&${priceMin}&${priceMax}&vrsta=samoprodaja&${sizeMin}&${sizeMax}&stranica=`,
|
||||
email: request.email,
|
||||
uuid: request.uniqueId,
|
||||
hrefs: this.hrefs
|
||||
}
|
||||
console.log(olxUrl.url);
|
||||
urls.push(olxUrl);
|
||||
}
|
||||
|
||||
return urls;
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Indexer {
|
||||
/**
|
||||
*
|
||||
* @param {String|Array} olxUrl single or array of objects containing url email and uuid
|
||||
* @param {Array} hrefResutls array contaning urls from crawler results
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String|Array} olxUrl single or array of objects containing url email and uuid
|
||||
* @param {Array} hrefResutls array contaning urls from crawler results
|
||||
*/
|
||||
constructor(olxUrl, hrefResutls) {
|
||||
this.olxUrl = olxUrl;
|
||||
this.hrefResutls = hrefResutls;
|
||||
}
|
||||
|
||||
constructor(olxUrl, hrefResutls) {
|
||||
this.olxUrl = olxUrl;
|
||||
this.hrefResutls = hrefResutls;
|
||||
}
|
||||
async indexWithPagination(pageNumber = 1) {
|
||||
const pageNr = this.olxUrl.url.match(/\d+$/);
|
||||
const indexers = this.prepareIndexers(pageNumber ? [pageNumber] : pageNr);
|
||||
|
||||
async indexWithPagination(pageNumber = 1) {
|
||||
try {
|
||||
return Promise.map(indexers.indexers, function(indexer) {
|
||||
return indexer.indexPage(pageNumber);
|
||||
}).then(async results => {
|
||||
let hasResults = false;
|
||||
|
||||
console.log("This is olxUrl:" + this.olxUrl.url);
|
||||
const pageNr = this.olxUrl.url.match(/\d+$/);
|
||||
const indexers = this.prepareIndexers(pageNumber ? [pageNumber] : pageNr);
|
||||
results.forEach(result => {
|
||||
if (!hasResults) {
|
||||
hasResults = result.hasResults;
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
if (!hasResults) {
|
||||
const singlePageIndexers = this.prepareHrefIndexers(results);
|
||||
if (singlePageIndexers.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Promise.map(indexers.indexers, function (indexer) {
|
||||
return indexer.indexPage(pageNumber);
|
||||
}).then(async (results) => {
|
||||
let hasResults = false;
|
||||
|
||||
results.forEach(result => {
|
||||
if (!hasResults) {
|
||||
console.log("No results detected")
|
||||
hasResults = result.hasResults
|
||||
}
|
||||
});
|
||||
|
||||
if (!hasResults) {
|
||||
console.log("HAS NO MORE RESULTS, stop the paging, there are some results and they should contain only HREFS");
|
||||
console.log(results.length);
|
||||
const singlePageIndexers = this.prepareHrefIndexers(results);
|
||||
if (singlePageIndexers.length === 0) {
|
||||
console.log("THERE IS NOT EVEN SINGLE RESULT");
|
||||
return []
|
||||
}
|
||||
|
||||
return Promise.map(singlePageIndexers, function (indexer) {
|
||||
return indexer.indexSingle();
|
||||
}).then(async (results) => {
|
||||
console.log("SinglePageMethod in HAS NO RESULTS, MarketAralms");
|
||||
console.log(results.length);
|
||||
return results;
|
||||
});
|
||||
|
||||
} else {
|
||||
console.log("HAS MORE RESULTS, should only contain HREFS");
|
||||
console.log(results.length);
|
||||
const newResults = await this.indexWithPagination(results[0].pageNumber + 5);
|
||||
const singlePageIndexers = this.prepareHrefIndexers(results);
|
||||
|
||||
const newerResults = await Promise.map(singlePageIndexers, function (indexer) {
|
||||
return indexer.indexSingle();
|
||||
}).then(async (results) => {
|
||||
console.log("SinglePageMethod HAS RESULTS, should contain MarketAlerts only");
|
||||
console.log(results.length);
|
||||
return results;
|
||||
});
|
||||
|
||||
Array.prototype.push.apply(newResults, newerResults);
|
||||
return newResults;
|
||||
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("Error has accured", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
prepareIndexers(pageNr) {
|
||||
|
||||
console.log("Entering prepareIndexers : page nr - " + pageNr);
|
||||
const indexers = [];
|
||||
let lastPageNumber;
|
||||
if (pageNr) {
|
||||
for (let index = Number(pageNr[0]); index <= Number(pageNr[0]) + 5; index++) {
|
||||
lastPageNumber = index;
|
||||
const newOlxUrl = {
|
||||
url: this.olxUrl.url.replace(/\d+$/, "") + index,
|
||||
email: this.olxUrl.email,
|
||||
uuid: this.olxUrl.uuid,
|
||||
hrefs: this.olxUrl.hrefs
|
||||
}
|
||||
indexers.push(new Indexer(newOlxUrl));
|
||||
|
||||
}
|
||||
return Promise.map(singlePageIndexers, function(indexer) {
|
||||
return indexer.indexSingle();
|
||||
}).then(async results => {
|
||||
return results;
|
||||
});
|
||||
} else {
|
||||
for (let index = 1; index <= 5; index++) {
|
||||
lastPageNumber = index;
|
||||
const newOlxUrl = {
|
||||
url: this.olxUrl.url + index,
|
||||
email: this.olxUrl.email,
|
||||
uuid: this.olxUrl.uuid,
|
||||
hrefs: this.olxUrl.hrefs
|
||||
}
|
||||
indexers.push(new Indexer(newOlxUrl));
|
||||
}
|
||||
const newResults = await this.indexWithPagination(
|
||||
results[0].pageNumber + 5
|
||||
);
|
||||
const singlePageIndexers = this.prepareHrefIndexers(results);
|
||||
|
||||
const newerResults = await Promise.map(singlePageIndexers, function(
|
||||
indexer
|
||||
) {
|
||||
return indexer.indexSingle();
|
||||
}).then(async results => {
|
||||
return results;
|
||||
});
|
||||
|
||||
Array.prototype.push.apply(newResults, newerResults);
|
||||
return newResults;
|
||||
}
|
||||
return {
|
||||
indexers: indexers,
|
||||
lastPageNumber: lastPageNumber
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("Error has accured", e);
|
||||
}
|
||||
}
|
||||
|
||||
prepareIndexers(pageNr) {
|
||||
const indexers = [];
|
||||
let lastPageNumber;
|
||||
if (pageNr) {
|
||||
for (
|
||||
let index = Number(pageNr[0]);
|
||||
index <= Number(pageNr[0]) + 5;
|
||||
index++
|
||||
) {
|
||||
lastPageNumber = index;
|
||||
const newOlxUrl = {
|
||||
url: this.olxUrl.url.replace(/\d+$/, "") + index,
|
||||
email: this.olxUrl.email,
|
||||
uuid: this.olxUrl.uuid,
|
||||
hrefs: this.olxUrl.hrefs
|
||||
};
|
||||
indexers.push(new Indexer(newOlxUrl));
|
||||
}
|
||||
} else {
|
||||
for (let index = 1; index <= 5; index++) {
|
||||
lastPageNumber = index;
|
||||
const newOlxUrl = {
|
||||
url: this.olxUrl.url + index,
|
||||
email: this.olxUrl.email,
|
||||
uuid: this.olxUrl.uuid,
|
||||
hrefs: this.olxUrl.hrefs
|
||||
};
|
||||
indexers.push(new Indexer(newOlxUrl));
|
||||
}
|
||||
}
|
||||
return {
|
||||
indexers: indexers,
|
||||
lastPageNumber: lastPageNumber
|
||||
};
|
||||
}
|
||||
|
||||
prepareHrefIndexers(results) {
|
||||
const indexers = []
|
||||
prepareHrefIndexers(results) {
|
||||
const indexers = [];
|
||||
|
||||
if (!Array.isArray(results)) {
|
||||
results.hrefs.forEach(href => {
|
||||
const newOlxUrl = {
|
||||
url: href,
|
||||
email: results.olxUrl.email,
|
||||
uuid: results.olxUrl.uuid,
|
||||
hrefs: this.olxUrl.hrefs
|
||||
}
|
||||
if (!Array.isArray(results)) {
|
||||
results.hrefs.forEach(href => {
|
||||
const newOlxUrl = {
|
||||
url: href,
|
||||
email: results.olxUrl.email,
|
||||
uuid: results.olxUrl.uuid,
|
||||
hrefs: this.olxUrl.hrefs
|
||||
};
|
||||
|
||||
indexers.push(new Indexer(newOlxUrl));
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
results.forEach(result => {
|
||||
|
||||
if (result !== null && result.hasOwnProperty('hrefs')) {
|
||||
result.hrefs.forEach(href => {
|
||||
const newOlxUrl = {
|
||||
url: href,
|
||||
email: result.olxUrl.email,
|
||||
uuid: result.olxUrl.uuid,
|
||||
hrefs: this.olxUrl.hrefs
|
||||
}
|
||||
|
||||
indexers.push(new Indexer(newOlxUrl));
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return indexers;
|
||||
}
|
||||
|
||||
async indexPage(pageNumber) {
|
||||
console.log("Page number in index page, max page number :")
|
||||
console.log(pageNumber);
|
||||
|
||||
try {
|
||||
|
||||
console.log("Indexing page: " + this.olxUrl.url);
|
||||
const res = await fetch(this.olxUrl.url);
|
||||
const body = await res.text();
|
||||
const $ = cheerio.load(body);
|
||||
const hrefs = [];
|
||||
let hasResults = false
|
||||
|
||||
$('#rezultatipretrage').find('.listitem').each((i, elem) => {
|
||||
hasResults = true
|
||||
const href = $(elem).find('a').first().attr('href');
|
||||
hrefs.push(href);
|
||||
});
|
||||
|
||||
console.log("this is hrefs for olxUrl" + this.olxUrl.url);
|
||||
console.log("NUMBER OF HREFS " + hrefs.length);
|
||||
|
||||
return {
|
||||
hrefs: hrefs,
|
||||
hasResults: hasResults,
|
||||
pageNumber: pageNumber,
|
||||
olxUrl: this.olxUrl
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Exception caught:' + e);
|
||||
}
|
||||
}
|
||||
|
||||
async indexSingle() {
|
||||
try {
|
||||
console.log("Index single");
|
||||
console.log(this.olxUrl.url);
|
||||
|
||||
if (this.olxUrl.url === undefined) {
|
||||
return {}
|
||||
}
|
||||
|
||||
// if (global.hrefs) {
|
||||
|
||||
if (this.olxUrl.hrefs[this.olxUrl.uuid] && this.olxUrl.hrefs[this.olxUrl.uuid].includes(this.olxUrl.url)) {
|
||||
|
||||
console.log("We found duplicate URL");
|
||||
return null
|
||||
}
|
||||
// }
|
||||
|
||||
const res = await fetch(this.olxUrl.url);
|
||||
const body = await res.text();
|
||||
const $ = cheerio.load(body);
|
||||
|
||||
const title = $('#naslovartikla').text().trim();
|
||||
const realEstateType = $('#artikal_glavni_div > div.artikal_lijevo > div:nth-child(3) > div > span:nth-child(3) > a > span').text();
|
||||
|
||||
const price = $('#pc > p:nth-child(2)').text();
|
||||
const size = $('#dodatnapolja1 > div:nth-child(1) > div.df2').text();
|
||||
const rooms = $('#dodatnapolja1 > div:nth-child(2) > div.df2').text();
|
||||
const address = $('#dodatnapolja1 > div:nth-child(5) > div.df2').text();
|
||||
const gardenSize = $('#dodatnapolja1 > div:nth-child(6) > div.df2').text();
|
||||
const location = $('#artikal_glavni_div > div.artikal_lijevo > div.op.pop.mobile-lokacija').attr('data-content');
|
||||
|
||||
const time = $('time').attr('datetime');
|
||||
const olxId = $('#artikal_glavni_div > div.artikal_lijevo > div:nth-child(15) > div:nth-child(4) > div.df2').text();
|
||||
|
||||
const descriptions = $('.artikal_detaljniopis_tekst');
|
||||
const latLngRe = /LatLng\(([0-9]+\.[0-9]+)\,\s+([0-9]+\.[0-9]+)\)/g;
|
||||
const imgRe = /href":("[^"]*")/g;
|
||||
const matches = latLngRe.exec(body);
|
||||
let lng = '',
|
||||
lat = '';
|
||||
const parsePrice = (price) => parseFloat(price.replace(".", ""))
|
||||
|
||||
if (matches && matches.length >= 3) {
|
||||
lat = matches[1];
|
||||
lng = matches[2];
|
||||
}
|
||||
|
||||
const parsedPrice = parsePrice(price);
|
||||
|
||||
const locationArray = location.split(",");
|
||||
const region = locationArray[0];
|
||||
const municipality = locationArray[1];
|
||||
|
||||
const data = {
|
||||
realEstateType: this.getCategoryId(realEstateType),
|
||||
email: this.olxUrl.email,
|
||||
uuid: this.olxUrl.uuid,
|
||||
olxId: olxId,
|
||||
url: this.olxUrl.url,
|
||||
title,
|
||||
price: isNaN(parsedPrice) ? 0 : parsedPrice,
|
||||
size: parseFloat(size),
|
||||
gardenSize: isNaN(parseFloat(gardenSize)) ? 0 : parseFloat(gardenSize),
|
||||
address,
|
||||
region,
|
||||
municipality,
|
||||
time,
|
||||
shortDescription: descriptions.first().text(),
|
||||
longDescription: descriptions.last().text(),
|
||||
lat,
|
||||
lng,
|
||||
loc: [parseFloat(lat), parseFloat(lng)],
|
||||
indexers.push(new Indexer(newOlxUrl));
|
||||
});
|
||||
} else {
|
||||
results.forEach(result => {
|
||||
if (result !== null && result.hasOwnProperty("hrefs")) {
|
||||
result.hrefs.forEach(href => {
|
||||
const newOlxUrl = {
|
||||
url: href,
|
||||
email: result.olxUrl.email,
|
||||
uuid: result.olxUrl.uuid,
|
||||
hrefs: this.olxUrl.hrefs
|
||||
};
|
||||
|
||||
return data;
|
||||
} catch (e) {
|
||||
console.error('Exception caught: ' + e.message);
|
||||
indexers.push(new Indexer(newOlxUrl));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return indexers;
|
||||
}
|
||||
|
||||
async indexPage(pageNumber) {
|
||||
try {
|
||||
const res = await fetch(this.olxUrl.url);
|
||||
const body = await res.text();
|
||||
const $ = cheerio.load(body);
|
||||
const hrefs = [];
|
||||
let hasResults = false;
|
||||
|
||||
$("#rezultatipretrage")
|
||||
.find(".listitem")
|
||||
.each((i, elem) => {
|
||||
hasResults = true;
|
||||
const href = $(elem)
|
||||
.find("a")
|
||||
.first()
|
||||
.attr("href");
|
||||
hrefs.push(href);
|
||||
});
|
||||
return {
|
||||
hrefs: hrefs,
|
||||
hasResults: hasResults,
|
||||
pageNumber: pageNumber,
|
||||
olxUrl: this.olxUrl
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Exception caught:" + e);
|
||||
}
|
||||
}
|
||||
|
||||
async indexSingle() {
|
||||
try {
|
||||
if (this.olxUrl.url === undefined) {
|
||||
return {};
|
||||
}
|
||||
|
||||
// if (global.hrefs) {
|
||||
|
||||
if (
|
||||
this.olxUrl.hrefs[this.olxUrl.uuid] &&
|
||||
this.olxUrl.hrefs[this.olxUrl.uuid].includes(this.olxUrl.url)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
// }
|
||||
|
||||
const res = await fetch(this.olxUrl.url);
|
||||
const body = await res.text();
|
||||
const $ = cheerio.load(body);
|
||||
|
||||
const title = $("#naslovartikla")
|
||||
.text()
|
||||
.trim();
|
||||
const realEstateType = $(
|
||||
"#artikal_glavni_div > div.artikal_lijevo > div:nth-child(3) > div > span:nth-child(3) > a > span"
|
||||
).text();
|
||||
|
||||
const price = $("#pc > p:nth-child(2)").text();
|
||||
const size = $("#dodatnapolja1 > div:nth-child(1) > div.df2").text();
|
||||
const rooms = $("#dodatnapolja1 > div:nth-child(2) > div.df2").text();
|
||||
const address = $("#dodatnapolja1 > div:nth-child(5) > div.df2").text();
|
||||
const gardenSize = $(
|
||||
"#dodatnapolja1 > div:nth-child(6) > div.df2"
|
||||
).text();
|
||||
const location = $(
|
||||
"#artikal_glavni_div > div.artikal_lijevo > div.op.pop.mobile-lokacija"
|
||||
).attr("data-content");
|
||||
|
||||
const time = $("time").attr("datetime");
|
||||
const olxId = $(
|
||||
"#artikal_glavni_div > div.artikal_lijevo > div:nth-child(15) > div:nth-child(4) > div.df2"
|
||||
).text();
|
||||
|
||||
const descriptions = $(".artikal_detaljniopis_tekst");
|
||||
const latLngRe = /LatLng\(([0-9]+\.[0-9]+)\,\s+([0-9]+\.[0-9]+)\)/g;
|
||||
const imgRe = /href":("[^"]*")/g;
|
||||
const matches = latLngRe.exec(body);
|
||||
let lng = "",
|
||||
lat = "";
|
||||
const parsePrice = price => parseFloat(price.replace(".", ""));
|
||||
|
||||
if (matches && matches.length >= 3) {
|
||||
lat = matches[1];
|
||||
lng = matches[2];
|
||||
}
|
||||
|
||||
const parsedPrice = parsePrice(price);
|
||||
|
||||
const locationArray = location.split(",");
|
||||
const region = locationArray[0];
|
||||
const municipality = locationArray[1];
|
||||
|
||||
const data = {
|
||||
realEstateType: this.getCategoryId(realEstateType),
|
||||
email: this.olxUrl.email,
|
||||
uuid: this.olxUrl.uuid,
|
||||
olxId: olxId,
|
||||
url: this.olxUrl.url,
|
||||
title,
|
||||
price: isNaN(parsedPrice) ? 0 : parsedPrice,
|
||||
size: parseFloat(size),
|
||||
gardenSize: isNaN(parseFloat(gardenSize)) ? 0 : parseFloat(gardenSize),
|
||||
address,
|
||||
region,
|
||||
municipality,
|
||||
time,
|
||||
shortDescription: descriptions.first().text(),
|
||||
longDescription: descriptions.last().text(),
|
||||
lat,
|
||||
lng,
|
||||
loc: [parseFloat(lat), parseFloat(lng)]
|
||||
};
|
||||
|
||||
return data;
|
||||
} catch (e) {
|
||||
console.error("Exception caught: " + e.message);
|
||||
}
|
||||
|
||||
getCategoryId(category) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (category) {
|
||||
case 'Stanovi':
|
||||
return 'stan';
|
||||
getCategoryId(category) {
|
||||
switch (category) {
|
||||
case "Stanovi":
|
||||
return "stan";
|
||||
|
||||
case 'Vikendice':
|
||||
return 'vikendica'
|
||||
case "Vikendice":
|
||||
return "vikendica";
|
||||
|
||||
case 'Kuće':
|
||||
return 'kuca';
|
||||
case "Kuće":
|
||||
return "kuca";
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
const isValidEmail = (email) => {
|
||||
const isValidEmail = email => {
|
||||
const simpleEmailRegex = /^.+@.+\..+$/;
|
||||
return (email && email.length < 250 && simpleEmailRegex.test(email));
|
||||
return email && email.length < 250 && simpleEmailRegex.test(email);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
const realEstateTypes = [
|
||||
{ title: "Kuća", id: "kuca", hasGardenSize: true, olxCategory: 24 },
|
||||
{ title: "Stan", id: "stan", hasGardenSize: false, olxCategory: 23},
|
||||
{ title: "Vikendica", id: "vikendica", hasGardenSize: true, olxCategory: 26 }
|
||||
{ title: "Kuća", id: "kuca", hasGardenSize: true, olxCategory: 24 },
|
||||
{ title: "Stan", id: "stan", hasGardenSize: false, olxCategory: 23 },
|
||||
{ title: "Vikendica", id: "vikendica", hasGardenSize: true, olxCategory: 26 }
|
||||
];
|
||||
|
||||
const sizes = [
|
||||
{ title: "do 50 m2", id: "50m2" },
|
||||
{ title: "do 75 m2", id: "75m2" },
|
||||
{ title: "do 100 m2", id: "100m2" },
|
||||
{ title: "do 150 m2", id: "150m2" },
|
||||
{ title: "do 200 m2", id: "200m2" },
|
||||
{ title: "preko 200 m2", id: "moreThan200m2" }
|
||||
{ title: "do 50 m2", id: "50m2" },
|
||||
{ title: "do 75 m2", id: "75m2" },
|
||||
{ title: "do 100 m2", id: "100m2" },
|
||||
{ title: "do 150 m2", id: "150m2" },
|
||||
{ title: "do 200 m2", id: "200m2" },
|
||||
{ title: "preko 200 m2", id: "moreThan200m2" }
|
||||
];
|
||||
|
||||
const gardenSizes = [
|
||||
{ title: "do 100 m2", id: "100m2" },
|
||||
{ title: "do 500 m2", id: "500m2" },
|
||||
{ title: "do 1 dunum", id: "1000m2" },
|
||||
{ title: "do 2 dunuma", id: "2000m2" },
|
||||
{ title: "do 3 dunuma", id: "3000m2" },
|
||||
{ title: "preko 3 dunuma", id: "moreThan3000m2" }
|
||||
{ title: "do 100 m2", id: "100m2" },
|
||||
{ title: "do 500 m2", id: "500m2" },
|
||||
{ title: "do 1 dunum", id: "1000m2" },
|
||||
{ title: "do 2 dunuma", id: "2000m2" },
|
||||
{ title: "do 3 dunuma", id: "3000m2" },
|
||||
{ title: "preko 3 dunuma", id: "moreThan3000m2" }
|
||||
];
|
||||
|
||||
const prices = [
|
||||
{ title: "do 50 000 KM", id: "50kKM" },
|
||||
{ title: "do 100 000 KM", id: "100kKM" },
|
||||
{ title: "do 150 000 KM", id: "150kKM" },
|
||||
{ title: "do 200 000 KM", id: "200kKM" },
|
||||
{ title: "do 250 000 KM", id: "250kKM" },
|
||||
{ title: "preko 250 000 KM", id: "moreThan250kKM" }
|
||||
{ title: "do 50 000 KM", id: "50kKM" },
|
||||
{ title: "do 100 000 KM", id: "100kKM" },
|
||||
{ title: "do 150 000 KM", id: "150kKM" },
|
||||
{ title: "do 200 000 KM", id: "200kKM" },
|
||||
{ title: "do 250 000 KM", id: "250kKM" },
|
||||
{ title: "preko 250 000 KM", id: "moreThan250kKM" }
|
||||
];
|
||||
|
||||
const getEnumObject = (enumType, enumId) => {
|
||||
return enumType.find(enumValue => enumValue.id === enumId);
|
||||
return enumType.find(enumValue => enumValue.id === enumId);
|
||||
};
|
||||
|
||||
const getRealEstateTypeEnum = (enumId) => {
|
||||
return getEnumObject(realEstateTypes, enumId) || null;
|
||||
}
|
||||
const getRealEstateTypeEnum = enumId => {
|
||||
return getEnumObject(realEstateTypes, enumId) || null;
|
||||
};
|
||||
|
||||
const getEnumTypeTitle = (enumType, enumId) => {
|
||||
const enumObject = getEnumObject(enumType, enumId);
|
||||
if (!enumObject){
|
||||
return null;
|
||||
}
|
||||
return enumObject.title;
|
||||
const enumObject = getEnumObject(enumType, enumId);
|
||||
if (!enumObject) {
|
||||
return null;
|
||||
}
|
||||
return enumObject.title;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
realEstateTypes,
|
||||
sizes,
|
||||
gardenSizes,
|
||||
prices,
|
||||
getRealEstateTypeEnum,
|
||||
getEnumTypeTitle,
|
||||
realEstateTypes,
|
||||
sizes,
|
||||
gardenSizes,
|
||||
prices,
|
||||
getRealEstateTypeEnum,
|
||||
getEnumTypeTitle
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const db = require('../models/index');
|
||||
const db = require("../models/index");
|
||||
|
||||
const currentRERequest = async (req) => {
|
||||
const uniqueId = req.params['request_id'];
|
||||
if(!uniqueId) return null;
|
||||
const currentRERequest = async req => {
|
||||
const uniqueId = req.params["request_id"];
|
||||
if (!uniqueId) return null;
|
||||
|
||||
const request = await db.RealEstateRequest.findOne({ where: {uniqueId} });
|
||||
const request = await db.RealEstateRequest.findOne({ where: { uniqueId } });
|
||||
return request;
|
||||
};
|
||||
module.exports = {
|
||||
currentRERequest,
|
||||
currentRERequest
|
||||
};
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
const scrapTheItems = require("./scrapTheItems");
|
||||
const convertToDate = require("./convertToDate");
|
||||
const AWS = require('aws-sdk');
|
||||
const AWS = require("aws-sdk");
|
||||
// AWS.config.update({region: 'eu-central-1'});
|
||||
|
||||
|
||||
async function sendNotification(marketAlert) {
|
||||
const { id, email, olx_url } = marketAlert;
|
||||
let url =
|
||||
@@ -19,37 +18,37 @@ async function sendNotification(marketAlert) {
|
||||
|
||||
// Create sendEmail params
|
||||
const params = {
|
||||
Destination: { /* required */
|
||||
CcAddresses: [
|
||||
],
|
||||
ToAddresses: [
|
||||
email
|
||||
]
|
||||
Destination: {
|
||||
/* required */
|
||||
CcAddresses: [],
|
||||
ToAddresses: [email]
|
||||
},
|
||||
Message: { /* required */
|
||||
Body: { /* required */
|
||||
Message: {
|
||||
/* required */
|
||||
Body: {
|
||||
/* required */
|
||||
Html: {
|
||||
Charset: "UTF-8",
|
||||
Data: message
|
||||
Charset: "UTF-8",
|
||||
Data: message
|
||||
},
|
||||
Text: {
|
||||
Charset: "UTF-8",
|
||||
Data: message // TODO: convert to text
|
||||
Charset: "UTF-8",
|
||||
Data: message // TODO: convert to text
|
||||
}
|
||||
},
|
||||
Subject: {
|
||||
Charset: 'UTF-8',
|
||||
Data: 'Javimi alert'
|
||||
}
|
||||
},
|
||||
Subject: {
|
||||
Charset: "UTF-8",
|
||||
Data: "Javimi alert"
|
||||
}
|
||||
},
|
||||
Source: 'info@saburly.com', /* required */
|
||||
ReplyToAddresses: [
|
||||
'info@saburly.com',
|
||||
],
|
||||
Source: "info@saburly.com" /* required */,
|
||||
ReplyToAddresses: ["info@saburly.com"]
|
||||
};
|
||||
|
||||
if (message) {
|
||||
const sendPromise = new AWS.SES({apiVersion: '2010-12-01'}).sendEmail(params).promise();
|
||||
const sendPromise = new AWS.SES({ apiVersion: "2010-12-01" })
|
||||
.sendEmail(params)
|
||||
.promise();
|
||||
await sendPromise;
|
||||
return { id, date: String(convertToDate(lastDate)) };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('MarketAlerts', {
|
||||
return queryInterface.createTable("MarketAlerts", {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
@@ -29,6 +29,6 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('MarketAlerts');
|
||||
return queryInterface.dropTable("MarketAlerts");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('RealEstateRequests', {
|
||||
return queryInterface.createTable("RealEstateRequests", {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
@@ -28,6 +28,6 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('RealEstateRequests');
|
||||
return queryInterface.dropTable("RealEstateRequests");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'RealEstateRequests',
|
||||
'city',
|
||||
Sequelize.STRING
|
||||
"RealEstateRequests",
|
||||
"city",
|
||||
Sequelize.STRING
|
||||
);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'RealEstateRequests',
|
||||
'city'
|
||||
);
|
||||
return queryInterface.removeColumn("RealEstateRequests", "city");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'RealEstateRequests',
|
||||
'place',
|
||||
Sequelize.STRING
|
||||
"RealEstateRequests",
|
||||
"place",
|
||||
Sequelize.STRING
|
||||
);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'RealEstateRequests',
|
||||
'place'
|
||||
);
|
||||
return queryInterface.removeColumn("RealEstateRequests", "place");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.renameColumn(
|
||||
'RealEstateRequests',
|
||||
'place',
|
||||
'municipality'
|
||||
"RealEstateRequests",
|
||||
"place",
|
||||
"municipality"
|
||||
);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.renameColumn(
|
||||
'RealEstateRequests',
|
||||
'municipality',
|
||||
'place'
|
||||
"RealEstateRequests",
|
||||
"municipality",
|
||||
"place"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.renameColumn(
|
||||
'RealEstateRequests',
|
||||
'city',
|
||||
'region'
|
||||
);
|
||||
return queryInterface.renameColumn("RealEstateRequests", "city", "region");
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.renameColumn(
|
||||
'RealEstateRequests',
|
||||
'region',
|
||||
'city'
|
||||
);
|
||||
return queryInterface.renameColumn("RealEstateRequests", "region", "city");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'RealEstateRequests',
|
||||
'size',
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
}
|
||||
);
|
||||
return queryInterface.addColumn("RealEstateRequests", "size", {
|
||||
type: Sequelize.STRING
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'RealEstateRequests',
|
||||
'size'
|
||||
);
|
||||
return queryInterface.removeColumn("RealEstateRequests", "size");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'RealEstateRequests',
|
||||
'gardenSize',
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
}
|
||||
);
|
||||
return queryInterface.addColumn("RealEstateRequests", "gardenSize", {
|
||||
type: Sequelize.STRING
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'RealEstateRequests',
|
||||
'gardenSize'
|
||||
);
|
||||
return queryInterface.removeColumn("RealEstateRequests", "gardenSize");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'RealEstateRequests',
|
||||
'price',
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
}
|
||||
);
|
||||
return queryInterface.addColumn("RealEstateRequests", "price", {
|
||||
type: Sequelize.STRING
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'RealEstateRequests',
|
||||
'price'
|
||||
);
|
||||
return queryInterface.removeColumn("RealEstateRequests", "price");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.query("CREATE EXTENSION postgis").then(([results, metadata]) => {
|
||||
/// No result
|
||||
})
|
||||
return queryInterface.sequelize
|
||||
.query("CREATE EXTENSION postgis")
|
||||
.then(([results, metadata]) => {
|
||||
/// No result
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.query("DROP EXTENSION IF EXISTS postgis").then(([results, metadata]) => {
|
||||
return queryInterface.sequelize
|
||||
.query("DROP EXTENSION IF EXISTS postgis")
|
||||
.then(([results, metadata]) => {
|
||||
/// No result
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
|
||||
up: (queryInterface, Sequelize) => {
|
||||
|
||||
return queryInterface.sequelize.query("ALTER TABLE \"RealEstateRequests\" ADD COLUMN bounding_box geometry(Polygon);").then(([results, metadata]) => {
|
||||
/// No result
|
||||
})
|
||||
return queryInterface.sequelize
|
||||
.query(
|
||||
'ALTER TABLE "RealEstateRequests" ADD COLUMN bounding_box geometry(Polygon);'
|
||||
)
|
||||
.then(([results, metadata]) => {
|
||||
/// No result
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.query("ALTER TABLE \"RealEstateRequests\" DROP COLUMN bounding_box").then(([results, metadata]) => {
|
||||
/// No result
|
||||
})
|
||||
return queryInterface.sequelize
|
||||
.query('ALTER TABLE "RealEstateRequests" DROP COLUMN bounding_box')
|
||||
.then(([results, metadata]) => {
|
||||
/// No result
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,27 +1,48 @@
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.addColumn('RealEstateRequests', 'sizeRange', {
|
||||
type: Sequelize.STRING
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'gardenSizeRange', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'priceRange', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t })
|
||||
])
|
||||
})
|
||||
},
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction(t => {
|
||||
return Promise.all([
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"sizeRange",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"gardenSizeRange",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"priceRange",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
)
|
||||
]);
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn('RealEstateRequests', 'sizeRange', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeRange', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'priceRange', { transaction: t })
|
||||
])
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction(t => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn("RealEstateRequests", "sizeRange", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "gardenSizeRange", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "priceRange", {
|
||||
transaction: t
|
||||
})
|
||||
}
|
||||
};
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,63 +1,147 @@
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn('RealEstateRequests', 'sizeRange', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeRange', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'priceRange', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'size', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'gardenSize', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'price', { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'gardenSizeMin', {
|
||||
type: Sequelize.INTEGER,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'gardenSizeMax', {
|
||||
type: Sequelize.INTEGER,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'sizeMin', {
|
||||
type: Sequelize.INTEGER
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'sizeMax', {
|
||||
type: Sequelize.INTEGER,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'priceMin', {
|
||||
type: Sequelize.INTEGER,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'priceMax', {
|
||||
type: Sequelize.INTEGER
|
||||
}, { transaction: t })
|
||||
])
|
||||
})
|
||||
},
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction(t => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn("RealEstateRequests", "sizeRange", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "gardenSizeRange", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "priceRange", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "size", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "gardenSize", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "price", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"gardenSizeMin",
|
||||
{
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"gardenSizeMax",
|
||||
{
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"sizeMin",
|
||||
{
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"sizeMax",
|
||||
{
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"priceMin",
|
||||
{
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"priceMax",
|
||||
{
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
{ transaction: t }
|
||||
)
|
||||
]);
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeMin', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeMax', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'sizeMin', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'sizeMax', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'priceMin', { transaction: t }),
|
||||
queryInterface.removeColumn('RealEstateRequests', 'priceMin', { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'priceMax', {
|
||||
type: Sequelize.STRING
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'gardenSizeRange', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'priceRange', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'size', {
|
||||
type: Sequelize.STRING
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'gardenSize', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('RealEstateRequests', 'price', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t })
|
||||
])
|
||||
})
|
||||
}
|
||||
};
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction(t => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn("RealEstateRequests", "gardenSizeMin", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "gardenSizeMax", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "sizeMin", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "sizeMax", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "priceMin", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("RealEstateRequests", "priceMin", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"priceMax",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"gardenSizeRange",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"priceRange",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"size",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"gardenSize",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"RealEstateRequests",
|
||||
"price",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
)
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'RealEstateRequests',
|
||||
'subscribed',
|
||||
Sequelize.BOOLEAN
|
||||
"RealEstateRequests",
|
||||
"subscribed",
|
||||
Sequelize.BOOLEAN
|
||||
);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'RealEstateRequests',
|
||||
'subscribed'
|
||||
);
|
||||
return queryInterface.removeColumn("RealEstateRequests", "subscribed");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,37 +1,70 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.addColumn('MarketAlerts', 'size', {
|
||||
type: Sequelize.INTEGER,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('MarketAlerts', 'gardenSize', {
|
||||
type: Sequelize.INTEGER,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('MarketAlerts', 'price', {
|
||||
type: Sequelize.INTEGER,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('MarketAlerts', 'municipality', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('MarketAlerts', 'region', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t })
|
||||
])
|
||||
})
|
||||
},
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction(t => {
|
||||
return Promise.all([
|
||||
queryInterface.addColumn(
|
||||
"MarketAlerts",
|
||||
"size",
|
||||
{
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"MarketAlerts",
|
||||
"gardenSize",
|
||||
{
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"MarketAlerts",
|
||||
"price",
|
||||
{
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"MarketAlerts",
|
||||
"municipality",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"MarketAlerts",
|
||||
"region",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
)
|
||||
]);
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn('MarketAlerts', 'size', { transaction: t }),
|
||||
queryInterface.removeColumn('MarketAlerts', 'gardenSize', { transaction: t }),
|
||||
queryInterface.removeColumn('MarketAlerts', 'price', { transaction: t }),
|
||||
queryInterface.removeColumn('MarketAlerts', 'municipality', { transaction: t }),
|
||||
queryInterface.removeColumn('MarketAlerts', 'region', { transaction: t })
|
||||
])
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction(t => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn("MarketAlerts", "size", { transaction: t }),
|
||||
queryInterface.removeColumn("MarketAlerts", "gardenSize", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("MarketAlerts", "price", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("MarketAlerts", "municipality", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("MarketAlerts", "region", {
|
||||
transaction: t
|
||||
})
|
||||
}
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,33 +1,59 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn('MarketAlerts', 'olxUrl', { transaction: t }),
|
||||
queryInterface.addColumn('MarketAlerts', 'url', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('MarketAlerts', 'realestateOrigin', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t }),
|
||||
queryInterface.addColumn('MarketAlerts', 'originId', {
|
||||
type: Sequelize.STRING,
|
||||
}, { transaction: t })
|
||||
])
|
||||
})
|
||||
},
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction(t => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn("MarketAlerts", "olxUrl", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.addColumn(
|
||||
"MarketAlerts",
|
||||
"url",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"MarketAlerts",
|
||||
"realestateOrigin",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
),
|
||||
queryInterface.addColumn(
|
||||
"MarketAlerts",
|
||||
"originId",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
)
|
||||
]);
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction((t) => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn('MarketAlerts', 'url', { transaction: t }),
|
||||
queryInterface.removeColumn('MarketAlerts', 'realestateOrigin', { transaction: t }),
|
||||
queryInterface.removeColumn('MarketAlerts', 'originId', { transaction: t }),
|
||||
queryInterface.addColumn('MarketAlerts', 'olxUrl', {
|
||||
type: Sequelize.STRING
|
||||
}, { transaction: t })
|
||||
])
|
||||
})
|
||||
}
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.sequelize.transaction(t => {
|
||||
return Promise.all([
|
||||
queryInterface.removeColumn("MarketAlerts", "url", { transaction: t }),
|
||||
queryInterface.removeColumn("MarketAlerts", "realestateOrigin", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.removeColumn("MarketAlerts", "originId", {
|
||||
transaction: t
|
||||
}),
|
||||
queryInterface.addColumn(
|
||||
"MarketAlerts",
|
||||
"olxUrl",
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
{ transaction: t }
|
||||
)
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'MarketAlerts',
|
||||
'realEstateType',
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
}
|
||||
);
|
||||
return queryInterface.addColumn("MarketAlerts", "realEstateType", {
|
||||
type: Sequelize.STRING
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'MarketAlerts',
|
||||
'realEstateType'
|
||||
);
|
||||
return queryInterface.removeColumn("MarketAlerts", "realEstateType");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'MarketAlerts',
|
||||
'notified',
|
||||
{
|
||||
type: Sequelize.BOOLEAN
|
||||
}
|
||||
);
|
||||
return queryInterface.addColumn("MarketAlerts", "notified", {
|
||||
type: Sequelize.BOOLEAN
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'MarketAlerts',
|
||||
'notified'
|
||||
);
|
||||
return queryInterface.removeColumn("MarketAlerts", "notified");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'MarketAlerts',
|
||||
'title',
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
}
|
||||
);
|
||||
return queryInterface.addColumn("MarketAlerts", "title", {
|
||||
type: Sequelize.STRING
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'MarketAlerts',
|
||||
'title'
|
||||
);
|
||||
return queryInterface.removeColumn("MarketAlerts", "title");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'MarketAlerts',
|
||||
'request',
|
||||
{
|
||||
type: Sequelize.STRING
|
||||
}
|
||||
);
|
||||
return queryInterface.addColumn("MarketAlerts", "request", {
|
||||
type: Sequelize.STRING
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'MarketAlerts',
|
||||
'request'
|
||||
);
|
||||
return queryInterface.removeColumn("MarketAlerts", "request");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn(
|
||||
'MarketAlerts',
|
||||
'hasLocation',
|
||||
{
|
||||
type: Sequelize.BOOLEAN
|
||||
}
|
||||
);
|
||||
return queryInterface.addColumn("MarketAlerts", "hasLocation", {
|
||||
type: Sequelize.BOOLEAN
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.removeColumn(
|
||||
'MarketAlerts',
|
||||
'hasLocation'
|
||||
);
|
||||
return queryInterface.removeColumn("MarketAlerts", "hasLocation");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,27 +1,39 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const Sequelize = require('sequelize');
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const Sequelize = require("sequelize");
|
||||
const basename = path.basename(__filename);
|
||||
const env = process.env.NODE_ENV || 'development';
|
||||
const config = require(__dirname + '/../config/config.json')[env];
|
||||
const env = process.env.NODE_ENV || "development";
|
||||
const config = require(__dirname + "/../config/config.json")[env];
|
||||
const db = {};
|
||||
|
||||
config.username = process.env.DB_USERNAME || config.username;
|
||||
config.password = process.env.DB_PASSWORD || config.password;
|
||||
config.database = process.env.DB_NAME || config.database;
|
||||
config.port = process.env.DB_PORT || config.port;
|
||||
config.logging = parseInt(process.env.SEQUELIZE_LOGGING) ? console.log : false;
|
||||
|
||||
let sequelize;
|
||||
if (config.use_env_variable) {
|
||||
sequelize = new Sequelize(process.env[config.use_env_variable], config);
|
||||
} else {
|
||||
sequelize = new Sequelize(config.database, config.username, config.password, config);
|
||||
sequelize = new Sequelize(
|
||||
config.database,
|
||||
config.username,
|
||||
config.password,
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
fs
|
||||
.readdirSync(__dirname)
|
||||
fs.readdirSync(__dirname)
|
||||
.filter(file => {
|
||||
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
|
||||
return (
|
||||
file.indexOf(".") !== 0 && file !== basename && file.slice(-3) === ".js"
|
||||
);
|
||||
})
|
||||
.forEach(file => {
|
||||
const model = sequelize['import'](path.join(__dirname, file));
|
||||
const model = sequelize["import"](path.join(__dirname, file));
|
||||
db[model.name] = model;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const MarketAlert = sequelize.define('MarketAlert', {
|
||||
url: DataTypes.STRING,
|
||||
realestateOrigin: DataTypes.STRING,
|
||||
originId: DataTypes.STRING,
|
||||
lastDate: DataTypes.STRING,
|
||||
size : DataTypes.INTEGER,
|
||||
gardenSize : DataTypes.INTEGER,
|
||||
price : DataTypes.INTEGER,
|
||||
municipality : DataTypes.STRING,
|
||||
region : DataTypes.STRING,
|
||||
realEstateType : DataTypes.STRING,
|
||||
notified : DataTypes.BOOLEAN,
|
||||
title : DataTypes.STRING,
|
||||
request: DataTypes.STRING,
|
||||
hasLocation: DataTypes.BOOLEAN,
|
||||
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
allowNul: false
|
||||
}
|
||||
}, {});
|
||||
const MarketAlert = sequelize.define(
|
||||
"MarketAlert",
|
||||
{
|
||||
url: DataTypes.STRING,
|
||||
realestateOrigin: DataTypes.STRING,
|
||||
originId: DataTypes.STRING,
|
||||
lastDate: DataTypes.STRING,
|
||||
size: DataTypes.INTEGER,
|
||||
gardenSize: DataTypes.INTEGER,
|
||||
price: DataTypes.INTEGER,
|
||||
municipality: DataTypes.STRING,
|
||||
region: DataTypes.STRING,
|
||||
realEstateType: DataTypes.STRING,
|
||||
notified: DataTypes.BOOLEAN,
|
||||
title: DataTypes.STRING,
|
||||
request: DataTypes.STRING,
|
||||
hasLocation: DataTypes.BOOLEAN,
|
||||
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
allowNul: false
|
||||
}
|
||||
},
|
||||
{}
|
||||
);
|
||||
MarketAlert.associate = function(models) {
|
||||
// associations can be defined here
|
||||
};
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
|
||||
const RealEstateRequest = sequelize.define('RealEstateRequest', {
|
||||
uniqueId: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
allowNull: false
|
||||
const RealEstateRequest = sequelize.define(
|
||||
"RealEstateRequest",
|
||||
{
|
||||
uniqueId: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
allowNull: false
|
||||
},
|
||||
realEstateType: DataTypes.STRING,
|
||||
email: DataTypes.STRING,
|
||||
region: DataTypes.STRING,
|
||||
municipality: DataTypes.STRING,
|
||||
sizeMin: DataTypes.INTEGER,
|
||||
sizeMax: DataTypes.INTEGER,
|
||||
gardenSizeMin: DataTypes.INTEGER,
|
||||
gardenSizeMax: DataTypes.INTEGER,
|
||||
priceMin: DataTypes.INTEGER,
|
||||
priceMax: DataTypes.INTEGER,
|
||||
bounding_box: DataTypes.GEOMETRY("POINT", 4326),
|
||||
subscribed: DataTypes.BOOLEAN
|
||||
},
|
||||
realEstateType: DataTypes.STRING,
|
||||
email: DataTypes.STRING,
|
||||
region: DataTypes.STRING,
|
||||
municipality: DataTypes.STRING,
|
||||
sizeMin: DataTypes.INTEGER,
|
||||
sizeMax: DataTypes.INTEGER,
|
||||
gardenSizeMin: DataTypes.INTEGER,
|
||||
gardenSizeMax: DataTypes.INTEGER,
|
||||
priceMin: DataTypes.INTEGER,
|
||||
priceMax: DataTypes.INTEGER,
|
||||
bounding_box: DataTypes.GEOMETRY('POINT', 4326),
|
||||
subscribed: DataTypes.BOOLEAN
|
||||
}, {});
|
||||
{}
|
||||
);
|
||||
RealEstateRequest.associate = function(models) {
|
||||
// associations can be defined here
|
||||
};
|
||||
|
||||
@@ -1,85 +1,77 @@
|
||||
|
||||
const Promise = require("bluebird");
|
||||
const OlxCrawler = require("../helpers/crawlers/olxClawler");
|
||||
const db = require("../models/index");
|
||||
const { allMarketAlerts } = require('../helpers/db/dbHelper');
|
||||
|
||||
const { allMarketAlerts } = require("../helpers/db/dbHelper");
|
||||
|
||||
async function crawlAll() {
|
||||
console.log("CRAWLER SERVICE: crawlAll");
|
||||
try {
|
||||
const marketAlertsFromDb = await allMarketAlerts(true);
|
||||
const hrefs = [];
|
||||
|
||||
try {
|
||||
const marketAlertsFromDb = await allMarketAlerts(true);
|
||||
const hrefs = [];
|
||||
marketAlertsFromDb.map(marketAlert => {
|
||||
if (hrefs[marketAlert.request] === undefined) {
|
||||
hrefs[marketAlert.request] = [];
|
||||
}
|
||||
|
||||
marketAlertsFromDb.map(marketAlert => {
|
||||
if (hrefs[marketAlert.request] === undefined) {
|
||||
hrefs[marketAlert.request] = []
|
||||
}
|
||||
hrefs[marketAlert.request].push(marketAlert.url);
|
||||
});
|
||||
|
||||
hrefs[marketAlert.request].push(marketAlert.url);
|
||||
})
|
||||
const olxCrawler = new OlxCrawler(hrefs);
|
||||
|
||||
console.log("CRAWLER SERVICE: GLOBAL HREFS");
|
||||
console.log(hrefs);
|
||||
const olxCrawler = new OlxCrawler(hrefs);
|
||||
const crawlers = [olxCrawler];
|
||||
|
||||
const crawlers = [
|
||||
olxCrawler,
|
||||
];
|
||||
|
||||
return Promise.map(crawlers, function (crawler) {
|
||||
return crawler.crawl();
|
||||
}).then(async (results) => {
|
||||
return Promise.map(crawlers, function(crawler) {
|
||||
return crawler.crawl();
|
||||
}).then(async results => {
|
||||
try {
|
||||
const marketAlertsFromDb = await allMarketAlerts(false, true);
|
||||
|
||||
try {
|
||||
const marketAlerts = [];
|
||||
const mergedResults = [].concat.apply([], results);
|
||||
|
||||
const marketAlertsFromDb = await allMarketAlerts(false, true);
|
||||
for (const result of mergedResults) {
|
||||
marketAlerts.push({
|
||||
url: result.url,
|
||||
realestateOrigin: "OLX",
|
||||
originId: 1,
|
||||
size: result.size,
|
||||
price: result.price,
|
||||
email: result.email,
|
||||
request: result.uuid,
|
||||
municipality: result.municipality,
|
||||
region: result.region,
|
||||
gardenSize: isNaN(result.gardenSize) ? 0 : result.gardenSize,
|
||||
realEstateType: result.realEstateType,
|
||||
title: result.title,
|
||||
notified: false,
|
||||
hasLocation: result.hasLocation
|
||||
});
|
||||
}
|
||||
|
||||
console.log("CRAWLER SERVICE: number of existing MarketAlerts from db: " + marketAlertsFromDb.length);
|
||||
try {
|
||||
const filteredMarketAlerts = marketAlerts.filter(
|
||||
elem =>
|
||||
!marketAlertsFromDb.find(({ url, request }) => {
|
||||
return elem.url === url && elem.request === request;
|
||||
})
|
||||
);
|
||||
|
||||
const marketAlerts = [];
|
||||
const mergedResults = [].concat.apply([], results);
|
||||
|
||||
for (const result of mergedResults) {
|
||||
marketAlerts.push({
|
||||
url: result.url,
|
||||
realestateOrigin: "OLX",
|
||||
originId: 1,
|
||||
size: result.size,
|
||||
price: result.price,
|
||||
email: result.email,
|
||||
request: result.uuid,
|
||||
municipality: result.municipality,
|
||||
region: result.region,
|
||||
gardenSize: isNaN(result.gardenSize) ? 0 : result.gardenSize,
|
||||
realEstateType: result.realEstateType,
|
||||
title: result.title,
|
||||
notified: false,
|
||||
hasLocation: result.hasLocation
|
||||
})
|
||||
}
|
||||
console.log("CRAWLER SERVICE: Number of crawler results: " + marketAlerts.length);
|
||||
|
||||
try {
|
||||
|
||||
const filteredMarketAlerts = marketAlerts.filter((elem) => !marketAlertsFromDb.find(({ url, request }) => {
|
||||
|
||||
return (elem.url === url && elem.request === request)
|
||||
}));
|
||||
console.log("CRAWLER SERVICE: Number of new crawler results: " + filteredMarketAlerts.length);
|
||||
|
||||
await db.MarketAlert.bulkCreate(filteredMarketAlerts);
|
||||
|
||||
} catch (e) {
|
||||
console.log("CRAWLER SERVICE: Could not bulkCreate marketalers reason: ", e);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("CRAWLER SERVICE: Error crawling. Trying next crawler! ", e);
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
console.error("CRAWLER SERVICE:could not fetch marketalerts ", e);
|
||||
}
|
||||
};
|
||||
await db.MarketAlert.bulkCreate(filteredMarketAlerts);
|
||||
} catch (e) {
|
||||
console.log(
|
||||
"CRAWLER SERVICE: Could not bulkCreate marketalers reason: ",
|
||||
e
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(
|
||||
"CRAWLER SERVICE: Error crawling. Trying next crawler! ",
|
||||
e
|
||||
);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("CRAWLER SERVICE:could not fetch marketalerts ", e);
|
||||
}
|
||||
}
|
||||
module.exports = crawlAll;
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
|
||||
const db = require("../models/index");
|
||||
const { allMarketAlerts } = require('../helpers/db/dbHelper');
|
||||
const { createMarketAlertEmailTemplate, sendBulkEmail } = require('../helpers/awsEmail');
|
||||
|
||||
const { allMarketAlerts } = require("../helpers/db/dbHelper");
|
||||
const {
|
||||
createMarketAlertEmailTemplate,
|
||||
sendBulkEmail
|
||||
} = require("../helpers/awsEmail");
|
||||
|
||||
async function processNotifications() {
|
||||
|
||||
try {
|
||||
const marketAlerts = await allMarketAlerts(false, false);
|
||||
console.log(marketAlerts.length)
|
||||
await createMarketAlertEmailTemplate();
|
||||
if (marketAlerts.length > 0) {
|
||||
console.log("NOTIFICATION SERVICE: Number of new alerts: " + marketAlerts.length)
|
||||
await sendBulkEmail(marketAlerts);
|
||||
} else {
|
||||
console.log("NOTIFICATION SERVICE: No new alerts");
|
||||
}
|
||||
|
||||
await db.MarketAlert.update(
|
||||
{ notified: true }, /* set attributes' value */
|
||||
{ where: { notified: false } } /* where criteria */
|
||||
);
|
||||
} catch (e) {
|
||||
console.log("NOTIFICATION SERVICE: could not send notifications reason: ", e);
|
||||
try {
|
||||
const marketAlerts = await allMarketAlerts(false, false);
|
||||
await createMarketAlertEmailTemplate();
|
||||
if (marketAlerts.length > 0) {
|
||||
await sendBulkEmail(marketAlerts);
|
||||
}
|
||||
|
||||
await db.MarketAlert.update(
|
||||
{ notified: true } /* set attributes' value */,
|
||||
{ where: { notified: false } } /* where criteria */
|
||||
);
|
||||
} catch (e) {
|
||||
console.log(
|
||||
"NOTIFICATION SERVICE: could not send notifications reason: ",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = processNotifications;
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
AMAZON_ACCES_KEY_ID=(your-key-here)
|
||||
AMAZON_SECRET_ACCESS_KEY=(your-key-here)
|
||||
AMAZON_REGION=eu-west-1
|
||||
APP_URL=http://localhost:3001
|
||||
SOURCE_EMAIL=info@saburly.com
|
||||
DB_USERNAME=Username for the database
|
||||
DB_PASSWORD=Password for the database
|
||||
DB_NAME=Database name
|
||||
DB_PORT=Database port
|
||||
|
||||
SEQUELIZE_LOGGING=0- no sequelize logging, 1- log to the console
|
||||
|
||||
APP_PORT=Port for the app, defaults to 5000
|
||||
APP_BASE_URL=base url for the app
|
||||
|
||||
AMAZON_ACCES_KEY_ID=(your-key-here)
|
||||
AMAZON_SECRET_ACCESS_KEY=(your-key-here)
|
||||
AMAZON_REGION=eu-west-1
|
||||
APP_URL=http://localhost:3001
|
||||
SOURCE_EMAIL=info@saburly.com
|
||||
|
||||
14
index.js
14
index.js
@@ -1,3 +1,6 @@
|
||||
require("dotenv").config();
|
||||
const { APP_PORT } = require("./app/config/appConfig");
|
||||
|
||||
const welcome = require("./app/controllers/welcome").getWelcome;
|
||||
const {
|
||||
getRealEstateTypes,
|
||||
@@ -48,8 +51,6 @@ const app = express();
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
const port = process.env.PORT || 5000;
|
||||
|
||||
app.set("views", path.join(__dirname, "/app/views"));
|
||||
app.set("view engine", "ejs");
|
||||
app.use(layout());
|
||||
@@ -180,10 +181,13 @@ app.get("/redirect/:id", redirect);
|
||||
|
||||
app.use("/assets", express.static("./app/public"));
|
||||
|
||||
app.listen(port, () => console.log(`Example app listening on port ${port}!`));
|
||||
app.listen(APP_PORT, () =>
|
||||
console.log(`Example app listening on port ${APP_PORT}!`)
|
||||
);
|
||||
|
||||
var rule = new schedule.RecurrenceRule();
|
||||
rule.seccond = 1;
|
||||
//TODO: based on node-schedule package author, setInterval is better suited for this kind of the job
|
||||
const rule = new schedule.RecurrenceRule();
|
||||
rule.second = 1;
|
||||
schedule.scheduleJob(rule, async function() {
|
||||
console.log(new Date(), "Crawler service started");
|
||||
await crawlAll();
|
||||
|
||||
@@ -1,389 +1,430 @@
|
||||
<!DOCTYPE>
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://code.jquery.com/jquery-3.4.0.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<select name="kanton" id="kanton" class="drop-select" onchange="pronadji_gradove()">
|
||||
<option value="">Iz svih lokacija</option>
|
||||
|
||||
<option value="" disabled="">Federacija BiH</option>
|
||||
<option value="9"> Sarajevo</option>
|
||||
<option value="3"> Tuzlanski</option>
|
||||
<option value="4"> Zeničko-Dobojski</option>
|
||||
<option value="1"> Unsko-Sanski</option>
|
||||
<option value="2"> Posavski</option>
|
||||
<option value="5"> Bosansko-podrinjski</option>
|
||||
<option value="6"> Srednjobosanski</option>
|
||||
<option value="7"> Hercegovačko-Neretvanski</option>
|
||||
<option value="8"> Zapadno-Hercegovački</option>
|
||||
<option value="10"> Livanjski</option>
|
||||
|
||||
<option value="" disabled="">Republika Srpska</option>
|
||||
<option value="14"> Banjalučka</option>
|
||||
<option value="15"> Dobojsko-Bijeljinska</option>
|
||||
<option value="16"> Sarajevsko-Zvornička</option>
|
||||
<option value="17"> Trebinjsko-Fočanska</option>
|
||||
|
||||
<option value="12">Disktrikt Brčko</option>
|
||||
</select>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="unskosanski" id="unskosanski" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="75">Bihać</option>
|
||||
<option value="373">Bosanska Krupa</option>
|
||||
<option value="504">Bosanski Petrovac</option>
|
||||
<option value="374">Bužim</option>
|
||||
<option value="857">Cazin</option>
|
||||
<option value="2362">Ključ</option>
|
||||
<option value="3738">Sanski Most</option>
|
||||
<option value="5122">Velika Kladuša</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="posavski" id="posavski" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="6144">Domaljevac</option>
|
||||
<option value="424">Odžak</option>
|
||||
<option value="3252">Orašje</option>
|
||||
<option value="540">Šamac</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="tuzlanski" id="tuzlanski" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="2">Banovići</option>
|
||||
<option value="1090">Doboj-Istok</option>
|
||||
<option value="1854">Gradačac</option>
|
||||
<option value="1826">Gračanica</option>
|
||||
<option value="2129">Kalesija</option>
|
||||
<option value="2319">Kladanj</option>
|
||||
<option value="2840">Lukavac</option>
|
||||
<option value="5699">Sapna</option>
|
||||
<option value="4391">Srebrenik</option>
|
||||
<option value="5010">Teočak</option>
|
||||
<option value="4944">Tuzla</option>
|
||||
<option value="2801">Čelić</option>
|
||||
<option value="5774">Živinice</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="zenickodobojski" id="zenickodobojski" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="704">Breza</option>
|
||||
<option value="1122">Doboj-Jug</option>
|
||||
<option value="2022">Kakanj</option>
|
||||
<option value="2941">Maglaj</option>
|
||||
<option value="1925">Olovo</option>
|
||||
<option value="4594">Tešanj</option>
|
||||
<option value="1087">Usora</option>
|
||||
<option value="5037">Vareš</option>
|
||||
<option value="5171">Visoko</option>
|
||||
<option value="5548">Zavidovići</option>
|
||||
<option value="4571">Zenica</option>
|
||||
<option value="2940">Žepče</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="bosanskopodrinjski" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="1289">Foča</option>
|
||||
<option value="1588">Goražde</option>
|
||||
<option value="3546">Pale</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="srednjobosanski" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="732">Bugojno</option>
|
||||
<option value="810">Busovača</option>
|
||||
<option value="4151">Dobretići</option>
|
||||
<option value="1160">Donji Vakuf</option>
|
||||
<option value="1407">Fojnica</option>
|
||||
<option value="1775">Gornji Vakuf - Uskoplje</option>
|
||||
<option value="1960">Jajce</option>
|
||||
<option value="2237">Kiseljak</option>
|
||||
<option value="2608">Kreševo</option>
|
||||
<option value="3477">Novi Travnik</option>
|
||||
<option value="4678">Travnik</option>
|
||||
<option value="5422">Vitez</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="hercegovackoneretvanski" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="3017">Grad Mostar</option>
|
||||
<option value="1930">Jablanica</option>
|
||||
<option value="2169">Konjic</option>
|
||||
<option value="3111">Neum</option>
|
||||
<option value="3421">Prozor</option>
|
||||
<option value="4769">Ravno</option>
|
||||
<option value="4439">Stolac</option>
|
||||
<option value="947">Čapljina</option>
|
||||
<option value="1009">Čitluk</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="zapadnohercegovacki" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="1892">Grude</option>
|
||||
<option value="2905">Ljubuški</option>
|
||||
<option value="3268">Posušje</option>
|
||||
<option value="2708">Široki Brijeg</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="sarajevo" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="3817">Hadžići</option>
|
||||
<option value="3879">Ilidža</option>
|
||||
<option value="3892">Ilijaš</option>
|
||||
<option value="3812">Sarajevo - Centar</option>
|
||||
<option value="3969">Sarajevo-Novi Grad</option>
|
||||
<option value="5896">Sarajevo-Novo Sarajevo</option>
|
||||
<option value="4048">Sarajevo-Stari Grad</option>
|
||||
<option value="4063">Trnovo</option>
|
||||
<option value="4126">Vogošća</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="livanjski" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="560">Bosansko Grahovo</option>
|
||||
<option value="4640">Drvar</option>
|
||||
<option value="1533">Glamoč</option>
|
||||
<option value="2635">Kupres</option>
|
||||
<option value="2741">Livno</option>
|
||||
<option value="1228">Tomislavgrad</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="grad11" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="645">distriktbrcko</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="banjalučka" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="21">Banja Luka</option>
|
||||
<option value="305">Gradiška</option>
|
||||
<option value="4662">Istočni Drvar</option>
|
||||
<option value="1965">Jezero</option>
|
||||
<option value="4147">Kneževo</option>
|
||||
<option value="6142">Kostajnica</option>
|
||||
<option value="2574">Kotor Varoš</option>
|
||||
<option value="244">Kozarska Dubica</option>
|
||||
<option value="382">Krupa na uni</option>
|
||||
<option value="2654">Kupres </option>
|
||||
<option value="2671">Laktaši</option>
|
||||
<option value="3073">Mrkonjić Grad</option>
|
||||
<option value="444">Novi Grad</option>
|
||||
<option value="3737">Oštra Luka</option>
|
||||
<option value="515">Petrovac</option>
|
||||
<option value="3287">Prijedor</option>
|
||||
<option value="3358">Prnjavor</option>
|
||||
<option value="2365">Ribnik</option>
|
||||
<option value="4271">Srbac</option>
|
||||
<option value="979">Čelinac</option>
|
||||
<option value="4509">Šipovo</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="dobojskobijeljinska" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="123">Bijeljina</option>
|
||||
<option value="421">Bosanski Brod</option>
|
||||
<option value="1030">Derventa</option>
|
||||
<option value="1088">Doboj</option>
|
||||
<option value="3254">Donji Žabar</option>
|
||||
<option value="2800">Lopare</option>
|
||||
<option value="6029">Lukavac</option>
|
||||
<option value="2996">Modriča</option>
|
||||
<option value="1856">Pelagićevo</option>
|
||||
<option value="1827">Petrovo</option>
|
||||
<option value="1148">Stanari</option>
|
||||
<option value="4549">Teslić</option>
|
||||
<option value="4636">Tešanj</option>
|
||||
<option value="4692">Travnik</option>
|
||||
<option value="4966">Tuzla</option>
|
||||
<option value="5009">Ugljevik</option>
|
||||
<option value="3197">Vukosavlje</option>
|
||||
<option value="539">Šamac</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="sarajevskozvornicka" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="595">Bratunac</option>
|
||||
<option value="1904">Han Pijesak</option>
|
||||
<option value="3947">Ilijaš</option>
|
||||
<option value="4049">Istočni Stari Grad</option>
|
||||
<option value="3880">Kasindo</option>
|
||||
<option value="2325">Kladanj</option>
|
||||
<option value="3971">Lukavica</option>
|
||||
<option value="6143">Milići</option>
|
||||
<option value="3221">Olovo</option>
|
||||
<option value="2128">Osmaci</option>
|
||||
<option value="3978">Pale</option>
|
||||
<option value="3529">Rogatica</option>
|
||||
<option value="3648">Rudo</option>
|
||||
<option value="6069">Sarajevo-Novi Grad</option>
|
||||
<option value="4183">Sokolac</option>
|
||||
<option value="4310">Srebrenica</option>
|
||||
<option value="4067">Trnovo</option>
|
||||
<option value="1593">Ustiprača</option>
|
||||
<option value="5259">Višegrad</option>
|
||||
<option value="5456">Vlasenica</option>
|
||||
<option value="5684">Zvornik</option>
|
||||
<option value="4475">Šekovići</option>
|
||||
<option value="1906">Žepa</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="height:40px;">
|
||||
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="trebinjskofocanska" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="4441">Berkovići</option>
|
||||
<option value="183">Bileća</option>
|
||||
<option value="1287">Foča</option>
|
||||
<option value="1462">Gacko</option>
|
||||
<option value="3038">Istočni Mostar</option>
|
||||
<option value="2164">Kalinovik</option>
|
||||
<option value="2884">Ljubinje</option>
|
||||
<option value="3138">Nevesinje</option>
|
||||
<option value="4766">Trebinje</option>
|
||||
<option value="911">Čajniče</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
const stavi_grad = () => {};
|
||||
const gradovi = [
|
||||
{"ime":" Sarajevo","id":"sarajevo"},
|
||||
{"ime":" Unsko-sanski","id":"unskosanski"},
|
||||
{"ime":" Posavski","id":"posavski"},
|
||||
{"ime":" Tuzlanski","id":"tuzlanski"},
|
||||
{"ime":" Zeničko-dobojski","id":"zenickodobojski"},
|
||||
{"ime":" Bosansko-podrinjski","id":"bosanskopodrinjski"},
|
||||
{"ime":" Srednjobosanski","id":"srednjobosanski"},
|
||||
{"ime":" Hercegovačko-neretvanski","id":"hercegovackoneretvanski"},
|
||||
{"ime":" Zapadno-hercegovački","id":"zapadnohercegovacki"},
|
||||
{"ime":" Livanjski","id":"livanjski"},
|
||||
{"ime":" Banjalučka","id":"banjalučka"},
|
||||
{"ime":" Dobojsko-Bijeljinska","id":"dobojskobijeljinska"},
|
||||
{"ime":" Sarajevsko-Zvornička","id":"sarajevskozvornicka"},
|
||||
{"ime":" Trebinjsko-Fočanska","id":"trebinjskofocanska"},
|
||||
{"ime":"Distrikt Brčko","id":"distriktbrcko"},
|
||||
];
|
||||
|
||||
for (let grad of gradovi) {
|
||||
const mjesta = [];
|
||||
$('#' + grad.id).children().each( function() {
|
||||
const mjesto = $(this).text();
|
||||
mjesta.push( {
|
||||
ime: mjesto,
|
||||
id: mjesto.toLowerCase().replace(/[^a-z]/g,''),
|
||||
olxid: $(this).val()
|
||||
});
|
||||
});
|
||||
grad.mjesta = mjesta;
|
||||
}
|
||||
|
||||
console.log(JSON.stringify(gradovi));
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<!DOCTYPE >
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://code.jquery.com/jquery-3.4.0.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<select
|
||||
name="kanton"
|
||||
id="kanton"
|
||||
class="drop-select"
|
||||
onchange="pronadji_gradove()"
|
||||
>
|
||||
<option value="">Iz svih lokacija</option>
|
||||
|
||||
<option value="" disabled="">Federacija BiH</option>
|
||||
<option value="9"> Sarajevo</option>
|
||||
<option value="3"> Tuzlanski</option>
|
||||
<option value="4"> Zeničko-Dobojski</option>
|
||||
<option value="1"> Unsko-Sanski</option>
|
||||
<option value="2"> Posavski</option>
|
||||
<option value="5"> Bosansko-podrinjski</option>
|
||||
<option value="6"> Srednjobosanski</option>
|
||||
<option value="7"> Hercegovačko-Neretvanski</option>
|
||||
<option value="8"> Zapadno-Hercegovački</option>
|
||||
<option value="10"> Livanjski</option>
|
||||
|
||||
<option value="" disabled="">Republika Srpska</option>
|
||||
<option value="14"> Banjalučka</option>
|
||||
<option value="15"> Dobojsko-Bijeljinska</option>
|
||||
<option value="16"> Sarajevsko-Zvornička</option>
|
||||
<option value="17"> Trebinjsko-Fočanska</option>
|
||||
|
||||
<option value="12">Disktrikt Brčko</option>
|
||||
</select>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name="unskosanski"
|
||||
id="unskosanski"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="75">Bihać</option>
|
||||
<option value="373">Bosanska Krupa</option>
|
||||
<option value="504">Bosanski Petrovac</option>
|
||||
<option value="374">Bužim</option>
|
||||
<option value="857">Cazin</option>
|
||||
<option value="2362">Ključ</option>
|
||||
<option value="3738">Sanski Most</option>
|
||||
<option value="5122">Velika Kladuša</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name="posavski"
|
||||
id="posavski"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="6144">Domaljevac</option>
|
||||
<option value="424">Odžak</option>
|
||||
<option value="3252">Orašje</option>
|
||||
<option value="540">Šamac</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name="tuzlanski"
|
||||
id="tuzlanski"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="2">Banovići</option>
|
||||
<option value="1090">Doboj-Istok</option>
|
||||
<option value="1854">Gradačac</option>
|
||||
<option value="1826">Gračanica</option>
|
||||
<option value="2129">Kalesija</option>
|
||||
<option value="2319">Kladanj</option>
|
||||
<option value="2840">Lukavac</option>
|
||||
<option value="5699">Sapna</option>
|
||||
<option value="4391">Srebrenik</option>
|
||||
<option value="5010">Teočak</option>
|
||||
<option value="4944">Tuzla</option>
|
||||
<option value="2801">Čelić</option>
|
||||
<option value="5774">Živinice</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name="zenickodobojski"
|
||||
id="zenickodobojski"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="704">Breza</option>
|
||||
<option value="1122">Doboj-Jug</option>
|
||||
<option value="2022">Kakanj</option>
|
||||
<option value="2941">Maglaj</option>
|
||||
<option value="1925">Olovo</option>
|
||||
<option value="4594">Tešanj</option>
|
||||
<option value="1087">Usora</option>
|
||||
<option value="5037">Vareš</option>
|
||||
<option value="5171">Visoko</option>
|
||||
<option value="5548">Zavidovići</option>
|
||||
<option value="4571">Zenica</option>
|
||||
<option value="2940">Žepče</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name=""
|
||||
id="bosanskopodrinjski"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="1289">Foča</option>
|
||||
<option value="1588">Goražde</option>
|
||||
<option value="3546">Pale</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name=""
|
||||
id="srednjobosanski"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="732">Bugojno</option>
|
||||
<option value="810">Busovača</option>
|
||||
<option value="4151">Dobretići</option>
|
||||
<option value="1160">Donji Vakuf</option>
|
||||
<option value="1407">Fojnica</option>
|
||||
<option value="1775">Gornji Vakuf - Uskoplje</option>
|
||||
<option value="1960">Jajce</option>
|
||||
<option value="2237">Kiseljak</option>
|
||||
<option value="2608">Kreševo</option>
|
||||
<option value="3477">Novi Travnik</option>
|
||||
<option value="4678">Travnik</option>
|
||||
<option value="5422">Vitez</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name=""
|
||||
id="hercegovackoneretvanski"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="3017">Grad Mostar</option>
|
||||
<option value="1930">Jablanica</option>
|
||||
<option value="2169">Konjic</option>
|
||||
<option value="3111">Neum</option>
|
||||
<option value="3421">Prozor</option>
|
||||
<option value="4769">Ravno</option>
|
||||
<option value="4439">Stolac</option>
|
||||
<option value="947">Čapljina</option>
|
||||
<option value="1009">Čitluk</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name=""
|
||||
id="zapadnohercegovacki"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="1892">Grude</option>
|
||||
<option value="2905">Ljubuški</option>
|
||||
<option value="3268">Posušje</option>
|
||||
<option value="2708">Široki Brijeg</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name=""
|
||||
id="sarajevo"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="3817">Hadžići</option>
|
||||
<option value="3879">Ilidža</option>
|
||||
<option value="3892">Ilijaš</option>
|
||||
<option value="3812">Sarajevo - Centar</option>
|
||||
<option value="3969">Sarajevo-Novi Grad</option>
|
||||
<option value="5896">Sarajevo-Novo Sarajevo</option>
|
||||
<option value="4048">Sarajevo-Stari Grad</option>
|
||||
<option value="4063">Trnovo</option>
|
||||
<option value="4126">Vogošća</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name=""
|
||||
id="livanjski"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="560">Bosansko Grahovo</option>
|
||||
<option value="4640">Drvar</option>
|
||||
<option value="1533">Glamoč</option>
|
||||
<option value="2635">Kupres</option>
|
||||
<option value="2741">Livno</option>
|
||||
<option value="1228">Tomislavgrad</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select name="" id="grad11" class="drop-select" onchange="stavi_grad()">
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="645">distriktbrcko</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name=""
|
||||
id="banjalučka"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="21">Banja Luka</option>
|
||||
<option value="305">Gradiška</option>
|
||||
<option value="4662">Istočni Drvar</option>
|
||||
<option value="1965">Jezero</option>
|
||||
<option value="4147">Kneževo</option>
|
||||
<option value="6142">Kostajnica</option>
|
||||
<option value="2574">Kotor Varoš</option>
|
||||
<option value="244">Kozarska Dubica</option>
|
||||
<option value="382">Krupa na uni</option>
|
||||
<option value="2654">Kupres </option>
|
||||
<option value="2671">Laktaši</option>
|
||||
<option value="3073">Mrkonjić Grad</option>
|
||||
<option value="444">Novi Grad</option>
|
||||
<option value="3737">Oštra Luka</option>
|
||||
<option value="515">Petrovac</option>
|
||||
<option value="3287">Prijedor</option>
|
||||
<option value="3358">Prnjavor</option>
|
||||
<option value="2365">Ribnik</option>
|
||||
<option value="4271">Srbac</option>
|
||||
<option value="979">Čelinac</option>
|
||||
<option value="4509">Šipovo</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name=""
|
||||
id="dobojskobijeljinska"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="123">Bijeljina</option>
|
||||
<option value="421">Bosanski Brod</option>
|
||||
<option value="1030">Derventa</option>
|
||||
<option value="1088">Doboj</option>
|
||||
<option value="3254">Donji Žabar</option>
|
||||
<option value="2800">Lopare</option>
|
||||
<option value="6029">Lukavac</option>
|
||||
<option value="2996">Modriča</option>
|
||||
<option value="1856">Pelagićevo</option>
|
||||
<option value="1827">Petrovo</option>
|
||||
<option value="1148">Stanari</option>
|
||||
<option value="4549">Teslić</option>
|
||||
<option value="4636">Tešanj</option>
|
||||
<option value="4692">Travnik</option>
|
||||
<option value="4966">Tuzla</option>
|
||||
<option value="5009">Ugljevik</option>
|
||||
<option value="3197">Vukosavlje</option>
|
||||
<option value="539">Šamac</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name=""
|
||||
id="sarajevskozvornicka"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="595">Bratunac</option>
|
||||
<option value="1904">Han Pijesak</option>
|
||||
<option value="3947">Ilijaš</option>
|
||||
<option value="4049">Istočni Stari Grad</option>
|
||||
<option value="3880">Kasindo</option>
|
||||
<option value="2325">Kladanj</option>
|
||||
<option value="3971">Lukavica</option>
|
||||
<option value="6143">Milići</option>
|
||||
<option value="3221">Olovo</option>
|
||||
<option value="2128">Osmaci</option>
|
||||
<option value="3978">Pale</option>
|
||||
<option value="3529">Rogatica</option>
|
||||
<option value="3648">Rudo</option>
|
||||
<option value="6069">Sarajevo-Novi Grad</option>
|
||||
<option value="4183">Sokolac</option>
|
||||
<option value="4310">Srebrenica</option>
|
||||
<option value="4067">Trnovo</option>
|
||||
<option value="1593">Ustiprača</option>
|
||||
<option value="5259">Višegrad</option>
|
||||
<option value="5456">Vlasenica</option>
|
||||
<option value="5684">Zvornik</option>
|
||||
<option value="4475">Šekovići</option>
|
||||
<option value="1906">Žepa</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="height:40px;">
|
||||
<span class="drop-container" style="width: 168px;">
|
||||
<span class="drop-label">Mjesto</span><span class="drop-arrow"></span>
|
||||
<select
|
||||
name=""
|
||||
id="trebinjskofocanska"
|
||||
class="drop-select"
|
||||
onchange="stavi_grad()"
|
||||
>
|
||||
<option value="0">Mjesto</option>
|
||||
<option value="4441">Berkovići</option>
|
||||
<option value="183">Bileća</option>
|
||||
<option value="1287">Foča</option>
|
||||
<option value="1462">Gacko</option>
|
||||
<option value="3038">Istočni Mostar</option>
|
||||
<option value="2164">Kalinovik</option>
|
||||
<option value="2884">Ljubinje</option>
|
||||
<option value="3138">Nevesinje</option>
|
||||
<option value="4766">Trebinje</option>
|
||||
<option value="911">Čajniče</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const stavi_grad = () => {};
|
||||
const gradovi = [
|
||||
{ ime: " Sarajevo", id: "sarajevo" },
|
||||
{ ime: " Unsko-sanski", id: "unskosanski" },
|
||||
{ ime: " Posavski", id: "posavski" },
|
||||
{ ime: " Tuzlanski", id: "tuzlanski" },
|
||||
{ ime: " Zeničko-dobojski", id: "zenickodobojski" },
|
||||
{ ime: " Bosansko-podrinjski", id: "bosanskopodrinjski" },
|
||||
{ ime: " Srednjobosanski", id: "srednjobosanski" },
|
||||
{ ime: " Hercegovačko-neretvanski", id: "hercegovackoneretvanski" },
|
||||
{ ime: " Zapadno-hercegovački", id: "zapadnohercegovacki" },
|
||||
{ ime: " Livanjski", id: "livanjski" },
|
||||
{ ime: " Banjalučka", id: "banjalučka" },
|
||||
{ ime: " Dobojsko-Bijeljinska", id: "dobojskobijeljinska" },
|
||||
{ ime: " Sarajevsko-Zvornička", id: "sarajevskozvornicka" },
|
||||
{ ime: " Trebinjsko-Fočanska", id: "trebinjskofocanska" },
|
||||
{ ime: "Distrikt Brčko", id: "distriktbrcko" }
|
||||
];
|
||||
|
||||
for (let grad of gradovi) {
|
||||
const mjesta = [];
|
||||
$("#" + grad.id)
|
||||
.children()
|
||||
.each(function() {
|
||||
const mjesto = $(this).text();
|
||||
mjesta.push({
|
||||
ime: mjesto,
|
||||
id: mjesto.toLowerCase().replace(/[^a-z]/g, ""),
|
||||
olxid: $(this).val()
|
||||
});
|
||||
});
|
||||
grad.mjesta = mjesta;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user