add contracts
This commit is contained in:
96
ui/hv2-ui/package-lock.json
generated
96
ui/hv2-ui/package-lock.json
generated
@ -33,8 +33,6 @@
|
||||
"@types/jasmine": "~3.6.0",
|
||||
"@types/node": "^12.11.1",
|
||||
"codelyzer": "^6.0.0",
|
||||
"jasmine-core": "~3.6.0",
|
||||
"jasmine-spec-reporter": "~5.0.0",
|
||||
"karma": "~5.1.0",
|
||||
"karma-chrome-launcher": "~3.1.0",
|
||||
"karma-coverage": "~2.0.3",
|
||||
@ -3588,6 +3586,16 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/bindings": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/blob": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz",
|
||||
@ -6612,6 +6620,13 @@
|
||||
"url": "https://opencollective.com/webpack"
|
||||
}
|
||||
},
|
||||
"node_modules/file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
@ -8575,19 +8590,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/jasmine-core": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.6.0.tgz",
|
||||
"integrity": "sha512-8uQYa7zJN8hq9z+g8z1bqCfdC8eoDAeVnM5sfqs7KHv9/ifoJ500m018fpFc7RDaO6SWCLCXwo/wPSNcdYTgcw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/jasmine-spec-reporter": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-5.0.2.tgz",
|
||||
"integrity": "sha512-6gP1LbVgJ+d7PKksQBc2H0oDGNRQI3gKUsWlswKaQ2fif9X5gzhQcgM5+kiJGCQVurOG09jqNhk7payggyp5+g==",
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-4.5.0.tgz",
|
||||
"integrity": "sha512-9PMzyvhtocxb3aXJVOPqBDswdgyAeSB81QnLop4npOpbqnheaTEwPc9ZloQeVswugPManznQBjD8kWDTjlnHuw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"colors": "1.4.0"
|
||||
}
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/jasmine/node_modules/jasmine-core": {
|
||||
"version": "2.8.0",
|
||||
@ -8889,6 +8896,12 @@
|
||||
"karma-jasmine": ">=1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/karma-jasmine/node_modules/jasmine-core": {
|
||||
"version": "3.99.1",
|
||||
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.99.1.tgz",
|
||||
"integrity": "sha512-Hu1dmuoGcZ7AfyynN3LsfruwMbxMALMka+YtZeGoLuDEySVmVAPaonkNoBRIw/ectu8b9tVQCJNgp4a4knp+tg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/karma-source-map-support": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/karma-source-map-support/-/karma-source-map-support-1.4.0.tgz",
|
||||
@ -9980,6 +9993,13 @@
|
||||
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/nan": {
|
||||
"version": "2.17.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz",
|
||||
"integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/nanomatch": {
|
||||
"version": "1.2.13",
|
||||
"resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
|
||||
@ -19949,6 +19969,16 @@
|
||||
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
|
||||
"dev": true
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"blob": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz",
|
||||
@ -22456,6 +22486,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
@ -23973,19 +24010,11 @@
|
||||
}
|
||||
},
|
||||
"jasmine-core": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.6.0.tgz",
|
||||
"integrity": "sha512-8uQYa7zJN8hq9z+g8z1bqCfdC8eoDAeVnM5sfqs7KHv9/ifoJ500m018fpFc7RDaO6SWCLCXwo/wPSNcdYTgcw==",
|
||||
"dev": true
|
||||
},
|
||||
"jasmine-spec-reporter": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-5.0.2.tgz",
|
||||
"integrity": "sha512-6gP1LbVgJ+d7PKksQBc2H0oDGNRQI3gKUsWlswKaQ2fif9X5gzhQcgM5+kiJGCQVurOG09jqNhk7payggyp5+g==",
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-4.5.0.tgz",
|
||||
"integrity": "sha512-9PMzyvhtocxb3aXJVOPqBDswdgyAeSB81QnLop4npOpbqnheaTEwPc9ZloQeVswugPManznQBjD8kWDTjlnHuw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"colors": "1.4.0"
|
||||
}
|
||||
"peer": true
|
||||
},
|
||||
"jasminewd2": {
|
||||
"version": "2.2.0",
|
||||
@ -24354,6 +24383,14 @@
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"jasmine-core": "^3.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"jasmine-core": {
|
||||
"version": "3.99.1",
|
||||
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.99.1.tgz",
|
||||
"integrity": "sha512-Hu1dmuoGcZ7AfyynN3LsfruwMbxMALMka+YtZeGoLuDEySVmVAPaonkNoBRIw/ectu8b9tVQCJNgp4a4knp+tg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"karma-jasmine-html-reporter": {
|
||||
@ -25101,6 +25138,13 @@
|
||||
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
|
||||
"dev": true
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.17.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz",
|
||||
"integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"nanomatch": {
|
||||
"version": "1.2.13",
|
||||
"resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
|
||||
|
@ -37,8 +37,6 @@
|
||||
"@types/jasmine": "~3.6.0",
|
||||
"@types/node": "^12.11.1",
|
||||
"codelyzer": "^6.0.0",
|
||||
"jasmine-core": "~3.6.0",
|
||||
"jasmine-spec-reporter": "~5.0.0",
|
||||
"karma": "~5.1.0",
|
||||
"karma-chrome-launcher": "~3.1.0",
|
||||
"karma-coverage": "~2.0.3",
|
||||
|
@ -20,11 +20,14 @@ import { FeeDetailsComponent } from './fee-details/fee-details.component';
|
||||
import { EnterPaymentComponent } from './enter-payment/enter-payment.component';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { LedgerComponent } from './ledger/ledger.component';
|
||||
import { ContractComponent } from './contract/contract.component';
|
||||
import { MyContractsComponent } from './my-contracts/my-contracts.component';
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: 'tenants', component: MyTenantsComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'premises', component: MyPremisesComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'contracts', component: MyContractsComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'flats', component: MyFlatsComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'parkings', component: MyParkingsComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'commercialunits', component: MyCommercialUnitsComponent, canActivate: [ AuthGuardService ] },
|
||||
@ -46,6 +49,8 @@ const routes: Routes = [
|
||||
{ path: 'fee', component: FeeDetailsComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'enterPayment', component: EnterPaymentComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'ledger', component: LedgerComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'contract', component: ContractComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'contract/:id', component: ContractComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'home', component: HomeComponent },
|
||||
{ path: 'logout', component: LogoutComponent },
|
||||
{ path: 'login', component: LoginComponent },
|
||||
|
@ -51,6 +51,8 @@ import { HomeComponent } from './home/home.component';
|
||||
import { LedgerComponent } from './ledger/ledger.component';
|
||||
import { ErrorDialogComponent } from './error-dialog/error-dialog.component'
|
||||
import { MatSortModule } from '@angular/material/sort';
|
||||
import { ContractComponent } from './contract/contract.component';
|
||||
import { MyContractsComponent } from './my-contracts/my-contracts.component';
|
||||
|
||||
registerLocaleData(localeDe)
|
||||
|
||||
@ -81,7 +83,9 @@ registerLocaleData(localeDe)
|
||||
EnterPaymentComponent,
|
||||
HomeComponent,
|
||||
LedgerComponent,
|
||||
ErrorDialogComponent
|
||||
ErrorDialogComponent,
|
||||
ContractComponent,
|
||||
MyContractsComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -1,5 +1,5 @@
|
||||
export const serviceBaseUrl = "https://api.hv.nober.de";
|
||||
// export const serviceBaseUrl = "https://api.hv.nober.de";
|
||||
// export const serviceBaseUrl = "http://172.16.3.96:8080";
|
||||
// export const serviceBaseUrl = "http://localhost:8080"
|
||||
export const serviceBaseUrl = "http://localhost:8080"
|
||||
export const authserviceBaseUrl = "https://authservice.hottis.de"
|
||||
export const applicationId = "hv2"
|
||||
|
4
ui/hv2-ui/src/app/contract/contract.component.css
Normal file
4
ui/hv2-ui/src/app/contract/contract.component.css
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
.notearea {
|
||||
width: 75%;
|
||||
}
|
46
ui/hv2-ui/src/app/contract/contract.component.html
Normal file
46
ui/hv2-ui/src/app/contract/contract.component.html
Normal file
@ -0,0 +1,46 @@
|
||||
<section class="mat-typography">
|
||||
<mat-card class="defaultCard">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
{{contract?.supplier}} {{contract?.content}}
|
||||
</mat-card-title>
|
||||
<mat-card-subtitle>
|
||||
ID: {{contract?.id}}
|
||||
</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div>>
|
||||
<form (ngSubmit)="saveContract()">
|
||||
<div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Partner</mat-label>
|
||||
<input matInput name="supplier" [(ngModel)]="contract.supplier"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Gegenstand</mat-label>
|
||||
<input matInput name="content" [(ngModel)]="contract.content"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>ID</mat-label>
|
||||
<input matInput name="identifier" [(ngModel)]="contract.identifier"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline" class="notearea">
|
||||
<mat-label>Notizen</mat-label>
|
||||
<textarea matInput
|
||||
cdkTextareaAutosize
|
||||
#autosize="cdkTextareaAutosize"
|
||||
cdkAutosizeMinRows="5"
|
||||
cdkAutosizeMaxRows="10"
|
||||
name="notes" [(ngModel)]="contract.notes"></textarea>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</section>
|
25
ui/hv2-ui/src/app/contract/contract.component.spec.ts
Normal file
25
ui/hv2-ui/src/app/contract/contract.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ContractComponent } from './contract.component';
|
||||
|
||||
describe('ContractComponent', () => {
|
||||
let component: ContractComponent;
|
||||
let fixture: ComponentFixture<ContractComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ContractComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ContractComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
61
ui/hv2-ui/src/app/contract/contract.component.ts
Normal file
61
ui/hv2-ui/src/app/contract/contract.component.ts
Normal file
@ -0,0 +1,61 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ContractService } from '../data-object-service';
|
||||
import { Contract, NULL_CommercialPremise, NULL_Contract } from '../data-objects';
|
||||
import { MessageService } from '../message.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-contract',
|
||||
templateUrl: './contract.component.html',
|
||||
styleUrls: ['./contract.component.css']
|
||||
})
|
||||
export class ContractComponent implements OnInit {
|
||||
|
||||
@ViewChild('submitButton') submitButton: MatButton
|
||||
|
||||
contract: Contract = NULL_Contract
|
||||
|
||||
constructor(
|
||||
private contractService: ContractService,
|
||||
private messageService: MessageService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router
|
||||
) { }
|
||||
|
||||
async getContract(): Promise<void> {
|
||||
try {
|
||||
const id = +this.route.snapshot.paramMap.get('id')
|
||||
if (id != 0) {
|
||||
this.contract = await this.contractService.getContract(id)
|
||||
}
|
||||
} catch (err) {
|
||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||
}
|
||||
}
|
||||
|
||||
async saveContract() {
|
||||
try {
|
||||
this.submitButton.disabled = true
|
||||
this.messageService.add(`saveContract: ${ JSON.stringify(this.contract, undefined, 4) }`)
|
||||
if (this.contract.id == 0) {
|
||||
this.messageService.add("about to insert new contract")
|
||||
this.contract = await this.contractService.postContract(this.contract)
|
||||
this.messageService.add(`Successfully added contract with id ${this.contract.id}`)
|
||||
} else {
|
||||
this.messageService.add("about to update existing contract")
|
||||
this.contract = await this.contractService.putContract(this.contract)
|
||||
this.messageService.add(`Successfully changed contract with id ${this.contract.id}`)
|
||||
}
|
||||
this.router.navigate(['/contracts'])
|
||||
} finally {
|
||||
this.submitButton.disabled = false
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getContract()
|
||||
}
|
||||
|
||||
}
|
@ -27,6 +27,7 @@ import { TenancyFeeMapping } from './data-objects';
|
||||
import { AccountEntryCategory } from './data-objects';
|
||||
import { AccountEntry } from './data-objects';
|
||||
import { Note } from './data-objects';
|
||||
import { Contract } from './data-objects';
|
||||
|
||||
|
||||
|
||||
@ -519,4 +520,35 @@ export class NoteService {
|
||||
|
||||
}
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ContractService {
|
||||
constructor(private messageService: MessageService, private http: HttpClient) { }
|
||||
|
||||
async getContracts(): Promise<Contract[]> {
|
||||
this.messageService.add(`ContractService: get data`);
|
||||
return this.http.get<Contract[]>(`${serviceBaseUrl}/v1/contracts`).toPromise()
|
||||
}
|
||||
|
||||
async getContract(id: number): Promise<Contract> {
|
||||
this.messageService.add(`ContractService: get data for ${id}`);
|
||||
return this.http.get<Contract>(`${serviceBaseUrl}/v1/contracts/${id}`).toPromise()
|
||||
}
|
||||
|
||||
async postContract(item: Contract): Promise<Contract> {
|
||||
let itemStr: string = JSON.stringify(item, undefined, 4)
|
||||
this.messageService.add(`ContractService: post data for ${itemStr}`);
|
||||
return this.http.post<Contract>(`${serviceBaseUrl}/v1/contracts`, item).toPromise()
|
||||
}
|
||||
|
||||
async putContract(item: Contract): Promise<Contract> {
|
||||
let itemStr: string = JSON.stringify(item, undefined, 4)
|
||||
this.messageService.add(`ContractService: put data for ${itemStr}`)
|
||||
let id: number = item["id"]
|
||||
return this.http.put<Contract>(`${serviceBaseUrl}/v1/contracts/${id}`, item).toPromise()
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,4 +226,19 @@ export const NULL_Note: Note = {
|
||||
,note: ''
|
||||
}
|
||||
|
||||
export interface Contract {
|
||||
id: number
|
||||
supplier: string
|
||||
content: string
|
||||
identifier: string
|
||||
notes: string
|
||||
}
|
||||
export const NULL_Contract: Contract = {
|
||||
id: 0
|
||||
,supplier: ''
|
||||
,content: ''
|
||||
,identifier: ''
|
||||
,notes: ''
|
||||
}
|
||||
|
||||
|
||||
|
31
ui/hv2-ui/src/app/my-contracts/my-contracts.component.html
Normal file
31
ui/hv2-ui/src/app/my-contracts/my-contracts.component.html
Normal file
@ -0,0 +1,31 @@
|
||||
<section class="mat-typography">
|
||||
<mat-card class="defaultCard">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
<span>Meine Verträge</span>
|
||||
<span class="spacer"></span>
|
||||
<a mat-button routerLink="/contract">Neu anlegen</a>
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div>
|
||||
<table mat-table [dataSource]="dataSource" #zftable>
|
||||
<ng-container matColumnDef="supplier">
|
||||
<th mat-header-cell *matHeaderCellDef>Partner</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.supplier}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="content">
|
||||
<th mat-header-cell *matHeaderCellDef>Gegenstand</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.content}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="identifier">
|
||||
<th mat-header-cell *matHeaderCellDef>ID</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.identifier}}</td>
|
||||
</ng-container>
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/contract/', row.id]"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</section>
|
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MyContractsComponent } from './my-contracts.component';
|
||||
|
||||
describe('MyContractsComponent', () => {
|
||||
let component: MyContractsComponent;
|
||||
let fixture: ComponentFixture<MyContractsComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ MyContractsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MyContractsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
38
ui/hv2-ui/src/app/my-contracts/my-contracts.component.ts
Normal file
38
ui/hv2-ui/src/app/my-contracts/my-contracts.component.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { ContractService } from '../data-object-service';
|
||||
import { Contract } from '../data-objects';
|
||||
import { MessageService } from '../message.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-my-contracts',
|
||||
templateUrl: './my-contracts.component.html',
|
||||
styleUrls: ['./my-contracts.component.css']
|
||||
})
|
||||
export class MyContractsComponent implements OnInit {
|
||||
|
||||
contracts: Contract[]
|
||||
dataSource: MatTableDataSource<Contract>
|
||||
displayedColumns: string[] = [ "supplier", "content", "identifier" ]
|
||||
|
||||
constructor(private contractService: ContractService, private messageService: MessageService) { }
|
||||
|
||||
async getContracts(): Promise<void> {
|
||||
try {
|
||||
this.messageService.add("Trying to load contracts")
|
||||
this.contracts = await this.contractService.getContracts();
|
||||
this.messageService.add("Contracts loaded")
|
||||
|
||||
this.dataSource = new MatTableDataSource<Contract>(this.contracts)
|
||||
} catch (err) {
|
||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.messageService.add("MyContractsComponent.ngOnInit")
|
||||
this.getContracts()
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -22,6 +22,8 @@
|
||||
<a mat-list-item href="/premises">Meine Häuser</a>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/ledger">Buchführung</a>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/contracts">Verträge</a>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/logout">Abmelden</a>
|
||||
</mat-nav-list>
|
||||
|
Reference in New Issue
Block a user