@acorex/platform 19.3.0 → 19.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/lib/utils/index.d.ts +0 -1
- package/fesm2022/acorex-platform-common.mjs +1 -134
- package/fesm2022/acorex-platform-common.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-components.mjs +247 -0
- package/fesm2022/acorex-platform-layout-components.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-designer.mjs.map +1 -1
- package/fesm2022/{acorex-platform-widgets-tabular-data-edit-popup.component-CybYV1Kf.mjs → acorex-platform-widgets-tabular-data-edit-popup.component-1IseEVXQ.mjs} +2 -2
- package/fesm2022/acorex-platform-widgets-tabular-data-edit-popup.component-1IseEVXQ.mjs.map +1 -0
- package/fesm2022/acorex-platform-widgets.mjs +8 -4395
- package/fesm2022/acorex-platform-widgets.mjs.map +1 -1
- package/layout/components/README.md +3 -0
- package/layout/components/index.d.ts +1 -0
- package/layout/components/lib/user-avatar/index.d.ts +4 -0
- package/layout/components/lib/user-avatar/user-avatar.component.d.ts +27 -0
- package/layout/components/lib/user-avatar/user-avatar.provider.d.ts +3 -0
- package/layout/components/lib/user-avatar/user-avatar.service.d.ts +42 -0
- package/layout/components/lib/user-avatar/user-avatar.types.d.ts +12 -0
- package/package.json +5 -1
- package/widgets/lib/widgets/index.d.ts +0 -11
- package/common/lib/utils/data-generator.d.ts +0 -26
- package/fesm2022/acorex-platform-widgets-tabular-data-edit-popup.component-CybYV1Kf.mjs.map +0 -1
- package/widgets/lib/widgets/charts/bar-chart/bar-chart-widget.component.d.ts +0 -72
- package/widgets/lib/widgets/charts/bar-chart/bar-chart-widget.config.d.ts +0 -7
- package/widgets/lib/widgets/charts/bar-chart/bar-chart.type.d.ts +0 -34
- package/widgets/lib/widgets/charts/bar-chart/index.d.ts +0 -2
- package/widgets/lib/widgets/charts/chart.type.d.ts +0 -3
- package/widgets/lib/widgets/charts/clock-calendar/clock-calendar-widget.component.d.ts +0 -40
- package/widgets/lib/widgets/charts/clock-calendar/clock-calendar-widget.config.d.ts +0 -7
- package/widgets/lib/widgets/charts/clock-calendar/clock-calendar.types.d.ts +0 -50
- package/widgets/lib/widgets/charts/clock-calendar/index.d.ts +0 -3
- package/widgets/lib/widgets/charts/donut-chart/donut-chart-widget.component.d.ts +0 -58
- package/widgets/lib/widgets/charts/donut-chart/donut-chart-widget.config.d.ts +0 -7
- package/widgets/lib/widgets/charts/donut-chart/donut-chart.type.d.ts +0 -67
- package/widgets/lib/widgets/charts/donut-chart/index.d.ts +0 -2
- package/widgets/lib/widgets/charts/gauge-chart/gauge-chart-widget.component.d.ts +0 -75
- package/widgets/lib/widgets/charts/gauge-chart/gauge-chart-widget.config.d.ts +0 -7
- package/widgets/lib/widgets/charts/gauge-chart/gauge-chart.type.d.ts +0 -29
- package/widgets/lib/widgets/charts/gauge-chart/index.d.ts +0 -3
- package/widgets/lib/widgets/charts/index.d.ts +0 -11
- package/widgets/lib/widgets/charts/line-chart/index.d.ts +0 -3
- package/widgets/lib/widgets/charts/line-chart/line-chart-widget.component.d.ts +0 -76
- package/widgets/lib/widgets/charts/line-chart/line-chart-widget.config.d.ts +0 -7
- package/widgets/lib/widgets/charts/line-chart/line-chart.type.d.ts +0 -41
- package/widgets/lib/widgets/charts/notification/index.d.ts +0 -3
- package/widgets/lib/widgets/charts/notification/notification-widget.component.d.ts +0 -54
- package/widgets/lib/widgets/charts/notification/notification-widget.config.d.ts +0 -10
- package/widgets/lib/widgets/charts/notification/notification.type.d.ts +0 -47
- package/widgets/lib/widgets/charts/shared/chart-base.component.d.ts +0 -44
- package/widgets/lib/widgets/charts/shared/chart-base.type.d.ts +0 -37
- package/widgets/lib/widgets/charts/shared/components/chart-tooltip/chart-tooltip.component.d.ts +0 -28
- package/widgets/lib/widgets/charts/shared/components/chart-tooltip/index.d.ts +0 -1
- package/widgets/lib/widgets/charts/shared/index.d.ts +0 -3
- package/widgets/lib/widgets/charts/sticky-note/index.d.ts +0 -2
- package/widgets/lib/widgets/charts/sticky-note/sticky-note-widget.component.d.ts +0 -21
- package/widgets/lib/widgets/charts/sticky-note/sticky-note-widget.config.d.ts +0 -7
- package/widgets/lib/widgets/charts/tasklist/index.d.ts +0 -3
- package/widgets/lib/widgets/charts/tasklist/tasklist-widget.component.d.ts +0 -34
- package/widgets/lib/widgets/charts/tasklist/tasklist-widget.config.d.ts +0 -7
- package/widgets/lib/widgets/charts/tasklist/tasklist.type.d.ts +0 -36
- package/widgets/lib/widgets/charts/weather/index.d.ts +0 -3
- package/widgets/lib/widgets/charts/weather/weather-services/index.d.ts +0 -3
- package/widgets/lib/widgets/charts/weather/weather-services/weather-api.abstract.d.ts +0 -174
- package/widgets/lib/widgets/charts/weather/weather-services/weather-api.key.d.ts +0 -2
- package/widgets/lib/widgets/charts/weather/weather-services/weather-api.mock.service.d.ts +0 -47
- package/widgets/lib/widgets/charts/weather/weather-services/weather-api.service.d.ts +0 -48
- package/widgets/lib/widgets/charts/weather/weather-widget.component.d.ts +0 -109
- package/widgets/lib/widgets/charts/weather/weather-widget.config.d.ts +0 -14
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, Injectable, input, signal, computed, ViewEncapsulation, Component } from '@angular/core';
|
|
3
|
+
import { BehaviorSubject, timer, Subject, takeUntil } from 'rxjs';
|
|
4
|
+
import { tap } from 'rxjs/operators';
|
|
5
|
+
import { AXFormModule } from '@acorex/components/form';
|
|
6
|
+
import { AXButtonModule } from '@acorex/components/button';
|
|
7
|
+
import { AXTextBoxModule } from '@acorex/components/text-box';
|
|
8
|
+
import { AXCheckBoxModule } from '@acorex/components/check-box';
|
|
9
|
+
import { AXLabelModule } from '@acorex/components/label';
|
|
10
|
+
import { CommonModule } from '@angular/common';
|
|
11
|
+
import * as i1 from '@acorex/components/image';
|
|
12
|
+
import { AXImageModule } from '@acorex/components/image';
|
|
13
|
+
import * as i2 from '@acorex/components/badge';
|
|
14
|
+
import { AXBadgeModule } from '@acorex/components/badge';
|
|
15
|
+
|
|
16
|
+
const AXP_USER_AVATAR_PROVIDER = new InjectionToken('AXP_USER_AVATAR_PROVIDER', {
|
|
17
|
+
providedIn: 'root',
|
|
18
|
+
factory: () => {
|
|
19
|
+
return new AXPUserAvatarProviderDefault();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
class AXPUserAvatarProviderDefault {
|
|
23
|
+
provide(username) {
|
|
24
|
+
return Promise.resolve({
|
|
25
|
+
username: username,
|
|
26
|
+
firstName: 'John',
|
|
27
|
+
lastName: 'Doe',
|
|
28
|
+
status: 'online',
|
|
29
|
+
avatarUrl: 'https://via.placeholder.com/150',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class AXPUserAvatarService {
|
|
35
|
+
constructor() {
|
|
36
|
+
this.provider = inject(AXP_USER_AVATAR_PROVIDER);
|
|
37
|
+
// Cache configuration
|
|
38
|
+
this.cacheExpiryTime = 5 * 60 * 1000; // 5 minutes in milliseconds
|
|
39
|
+
this.refreshInterval = 3 * 60 * 1000; // 3 minutes in milliseconds
|
|
40
|
+
// Cache storage
|
|
41
|
+
this.cache = new Map();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Gets user information with caching and auto-refresh
|
|
45
|
+
* @param username The username to fetch information for
|
|
46
|
+
* @returns Observable that emits user avatar data
|
|
47
|
+
*/
|
|
48
|
+
getUserInfo$(username) {
|
|
49
|
+
// Check if we have a cached entry
|
|
50
|
+
if (!this.cache.has(username) || this.isExpired(username)) {
|
|
51
|
+
// Create a new cache entry with default values
|
|
52
|
+
const defaultData = {
|
|
53
|
+
status: 'offline',
|
|
54
|
+
username: username,
|
|
55
|
+
firstName: '',
|
|
56
|
+
lastName: ''
|
|
57
|
+
};
|
|
58
|
+
const subject = new BehaviorSubject(defaultData);
|
|
59
|
+
this.cache.set(username, {
|
|
60
|
+
data: defaultData,
|
|
61
|
+
timestamp: Date.now(),
|
|
62
|
+
subject
|
|
63
|
+
});
|
|
64
|
+
// Fetch fresh data immediately
|
|
65
|
+
this.fetchAndUpdateCache(username);
|
|
66
|
+
// Set up auto refresh
|
|
67
|
+
timer(this.refreshInterval, this.refreshInterval)
|
|
68
|
+
.pipe(tap(() => this.fetchAndUpdateCache(username)))
|
|
69
|
+
.subscribe();
|
|
70
|
+
}
|
|
71
|
+
return this.cache.get(username).subject.asObservable();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Gets user information (Promise-based for backward compatibility)
|
|
75
|
+
* @param username The username to fetch information for
|
|
76
|
+
* @returns Promise that resolves to user avatar data
|
|
77
|
+
*/
|
|
78
|
+
async getUserInfo(username) {
|
|
79
|
+
// Check if we have an unexpired cached entry
|
|
80
|
+
if (this.cache.has(username) && !this.isExpired(username)) {
|
|
81
|
+
return this.cache.get(username).data;
|
|
82
|
+
}
|
|
83
|
+
// Fetch fresh data and cache it
|
|
84
|
+
return this.fetchAndUpdateCache(username);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Clears the entire cache or a specific user's cache
|
|
88
|
+
* @param username Optional username to clear specific cache
|
|
89
|
+
*/
|
|
90
|
+
clearCache(username) {
|
|
91
|
+
if (username) {
|
|
92
|
+
this.cache.delete(username);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this.cache.clear();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Force refresh data for a specific username
|
|
100
|
+
* @param username The username to refresh
|
|
101
|
+
* @returns Promise that resolves to the refreshed data
|
|
102
|
+
*/
|
|
103
|
+
async refreshUserInfo(username) {
|
|
104
|
+
return this.fetchAndUpdateCache(username);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Checks if a cache entry is expired
|
|
108
|
+
*/
|
|
109
|
+
isExpired(username) {
|
|
110
|
+
const entry = this.cache.get(username);
|
|
111
|
+
if (!entry)
|
|
112
|
+
return true;
|
|
113
|
+
return (Date.now() - entry.timestamp) > this.cacheExpiryTime;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Fetches data from provider and updates the cache
|
|
117
|
+
*/
|
|
118
|
+
async fetchAndUpdateCache(username) {
|
|
119
|
+
try {
|
|
120
|
+
const data = await this.provider.provide(username);
|
|
121
|
+
const entry = this.cache.get(username);
|
|
122
|
+
// Update the cache entry
|
|
123
|
+
if (entry) {
|
|
124
|
+
entry.data = data;
|
|
125
|
+
entry.timestamp = Date.now();
|
|
126
|
+
entry.subject.next(data);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
// Create a new cache entry if needed
|
|
130
|
+
const subject = new BehaviorSubject(data);
|
|
131
|
+
this.cache.set(username, {
|
|
132
|
+
data,
|
|
133
|
+
timestamp: Date.now(),
|
|
134
|
+
subject
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return data;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
console.error(`Error fetching user info for ${username}:`, error);
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPUserAvatarService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
145
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPUserAvatarService, providedIn: 'root' }); }
|
|
146
|
+
}
|
|
147
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPUserAvatarService, decorators: [{
|
|
148
|
+
type: Injectable,
|
|
149
|
+
args: [{
|
|
150
|
+
providedIn: 'root',
|
|
151
|
+
}]
|
|
152
|
+
}] });
|
|
153
|
+
|
|
154
|
+
class AXPUserAvatarComponent {
|
|
155
|
+
constructor() {
|
|
156
|
+
this.userAvatarService = inject(AXPUserAvatarService);
|
|
157
|
+
this.destroy$ = new Subject();
|
|
158
|
+
this.size = input(40);
|
|
159
|
+
this.username = input('');
|
|
160
|
+
this.src = signal('');
|
|
161
|
+
this.firstName = signal('');
|
|
162
|
+
this.lastName = signal('');
|
|
163
|
+
this.title = computed(() => `${this.firstName()} ${this.lastName()}`);
|
|
164
|
+
this.isOnline = signal(false);
|
|
165
|
+
}
|
|
166
|
+
ngOnInit() {
|
|
167
|
+
this.loadUserData();
|
|
168
|
+
}
|
|
169
|
+
ngOnDestroy() {
|
|
170
|
+
this.destroy$.next();
|
|
171
|
+
this.destroy$.complete();
|
|
172
|
+
}
|
|
173
|
+
loadUserData() {
|
|
174
|
+
// Skip if no username provided
|
|
175
|
+
if (!this.username()) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
// Subscribe to the user info observable to get real-time updates
|
|
179
|
+
this.userAvatarService.getUserInfo$(this.username())
|
|
180
|
+
.pipe(takeUntil(this.destroy$))
|
|
181
|
+
.subscribe(userData => {
|
|
182
|
+
// Update component signals with user data
|
|
183
|
+
this.firstName.set(userData.firstName || '');
|
|
184
|
+
this.lastName.set(userData.lastName || '');
|
|
185
|
+
this.isOnline.set(userData.status === 'online');
|
|
186
|
+
// Generate avatar image source if needed
|
|
187
|
+
// This is a placeholder - replace with your actual avatar URL logic
|
|
188
|
+
this.generateAvatarSrc(userData);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Generate avatar image source
|
|
193
|
+
* This is a placeholder - implement based on your actual requirements
|
|
194
|
+
*/
|
|
195
|
+
generateAvatarSrc(userData) {
|
|
196
|
+
// Example: Check if the user has a custom avatar URL
|
|
197
|
+
// If not, generate a placeholder using initials
|
|
198
|
+
if (userData.avatarUrl) {
|
|
199
|
+
this.src.set(userData.avatarUrl);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
// Generate a placeholder - you could use an external service like UI Avatars
|
|
203
|
+
// or implement your own logic
|
|
204
|
+
const initials = this.getInitials(userData.firstName || '', userData.lastName || '');
|
|
205
|
+
this.src.set(`https://ui-avatars.com/api/?name=${encodeURIComponent(initials)}&size=${this.size()}&background=random`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get initials from first and last name
|
|
210
|
+
*/
|
|
211
|
+
getInitials(firstName, lastName) {
|
|
212
|
+
const firstInitial = firstName.charAt(0).toUpperCase();
|
|
213
|
+
const lastInitial = lastName.charAt(0).toUpperCase();
|
|
214
|
+
return firstInitial + lastInitial;
|
|
215
|
+
}
|
|
216
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPUserAvatarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
217
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: AXPUserAvatarComponent, isStandalone: true, selector: "axp-user-avatar", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, username: { classPropertyName: "username", publicName: "username", isSignal: true, isRequired: false, transformFunction: null } }, providers: [], ngImport: i0, template: "<ax-image [src]=\"src()\" [alt]=\"title()\" [width]=\"size()\" [height]=\"size()\">\n <ax-badge [color]=\"isOnline() ? 'success' : 'danger'\"></ax-badge>\n</ax-image>\n", styles: [""], dependencies: [{ kind: "ngmodule", type:
|
|
218
|
+
// Angular
|
|
219
|
+
CommonModule }, { kind: "ngmodule", type:
|
|
220
|
+
// ACoreX
|
|
221
|
+
AXFormModule }, { kind: "ngmodule", type: AXTextBoxModule }, { kind: "ngmodule", type: AXButtonModule }, { kind: "ngmodule", type: AXLabelModule }, { kind: "ngmodule", type: AXCheckBoxModule }, { kind: "ngmodule", type:
|
|
222
|
+
// Platform
|
|
223
|
+
AXImageModule }, { kind: "component", type: i1.AXImageComponent, selector: "ax-image", inputs: ["width", "height", "overlayMode", "src", "alt", "priority", "lazy"], outputs: ["onLoad", "onError"] }, { kind: "ngmodule", type: AXBadgeModule }, { kind: "component", type: i2.AXBadgeComponent, selector: "ax-badge", inputs: ["color", "look", "text"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
224
|
+
}
|
|
225
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPUserAvatarComponent, decorators: [{
|
|
226
|
+
type: Component,
|
|
227
|
+
args: [{ selector: 'axp-user-avatar', imports: [
|
|
228
|
+
// Angular
|
|
229
|
+
CommonModule,
|
|
230
|
+
// ACoreX
|
|
231
|
+
AXFormModule,
|
|
232
|
+
AXTextBoxModule,
|
|
233
|
+
AXButtonModule,
|
|
234
|
+
AXLabelModule,
|
|
235
|
+
AXCheckBoxModule,
|
|
236
|
+
// Platform
|
|
237
|
+
AXImageModule,
|
|
238
|
+
AXBadgeModule
|
|
239
|
+
], encapsulation: ViewEncapsulation.None, providers: [], template: "<ax-image [src]=\"src()\" [alt]=\"title()\" [width]=\"size()\" [height]=\"size()\">\n <ax-badge [color]=\"isOnline() ? 'success' : 'danger'\"></ax-badge>\n</ax-image>\n" }]
|
|
240
|
+
}] });
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Generated bundle index. Do not edit.
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
export { AXPUserAvatarComponent, AXPUserAvatarService, AXP_USER_AVATAR_PROVIDER };
|
|
247
|
+
//# sourceMappingURL=acorex-platform-layout-components.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-platform-layout-components.mjs","sources":["../../../../libs/platform/layout/components/src/lib/user-avatar/user-avatar.provider.ts","../../../../libs/platform/layout/components/src/lib/user-avatar/user-avatar.service.ts","../../../../libs/platform/layout/components/src/lib/user-avatar/user-avatar.component.ts","../../../../libs/platform/layout/components/src/lib/user-avatar/user-avatar.component.html","../../../../libs/platform/layout/components/src/acorex-platform-layout-components.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\nimport { AXPUserAvatarData, AXPUserAvatarProvider } from \"./user-avatar.types\";\n\nexport const AXP_USER_AVATAR_PROVIDER = new InjectionToken<AXPUserAvatarProvider>(\n 'AXP_USER_AVATAR_PROVIDER',\n {\n providedIn: 'root',\n factory: () => {\n return new AXPUserAvatarProviderDefault();\n }\n }\n);\n\n\nclass AXPUserAvatarProviderDefault implements AXPUserAvatarProvider {\n provide(username: string): Promise<AXPUserAvatarData> {\n return Promise.resolve({\n username: username,\n firstName: 'John',\n lastName: 'Doe',\n status: 'online',\n avatarUrl: 'https://via.placeholder.com/150',\n });\n }\n}\n","import { inject, Injectable } from \"@angular/core\";\nimport { AXPUserAvatarData } from \"./user-avatar.types\";\nimport { AXP_USER_AVATAR_PROVIDER } from \"./user-avatar.provider\";\nimport { BehaviorSubject, Observable, timer } from 'rxjs';\nimport { map, shareReplay, switchMap, tap } from 'rxjs/operators';\n\ninterface CacheEntry {\n data: AXPUserAvatarData;\n timestamp: number;\n subject: BehaviorSubject<AXPUserAvatarData>;\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXPUserAvatarService {\n private provider = inject(AXP_USER_AVATAR_PROVIDER);\n\n // Cache configuration\n private readonly cacheExpiryTime = 5 * 60 * 1000; // 5 minutes in milliseconds\n private readonly refreshInterval = 3 * 60 * 1000; // 3 minutes in milliseconds\n\n // Cache storage\n private cache = new Map<string, CacheEntry>();\n\n /**\n * Gets user information with caching and auto-refresh\n * @param username The username to fetch information for\n * @returns Observable that emits user avatar data\n */\n getUserInfo$(username: string): Observable<AXPUserAvatarData> {\n // Check if we have a cached entry\n if (!this.cache.has(username) || this.isExpired(username)) {\n // Create a new cache entry with default values\n const defaultData: AXPUserAvatarData = {\n status: 'offline',\n username: username,\n firstName: '',\n lastName: ''\n };\n const subject = new BehaviorSubject<AXPUserAvatarData>(defaultData);\n this.cache.set(username, {\n data: defaultData,\n timestamp: Date.now(),\n subject\n });\n\n // Fetch fresh data immediately\n this.fetchAndUpdateCache(username);\n\n // Set up auto refresh\n timer(this.refreshInterval, this.refreshInterval)\n .pipe(\n tap(() => this.fetchAndUpdateCache(username))\n )\n .subscribe();\n }\n\n return this.cache.get(username)!.subject.asObservable();\n }\n\n /**\n * Gets user information (Promise-based for backward compatibility)\n * @param username The username to fetch information for\n * @returns Promise that resolves to user avatar data\n */\n async getUserInfo(username: string): Promise<AXPUserAvatarData> {\n // Check if we have an unexpired cached entry\n if (this.cache.has(username) && !this.isExpired(username)) {\n return this.cache.get(username)!.data;\n }\n\n // Fetch fresh data and cache it\n return this.fetchAndUpdateCache(username);\n }\n\n /**\n * Clears the entire cache or a specific user's cache\n * @param username Optional username to clear specific cache\n */\n clearCache(username?: string): void {\n if (username) {\n this.cache.delete(username);\n } else {\n this.cache.clear();\n }\n }\n\n /**\n * Force refresh data for a specific username\n * @param username The username to refresh\n * @returns Promise that resolves to the refreshed data\n */\n async refreshUserInfo(username: string): Promise<AXPUserAvatarData> {\n return this.fetchAndUpdateCache(username);\n }\n\n /**\n * Checks if a cache entry is expired\n */\n private isExpired(username: string): boolean {\n const entry = this.cache.get(username);\n if (!entry) return true;\n\n return (Date.now() - entry.timestamp) > this.cacheExpiryTime;\n }\n\n /**\n * Fetches data from provider and updates the cache\n */\n private async fetchAndUpdateCache(username: string): Promise<AXPUserAvatarData> {\n try {\n const data = await this.provider.provide(username);\n const entry = this.cache.get(username);\n\n // Update the cache entry\n if (entry) {\n entry.data = data;\n entry.timestamp = Date.now();\n entry.subject.next(data);\n } else {\n // Create a new cache entry if needed\n const subject = new BehaviorSubject<AXPUserAvatarData>(data);\n this.cache.set(username, {\n data,\n timestamp: Date.now(),\n subject\n });\n }\n\n return data;\n } catch (error) {\n console.error(`Error fetching user info for ${username}:`, error);\n throw error;\n }\n }\n}","import { Component, OnDestroy, OnInit, ViewEncapsulation, computed, inject, input, signal } from '@angular/core';\n\nimport { AXFormModule } from '@acorex/components/form';\nimport { AXButtonModule } from '@acorex/components/button';\nimport { AXTextBoxModule } from '@acorex/components/text-box';\nimport { AXCheckBoxModule } from '@acorex/components/check-box';\nimport { AXLabelModule } from '@acorex/components/label';\nimport { CommonModule } from '@angular/common';\nimport { AXImageModule } from '@acorex/components/image';\nimport { AXBadgeModule } from '@acorex/components/badge';\nimport { AXPUserAvatarService } from './user-avatar.service';\nimport { Subject, takeUntil } from 'rxjs';\n\n@Component({\n selector: 'axp-user-avatar',\n templateUrl: './user-avatar.component.html',\n styleUrl: './user-avatar.component.scss',\n imports: [\n // Angular\n CommonModule,\n // ACoreX\n AXFormModule,\n AXTextBoxModule,\n AXButtonModule,\n AXLabelModule,\n AXCheckBoxModule,\n // Platform\n AXImageModule,\n AXBadgeModule\n ],\n encapsulation: ViewEncapsulation.None,\n providers: [],\n})\nexport class AXPUserAvatarComponent implements OnInit, OnDestroy {\n private readonly userAvatarService = inject(AXPUserAvatarService);\n private readonly destroy$ = new Subject<void>();\n\n size = input<number>(40);\n username = input<string>('');\n\n src = signal<string>('');\n firstName = signal<string>('');\n lastName = signal<string>('');\n title = computed(() => `${this.firstName()} ${this.lastName()}`);\n isOnline = signal<boolean>(false);\n\n ngOnInit(): void {\n this.loadUserData();\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n\n private loadUserData(): void {\n // Skip if no username provided\n if (!this.username()) {\n return;\n }\n\n // Subscribe to the user info observable to get real-time updates\n this.userAvatarService.getUserInfo$(this.username())\n .pipe(takeUntil(this.destroy$))\n .subscribe(userData => {\n // Update component signals with user data\n this.firstName.set(userData.firstName || '');\n this.lastName.set(userData.lastName || '');\n this.isOnline.set(userData.status === 'online');\n\n // Generate avatar image source if needed\n // This is a placeholder - replace with your actual avatar URL logic\n this.generateAvatarSrc(userData);\n });\n }\n\n /**\n * Generate avatar image source\n * This is a placeholder - implement based on your actual requirements\n */\n private generateAvatarSrc(userData: any): void {\n // Example: Check if the user has a custom avatar URL\n // If not, generate a placeholder using initials\n if (userData.avatarUrl) {\n this.src.set(userData.avatarUrl);\n } else {\n // Generate a placeholder - you could use an external service like UI Avatars\n // or implement your own logic\n const initials = this.getInitials(userData.firstName || '', userData.lastName || '');\n this.src.set(`https://ui-avatars.com/api/?name=${encodeURIComponent(initials)}&size=${this.size()}&background=random`);\n }\n }\n\n /**\n * Get initials from first and last name\n */\n private getInitials(firstName: string, lastName: string): string {\n const firstInitial = firstName.charAt(0).toUpperCase();\n const lastInitial = lastName.charAt(0).toUpperCase();\n return firstInitial + lastInitial;\n }\n}\n","<ax-image [src]=\"src()\" [alt]=\"title()\" [width]=\"size()\" [height]=\"size()\">\n <ax-badge [color]=\"isOnline() ? 'success' : 'danger'\"></ax-badge>\n</ax-image>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;MAGa,wBAAwB,GAAG,IAAI,cAAc,CACtD,0BAA0B,EAC1B;AACI,IAAA,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,MAAK;QACV,OAAO,IAAI,4BAA4B,EAAE;;AAEhD,CAAA;AAIL,MAAM,4BAA4B,CAAA;AAC9B,IAAA,OAAO,CAAC,QAAgB,EAAA;QACpB,OAAO,OAAO,CAAC,OAAO,CAAC;AACnB,YAAA,QAAQ,EAAE,QAAQ;AAClB,YAAA,SAAS,EAAE,MAAM;AACjB,YAAA,QAAQ,EAAE,KAAK;AACf,YAAA,MAAM,EAAE,QAAQ;AAChB,YAAA,SAAS,EAAE,iCAAiC;AAC/C,SAAA,CAAC;;AAET;;MCTY,oBAAoB,CAAA;AAHjC,IAAA,WAAA,GAAA;AAIY,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAC;;QAGlC,IAAe,CAAA,eAAA,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;QAChC,IAAe,CAAA,eAAA,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;;AAGzC,QAAA,IA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