UI: BulkList
This commit is contained in:
parent
3f0fa3ca3f
commit
56660b2d31
@ -30,4 +30,12 @@ export class Bulk {
|
||||
return this.fromJson(json);
|
||||
}
|
||||
|
||||
public static trackBy(index: number, item: Bulk): number {
|
||||
return item.id;
|
||||
}
|
||||
|
||||
public static compareName(a: Bulk, b: Bulk): number {
|
||||
return a.name.localeCompare(b.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -40,4 +40,8 @@ export class BulkService implements ISearchService {
|
||||
this.api.getItem("bulk/create/", Bulk.fromJson, next, error);
|
||||
}
|
||||
|
||||
delete(bulk: Bulk, next: () => void, error: (error: any) => void = NO_OP): void {
|
||||
this.api.getItem("bulk/delete/" + bulk.id, _ => _, next, error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,17 +9,25 @@ import {ChannelListComponent} from "./pages/channel-list/channel-list.component"
|
||||
import {AreaListComponent} from "./pages/mobile/device-tree/area-list/area-list.component";
|
||||
import {RoomListComponent} from "./pages/mobile/device-tree/room-list/room-list.component";
|
||||
import {DeviceListComponent} from "./pages/mobile/device-tree/device-list/device-list.component";
|
||||
import {BulkListComponent} from "./pages/bulk/bulk-list/bulk-list.component";
|
||||
import {BulkComponent} from "./pages/bulk/bulk/bulk.component";
|
||||
|
||||
const routes: Routes = [
|
||||
{path: 'Device', component: DeviceComponent},
|
||||
{path: 'DeviceAllList', component: DeviceAllListComponent},
|
||||
|
||||
// {path: 'Channel', component: ChannelComponent},
|
||||
{path: 'ChannelList', component: ChannelListComponent},
|
||||
|
||||
// {path: 'Property', component: PropertyComponent},
|
||||
{path: 'PropertyList', component: PropertyListComponent},
|
||||
|
||||
{path: 'Schedule', component: ScheduleComponent},
|
||||
{path: 'ScheduleList', component: ScheduleListComponent},
|
||||
|
||||
{path: 'Bulk', component: BulkComponent},
|
||||
{path: 'BulkList', component: BulkListComponent},
|
||||
|
||||
{path: 'AreaList', component: AreaListComponent},
|
||||
{path: 'RoomList', component: RoomListComponent},
|
||||
{path: 'DeviceList', component: DeviceListComponent},
|
||||
|
||||
@ -7,6 +7,10 @@
|
||||
Geräte
|
||||
</div>
|
||||
|
||||
<div class="item" routerLink="/BulkList" routerLinkActive="itemActive">
|
||||
Massenverarbeitung
|
||||
</div>
|
||||
|
||||
<div class="item itemSecondary" routerLink="/PropertyList" routerLinkActive="itemActive">
|
||||
Eigenschaften
|
||||
</div>
|
||||
|
||||
@ -18,6 +18,8 @@ import {ChannelListComponent} from './pages/channel-list/channel-list.component'
|
||||
import {AreaListComponent} from './pages/mobile/device-tree/area-list/area-list.component';
|
||||
import {RoomListComponent} from './pages/mobile/device-tree/room-list/room-list.component';
|
||||
import {DeviceListComponent} from './pages/mobile/device-tree/device-list/device-list.component';
|
||||
import {BulkListComponent} from './pages/bulk/bulk-list/bulk-list.component';
|
||||
import {BulkComponent} from './pages/bulk/bulk/bulk.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@ -34,6 +36,8 @@ import {DeviceListComponent} from './pages/mobile/device-tree/device-list/device
|
||||
AreaListComponent,
|
||||
RoomListComponent,
|
||||
DeviceListComponent,
|
||||
BulkListComponent,
|
||||
BulkComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
<table>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Bezeichnung</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
<tr *ngFor="let bulk of bulks; trackBy: Bulk.trackBy">
|
||||
|
||||
<td class="boolean" (click)="set(bulk, 'enabled', !bulk.enabled)" [class.true]="bulk.enabled" [class.false]="!bulk.enabled">
|
||||
<fa-icon *ngIf="bulk.enabled" [icon]="faCheckCircle"></fa-icon>
|
||||
<fa-icon *ngIf="!bulk.enabled" [icon]="faCircle"></fa-icon>
|
||||
</td>
|
||||
|
||||
<td [routerLink]="['/Bulk', {id: bulk.id}]">
|
||||
{{bulk.name}}
|
||||
</td>
|
||||
|
||||
<td class="delete" (click)="delete(bulk)">
|
||||
<fa-icon title="Löschen" [icon]="faTimes"></fa-icon>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<button (click)="create()">+ Hinzufügen</button>
|
||||
</p>
|
||||
@ -0,0 +1,25 @@
|
||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {BulkListComponent} from './bulk-list.component';
|
||||
|
||||
describe('BulkListComponent', () => {
|
||||
let component: BulkListComponent;
|
||||
let fixture: ComponentFixture<BulkListComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [BulkListComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(BulkListComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,61 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {BulkService} from "../../../api/bulk/bulkService";
|
||||
import {Bulk} from "../../../api/bulk/Bulk";
|
||||
import {faCheckCircle, faCircle, faTimesCircle} from "@fortawesome/free-regular-svg-icons";
|
||||
|
||||
@Component({
|
||||
selector: 'app-bulk-list',
|
||||
templateUrl: './bulk-list.component.html',
|
||||
styleUrls: ['./bulk-list.component.less']
|
||||
})
|
||||
export class BulkListComponent implements OnInit {
|
||||
|
||||
readonly faCheckCircle = faCheckCircle;
|
||||
|
||||
readonly faCircle = faCircle;
|
||||
|
||||
readonly faTimes = faTimesCircle;
|
||||
|
||||
readonly Bulk = Bulk;
|
||||
|
||||
bulks: Bulk[] = [];
|
||||
|
||||
constructor(
|
||||
readonly bulkService: BulkService,
|
||||
) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bulkService.findAll(list => this.bulks = list)
|
||||
}
|
||||
|
||||
set(bulk: Bulk, key: string, value: any): void {
|
||||
this.bulkService.set(bulk, key, value, bulk => this.addOrReplace(bulk));
|
||||
}
|
||||
|
||||
private addOrReplace(bulk: Bulk): void {
|
||||
const index: number = this.bulks.findIndex(s => s.id === bulk.id);
|
||||
if (index < 0) {
|
||||
this.bulks.push(bulk);
|
||||
} else {
|
||||
this.bulks[index] = bulk;
|
||||
}
|
||||
this.bulks = this.bulks.sort(Bulk.compareName)
|
||||
}
|
||||
|
||||
private remove(bulk: Bulk): void {
|
||||
this.bulks.splice(this.bulks.findIndex(s => s.id === bulk.id), 1);
|
||||
}
|
||||
|
||||
create(): void {
|
||||
this.bulkService.create(bulk => this.addOrReplace(bulk));
|
||||
}
|
||||
|
||||
delete(bulk: Bulk): void {
|
||||
if (confirm("Zeitplan \"" + bulk.name + "\" wirklich löschen?")) {
|
||||
this.bulkService.delete(bulk, () => this.remove(bulk));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<p>bulk works!</p>
|
||||
@ -0,0 +1,25 @@
|
||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {BulkComponent} from './bulk.component';
|
||||
|
||||
describe('BulkComponent', () => {
|
||||
let component: BulkComponent;
|
||||
let fixture: ComponentFixture<BulkComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [BulkComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(BulkComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
16
src/main/angular/src/app/pages/bulk/bulk/bulk.component.ts
Normal file
16
src/main/angular/src/app/pages/bulk/bulk/bulk.component.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-bulk',
|
||||
templateUrl: './bulk.component.html',
|
||||
styleUrls: ['./bulk.component.less']
|
||||
})
|
||||
export class BulkComponent implements OnInit {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
||||
@ -13,6 +13,7 @@ export class ScheduleListComponent implements OnInit {
|
||||
readonly faCheckCircle = faCheckCircle;
|
||||
readonly faCircle = faCircle;
|
||||
readonly faTimes = faTimesCircle;
|
||||
|
||||
readonly Schedule = Schedule;
|
||||
|
||||
schedules: Schedule[] = [];
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<th>Unschärfe</th>
|
||||
<th colspan="6">Nächste Ausführung</th>
|
||||
<th colspan="2">Eingeschaft setzen</th>
|
||||
<th>Massenausführung</th>
|
||||
<th>Massenverarbeitung</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
<tr *ngFor="let entry of schedule.entries" [class.disabled]="entry.nextClearTimestamp === null">
|
||||
|
||||
@ -32,17 +32,17 @@ public class BulkController implements ISearchController {
|
||||
return bulkReader.filter(filter);
|
||||
}
|
||||
|
||||
@DeleteMapping("delete")
|
||||
public void delete(@RequestBody final long id) {
|
||||
@GetMapping("delete/{id}")
|
||||
public void delete(@PathVariable final long id) {
|
||||
bulkWriter.delete(id);
|
||||
}
|
||||
|
||||
@PostMapping("name/{id}")
|
||||
@PostMapping("set/{id}/name")
|
||||
public BulkDto name(@PathVariable final long id, @RequestBody final String name) {
|
||||
return bulkWriter.set(id, bulk -> bulk.setName(name));
|
||||
}
|
||||
|
||||
@PostMapping("enabled/{id}")
|
||||
@PostMapping("set/{id}/enabled")
|
||||
public BulkDto enabled(@PathVariable final long id, @RequestBody final boolean enabled) {
|
||||
return bulkWriter.set(id, bulk -> bulk.setEnabled(enabled));
|
||||
}
|
||||
@ -79,6 +79,12 @@ public class BulkController implements ISearchController {
|
||||
return bulkReader.findAllDtoLike("%" + term + "%").stream().map(this::toSearchResult).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@GetMapping("findAll")
|
||||
@Deprecated(since = "Use 'filter' instead", forRemoval = true)
|
||||
public List<BulkDto> findAll() {
|
||||
return bulkReader.findAllDto();
|
||||
}
|
||||
|
||||
private SearchResult toSearchResult(final BulkDto bulkDto) {
|
||||
return new SearchResult(bulkDto.getId(), bulkDto.getName());
|
||||
}
|
||||
|
||||
@ -37,4 +37,9 @@ public class BulkReader {
|
||||
return bulkRepository.findAllByNameLike(term).stream().map(bulkMapper::toDto).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Deprecated(since = "Use 'filter' instead", forRemoval = true)
|
||||
public List<BulkDto> findAllDto() {
|
||||
return bulkRepository.findAll().stream().map(bulkMapper::toDto).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user