Skip to content

Commit

Permalink
Merge pull request #17 from infra-geo-ouverte/master
Browse files Browse the repository at this point in the history
pull master source
  • Loading branch information
drekss authored Oct 4, 2019
2 parents 74ca893 + 2f8f274 commit e04d3b8
Show file tree
Hide file tree
Showing 34 changed files with 248 additions and 172 deletions.
1 change: 1 addition & 0 deletions demo/src/app/geo/layer/layer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<igo-metadata-button [layer]="layer"></igo-metadata-button>
<igo-download-button [layer]="layer"></igo-download-button>
<igo-ogc-filter-button [ogcFiltersInLayers]="true" [layer]="layer"></igo-ogc-filter-button>
<igo-track-feature-button [layer]="layer" [trackFeature]="true"></igo-track-feature-button>
</ng-template>

</igo-layer-list>
Expand Down
1 change: 1 addition & 0 deletions demo/src/app/geo/query/query.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
[view]="view"
igoOverlay
igoQuery
[queryFeatures]="true"
(query)="handleQueryResults($event)">
<igo-zoom-button [map]="map" color="primary"></igo-zoom-button>
</igo-map-browser>
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"_watch.core": "wait-on dist/utils/package.json && ng build core --watch",
"_watch.common": "wait-on dist/core/package.json && ng build common --watch",
"_watch.auth": "wait-on dist/common/package.json && ng build auth --watch",
"_watch.geo": "wait-on dist/common/package.json && ng build geo --watch",
"_watch.geo": "wait-on dist/auth/package.json && ng build geo --watch",
"_watch.context": "wait-on dist/geo/package.json && ng build context --watch",
"_watch.integration": "wait-on dist/context/package.json && ng build integration --watch",
"_watch.gulp": "wait-on dist/integration/package.json && gulp core && gulp common && gulp auth && gulp geo && gulp context && gulp integration && gulp core:bundleLocale",
Expand Down Expand Up @@ -81,7 +81,7 @@
"@ionic-native/network": "^5.12.0",
"@ionic/angular": "^4.6.2",
"@mat-datetimepicker/core": "^3.0.0-beta.0",
"@mdi/angular-material": "^3.6.95",
"@mdi/angular-material": "^4.4.95",
"@ngx-translate/core": "^10.0.1",
"@turf/helpers": "^6.1.4",
"@turf/line-intersect": "^6.0.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/lib/auth-form/auth-intern.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</mat-form-field>
</div>

<button mat-raised-button type="submit" [disabled]="!form.valid">{{'igo.auth.login' | translate}}</button>
<button *ngIf="allowAnonymous" mat-raised-button type="button" (click)="loginAnonymous()">{{'igo.auth.accessAnonymous' | translate }}</button>
<button mat-raised-button type="submit" [disabled]="!form.valid || loading">{{'igo.auth.login' | translate}}</button>
<button *ngIf="allowAnonymous" mat-raised-button type="button" [disabled]="loading" (click)="loginAnonymous()">{{'igo.auth.accessAnonymous' | translate }}</button>
<div *ngIf="error">
<br/>
<font size="3" color="red">{{error}}</font>
Expand Down
20 changes: 18 additions & 2 deletions packages/auth/src/lib/auth-form/auth-intern.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
EventEmitter
} from '@angular/core';
import { Validators, FormGroup, FormBuilder } from '@angular/forms';

import { AuthService } from '../shared/auth.service';
import { LanguageService } from '@igo2/core';

@Component({
selector: 'igo-auth-intern',
Expand All @@ -26,23 +28,37 @@ export class AuthInternComponent {

public error = '';
public form: FormGroup;
public loading = false;

@Output() login: EventEmitter<boolean> = new EventEmitter<boolean>();

constructor(public auth: AuthService, fb: FormBuilder) {
constructor(
public auth: AuthService,
private languageService: LanguageService,
fb: FormBuilder
) {
this.form = fb.group({
username: ['', Validators.required],
password: ['', Validators.required]
});
}

loginUser(values: any) {
this.loading = true;
this.auth.login(values.username, values.password).subscribe(
() => {
this.login.emit(true);
this.loading = false;
},
(error: any) => {
this.error = error.error.message;
try {
this.languageService.translate
.get('igo.auth.error.' + error.error.message)
.subscribe(errorMsg => (this.error = errorMsg));
} catch (e) {
this.error = error.error.message;
}
this.loading = false;
}
);
return false;
Expand Down
1 change: 1 addition & 0 deletions packages/auth/src/lib/shared/auth.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface User {
firstName?: string;
lastName?: string;
locale?: string;
isExpired?: boolean;
admin?: boolean;
defaultContextId?: string;
}
16 changes: 13 additions & 3 deletions packages/auth/src/lib/shared/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Router } from '@angular/router';
import { Observable, BehaviorSubject, of } from 'rxjs';
import { tap, catchError } from 'rxjs/operators';

import { ConfigService, LanguageService } from '@igo2/core';
import { ConfigService, LanguageService, MessageService } from '@igo2/core';
import { Base64 } from '@igo2/utils';

import { AuthOptions, User } from './auth.interface';
Expand All @@ -25,6 +25,7 @@ export class AuthService {
private tokenService: TokenService,
private config: ConfigService,
private languageService: LanguageService,
private messageService: MessageService,
@Optional() private router: Router
) {
this.options = this.config.getConfig('auth') || {};
Expand Down Expand Up @@ -132,8 +133,17 @@ export class AuthService {
tap((data: any) => {
this.tokenService.set(data.token);
const tokenDecoded = this.decodeToken();
if (tokenDecoded && tokenDecoded.user && tokenDecoded.user.locale) {
this.languageService.setLanguage(tokenDecoded.user.locale);
if (tokenDecoded && tokenDecoded.user) {
if (tokenDecoded.user.locale) {
this.languageService.setLanguage(tokenDecoded.user.locale);
}
if (tokenDecoded.user.isExpired) {
this.languageService.translate
.get('igo.auth.error.Password expired')
.subscribe(expiredAlert =>
this.messageService.alert(expiredAlert)
);
}
}
this.authenticate$.next(true);
}),
Expand Down
8 changes: 7 additions & 1 deletion packages/auth/src/locale/en.auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
"user": "User",
"welcome": "Welcome {{name}}!",
"deconnection": "You are logged out.",
"home": "Return to the home page"
"home": "Return to the home page",
"error": {
"Password expired": "Password expired",
"Maximun logins exceeded": "Maximun logins exceeded",
"Wrong password": "Wrong password",
"Invalid username": "Invalid username"
}
}
}
}
8 changes: 7 additions & 1 deletion packages/auth/src/locale/fr.auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
"user": "Utilisateur",
"welcome": "Bienvenue {{name}}!",
"deconnection": "Vous êtes déconnecté",
"home": "Retourner à la page d'accueil"
"home": "Retourner à la page d'accueil",
"error": {
"Password expired": "Votre mot de passe est expiré",
"Maximun logins exceeded": "Nombre maximal de connexions dépassé",
"Wrong password": "Mot de passe incorrect",
"Invalid username": "Utilisateur invalide"
}
}
}
}
8 changes: 6 additions & 2 deletions packages/core/src/lib/analytics/shared/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,24 @@ export class AnalyticsService {
if (!this.options.url || !this.options.id) {
return;
}
const url =
this.options.url.substr(-1) === '/'
? this.options.url + 'matomo'
: this.options.url;

(window as any)._paq = (window as any)._paq || [];
const paq: any = (window as any)._paq;
paq.push(['trackPageView']);
paq.push(['enableLinkTracking']);
(() => {
paq.push(['setTrackerUrl', this.options.url + 'matomo.php']);
paq.push(['setTrackerUrl', url + '.php']);
paq.push(['setSiteId', this.options.id]);
const g = document.createElement('script');
const s = document.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.async = true;
g.defer = true;
g.src = this.options.url + 'matomo.js';
g.src = url + '.js';
s.parentNode.insertBefore(g, s);
})();
}
Expand Down
10 changes: 6 additions & 4 deletions packages/core/src/lib/language/shared/language.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ import { TranslateService } from '@ngx-translate/core';
providedIn: 'root'
})
export class LanguageService {
private language: string = this.translate.getBrowserLang();

constructor(public translate: TranslateService) {
const lang = this.getLanguage();
this.translate.setDefaultLang(lang);
}

public getLanguage(): string {
const browserLang = this.translate.getBrowserLang();
return browserLang.match(/en|fr/) ? browserLang : 'en';
return this.language.match(/en|fr/) ? this.language : 'en';
}

public setLanguage(language: string) {
this.translate.use(language);
this.translate.reloadLang(language);
this.language = language.match(/en|fr/) ? language : 'en';
this.translate.use(this.language);
this.translate.reloadLang(this.language);
}
}
2 changes: 1 addition & 1 deletion packages/core/src/style/themes/blue.theme.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$primary: mat-palette($mat-blue, 700);
$primary: mat-palette($mat-blue, 700, 400, 900);
$accent: mat-palette($mat-blue, 200);
$warn: mat-palette($mat-red);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,50 @@ export class CatalogBrowserComponent implements OnInit, OnDestroy {
});
}

/**
* Sort the layers by title. asc or desc.
* @internal
*/
private sortCatalogItemsByTitle(items: CatalogItem[], direction) {
const returnItem = items.sort((a, b) => {
const titleA = a.title.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
const titleB = b.title.normalize('NFD').replace(/[\u0300-\u036f]/g, '');

if (titleA < titleB) {
return -1;
}
if (titleA > titleB) {
return 1;
}
return 0;
});
switch (direction) {
case 'asc':
return returnItem;
case 'desc':
return returnItem.reverse();
default:
return items;
}
}

/**
* Add all the layers of a group to map
* @param group Catalog group
*/
private addGroupToMap(group: CatalogItemGroup) {
const layers = group.items.filter((item: CatalogItem) => {
let layers = group.items.filter((item: CatalogItem) => {
const added = this.store.state.get(item).added || false;
return this.isLayer(item) && added === false;
});
if (this.catalog && this.catalog.sortDirection !== undefined) {
layers = this.sortCatalogItemsByTitle(layers, this.catalog.sortDirection);
}
this.addLayersToMap(layers.reverse() as CatalogItemLayer[]);
}

/**
* Remove all the layers of a groufrom map
* Remove all the layers of a group from map
* @param group Catalog group
*/
private removeGroupFromMap(group: CatalogItemGroup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ export class OgcFilterButtonComponent {
constructor() {}

toggleOgcFilter() {
if (this.layer.isInResolutionsRange) {
this.ogcFilterCollapse = !this.ogcFilterCollapse;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

.mat-button-toggle-group {
margin: 5px 5px 5px 5px;
flex-wrap: wrap;
}

.mat-button-toggle {
width: 100%;
display: inline-flex;
}

::ng-deep .material-tooltip {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
display: inline-block;
}

.mat-list-item {
height: auto;
}

mat-icon.disabled {
color: rgba(0,0,0,.38);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div *ngIf="geometryTypeField" class="geometry-type-toggle">
<mat-button-toggle-group
[disabled]="(value$ | async) !== undefined"
[ngModel]="geometryType">
[(ngModel)]="geometryType">
<mat-button-toggle
value="Point"
[disabled]="geometryTypes.indexOf('Point') < 0">
Expand All @@ -35,7 +35,7 @@
matInput
type="number"
[placeholder]="drawGuidePlaceholder"
[ngModel]="drawGuide">
[(ngModel)]="drawGuide">
<mat-icon
matPrefix
[color]="'primary'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class GeometryFormFieldComponent implements OnInit, OnDestroy {
set drawGuide(value: number) { this.drawGuide$.next(value); }
get drawGuide(): number { return this.drawGuide$.value; }
readonly drawGuide$: BehaviorSubject<number> = new BehaviorSubject(0);

/**
* Draw guide placeholder
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/geo/src/lib/import-export/shared/export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export class ExportService {
GML: 'gml',
GPX: 'gpx',
KML: 'kml',
Shapefile: 'ESRI Shapefile'
Shapefile: 'ESRI Shapefile',
CSV: 'CSV'
};

static noOgreFallbacks = ['GML', 'GPX', 'KML'];
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/src/lib/import-export/shared/export.type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { strEnum } from '@igo2/utils';

export const ExportFormat = strEnum(['GeoJSON', 'GML', 'GPX', 'KML', 'Shapefile']);
export const ExportFormat = strEnum(['GeoJSON', 'GML', 'GPX', 'KML', 'Shapefile', 'CSV']);
export type ExportFormat = keyof typeof ExportFormat;
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
.igo-layer-button-group {
float: right;
padding: 0 $igo-list-item-padding;
display: contents; /* ie11: display: ruby-base; */
max-width: 100%;

@include mobile {
float: none;
Expand Down
Loading

0 comments on commit e04d3b8

Please sign in to comment.