Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/integration' into integration
Browse files Browse the repository at this point in the history
  • Loading branch information
rmichaelis committed Jan 18, 2023
2 parents 0e068b0 + f003222 commit e964099
Show file tree
Hide file tree
Showing 22 changed files with 719 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ import '../../less/geoportailv3.less';
import '../lux-iframe-preview/lux-iframe-preview.ts';
import '../gmf-lidar-panel/gmf-lidar-panel.ts';
import '../lidar-plot/lidar-plot.ts';
import '../offlineWebComponent.ts';
import '../offline/lux-offline/lux-offline.component.ts';
import '../offline/lux-offline/lux-offline-alert.component.ts';
import '../offline/lux-offline/lux-offline-reload.component.ts';
import '../offline/lux-offline/lux-offline-error.component.ts';

import DragRotate from 'ol/interaction/DragRotate';
import {platformModifierKeyOnly} from 'ol/events/condition';
Expand Down
15 changes: 10 additions & 5 deletions geoportal/geoportailv3_geoportal/static-ngeo/js/apps/main.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -376,20 +376,25 @@
</div>
<div ng-if="mainCtrl.selectedLayers.length>0" class="slider-layer-label"><i class="fa fa-arrow-left"></i> <span>{{mainCtrl.selectedLayers[0].get('label') | translate}}</span></div>
</div>
<lux-offline-alert></lux-offline-alert>
<lux-offline-reload></lux-offline-reload>
<lux-offline-error></lux-offline-error>
<lux-offline
ng-class="mainCtrl.offlineBar.isBarOpen() ? 'show' : 'hide'"
ng-click="mainCtrl.offlineBar.toggleFullOffline()"
ng-prop-disabled="mainCtrl.offlineBar.isNgeoOfflineActive()"
ng-prop-bar="mainCtrl.offlineBar"
ng-prop-scope="mainCtrl.scope_"
></lux-offline>
<ngeo-offline
ng-class="mainCtrl.offlineBar.isBarOpen() ? 'show' : 'hide'"
ng-click="mainCtrl.offlineBar.toggleNgeoOffline()"
ng-class="[
mainCtrl.offlineBar.isBarOpen() ? 'show' : 'hide',
{'offline-mode': mainCtrl.offlineMode.isEnabled()}
]"
ngeo-offline-map="::mainCtrl.map"
ngeo-offline-mask-margin="::100"
ngeo-offline-min-zoom="::12"
ngeo-offline-max-zoom="::16"
ngeo-full-offline-active="mainCtrl.offlineBar.isFullOfflineActive()"
ng-class="{'offline-mode': mainCtrl.offlineMode.isEnabled()}"
ngeo-full-offline-active="mainCtrl.offlineBar.fullOffline_"
ng-show="!mainCtrl.embedded"
>
</ngeo-offline>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import 'jquery';
import 'bootstrap/js/modal.js';
import i18next from 'i18next';
import { combineLatestWith } from 'rxjs';
import {LuxBaseElement} from '../../LuxBaseElement';
import {html} from 'lit';
import {customElement, state, query} from 'lit/decorators.js';
import { LuxOfflineServiceInstance, LuxOfflineService } from './lux-offline.service';
import { OfflineStatus } from './lux-offline.model';

@customElement('lux-offline-alert')
export class LuxOfflineAlert extends LuxBaseElement {

@state()
private status;

@state()
private subscription;

@query('.modal-alert')
private modal: HTMLElement;

private prevStatus;
private offlineService: LuxOfflineService;

constructor() {
super();
this.offlineService = LuxOfflineServiceInstance;
this.prevStatus = this.offlineService.status$.getValue();
this.subscription = this.offlineService.status$.pipe(
combineLatestWith(this.offlineService.tileError$)
).subscribe(([status, error])=> {
if ((!error
&& status === OfflineStatus.UPDATE_AVAILABLE)
&& (this.prevStatus === undefined
|| this.prevStatus === OfflineStatus.UNINITIALIZED)) {
$(this.modal).modal('show');
}
if (status === OfflineStatus.UP_TO_DATE) {
$(this.modal).modal('hide');
}
this.status = status;
this.prevStatus = status
});
}

disconnectedCallback() {
this.subscription.unsubscribe();
super.disconnectedCallback();
}

render() {
return html`
<div class="modal modal-alert" tabindex="-1" role="dialog">
<div class="modal-dialog offline-modal" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">${i18next.t('New offline data available')}</h4>
</div>
<div class="modal-body">
<div>
<div class="offline-btn btn btn-primary" @click="${this.updateTiles}" ?disabled="${this.status!==OfflineStatus.UPDATE_AVAILABLE}">
${i18next.t('Update offline data')}
${this.status===OfflineStatus.IN_PROGRESS
? html `<i class="fa fa-circle-o-notch fa-spin"></i>`
: ''
}
</div>
</div>
</div>
</div>
</div>
</div>
`;
}

updateTiles(){
if (this.status === OfflineStatus.UPDATE_AVAILABLE) {
this.offlineService.updateTiles()
}
}

createRenderRoot() {
// no shadow dom
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import 'jquery';
import 'bootstrap/js/modal.js';
import i18next from 'i18next';
import {LuxBaseElement} from '../../LuxBaseElement';
import {html} from 'lit';
import {customElement, state, query, property} from 'lit/decorators.js';
import { LuxOfflineServiceInstance, LuxOfflineService } from './lux-offline.service';
import { OfflineStatus } from './lux-offline.model';

@customElement('lux-offline-error')
export class LuxOfflineError extends LuxBaseElement {

@state()
private tileError;

@state()
private subscription;

@query('.modal-error')
private modal: HTMLElement;

private offlineService: LuxOfflineService;

constructor() {
super();
this.offlineService = LuxOfflineServiceInstance;
this.subscription = this.offlineService.tileError$.subscribe((tileError)=> {
if (tileError) {
$(this.modal).modal('show');
} else {
$(this.modal).modal('hide');
}
this.tileError = tileError;
});
}

disconnectedCallback() {
this.subscription.unsubscribe();
super.disconnectedCallback();
}

render() {
return html`
<div class="modal modal-error" tabindex="-1" role="dialog">
<div class="modal-dialog offline-modal" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">${i18next.t('An error occured during download')}</h4>
</div>
<div class="modal-body">
<div>
<div class="offline-btn btn btn-primary" @click="${this.updateTiles}">
${i18next.t('Retry')}
</div>
</div>
</div>
</div>
</div>
</div>
`;
}

updateTiles(){
this.offlineService.updateTiles()
}

createRenderRoot() {
// no shadow dom
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import 'jquery';
import 'bootstrap/js/modal.js';
import i18next from 'i18next';
import { combineLatestWith } from 'rxjs';
import {LuxBaseElement} from '../../LuxBaseElement';
import {html} from 'lit';
import {customElement, state, query} from 'lit/decorators.js';
import { LuxOfflineServiceInstance, LuxOfflineService } from './lux-offline.service';
import { OfflineStatus } from './lux-offline.model';

@customElement('lux-offline-reload')
export class LuxReloadAlert extends LuxBaseElement {

@state()
private status;

private prevStatus;

@query('.modal-reload')
private modal: HTMLElement;

private offlineService: LuxOfflineService

constructor() {
super();
this.offlineService = LuxOfflineServiceInstance
this.prevStatus = this.offlineService.status$.getValue();
this.offlineService.status$.pipe(
combineLatestWith(this.offlineService.tileError$)
).subscribe(([status, error])=> {
if ((status === OfflineStatus.UP_TO_DATE ||
status === OfflineStatus.DELETED)
&& this.prevStatus !== undefined
&& this.prevStatus !== OfflineStatus.UNINITIALIZED
&& !error) {
if (status !== this.prevStatus) {
$(this.modal).modal('show');
}
}
this.prevStatus = status;
});
$(this.modal).modal('hide');
}

render() {
return html`
<div class="modal modal-reload" tabindex="-1" role="dialog">
<div class="modal-dialog offline-modal" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">${i18next.t('App reload needed: Offline data updated successfully')}</h4>
</div>
<div class="modal-body">
<div>
<div class="offline-btn btn btn-primary" @click="${this.reloadApp}">
${i18next.t('Restart app')}
</div>
</div>
</div>
</div>
</div>
</div>
`;
}

reloadApp(){
location.reload()
$(this.modal).modal('hide');
}

createRenderRoot() {
// no shadow dom
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import i18next from 'i18next';
import {LuxBaseElement} from '../../LuxBaseElement';
import {html} from 'lit';
import {customElement, state, property} from 'lit/decorators.js';
import { LuxOfflineServiceInstance, LuxOfflineService } from './lux-offline.service';
import { OfflineStatus } from './lux-offline.model';

@customElement('lux-offline')
export class LuxOffline extends LuxBaseElement {

@property({type: Boolean})
disabled: boolean = false;

@property()
private bar;

@property()
private scope;

@state()
private menuDisplayed;

@state()
private status;

@state()
private subscription;

private offlineService: LuxOfflineService;

constructor() {
super();
this.offlineService = LuxOfflineServiceInstance;
this.subscription = this.offlineService.status$.subscribe((status)=> {
this.status = status;
});
}

disconnectedCallback() {
this.subscription.unsubscribe();
super.disconnectedCallback();
}

renderMenu() {
return html`
<div class="offline-btns">
<div class="offline-btn btn btn-primary" @click="${this.updateTiles}" ?disabled="${this.status!==OfflineStatus.UPDATE_AVAILABLE}">
${i18next.t('Update offline data')}
${this.status===OfflineStatus.IN_PROGRESS
? html `<i class="fa fa-circle-o-notch fa-spin"></i>`
: ''
}
</div>
<br>
<div class="offline-btn btn btn-primary" @click="${this.deleteTiles}" ?disabled="${this.status===OfflineStatus.IN_PROGRESS}">
${i18next.t('Delete offline data')}
</div>
<br>
</div>
`;
}

render() {
return html`
<div class="db-button ol-control">
<span>
<button ?disabled="${this.disabled || !this.offlineService.hasLocalServer()}" class="no-data offline-wc" @click="${this.toggleMenu}"
title="${i18next.t('Full offline (only available on mobile)')}">
<i class="fa fa-database" aria-hidden="true"></i>
</button>
</span>
</div>
${this.menuDisplayed ? this.renderMenu() : ""}
`;
}

updateTiles(){
if (this.status === OfflineStatus.UPDATE_AVAILABLE) {
this.offlineService.updateTiles()
}
}

deleteTiles(){
if (this.status !== OfflineStatus.IN_PROGRESS) {
this.offlineService.deleteTiles()
}
}

toggleMenu() {
this.menuDisplayed = !this.menuDisplayed;
if (this.menuDisplayed) {
this.offlineService.checkTiles(true);
}
this.bar.toggleFullOffline();
this.scope.$digest()
}

createRenderRoot() {
// no shadow dom
return this;
}
}
Loading

0 comments on commit e964099

Please sign in to comment.