|
1 | 1 | import {Injectable} from '@angular/core';
|
2 |
| -import {CommonMessage, ConsumerPlan, ConsumerUserAccount} from "fusio-sdk"; |
3 |
| -import {ConfigService} from "./config.service"; |
4 |
| -import {EventListener} from "../config/config"; |
| 2 | +import {CommonCollection, CommonMessage, ConsumerEvent} from "fusio-sdk"; |
| 3 | +import {FusioService} from "./fusio.service"; |
| 4 | +import {Service} from "../abstract/service"; |
5 | 5 |
|
6 | 6 | @Injectable({
|
7 | 7 | providedIn: 'root'
|
8 | 8 | })
|
9 |
| -export class EventService { |
| 9 | +export class EventService extends Service<ConsumerEvent> { |
10 | 10 |
|
11 |
| - private eventListener: EventListener; |
12 |
| - |
13 |
| - constructor(config: ConfigService) { |
14 |
| - this.eventListener = config.getEventListener(); |
15 |
| - } |
16 |
| - |
17 |
| - public dispatchLogin(user: ConsumerUserAccount): void { |
18 |
| - if (this.eventListener.login) { |
19 |
| - this.eventListener.login.call(this, user); |
20 |
| - } |
21 |
| - } |
22 |
| - |
23 |
| - public dispatchLogout(): void { |
24 |
| - if (this.eventListener.logout) { |
25 |
| - this.eventListener.logout.call(this); |
26 |
| - } |
27 |
| - } |
28 |
| - |
29 |
| - public dispatchRegister(name: string, email: string): void { |
30 |
| - if (this.eventListener.register) { |
31 |
| - this.eventListener.register.call(this, name, email); |
32 |
| - } |
33 |
| - } |
34 |
| - |
35 |
| - public dispatchRegisterActivate(): void { |
36 |
| - if (this.eventListener.register_activate) { |
37 |
| - this.eventListener.register_activate.call(this); |
38 |
| - } |
39 |
| - } |
40 |
| - |
41 |
| - public dispatchPasswordConfirm(): void { |
42 |
| - if (this.eventListener.password_confirm) { |
43 |
| - this.eventListener.password_confirm.call(this); |
44 |
| - } |
45 |
| - } |
46 |
| - |
47 |
| - public dispatchPasswordReset(): void { |
48 |
| - if (this.eventListener.password_reset) { |
49 |
| - this.eventListener.password_reset.call(this); |
50 |
| - } |
51 |
| - } |
52 |
| - |
53 |
| - public dispatchCheckout(plan: ConsumerPlan): void { |
54 |
| - if (this.eventListener.checkout) { |
55 |
| - this.eventListener.checkout.call(this, plan); |
56 |
| - } |
| 11 | + constructor(private fusio: FusioService) { |
| 12 | + super(); |
57 | 13 | }
|
58 | 14 |
|
59 |
| - public dispatchPurchase(plan: ConsumerPlan): void { |
60 |
| - if (this.eventListener.purchase) { |
61 |
| - this.eventListener.purchase.call(this, plan); |
62 |
| - } |
| 15 | + async getAll(parameters: Array<any>): Promise<CommonCollection<ConsumerEvent>> { |
| 16 | + return this.fusio.getClient().consumer().event().getAll(...parameters); |
63 | 17 | }
|
64 | 18 |
|
65 |
| - public dispatchError(error: CommonMessage): void { |
66 |
| - if (this.eventListener.error) { |
67 |
| - this.eventListener.error.call(this, error); |
68 |
| - } |
| 19 | + async get(id: string): Promise<ConsumerEvent> { |
| 20 | + return {}; |
69 | 21 | }
|
70 | 22 |
|
71 |
| - public dispatchModelList(route: string): void { |
72 |
| - if (this.eventListener.model_list) { |
73 |
| - this.eventListener.model_list.call(this, route); |
74 |
| - } |
| 23 | + async create(entity: ConsumerEvent): Promise<CommonMessage> { |
| 24 | + return {}; |
75 | 25 | }
|
76 | 26 |
|
77 |
| - public dispatchModelDetail(model: any, route: string): void { |
78 |
| - if (this.eventListener.model_detail) { |
79 |
| - this.eventListener.model_detail.call(this, model, route); |
80 |
| - } |
| 27 | + async update(entity: ConsumerEvent): Promise<CommonMessage> { |
| 28 | + return {}; |
81 | 29 | }
|
82 | 30 |
|
83 |
| - public dispatchModelCreated(model: any, route: string): void { |
84 |
| - if (this.eventListener.model_created) { |
85 |
| - this.eventListener.model_created.call(this, model, route); |
86 |
| - } |
| 31 | + async delete(entity: ConsumerEvent): Promise<CommonMessage> { |
| 32 | + return {}; |
87 | 33 | }
|
88 | 34 |
|
89 |
| - public dispatchModelUpdated(model: any, route: string): void { |
90 |
| - if (this.eventListener.model_updated) { |
91 |
| - this.eventListener.model_updated.call(this, model, route); |
92 |
| - } |
| 35 | + newEntity(): ConsumerEvent { |
| 36 | + return { |
| 37 | + name: '', |
| 38 | + }; |
93 | 39 | }
|
94 | 40 |
|
95 |
| - public dispatchModelDeleted(model: any, route: string): void { |
96 |
| - if (this.eventListener.model_deleted) { |
97 |
| - this.eventListener.model_deleted.call(this, model, route); |
98 |
| - } |
| 41 | + getLink(): Array<string> { |
| 42 | + return ['/', 'account', 'event']; |
99 | 43 | }
|
100 | 44 |
|
101 | 45 | }
|
0 commit comments