Skip to content

Commit

Permalink
[fix] Peer select modal : Show if GVA is enable
Browse files Browse the repository at this point in the history
[enh] Enable ES plugin by default
  • Loading branch information
blavenie committed Jul 26, 2019
1 parent 52da514 commit 4a92287
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 56 deletions.
6 changes: 4 additions & 2 deletions src/app/core/peer/select-peer.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<!-- icon -->
<ion-avatar slot="start" *ngIf="peer.reachable && peer.avatar" >
<ion-img [src]="peer.avatar"></ion-img>
<ion-img [src]="peer.avatar.src"></ion-img>
</ion-avatar>
<ion-icon slot="start" *ngIf="peer.reachable && !peer.avatar" name="desktop" color="success" text-center></ion-icon>
<ion-icon slot="start" *ngIf="!peer.reachable" name="desktop" color="medium" text-center></ion-icon>
Expand All @@ -50,7 +50,9 @@ <h4>{{peer.label}}</h4>
</ion-col>
<ion-col no-padding>
<ion-label text-wrap text-center color="medium">
<h3>{{peer.softwareName}}</h3>
<h3>{{peer.softwareName}}
<span *ngIf="peer.hasEndpoint('GVA')">(GVA)</span>
</h3>
<h4><small>v{{peer.softwareVersion}}</small></h4>
</ion-label>
</ion-col>
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/services/local-settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ export class LocalSettingsService {
return this.data && this.data.properties && this.data.properties[propertyName];
}

getPropertyAsString(option: FormFieldDefinition): any {
return this.getProperty(option.key) || option.defaultValue;
}

getPropertyAsBoolean(option: FormFieldDefinition): any {
return toBoolean(this.getProperty(option.key), option.defaultValue);
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/core/services/network/network.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export class Peer extends Entity<Peer, string> {
}

static parseUrl(peerUrl: string) {
if (isNilOrBlank(peerUrl)) throw Error('Unable to parse an empty url');
if (peerUrl && !peerUrl.startsWith('http://') && !peerUrl.startsWith('https://')) {
return Peer.parseUrl('http://' + peerUrl);
}
const url = new URL(peerUrl);
return Peer.fromObject({
dns: url.hostname,
Expand All @@ -29,7 +33,7 @@ export class Peer extends Entity<Peer, string> {
useSsl: boolean;
pubkey: string;

avatar: string;
avatar?: {src?: string};
status: 'UP' | 'DOWN';
softwareName: string;
softwareVersion: string;
Expand Down
9 changes: 8 additions & 1 deletion src/app/plugins/es/es.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ import {DuniterRegexpStr} from "../../core/services/duniter/duniter.constants";
import {FormFieldType} from "../../shared/form/field.model";

export const EsOptions = {
ENABLE: {
key: 'plugin.es.enable',
label: 'PLUGINS.ES.SETTINGS.ENABLE',
type: 'boolean' as FormFieldType,
defaultValue: true
},
PEER_URL: {
key: 'plugin.es.peerUrl',
label: 'PLUGINS.ES.SETTINGS.PEER_URL',
type: 'string' as FormFieldType
type: 'string' as FormFieldType,
defaultValue: 'g1.data.duniter.fr:443'
},
ENABLE_WOT_MIXED_SEARCH: {
key: 'plugin.es.wot.mixedSearch',
Expand Down
30 changes: 15 additions & 15 deletions src/app/plugins/es/es.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,21 @@ export class EsModule {
});

// profile.address
wotService.addAdditionalField({
key: 'address',
label: 'PLUGINS.ES.PROFILE.ADDRESS',
type: 'string',
extra: {
registration: {
required: false,
disable: true
},
account: {
required: false,
disable: false
}
}
});
// wotService.addAdditionalField({
// key: 'address',
// label: 'PLUGINS.ES.PROFILE.ADDRESS',
// type: 'string',
// extra: {
// registration: {
// required: false,
// disable: true
// },
// account: {
// required: false,
// disable: false
// }
// }
// });
// profile.city
wotService.addAdditionalField({
key: 'city',
Expand Down
12 changes: 10 additions & 2 deletions src/app/plugins/es/services/es-network.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export class EsNetworkService {
this.resetData();

// Start the service
this.start();
//this.start();

// Start the service
this.network.onStart.subscribe(() => this.restart());

// For DEV only
this._debug = !environment.production;
Expand All @@ -80,7 +83,7 @@ export class EsNetworkService {
this._startPromise = this.settings.ready()
.then(async () => {

const peerUrl = this.settings.getProperty(EsOptions.PEER_URL.key);
const peerUrl = this.settings.getPropertyAsString(EsOptions.PEER_URL);
let peer = peerUrl && Peer.parseUrl(peerUrl);

// No peer: ask user to choose
Expand Down Expand Up @@ -129,6 +132,11 @@ export class EsNetworkService {
this._subscriptions = [];
}

async restart(): Promise<any> {
if (this.started) this.stop();
return this.start();
}

/**
* Check if the peer is alive
* @param email
Expand Down
43 changes: 10 additions & 33 deletions src/app/wot/pages/wot-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,14 @@

<ion-content no-padding>

<mat-toolbar no-padding hidden-xs>

<!-- <button mat-icon-button *ngIf="!selection.hasValue()" [title]="'COMMON.BTN_ADD'|translate" (click)="addRow()"-->
<!-- [class.hidden]="!inlineEdition">-->
<!-- <mat-icon>add</mat-icon>-->
<!-- </button>-->
<!-- <button mat-icon-button color="light" *ngIf="!selection.hasValue()" [title]="'COMMON.BTN_REFRESH'|translate"-->
<!-- (click)="onRefresh.emit()">-->
<!-- <mat-icon>refresh</mat-icon>-->
<!-- </button>-->
<!-- <button mat-icon-button *ngIf="!selection.hasValue()" [title]="'COMMON.BTN_FILTER'|translate" (click)="filterExpansionPanel.toggle()">-->
<!-- <mat-icon>search</mat-icon>-->
<!-- </button>-->
<!-- <button mat-icon-button color="light" *ngIf="selection.hasValue()" [title]="'COMMON.BTN_DELETE'|translate" (click)="deleteSelection()"-->
<!-- [class.hidden]="!inlineEdition">-->
<!-- <mat-icon>delete</mat-icon>-->
<!-- </button>-->
<mat-toolbar no-padding>

<div class="toolbar-spacer"></div>

<button mat-icon-button color="light"
[title]="'PLUGINS.ES.MAP.TITLE'|translate" [routerLink]="['map']">
<mat-icon>location_on</mat-icon>
</button>
<!-- <button mat-icon-button color="light"-->
<!-- [title]="'PLUGINS.ES.MAP.TITLE'|translate" [routerLink]="['map']">-->
<!-- <mat-icon>location_on</mat-icon>-->
<!-- </button>-->

<button mat-icon-button [title]="'COMMON.DISPLAYED_COLUMNS'|translate" (click)="openSelectColumnsModal($event)">
<mat-icon>more_vert</mat-icon>
Expand Down Expand Up @@ -160,17 +144,10 @@
</ion-col>
</ion-row>

<!--ion-fab right bottom>
<button ion-fab color="light" (click)="openTripModal()"><ion-icon name="md-add"></ion-icon></button>
</ion-fab-->
</ion-content>

<ion-footer hidden-xs hidden-sm *ngIf="inlineEdition">
<form-buttons-bar (onCancel)="onRefresh.emit()" (onSave)="save()" [disabled]="loading || !dirty"></form-buttons-bar>
</ion-footer>

<ion-fab vertical="bottom" horizontal="end" visible-xs visible-sm>
<ion-fab-button color="secondary" (click)="addRow()">
<ion-icon name="add"></ion-icon>
</ion-fab-button>
</ion-fab>
<!--<ion-fab vertical="bottom" horizontal="end" visible-xs visible-sm>-->
<!-- <ion-fab-button color="secondary" (click)="addRow()">-->
<!-- <ion-icon name="add"></ion-icon>-->
<!-- </ion-fab-button>-->
<!--</ion-fab>-->
4 changes: 4 additions & 0 deletions src/app/wot/pages/wot-search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
color: var(--ion-color-medium)
}

.mat-column-city {
max-width: 150px;
}

.mat-cell.additional-field ion-label {
text-overflow: ellipsis;
max-height: 40px;
Expand Down
4 changes: 3 additions & 1 deletion src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@
"PLUGINS": {
"ES": {
"SETTINGS": {
"PEER_URL": "Addresse du noeud Cesium+"
"ENABLE": "Activer Cesium+ ?",
"PEER_URL": "Addresse du noeud Cesium+",
"ENABLE_WOT_MIXED_SEARCH": "Annuaire > Rechercher dans les pages Cesium+ ?"
},
"PROFILE": {
"PROFILE_DIVIDER": "Profil Cesium+",
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<title id="appTitle">Loading...</title>
<link id="appFavicon" rel="icon" type="image/x-icon" href="./favicon.ico">

<base href="/cesium2/">
<base href="/">

<link rel="manifest" href="./manifest.json">
<meta name="theme-color" content="#4e8ef7">
Expand Down

0 comments on commit 4a92287

Please sign in to comment.