-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
598 additions
and
17 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
backend/src/main/java/at/camconnect/boundary/DeviceSetResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,31 @@ | ||
package at.camconnect.boundary; | ||
|
||
import at.camconnect.model.Device; | ||
import at.camconnect.repository.DeviceSetRepository; | ||
import at.camconnect.responseSystem.CCException; | ||
import at.camconnect.responseSystem.CCResponse; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import java.util.List; | ||
|
||
@Path("deviceset") | ||
public class DeviceSetResource { | ||
//TODO this and the repo | ||
|
||
@Inject | ||
DeviceSetRepository deviceSetRepository; | ||
|
||
@GET | ||
@Path("/getall") | ||
public Response getAll() { | ||
List<Device> devices; | ||
try{ | ||
return CCResponse.ok(deviceSetRepository.getAll()); | ||
}catch (CCException ex){ | ||
return CCResponse.error(ex); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/at/camconnect/dtos/deviceSet/DeviceSetCreateDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package at.camconnect.dtos.deviceSet; | ||
|
||
import at.camconnect.enums.DeviceStatus; | ||
|
||
import java.util.List; | ||
|
||
public record DeviceSetCreateDTO (Long id, String name, String description, List<Long> deviceTypeIds, DeviceStatus status) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
backend/src/main/java/at/camconnect/repository/DeviceSetRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package at.camconnect.repository; | ||
|
||
import at.camconnect.model.DeviceSet; | ||
import at.camconnect.model.DeviceType; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.persistence.EntityManager; | ||
|
||
import java.util.List; | ||
|
||
@ApplicationScoped | ||
public class DeviceSetRepository { | ||
@Inject | ||
EntityManager em; | ||
|
||
public List<DeviceSet> getAll(){ | ||
return em.createQuery("SELECT d FROM DeviceSet d order by d.id", DeviceSet.class).getResultList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
frontend/web/src/components/app/edit/deviceSetEdit.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import {html, LitElement, PropertyValues} from 'lit' | ||
import {customElement, property} from 'lit/decorators.js' | ||
import styles from '../../../../styles/components/app/edit/deviceTypeEdit.styles.scss' | ||
import { | ||
DeviceTypeFullDTO, DeviceTypeVariantEnum, | ||
} from "../../../service/deviceType.service" | ||
import {EditPageEnum, ObservedProperty} from "../../../model" | ||
import UrlHandler from "../../../util/UrlHandler" | ||
import {model} from "../../../index" | ||
import {AppState} from "../../../AppState" | ||
import {InputType} from "../../basic/input.component" | ||
import {ColorEnum, SizeEnum} from "../../../base" | ||
import TagService, {Tag} from "../../../service/tag.service" | ||
import {ChipType} from "../../basic/chip.component" | ||
import {DeviceSetCreateDTO, DeviceSet} from "../../../service/deviceSet.service" | ||
|
||
@customElement('cc-device-set-edit') | ||
export class DeviceSetEditComponent extends LitElement { | ||
@property() private deviceSets: ObservedProperty<DeviceSet[]> | ||
|
||
@property() private appState: ObservedProperty<AppState> | ||
|
||
constructor() { | ||
super() | ||
this.deviceSets = new ObservedProperty<DeviceSet[]>(this, model.deviceSets) | ||
this.appState = new ObservedProperty<AppState>(this, model.appState) | ||
|
||
console.log(this.deviceSets.value) | ||
} | ||
|
||
render() { | ||
return html` | ||
<style>${styles}</style> | ||
<div class="toolbar-container"> | ||
<cc-toolbar type="edit"></cc-toolbar> | ||
<main> | ||
<div class="header"> | ||
<h1> | ||
Geräte-Sets | ||
</h1> | ||
</div> | ||
${Object.values(this.deviceSets.value)?.flat().map(deviceSet => { | ||
return html`<cc-device-set-edit-entry .deviceSet="${deviceSet}" @click="${() => { | ||
let convertedDeviceSet : DeviceSetCreateDTO = { | ||
id: deviceSet.id, | ||
name: deviceSet.name, | ||
description: deviceSet.description, | ||
deviceTypeIds: deviceSet.device_types.map(deviceType => deviceType.type_id) || [], | ||
status: deviceSet.status | ||
} as DeviceSetCreateDTO | ||
model.appState.value.openOverlay(html`<cc-edit-device-set-modal .element="${deviceSet}" .isEditMode="${true}"></cc-edit-device-set-modal>`, () => {})}}"> | ||
}}"></cc-device-set-edit-entry>` | ||
})} | ||
</main> | ||
</div> | ||
` | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
"cc-device-set-edit": DeviceSetEditComponent | ||
} | ||
} |
Oops, something went wrong.