update methods and immutable attribute added

This commit is contained in:
2021-09-07 15:22:55 +02:00
parent 0afef9f3cd
commit 6470aa5358
10 changed files with 956 additions and 20 deletions

View File

@ -2,4 +2,4 @@
// export const serviceBaseUrl = "http://172.16.10.38:5000";
export const serviceBaseUrl = "http://localhost:8080"
export const authserviceBaseUrl = "https://authservice.hottis.de"
export const applicationId = "hv2"

View File

@ -7,8 +7,7 @@
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { MessageService } from './message.service';
import { serviceBaseUrl } from './config';
@ -54,6 +53,13 @@ export class AccountService {
return this.http.post<Account>(`${serviceBaseUrl}/v1/accounts`, item).toPromise()
}
async putAccount(item: Account): Promise<Account> {
let itemStr: string = JSON.stringify(item, undefined, 4)
this.messageService.add(`AccountService: put data for ${itemStr}`)
let id: number = item["id"]
return this.http.put<Account>(`${serviceBaseUrl}/v1/accounts/${id}`, item).toPromise()
}
}
@Injectable({ providedIn: 'root' })
@ -76,6 +82,13 @@ export class TenantService {
return this.http.post<Tenant>(`${serviceBaseUrl}/v1/tenants`, item).toPromise()
}
async putTenant(item: Tenant): Promise<Tenant> {
let itemStr: string = JSON.stringify(item, undefined, 4)
this.messageService.add(`TenantService: put data for ${itemStr}`)
let id: number = item["id"]
return this.http.put<Tenant>(`${serviceBaseUrl}/v1/tenants/${id}`, item).toPromise()
}
}
@Injectable({ providedIn: 'root' })
@ -98,6 +111,13 @@ export class PremiseService {
return this.http.post<Premise>(`${serviceBaseUrl}/v1/premises`, item).toPromise()
}
async putPremise(item: Premise): Promise<Premise> {
let itemStr: string = JSON.stringify(item, undefined, 4)
this.messageService.add(`PremiseService: put data for ${itemStr}`)
let id: number = item["id"]
return this.http.put<Premise>(`${serviceBaseUrl}/v1/premises/${id}`, item).toPromise()
}
}
@Injectable({ providedIn: 'root' })
@ -120,6 +140,13 @@ export class FlatService {
return this.http.post<Flat>(`${serviceBaseUrl}/v1/flats`, item).toPromise()
}
async putFlat(item: Flat): Promise<Flat> {
let itemStr: string = JSON.stringify(item, undefined, 4)
this.messageService.add(`FlatService: put data for ${itemStr}`)
let id: number = item["id"]
return this.http.put<Flat>(`${serviceBaseUrl}/v1/flats/${id}`, item).toPromise()
}
}
@Injectable({ providedIn: 'root' })
@ -142,6 +169,13 @@ export class OverheadAdvanceService {
return this.http.post<OverheadAdvance>(`${serviceBaseUrl}/v1/overhead_advances`, item).toPromise()
}
async putOverheadAdvance(item: OverheadAdvance): Promise<OverheadAdvance> {
let itemStr: string = JSON.stringify(item, undefined, 4)
this.messageService.add(`OverheadAdvanceService: put data for ${itemStr}`)
let id: number = item["id"]
return this.http.put<OverheadAdvance>(`${serviceBaseUrl}/v1/overhead_advances/${id}`, item).toPromise()
}
}
@Injectable({ providedIn: 'root' })
@ -164,6 +198,7 @@ export class OverheadAdvanceFlatMappingService {
return this.http.post<OverheadAdvanceFlatMapping>(`${serviceBaseUrl}/v1/overhead_advance_flat_mappings`, item).toPromise()
}
}
@Injectable({ providedIn: 'root' })
@ -186,6 +221,13 @@ export class ParkingService {
return this.http.post<Parking>(`${serviceBaseUrl}/v1/parkings`, item).toPromise()
}
async putParking(item: Parking): Promise<Parking> {
let itemStr: string = JSON.stringify(item, undefined, 4)
this.messageService.add(`ParkingService: put data for ${itemStr}`)
let id: number = item["id"]
return this.http.put<Parking>(`${serviceBaseUrl}/v1/parkings/${id}`, item).toPromise()
}
}
@Injectable({ providedIn: 'root' })
@ -208,6 +250,13 @@ export class CommercialPremiseService {
return this.http.post<CommercialPremise>(`${serviceBaseUrl}/v1/commercial_premises`, item).toPromise()
}
async putCommercialPremise(item: CommercialPremise): Promise<CommercialPremise> {
let itemStr: string = JSON.stringify(item, undefined, 4)
this.messageService.add(`CommercialPremiseService: put data for ${itemStr}`)
let id: number = item["id"]
return this.http.put<CommercialPremise>(`${serviceBaseUrl}/v1/commercial_premises/${id}`, item).toPromise()
}
}
@Injectable({ providedIn: 'root' })
@ -230,6 +279,13 @@ export class TenancyService {
return this.http.post<Tenancy>(`${serviceBaseUrl}/v1/tenancys`, item).toPromise()
}
async putTenancy(item: Tenancy): Promise<Tenancy> {
let itemStr: string = JSON.stringify(item, undefined, 4)
this.messageService.add(`TenancyService: put data for ${itemStr}`)
let id: number = item["id"]
return this.http.put<Tenancy>(`${serviceBaseUrl}/v1/tenancys/${id}`, item).toPromise()
}
}
@Injectable({ providedIn: 'root' })
@ -252,6 +308,13 @@ export class FeeService {
return this.http.post<Fee>(`${serviceBaseUrl}/v1/fees`, item).toPromise()
}
async putFee(item: Fee): Promise<Fee> {
let itemStr: string = JSON.stringify(item, undefined, 4)
this.messageService.add(`FeeService: put data for ${itemStr}`)
let id: number = item["id"]
return this.http.put<Fee>(`${serviceBaseUrl}/v1/fees/${id}`, item).toPromise()
}
}
@Injectable({ providedIn: 'root' })
@ -274,6 +337,7 @@ export class TenancyFeeMappingService {
return this.http.post<TenancyFeeMapping>(`${serviceBaseUrl}/v1/tenancy_fee_mappings`, item).toPromise()
}
}
@Injectable({ providedIn: 'root' })
@ -296,6 +360,7 @@ export class AccountEntryService {
return this.http.post<AccountEntry>(`${serviceBaseUrl}/v1/account_entrys`, item).toPromise()
}
}

View File

@ -2,8 +2,7 @@ $GENERATED_TS_COMMENT
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { MessageService } from './message.service';
import { serviceBaseUrl } from './config';
@ -42,6 +41,15 @@ export class ${JsNameConverter($table.name)}Service {
return this.http.post<${JsNameConverter($table.name)}>(`\${serviceBaseUrl}/v1/${table.name}s`, item).toPromise()
}
#if (('immutable' not in $table) or (not $table.immutable))
async put${JsNameConverter($table.name)}(item: ${JsNameConverter($table.name)}): Promise<${JsNameConverter($table.name)}> {
let itemStr: string = JSON.stringify(item, undefined, 4)
this.messageService.add(`${JsNameConverter($table.name)}Service: put data for \${itemStr}`)
let id: number = item["id"]
return this.http.put<${JsNameConverter($table.name)}>(`\${serviceBaseUrl}/v1/${table.name}s/\${id}`, item).toPromise()
}
#end if
}
#end for

View File

@ -5,7 +5,7 @@ import { UserCreds } from './userCreds'
import jwt_decode from 'jwt-decode'
import { Observable, interval, Subject, Subscription } from 'rxjs'
import { map, takeWhile } from 'rxjs/operators'
import { authserviceBaseUrl } from './config'
import { authserviceBaseUrl, applicationId } from './config'
interface TokenTuple {
@ -66,7 +66,7 @@ export class TokenService {
async login(login: string, password: string) : Promise<void> {
this.messageService.add(`TokenService: trying to login and obtain token`)
const userCreds : UserCreds = {
"application": "hv2",
"application": applicationId,
"login": login,
"password": password
}