Skip to content

Commit

Permalink
Merge pull request #3 from NaturalSolutions/fix-img-src-with-imaginary
Browse files Browse the repository at this point in the history
fix img src with imaginary
  • Loading branch information
Jeje2201 authored Jul 18, 2022
2 parents 89532e6 + 48b68c1 commit 046d73c
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 26 deletions.
7 changes: 1 addition & 6 deletions backend/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def returnAllSites():
if main_photo:
photo_schema = models.TPhotoSchema()
main_photo = photo_schema.dump(main_photo)
site['main_photo'] = utils.getThumbnail(main_photo).get('output_name')
site['main_photo'] = main_photo.get("path_file_photo") #utils.getThumbnail(main_photo).get('output_name')
else:
site["main_photo"] = "no_photo"

Expand Down Expand Up @@ -164,9 +164,6 @@ def returnSiteById(id_site):
site[0]['themes'] = themes_list
site[0]['subthemes'] = subthemes_list

for photo in dump_photos:
photo['sm'] = utils.getThumbnail(photo).get('output_name'),

photos = dump_photos
return jsonify(site=site, photos=photos), 200

Expand All @@ -175,8 +172,6 @@ def returnSiteById(id_site):
def gallery():
get_photos = models.TPhoto.query.order_by('id_site').all()
dump_photos = photo_schema.dump(get_photos)
for photo in dump_photos:
photo['sm'] = utils.getThumbnail(photo).get('output_name')

return jsonify(dump_photos), 200

Expand Down
2 changes: 1 addition & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Exemple :
```
export const Conf = {
apiUrl: '/api/',
staticPicturesUrl: '/static/data/images/',
img_srv: '/static/data/images/',
customFiles: '/static/custom/',
id_application: 1,
ign_Key: 'ign key',
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Désampler et éditer le fichier de configuration

> Pour utiliser l'utilisateur \"admin\" créé par défaut, il faut renseigner `id_application : 1`
> Pour `apiUrl` et `staticPicturesUrl`, bien mettre <http://xxx.xxx.xxx.xxx>, si utilisation d'une adresse IP
> Pour `apiUrl` et `img_srv`, bien mettre <http://xxx.xxx.xxx.xxx>, si utilisation d'une adresse IP
**2. Lancer l'installation automatique de l'application :**
```
Expand Down
6 changes: 3 additions & 3 deletions front-backOffice/src/app/add-site/add-site.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,12 @@ export class AddSiteComponent implements OnInit, OnDestroy {
_.forEach(site.photos, (photo) => {
this.initPhotos.push({
id_photo: photo.id_photo,
imgUrl: Conf.staticPicturesUrl + photo.sm,
imgUrl: Conf.img_srv + 'crop?file=' + photo.path_file_photo + '&width=120&height=120&type=jpeg',
name: photo.path_file_photo,
});
this.photos.push({
id_photo: photo.id_photo,
imgUrl: Conf.staticPicturesUrl + photo.sm,
imgUrl: Conf.img_srv + 'crop?file=' + photo.path_file_photo + '&width=120&height=120&type=jpeg',
name: photo.path_file_photo,
});
});
Expand Down Expand Up @@ -648,7 +648,7 @@ export class AddSiteComponent implements OnInit, OnDestroy {
_.remove(this.new_photos, (item) => {
return item === photo;
});
photo.imgUrl = photo.imgUrl.replace(Conf.staticPicturesUrl, '');
photo.imgUrl = photo.imgUrl.replace(Conf.img_srv, '');
this.deleted_photos.push(photo);
}

Expand Down
2 changes: 1 addition & 1 deletion front-backOffice/src/app/config.ts.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const Conf = {
apiUrl: '<server_name>/api/',
staticPicturesUrl: '<server_name>/pictures/',
img_srv: '<server_name>/pictures/',
customFiles: '<server_name>/static/custom/',
id_application: id_app,
ign_Key : 'ign key',
Expand Down
2 changes: 1 addition & 1 deletion front-backOffice/src/app/gallery/gallery.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class GalleryComponent implements OnInit {
if (photo.id_photo === data.site[0].main_photo) {
photo.main_photo = true;
}
photo.sm = Conf.staticPicturesUrl + photo.sm;
photo.sm = Conf.img_srv + 'crop?file=' + photo.path_file_photo + '&width=150&height=150&type=jpeg';
photo.cssClass = 'gallery';
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[reorderable]="reorderable" [selectionType]="'single'" (activate)="onCenterChange($event)" (select)='onSelect($event)'>
<ngx-datatable-column name="Photo">
<ng-template let-row="row" ngx-datatable-cell-template>
<img class="main-photo" src="{{row.main_photo}}" alt="" width="80">
<img class="main-photo" src="{{row.main_photo}}" alt="">
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column prop="ref_site" name="Référence" width="100">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export class ManageSitesComponent implements OnInit, OnDestroy {
this.siteService.getAllSites().subscribe(
(sites) => {
_.forEach(sites, (site) => {
site.main_photo = Conf.staticPicturesUrl + site.main_photo;
const newMarker = marker(site.geom, {
icon: L.icon({
iconSize: [ 25, 41 ],
Expand All @@ -85,12 +84,13 @@ export class ManageSitesComponent implements OnInit, OnDestroy {
'<div class="title">' +
site.name_site +
'</div>' +
'<div class="img-inner"> <img " src=' +
site.main_photo +
'<div class=""> <img src=' +
Conf.img_srv + 'crop?file=' + site.main_photo + '&width=80&height=80&type=jpeg' +
'> </div>';
const customOptions = {
className: 'custom-popup'
};
site.main_photo = Conf.img_srv + 'crop?file=' + site.main_photo + '&width=50&height=50&type=jpeg'
site.marker = newMarker.bindPopup(customPopup, customOptions);
newMarker
.bindPopup(customPopup, customOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@
(activate)="onCenterChange($event)"
(select)="onSelect($event)"
>
<ngx-datatable-column prop="photo" name="Photo" width="100">
<ngx-datatable-column prop="photo" name="Logo" width="100">
<ng-template let-row="row" ngx-datatable-cell-template>
<img
class="main-photo"
src="{{ row.observatory.photo }}"
alt=""
width="80"
src="{{ row.observatory.logo }}"
/>
</ng-template>
</ngx-datatable-column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class ObservatoriesComponent implements OnInit, OnDestroy {
this.observatoriesSrv.getAll().subscribe(
(items) => {
_.forEach(items, (observatory) => {
observatory.photo = Conf.staticPicturesUrl + observatory.photo
observatory.logo = Conf.img_srv + 'crop?file=' + observatory.logo + '&width=50&height=50'
/* const newMarker = Marker(observatory.geom, {
icon: L.icon({
iconSize: [25, 41],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<div class="col">
<label class="label">Photo</label>
<div *ngIf="observatory?.photo">
<a [href]="photoBaseUrl + observatory?.photo" target="_blank">
<a [href]="photoBaseUrl + 'convert?file='+ observatory?.photo + '&type=jpeg'" target="_blank">
{{ observatory?.photo }} <i class="icon-eye"></i>
</a>
</div>
Expand Down Expand Up @@ -120,7 +120,7 @@
<div class="col">
<label class="label">Logo</label>
<div *ngIf="observatory?.logo">
<a [href]="photoBaseUrl + observatory?.logo" target="_blank">
<a [href]="photoBaseUrl + 'blur?file='+ observatory?.logo + '&sigma=0.2'" target="_blank">
{{ observatory?.logo }} <i class="icon-eye"></i>
</a>
</div>
Expand Down
4 changes: 2 additions & 2 deletions front-backOffice/src/app/observatory/observatory.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ObservatoryComponent implements OnInit {
zoom: 10,
center: latLng(Conf.map_lat_center, Conf.map_lan_center),
};
photoBaseUrl = Conf.staticPicturesUrl;
photoBaseUrl = Conf.img_srv;
drawOptions = {
position: 'topleft',
draw: {
Expand Down Expand Up @@ -448,7 +448,7 @@ export class ObservatoryComponent implements OnInit {
_.remove(this.new_photos, (item) => {
return item === photo;
});
photo.imgUrl = photo.imgUrl.replace(Conf.staticPicturesUrl, '');
photo.imgUrl = photo.imgUrl.replace(Conf.img_srv, '');
this.deleted_photos.push(photo);
}

Expand Down

0 comments on commit 046d73c

Please sign in to comment.