Compare commits

...

17 Commits

Author SHA1 Message Date
Naida Vatric
11848cc0bb Added real estate ad edit ability 2020-03-25 16:33:21 +01:00
Naida Vatric
3fa9804ca6 Dropzone edit opction adadded. 2020-03-24 11:10:16 +01:00
Naida Vatric
477424caa1 Removing existing photos wip. 2020-03-23 12:26:08 +01:00
Naida Vatric
60f74c2cde Changed editing redirection. 2020-03-20 15:40:38 +01:00
Naida Vatric
55cb01c3c2 Started edit ad option. 2020-03-19 15:24:58 +01:00
Naida Vatric
f2d9369d5c Added delete ability. 2020-03-19 11:36:23 +01:00
Naida Vatric
ab50eb05af Started deleting of ads. 2020-03-18 21:29:11 +01:00
Naida Vatric
084766d0ea Added notification for new ad pusblish and new real estate. 2020-03-16 16:13:16 +01:00
Naida Vatric
981faeb610 For review view ad page. 2020-03-14 15:34:18 +01:00
Naida Vatric
a36fba09eb Merged finished kivi-input in view 2020-03-14 14:09:36 +01:00
Naida Vatric
6821f61e55 Flexslider fixed. 2020-03-03 22:03:41 +01:00
Naida Vatric
54d9822fc8 Flexslider vs Materilize debugg. 2020-03-03 17:02:20 +01:00
Naida Vatric
b80577ef6b WiP Ad preview page - flexslider problem. 2020-02-24 23:15:48 +01:00
Naida Vatric
d36d7f413d Initialized flex slider 2020-02-24 15:41:28 +01:00
Naida Vatric
9c63bdfbe2 Started photo gallery. 2020-02-23 23:05:28 +01:00
Naida Vatric
2218e6888a Added map to kivi ad preview. 2020-02-23 01:52:43 +01:00
Naida Vatric
16d004c1ab WiP Started kivi original ad view. 2020-02-14 13:38:31 +01:00
50 changed files with 10167 additions and 265 deletions

View File

@@ -34,7 +34,7 @@ const MAX_REAL_ESTATES_IN_FIRST_EMAIL =
const PRINT_CRAWLER_DEBUG = process.env.PRINT_CRAWLER_DEBUG_INFO || 0;
const API_MAP_KEY = process.env.API_MAP_KEY || "";
const GOOGLE_MAP_KEY = process.env.GOOGLE_MAP_KEY || "";
const PROSTOR_LOGIN = {
EMAIL: process.env.PROSTOR_LOGIN_EMAIL,
@@ -51,9 +51,8 @@ module.exports = {
MAX_REAL_ESTATES_IN_EMAIL,
MAX_REAL_ESTATES_IN_FIRST_EMAIL,
PRINT_CRAWLER_DEBUG,
API_MAP_KEY,
GOOGLE_MAP_KEY,
STAGING,
CHECK_UP_DAYS,
PROSTOR_LOGIN
};

View File

@@ -0,0 +1,34 @@
const { currentKiviRealEstate } = require("../helpers/url");
const { findRealEstateByAgencyId } = require("../helpers/db/realEstate");
const getDeletePublishedAd = async (req, res) => {
const title = "Uspješno ste izbrisali svoj oglas iz baze.";
const kiviOriginal = await currentKiviRealEstate(req);
if (!kiviOriginal || !kiviOriginal.kiviAdId) {
res.render("notFound", { title: " " });
return;
}
const realEstate = await findRealEstateByAgencyId(kiviOriginal.kiviAdId);
if (!realEstate || !realEstate.dataValues) {
res.render("notFound", { title: " " });
return;
}
realEstate.deleted = true;
realEstate.deletedAt = Date.now();
kiviOriginal.email = "";
await realEstate.save();
await kiviOriginal.save();
res.render("deleteRealEstate", { nextStep: "/", title });
};
module.exports = {
getDeletePublishedAd
};

View File

@@ -0,0 +1,8 @@
const editSuccess = async (req, res) => {
const title = "Uspjeh!";
res.render("editSuccess", { title });
};
module.exports = {
editSuccess
};

View File

@@ -1,7 +1,14 @@
const { findRealEstateByAgencyId } = require("../helpers/db/realEstate");
const { bulkUpsertKiviPhotos } = require("../helpers/db/kiviOriginalAdsPhotos");
const {
bulkUpsertKiviPhotos,
findPhotosForKiviAd,
deleteUrlPhotosAfterUpdate
} = require("../helpers/db/kiviOriginalAdsPhotos");
const { currentKiviRealEstate } = require("../helpers/url");
const {
notifyForNewRealEstates,
notifyForNewAdPublish
} = require("../services/notificationService");
const validate = require("validate.js");
const {
@@ -10,6 +17,8 @@ const {
ACCESS_ROAD_TYPE,
HEATING_TYPE
} = require("../common/enums");
const { APP_URL } = require("../config/appConfig");
const {
BASIC_BOOLEAN_PUBLISH,
BASIC_SEGMENT_PUBLISH,
@@ -22,7 +31,9 @@ const {
const getPublishInputs = async (req, res) => {
const kiviOriginal = await currentKiviRealEstate(req);
const realEstate = await findRealEstateByAgencyId(kiviOriginal.kiviAdId);
const realEstate = await findRealEstateByAgencyId(
kiviOriginal.dataValues.kiviAdId
);
if (!realEstate || !realEstate.dataValues) {
res.render("notFound", { title: " " });
@@ -77,6 +88,29 @@ const getPublishInputs = async (req, res) => {
title,
longDescription
} = realEstate;
const email = kiviOriginal.dataValues.email;
//If email is not empty - has string value, then proces of publishing has been conducted alredy
//That means user is editing existing real estate ad not publishing new one
let editingRealEstate = false;
if (email) {
editingRealEstate = true;
}
//If we are editing real estate ad we need to fetch and show images on server
const urlGooglePrefix =
"https://storage.cloud.google.com/marketalarm-photos/";
let realEstatePhotosUrls = [];
if (editingRealEstate) {
const realEstatePhotosData = await findPhotosForKiviAd(
kiviOriginal.dataValues.kiviAdId
);
realEstatePhotosData.map(row => {
realEstatePhotosUrls.push(urlGooglePrefix + row.dataValues.photoUrl);
});
} else {
realEstatePhotosUrls.push(false);
}
const category = AD_CATEGORY[realEstateType] || AD_CATEGORY.FLAT;
// TODO: Maybe this is slow, pay attention to this
@@ -167,13 +201,22 @@ const getPublishInputs = async (req, res) => {
basicInputValues,
additionalInputInputs,
additionalInputValues,
validate: validate
validate: validate,
email,
locationLat: locationLat || 0,
locationLong: locationLong || 0,
editingRealEstate,
realEstatePhotosUrls
});
};
const postPublishInputs = async (req, res) => {
const kiviOriginal = await currentKiviRealEstate(req);
if (!kiviOriginal || !kiviOriginal.kiviAdId) {
res.render("notFound", { title: " " });
return;
}
const realEstate = await findRealEstateByAgencyId(kiviOriginal.kiviAdId);
if (!realEstate || !realEstate.dataValues) {
@@ -181,8 +224,13 @@ const postPublishInputs = async (req, res) => {
return;
}
const nextStepPage = req.query.nextStep || "/uspjesnaobjava";
const editingRealEstate = req.body.editingRealEstate === "true";
// console.log("Editing real estate:", editingRealEstate);
const nextStepPage = editingRealEstate
? req.query.nextStep || "/uspjesnaizmjena"
: req.query.nextStep || "/uspjesnaobjava";
//Request body
//console.log("Body:", req.body);
@@ -249,6 +297,11 @@ const postPublishInputs = async (req, res) => {
//Image urls are stored in new table
const imageUrls =
req.body.imageUrls.split("|").filter(url => url !== "") || [];
//If we are in editing mode we need to "delete" photos that are not longer associated with real estate ad
if (editingRealEstate) {
await deleteUrlPhotosAfterUpdate(imageUrls);
}
const imageUrlsData = imageUrls.map(url => {
return {
kiviAdId: kiviOriginal.kiviAdId,
@@ -306,10 +359,23 @@ const postPublishInputs = async (req, res) => {
kiviOriginal.email = contactEmail;
//console.log("realEstate", realEstate);
await realEstate.save();
await kiviOriginal.save();
//Calling function to notify real estate owner that ads is published or edited on Kivi page after 1 sec
setTimeout(
notifyForNewAdPublish,
1000,
realEstate,
kiviOriginal,
editingRealEstate
);
//Calling function to notify users of new real estate (or edited realestate) after 2 min
setTimeout(notifyForNewRealEstates, 1000 * 60 * 2, [realEstate]);
res.redirect(nextStepPage);
};

View File

@@ -6,6 +6,7 @@ const {
const { createKiviOriginal } = require("../helpers/db/kiviOriginal");
const { AD_CATEGORY, AD_TYPE, AD_AGENCY } = require("../common/enums");
const { APP_URL } = require("../config/appConfig");
const getPublishTypes = async (req, res) => {
const kiviOriginal = await currentKiviRealEstate(req);
@@ -70,6 +71,8 @@ const postPublishTypes = async (req, res) => {
realEstate.adType = adTypeStringId;
realEstate.realEstateType = selectedRealEstateType;
//Url override
realEstate.url = `${APP_URL}/preglednekretnine/${realEstate.id}`;
await realEstate.save();
} else {
@@ -77,11 +80,12 @@ const postPublishTypes = async (req, res) => {
const newKiviOriginal = await createKiviOriginal({
email: ""
});
const newKiviAdViewUrl = `${APP_URL}/preglednekretnine/${realEstate.id}`;
const newRealEstate = await createRealEstate({
adType: adTypeStringId,
realEstateType: selectedRealEstateType,
url: "http://localhost:5000/",
url: newKiviAdViewUrl,
originAgencyName: AD_AGENCY.KIVI,
agencyObjectId: newKiviOriginal.kiviAdId
});

View File

@@ -0,0 +1,202 @@
const { findRealEstateByAgencyId } = require("../helpers/db/realEstate");
const { findPhotosForKiviAd } = require("../helpers/db/kiviOriginalAdsPhotos");
const { currentKiviRealEstate, currentRealEstate } = require("../helpers/url");
const {
BASIC_BOOLEAN_PUBLISH,
BASIC_SEGMENT_PUBLISH,
ADDITIONAL_BOOLEAN_PUBLISH,
ADDITIONAL_SEGMENT_PUBLISH,
BASIC_INPUT_PUBLISH,
ADDITIONAL_INPUT_PUBLISH
} = require("../common/publishEnums");
const { AD_CATEGORY, AD_TYPE } = require("../common/enums");
const getViewRealEstate = async (req, res) => {
//Variation if we acces to real estate previews via kiviAdId
/*
const kiviOriginal = await currentKiviRealEstate(req);
if (!kiviOriginal || !kiviOriginal.kiviAdId) {
res.render("notFound", { title: " " });
return;
}
const realEstate = await findRealEstateByAgencyId(kiviOriginal.kiviAdId); */
const realEstate = await currentRealEstate(req);
if (!realEstate || !realEstate.dataValues) {
res.render("notFound", { title: " " });
return;
}
const pageTitle = "Pregled nekretnine";
const {
price,
area,
adType,
agencyObjectId,
realEstateType,
locationLat,
locationLong,
accessRoadType,
heatingType,
balcony,
newBuilding,
elevator,
recentlyAdapted,
gardenSize,
numberOfRooms,
numberOfFloors,
floor,
water,
electricity,
drainageSystem,
registeredInZkBooks,
parking,
garage,
gas,
antiTheftDoor,
airCondition,
phoneConnection,
cableTV,
internet,
basementAttic,
storeRoom,
videoSurveillance,
alarm,
suitableForStudents,
includingBills,
animalsAllowed,
pool,
exchange,
urbanPlanPermit,
buildingPermit,
furnishingType,
shortDescription,
streetName,
title,
longDescription
} = realEstate;
//Categorize all database values by value type - input, boolean or segment selected
const allInputValues = {
price,
area,
gardenSize,
numberOfRooms,
numberOfFloors,
floor,
title,
shortDescription,
streetName,
longDescription
};
const allBooleanValues = {
balcony,
elevator,
newBuilding,
recentlyAdapted,
water,
electricity,
drainageSystem,
registeredInZkBooks,
parking,
garage,
gas,
antiTheftDoor,
airCondition,
phoneConnection,
cableTV,
internet,
basementAttic,
storeRoom,
videoSurveillance,
alarm,
suitableForStudents,
includingBills,
animalsAllowed,
pool,
exchange,
urbanPlanPermit,
buildingPermit
};
const allSegmentSelectedValues = {
furnishingType,
accessRoadType,
heatingType
};
//We need titles of fields ex Balkon, Novogradnja
const ALL_BOOLEAN_FIELDS = [
...BASIC_BOOLEAN_PUBLISH,
...ADDITIONAL_BOOLEAN_PUBLISH
];
const ALL_INPUT_FIELDS = [
...BASIC_INPUT_PUBLISH,
...ADDITIONAL_INPUT_PUBLISH
];
const ALL_SEGMENT_FIELDS = [
...BASIC_SEGMENT_PUBLISH,
...ADDITIONAL_SEGMENT_PUBLISH
];
//On view add page we will show only values that are not - null, or "", or undefined
const forShowing = value => {
return value !== false && value !== null && value !== "";
};
//Filter all values to be shown on page or not
//For showing on page we also need title ex. "Balkon"
const booleanFields = ALL_BOOLEAN_FIELDS.filter(object => {
return forShowing(allBooleanValues[object.dbField]);
});
const inputFields = ALL_INPUT_FIELDS.filter(object => {
return forShowing(allInputValues[object.dbField]);
});
const segmentFields = ALL_SEGMENT_FIELDS.filter(object => {
return forShowing(allSegmentSelectedValues[object.dbField]);
});
//Photo urls from Google storage bucket
const kiviAdId = agencyObjectId;
const urlGooglePrefix =
"https://storage.cloud.google.com/marketalarm-photos/";
const realEstatePhotosData = await findPhotosForKiviAd(kiviAdId);
const realEstatePhotosUrls = realEstatePhotosData.map(row => {
return urlGooglePrefix + row.dataValues.photoUrl;
});
const showRealEstateType = AD_CATEGORY[realEstateType].title.toUpperCase();
let showAdType = "";
switch (adType) {
case AD_TYPE.AD_TYPE_SALE.stringId:
showAdType = AD_TYPE.AD_TYPE_SALE.title.toUpperCase();
break;
case AD_TYPE.AD_TYPE_RENT.stringId:
showAdType = AD_TYPE.AD_TYPE_RENT.title.toUpperCase();
break;
default:
showAdType = "-";
break;
}
res.render("viewRealEstate", {
title: pageTitle,
booleanFields,
inputFields,
allInputValues,
segmentFields,
allSegmentSelectedValues,
locationLat,
locationLong,
showAdType,
showRealEstateType,
realEstatePhotosUrls
});
};
module.exports = {
getViewRealEstate
};

View File

@@ -2,6 +2,7 @@ const { createSearchRequest } = require("../helpers/db/searchRequest");
const { createRealEstate } = require("../helpers/db/realEstate");
const { createKiviOriginal } = require("../helpers/db/kiviOriginal");
const { AD_TYPE, AD_CATEGORY, AD_AGENCY } = require("../common/enums");
const { APP_URL } = require("../config/appConfig");
const getWelcome = (req, res) => {
res.render("welcome", {
@@ -38,12 +39,13 @@ const postWelcome = async (req, res) => {
const newKiviOriginal = await createKiviOriginal({
email: ""
});
//Temporary url because we have cyclic id call - need to override for safety measures
const newKiviAdViewUrl = `${APP_URL}/preglednekretnine/${newKiviOriginal.kiviAdId}`;
const newRealEstate = await createRealEstate({
adType: adTypeStringId,
realEstateType: AD_CATEGORY.FLAT.id,
//Temp variable because of the not null constraints
url: "http://localhost:5000/",
url: newKiviAdViewUrl,
originAgencyName: AD_AGENCY.KIVI,
agencyObjectId: newKiviOriginal.kiviAdId
});

View File

@@ -1,6 +1,8 @@
"use strict";
const db = require("../../models/index");
const sequelize = require("sequelize");
const Op = sequelize.Op;
const bulkUpsertKiviPhotos = async kiviPhotosData => {
try {
@@ -12,6 +14,38 @@ const bulkUpsertKiviPhotos = async kiviPhotosData => {
}
};
module.exports = {
bulkUpsertKiviPhotos
const findPhotosForKiviAd = async id => {
try {
return db.KiviOriginalAdsPhotos.findAll({
where: {
kiviAdId: id
}
});
} catch (error) {
console.log("kiviOriginalAdsPhotos.js", error);
return null;
}
};
const deleteUrlPhotosAfterUpdate = async photoUrlsToKeep => {
//We delete all urls that are not in "newly changed - edited" photo urls array
const deleteQuery = {
photoUrl: {
[Op.notIn]: photoUrlsToKeep
}
};
try {
return db.KiviOriginalAdsPhotos.destroy({
where: deleteQuery
});
} catch (error) {
console.log("kiviOriginalAdsPhotos.js", error);
return null;
}
};
module.exports = {
bulkUpsertKiviPhotos,
findPhotosForKiviAd,
deleteUrlPhotosAfterUpdate
};

View File

@@ -350,6 +350,13 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
}
};
}
//Query only for real estated that are not deleted
query.deleted = {
[Op.eq]: false
};
queryIncludeIncomplete.deleted = {
[Op.eq]: false
};
const order = [["updatedAt", "desc"]];

View File

@@ -202,9 +202,52 @@ const generateCheckUpEmail = searchRequest => {
${emailFooter}`;
};
const generateNewAdPublishEmail = (
realEstate,
kiviOriginal,
editingRealEstate,
numberOfMatchingRequests
) => {
let countingPrefix;
if (
numberOfMatchingRequests === 2 ||
numberOfMatchingRequests === 3 ||
numberOfMatchingRequests === 4
) {
countingPrefix = "postoje";
} else {
countingPrefix = "postoji";
}
let countingSufix;
if (numberOfMatchingRequests % 10 === 1 && numberOfMatchingRequests !== 11) {
countingSufix = "zahtjev";
} else {
countingSufix = "zahtjeva";
}
const successIntro = editingRealEstate
? `<div>Uspješno ste izmijenili oglas za Vašu nekretninu na <strong>Kivi.ba.</strong><div>`
: `<div>Uspješno ste objavili oglas za Vašu nekretninu na <strong>Kivi.ba.</strong><div>`;
return `<h3>${stagingTag}Zdravo</h3>
${successIntro}
<br/>
<div>U Kivi bazi trenutno ${countingPrefix} ${numberOfMatchingRequests} ${countingSufix} za nekretninom kao sto je Vaša.</div>
<br />
<div>Pregledajte Vaš oglas na sljedećem linku: <a href="${realEstate.url}" rel="noreferrer">${realEstate.title}</a><div>
<br/>
<div>Ako želite izmijeniti detalje oglasa, <a href="${APP_URL}/podacionekretnini/${kiviOriginal.kiviAdId}">izmjenite ovdje.</a></div>
<div>Ako želite izbrisati Vaš oglas iz Kivi baze, <a href="${APP_URL}/obrisioglas/${kiviOriginal.kiviAdId}">izbrišite ovdje.</a></div>
<br/>
<div>Hvala na ukazanom povjerenju!</div>
<br/>
<strong>Vaš,<br/>Kivi tim</strong>`;
};
module.exports = {
generateNotificationEmail,
generateNewSearchRequestEmail,
generateEmailSubject,
generateCheckUpEmail
generateCheckUpEmail,
generateNewAdPublishEmail
};

View File

@@ -1,6 +1,7 @@
const { getSearchRequest } = require("./db/searchRequest");
const { getRealEstateById } = require("./db/realEstate");
const { getKiviOriginalById } = require("./db/kiviOriginal");
const validator = require("validator");
const currentSearchRequest = async req => {
const searchRequestId =
@@ -19,7 +20,7 @@ const currentRealEstate = async req => {
const currentKiviRealEstate = async req => {
const kiviRealEstateId =
req && req.params ? req.params["kiviRealEstateId"] : null;
if (!kiviRealEstateId) return null;
if (!kiviRealEstateId || !validator.isUUID(kiviRealEstateId)) return null;
return await getKiviOriginalById(kiviRealEstateId);
};

View File

@@ -0,0 +1,22 @@
"use strict";
module.exports = {
up: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.addColumn("RealEstates", "deleted", {
type: Sequelize.BOOLEAN,
defaultValue: false
}),
queryInterface.addColumn("RealEstates", "deletedAt", {
type: Sequelize.DATE
})
]);
},
down: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.removeColumn("RealEstates", "deleted"),
queryInterface.removeColumn("RealEstates", "deletedAt")
]);
}
};

View File

@@ -0,0 +1,18 @@
"use strict";
module.exports = {
up: (queryInterface, Sequelize) =>
queryInterface.addConstraint(
"KiviOriginalAdsPhotos",
["kiviAdId", "photoUrl"],
{
type: "unique",
name: "uniqueKiviAdIdPhoto"
}
),
down: queryInterface =>
queryInterface.removeConstraint(
"KiviOriginalAdsPhotos",
"uniqueKiviAdIdPhoto"
)
};

View File

@@ -13,6 +13,7 @@ module.exports = (sequalize, DataTypes) => {
kiviAdId: {
type: DataTypes.UUID,
allowNull: false,
unique: "uniqueKiviAdIdPhoto",
references: {
model: "KiviOriginal",
key: "kiviAdId"
@@ -20,7 +21,8 @@ module.exports = (sequalize, DataTypes) => {
},
photoUrl: {
type: DataTypes.TEXT,
allowNull: false
allowNull: false,
unique: "uniqueKiviAdIdPhoto"
}
},
{

View File

@@ -85,7 +85,9 @@ module.exports = (sequelize, DataTypes) => {
utilityConnection: DataTypes.BOOLEAN,
distanceToRiver: DataTypes.INTEGER,
numberOfViewsAgency: DataTypes.INTEGER,
numberOfViewsKivi: DataTypes.INTEGER
numberOfViewsKivi: DataTypes.INTEGER,
deleted: DataTypes.BOOLEAN,
deletedAt: DataTypes.DATE
});
return RealEstate;

7
app/public/dropzone-5.7.0/.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
build
components
node_modules
.DS_Store
.sass-cache
_site
_config.yaml

View File

@@ -0,0 +1,52 @@
{
"files": [
{
"name": "src/dropzone.coffee",
"regexs": [
"Dropzone.version = \"###\""
]
},
{
"name": "dist/dropzone.js",
"regexs": [
"version = \"###\""
]
},
{
"name": "dist/min/dropzone.min.js",
"regexs": [
"version=\"###\""
]
},
{
"name": "dist/dropzone-amd-module.js",
"regexs": [
"version = \"###\""
]
},
{
"name": "dist/min/dropzone-amd-module.min.js",
"regexs": [
"version=\"###\""
]
},
{
"name": "package.json",
"regexs": [
"\"version\": \"###\""
]
},
{
"name": "component.json",
"regexs": [
"\"version\": \"###\""
]
},
{
"name": "bower.json",
"regexs": [
"\"version\": \"###\""
]
}
]
}

View File

@@ -0,0 +1,6 @@
Contribute
==========
DO NOT CREATE PULL REQUESTS ON GITHUB!
I will simply close them. If you want to contribute, please use [gitlab.com](https://gitlab.com/meno/dropzone) instead.

View File

@@ -0,0 +1,12 @@
License
(The MIT License)
Copyright (c) 2012 Matias Meno <m@tias.me>
Logo & Website Design (c) 2015 "1910" www.weare1910.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,36 @@
<img alt="Dropzone.js" src="http://www.dropzonejs.com/images/new-logo.svg" />
Dropzone.js is a light weight JavaScript library that turns an HTML element into a dropzone.
This means that a user can drag and drop a file onto it, and the file gets uploaded to the server via AJAX.
* * *
_If you want support, please use [stackoverflow](http://stackoverflow.com/) with the `dropzone.js` tag and not the
GitHub issues tracker. Only post an issue here if you think you discovered a bug or have a feature request._
* * *
**Please read the [contributing guidelines](CONTRIBUTING.md) before you start working on Dropzone!**
<br>
<div align="center">
<a href="https://gitlab.com/meno/dropzone/builds/artifacts/master/download?job=release"><strong>&gt;&gt; Download &lt;&lt;</strong></a>
</div>
<br>
<br>
This is no longer the official repository for Dropzone. I have switched to [gitlab.com](https://gitlab.com/meno/dropzone)
as the primary location to continue development.
There are multiple reasons why I am switching from GitHub to GitLab, but a few of the reasons are the
issue tracker that GitHub is providing, *drowning* me in issues that I am unable to categorise or prioritize properly,
the lack of proper continuous integration, and build files. I don't want the compiled `.js` files in my repository, and
people regularly commit changes to the compiled files and create pull requests with them.
I will write a blog post soon, that goes into detail about why I am doing the switch.
This repository will still remain, and always host the most up to date versions of dropzone, but only the distribution
files!
MIT License
-----------

View File

@@ -0,0 +1,16 @@
{
"name": "dropzone",
"location": "enyo/dropzone",
"version": "5.7.0",
"description": "Dropzone is an easy to use drag'n'drop library. It supports image previews and shows nice progress bars.",
"homepage": "http://www.dropzonejs.com",
"main": [
"dist/min/dropzone.min.css",
"dist/min/dropzone.min.js"
],
"ignore": [
"*",
"!dist",
"!dist/**/*"
]
}

View File

@@ -0,0 +1,10 @@
{
"name": "dropzone",
"repo": "enyo/dropzone",
"version": "5.7.0",
"description": "Handles drag and drop of files for you.",
"scripts": [ "index.js", "dist/dropzone.js" ],
"styles": [ "dist/basic.css" ],
"dependencies": { },
"license": "MIT"
}

View File

@@ -0,0 +1,18 @@
{
"name": "enyo/dropzone",
"description": "Handles drag and drop of files for you.",
"homepage": "http://www.dropzonejs.com",
"keywords": [
"dragndrop",
"drag and drop",
"file upload",
"upload"
],
"authors": [{
"name": "Matias Meno",
"email": "m@tias.me",
"homepage": "http://www.matiasmeno.com"
}],
"license": "MIT",
"minimum-stability": "dev"
}

View File

@@ -0,0 +1,39 @@
/*
* The MIT License
* Copyright (c) 2012 Matias Meno <m@tias.me>
*/
.dropzone, .dropzone * {
box-sizing: border-box; }
.dropzone {
position: relative; }
.dropzone .dz-preview {
position: relative;
display: inline-block;
width: 120px;
margin: 0.5em; }
.dropzone .dz-preview .dz-progress {
display: block;
height: 15px;
border: 1px solid #aaa; }
.dropzone .dz-preview .dz-progress .dz-upload {
display: block;
height: 100%;
width: 0;
background: green; }
.dropzone .dz-preview .dz-error-message {
color: red;
display: none; }
.dropzone .dz-preview.dz-error .dz-error-message, .dropzone .dz-preview.dz-error .dz-error-mark {
display: block; }
.dropzone .dz-preview.dz-success .dz-success-mark {
display: block; }
.dropzone .dz-preview .dz-error-mark, .dropzone .dz-preview .dz-success-mark {
position: absolute;
display: none;
left: 30px;
top: 30px;
width: 54px;
height: 58px;
left: 50%;
margin-left: -27px; }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,396 @@
/*
* The MIT License
* Copyright (c) 2012 Matias Meno <m@tias.me>
*/
@-webkit-keyframes passing-through {
0% {
opacity: 0;
-webkit-transform: translateY(40px);
-moz-transform: translateY(40px);
-ms-transform: translateY(40px);
-o-transform: translateY(40px);
transform: translateY(40px); }
30%, 70% {
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px); }
100% {
opacity: 0;
-webkit-transform: translateY(-40px);
-moz-transform: translateY(-40px);
-ms-transform: translateY(-40px);
-o-transform: translateY(-40px);
transform: translateY(-40px); } }
@-moz-keyframes passing-through {
0% {
opacity: 0;
-webkit-transform: translateY(40px);
-moz-transform: translateY(40px);
-ms-transform: translateY(40px);
-o-transform: translateY(40px);
transform: translateY(40px); }
30%, 70% {
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px); }
100% {
opacity: 0;
-webkit-transform: translateY(-40px);
-moz-transform: translateY(-40px);
-ms-transform: translateY(-40px);
-o-transform: translateY(-40px);
transform: translateY(-40px); } }
@keyframes passing-through {
0% {
opacity: 0;
-webkit-transform: translateY(40px);
-moz-transform: translateY(40px);
-ms-transform: translateY(40px);
-o-transform: translateY(40px);
transform: translateY(40px); }
30%, 70% {
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px); }
100% {
opacity: 0;
-webkit-transform: translateY(-40px);
-moz-transform: translateY(-40px);
-ms-transform: translateY(-40px);
-o-transform: translateY(-40px);
transform: translateY(-40px); } }
@-webkit-keyframes slide-in {
0% {
opacity: 0;
-webkit-transform: translateY(40px);
-moz-transform: translateY(40px);
-ms-transform: translateY(40px);
-o-transform: translateY(40px);
transform: translateY(40px); }
30% {
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px); } }
@-moz-keyframes slide-in {
0% {
opacity: 0;
-webkit-transform: translateY(40px);
-moz-transform: translateY(40px);
-ms-transform: translateY(40px);
-o-transform: translateY(40px);
transform: translateY(40px); }
30% {
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px); } }
@keyframes slide-in {
0% {
opacity: 0;
-webkit-transform: translateY(40px);
-moz-transform: translateY(40px);
-ms-transform: translateY(40px);
-o-transform: translateY(40px);
transform: translateY(40px); }
30% {
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px); } }
@-webkit-keyframes pulse {
0% {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1); }
10% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1); }
20% {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1); } }
@-moz-keyframes pulse {
0% {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1); }
10% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1); }
20% {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1); } }
@keyframes pulse {
0% {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1); }
10% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1); }
20% {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1); } }
.dropzone, .dropzone * {
box-sizing: border-box; }
.dropzone {
min-height: 150px;
border: 2px solid rgba(0, 0, 0, 0.3);
background: white;
padding: 20px 20px; }
.dropzone.dz-clickable {
cursor: pointer; }
.dropzone.dz-clickable * {
cursor: default; }
.dropzone.dz-clickable .dz-message, .dropzone.dz-clickable .dz-message * {
cursor: pointer; }
.dropzone.dz-started .dz-message {
display: none; }
.dropzone.dz-drag-hover {
border-style: solid; }
.dropzone.dz-drag-hover .dz-message {
opacity: 0.5; }
.dropzone .dz-message {
text-align: center;
margin: 2em 0; }
.dropzone .dz-message .dz-button {
background: none;
color: inherit;
border: none;
padding: 0;
font: inherit;
cursor: pointer;
outline: inherit; }
.dropzone .dz-preview {
position: relative;
display: inline-block;
vertical-align: top;
margin: 16px;
min-height: 100px; }
.dropzone .dz-preview:hover {
z-index: 1000; }
.dropzone .dz-preview:hover .dz-details {
opacity: 1; }
.dropzone .dz-preview.dz-file-preview .dz-image {
border-radius: 20px;
background: #999;
background: linear-gradient(to bottom, #eee, #ddd); }
.dropzone .dz-preview.dz-file-preview .dz-details {
opacity: 1; }
.dropzone .dz-preview.dz-image-preview {
background: white; }
.dropzone .dz-preview.dz-image-preview .dz-details {
-webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear;
-ms-transition: opacity 0.2s linear;
-o-transition: opacity 0.2s linear;
transition: opacity 0.2s linear; }
.dropzone .dz-preview .dz-remove {
font-size: 14px;
text-align: center;
display: block;
cursor: pointer;
border: none; }
.dropzone .dz-preview .dz-remove:hover {
text-decoration: underline; }
.dropzone .dz-preview:hover .dz-details {
opacity: 1; }
.dropzone .dz-preview .dz-details {
z-index: 20;
position: absolute;
top: 0;
left: 0;
opacity: 0;
font-size: 13px;
min-width: 100%;
max-width: 100%;
padding: 2em 1em;
text-align: center;
color: rgba(0, 0, 0, 0.9);
line-height: 150%; }
.dropzone .dz-preview .dz-details .dz-size {
margin-bottom: 1em;
font-size: 16px; }
.dropzone .dz-preview .dz-details .dz-filename {
white-space: nowrap; }
.dropzone .dz-preview .dz-details .dz-filename:hover span {
border: 1px solid rgba(200, 200, 200, 0.8);
background-color: rgba(255, 255, 255, 0.8); }
.dropzone .dz-preview .dz-details .dz-filename:not(:hover) {
overflow: hidden;
text-overflow: ellipsis; }
.dropzone .dz-preview .dz-details .dz-filename:not(:hover) span {
border: 1px solid transparent; }
.dropzone .dz-preview .dz-details .dz-filename span, .dropzone .dz-preview .dz-details .dz-size span {
background-color: rgba(255, 255, 255, 0.4);
padding: 0 0.4em;
border-radius: 3px; }
.dropzone .dz-preview:hover .dz-image img {
-webkit-transform: scale(1.05, 1.05);
-moz-transform: scale(1.05, 1.05);
-ms-transform: scale(1.05, 1.05);
-o-transform: scale(1.05, 1.05);
transform: scale(1.05, 1.05);
-webkit-filter: blur(8px);
filter: blur(8px); }
.dropzone .dz-preview .dz-image {
border-radius: 20px;
overflow: hidden;
width: 120px;
height: 120px;
position: relative;
display: block;
z-index: 10; }
.dropzone .dz-preview .dz-image img {
display: block; }
.dropzone .dz-preview.dz-success .dz-success-mark {
-webkit-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1);
-moz-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1);
-ms-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1);
-o-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1);
animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); }
.dropzone .dz-preview.dz-error .dz-error-mark {
opacity: 1;
-webkit-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1);
-moz-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1);
-ms-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1);
-o-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1);
animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); }
.dropzone .dz-preview .dz-success-mark, .dropzone .dz-preview .dz-error-mark {
pointer-events: none;
opacity: 0;
z-index: 500;
position: absolute;
display: block;
top: 50%;
left: 50%;
margin-left: -27px;
margin-top: -27px; }
.dropzone .dz-preview .dz-success-mark svg, .dropzone .dz-preview .dz-error-mark svg {
display: block;
width: 54px;
height: 54px; }
.dropzone .dz-preview.dz-processing .dz-progress {
opacity: 1;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
transition: all 0.2s linear; }
.dropzone .dz-preview.dz-complete .dz-progress {
opacity: 0;
-webkit-transition: opacity 0.4s ease-in;
-moz-transition: opacity 0.4s ease-in;
-ms-transition: opacity 0.4s ease-in;
-o-transition: opacity 0.4s ease-in;
transition: opacity 0.4s ease-in; }
.dropzone .dz-preview:not(.dz-processing) .dz-progress {
-webkit-animation: pulse 6s ease infinite;
-moz-animation: pulse 6s ease infinite;
-ms-animation: pulse 6s ease infinite;
-o-animation: pulse 6s ease infinite;
animation: pulse 6s ease infinite; }
.dropzone .dz-preview .dz-progress {
opacity: 1;
z-index: 1000;
pointer-events: none;
position: absolute;
height: 16px;
left: 50%;
top: 50%;
margin-top: -8px;
width: 80px;
margin-left: -40px;
background: rgba(255, 255, 255, 0.9);
-webkit-transform: scale(1);
border-radius: 8px;
overflow: hidden; }
.dropzone .dz-preview .dz-progress .dz-upload {
background: #333;
background: linear-gradient(to bottom, #666, #444);
position: absolute;
top: 0;
left: 0;
bottom: 0;
width: 0;
-webkit-transition: width 300ms ease-in-out;
-moz-transition: width 300ms ease-in-out;
-ms-transition: width 300ms ease-in-out;
-o-transition: width 300ms ease-in-out;
transition: width 300ms ease-in-out; }
.dropzone .dz-preview.dz-error .dz-error-message {
display: block; }
.dropzone .dz-preview.dz-error:hover .dz-error-message {
opacity: 1;
pointer-events: auto; }
.dropzone .dz-preview .dz-error-message {
pointer-events: none;
z-index: 1000;
position: absolute;
display: block;
display: none;
opacity: 0;
-webkit-transition: opacity 0.3s ease;
-moz-transition: opacity 0.3s ease;
-ms-transition: opacity 0.3s ease;
-o-transition: opacity 0.3s ease;
transition: opacity 0.3s ease;
border-radius: 8px;
font-size: 13px;
top: 130px;
left: -10px;
width: 140px;
background: #be2626;
background: linear-gradient(to bottom, #be2626, #a92222);
padding: 0.5em 1.2em;
color: white; }
.dropzone .dz-preview .dz-error-message:after {
content: '';
position: absolute;
top: -6px;
left: 64px;
width: 0;
height: 0;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #be2626; }

4697
app/public/dropzone-5.7.0/dist/dropzone.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
.dropzone,.dropzone *{box-sizing:border-box}.dropzone{position:relative}.dropzone .dz-preview{position:relative;display:inline-block;width:120px;margin:0.5em}.dropzone .dz-preview .dz-progress{display:block;height:15px;border:1px solid #aaa}.dropzone .dz-preview .dz-progress .dz-upload{display:block;height:100%;width:0;background:green}.dropzone .dz-preview .dz-error-message{color:red;display:none}.dropzone .dz-preview.dz-error .dz-error-message,.dropzone .dz-preview.dz-error .dz-error-mark{display:block}.dropzone .dz-preview.dz-success .dz-success-mark{display:block}.dropzone .dz-preview .dz-error-mark,.dropzone .dz-preview .dz-success-mark{position:absolute;display:none;left:30px;top:30px;width:54px;height:58px;left:50%;margin-left:-27px}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
module.exports = require("./dist/dropzone.js"); // Exposing dropzone

View File

@@ -0,0 +1,40 @@
{
"name": "dropzone",
"version": "5.7.0",
"description": "Handles drag and drop of files for you.",
"keywords": [
"dragndrop",
"drag and drop",
"file upload",
"upload"
],
"homepage": "http://www.dropzonejs.com",
"main": "./dist/dropzone.js",
"maintainers": [
{
"name": "Matias Meno",
"email": "m@tias.me",
"web": "http://www.colorglare.com"
}
],
"contributors": [
{
"name": "Matias Meno",
"email": "m@tias.me",
"web": "http://www.colorglare.com"
}
],
"scripts": {
"test": "grunt && npm run test-prebuilt",
"test-prebuilt": "mocha-headless-chrome -f test/test-prebuilt.html -a no-sandbox -a disable-setuid-sandbox"
},
"bugs": {
"email": "m@tias.me",
"url": "https://gitlab.com/meno/dropzone/issues"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://gitlab.com/meno/dropzone.git"
}
}

View File

@@ -169,6 +169,26 @@ h3 {
right: auto;
}
.dont-break-out {
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
word-break: break-all;
word-break: break-word;
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
.flex-direction-nav li a {
height: 50px;
}
.slider .slides li {
opacity: 1;
position: relative;
}
.dropzone {
background: white;
border-radius: 10px;
@@ -182,3 +202,9 @@ h3 {
.dz-progress {
display: none;
}
.dz-preview .dz-image img {
width: 100%;
height: 100%;
object-fit: cover;
}

View File

@@ -15,14 +15,17 @@ const {
getPublishInputs,
postPublishInputs
} = require("../controllers/publishRealEstate");
const { getViewRealEstate } = require("../controllers/viewRealEstate");
const {
getQueryReview,
postQueryReview
} = require("../controllers/queryReview");
const { getGoAgain } = require("../controllers/goAgain");
const { publishSuccess } = require("../controllers/publishSuccess");
const { editSuccess } = require("../controllers/editSuccess");
const { getLocation, postLocation } = require("../controllers/location");
const { getUnsubscribe } = require("../controllers/unsubscribe");
const { getDeletePublishedAd } = require("../controllers/deleteRealEstate");
const { getRealEstates } = require("../controllers/realEstates");
const { getRedirect } = require("../controllers/redirect");
const { getFilters, postFilters } = require("../controllers/realEstateFilters");
@@ -45,6 +48,8 @@ router.post("/objavinekretninu", postPublishTypes);
router.get("/podacionekretnini/:kiviRealEstateId", getPublishInputs);
router.post("/podacionekretnini/:kiviRealEstateId", postPublishInputs);
router.get("/preglednekretnine/:realEstateId", getViewRealEstate);
router.get("/lokacija/:searchRequestId", getLocation);
router.post("/lokacija/:searchRequestId", postLocation);
@@ -56,10 +61,14 @@ router.post("/pregled/:searchRequestId", postQueryReview);
router.get("/odjava/:searchRequestId", getUnsubscribe);
router.get("/obrisioglas/:kiviRealEstateId", getDeletePublishedAd);
router.get("/ponovo", getGoAgain);
router.get("/uspjesnaobjava", publishSuccess);
router.get("/uspjesnaizmjena", editSuccess);
router.get("/nekretnine/:searchRequestId", getRealEstates);
router.get("/redirect/:id", getRedirect);

View File

@@ -11,7 +11,8 @@ const {
generateNotificationEmail,
generateNewSearchRequestEmail,
generateEmailSubject,
generateCheckUpEmail
generateCheckUpEmail,
generateNewAdPublishEmail
} = require("../helpers/emailContentGenerator");
const {
findNotNotifiedMatches,
@@ -147,9 +148,38 @@ const checkUpNotify = async () => {
await Promise.all(asyncSendEmailActions);
};
const notifyForNewAdPublish = async (
realEstate,
kiviOriginal,
editingRealEstate
) => {
// console.log("Real estate:", realEstate);
// console.log("Kivi original:", kiviOriginal);
const email = kiviOriginal.dataValues.email;
const emailSubject = editingRealEstate
? `${stagingTag}Kivi - Uspješno ste izmijenili oglas!`
: `${stagingTag}Kivi - Uspješno ste objavili oglas!`;
const matches = await matchRealEstates([realEstate]);
//Counting number of matching req
let numberOfMatchingRequests = 0;
for (const match in matches) {
numberOfMatchingRequests++;
}
const emailContent = generateNewAdPublishEmail(
realEstate,
kiviOriginal,
editingRealEstate,
numberOfMatchingRequests
);
await sendEmail(email, emailSubject, emailContent);
};
module.exports = {
notifyForNewRealEstates,
notifyForNewSearchRequest,
notifyRequestsWithDailyOption,
notifyForNewAdPublish,
checkUpNotify
};

View File

@@ -9,11 +9,16 @@ const { MAX_REAL_ESTATES_IN_FIRST_EMAIL } = require("../config/appConfig");
const { EMAIL_FREQUENCY } = require("../common/enums");
const matchRealEstates = async realEstates => {
if (Array.isArray(realEstates)) {
//Filter deleted real estates
const filteredRealEstates = realEstates.filter(
realEstate => realEstate.deleted === false
);
if (Array.isArray(filteredRealEstates)) {
const asyncMatchActions = [];
const matches = {};
const matchingRecords = [];
for (const realEstate of realEstates) {
for (const realEstate of filteredRealEstates) {
const searchRequestsPromise = findSearchRequestsForRealEstate(realEstate);
asyncMatchActions.push(searchRequestsPromise);

View File

@@ -0,0 +1,12 @@
<!-- -->
<br><br>
<div class="row center-align">
<img src="../assets/images/logo.svg" alt="kivi logo" width="160">
</div>
<div class="row">
<div class="col s6 push-s3">
<a href="<%= nextStep %>" class="welcome-center-button waves-effect waves-light btn">
Početna stranica
</a>
</div>
</div>

11
app/views/editSuccess.ejs Normal file
View File

@@ -0,0 +1,11 @@
<br>
<div class="row center-align">
<p>Vaš oglas je izmijenjen u Kivi bazi.</p>
<br>
<div class="row center-align">
<img src="../assets/images/logo.svg" alt="kivi logo" width="160">
</div>
<br>
<p>Poslali smo potvrdni email sa izmijenjenim detaljima oglasa na Vašu email adresu.</p>
<a href="/" class="">Nova pretraga</a>
</div>

View File

@@ -19,7 +19,7 @@
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/validate.js/0.13.1/validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.7.0/dropzone.js"></script>
<script src="/assets/dropzone-5.7.0/dist/dropzone.js"></script>
<script type="text/javascript">
Dropzone.autoDiscover = false;
</script>
@@ -27,6 +27,10 @@
<meta charset="UTF-8" />
<link rel="stylesheet" href="/assets/main.css">
<link rel="stylesheet" href="/assets/segment.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.7.2/flexslider.css" type="text/css" media="screen" />
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.7.2/jquery.flexslider.js"></script>
<link rel="apple-touch-icon" sizes="180x180" href="/assets/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon-32x32.png">

View File

@@ -217,7 +217,7 @@
});
</script>
<script
src="https://maps.googleapis.com/maps/api/js?key=<%= process.env.API_MAP_KEY %>&language=bs&libraries=places&callback=initMap"
src="https://maps.googleapis.com/maps/api/js?key=<%= process.env.GOOGLE_MAP_KEY %>&language=bs&libraries=places&callback=initMap"
async
defer
></script>

View File

@@ -9,6 +9,7 @@
id="email"
name="email"
type="email"
value="<%= email !== undefined ? email : ""%>"
>
<div class="messages"></div>
<label for="email">Email</label>
@@ -17,7 +18,14 @@
<br>
<div class="row center-align">
<div class="col s6 push-s3">
<a id="submit" href="#" form="publishForm" class="welcome-center-button waves-effect waves-light btn">Objavi oglas</a>
<a id="submit" href="#" form="publishForm" class="welcome-center-button waves-effect waves-light btn">
<% if(editingRealEstate) { %>
Snimi izmjene
<% } else { %>
Objavi oglas
<% } %>
</a>
</div>
</div>

View File

@@ -36,6 +36,9 @@
let places;
let geocoder;
let marker =false; //Initialy no marker on map
const editingRealEstate = <%- editingRealEstate %>;
function locateMe() {
if (navigator.geolocation) {
@@ -101,6 +104,13 @@
autocomplete.addListener("place_changed", onPlaceChanged);
pacSelectFirst(inputElement);
addLocateMeButton(map);
//Move map and marker to already selected position if in editing mode
if( editingRealEstate===true) {
//console.log('Editujem mapu!');
setMarkerToLocation(map, editingRealEstate);
}
//Add event listener to position marker on map
google.maps.event.addListener(map, 'click', positionMarker);
@@ -114,13 +124,35 @@
map: map,
draggable: true
});
google.maps.event.addListener(marker, 'dragend', function(event){
markerLocation();
});
//google.maps.event.addListener(marker, 'dragend', function(event){
// markerLocation();
// });
} else{
marker.setPosition(clickedLocation);
}
}
function setMarkerToLocation(map) {
const ESTATE_COORDINATES = ( <%= locationLat %> !==0 && <%= locationLong %> !== 0 ) ?
{
lat: <%= locationLat %>,
lng: <%= locationLong %>
}:
{ lat: 43.85, //Set to Sarajevo if coordinates are not picked
lng: 18.41
};
marker = new google.maps.Marker({
position: ESTATE_COORDINATES,
map: map,
draggable: true
});
// google.maps.event.addListener(marker, 'dragend', function(event){
// markerLocation();
// });
//Zooming map to current location
map.setCenter(ESTATE_COORDINATES);
map.setZoom(13);
}
function addLocateMeButton(map) {
var parent = document.createElement("div");
@@ -185,7 +217,7 @@
</script>
<script
src="https://maps.googleapis.com/maps/api/js?key=<%= process.env.API_MAP_KEY %>&language=bs&libraries=places&callback=initMap"
src="https://maps.googleapis.com/maps/api/js?key=<%= process.env.GOOGLE_MAP_KEY %>&language=bs&libraries=places&callback=initMap"
async
defer
></script>

View File

@@ -1,4 +1,5 @@
<br>
<form id="publishForm" method="POST" novalidate >
<div class="row">
<div class="col s12">
@@ -27,6 +28,7 @@
<%- include("./publishEnd.ejs") %>
</div>
</div>
<input type="hidden" name="editingRealEstate" id="editingRealEstate" value="">
</form>
@@ -85,6 +87,11 @@
$(document).ready(function(){
$('.tabs').tabs();
const editingRealEstate = <%- JSON.stringify(editingRealEstate) %>;
$("#editingRealEstate").val(editingRealEstate);
const currentRealEstatePhotosUrls = <%-JSON.stringify(realEstatePhotosUrls)%>;
// Manual dropzone init
const dropzoneOptions = {
url: "/photos-upload", //can be a function that returns url ?
@@ -105,8 +112,38 @@
dictRemoveFile: 'Izbriši ',
dictFileTooBig: 'Fajl je prevelik!',
dictInvalidFileType: 'Iabrani fajl nije fotografija!',
dictMaxFilesExceeded: 'Dostigli ste maksimalan broj fotografija!'
};
dictMaxFilesExceeded: 'Dostigli ste maksimalan broj fotografija!',
init: function () {
let fileCountOnServer = currentRealEstatePhotosUrls.length; // The number of files already uploaded
this.options.maxFiles = this.options.maxFiles - fileCountOnServer;
if (editingRealEstate) {
for (let i=0; i<currentRealEstatePhotosUrls.length; i++) {
let fileName = currentRealEstatePhotosUrls[i].replace("https://storage.cloud.google.com/marketalarm-photos/", "");
var mockFile = { name: fileName, size: 12345, type: 'image/jpeg', accepted: true, status: Dropzone.ACCEPTED };
this.options.addedfile.call(this, mockFile);
this.options.thumbnail.call(this, mockFile, currentRealEstatePhotosUrls[i]);
this.files.push(mockFile);
mockFile.previewElement.classList.add('dz-success');
mockFile.previewElement.classList.add('dz-complete');
}
};
this.on("addedfile", function(event) {
while (this.files.length > this.options.maxFiles) {
this.removeFile(this.files[0]); //automaticly removing if more then 10 files
}
});
this.on("removedfile", function(event) {
let fileCountOnPreview = this.files.length;
this.options.maxFiles = 10; //resets allowed number of files
this._updateMaxFilesReachedClass();
});
}
}
var photosUploader = new Dropzone('#photos-upload', dropzoneOptions);
@@ -268,20 +305,42 @@
})
for (const input of basicInputInputs ) {
alert(input.getAttribute(name));
validate (input);
} */
const addedFiles = photosUploader.files.filter(file => file.status!=="error");
const asyncUpload =[];
addedFiles.forEach( file => {
//Filter all files to exclude ones that are already uploaded during the ad publish
//But keep them stored to know that they are not deleted from ad
let filesForUpload =[];
if(editingRealEstate) {
let currentPhotosFilenames = currentRealEstatePhotosUrls.map( url => {
return url.replace("https://storage.cloud.google.com/marketalarm-photos/", "");
})
photosUploader.files.map( file => {
if ( currentPhotosFilenames.includes(file.name) ) {
return $("#imageUrls").val($("#imageUrls").val()+ file.name+"|");
} else if (file.status!=="error") {
return filesForUpload.push(file);
}
});
} else {
photosUploader.files.map( file => {
if (file.status!=="error") {
return filesForUpload.push(file);
}
})
}
const asyncUpload =[];
filesForUpload.forEach( file => {
asyncUpload.push(generateSignedURL(file));
})
if (!hasErrors) {
await Promise.all(asyncUpload);
$("#publishForm").submit();
};
});

View File

@@ -0,0 +1,129 @@
<br/>
<div class="row col s12 center-align">
<div class="col s6 center-align distinguished">
<div><%= showAdType %> </div>
</div>
<div class="col s6 center-align distinguished">
<%= showRealEstateType %>
</div>
</div>
<section class="slider">
<div class="flexslider" >
<ul class="slides">
<% for (const photoUrl of realEstatePhotosUrls) { %>
<li class="flex-li">
<img src=<%= photoUrl %> alt=""/>
</li>
<% } %>
</ul>
</div>
</section>
<br/>
<br>
<div class="row col s12">
<% for (const field of inputFields){ %>
<p>
<span class="col s4"><%= field.title %></span>
<span class="col s8 distinguished dont-break-out"><%= allInputValues[field.dbField] %></span>
</p>
<br>
<% } %>
</div>
<br>
<div class="row">
<% for (const field of segmentFields){ %>
<p>
<span class="col s4"><%= field.title.replace(/>/g,'') %></span>
<% for (const segmentObject of field.values) { %>
<% if (allSegmentSelectedValues[field.dbField] === segmentObject.id) { %>
<span class="col s8 distinguished"><%= segmentObject.title.replace(/>/g,'') %></span>
<% } %>
<% } %>
</p>
<br>
<% } %>
</div>
<br>
<div class="row col s12">
<% for (const field of booleanFields){ %>
<p class="col s4">
<span>&#10003;</span>
<span><%= field.title %></span>
</p>
<% } %>
</div>
<div class="row center-align ">
<div class="distinguished">
<span>Lokacija nekretnine</span>
</div>
<br>
<br>
<div class="col s12">
<div id="map"></div>
</div>
</div>
<script type="text/javascript">
$(window).load(function() {
$('.flexslider').flexslider({
animation: "slide",
smoothHeight: true
});
});
</script>
<script>
//Setting up image gallery - carousel
//Setting up location map
let map;
function initMap() {
const BOSNIA_BOUNDS = {
north: 45.7,
south: 41.69,
west: 15.55,
east: 20.77
};
const ESTATE_COORDINATES = {
lat: <%= locationLat %>,
lng: <%= locationLong %>
};
const mapElement = document.getElementById("map");
const restrictMapPanningToBosniaOnly = {
latLngBounds: BOSNIA_BOUNDS,
strictBounds: true
};
const initialMapParams = {
center: ESTATE_COORDINATES,
zoom: 13,
restriction: restrictMapPanningToBosniaOnly,
mapTypeControl: false,
panControl: false,
zoomControl: true,
streetViewControl: false
};
map = new google.maps.Map(mapElement, initialMapParams);
marker = new google.maps.Marker({
position: ESTATE_COORDINATES,
map: map,
});
}
</script>
<script
src="https://maps.googleapis.com/maps/api/js?key=<%= process.env.GOOGLE_MAP_KEY %>&language=bs&libraries=places&callback=initMap"
async
defer
></script>

View File

@@ -19,7 +19,7 @@ CHECK_UP_DAYS=Check up email is sent after this number of days without notificat
GA_ID=Google Analytics ID
#=============== GOOGLE MAPS =============#
API_MAP_KEY=(your-key-here)
GOOGLE_MAP_KEY=(your-key-here)
#=============== GOOGLE STORAGE =============#
GOOGLE_APPLICATION_CREDENTIALS="Path to json key file"

397
help.js
View File

@@ -1,237 +1,184 @@
(function() {
// Before using it we must add the parse and format functions
// Here is a sample implementation using moment.js
validate.extend(validate.validators.datetime, {
// The value is guaranteed not to be null or undefined but otherwise it
// could be anything.
parse: function(value, options) {
return +moment.utc(value);
},
// Input is a unix timestamp
format: function(value, options) {
var format = options.dateOnly ? "YYYY-MM-DD" : "YYYY-MM-DD hh:mm:ss";
return moment.utc(value).format(format);
}
});
let autocomplete;
let map;
let places;
let geocoder;
let marker =false; //Initialy no marker on map
// These are the constraints used to validate the form
var constraints = {
email: {
// Email is required
presence: true,
// and must be an email (duh)
email: true
},
password: {
// Password is also required
presence: true,
// And must be at least 5 characters long
length: {
minimum: 5
}
},
"confirm-password": {
// You need to confirm your password
presence: true,
// and it needs to be equal to the other password
equality: {
attribute: "password",
message: "^The passwords does not match"
}
},
username: {
// You need to pick a username too
presence: true,
// And it must be between 3 and 20 characters long
length: {
minimum: 3,
maximum: 20
},
format: {
// We don't allow anything that a-z and 0-9
pattern: "[a-z0-9]+",
// but we don't care if the username is uppercase or lowercase
flags: "i",
message: "can only contain a-z and 0-9"
}
},
birthdate: {
// The user needs to give a birthday
presence: true,
// and must be born at least 18 years ago
date: {
latest: moment().subtract(18, "years"),
message: "^You must be at least 18 years old to use this service"
}
},
country: {
// You also need to input where you live
presence: true,
// And we restrict the countries supported to Sweden
inclusion: {
within: ["SE"],
// The ^ prevents the field name from being prepended to the error
message: "^Sorry, this service is for Sweden only"
}
},
zip: {
// Zip is optional but if specified it must be a 5 digit long number
format: {
pattern: "\\d{5}"
}
},
"number-of-children": {
presence: true,
// Number of children has to be an integer >= 0
numericality: {
onlyInteger: true,
greaterThanOrEqualTo: 0
const editingRealEstate = <%- editingRealEstate %>;
function locateMe() {
if (navigator.geolocation) {
function onLocationSuccess(position) {
const coordinates =
position && position.coords ? position.coords : null;
if (coordinates) {
const longitude = coordinates.longitude || null;
const latitude = coordinates.latitude || null;
if (longitude && latitude && map) {
map.setCenter({ lat: latitude, lng: longitude });
map.setZoom(16);
}
}
}
navigator.geolocation.getCurrentPosition(onLocationSuccess);
}
}
};
function initMap() {
const BOSNIA_BOUNDS = {
north: 45.7,
south: 41.69,
west: 15.55,
east: 20.77
};
const SARAJEVO_COORDINATES = {
lat: 43.85,
lng: 18.41
};
const mapElement = document.getElementById("map");
const restrictMapPanningToBosniaOnly = {
latLngBounds: BOSNIA_BOUNDS,
strictBounds: true
};
const initialMapParams = {
center: SARAJEVO_COORDINATES,
zoom: 12,
restriction: restrictMapPanningToBosniaOnly,
mapTypeControl: false,
panControl: false,
zoomControl: true,
streetViewControl: false
};
map = new google.maps.Map(mapElement, initialMapParams);
const inputElement = document.getElementById("autocompleteInput");
const restrictAutocompleteResultsToBosniaOnly = { country: "ba" };
const initialAutocompleteParams = {
types: ["geocode"],
componentRestrictions: restrictAutocompleteResultsToBosniaOnly,
fields: ["geometry", "types", "address_components"]
};
autocomplete = new google.maps.places.Autocomplete(
inputElement,
initialAutocompleteParams
);
autocomplete.bindTo("bounds", map);
autocomplete.addListener("place_changed", onPlaceChanged);
pacSelectFirst(inputElement);
addLocateMeButton(map);
// Hook up the form so we can prevent it from being posted
var form = document.querySelector("form#main");
form.addEventListener("submit", function(ev) {
ev.preventDefault();
handleFormSubmit(form);
});
//Move map and marker to already selected position if in editing mode
if( editingRealEstate===true) {
console.log('Editujem mapu!');
setMarkerToLocation(map, editingRealEstate);
}
// Hook up the inputs to validate on the fly
var inputs = document.querySelectorAll("input, textarea, select");
for (var i = 0; i < inputs.length; ++i) {
inputs.item(i).addEventListener("change", function(ev) {
var errors = validate(form, constraints) || {};
showErrorsForInput(this, errors[this.name]);
});
}
function handleFormSubmit(form, input) {
// validate the form against the constraints
var errors = validate(form, constraints);
// then we update the form to reflect the results
showErrors(form, errors || {});
if (!errors) {
showSuccess();
//Add event listener to position marker on map
google.maps.event.addListener(map, 'click', positionMarker);
}
}
// Updates the inputs with the validation errors
function showErrors(form, errors) {
// We loop through all the inputs and show the errors for that input
_.each(form.querySelectorAll("input[name], select[name]"), function(input) {
// Since the errors can be null if no errors were found we need to handle
// that
showErrorsForInput(input, errors && errors[input.name]);
});
}
// Shows the errors for a specific input
function showErrorsForInput(input, errors) {
// This is the root of the input
var formGroup = closestParent(input.parentNode, "form-group"),
// Find where the error messages will be insert into
messages = formGroup.querySelector(".messages");
// First we remove any old messages and resets the classes
resetFormGroup(formGroup);
// If we have errors
if (errors) {
// we first mark the group has having errors
formGroup.classList.add("has-error");
// then we append all the errors
_.each(errors, function(error) {
addError(messages, error);
});
} else {
// otherwise we simply mark it as success
formGroup.classList.add("has-success");
function positionMarker(event) {
let clickedLocation = event.latLng;
if(marker === false){
marker = new google.maps.Marker({
position: clickedLocation,
map: map,
draggable: true
});
//google.maps.event.addListener(marker, 'dragend', function(event){
// markerLocation();
// });
} else{
marker.setPosition(clickedLocation);
}
}
}
function setMarkerToLocation(map) {
const ESTATE_COORDINATES = ( <%= locationLat %> !==0 && <%= locationLong %> !== 0 ) ?
{
lat: <%= locationLat %>,
lng: <%= locationLong %>
}:
{ lat: 43.85, //Set to Sarajevo if coordinates are not picked
lng: 18.41
};
// Recusively finds the closest parent that has the specified class
function closestParent(child, className) {
if (!child || child == document) {
return null;
marker = new google.maps.Marker({
position: ESTATE_COORDINATES,
map: map,
draggable: true
});
// google.maps.event.addListener(marker, 'dragend', function(event){
// markerLocation();
// });
//Zooming map to current location
map.setCenter(ESTATE_COORDINATES);
map.setZoom(13);
}
if (child.classList.contains(className)) {
return child;
} else {
return closestParent(child.parentNode, className);
function addLocateMeButton(map) {
var parent = document.createElement("div");
parent.className = "locate-me-container";
var a = document.createElement("a");
a.id = "locateMe";
a.className = "btn-floating";
var i = document.createElement("i");
i.innerText = "gps_fixed";
i.className = "material-icons right";
a.appendChild(i);
a.addEventListener("click", locateMe);
parent.appendChild(a);
map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(parent);
}
}
function resetFormGroup(formGroup) {
// Remove the success and error classes
formGroup.classList.remove("has-error");
formGroup.classList.remove("has-success");
// and remove any old messages
_.each(formGroup.querySelectorAll(".help-block.error"), function(el) {
el.parentNode.removeChild(el);
});
}
// Adds the specified error with the following markup
// <p class="help-block error">[message]</p>
function addError(messages, error) {
var block = document.createElement("p");
block.classList.add("help-block");
block.classList.add("error");
block.innerText = error;
messages.appendChild(block);
}
function showSuccess() {
// We made it \:D/
alert("Success!");
}
})();
/////////////////////////////////////////////////
const isPresent = $input => {
return $input && $input!=="" && $input != null;
}
const isNumber = $input => {
const simpleNumberRegex = /[+-]?(?:\d*[.,])?\d+/;
return $input && $input.length <250 && simpleNumberRegex.test($input);
}
const isInteger = $input => {
const simpleIntegerRegex = /^([+-]?[1-9]\d*|0)$/;
return $input && $input.length <250 && simpleIntegerRegex.test($input);
}
const validate = (input) => {
const valid;
const errorMsg;
const constraint = input.constraint[0];
switch (constraint) {
case "required":
valid = isPresent ($(`#${input.dbField}`).val());
errorMsg = ["Ovo je obavezno polje."];
break;
case "numerical":
valid = isNumber ($(`#${input.dbField}`).val());
errorMsg = ["Unesite brojcanu vrijednost."];
break;
case "integer":
valid = isInteger ($(`#${input.dbField}`).val());
errorMsg = ["Unesite cijeli broj."];
break;
default :
valid = true;
function onPlaceChanged() {
const place = autocomplete.getPlace();
if (place.geometry) {
map.fitBounds(place.geometry.viewport);
map.setZoom(map.getZoom() + 1);
$("#locationInputData").val(JSON.stringify(place));
}
}
if (!valid) {
const inputField = document.querySelector(`#${input.dbField}`);
showErrorsForInput( inputField, errorMsg);
return false;
} else {
return true;
}
}
function pacSelectFirst(input) {
// store the original event binding function
const _addEventListener = input.addEventListener
? input.addEventListener
: input.attachEvent;
function addEventListenerWrapper(type, listener) {
// Simulate a 'down arrow' keypress on hitting 'return' when no pac suggestion is selected,
// and then trigger the original listener.
if (type == "keydown") {
const originalListener = listener;
listener = function(event) {
const suggestionSelected = $(".pac-item-selected").length > 0;
if (event.key == "Enter" && !suggestionSelected) {
const simulatedDownArrow = $.Event("keydown", {
keyCode: 40,
which: 40
});
originalListener.apply(input, [simulatedDownArrow]);
}
originalListener.apply(input, [event]);
};
}
_addEventListener.apply(input, [type, listener]);
}
input.addEventListener = addEventListenerWrapper;
input.attachEvent = addEventListenerWrapper;
}

11
package-lock.json generated
View File

@@ -4162,6 +4162,11 @@
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
},
"validator": {
"version": "10.11.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-10.11.0.tgz",
"integrity": "sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw=="
}
}
},
@@ -4944,9 +4949,9 @@
"integrity": "sha512-PnFM3xiZ+kYmLyTiMgTYmU7ZHkjBZz2/+F0DaALc/uUtVzdCt1wAosvYJ5hFQi/hz8O4zb52FQhHZRC+uVkJ+g=="
},
"validator": {
"version": "10.11.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-10.11.0.tgz",
"integrity": "sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw=="
"version": "12.2.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-12.2.0.tgz",
"integrity": "sha512-jJfE/DW6tIK1Ek8nCfNFqt8Wb3nzMoAbocBF6/Icgg1ZFSBpObdnwVY2jQj6qUqzhx5jc71fpvBWyLGO7Xl+nQ=="
},
"vary": {
"version": "1.1.2",

View File

@@ -54,7 +54,8 @@
"react-step-wizard": "^5.1.0",
"sequelize": "^5.18.4",
"sequelize-cli": "^5.5.0",
"validate.js": "^0.13.1"
"validate.js": "^0.13.1",
"validator": "^12.2.0"
},
"devDependencies": {
"nodemon": "^1.19.0"