diff --git a/backend/api.py b/backend/api.py
index 373c5742..62fe5207 100755
--- a/backend/api.py
+++ b/backend/api.py
@@ -22,15 +22,25 @@
users_schema = user_models.usersViewSchema(many=True)
corThemeStheme_Schema = models.CorThemeSthemeSchema(many=True)
themes_sthemes_schema = models.CorSthemeThemeSchema(many=True)
+ville_schema = models.VilleSchema(many=True)
+
@api.route('/api/sites', methods=['GET'])
def returnAllSites():
- get_all_sites = models.TSite.query.all()
+ get_all_sites = models.TSite.query.order_by('name_site').all()
sites = site_schema.dump(get_all_sites).data
for site in sites:
- get_photo = models.TPhoto.query.filter_by(
- id_photo=site.get('t_photos')[0])
- main_photo = photo_schema.dump(get_photo).data
+ get_main_photo = models.TPhoto.query.filter_by(
+ id_photo=site.get('main_photo'))
+ '''
+ get_photos = models.TPhoto.query.filter(
+ models.TPhoto.id_photo.in_(site.get('t_photos')))
+ dump_photos = photo_schema.dump(get_photos).data
+ for photo in dump_photos :
+ photo['sm'] = utils.getThumbnail(photo).get('output_name'),
+ site['photos'] = dump_photos
+ '''
+ main_photo = photo_schema.dump(get_main_photo).data
site['main_photo'] = utils.getThumbnail(
main_photo[0]).get('output_name')
return jsonify(sites), 200
@@ -39,8 +49,8 @@ def returnAllSites():
def returnSiteById(id_site):
get_site_by_id = models.TSite.query.filter_by(id_site=id_site)
site = site_schema.dump(get_site_by_id).data
- get_photos_by_site = models.TPhoto.query.filter_by(id_site=id_site)
- photos = photo_schema.dump(get_photos_by_site).data
+ get_photos_by_site = models.TPhoto.query.order_by('filter_date').filter_by(id_site=id_site).all()
+ dump_photos = photo_schema.dump(get_photos_by_site).data
cor_sthemes_themes = site[0].get('cor_site_stheme_themes')
cor_list = []
@@ -61,18 +71,21 @@ def returnSiteById(id_site):
site[0]['themes'] = themes_list
site[0]['subthemes'] = subthemes_list
- def getPhoto(photo):
- return {
- 'id': photo.get('id_photo'),
- 'sm': url_for('static', filename=DATA_IMAGES_PATH + utils.getThumbnail(photo).get('output_name')),
- 'md': url_for('static', filename=DATA_IMAGES_PATH + utils.getMedium(photo).get('output_name')),
- 'lg': url_for('static', filename=DATA_IMAGES_PATH + utils.getLarge(photo).get('output_name')),
- 'date': photo.get('date_photo')
- }
+ for photo in dump_photos :
+ photo['sm'] = utils.getThumbnail(photo).get('output_name'),
- photos = [getPhoto(photo) for photo in photos]
+ photos = dump_photos
return jsonify(site=site, photos=photos), 200
+@api.route('/api/gallery')
+def gallery():
+
+ get_photos = models.TPhoto.query.order_by('id_site').all()
+ dump_photos = photo_schema.dump(get_photos).data
+ for photo in dump_photos :
+ photo['sm'] = utils.getThumbnail(photo).get('output_name'),
+ return jsonify(dump_photos), 200
+
@api.route('/api/themes', methods=['GET'])
def returnAllThemes():
try:
@@ -153,7 +166,6 @@ def add_site():
@fnauth.check_auth(6, False, None, None)
def update_site():
site = request.get_json()
- print('site',site)
models.CorSiteSthemeTheme.query.filter_by(id_site=site.get('id_site')).delete()
models.TSite.query.filter_by(id_site= site.get('id_site')).update(site)
db.session.commit()
@@ -199,6 +211,30 @@ def upload_file():
return jsonify('photo added successfully'), 200
+@api.route('/api/updatePhoto', methods=['PATCH'])
+@fnauth.check_auth(6, False, None, None)
+def update_photo():
+ base_path = './static/' + DATA_IMAGES_PATH
+ data = request.form.get('data')
+ image = request.files.get('image')
+ data_serialized = json.loads(data)
+ photos_query = models.TPhoto.query.filter_by(id_photo=data_serialized.get('id_photo')).all()
+ photo_name = photo_schema.dump(photos_query).data[0].get('path_file_photo')
+ print('data_serialized', data_serialized)
+ if (data_serialized.get('main_photo') == True):
+ models.TSite.query.filter_by(id_site= data_serialized.get('id_site')).update({models.TSite.main_photo: data_serialized.get('id_photo')})
+ if (data_serialized.get('main_photo')):
+ del data_serialized['main_photo']
+ models.TPhoto.query.filter_by(id_photo = data_serialized.get('id_photo')).update(data_serialized)
+ db.session.commit()
+ if (image):
+ for fileName in os.listdir(base_path):
+ if fileName.endswith(photo_name):
+ os.remove(base_path + fileName)
+ image.save(os.path.join(base_path + image.filename))
+ return jsonify('photo added successfully'), 200
+
+
@api.route('/api/deletePhotos', methods=['POST'])
@fnauth.check_auth(6, False, None, None)
def deletePhotos():
@@ -215,3 +251,15 @@ def deletePhotos():
if fileName.endswith(photo_name):
os.remove(base_path + fileName)
return jsonify('site has been deleted'), 200
+
+
+
+
+@api.route('/api/villes', methods=['GET'])
+def returnAllville():
+ try:
+ get_all_ville = models.Ville.query.all()
+ ville= ville_schema.dump(get_all_ville).data
+ return jsonify(ville), 200
+ except Exception as exception:
+ return jsonify(error=exception), 400
\ No newline at end of file
diff --git a/backend/models.py b/backend/models.py
index da92edb3..d9c85aca 100755
--- a/backend/models.py
+++ b/backend/models.py
@@ -11,11 +11,13 @@
db = SQLAlchemy()
ma = Marshmallow()
+
class TSite(db.Model):
__tablename__ = 't_site'
__table_args__ = {'schema': 'geopaysages'}
- id_site = db.Column(db.Integer, primary_key=True, server_default=db.FetchedValue())
+ id_site = db.Column(db.Integer, primary_key=True,
+ server_default=db.FetchedValue())
name_site = db.Column(db.String)
desc_site = db.Column(db.String)
legend_site = db.Column(db.String)
@@ -25,38 +27,49 @@ class TSite(db.Model):
path_file_guide_site = db.Column(db.String(1))
publish_site = db.Column(db.Boolean)
geom = db.Column(Geometry(geometry_type='POINT', srid=4326))
-
+ main_photo = db.Column(db.Integer)
class CorSiteSthemeTheme(db.Model):
__tablename__ = 'cor_site_stheme_theme'
__table_args__ = {'schema': 'geopaysages'}
- id_site_stheme_theme = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
- id_site = db.Column(db.ForeignKey('geopaysages.t_site.id_site'), primary_key=True, nullable=False)
- id_stheme_theme = db.Column(db.ForeignKey('geopaysages.cor_stheme_theme.id_stheme_theme'), primary_key=True, nullable=False)
+ id_site_stheme_theme = db.Column(
+ db.Integer, nullable=False, server_default=db.FetchedValue())
+ id_site = db.Column(db.ForeignKey(
+ 'geopaysages.t_site.id_site'), primary_key=True, nullable=False)
+ id_stheme_theme = db.Column(db.ForeignKey(
+ 'geopaysages.cor_stheme_theme.id_stheme_theme'), primary_key=True, nullable=False)
- t_site = db.relationship('TSite', primaryjoin='CorSiteSthemeTheme.id_site == TSite.id_site', backref='cor_site_stheme_themes')
- cor_stheme_theme = db.relationship('CorSthemeTheme', primaryjoin='CorSiteSthemeTheme.id_stheme_theme == CorSthemeTheme.id_stheme_theme', backref='cor_site_stheme_themes')
+ t_site = db.relationship(
+ 'TSite', primaryjoin='CorSiteSthemeTheme.id_site == TSite.id_site', backref='cor_site_stheme_themes')
+ cor_stheme_theme = db.relationship(
+ 'CorSthemeTheme', primaryjoin='CorSiteSthemeTheme.id_stheme_theme == CorSthemeTheme.id_stheme_theme', backref='cor_site_stheme_themes')
class CorSthemeTheme(db.Model):
__tablename__ = 'cor_stheme_theme'
__table_args__ = {'schema': 'geopaysages'}
- id_stheme_theme = db.Column(db.Integer, nullable=False, unique=True, server_default=db.FetchedValue())
- id_stheme = db.Column(db.ForeignKey('geopaysages.dico_stheme.id_stheme'), primary_key=True, nullable=False)
- id_theme = db.Column(db.ForeignKey('geopaysages.dico_theme.id_theme'), primary_key=True, nullable=False)
+ id_stheme_theme = db.Column(
+ db.Integer, nullable=False, unique=True, server_default=db.FetchedValue())
+ id_stheme = db.Column(db.ForeignKey(
+ 'geopaysages.dico_stheme.id_stheme'), primary_key=True, nullable=False)
+ id_theme = db.Column(db.ForeignKey(
+ 'geopaysages.dico_theme.id_theme'), primary_key=True, nullable=False)
- dico_stheme = db.relationship('DicoStheme', primaryjoin='CorSthemeTheme.id_stheme == DicoStheme.id_stheme', backref='cor_stheme_themes')
- dico_theme = db.relationship('DicoTheme', primaryjoin='CorSthemeTheme.id_theme == DicoTheme.id_theme', backref='cor_stheme_themes')
+ dico_stheme = db.relationship(
+ 'DicoStheme', primaryjoin='CorSthemeTheme.id_stheme == DicoStheme.id_stheme', backref='cor_stheme_themes')
+ dico_theme = db.relationship(
+ 'DicoTheme', primaryjoin='CorSthemeTheme.id_theme == DicoTheme.id_theme', backref='cor_stheme_themes')
class DicoLicencePhoto(db.Model):
__tablename__ = 'dico_licence_photo'
__table_args__ = {'schema': 'geopaysages'}
- id_licence_photo = db.Column(db.Integer, primary_key=True, server_default=db.FetchedValue())
+ id_licence_photo = db.Column(
+ db.Integer, primary_key=True, server_default=db.FetchedValue())
name_licence_photo = db.Column(db.String)
description_licence_photo = db.Column(db.String)
@@ -65,7 +78,8 @@ class DicoStheme(db.Model):
__tablename__ = 'dico_stheme'
__table_args__ = {'schema': 'geopaysages'}
- id_stheme = db.Column(db.Integer, primary_key=True, server_default=db.FetchedValue())
+ id_stheme = db.Column(db.Integer, primary_key=True,
+ server_default=db.FetchedValue())
name_stheme = db.Column(db.String)
@@ -73,26 +87,30 @@ class DicoTheme(db.Model):
__tablename__ = 'dico_theme'
__table_args__ = {'schema': 'geopaysages'}
- id_theme = db.Column(db.Integer, primary_key=True, server_default=db.FetchedValue())
+ id_theme = db.Column(db.Integer, primary_key=True,
+ server_default=db.FetchedValue())
name_theme = db.Column(db.String)
-
class TRole(db.Model):
__tablename__ = 't_roles'
__table_args__ = {'schema': 'utilisateurs'}
- groupe = db.Column(db.Boolean, nullable=False, server_default=db.FetchedValue())
- id_role = db.Column(db.Integer, primary_key=True, server_default=db.FetchedValue())
+ groupe = db.Column(db.Boolean, nullable=False,
+ server_default=db.FetchedValue())
+ id_role = db.Column(db.Integer, primary_key=True,
+ server_default=db.FetchedValue())
identifiant = db.Column(db.String(100))
nom_role = db.Column(db.String(50))
prenom_role = db.Column(db.String(50))
desc_role = db.Column(db.Text)
_pass = db.Column('pass', db.String(100))
email = db.Column(db.String(250))
- id_organisme = db.Column(db.ForeignKey('utilisateurs.bib_organismes.id_organisme', onupdate='CASCADE'))
+ id_organisme = db.Column(db.ForeignKey(
+ 'utilisateurs.bib_organismes.id_organisme', onupdate='CASCADE'))
organisme = db.Column(db.String(32))
- id_unite = db.Column(db.ForeignKey('utilisateurs.bib_unites.id_unite', onupdate='CASCADE'))
+ id_unite = db.Column(db.ForeignKey(
+ 'utilisateurs.bib_unites.id_unite', onupdate='CASCADE'))
remarques = db.Column(db.Text)
pn = db.Column(db.Boolean)
session_appli = db.Column(db.String(50))
@@ -104,14 +122,15 @@ class VTest(db.Model):
__tablename__ = 'VTest'
__table_args__ = {'schema': 'geopaysages'}
- id = db.Column(db.Integer,primary_key=True)
+ id = db.Column(db.Integer, primary_key=True)
class TPhoto(db.Model):
__tablename__ = 't_photo'
__table_args__ = {'schema': 'geopaysages'}
- id_photo = db.Column(db.Integer, primary_key=True, server_default=db.FetchedValue())
+ id_photo = db.Column(db.Integer, primary_key=True,
+ server_default=db.FetchedValue())
id_site = db.Column(db.ForeignKey('geopaysages.t_site.id_site'))
path_file_photo = db.Column(db.String)
id_role = db.Column(db.ForeignKey('utilisateurs.t_roles.id_role'))
@@ -119,11 +138,49 @@ class TPhoto(db.Model):
filter_date = db.Column(db.Date)
legende_photo = db.Column(db.String)
display_gal_photo = db.Column(db.Boolean)
- id_licence_photo = db.Column(db.ForeignKey('geopaysages.dico_licence_photo.id_licence_photo'))
+ id_licence_photo = db.Column(db.ForeignKey(
+ 'geopaysages.dico_licence_photo.id_licence_photo'))
+
+ dico_licence_photo = db.relationship(
+ 'DicoLicencePhoto', primaryjoin='TPhoto.id_licence_photo == DicoLicencePhoto.id_licence_photo', backref='t_photos')
+ t_role = db.relationship(
+ 'TRole', primaryjoin='TPhoto.id_role == TRole.id_role', backref='t_photos')
+ t_site = db.relationship(
+ 'TSite', primaryjoin='TPhoto.id_site == TSite.id_site', backref='t_photos')
+
+
+class Ville(db.Model):
+ __tablename__ = 'villes_france'
+ __table_args__ = {'schema': 'geopaysages'}
+
+ ville_id = db.Column(db.Integer, primary_key=True,
+ server_default=db.FetchedValue())
+ ville_departement = db.Column(db.String)
+ ville_slug = db.Column(db.String)
+ ville_nom = db.Column(db.String)
+ ville_nom_simple = db.Column(db.String)
+ ville_nom_reel = db.Column(db.String)
+ ville_nom_soundex = db.Column(db.String)
+ ville_nom_metaphone = db.Column(db.String)
+ ville_code_postal = db.Column(db.String)
+ ville_commune = db.Column(db.String)
+ ville_code_commune = db.Column(db.String)
+ ville_arrondissement = db.Column(db.Integer)
+ ville_canton = db.Column(db.String)
+ ville_amdi = db.Column(db.Integer)
+ ville_population_2010 = db.Column(db.Integer)
+ ville_population_1999 = db.Column(db.Integer)
+ ville_population_2012 = db.Column(db.Integer)
+ ville_densite_2010 = db.Column(db.Integer)
+ ville_surface = db.Column(db.Integer)
+ ville_longitude_deg = db.Column(db.Integer)
+ ville_latitude_deg = db.Column(db.Integer)
+ ville_longitude_grd = db.Column(db.String)
+ ville_latitude_grd = db.Column(db.String)
+ ville_latitude_dms = db.Column(db.String)
+ ville_zmin = db.Column(db.Integer)
+ ville_zmax = db.Column(db.Integer)
- dico_licence_photo = db.relationship('DicoLicencePhoto', primaryjoin='TPhoto.id_licence_photo == DicoLicencePhoto.id_licence_photo', backref='t_photos')
- t_role = db.relationship('TRole', primaryjoin='TPhoto.id_role == TRole.id_role', backref='t_photos')
- t_site = db.relationship('TSite', primaryjoin='TPhoto.id_site == TSite.id_site', backref='t_photos')
class GeographySerializationField(fields.String):
def _serialize(self, value, attr, obj):
@@ -145,37 +202,54 @@ def _deserialize(self, value, attr, data):
return None
#schemas#
+
+
class DicoThemeSchema(ma.ModelSchema):
class Meta:
- fields = ('id_theme','name_theme')
+ fields = ('id_theme', 'name_theme')
+
class DicoSthemeSchema(ma.ModelSchema):
class Meta:
model = DicoStheme
+
class CorThemeSthemeSchema(ma.ModelSchema):
class Meta:
fields = ('id_stheme_theme',)
+
class LicencePhotoSchema(ma.ModelSchema):
class Meta:
- fields =('id_licence_photo','name_licence_photo','description_licence_photo')
-
+ fields = ('id_licence_photo', 'name_licence_photo',
+ 'description_licence_photo')
+
class TPhotoSchema(ma.ModelSchema):
- dico_licence_photo = ma.Nested(LicencePhotoSchema)
+ dico_licence_photo = ma.Nested(LicencePhotoSchema)
+
class Meta:
model = TPhoto
-
+
+
class CorSthemeThemeSchema(ma.ModelSchema):
- dico_theme = ma.Nested(DicoThemeSchema,only=["id_theme","name_theme"] )
- dico_stheme = ma.Nested(DicoSthemeSchema,only=["id_stheme","name_stheme"] )
+ dico_theme = ma.Nested(DicoThemeSchema, only=["id_theme", "name_theme"])
+ dico_stheme = ma.Nested(DicoSthemeSchema, only=[
+ "id_stheme", "name_stheme"])
+
class Meta:
fields = ('dico_theme', 'dico_stheme')
#model = CorSthemeTheme
-
+
+
class TSiteSchema(ma.ModelSchema):
geom = GeographySerializationField(attribute='geom')
+
class Meta:
model = TSite
-
+
+
+class VilleSchema(ma.ModelSchema):
+ class Meta:
+ fields = ('ville_nom',)
+
diff --git a/front-backOffice/src/app/add-photo/add-photo.component.html b/front-backOffice/src/app/add-photo/add-photo.component.html
index b0e10b95..134b2d89 100644
--- a/front-backOffice/src/app/add-photo/add-photo.component.html
+++ b/front-backOffice/src/app/add-photo/add-photo.component.html
@@ -1,11 +1,16 @@
-
+
+
diff --git a/front-backOffice/src/app/add-site/add-site.component.scss b/front-backOffice/src/app/add-site/add-site.component.scss
index 90b8a81a..402ac916 100644
--- a/front-backOffice/src/app/add-site/add-site.component.scss
+++ b/front-backOffice/src/app/add-site/add-site.component.scss
@@ -98,28 +98,6 @@
margin-left: 15px
}
-.modal-body {
- padding: 20px
-}
-
-.modal-header {
- padding: 10px;
- color: white;
- display: flex;
- justify-content: center;
- background-color: #ff6666
-}
-
-.cancel-btn {
- background-color: white;
- border: 1px solid black;
- box-shadow: none;
- padding: 4px 38px;
- text-transform: uppercase;
- font-size: 13px;
- width: fit-content;
- outline: none
-}
.inner-photo {
position: relative;
diff --git a/front-backOffice/src/app/add-site/add-site.component.ts b/front-backOffice/src/app/add-site/add-site.component.ts
index b79ac708..11fe518f 100644
--- a/front-backOffice/src/app/add-site/add-site.component.ts
+++ b/front-backOffice/src/app/add-site/add-site.component.ts
@@ -3,9 +3,9 @@ import { SitesService } from '../services/sites.service';
import { HttpEventType } from '@angular/common/http';
import { Router, ActivatedRoute } from '@angular/router';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
-import { tileLayer, latLng, Map } from 'leaflet';
-import { LatlngValidator } from '../shared/latlng-validator';
+import { FormGroup } from '@angular/forms';
+import { tileLayer, latLng, Map, marker, Layer } from 'leaflet';
+import { FormService } from '../services/form.service';
import { Conf } from './../config';
import * as L from 'leaflet';
import * as _ from 'lodash';
@@ -74,10 +74,12 @@ export class AddSiteComponent implements OnInit {
deleted_photos = [];
photoRequired = false;
new_photos = [];
+ marker: Layer[] = [];
+ center: any;
constructor(
private sitesService: SitesService,
- private formBuilder: FormBuilder,
+ public formService: FormService,
protected router: Router,
private route: ActivatedRoute,
private modalService: NgbModal,
@@ -87,12 +89,13 @@ export class AddSiteComponent implements OnInit {
ngOnInit() {
this.id_site = this.route.snapshot.params['id'];
+ this.initForm();
if (this.id_site) {
+
this.getSite(this.id_site);
this.submit_btn_text = 'Modifier';
} else {
this.edit_btn = true;
- this.initForm();
}
this.sitesService.getThemes()
.subscribe(
@@ -107,7 +110,6 @@ export class AddSiteComponent implements OnInit {
);
}
);
-
}
onMapReady(map: Map) {
@@ -154,6 +156,9 @@ export class AddSiteComponent implements OnInit {
onDrawReady(drawControl) {
this.drawControl = drawControl;
+ if (this.id_site) {
+ this.map.removeControl(this.drawControl);
+ }
}
onFileSelected(event) {
@@ -210,7 +215,6 @@ export class AddSiteComponent implements OnInit {
this.photos.push(photo);
}
-
/*
uploadImage() {
console.log('this.selectedFile,', this.selectedFiles);
@@ -246,7 +250,7 @@ export class AddSiteComponent implements OnInit {
this.sitesService.addPhotos(photosData).subscribe(
(event) => {
if (event.type === HttpEventType.UploadProgress) {
- console.log('resUplod', event.loaded);
+ // console.log('resUplod', event.loaded);
}
},
err => {
@@ -274,7 +278,6 @@ export class AddSiteComponent implements OnInit {
});
this.sitesService.addThemes({ 'data': stheme_theme }).subscribe(
(response) => {
- console.log('response', response);
this.router.navigate(['sites']);
}
);
@@ -287,52 +290,39 @@ export class AddSiteComponent implements OnInit {
};
}
-
getSite(id_site) {
this.sitesService.getsiteById(id_site).subscribe(
(site) => {
this.site = site.site[0];
_.forEach(site.photos, (photo) => {
- this.photos.push({ 'id_photo': photo.id, 'imgUrl': Conf.serveurUrl + photo.sm });
+ this.photos.push({ 'id_photo': photo.id, 'imgUrl': Conf.staticPicturesUrl + photo.sm });
this.initPhotos = this.photos;
});
},
(err) => console.log('err', err),
() => {
- this.loadForm = true;
- this.siteForm = this.formBuilder.group({
- name_site: [this.site.name_site, Validators.required],
- desc_site: [this.site.desc_site, Validators.required],
- testim_site: [this.site.testim_site, Validators.required],
- publish_site: [this.site.publish_site, Validators.required],
- lng: [this.site.geom[1].toFixed(6), LatlngValidator.lng],
- lat: [this.site.geom[0].toFixed(6), LatlngValidator.lat],
- id_theme: [this.site.themes, Validators.required],
- id_stheme: [this.site.subthemes, Validators.required],
- code_city_site: [this.site.code_city_site, Validators.required],
- notice: [null],
+ this.siteForm.patchValue({
+ 'name_site': this.site.name_site,
+ 'desc_site': this.site.desc_site,
+ 'testim_site': this.site.testim_site,
+ 'publish_site': this.site.publish_site,
+ 'lng': this.site.geom[1].toFixed(6),
+ 'lat': this.site.geom[0].toFixed(6),
+ 'id_theme': this.site.themes,
+ 'id_stheme': this.site.subthemes,
+ 'code_city_site': this.site.code_city_site,
+ 'notice': null,
});
this.siteForm.disable();
- this.themes_onChange();
}
);
}
initForm() {
this.loadForm = true;
- this.siteForm = this.formBuilder.group({
- name_site: [null, Validators.required],
- desc_site: [null, Validators.required],
- testim_site: [null, Validators.required],
- publish_site: [false, Validators.required],
- lng: [null, LatlngValidator.lng],
- lat: [null, LatlngValidator.lat],
- id_theme: [null, Validators.required],
- id_stheme: [null, Validators.required],
- code_city_site: [null, Validators.required],
- notice: [null],
- });
+ this.siteForm = this.formService.initFormSite();
this.themes_onChange();
+ this.latlan_onChange();
}
themes_onChange() {
@@ -354,6 +344,48 @@ export class AddSiteComponent implements OnInit {
});
}
+ latlan_onChange() {
+ this.siteForm.controls['lat'].statusChanges
+ .subscribe(() => {
+ if (this.siteForm.controls['lat'].valid && this.siteForm.controls['lng'].valid) {
+ this.marker = [];
+ this.marker.push(marker(latLng(this.siteForm.controls['lat'].value, this.siteForm.controls['lng'].value), {
+ icon: L.icon({
+ iconSize: [25, 41],
+ iconAnchor: [13, 41],
+ iconUrl: './assets/marker-icon.png',
+ shadowUrl: './assets/marker-shadow.png'
+ })
+ }));
+ this.center = this.marker[0]._latlng;
+ this.map.removeControl(this.drawControl);
+ } else if (this.siteForm.controls['lat'].invalid || this.siteForm.controls['lng'].invalid) {
+ this.marker = [];
+ this.map.addControl(this.drawControl);
+ }
+ });
+ this.siteForm.controls['lng'].statusChanges
+ .subscribe(() => {
+ this.marker = [];
+ if (this.siteForm.controls['lat'].valid && this.siteForm.controls['lng'].valid) {
+ this.marker.push(marker(latLng(this.siteForm.controls['lat'].value, this.siteForm.controls['lng'].value), {
+ icon: L.icon({
+ iconSize: [25, 41],
+ iconAnchor: [13, 41],
+ iconUrl: './assets/marker-icon.png',
+ shadowUrl: './assets/marker-shadow.png'
+ })
+ }));
+ this.center = this.marker[0]._latlng;
+ this.map.removeControl(this.drawControl);
+ } else if (this.siteForm.controls['lat'].invalid || this.siteForm.controls['lng'].invalid) {
+ this.marker = [];
+ this.map.addControl(this.drawControl);
+ }
+ });
+ }
+
+
patchSite(siteJson, themes, sthemes) {
siteJson.id_site = this.id_site;
_.forEach(this.photos, (photo) => {
@@ -374,9 +406,11 @@ export class AddSiteComponent implements OnInit {
editForm() {
this.edit_btn = !this.edit_btn;
if (!this.edit_btn) {
+ this.map.removeControl(this.drawControl);
this.edit_btn_text = 'ÉDITER';
this.siteForm.disable();
} else {
+ this.map.addControl(this.drawControl);
this.edit_btn_text = 'Annuler';
this.siteForm.enable();
}
diff --git a/front-backOffice/src/app/app-routing.module.ts b/front-backOffice/src/app/app-routing.module.ts
index 97b49df2..64535de5 100644
--- a/front-backOffice/src/app/app-routing.module.ts
+++ b/front-backOffice/src/app/app-routing.module.ts
@@ -4,10 +4,13 @@ import { Routes, RouterModule } from '@angular/router';
import { LoginPageComponent } from './login-page/login-page.component';
import { ManageSitesComponent } from './manage-sites/manage-sites.component';
import { AddSiteComponent } from './add-site/add-site.component';
+import { GalleryComponent } from './gallery/gallery.component';
+
const routes: Routes = [
{ path: 'login', component: LoginPageComponent },
{ path: 'sites', component: ManageSitesComponent },
+ { path: 'gallery', component: GalleryComponent },
{ path: 'sites/form', component: AddSiteComponent },
{ path: 'sites/details/:id', component: AddSiteComponent},
{ path: '', component: LoginPageComponent },
diff --git a/front-backOffice/src/app/app.module.ts b/front-backOffice/src/app/app.module.ts
index b565d4d2..f0cbb3d9 100644
--- a/front-backOffice/src/app/app.module.ts
+++ b/front-backOffice/src/app/app.module.ts
@@ -15,11 +15,12 @@ import { ManageSitesComponent } from './manage-sites/manage-sites.component';
import { LeafletModule } from '@asymmetrik/ngx-leaflet';
import { LeafletDrawModule } from '@asymmetrik/ngx-leaflet-draw';
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
-import { HomePageComponent } from './home-page/home-page.component';
import { AddSiteComponent } from './add-site/add-site.component';
import { SitesService } from './services/sites.service';
+import { FormService } from './services/form.service';
import { AddPhotoComponent } from './add-photo/add-photo.component';
import { NgSelectModule } from '@ng-select/ng-select';
+import { GalleryComponent } from './gallery/gallery.component';
@@ -31,9 +32,9 @@ import { NgSelectModule } from '@ng-select/ng-select';
HeaderComponent,
FormErrorComponent,
ManageSitesComponent,
- HomePageComponent,
AddSiteComponent,
AddPhotoComponent,
+ GalleryComponent,
],
imports: [
BrowserModule,
@@ -50,6 +51,7 @@ import { NgSelectModule } from '@ng-select/ng-select';
providers: [
LoginService,
SitesService,
+ FormService,
{
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
diff --git a/front-backOffice/src/app/gallery/gallery.component.html b/front-backOffice/src/app/gallery/gallery.component.html
new file mode 100644
index 00000000..956502b3
--- /dev/null
+++ b/front-backOffice/src/app/gallery/gallery.component.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/front-backOffice/src/app/gallery/gallery.component.scss b/front-backOffice/src/app/gallery/gallery.component.scss
new file mode 100644
index 00000000..7fc2e418
--- /dev/null
+++ b/front-backOffice/src/app/gallery/gallery.component.scss
@@ -0,0 +1,60 @@
+.picture {
+ padding: 20px 10px 0px 10px;
+ overflow: hidden;
+ position: relative;
+}
+
+
+.thumb {
+ margin-bottom: 20px;
+ padding: 0 10px;
+}
+
+.photos {
+ display: flex;
+ -webkit-flex-wrap: wrap;
+ flex-wrap: wrap;
+ padding-top: 30px;
+ height: fit-content;
+}
+
+.site-title {
+ text-align: left;
+ width: 100%;
+ padding: 10px 15px;
+ font-size: 14px;
+ font-weight: 600;
+ color: #dedede;
+ background-color: #434343;
+ border: 1px solid #7d7b7b;
+}
+
+.site-title:hover {
+ color: white;
+ background-color: #2f2f2f;
+}
+
+.site-title:focus {
+ color: white;
+ background-color: #2f2f2f;
+ border: 1px solid #7d7b7b;
+ outline: 0;
+}
+
+.list-site {
+ background: rgba(0, 0, 0, .8);
+ padding: 30px 15px;
+
+}
+
+.inner {
+ min-height: calc(100vh - 98px);
+}
+
+.icon-star-full {
+ position: absolute;
+ z-index: 999;
+ top: 5px;
+ right: 15px;
+ color: #00188F;
+}
diff --git a/front-backOffice/src/app/home-page/home-page.component.spec.ts b/front-backOffice/src/app/gallery/gallery.component.spec.ts
similarity index 55%
rename from front-backOffice/src/app/home-page/home-page.component.spec.ts
rename to front-backOffice/src/app/gallery/gallery.component.spec.ts
index e1803322..01541ffb 100644
--- a/front-backOffice/src/app/home-page/home-page.component.spec.ts
+++ b/front-backOffice/src/app/gallery/gallery.component.spec.ts
@@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-import { HomePageComponent } from './home-page.component';
+import { GalleryComponent } from './gallery.component';
-describe('HomePageComponent', () => {
- let component: HomePageComponent;
- let fixture: ComponentFixture;
+describe('GalleryComponent', () => {
+ let component: GalleryComponent;
+ let fixture: ComponentFixture;
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ HomePageComponent ]
+ declarations: [ GalleryComponent ]
})
.compileComponents();
}));
beforeEach(() => {
- fixture = TestBed.createComponent(HomePageComponent);
+ fixture = TestBed.createComponent(GalleryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
diff --git a/front-backOffice/src/app/gallery/gallery.component.ts b/front-backOffice/src/app/gallery/gallery.component.ts
new file mode 100644
index 00000000..feb84483
--- /dev/null
+++ b/front-backOffice/src/app/gallery/gallery.component.ts
@@ -0,0 +1,63 @@
+import { Component, OnInit } from '@angular/core';
+import { SitesService } from '../services/sites.service';
+import { Conf } from './../config';
+import * as _ from 'lodash';
+
+@Component({
+ selector: 'app-gallery',
+ templateUrl: './gallery.component.html',
+ styleUrls: ['./gallery.component.scss']
+})
+export class GalleryComponent implements OnInit {
+
+ sitesLoaded = false;
+ sites: any;
+ isMainPhoto;
+ photos: any;
+ constructor(
+ public sitesService: SitesService,
+ ) { }
+
+ ngOnInit() {
+
+ this.sitesService.getAllSites().subscribe(
+ (sites) => {
+ this.sites = sites;
+ this.getPhotosSite(this.sites[0].id_site);
+ },
+ (error) => console.log('getGallery error', error),
+ );
+
+ }
+
+ getPhotosSite(id) {
+ this.sitesService.getsiteById(id).subscribe(
+ (data) => {
+ this.photos = data.photos;
+ _.map(this.photos, (photo) => {
+ if (photo.id_photo === data.site[0].main_photo) {
+ photo.main_photo = true;
+ }
+ photo.sm = Conf.staticPicturesUrl + photo.sm;
+ photo.cssClass = 'gallery';
+
+ });
+ this.sitesLoaded = true;
+ }
+ );
+ }
+
+ updatePhotos(event) {
+ _.map(this.sites, (site) => {
+ if (event.type === 'delete') {
+ _.remove(site.photos, (item: any) => {
+ return item.id_photo === event.data;
+ });
+ }
+ if (event.type === 'update') {
+ this.getPhotosSite(event.data.id_site);
+ }
+ });
+ }
+
+}
diff --git a/front-backOffice/src/app/header/header.component.html b/front-backOffice/src/app/header/header.component.html
index cc1fbba8..cfd22192 100644
--- a/front-backOffice/src/app/header/header.component.html
+++ b/front-backOffice/src/app/header/header.component.html
@@ -12,9 +12,9 @@
Gestion sites photos
- Gestion page d'acceuil
+ Gestion gallerie photos
-
+
diff --git a/front-backOffice/src/app/header/header.component.scss b/front-backOffice/src/app/header/header.component.scss
index 0d05102b..45c3f800 100644
--- a/front-backOffice/src/app/header/header.component.scss
+++ b/front-backOffice/src/app/header/header.component.scss
@@ -29,7 +29,7 @@
}
li {
- padding: 2px 14px;
+ padding: 2px 10px;
}
.navbar-brand {
@@ -69,5 +69,10 @@ li {
}
.icon-logout{
- font-size: 22px
+ font-size: 26px
+}
+.logout{
+ padding-bottom: 3px;
+ padding-left: 0px;
+ padding-right: 20px
}
\ No newline at end of file
diff --git a/front-backOffice/src/app/home-page/home-page.component.html b/front-backOffice/src/app/home-page/home-page.component.html
deleted file mode 100644
index a05daf2f..00000000
--- a/front-backOffice/src/app/home-page/home-page.component.html
+++ /dev/null
@@ -1,163 +0,0 @@
-
-
-
BLOC 1
-
-
-
-
-
-
-
BLOC 2
-
-
-
-
-
-
BLOC 3
-
-
-
-
-
-
BLOC 4
-
-
-
-
-
-
BLOC 5
-
-
-
-
-
-
-
-
BLOC 6
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/front-backOffice/src/app/home-page/home-page.component.scss b/front-backOffice/src/app/home-page/home-page.component.scss
deleted file mode 100644
index e69de29b..00000000
diff --git a/front-backOffice/src/app/home-page/home-page.component.ts b/front-backOffice/src/app/home-page/home-page.component.ts
deleted file mode 100644
index 4f495951..00000000
--- a/front-backOffice/src/app/home-page/home-page.component.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-
-@Component({
- selector: 'app-home-page',
- templateUrl: './home-page.component.html',
- styleUrls: ['./home-page.component.scss']
-})
-export class HomePageComponent implements OnInit {
-
- constructor() { }
-
- ngOnInit() {
- }
-
-}
diff --git a/front-backOffice/src/app/services/form.service.ts b/front-backOffice/src/app/services/form.service.ts
new file mode 100644
index 00000000..a0eca2c1
--- /dev/null
+++ b/front-backOffice/src/app/services/form.service.ts
@@ -0,0 +1,40 @@
+import { Injectable } from '@angular/core';
+import { FormGroup, FormBuilder, Validators } from '@angular/forms';
+import { LatlngValidator } from '../shared/latlng-validator';
+@Injectable()
+export class FormService {
+ public disabled = true;
+
+ constructor(private _fb: FormBuilder) { }
+
+ initFormSite(): FormGroup {
+ const formSite = this._fb.group({
+ name_site: [null, Validators.required],
+ desc_site: [null, Validators.required],
+ testim_site: [null, Validators.required],
+ publish_site: [false, Validators.required],
+ lng: [null, {validators: LatlngValidator.lng, updateOn : 'blur'}],
+ lat: [null, {validators: LatlngValidator.lat, updateOn : 'blur'}],
+ id_theme: [null, Validators.required],
+ id_stheme: [null, Validators.required],
+ code_city_site: [null, Validators.required],
+ notice: [null],
+ });
+ return formSite;
+ }
+
+
+ initFormPhoto(): FormGroup {
+ const formPhoto = this._fb.group({
+ id_role: [null, Validators.required],
+ display_gal_photo: [false, Validators.required],
+ id_licence_photo: [null, Validators.required],
+ date_photo: [null, Validators.required],
+ legende_photo: [null, Validators.required],
+ filter_date: [null, Validators.required],
+ photo_file: [null],
+ main_photo: [null],
+ });
+ return formPhoto;
+ }
+}
diff --git a/front-backOffice/src/app/services/sites.service.ts b/front-backOffice/src/app/services/sites.service.ts
index 5df21604..cd11e93a 100644
--- a/front-backOffice/src/app/services/sites.service.ts
+++ b/front-backOffice/src/app/services/sites.service.ts
@@ -24,6 +24,10 @@ export class SitesService {
return this.http.post(Conf.apiUrl + 'addPhotos', image, { withCredentials: true, reportProgress: true, observe: 'events' });
}
+ updatePhoto(image) {
+ return this.http.patch(Conf.apiUrl + 'updatePhoto', image, { withCredentials: true, reportProgress: true, observe: 'events' });
+ }
+
deletePhotos(images) {
return this.http.post(Conf.apiUrl + 'deletePhotos', images, { withCredentials: true });
}
@@ -55,6 +59,10 @@ export class SitesService {
addThemes(themes) {
return this.http.post(Conf.apiUrl + 'addThemes', themes, { withCredentials: true });
}
+
+ getgallery() {
+ return this.http.get(Conf.apiUrl + 'gallery');
+ }
}
diff --git a/front-backOffice/src/assets/css/icomoon.css b/front-backOffice/src/assets/css/icomoon.css
index ac7edc71..a78685dc 100644
--- a/front-backOffice/src/assets/css/icomoon.css
+++ b/front-backOffice/src/assets/css/icomoon.css
@@ -145,3 +145,10 @@
.icon-cancel-circle:before {
content: "\e91d";
}
+
+.icon-star-full:before {
+ content: "\e91e";
+}
+.icon-eye-blocked:before {
+ content: "\e91f";
+}
\ No newline at end of file
diff --git a/front-backOffice/src/assets/fonts/icomoon.eot b/front-backOffice/src/assets/fonts/icomoon.eot
index 227b2690..c431dee8 100644
Binary files a/front-backOffice/src/assets/fonts/icomoon.eot and b/front-backOffice/src/assets/fonts/icomoon.eot differ
diff --git a/front-backOffice/src/assets/fonts/icomoon.svg b/front-backOffice/src/assets/fonts/icomoon.svg
index 39b6bc36..64510b95 100644
--- a/front-backOffice/src/assets/fonts/icomoon.svg
+++ b/front-backOffice/src/assets/fonts/icomoon.svg
@@ -37,4 +37,6 @@
+
+
\ No newline at end of file
diff --git a/front-backOffice/src/assets/fonts/icomoon.ttf b/front-backOffice/src/assets/fonts/icomoon.ttf
index 5d3a26a6..a07b0c26 100644
Binary files a/front-backOffice/src/assets/fonts/icomoon.ttf and b/front-backOffice/src/assets/fonts/icomoon.ttf differ
diff --git a/front-backOffice/src/assets/fonts/icomoon.woff b/front-backOffice/src/assets/fonts/icomoon.woff
index adb2d98d..746dac64 100644
Binary files a/front-backOffice/src/assets/fonts/icomoon.woff and b/front-backOffice/src/assets/fonts/icomoon.woff differ
diff --git a/front-backOffice/src/assets/fonts/icomoon.woff2 b/front-backOffice/src/assets/fonts/icomoon.woff2
index dde2247b..9ff2c51b 100644
Binary files a/front-backOffice/src/assets/fonts/icomoon.woff2 and b/front-backOffice/src/assets/fonts/icomoon.woff2 differ
diff --git a/front-backOffice/src/index.html b/front-backOffice/src/index.html
index e9ce9eb3..c547850b 100644
--- a/front-backOffice/src/index.html
+++ b/front-backOffice/src/index.html
@@ -3,7 +3,7 @@
FrontBackOffice
-
+
diff --git a/front-backOffice/src/styles.scss b/front-backOffice/src/styles.scss
index 4c41da6b..2b5788bc 100644
--- a/front-backOffice/src/styles.scss
+++ b/front-backOffice/src/styles.scss
@@ -7,14 +7,19 @@
@import './assets/css/custom_ngx_table.scss';
.custom-modal {
- .modal-content{
- min-width: 600px;
+ .modal-content {
+ min-width: 600px;
}
-}
-.delete-modal {
- .modal-content{
- min-width: 300px;
+
+ .modal-body {
+ padding: 20px
}
+
+ .modal-header {
+ padding: 15px;
+ background-color: #f8f9fa
+ }
+
}
.switch {
@@ -108,12 +113,14 @@ button:focus {
font-style: italic;
font-size: 14px;
}
-ng-select{
- .ng-placeholder{
+
+ng-select {
+ .ng-placeholder {
font-style: italic;
font-size: 14px;
}
}
+
.form-control {
border: none;
border-radius: 0px;
@@ -140,6 +147,7 @@ ng-select{
font-size: 13px;
width: fit-content;
}
+
.red-btn {
background-color: var(--color-red);
color: #fff;
@@ -148,7 +156,7 @@ ng-select{
text-transform: uppercase;
font-size: 13px;
width: fit-content;
-}
+}
.progress-bar {
background-color: var(--color-primary);
@@ -226,7 +234,36 @@ h6 .light {
}
}
+.delete-modal {
-.custom-popup{
+ .modal-content {
+ min-width: 300px;
+ }
+
+ .modal-body {
+ padding: 20px
+ }
+
+ .modal-header {
+ padding: 10px;
+ color: white;
+ display: flex;
+ justify-content: center;
+ background-color: #ff6666
+ }
+
+ .cancel-btn {
+ background-color: white;
+ border: 1px solid black;
+ box-shadow: none;
+ padding: 4px 38px;
+ text-transform: uppercase;
+ font-size: 13px;
+ width: fit-content;
+ outline: none
+ }
+}
+
+.custom-popup {
bottom: 26px !important;
- }
\ No newline at end of file
+}