-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/integration' into integration
- Loading branch information
Showing
22 changed files
with
719 additions
and
196 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
88 changes: 88 additions & 0 deletions
88
.../geoportailv3_geoportal/static-ngeo/js/offline/lux-offline/lux-offline-alert.component.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,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">×</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; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
.../geoportailv3_geoportal/static-ngeo/js/offline/lux-offline/lux-offline-error.component.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,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">×</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; | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...geoportailv3_geoportal/static-ngeo/js/offline/lux-offline/lux-offline-reload.component.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,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">×</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; | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
geoportal/geoportailv3_geoportal/static-ngeo/js/offline/lux-offline/lux-offline.component.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,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; | ||
} | ||
} |
Oops, something went wrong.