UI objects for UserSharingsGet and FingerprintPut added
This commit is contained in:
parent
b5184b9b3c
commit
22e27ed899
@ -113,10 +113,10 @@ paths:
|
||||
example:
|
||||
- sharingId: 8
|
||||
userId: 25
|
||||
userSharingId: 42
|
||||
userSharedId: 42
|
||||
- sharingId: 9
|
||||
userId: 25
|
||||
userSharingId:
|
||||
userSharedId: 7
|
||||
default:
|
||||
$ref: '#/components/responses/Error'
|
||||
|
||||
|
@ -31,7 +31,7 @@ final class FingerprintPutController extends AbstractController
|
||||
try {
|
||||
$fingerprint = new Fingerprint($this->fingerprintId);
|
||||
|
||||
if ($this->hasUserPermission($fingerprint->getUserId()) || $this->handleFingerprint($fingerprint)) {
|
||||
if ($this->hasUserPermission($fingerprint->getUserId()) && $this->handleFingerprint($fingerprint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
18
js/api/FingerprintPutApiRequest.ts
Normal file
18
js/api/FingerprintPutApiRequest.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import ApiRequest from "./ApiRequest.js";
|
||||
import Fingerprint from "../types/Fingerprint.js";
|
||||
import RequestMethod from "./RequestMethod.js";
|
||||
import FingerprintChangedEvent from "../event/FingerprintChangedEvent.js";
|
||||
|
||||
export default class FingerprintPutApiRequest extends ApiRequest
|
||||
{
|
||||
public constructor(fingerprint: Fingerprint) {
|
||||
super('fingerprint/' + fingerprint.getFingerprintId(), RequestMethod.PUT);
|
||||
|
||||
this.addParameter('fingerprint', fingerprint.getFingerprint());
|
||||
|
||||
this.onSuccess = (responseText: string) => {
|
||||
console.log(responseText);
|
||||
window.dispatchEvent(new FingerprintChangedEvent(fingerprint));
|
||||
};
|
||||
}
|
||||
}
|
26
js/api/UserSharingsGetApiRequest.ts
Normal file
26
js/api/UserSharingsGetApiRequest.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import ApiRequest from "./ApiRequest.js";
|
||||
import RequestMethod from "./RequestMethod.js";
|
||||
import Sharing from "../types/Sharing.js";
|
||||
import UserSharingsGetEvent from "../event/UserSharingsGetEvent.js";
|
||||
|
||||
export default class UserSharingsGetApiRequest extends ApiRequest
|
||||
{
|
||||
public constructor(userId: number)
|
||||
{
|
||||
super('user/' + userId + '/sharings', RequestMethod.GET);
|
||||
|
||||
this.onSuccess = (response: string) => {
|
||||
let json = JSON.parse(response);
|
||||
|
||||
let sharings: Array<Sharing> = [];
|
||||
|
||||
json.sharings.forEach(
|
||||
(result: any) => {
|
||||
sharings.push(new Sharing(result.sharingId, result.userId, result.userSharedId));
|
||||
}
|
||||
);
|
||||
|
||||
window.dispatchEvent(new UserSharingsGetEvent(sharings));
|
||||
}
|
||||
}
|
||||
}
|
18
js/event/FingerprintChangedEvent.ts
Normal file
18
js/event/FingerprintChangedEvent.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import RingfingerEvent from "./RingfingerEvent.js";
|
||||
import Fingerprint from "../types/Fingerprint.js";
|
||||
|
||||
export default class FingerprintChangedEvent extends RingfingerEvent
|
||||
{
|
||||
private fingerprint: Fingerprint;
|
||||
|
||||
public constructor(fingerprint: Fingerprint) {
|
||||
super(FingerprintChangedEvent.name);
|
||||
|
||||
this.fingerprint = fingerprint;
|
||||
}
|
||||
|
||||
public getFingerprint(): Fingerprint
|
||||
{
|
||||
return this.fingerprint;
|
||||
}
|
||||
}
|
18
js/event/UserSharingsGetEvent.ts
Normal file
18
js/event/UserSharingsGetEvent.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import RingfingerEvent from "./RingfingerEvent.js";
|
||||
import Sharing from "../types/Sharing.js";
|
||||
|
||||
export default class UserSharingsGetEvent extends RingfingerEvent
|
||||
{
|
||||
private sharings: Array<Sharing>;
|
||||
|
||||
public constructor(sharings: Array<Sharing>) {
|
||||
super(UserSharingsGetEvent.name);
|
||||
|
||||
this.sharings = sharings;
|
||||
}
|
||||
|
||||
public getSharings(): Array<Sharing>
|
||||
{
|
||||
return this.sharings;
|
||||
}
|
||||
}
|
28
js/types/Sharing.ts
Normal file
28
js/types/Sharing.ts
Normal file
@ -0,0 +1,28 @@
|
||||
export default class Sharing
|
||||
{
|
||||
private readonly sharingId: number;
|
||||
private readonly userId: number;
|
||||
private readonly userSharingId: number;
|
||||
|
||||
public constructor(sharingId: number, userId: number, userSharingId: number)
|
||||
{
|
||||
this.sharingId = sharingId;
|
||||
this.userId = userId;
|
||||
this.userSharingId = userSharingId;
|
||||
}
|
||||
|
||||
public getSharingId(): number
|
||||
{
|
||||
return this.sharingId;
|
||||
}
|
||||
|
||||
public getUserId(): number
|
||||
{
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public getUserSharingId(): number
|
||||
{
|
||||
return this.userSharingId;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user