Changeset 955f4b4


Ignore:
Timestamp:
Oct 20, 2019, 6:34:05 PM (7 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, master
Children:
4348785
Parents:
ca1bb14
Message:

Device section of service implemented:

  • Listing devices of current user
  • Adding devices
  • deleting devices
Location:
src/mapservice-webclient/src/app
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/mapservice-webclient/src/app/app.module.ts

    rca1bb14 r955f4b4  
    1616import { WatersComponent, WaterComponent, WaterDetailsComponent, GaugesComponent } from './water';
    1717import { MapComponent } from './map';
    18 import { UserComponent, WaterAddComponent, GaugeEditComponent } from './mygnuboat';
     18import { UserComponent, WaterAddComponent, GaugeEditComponent, DeviceAddComponent } from './mygnuboat';
    1919
    2020
    … …  
    4040    WaterAddComponent,
    4141    GaugeEditComponent,
     42    DeviceAddComponent,
    4243    MapComponent,
    4344  ],
  • src/mapservice-webclient/src/app/app.routing.ts

    rca1bb14 r955f4b4  
    44import { LoginComponent, RegisterComponent } from './user';
    55import { WatersComponent, WaterDetailsComponent } from './water';
    6 import { UserComponent, WaterAddComponent } from './mygnuboat';
     6import { UserComponent, WaterAddComponent, DeviceAddComponent } from './mygnuboat';
    77import { HomeComponent } from './home';
    88
    … …  
    1212  { path: 'mygnuboat', component: UserComponent, canActivate: [AuthGuard] },
    1313  { path: 'mygnuboat/water/add', component: WaterAddComponent, canActivate: [AuthGuard] },
     14  { path: 'mygnuboat/device/add', component: DeviceAddComponent, canActivate: [AuthGuard] },
    1415  { path: 'water', component: WatersComponent },
    1516  { path: 'water/:id', component: WaterDetailsComponent },
  • src/mapservice-webclient/src/app/mygnuboat/index.ts

    rca1bb14 r955f4b4  
    22export * from './wateradd.component';
    33export * from './gaugeedit.component';
     4export * from './deviceadd.component';
  • src/mapservice-webclient/src/app/mygnuboat/user.component.html

    rca1bb14 r955f4b4  
    1919  </div>
    2020  <h2 class="content-subhead"><object data="/resources/gnuboat-device.svg" ype="image/svg++xml" class="svg-icon"></object>Devices</h2>
     21  <div>
     22    <a name="devices"></a>
     23    <p><a class="pure-button button-add" routerLink="device/add">Add Device</a></p>
     24    <table id="devices" class="pure-table pure-table-horizontal pure-table-striped">
     25      <thead>
     26        <tr>
     27          <th>Name</th>
     28          <th>Sensor Depth</th>
     29          <th>Comment</th>
     30          <th></th>
     31          <th></th>
     32        </tr>
     33      </thead>
     34      <tbody>
     35        <tr *ngFor="let device of devices">
     36          <td id="name">{{device.name}}</td>
     37          <td id="sensorDepth">{{device.sensorDepth}}cm</td>
     38          <td id="comment">{{device.comment}}</td>
     39          <td id="button"><button disabled (click)="deviceUploadLogfile(apiKey)" class="button-add pure-button">Upload Logfile</button></td>
     40          <td id="button"><button (click)="deviceDelete(device)" class="button-remove pure-button">Delete</button></td>
     41        </tr>
     42      </tbody>
     43    </table>
     44  </div>
    2145  <h2 class="content-subhead">Your API keys</h2>
    2246  <div>
  • src/mapservice-webclient/src/app/mygnuboat/user.component.ts

    rca1bb14 r955f4b4  
    33import { first } from 'rxjs/operators';
    44
    5 import { User, UsersService, Water, WatersService } from '../../../src-gen/gnuboat-mapservice';
    6 import { AuthenticationService } from '../services';
     5import { User, UsersService, Water, WatersService, Device, DevicesService } from '../../../src-gen/gnuboat-mapservice';
     6import { AuthenticationService, AlertService } from '../services';
    77
    88@Component({ templateUrl: 'user.component.html' })
    … …  
    1212    apiKeys: string[] = [];
    1313    waters: Water[] = [];
     14    devices: Device[] = [];
    1415
    1516    constructor(
    1617        private authenticationService: AuthenticationService,
    1718        private usersService: UsersService,
    18         private watersService: WatersService
     19        private watersService: WatersService,
     20        private devicesService: DevicesService,
     21        private alertService: AlertService
    1922    ) {
    2023        this.currentUserSubscription = this.authenticationService.currentUser.subscribe(user => {
    … …  
    2629            this.watersService.watersGet(undefined, user.username).pipe(first()).subscribe(waters => {
    2730              this.waters = waters
     31            });
     32            this.devicesService.devicesGet().pipe(first()).subscribe(devices => {
     33              this.devices = devices
    2834            });
    2935        });
    … …  
    3945    }
    4046
     47     deviceDelete(device: Device) {
     48        this.devicesService.devicesDeviceDelete(device.deviceId).pipe(first()).subscribe(devices => {
     49          this.devices = devices
     50        },
     51        error => {
     52          this.alertService.error(error);
     53        });
     54    }
     55
    4156    apiKeyDelete(apiKey: string) {
    4257        this.usersService.usersApiKeyDelete(apiKey).pipe(first()).subscribe(keys => {
    4358          this.apiKeys = keys
     59        },
     60        error => {
     61          this.alertService.error(error);
    4462        });
    4563    }
    … …  
    4866      this.usersService.usersApiKeyCreate().pipe(first()).subscribe(keys => {
    4967        this.apiKeys = keys
     68      },
     69      error => {
     70        this.alertService.error(error);
    5071      });
    5172    }
  • src/mapservice-webclient/src/app/water/gauges.component.html

    rca1bb14 r955f4b4  
    1515        <td>{{decimalDegreesToDegreesMinutesSeconds(gauge.location[1], Coordinate.Latitude)}}</td>
    1616        <td>{{decimalDegreesToDegreesMinutesSeconds(gauge.location[0], Coordinate.Longitude)}}</td>
    17         <td><a *ngIf="user && gauge.manager==currentuser.username" class="pure-button" [routerLink]="['/water', water.waterId]">Edit</a></td>
     17        <td>
     18          <a *ngIf="currentUser" class="pure-button" [routerLink]="['/water', water.waterId]">Edit</a>
     19        </td>
    1820      </tr>
    1921    </ng-container>
Note: See TracChangeset for help on using the changeset viewer.