Skip to content

Commit

Permalink
Merge pull request #163 from PnX-SI/dev
Browse files Browse the repository at this point in the history
End of NaturalSolution mission
  • Loading branch information
lpofredc authored Sep 9, 2019
2 parents 72ecc5e + 741808d commit 14301e1
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 27 deletions.
7 changes: 2 additions & 5 deletions backend/gncitizen/core/commons/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,8 @@ def taxonomy_lists():
class ProgramView(ModelView):
form_base_class = SecureForm
form_overrides = dict(long_desc=CKEditorField)
# form_overrides = dict(long_desc=CKEditorField, taxonomy_list=SelectField)
# form_args = dict(
# taxonomy_list=dict(
# choices=taxonomy_lists()
# ))
form_overrides = {'long_desc':CKEditorField, 'taxonomy_list':SelectField}
form_args = {'taxonomy_list':{'choices':taxonomy_lists(), 'coerce':int}}
create_template = 'edit.html'
edit_template = 'edit.html'

Expand Down
1 change: 0 additions & 1 deletion backend/gncitizen/core/observations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class ObservationModel(ObserverMixinModel, TimestampMixinModel, db.Model):
db.Integer, db.ForeignKey(ProgramsModel.id_program), nullable=False
)
cd_nom = db.Column(db.Integer, db.ForeignKey(Taxref.cd_nom), nullable=False)
# specie = db.Column(db.String(200))
date = db.Column(db.Date, nullable=False)
count = db.Column(db.Integer)
comment = db.Column(db.String(300))
Expand Down
12 changes: 11 additions & 1 deletion backend/gncitizen/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ def load_config(config_file=None):
return config_gnc


def valid_api_url(url):
"""Return a valid API URL ending with /"""
if url[-1:] == '/':
url = url
else:
url = url+'/'
return url


app_conf = load_config()
MEDIA_DIR = str(ROOT_DIR / app_conf["MEDIA_FOLDER"])
SQLALCHEMY_DATABASE_URI = app_conf["SQLALCHEMY_DATABASE_URI"]
Expand Down Expand Up @@ -70,7 +79,8 @@ def load_config(config_file=None):
)


taxhub_url = app_conf.get("API_TAXHUB", "")
taxhub_url = valid_api_url(app_conf.get("API_TAXHUB", ""))

taxhub_lists_url = taxhub_url + "biblistes/"


Expand Down
13 changes: 13 additions & 0 deletions frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Component, OnInit, ViewEncapsulation } from "@angular/core";

import { AppConfig } from "../conf/app.config";
import { Router, NavigationStart } from "@angular/router";
import { ModalsTopbarService } from "./core/topbar/modalTopbar.service";

@Component({
selector: "app-root",
Expand All @@ -12,6 +14,17 @@ export class AppComponent implements OnInit {
title = "GeoNature-citizen";
public appConfig: any;

constructor(
private router: Router,
private modalService: ModalsTopbarService
) {
this.router.events.subscribe(event => {
if (event instanceof NavigationStart) {
this.modalService.close()
}
});
}

ngOnInit() {
this.appConfig = AppConfig;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,7 @@ export class UserDashboardComponent implements OnInit {
}
);
}
ngOnDestroy(): void {
if (this.modalRef) this.modalRef.close()
}
}
19 changes: 19 additions & 0 deletions frontend/src/app/core/topbar/modalTopbar.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Injectable } from "@angular/core";

import { NgbModal, NgbModalRef } from "@ng-bootstrap/ng-bootstrap";

@Injectable({
providedIn: "root"
})
export class ModalsTopbarService {
modalRef: NgbModalRef;

constructor(private modalService: NgbModal) {}

open(content, option) {
this.modalRef = this.modalService.open(content, option);
}
close() {
if (this.modalRef) this.modalRef.close();
}
}
19 changes: 6 additions & 13 deletions frontend/src/app/core/topbar/topbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Component, OnInit } from "@angular/core";
import { Observable, Subject, throwError } from "rxjs";
import { tap, map, catchError } from "rxjs/operators";

import { NgbModal, NgbModalRef } from "@ng-bootstrap/ng-bootstrap";

import { AppConfig } from "../../../conf/app.config";
import { AuthService } from "./../../auth/auth.service";
import { LoginComponent } from "../../auth/login/login.component";
Expand All @@ -15,6 +13,7 @@ import { GncProgramsService } from "../../api/gnc-programs.service";
import { ActivatedRoute } from "@angular/router";
import { HttpClient } from "@angular/common/http";
import { DomSanitizer, SafeUrl } from "@angular/platform-browser";
import { ModalsTopbarService } from "./modalTopbar.service";

@Component({
selector: "app-topbar",
Expand All @@ -25,7 +24,6 @@ export class TopbarComponent implements OnInit {
title: string = AppConfig.appName;
// isLoggedIn: boolean = false;
username: any;
modalRef: NgbModalRef;
programs$ = new Subject<Program[]>();
isAdmin = false;
canDisplayAbout: boolean = AppConfig.about;
Expand All @@ -35,7 +33,7 @@ export class TopbarComponent implements OnInit {
private route: ActivatedRoute,
private programService: GncProgramsService,
private auth: AuthService,
private modalService: NgbModal,
private modalService: ModalsTopbarService,
private sanitizer: DomSanitizer,
protected http: HttpClient
) {
Expand Down Expand Up @@ -69,30 +67,29 @@ export class TopbarComponent implements OnInit {
);
}


login() {
this.modalRef = this.modalService.open(LoginComponent, {
this.modalService.open(LoginComponent, {
size: "lg",
centered: true
});
}

register() {
this.modalRef = this.modalService.open(RegisterComponent, {
this.modalService.open(RegisterComponent, {
size: "lg",
centered: true
});
}

logout() {
this.modalRef = this.modalService.open(LogoutComponent, {
this.modalService.open(LogoutComponent, {
size: "lg",
centered: true
});
}

programs() {
this.modalRef = this.modalService.open(ProgramsComponent, {
this.modalService.open(ProgramsComponent, {
size: "lg",
centered: true
});
Expand Down Expand Up @@ -156,8 +153,4 @@ export class TopbarComponent implements OnInit {
);*/
}
}

close(d) {
this.modalRef.close(d);
}
}
8 changes: 5 additions & 3 deletions frontend/src/app/home/home.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ section {
bottom: 0;
display: flex;
align-items: center;
max-width: 60%;
max-width: 40%;
}

#slider .carousel-text {
background-color: #fff;
background-color: #eeeeeecf;
padding: 35px 20px 35px 35px;
min-width: 450px;
max-height: 80%;
Expand All @@ -232,6 +232,8 @@ section {
max-height: 50%;
overflow-y: auto;
margin-bottom: 1em;
color: black;
font-size: 14px
}

#slider .carousel-text h3 {
Expand All @@ -242,10 +244,10 @@ section {
#slider .carousel-text>p {
font-style: italic;
font-size: 14px;
color: black;
}

#slider .carousel-text a {
background-color: var(--secondary);
width: fit-content;
text-align: center;
margin: 0 auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class ModalFlowService extends FlowService {
trigger = reason;
break;
}
console.debug(`dismissed with ${trigger}`);
}
);
}
Expand All @@ -61,6 +60,9 @@ export class ModalFlowService extends FlowService {
close(data) {
this.modalRef.close(data);
}
closeModal() {
if (this.modalRef) this.modalRef.close();
}

getFlowItems(initialState) {
return [
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/app/programs/observations/obs.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ section {
bottom: 0;
display: flex;
align-items: center;
max-width: 70%;
max-width: 40%;
}

#slider .carousel-text {
background-color: #fff;
padding: 35px 20px 35px 35px;
min-width: 450px;
max-height: 80%;
height: auto;
background-color: #eeeeeecf;
display: flex;
flex-direction: column;
justify-content: space-between;
Expand All @@ -108,16 +108,18 @@ section {
font-style: italic;
font-size: 14px;
max-height: 20%;
color: black;
}

#slider .carousel-text div {
max-height: 50%;
overflow-y: auto;
margin-bottom: 15px;
color: black;
font-size: 14px
}

#slider .carousel-text a {
background-color: var(--secondary);
width: fit-content;
text-align: center;
margin: 0 auto;
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/app/programs/observations/obs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,8 @@ export class ObsComponent implements OnInit, AfterViewInit {
features: this.observations.features
};
}

ngOnDestroy(): void {
this.flowService.closeModal()
}
}

0 comments on commit 14301e1

Please sign in to comment.