Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/crud/gp sites components #38

Merged
merged 44 commits into from
Feb 24, 2023
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a093d9a
feat(front): wip sites_groups component and svc
Dec 23, 2022
ce64039
WIP feat(front): DataTable sites_groups
andriacap Dec 26, 2022
3ee07bc
feat(front): Datatable format and selected row
andriacap Dec 27, 2022
1ec9c79
feat(front): Filtering table (OK)
andriacap Dec 27, 2022
673c180
feat(front): wip server pagination & filtering
Jan 2, 2023
c3194cc
feat(front): add sorting capability and fixes
Jan 4, 2023
4e0d1ad
fix(db): change trigger to constraint (migrations)
andriacap Jan 16, 2023
15a7a10
refactor: Custom type Geojson and group properties
andriacap Jan 17, 2023
f10e201
refactor: site component with site-service
andriacap Jan 17, 2023
acf9ff2
refactor: create datatable component and service
andriacap Jan 18, 2023
868348c
fix: change offset to page
andriacap Jan 19, 2023
7b6340a
merge: merge interface and type
andriacap Jan 19, 2023
49a9bd5
feat: details properties sites groups
andriacap Jan 19, 2023
8a4e434
feat: display groups sites's child
andriacap Jan 20, 2023
f965a6a
refactor(front): rename interfaces, remove classes
Jan 19, 2023
c5e1917
feat(front): get all geometries
Jan 23, 2023
7580095
feat(front): WIP: geojson service to create layers
Jan 24, 2023
d203a11
feat(front): implemented select capability
Jan 24, 2023
dc09191
feat(api): add route to get one site_group by id
Jan 27, 2023
f6489ad
fix(front): too much /
Jan 27, 2023
314584a
feat(front): add get sites_group from id
Jan 27, 2023
73a6153
fix(front): add possibility to provide Geometry
Jan 27, 2023
8127226
refactor(front): sites and sites_groups component
Jan 27, 2023
409d81f
fix(front): fix filters by adding baseFilters
Jan 27, 2023
2748431
feat: edit sitegroups
andriacap Jan 31, 2023
6efe45f
feat: edit sitegroups
andriacap Feb 1, 2023
36e9434
feat: improve edit
andriacap Feb 1, 2023
de2118a
feat: improve rendering front "edit" and "add"
andriacap Feb 1, 2023
e72ee0a
feat: improving patch method object
andriacap Feb 2, 2023
2b3632a
feat: create site group method with form
andriacap Feb 20, 2023
d234330
feat: delete site_group component
andriacap Feb 20, 2023
c4a82bf
chore(api): removed unused code
Feb 21, 2023
47c825c
style(config): apply formatter
Feb 21, 2023
601cb2c
chore(front): removed unused code & console.log
Feb 21, 2023
1fc5dfc
feat(front): removed display map button
Feb 21, 2023
36ba4e3
refactor(front): remove Object for keys
Feb 21, 2023
05e3fb0
style(front): reformat routes
Feb 21, 2023
6d1ebb7
refactor(front): add create component
Feb 22, 2023
ce30a88
chore(front): remove unused services
Feb 22, 2023
3c04ec6
chore(front): removed usused code
Feb 22, 2023
fca2f5a
chore(api): remove string package
Feb 22, 2023
7456009
chore(api): removed unused comment
Feb 22, 2023
c3b5b7b
chore(front): removed console.log and comments
Feb 22, 2023
fb0c29a
chore(api): removed unused code and log
Feb 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: improve edit
Add method to define objectType according to service used (site or
gpsite)

Rewied-by: andriacap
[Refs_ticket]: #4
andriacap authored and Maxime Vergez committed Feb 21, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 36e9434df1669e0bc08bd1c390fc0633e7efcf4a
Original file line number Diff line number Diff line change
@@ -21,8 +21,7 @@
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
<i class="fa fa-plus" aria-hidden="true"></i> Ajouter {{objectType}}
</button>
</div>
<ngx-datatable
Original file line number Diff line number Diff line change
@@ -12,18 +12,8 @@ import {
import { Subject } from "rxjs";
import { debounceTime } from "rxjs/operators";
import { DataTableService } from "../../services/data-table.service";

interface ColName {
name: string;
prop: string;
description?: string;
}

interface Page {
count: number;
limit: number;
offset: number;
}
import { IColumn } from "../../interfaces/column";
import { IPage } from "../../interfaces/page";

interface ItemObjectTable {
id: number | null;
@@ -40,10 +30,12 @@ type ItemsObjectTable = { [key: string]: ItemObjectTable };
})
export class MonitoringDatatableGComponent implements OnInit {
@Input() rows;
@Input() colsname: ColName[];
@Input() page: Page = { count: 0, limit: 0, offset: 0 };
@Input() colsname: IColumn[];
@Input() page: IPage = { count: 0, limit: 0, page: 0 };
@Input() obj;

@Input() objectType:string;

@Input() rowStatus: Array<any>;
@Output() rowStatusChange = new EventEmitter<Object>();

@@ -57,7 +49,6 @@ export class MonitoringDatatableGComponent implements OnInit {
@Output() onDetailsRow = new EventEmitter<any>();

private filterSubject: Subject<string> = new Subject();
private subscription: any;
displayFilter: boolean = false;
objectsStatus: ItemsObjectTable;

@@ -81,6 +72,11 @@ export class MonitoringDatatableGComponent implements OnInit {
initDatatable() {
console.log("Inside initDatatable");
console.log("this.rows", this.rows);

// IF prefered observable compare to ngOnChanges uncomment this:
// this._dataTableService.currentCols.subscribe(newCols => { this.columns = newCols })


this.filters = {};
this.filterSubject.pipe(debounceTime(500)).subscribe(() => {
this.filter();
@@ -179,6 +175,8 @@ export class MonitoringDatatableGComponent implements OnInit {
ngOnChanges(changes: SimpleChanges) {
console.log("inside ngOnChanges");
console.log("changes", changes);

// IF prefered ngOnChanges compare to observable uncomment this:
if (changes["rows"] && this.rows && this.rows.length > 0) {
this.columns = this._dataTableService.colsTable(
this.colsname,
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@

<button class="btn btn-success mr-2" (click)="onEditClick()" *ngIf="
!bEdit">
Éditer le groupe de site
Éditer {{objectType}}
</button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ export class MonitoringPropertiesGComponent implements OnInit {
@Input() selectedObj: ISitesGroup;
@Input() bEdit: boolean;
@Output() bEditChange = new EventEmitter<boolean>();

@Input() objectType:string;
Object = Object;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supprimer les attributs non utilisés


// @Input() currentUser;
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<pnx-monitoring-properties-g *ngIf="!bEdit" [(bEdit)]="bEdit" [selectedObj]="sitesGroup">
<pnx-monitoring-properties-g
[objectType]="objectType"
*ngIf="!bEdit"
[(bEdit)]="bEdit"
[selectedObj]="sitesGroup"
>
</pnx-monitoring-properties-g>
<pnx-monitoring-form-g
[obj]="sitesGroup"
(objChanged)="onObjChanged($event)"
*ngIf="bEdit"
[(bEdit)]="bEdit"
[objForm]="objForm"
[obj]="sitesGroup"
(objChanged)="onObjChanged($event)"
*ngIf="bEdit"
[(bEdit)]="bEdit"
[objForm]="objForm"
></pnx-monitoring-form-g>
<pnx-monitoring-datatable-g
[rows]="sites"
@@ -17,4 +22,5 @@
[obj]="sites"
(rowStatusChange)="onSelect($event)"
(onDetailsRow)="seeDetails($event)"
[objectType]="objectType"
></pnx-monitoring-datatable-g>
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import { MonitoringGeomComponent } from "../../class/monitoring-geom-component";
import { setPopup } from "../../functions/popup";
import { GeoJSONService } from "../../services/geojson.service";
import { FormGroup, FormBuilder } from "@angular/forms";
import { SitesService } from "../../services/sites.service";

const LIMIT = 10;

@@ -31,10 +32,12 @@ export class MonitoringSitesComponent
filters = {};
siteGroupLayer: L.FeatureGroup;
@Input() bEdit:boolean;
@Input() objectType:string;
objForm: FormGroup;

constructor(
private _sitesGroupService: SitesGroupService,
private _siteService: SitesService,
private router: Router,
private _Activatedroute: ActivatedRoute,
private _geojsonService: GeoJSONService,
@@ -46,6 +49,7 @@ export class MonitoringSitesComponent

ngOnInit() {
this.objForm = this._formBuilder.group({});
this.objectType = this._siteService.addObjectType()
this.initSite()
}

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- IF prefered observable compare to ngOnChanges we can remove rows and colsname-->
<div>
<pnx-monitoring-datatable-g
[rows]="sitesGroups"
@@ -8,5 +9,6 @@
(onSetPage)="setPage($event)"
[obj]="sitesGroups"
(onDetailsRow)="seeDetails($event)"
[objectType]="objectType"
></pnx-monitoring-datatable-g>
</div>
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import { ISite, ISitesGroup } from "../../interfaces/geom";
import { GeoJSONService } from "../../services/geojson.service";
import { MonitoringGeomComponent } from "../../class/monitoring-geom-component";
import { setPopup } from "../../functions/popup";
import { DataTableService } from "../../services/data-table.service";

const LIMIT = 10;

@@ -31,22 +32,28 @@ export class MonitoringSitesGroupsComponent
@Input() columnNameSite: typeof columnNameSite = columnNameSite;
@Input() sitesGroupsSelected: ISitesGroup;

@Input() rows;
// @Input() rows;
@Input() colsname;
@Input() obj;
@Input() objectType:string;




constructor(
private _sites_group_service: SitesGroupService,
public geojsonService: GeoJSONService,
private router: Router,
// IF prefered observable compare to ngOnChanges uncomment this:
// private _dataTableService:DataTableService,
private _Activatedroute: ActivatedRoute, // private _routingService: RoutingService
) {
super();
this.getAllItemsCallback = this.getSitesGroups;
}

ngOnInit() {
this.objectType = this._sites_group_service.addObjectType()
this.getSitesGroups(1);
this.geojsonService.getSitesGroupsGeometries(
this.onEachFeatureSiteGroups()
@@ -82,6 +89,8 @@ export class MonitoringSitesGroupsComponent
};
this.sitesGroups = data.items;
this.colsname = this.columnNameSiteGroup;
// IF prefered observable compare to ngOnChanges uncomment this:
// this._dataTableService.changeColsTable(this.colsname,this.sitesGroups[0])
});
}

24 changes: 22 additions & 2 deletions frontend/app/services/data-table.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from "@angular/core";
import { IColumn } from "../interfaces/column";

import { BehaviorSubject} from "rxjs";
interface ItemObjectTable {
id: number | null;
selected: boolean;
@@ -17,9 +17,29 @@ export class DataTableService {
rowStatus: ItemObjectTable;
idObj: number;


// IF prefered observable compare to ngOnChanges uncomment this:
// dataCol:IColumn[] =[{prop:"",name:"",description:""}]
// private dataCols = new BehaviorSubject<object>(this.dataCol);
// currentCols = this.dataCols.asObservable();


constructor() {}

colsTable(colName, dataTable): IColumn[] {
// IF prefered observable compare to ngOnChanges uncomment this:
// changeColsTable(newCols:IColumn[],newRows){
// const arr = Object.keys(newCols);
// const allColumn: IColumn[] = arr
// .filter((item) => Object.keys(newRows).includes(item))
// .map((elm) => ({
// name: newCols[elm],
// prop: elm,
// description: elm,
// }));
// this.dataCols.next(allColumn)
// }

colsTable(colName:IColumn[], dataTable): IColumn[] {
const arr = Object.keys(colName);
const allColumn: IColumn[] = arr
.filter((item) => Object.keys(dataTable).includes(item))
8 changes: 8 additions & 0 deletions frontend/app/services/sites.service.ts
Original file line number Diff line number Diff line change
@@ -34,4 +34,12 @@ export class SitesService implements IGeomService {
}
);
}

addObjectType():string {
return " un nouveau site"
}

editObjectType():string {
return "Editer le site"
}
}
8 changes: 8 additions & 0 deletions frontend/app/services/sites_group.service.ts
Original file line number Diff line number Diff line change
@@ -59,4 +59,12 @@ export class SitesGroupService implements IGeomService {
patchGroupSite(id:number,updatedData:JsonData):Observable<ResponseUpdated>{
return this._cacheService.request("patch",`sites_groups/${id}`,{postData : updatedData})
}

addObjectType():string {
return "un nouveau groupe de site"
}

editObjectType():string {
return "Editer le groupe de site"
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En double avec api-geom-service.ts non ?