Skip to content

Commit

Permalink
merge: merge interface and type
Browse files Browse the repository at this point in the history
merge site_group.service.ts
delete site.service.ts
add interfaces
re arrange code from branch front-site-interface

Reviewed-by: andriacap
[Refs ticket]: #4
  • Loading branch information
andriacap committed Jan 19, 2023
1 parent 97ae9bb commit ee5818d
Show file tree
Hide file tree
Showing 15 changed files with 436 additions and 316 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,27 @@ def upgrade():
schema=monitorings_schema,
)

op.create_check_constraint(
"ck_bib_type_site_id_nomenclature",
"bib_type_site",
f"{nomenclature_schema}.check_nomenclature_type_by_mnemonique(id_nomenclature,'TYPE_SITE')",
schema=monitorings_schema)
# FIXME: if sqlalchemy >= 1.4.32, it should work with postgresql_not_valid=True: cleaner
# op.create_check_constraint(
# "ck_bib_type_site_id_nomenclature_type_site",
# "bib_type_site",
# f"{nomenclature_schema}.check_nomenclature_type_by_mnemonique(id_nomenclature_type_site,'TYPE_SITE')",
# schema=monitorings_schema,
# postgresql_not_valid=True
# )
statement = sa.text(
f"""
ALTER TABLE {monitorings_schema}.bib_type_site
ADD
CONSTRAINT ck_bib_type_site_id_nomenclature_type_site CHECK (
{nomenclature_schema}.check_nomenclature_type_by_mnemonique(
id_nomenclature_type_site, 'TYPE_SITE' :: character varying
)
) NOT VALID
"""
)
op.execute(statement)


def downgrade():
op.drop_table("bib_type_site", schema=monitorings_schema)
6 changes: 3 additions & 3 deletions backend/gn_module_monitoring/monitoring/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class Meta:


geometry = fields.Method("serialize_geojson", dump_only=True)
properties = fields.Method("group_properties_geojson")
# properties = fields.Method("group_properties_geojson")

def group_properties_geojson(self, obj):
return {field: getattr(obj,field) for field in self.fields.keys() if field not in ("geometry","properties")}
# def group_properties_geojson(self, obj):
# return {field: getattr(obj,field) for field in self.fields.keys() if field not in ("geometry","properties")}

def serialize_geojson(self, obj):
if obj.geom_geojson is not None:
Expand Down
54 changes: 54 additions & 0 deletions frontend/app/class/monitoring-site.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { ISite, JsonData } from "../interfaces/geom";
import { GeoJSON } from "geojson";

export class MonitoringSite implements ISite {
altitude_max: number;
altitude_min: number;
base_site_code: string;
base_site_description?: string;
base_site_name: string;
data: JsonData;
first_use_date: string;
geometry: GeoJSON.FeatureCollection;
id_base_site: number;
id_nomenclature_type_site?: number;
last_visit?: Date;
meta_create_date: Date;
meta_update_date: Date;
nb_visits: number;
uuid_base_site: string;

constructor(
altitude_max: number,
altitude_min: number,
base_site_code: string,
base_site_description: string,
base_site_name: string,
data: JsonData,
geometry: GeoJSON.FeatureCollection,
first_use_date: string,
id_base_site: number,
id_nomenclature_type_site: number,
last_visit: Date,
meta_create_date: Date,
meta_update_date: Date,
nb_visits: number,
uuid_base_site: string
) {
this.altitude_max = altitude_max;
this.altitude_min = altitude_min;
this.base_site_code = base_site_code;
this.base_site_description = base_site_description;
this.base_site_name = base_site_name;
this.data = data;
this.first_use_date = first_use_date;
this.geometry = geometry;
this.id_base_site = id_base_site;
this.id_nomenclature_type_site = id_nomenclature_type_site;
this.last_visit = last_visit;
this.meta_create_date = meta_create_date;
this.meta_update_date = meta_update_date;
this.nb_visits = nb_visits;
this.uuid_base_site = uuid_base_site;
}
}
36 changes: 36 additions & 0 deletions frontend/app/class/monitoring-sites-group.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { ISitesGroup, JsonData } from "../interfaces/geom";
import { GeoJSON } from "geojson";

export class MonitoringSitesGroup implements ISitesGroup {
id_sites_group: number;
sites_group_name: string;
sites_group_code: string;
sites_group_description: string;
geometry: GeoJSON.FeatureCollection;
data: JsonData;
nb_sites: number;
nb_visits: number;
uuid_sites_group: string; //FIXME: see if OK

constructor(
id_sites_group: number,
sites_group_name: string,
sites_group_code: string,
sites_group_description: string,
geometry: GeoJSON.FeatureCollection,
data: JsonData,
nb_sites: number,
nb_visits: number,
uuid_sites_group: string = "" //FIXME: see if OK
) {
this.id_sites_group = id_sites_group;
this.sites_group_name = sites_group_name;
this.sites_group_code = sites_group_code;
this.sites_group_description = sites_group_description;
this.geometry = geometry;
this.data = data;
this.nb_sites = nb_sites;
this.nb_visits = nb_visits;
this.uuid_sites_group = uuid_sites_group;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- <div *ngIf="child0 && row_save"> -->
<div *ngIf="rows">
<div *ngIf="rows">
<!-- <input
type="text"
style="padding:8px;margin:15px auto;width:30%;"
Expand All @@ -11,43 +11,46 @@
<button
class="btn btn-info"
(click)="displayFilter = !displayFilter"
matTooltip="{{displayFilter ? 'Cacher' : 'Afficher'}} les filtres"
><i class="fa fa-filter" aria-hidden="true"></i></button
matTooltip="{{ displayFilter ? 'Cacher' : 'Afficher' }} les filtres"
>
<!--TODO Revoir pour rendre générique le bouton "Ajouter" , avant : {{ (child0.template["label_art_undef_new"] || "") }}-->
<!-- TODO Revoir pour les droits pour pouvoir créer un groupe de site avec anciennement: *ngIf=obj.moduleCode && (currentUser['cruved_object'][child0.objectType] || currentUser['cruved']).C >= child0.cruved('C')" -->
<i class="fa fa-filter" aria-hidden="true"></i>
</button>
<!--TODO Revoir pour rendre générique le bouton "Ajouter" , avant : {{ (child0.template["label_art_undef_new"] || "") }}-->
<!-- TODO Revoir pour les droits pour pouvoir créer un groupe de site avec anciennement: *ngIf=obj.moduleCode && (currentUser['cruved_object'][child0.objectType] || currentUser['cruved']).C >= child0.cruved('C')" -->
<button
class="btn btn-success float-right"
(click)="navigateToAddChildren(null,null)"
><i class="fa fa-plus" aria-hidden="true"></i> Ajouter un nouveau groupe de site
</button
(click)="navigateToAddChildren(null, null)"
>
<i class="fa fa-plus" aria-hidden="true"></i> Ajouter un nouveau groupe de
site
</button>
</div>
<ngx-datatable
*ngIf="rows"
#table
class="material striped custom-dt"
[columnMode]="'force'"
[headerHeight]="'auto'"
[footerHeight]="50"
[rowHeight]="40"
[externalPaging]="true"
[count]="page.count"
[offset]="page.page"
[limit]="page.limit"
[rows]="rows"
[columns]="columns"
[selected]="selected"
selectionType="single"
(select)="onSelectEvent($event)"
[messages]= "{
emptyMessage: 'Pas de données disponibles',
totalMessage: 'total',
selectedMessage: 'selection'
}"
(page)="setPage($event)"
(sort)="onSortEvent($event)"
> <ngx-datatable-column
<ngx-datatable
*ngIf="rows"
#table
class="material striped custom-dt"
[columnMode]="'force'"
[headerHeight]="'auto'"
[footerHeight]="50"
[rowHeight]="40"
[externalPaging]="true"
[count]="page.count"
[offset]="page.page"
[limit]="page.limit"
[rows]="rows"
[columns]="columns"
[selected]="selected"
selectionType="single"
(select)="onSelectEvent($event)"
[messages]="{
emptyMessage: 'Pas de données disponibles',
totalMessage: 'total',
selectedMessage: 'selection'
}"
(page)="setPage($event)"
(sort)="onSortEvent($event)"
>
<ngx-datatable-column
[cellClass]="'cell-link'"
prop="Action"
class="object-link"
Expand All @@ -64,37 +67,47 @@
<!-- TODO Action Column : Changer ngIf, click function, matTooltip // voir comment adapter à ce qu'il y avait avant : *ngIf="child0.child0()"" et dans la function `child0.child0().labelArtUndef(true)` -->
<a
class="nav-link link cell-link"
(click)="navigateToAddChildren(null,row.id)"
(click)="navigateToAddChildren(null, row.id)"
matTooltip="Ajouter `child0.child0().labelArtUndef(true)` "
>
<i class="fa fa-plus" aria-hidden="true"></i>
</a>
</ng-template>
</ngx-datatable-column>
<!-- TODO Filter field : Changer ngIf et rajouter [comparator]="customColumnComparator" -->

<!-- TODO Filter field : Changer ngIf et rajouter [comparator]="customColumnComparator" -->
<ngx-datatable-column
*ngFor="let col of columns"
[name]="col.name"
[prop]="col.prop"
[headerTemplate]="hdrTpl"
></ngx-datatable-column>
</ngx-datatable>

<ng-template #hdrTpl let-column="column" let-sortDir="sortDir" let-sortFn="sortFn">

<ng-template
#hdrTpl
let-column="column"
let-sortDir="sortDir"
let-sortFn="sortFn"
>
<div class="header-sort-span" (click)="sortFn()">
<!-- {{column.name}} -->
<i class="material-icons icon-sort" [innerText]="sortDir ? (sortDir === 'asc' ? 'arrow_upward' : 'arrow_downward') : ''"></i>
<i
<i
class="material-icons icon-sort"
[innerText]="
sortDir ? (sortDir === 'asc' ? 'arrow_upward' : 'arrow_downward') : ''
"
></i>
<i
*ngIf="column.description"
class="material-icons icon-sort"
class="material-icons icon-sort"
[matTooltip]="column.description"
matTooltipPosition="above"
>help</i>
<span
[matTooltip]="column.name"
matTooltipPosition="above"
> {{ column.name }}</span>
>help</i
>
<span [matTooltip]="column.name" matTooltipPosition="above">
{{ column.name }}</span
>
</div>
<div class="header-filter-span">
<input
Expand Down
Loading

0 comments on commit ee5818d

Please sign in to comment.