Ignore:
Timestamp:
May 25, 2019, 5:40:08 PM (8 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, master
Children:
70f328b
Parents:
28198a1
git-author:
Joachim Langenbach <joachim.langenbach@…> (05/22/19 18:20:13)
git-committer:
Joachim Langenbach <joachim.langenbach@…> (05/25/19 17:40:08)
Message:

Gauges could be added now

Location:
src/mapservice-webclient
Files:
12 added
18 edited

Legend:

Unmodified
Added
Removed
  • src/mapservice-webclient/src-gen/gnuboat-mapservice/api/users.service.ts

    r28198a1 r13cbe66  
    148148        let headers = this.defaultHeaders;
    149149
    150         // authentication (apiKeyAuth) required
    151         if (this.configuration.apiKeys && this.configuration.apiKeys["X-API-KEY"]) {
    152             headers = headers.set('X-API-KEY', this.configuration.apiKeys["X-API-KEY"]);
    153         }
    154 
    155150        // authentication (basicAuth) required
    156151        if (this.configuration.username || this.configuration.password) {
    … …  
    197192        let headers = this.defaultHeaders;
    198193
    199         // authentication (apiKeyAuth) required
    200         if (this.configuration.apiKeys && this.configuration.apiKeys["X-API-KEY"]) {
    201             headers = headers.set('X-API-KEY', this.configuration.apiKeys["X-API-KEY"]);
    202         }
    203 
    204194        // authentication (basicAuth) required
    205195        if (this.configuration.username || this.configuration.password) {
    … …  
    231221    /**
    232222     * Returns info of a user
    233      * Returns information for a user
     223     * Returns information of current/authorized user
    234224     * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
    235225     * @param reportProgress flag to report request and response progress.
  • src/mapservice-webclient/src-gen/gnuboat-mapservice/api/waters.service.ts

    r28198a1 r13cbe66  
    1919import { Observable }                                        from 'rxjs/Observable';
    2020
     21import { Gauge } from '../model/gauge';
     22import { GaugeCreation } from '../model/gaugeCreation';
    2123import { HttpError } from '../model/httpError';
    2224import { Water } from '../model/water';
    … …  
    6163
    6264    /**
    63      * Represents a water
    64      * Returns the water identified by id
    65      * @param id Item ID
    66      * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
    67      * @param reportProgress flag to report request and response progress.
    68      */
    69     public waterGetById(id: number, observe?: 'body', reportProgress?: boolean): Observable<Water>;
    70     public waterGetById(id: number, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Water>>;
    71     public waterGetById(id: number, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Water>>;
    72     public waterGetById(id: number, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
    73         if (id === null || id === undefined) {
    74             throw new Error('Required parameter id was null or undefined when calling waterGetById.');
    75         }
    76 
    77         let headers = this.defaultHeaders;
    78 
    79         // to determine the Accept header
    80         const httpHeaderAccepts: string[] = [
    81             'application/json'
    82         ];
    83         const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
    84         if (httpHeaderAcceptSelected !== undefined) {
    85             headers = headers.set('Accept', httpHeaderAcceptSelected);
    86         }
    87 
    88         // to determine the Content-Type header
    89         const consumes: string[] = [
    90         ];
    91 
    92         return this.httpClient.get<Water>(`${this.configuration.basePath}/waters/${encodeURIComponent(String(id))}`,
    93             {
    94                 withCredentials: this.configuration.withCredentials,
    95                 headers: headers,
    96                 observe: observe,
    97                 reportProgress: reportProgress
    98             }
    99         );
    100     }
    101 
    102     /**
    10365     * Add a new water
    10466     * Adds a new water to the database
    … …  
    144106            waterCreation,
    145107            {
     108                withCredentials: this.configuration.withCredentials,
     109                headers: headers,
     110                observe: observe,
     111                reportProgress: reportProgress
     112            }
     113        );
     114    }
     115
     116    /**
     117     * Add a new water
     118     * Adds a new gauge for water waterId to the database
     119     * @param waterId Water ID
     120     * @param gaugeCreation
     121     * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
     122     * @param reportProgress flag to report request and response progress.
     123     */
     124    public watersGaugeCreate(waterId: number, gaugeCreation?: GaugeCreation, observe?: 'body', reportProgress?: boolean): Observable<Gauge>;
     125    public watersGaugeCreate(waterId: number, gaugeCreation?: GaugeCreation, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Gauge>>;
     126    public watersGaugeCreate(waterId: number, gaugeCreation?: GaugeCreation, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Gauge>>;
     127    public watersGaugeCreate(waterId: number, gaugeCreation?: GaugeCreation, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
     128        if (waterId === null || waterId === undefined) {
     129            throw new Error('Required parameter waterId was null or undefined when calling watersGaugeCreate.');
     130        }
     131
     132        let headers = this.defaultHeaders;
     133
     134        // authentication (apiKeyAuth) required
     135        if (this.configuration.apiKeys && this.configuration.apiKeys["X-API-KEY"]) {
     136            headers = headers.set('X-API-KEY', this.configuration.apiKeys["X-API-KEY"]);
     137        }
     138
     139        // authentication (basicAuth) required
     140        if (this.configuration.username || this.configuration.password) {
     141            headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password));
     142        }
     143        // to determine the Accept header
     144        const httpHeaderAccepts: string[] = [
     145            'application/json',
     146            'application/geo+json'
     147        ];
     148        const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
     149        if (httpHeaderAcceptSelected !== undefined) {
     150            headers = headers.set('Accept', httpHeaderAcceptSelected);
     151        }
     152
     153        // to determine the Content-Type header
     154        const consumes: string[] = [
     155            'application/json'
     156        ];
     157        const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
     158        if (httpContentTypeSelected !== undefined) {
     159            headers = headers.set('Content-Type', httpContentTypeSelected);
     160        }
     161
     162        return this.httpClient.post<Gauge>(`${this.configuration.basePath}/waters/${encodeURIComponent(String(waterId))}/gauges`,
     163            gaugeCreation,
     164            {
     165                withCredentials: this.configuration.withCredentials,
     166                headers: headers,
     167                observe: observe,
     168                reportProgress: reportProgress
     169            }
     170        );
     171    }
     172
     173    /**
     174     * Represents a gauge
     175     * Returns the gauge identified by id
     176     * @param waterId Water ID
     177     * @param gaugeId Gauge ID
     178     * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
     179     * @param reportProgress flag to report request and response progress.
     180     */
     181    public watersGaugeGetById(waterId: number, gaugeId: number, observe?: 'body', reportProgress?: boolean): Observable<Gauge>;
     182    public watersGaugeGetById(waterId: number, gaugeId: number, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Gauge>>;
     183    public watersGaugeGetById(waterId: number, gaugeId: number, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Gauge>>;
     184    public watersGaugeGetById(waterId: number, gaugeId: number, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
     185        if (waterId === null || waterId === undefined) {
     186            throw new Error('Required parameter waterId was null or undefined when calling watersGaugeGetById.');
     187        }
     188        if (gaugeId === null || gaugeId === undefined) {
     189            throw new Error('Required parameter gaugeId was null or undefined when calling watersGaugeGetById.');
     190        }
     191
     192        let headers = this.defaultHeaders;
     193
     194        // to determine the Accept header
     195        const httpHeaderAccepts: string[] = [
     196            'application/json',
     197            'application/geo+json'
     198        ];
     199        const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
     200        if (httpHeaderAcceptSelected !== undefined) {
     201            headers = headers.set('Accept', httpHeaderAcceptSelected);
     202        }
     203
     204        // to determine the Content-Type header
     205        const consumes: string[] = [
     206        ];
     207
     208        return this.httpClient.get<Gauge>(`${this.configuration.basePath}/waters/${encodeURIComponent(String(waterId))}/gauges/${encodeURIComponent(String(gaugeId))}`,
     209            {
     210                withCredentials: this.configuration.withCredentials,
     211                headers: headers,
     212                observe: observe,
     213                reportProgress: reportProgress
     214            }
     215        );
     216    }
     217
     218    /**
     219     * Find gauges of water waterId by gaugeId
     220     * Returns all gauges of water waterId
     221     * @param waterId Water ID
     222     * @param name
     223     * @param manager
     224     * @param orderBy Order by field: name
     225     * @param offset Skip over a number of elements by specifying an offset value for the query
     226     * @param limit Limit the number of elements on the response
     227     * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
     228     * @param reportProgress flag to report request and response progress.
     229     */
     230    public watersGaugesGet(waterId: number, name?: string, manager?: string, orderBy?: string, offset?: number, limit?: number, observe?: 'body', reportProgress?: boolean): Observable<Array<Gauge>>;
     231    public watersGaugesGet(waterId: number, name?: string, manager?: string, orderBy?: string, offset?: number, limit?: number, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Array<Gauge>>>;
     232    public watersGaugesGet(waterId: number, name?: string, manager?: string, orderBy?: string, offset?: number, limit?: number, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Array<Gauge>>>;
     233    public watersGaugesGet(waterId: number, name?: string, manager?: string, orderBy?: string, offset?: number, limit?: number, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
     234        if (waterId === null || waterId === undefined) {
     235            throw new Error('Required parameter waterId was null or undefined when calling watersGaugesGet.');
     236        }
     237
     238        let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
     239        if (name !== undefined && name !== null) {
     240            queryParameters = queryParameters.set('name', <any>name);
     241        }
     242        if (manager !== undefined && manager !== null) {
     243            queryParameters = queryParameters.set('manager', <any>manager);
     244        }
     245        if (orderBy !== undefined && orderBy !== null) {
     246            queryParameters = queryParameters.set('orderBy', <any>orderBy);
     247        }
     248        if (offset !== undefined && offset !== null) {
     249            queryParameters = queryParameters.set('offset', <any>offset);
     250        }
     251        if (limit !== undefined && limit !== null) {
     252            queryParameters = queryParameters.set('limit', <any>limit);
     253        }
     254
     255        let headers = this.defaultHeaders;
     256
     257        // to determine the Accept header
     258        const httpHeaderAccepts: string[] = [
     259            'application/json',
     260            'application/geo+json'
     261        ];
     262        const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
     263        if (httpHeaderAcceptSelected !== undefined) {
     264            headers = headers.set('Accept', httpHeaderAcceptSelected);
     265        }
     266
     267        // to determine the Content-Type header
     268        const consumes: string[] = [
     269        ];
     270
     271        return this.httpClient.get<Array<Gauge>>(`${this.configuration.basePath}/waters/${encodeURIComponent(String(waterId))}/gauges`,
     272            {
     273                params: queryParameters,
    146274                withCredentials: this.configuration.withCredentials,
    147275                headers: headers,
    … …  
    211339    }
    212340
     341    /**
     342     * Represents a water
     343     * Returns the water identified by id
     344     * @param id Item ID
     345     * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
     346     * @param reportProgress flag to report request and response progress.
     347     */
     348    public watersGetById(id: number, observe?: 'body', reportProgress?: boolean): Observable<Water>;
     349    public watersGetById(id: number, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Water>>;
     350    public watersGetById(id: number, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Water>>;
     351    public watersGetById(id: number, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
     352        if (id === null || id === undefined) {
     353            throw new Error('Required parameter id was null or undefined when calling watersGetById.');
     354        }
     355
     356        let headers = this.defaultHeaders;
     357
     358        // to determine the Accept header
     359        const httpHeaderAccepts: string[] = [
     360            'application/json'
     361        ];
     362        const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
     363        if (httpHeaderAcceptSelected !== undefined) {
     364            headers = headers.set('Accept', httpHeaderAcceptSelected);
     365        }
     366
     367        // to determine the Content-Type header
     368        const consumes: string[] = [
     369        ];
     370
     371        return this.httpClient.get<Water>(`${this.configuration.basePath}/waters/${encodeURIComponent(String(id))}`,
     372            {
     373                withCredentials: this.configuration.withCredentials,
     374                headers: headers,
     375                observe: observe,
     376                reportProgress: reportProgress
     377            }
     378        );
     379    }
     380
    213381}
  • src/mapservice-webclient/src-gen/gnuboat-mapservice/model/models.ts

    r28198a1 r13cbe66  
     1export * from './gauge';
     2export * from './gaugeCreation';
     3export * from './gaugeGeoJson';
     4export * from './gaugeGeoJsonProperties';
     5export * from './geoJsonPoint';
     6export * from './geoJsonType';
    17export * from './httpError';
    28export * from './order';
  • src/mapservice-webclient/src-gen/gnuboat-mapservice/model/water.ts

    r28198a1 r13cbe66  
    1010 * Do not edit the class manually.
    1111 */
     12import { Gauge } from './gauge';
    1213import { OsmType } from './osmType';
    1314
    … …  
    1920    osmId?: number;
    2021    osmType?: OsmType;
     22    gauges?: Array<Gauge>;
    2123}
    2224
  • src/mapservice-webclient/src/app/app.component.html

    r28198a1 r13cbe66  
    88          <li class="pure-menu-item"><a class="pure-menu-link" routerLink="water">Waters</a></li>
    99          <li class="pure-menu-heading">My GNUBoat</li>
     10          <li class="pure-menu-item"><a class="pure-menu-link" routerLink="mygnuboat" fragment="logfiles">Logfiles</a></li>
    1011          <li class="pure-menu-item"><a class="pure-menu-link" routerLink="mygnuboat" fragment="waters">Waters</a></li>
    11           <li class="pure-menu-item"><a class="pure-menu-link" routerLink="mygnuboat" fragment="logfiles">Logfiles</a></li>
    1212          <li class="pure-menu-item"><a class="pure-menu-link" routerLink="mygnuboat" fragment="profile">Profile</a></li>
    1313          <li class="pure-menu-item" *ngIf="currentUser"><a class="pure-menu-link" (click)="logout()">Logout</a></li>
  • src/mapservice-webclient/src/app/app.module.ts

    r28198a1 r13cbe66  
    1414import { HomeComponent } from './home/';
    1515import { LoginComponent, RegisterComponent } from './user';
    16 import { WatersComponent, WaterComponent, WaterDetailsComponent } from './water';
     16import { WatersComponent, WaterComponent, WaterDetailsComponent, GaugesComponent } from './water';
    1717import { MapComponent } from './map';
    18 import { UserComponent, WaterAddComponent } from './mygnuboat';
     18import { UserComponent, WaterAddComponent, GaugeEditComponent } from './mygnuboat';
    1919
    2020
    … …  
    3737    WaterComponent,
    3838    WaterDetailsComponent,
     39    GaugesComponent,
    3940    WaterAddComponent,
     41    GaugeEditComponent,
    4042    MapComponent,
    4143  ],
  • src/mapservice-webclient/src/app/map/map.component.ts

    r28198a1 r13cbe66  
    1 import { Component, OnInit, OnDestroy, Input, ViewChild, Output, EventEmitter } from '@angular/core';
     1import { Component, OnInit, OnDestroy, Input, ViewChild, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
    22
    33declare let L;
    44
    5 import { OsmType } from '../../../src-gen/gnuboat-mapservice';
     5import { OsmType, Water, Gauge, GaugeGeoJson, GeoJsonPoint, GaugeGeoJsonProperties } from '../../../src-gen/gnuboat-mapservice';
    66import { OsmOverpassService } from '../services';
    77import { GeoPoint } from '../model';
    … …  
    1212  providers: [OsmOverpassService],
    1313})
    14 export class MapComponent implements OnInit, OnDestroy {
     14export class MapComponent implements OnInit, OnDestroy, OnChanges {
    1515  private _mapViewportStyleClass:string;
    1616  private map;
    1717  private mapControl;
    18   private geoJsonLayer;
     18  private osmLayer;
     19  private gaugesLayer;
     20  @Input() water: Water = undefined;
    1921  @Input() controlsShow = true;
    2022  @ViewChild('mapElement') mapElement;
    21   @Output() clicked = new EventEmitter<GeoPoint>();
     23  @Output() clickedRight = new EventEmitter<GeoPoint>();
    2224
    2325  constructor(private osmOverpassService: OsmOverpassService) {
    … …  
    2931
    3032  ngOnDestroy() {
     33  }
     34
     35  ngOnChanges(changes: SimpleChanges): void {
     36    if('water' in changes && this.water && this.map){
     37      this.addWaterToMap(this.water);
     38    }
    3139  }
    3240
    … …  
    5159    });
    5260
    53     this.map.on('click', event => {
     61    this.map.on('contextmenu', event => {
    5462      var point = {} as GeoPoint;
    5563      point.latitude = event.latlng.lat;
    5664      point.longitude = event.latlng.lng;
    57       this.clicked.emit(point);
     65      this.clickedRight.emit(point);
     66      return event;
    5867    });
    5968
    … …  
    95104      L.control.scale().addTo(this.map);
    96105    }
     106
     107    if(this.water){
     108      this.addWaterToMap(this.water);
     109    }
    97110  }
    98111
    99112  addOsmElement(id: number, osmType: OsmType){
    100     if(!this.geoJsonLayer){
    101       this.geoJsonLayer = L.geoJSON().addTo(this.map);
     113    if(!this.osmLayer){
     114      this.osmLayer = this.addGeoJsonLayer();
    102115    }
     116    this.osmLayer.clearLayers();
    103117    this.osmOverpassService.getElement(id, osmType).subscribe(res => {
    104       this.geoJsonLayer.addData(res);
    105       this.map.fitBounds(this.geoJsonLayer.getBounds());
     118      this.osmLayer.addData(res);
     119      this.map.fitBounds(this.osmLayer.getBounds());
    106120    });
    107121  }
     122
     123  addGeoJsonLayer(options = {}){
     124    return L.geoJSON(undefined, options).addTo(this.map);
     125  }
     126
     127  addWaterToMap(water:Water){
     128    this.addOsmElement(water.osmId, water.osmType);
     129    if('gauges' in water){
     130      this.addGaugesToMap(water.gauges);
     131    }
     132  }
     133
     134  addGaugesToMap(gauges:Gauge[]){
     135    /* currently openapi-generators typescript-angular plugin isn't able to handle content types, which are not plain json
     136       therefore we convert the gauges here and add them to the map. The API as defined, supports geo+json format already
     137     */
     138    if(this.gaugesLayer){
     139      this.gaugesLayer.clearLayers();
     140    }
     141    if(gauges && gauges.length < 1){
     142      return;
     143    }
     144    if(!this.gaugesLayer){
     145      this.gaugesLayer = this.addGeoJsonLayer({
     146        onEachFeature: this.gaugesMarkerPopup,
     147        pointToLayer: this.gaugesMarker
     148      });
     149    }
     150    gauges.forEach(gauge => {
     151      var gaugeGeoJson = {} as GaugeGeoJson;
     152      gaugeGeoJson.type = "Feature";
     153      gaugeGeoJson.geometry = {} as GeoJsonPoint;
     154      gaugeGeoJson.geometry.type = "Point";
     155      gaugeGeoJson.geometry.coordinates = [];
     156      gaugeGeoJson.geometry.coordinates.push(gauge.location[0]);
     157      gaugeGeoJson.geometry.coordinates.push(gauge.location[1]);
     158      gaugeGeoJson.properties = {} as GaugeGeoJsonProperties;
     159      gaugeGeoJson.properties.name = gauge.name;
     160      gaugeGeoJson.properties.manager = gauge.manager;
     161      gaugeGeoJson.properties.comment = gauge.comment;
     162      this.gaugesLayer.addData(gaugeGeoJson);
     163    });
     164  }
     165
     166  gaugesMarker(feature, latlng){
     167    var markerOptions = {
     168      radius: 8,
     169      fillColor: "#ff7800",
     170      color: "#000",
     171      weight: 1,
     172      opacity: 1,
     173      fillOpacity: 0.8
     174    };
     175    return L.circleMarker(latlng, markerOptions);
     176  }
     177
     178  gaugesMarkerPopup(feature, layer) {
     179    if (feature.properties && feature.properties.name) {
     180        layer.bindPopup(feature.properties.name);
     181    }
     182  }
    108183}
  • src/mapservice-webclient/src/app/mygnuboat/index.ts

    r28198a1 r13cbe66  
    11export * from './user.component';
    22export * from './wateradd.component';
     3export * from './gaugeedit.component';
  • src/mapservice-webclient/src/app/mygnuboat/wateradd.component.html

    r28198a1 r13cbe66  
    11<div class="header">
    2   <h1>Add a new Water to GNUBoat</h1>
     2  <h1 i18n="@@wateraddTitle">Add a new Water to GNUBoat</h1>
    33  <alert></alert>
    44</div>
    … …  
    99        <fieldset>
    1010          <div class="pure-control-group">
    11             <label for="name">Name:</label>
    12             <input #waterNameInput id="waterNameAutocomplete" formControlName='name' type="text" placeholder="Name of Water" required>
     11            <label for="name" i18n="@@waterAddName">Name:</label>
     12            <input #waterNameInput id="waterNameAutocomplete" formControlName='name' type="text" i18n-placeholder placeholder="Name of Water" required>
    1313            <img *ngIf="isProcessingGnuBoat || isProcessingOverpass" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" />
    14             <span *ngIf="submitted && watersForm.name.errors" class="pure-form-message-inline">Watername is required.</span>
     14            <span *ngIf="submitted && watersForm.name.errors" class="pure-form-message-inline" i18n="@@waterNameRequired">Watername is required.</span>
    1515          </div>
    1616          <div class="pure-controls">
    17             <button [disabled]="!waterChoosen || !currentUser" *ngIf="!waterChoosen || waterChoosen.origin!=Origin.GNUBOAT" class="pure-button pure-button-primary">Add</button>
    18             <button [disabled]="!waterChoosen || !currentUser" *ngIf="waterChoosen && waterChoosen.origin==Origin.GNUBOAT" class="pure-button pure-button-primary">Choose</button>
     17            <button [disabled]="!waterChoosen || !currentUser" *ngIf="!waterChoosen || waterChoosen.origin!=Origin.GNUBOAT" class="pure-button pure-button-primary" i18n="@@waterButtonAdd">Add</button>
     18            <button [disabled]="!waterChoosen || !currentUser" *ngIf="waterChoosen && waterChoosen.origin==Origin.GNUBOAT" class="pure-button pure-button-primary" i18n="@@waterButtonChoose">Choose</button>
    1919          </div>
    2020        </fieldset>
  • src/mapservice-webclient/src/app/mygnuboat/wateradd.component.ts

    r28198a1 r13cbe66  
    201201    }
    202202    if(this.waterChoosen.origin == Origin.OSM){
    203       console.log("GNUBOAT --> OSM");
    204203      var water = {} as WaterCreation;
    205204      water.name = this.waterChoosen.value;
    … …  
    207206      water.osmType = this.waterChoosen.osmType;
    208207      this.watersService.watersCreate(water).pipe(first()).subscribe(result => {
    209         console.log([water.name, result.name]);
    210208        if(water.name == result.name){
    211209          this.router.navigate(['/water', result.waterId]);
  • src/mapservice-webclient/src/app/water/index.ts

    r28198a1 r13cbe66  
    22export * from './water.component';
    33export * from './waterdetails.component';
     4export * from './gauges.component';
  • src/mapservice-webclient/src/app/water/water.component.html

    r28198a1 r13cbe66  
    11<div class="water">
    22        <div class="water-background">
    3                 <gnuboat-map #mapComponent [viewportStyleClass]='mapViewportStyleClass' [controlsShow]='mapControlsShow'></gnuboat-map>
     3                <gnuboat-map #mapComponent [viewportStyleClass]='mapViewportStyleClass' [controlsShow]='mapControlsShow' [water]='water'></gnuboat-map>
    44        </div>
    55        <div class="water-content">
    6                 <h2>{{water.name}}</h2>
     6                <a [routerLink]="['/water', water.waterId]"><h2>{{water.name}}</h2></a>
    77                <ul>
    8                 <li>Managed by {{water.manager}}</li>
     8                <li *ngIf="water.gauges; else noGauges">{{water.gauges.length}} Gauges</li>
     9                <ng-template #noGauges><li>No Gauges</li></ng-template>
    910                <li><button class="button-add pure-button">Upload Logfile</button></li>
    1011                <li><a class="pure-button water-edit" [routerLink]="['/water', water.waterId]"><span *ngIf="user">Edit / </span>Details</a></li>
  • src/mapservice-webclient/src/app/water/water.component.ts

    r28198a1 r13cbe66  
    1 import { Component, OnInit, OnDestroy, AfterViewInit, Input, ViewChild } from '@angular/core';
     1import { Component, OnInit, OnDestroy, Input, ViewChild } from '@angular/core';
    22import { Subscription } from 'rxjs';
    33import { first } from 'rxjs/operators';
    … …  
    1212  templateUrl: 'water.component.html',
    1313})
    14 export class WaterComponent implements OnInit, OnDestroy, AfterViewInit {
     14export class WaterComponent implements OnInit, OnDestroy {
    1515  @Input() water: Water;
    1616  @Input() user: User;
    … …  
    2525  }
    2626
    27   ngAfterViewInit() {
    28     this.mapComponent.addOsmElement(this.water.osmId, this.water.osmType);
    29   }
    30 
    3127  ngOnDestroy() {
    3228  }
  • src/mapservice-webclient/src/app/water/waterdetails.component.html

    r28198a1 r13cbe66  
    44</div>
    55<div class="content">
    6   <p *ngIf="currentUser">Click on Map to add new Levels</p>
    7   <gnuboat-map #mapComponent [viewportStyleClass]='mapViewportStyleClass' [controlsShow]='mapControlsShow' (clicked)='mapClicked($event)'></gnuboat-map>
    8   <h2 class="content-subhead">Levels</h2>
    9 
     6  <p *ngIf="currentUser">Right click on Map to add new Gauges</p>
     7  <gnuboat-map #mapComponent [viewportStyleClass]='mapViewportStyleClass' [controlsShow]='mapControlsShow' (clickedRight)='mapClicked($event)' [water]='water'></gnuboat-map>
     8  <gnuboat-gauge-edit *ngIf="gaugeEditing" [water]="water" [gauge]="gaugeEditing" (cancel)='gaugeEditingCanceled()' (gaugeCreated)='gaugeCreated($event)'></gnuboat-gauge-edit>
     9  <gnuboat-gauges [water]="water" [mapComponent]="mapComponent"></gnuboat-gauges>
    1010</div>
    1111
  • src/mapservice-webclient/src/app/water/waterdetails.component.ts

    r28198a1 r13cbe66  
    1 import { Component, OnInit, OnDestroy, AfterViewInit, Input, ViewChild } from '@angular/core';
     1import { Component, OnInit, OnDestroy, Input, ViewChild } from '@angular/core';
    22import { Router, ActivatedRoute, ParamMap } from '@angular/router';
    33import { switchMap, first } from 'rxjs/operators';
    44import { Observable, Subscription } from 'rxjs';
    55
    6 import { User, Water, WatersService } from '../../../src-gen/gnuboat-mapservice';
     6import { User, Water, Gauge, GaugeCreation, WatersService } from '../../../src-gen/gnuboat-mapservice';
    77import { MapComponent } from '../map';
    88import { GeoPoint } from '../model';
    … …  
    1212  templateUrl: 'waterdetails.component.html',
    1313})
    14 export class WaterDetailsComponent implements OnInit, OnDestroy, AfterViewInit {
     14export class WaterDetailsComponent implements OnInit, OnDestroy {
    1515  @Input() water: Water;
    1616  mapViewportStyleClass:string = "water-edit-map";
    … …  
    1818  @ViewChild('mapComponent') mapComponent: MapComponent;
    1919  currentUser: User = undefined;
     20  gaugeEditing: GaugeCreation = undefined;
    2021
    2122  private currentUserSubscription: Subscription;
    … …  
    3839      }
    3940    });
    40   }
    41 
    42   ngAfterViewInit() {
    4341    const id = Number(this.route.snapshot.paramMap.get('id'));
    44     this.watersService.waterGetById(id).subscribe(water => {
     42    this.watersService.watersGetById(id).subscribe(water => {
    4543      this.water = water;
    46       this.mapComponent.addOsmElement(water.osmId, water.osmType);
    4744    },
    4845    error => {
    … …  
    5552
    5653  mapClicked(point: GeoPoint){
    57     console.log(point);
     54    if(!this.currentUser){
     55      return;
     56    }
     57    if(this.gaugeEditing){
     58      this.alertService.error("Please finish or abort your currently edited gauge before creating a new one!");
     59      return;
     60    }
     61    this.gaugeEditing = {} as GaugeCreation;
     62    this.gaugeEditing.location = [];
     63    this.gaugeEditing.location.push(point.longitude);
     64    this.gaugeEditing.location.push(point.latitude);
     65    this.gaugeEditing.comment = "";
     66  }
     67
     68  gaugeEditingCanceled(){
     69    this.gaugeEditing = undefined;
     70  }
     71
     72  gaugeCreated(gauge: Gauge){
     73    this.water.gauges.push(gauge);
     74    this.water = Object.assign({}, this.water);
     75    this.gaugeEditing = undefined;
    5876  }
    5977}
  • src/mapservice-webclient/src/app/water/waters.component.ts

    r28198a1 r13cbe66  
    33import { first } from 'rxjs/operators';
    44
     5import { WaterDetailsComponent } from './';
    56import { User, UsersService, Water, WatersService } from '../../../src-gen/gnuboat-mapservice';
    67import { AuthenticationService } from '../services';
    … …  
    89@Component({
    910  selector: 'gnuboat-waters',
    10   templateUrl: 'waters.component.html'
     11  templateUrl: 'waters.component.html',
    1112})
    1213export class WatersComponent implements OnInit, OnDestroy {
  • src/mapservice-webclient/src/css/GnuBoat.Mapservice.Webclient.css

    r28198a1 r13cbe66  
    123123}
    124124
    125 .water h2 {
     125.water a, .water a:link, .water a:visited, .water a:hover, .water a:active {
     126  text-decoration: None;
     127  color: inherit;
     128}
     129
     130.water a h2 {
    126131  padding: 0.8em;
    127132  margin: 0;
  • src/mapservice-webclient/src/tsconfig.app.json

    r28198a1 r13cbe66  
    1111        "app/*"
    1212      ]
    13     }
     13    },
    1414    "outDir": "../out-tsc/app",
    1515    "types": []
Note: See TracChangeset for help on using the changeset viewer.