-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
196 additions
and
5 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
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
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
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
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
56 changes: 56 additions & 0 deletions
56
...src/pages/component-editor/component-editor-geolocation/component-editor-geolocation.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,56 @@ | ||
<component-editor [outputBlock]="outputBlock"> | ||
<ion-item no-lines text-wrap> | ||
<p [innerHtml]="'geoLocationDescription' | translate"></p> | ||
</ion-item> | ||
|
||
<ion-item no-lines> | ||
<ion-label no-lines>{{ 'geoLocationSavedLocations' | translate }}</ion-label> | ||
</ion-item> | ||
<ion-item no-lines text-wrap> | ||
<p>{{ 'geoLocationAssignNames' | translate }}</p> | ||
<p> | ||
<a class="clickable" (click)="electronProvider.shell.openExternal('https://www.loom.com/share/07153366b44c40d9b778396671cada98?sid=c9cd4e33-6653-4541-a42b-566889806cb6')"> | ||
{{ 'geoLocationCoordinatesTutorial' | translate }} | ||
</a> | ||
</p> | ||
</ion-item> | ||
<ion-grid class="fields" [hidden]="!savedGeoLocations || !savedGeoLocations.length"> | ||
<ion-item no-lines *ngFor="let field of savedGeoLocations; let i = index;"> | ||
<ion-row no-padding> | ||
<ion-col> | ||
<input [(ngModel)]="savedGeoLocations[i].name" class="inline-input" type="text" placeholder="Location name" /> | ||
</ion-col> | ||
<ion-col col-3> | ||
<input (keyup)="onLatitudeChange(i)" (change)="onLatitudeChange(i)" [(ngModel)]="savedGeoLocations[i].latitude" class="inline-input" type="text" placeholder="0.000000" /> | ||
</ion-col> | ||
<ion-col col-3> | ||
<input [(ngModel)]="savedGeoLocations[i].longitude" class="inline-input" type="text" placeholder="0.000000" /> | ||
</ion-col> | ||
<ion-col col-1> | ||
<button ion-button small center clear icon-only color="output-block-component-geolocation" class="btn-output-template-action" (click)="deleteSavedLocation(i)"> | ||
<ion-icon name="trash"></ion-icon> | ||
</button> | ||
</ion-col> | ||
</ion-row> | ||
</ion-item> | ||
</ion-grid> | ||
|
||
<p [hidden]="!(!savedGeoLocations || !savedGeoLocations.length)" text-center> | ||
{{ 'geoLocationNotfound' | translate }} | ||
</p> | ||
|
||
<ion-item text-center padding-top no-lines> | ||
<button ion-button small icon-start (click)="addSavedLocation()" color="output-block-component-geolocation"> | ||
<ion-icon name="add"></ion-icon> | ||
{{ 'geoLocationAddLocation' | translate }} | ||
</button> | ||
</ion-item> | ||
|
||
<ion-item text-wrap [hidden]="!savedGeoLocations || !savedGeoLocations.length"> | ||
<label for="_maxDistanceFromSavedLocation">{{ 'geoLocationMaxDistanceFromSavedLocation' | translate }}</label> | ||
<input id="_maxDistanceFromSavedLocation" [(ngModel)]="outputBlock.maxDistanceFromSavedLocation" class="inline-input" type="number" placeholder="0" /> | ||
<br> | ||
<p>{{ 'geoLocationMaxDistanceFromSavedLocationDescription' | translate }}</p> | ||
</ion-item> | ||
|
||
</component-editor> |
13 changes: 13 additions & 0 deletions
13
...src/pages/component-editor/component-editor-geolocation/component-editor-geolocation.scss
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,13 @@ | ||
page-component-editor-geolocation { | ||
ion-col { | ||
padding: 0 10px 0 0 !important; | ||
|
||
input { | ||
margin-top: 1px !important | ||
} | ||
} | ||
|
||
.fields ion-label { | ||
margin: 0; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...c/src/pages/component-editor/component-editor-geolocation/component-editor-geolocation.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,58 @@ | ||
import { Component } from '@angular/core'; | ||
import { NavParams } from 'ionic-angular'; | ||
import { OutputBlockModel } from '../../../models/output-block.model'; | ||
import { ElectronProvider } from '../../../providers/electron/electron'; | ||
import { UtilsProvider } from '../../../providers/utils/utils'; | ||
import { Config } from '../../../config'; | ||
|
||
@Component({ | ||
selector: 'page-component-editor-geolocation', | ||
templateUrl: 'component-editor-geolocation.html', | ||
}) | ||
export class ComponentEditorGeolocationPage { | ||
|
||
public outputBlock: OutputBlockModel; | ||
public savedGeoLocations: { name: string, latitude: number, longitude: number }[] = []; | ||
|
||
constructor( | ||
public navParams: NavParams, | ||
private utilsProvider: UtilsProvider, | ||
private electronProvider: ElectronProvider, | ||
) { | ||
this.outputBlock = this.navParams.get('outputBlock'); | ||
|
||
this.savedGeoLocations = this.electronProvider.store.get(Config.STORAGE_SAVED_GEOLOCATIONS, []); | ||
} | ||
|
||
ionViewWillUnload() { | ||
this.outputBlock.value = Math.random() + ''; // trigger Save & Apply | ||
// keep only locations that have actual values and that can be converted to numbers | ||
this.savedGeoLocations = this.savedGeoLocations.filter(x => x.latitude && x.longitude && !isNaN(x.latitude) && !isNaN(x.longitude)); | ||
// convert to numbers | ||
this.savedGeoLocations = this.savedGeoLocations.map(x => { return { name: x.name, latitude: parseFloat(x.latitude.toString()), longitude: parseFloat(x.longitude.toString()) } }); | ||
// save | ||
this.electronProvider.store.set(Config.STORAGE_SAVED_GEOLOCATIONS, this.savedGeoLocations); | ||
} | ||
|
||
ionViewDidLoad() { | ||
console.log('ionViewDidLoad ComponentEditorGeolocationPage'); | ||
} | ||
|
||
async addSavedLocation() { | ||
this.savedGeoLocations = [...this.savedGeoLocations, { name: await this.utilsProvider.text('savedLocation') + (this.savedGeoLocations.length + 1).toString(), latitude: null, longitude: null }]; | ||
} | ||
|
||
deleteSavedLocation(removeIndex: number) { | ||
this.savedGeoLocations = this.savedGeoLocations.filter((x, index) => index != removeIndex); | ||
} | ||
|
||
onLatitudeChange(index: number) { | ||
let latitude = (this.savedGeoLocations[index].latitude || 0).toString(); | ||
if (latitude.indexOf(',') > -1) { | ||
let latitudeLongitude = latitude.split(','); | ||
this.savedGeoLocations[index].latitude = parseFloat(latitudeLongitude[0] || '0'); | ||
this.savedGeoLocations[index].longitude = parseFloat(latitudeLongitude[1] || '0'); | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.