forked from PnX-SI/gn_module_monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle error when "Edit" path method Create class of invalid request to manage return erreor Create function to handle type of field (wip) Reviewed-by:andriacap [Refs_ticket]:#4
- Loading branch information
Showing
14 changed files
with
613 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# class APIError(Exception): | ||
# """All custom API Exceptions""" | ||
# pass | ||
|
||
|
||
class InvalidUsage(Exception): | ||
status_code = 400 | ||
|
||
def __init__(self, message, status_code=None, payload=None): | ||
Exception.__init__(self) | ||
self.message = message | ||
if status_code is not None: | ||
self.status_code = status_code | ||
self.payload = payload | ||
|
||
|
||
def to_dict(self): | ||
rv = {} | ||
# rv['payload'] = dict(self.payload or ()) | ||
rv["payload"] = self.payload | ||
rv["message"] = self.message | ||
rv["status_code"] = self.status_code | ||
return (rv,self.status_code) | ||
|
||
|
||
class APIAuthError(Exception): | ||
"""Custom Authentication Error Class.""" | ||
|
||
code = 403 | ||
description = "Authentication Error" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"item_name_exists": "An item with name '{}' already exists.", | ||
"item_error_inserting": "An error occurred while inserting the item.", | ||
"item_not_found": "An item <id='{}'> cannot be found.", | ||
"item_deleted": "Item deleted.", | ||
"item_not_validated" :"Validation fields not pass , message : {}", | ||
"field_not_valid":"The field '{}' from request body is not valid see the model {} '" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
libs.strings | ||
By default, uses `en-gb.json` file inside the `strings` top-level folder. | ||
If language changes, set `libs.strings.default_locale` and run `libs.strings.refresh()`. | ||
""" | ||
import json,os | ||
|
||
default_locale = "en-gb" | ||
cached_strings = {} | ||
dir = os.path.dirname(os.path.realpath(__file__)) | ||
# parent_dir = os.path.abspath(os.path.join(dir, os.pardir)) | ||
def refresh(): | ||
print("Refreshing...") | ||
global cached_strings | ||
with open(os.path.join(dir,f"{default_locale}.json")) as f: | ||
cached_strings = json.load(f) | ||
|
||
|
||
def gettext(name): | ||
return cached_strings[name] | ||
|
||
|
||
refresh() |
31 changes: 31 additions & 0 deletions
31
frontend/app/components/monitoring-form-g/monitoring-form.component-g.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
:host ::ng-deep .obj-form { | ||
margin: 0; | ||
margin-bottom: 10px; | ||
padding: 0; | ||
} | ||
|
||
.hide-spinner { | ||
display: none; | ||
} | ||
|
||
.btn-height { | ||
height: 39px; | ||
} | ||
|
||
.float-right { | ||
margin-left: 5px; | ||
} | ||
|
||
|
||
.float-left { | ||
margin-right: 10px; | ||
float: left; | ||
} | ||
|
||
form:invalid { | ||
outline: none; | ||
} | ||
|
||
form.ng-invalid { | ||
border: 0px !important; | ||
} |
124 changes: 124 additions & 0 deletions
124
frontend/app/components/monitoring-form-g/monitoring-form.component-g.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<pnx-modal-msg [bDisplayModal]="bDeleteModal" *ngIf="obj && obj.bIsInitialized"> | ||
<h2>Attention</h2> | ||
<p> | ||
<!-- TODO: voir pour améliorer le passage d'informations ici --> | ||
Vous êtes sur le point de supprimer le groupe de site | ||
<b>Description du groupe de site</b> | ||
</p> | ||
<button class="btn btn-danger float-right" (click)="onDelete()"> | ||
<span | ||
[ngClass]="{ 'hide-spinner': !bDeleteSpinner }" | ||
class="spinner-border spinner-border-sm" | ||
role="status" | ||
aria-hidden="true" | ||
></span> | ||
Confirmer la suppression | ||
</button> | ||
<button class="btn btn-primary" (click)="bDeleteModal = false"> | ||
Annuler | ||
</button> | ||
</pnx-modal-msg> | ||
|
||
<div> | ||
<div | ||
id="properties-form" | ||
class="cadre" | ||
> | ||
<!-- TODO: voir pour intiialisation si nécessaire à remettre dans la div du dessus --> | ||
<!-- *ngIf="obj.bIsInitialized && objFormsDefinition" --> | ||
|
||
|
||
<!-- TODO: Voir pour l'enchainement des saisies --> | ||
<!-- <span | ||
*ngIf="!obj.id && obj.config['chained']" | ||
id="toggle-btn" | ||
class="float-right" | ||
matTooltip="Enchainer les saisies" | ||
matTooltipPosition="left" | ||
> | ||
<i class="fa fa-repeat" aria-hidden="true"></i> | ||
<mat-slide-toggle | ||
color="primary" | ||
[(ngModel)]="bChainInput" | ||
(change)="bChainInputChanged($event)" | ||
> | ||
</mat-slide-toggle> | ||
</span> --> | ||
|
||
<form [formGroup]="objForm"> | ||
|
||
<!-- TODO: Gérer la saisie de géometrie --> | ||
<!-- <p | ||
class="alert alert-warning" | ||
style="display:inline-block;" | ||
*ngIf="obj.config['geometry_type'] && !objForm.value.geometry" | ||
> | ||
<span> Veuillez saisir une géométrie sur la carte </span> | ||
</p> --> | ||
|
||
<!-- composant choix de site select + filtre --> | ||
|
||
<!-- <pnx-dynamic-form-generator | ||
class="obj-form" | ||
#dynamicForm | ||
[autoGenerated]="true" | ||
[myFormGroup]="objForm" | ||
[formsDefinition]="objFormsDefinition" | ||
(myFormGroupChange)="initForm()" | ||
(change)="onObjFormValueChange($event)" | ||
></pnx-dynamic-form-generator> --> | ||
|
||
<div> | ||
<!-- <button | ||
*ngIf="!bChainInput && !obj.id && obj.uniqueChildrenName()" | ||
class="btn btn-success float-right" | ||
(click)="bSaveAndAddChildrenSpinner = bAddChildren = true; onSubmit()" | ||
[disabled]="!objForm.valid" | ||
> | ||
<span | ||
[ngClass]="{ 'hide-spinner': !bSaveAndAddChildrenSpinner }" | ||
class="spinner-border spinner-border-sm float-right" | ||
role="status" | ||
aria-hidden="true" | ||
></span> | ||
<span | ||
>Valider et saisir des {{obj.uniqueChildrenName()}}</span | ||
> | ||
</button> --> | ||
|
||
<button | ||
class="btn btn-success float-right" | ||
(click)="bSaveSpinner = true; onSubmit()" | ||
[disabled]="!objForm.valid" | ||
> | ||
<span | ||
[ngClass]="{ 'hide-spinner': !bSaveSpinner }" | ||
class="spinner-border spinner-border-sm float-right" | ||
role="status" | ||
aria-hidden="true" | ||
></span> | ||
|
||
<!-- <span *ngIf="bChainInput && !obj.id" | ||
>Valider et enchainer les saisies</span | ||
> --> | ||
<!-- <span *ngIf="!bChainInput || obj.id">Valider</span> | ||
</button> --> | ||
<span >Valider</span> | ||
</button> | ||
|
||
<button class="btn btn-primary float-left" (click)="onCancelEdit()"> | ||
Annuler | ||
</button> | ||
<button | ||
class="btn btn-danger float-left" | ||
(click)="bDeleteModal = true" | ||
*ngIf="obj.id && (currentUser['cruved_object'][obj.objectType] || currentUser['cruved']).D >= obj.cruved('D')" | ||
> | ||
Supprimer | ||
</button> | ||
</div> | ||
<div class="btn-height"></div> | ||
</form> | ||
</div> | ||
</div> |
25 changes: 25 additions & 0 deletions
25
frontend/app/components/monitoring-form-g/monitoring-form.component-g.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { MonitoringFormComponent } from './monitoring-form.component'; | ||
|
||
describe('MonitoringFormComponent', () => { | ||
let component: MonitoringFormComponent; | ||
let fixture: ComponentFixture<MonitoringFormComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ MonitoringFormComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(MonitoringFormComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.