@noatgnu/cupcake-core 1.3.2 → 1.3.4
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.
|
@@ -4,7 +4,7 @@ import * as i1 from '@angular/common/http';
|
|
|
4
4
|
import { HttpClient, HttpParams, provideHttpClient, withInterceptors, HttpClientModule } from '@angular/common/http';
|
|
5
5
|
import { BehaviorSubject, catchError, throwError, switchMap, filter, take, map, tap, Subject, timer, EMPTY, interval, debounceTime, distinctUntilChanged } from 'rxjs';
|
|
6
6
|
import { Router, ActivatedRoute, RouterModule } from '@angular/router';
|
|
7
|
-
import { map as map$1, takeUntil, tap as tap$1, switchMap as switchMap$1
|
|
7
|
+
import { map as map$1, takeUntil, tap as tap$1, switchMap as switchMap$1 } from 'rxjs/operators';
|
|
8
8
|
import * as i1$1 from '@angular/forms';
|
|
9
9
|
import { FormBuilder, Validators, ReactiveFormsModule, FormsModule, NonNullableFormBuilder } from '@angular/forms';
|
|
10
10
|
import * as i2 from '@angular/common';
|
|
@@ -1166,7 +1166,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.7", ngImpor
|
|
|
1166
1166
|
|
|
1167
1167
|
const WEBSOCKET_ENDPOINT = new InjectionToken('WEBSOCKET_ENDPOINT', {
|
|
1168
1168
|
providedIn: 'root',
|
|
1169
|
-
factory: () => 'notifications'
|
|
1169
|
+
factory: () => 'ccc/notifications'
|
|
1170
1170
|
});
|
|
1171
1171
|
class WebSocketService {
|
|
1172
1172
|
authService;
|
|
@@ -1184,7 +1184,7 @@ class WebSocketService {
|
|
|
1184
1184
|
connectionState$ = computed(() => this.connectionState(), ...(ngDevMode ? [{ debugName: "connectionState$" }] : []));
|
|
1185
1185
|
lastError$ = computed(() => this.lastError(), ...(ngDevMode ? [{ debugName: "lastError$" }] : []));
|
|
1186
1186
|
config_token = inject(CUPCAKE_CORE_CONFIG);
|
|
1187
|
-
endpoint = inject(WEBSOCKET_ENDPOINT, { optional: true }) || 'notifications';
|
|
1187
|
+
endpoint = inject(WEBSOCKET_ENDPOINT, { optional: true }) || 'ccc/notifications';
|
|
1188
1188
|
constructor(authService) {
|
|
1189
1189
|
this.authService = authService;
|
|
1190
1190
|
this.config = {
|
|
@@ -1207,14 +1207,14 @@ class WebSocketService {
|
|
|
1207
1207
|
const url = new URL(apiUrl);
|
|
1208
1208
|
const protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
1209
1209
|
const host = url.host;
|
|
1210
|
-
const endpoint = this.config?.endpoint || 'notifications';
|
|
1210
|
+
const endpoint = this.config?.endpoint || 'ccc/notifications';
|
|
1211
1211
|
return `${protocol}//${host}/ws/${endpoint}/`;
|
|
1212
1212
|
}
|
|
1213
1213
|
catch (error) {
|
|
1214
1214
|
console.error('Invalid API URL in cupcake config:', apiUrl);
|
|
1215
1215
|
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
1216
1216
|
const host = window.location.host;
|
|
1217
|
-
const endpoint = this.config?.endpoint || 'notifications';
|
|
1217
|
+
const endpoint = this.config?.endpoint || 'ccc/notifications';
|
|
1218
1218
|
return `${protocol}//${host}/ws/${endpoint}/`;
|
|
1219
1219
|
}
|
|
1220
1220
|
}
|
|
@@ -1472,6 +1472,9 @@ class AsyncTaskMonitorService extends BaseApiService {
|
|
|
1472
1472
|
tasksSubject = new BehaviorSubject([]);
|
|
1473
1473
|
isSubscribed = false;
|
|
1474
1474
|
websocket = inject(WebSocketService);
|
|
1475
|
+
constructor() {
|
|
1476
|
+
super();
|
|
1477
|
+
}
|
|
1475
1478
|
tasks$ = this.tasksSubject.asObservable();
|
|
1476
1479
|
activeTasks$ = this.tasks$.pipe(map$1(tasks => {
|
|
1477
1480
|
const taskArray = Array.isArray(tasks) ? tasks : [];
|
|
@@ -1490,21 +1493,16 @@ class AsyncTaskMonitorService extends BaseApiService {
|
|
|
1490
1493
|
}
|
|
1491
1494
|
console.log('AsyncTaskMonitorService: Starting real-time updates');
|
|
1492
1495
|
this.isSubscribed = true;
|
|
1493
|
-
if (!this.websocket.connectionState$() || this.websocket.connectionState$() === 'disconnected') {
|
|
1494
|
-
console.log('AsyncTaskMonitorService: WebSocket not connected, connecting now...');
|
|
1495
|
-
this.websocket.connect();
|
|
1496
|
-
}
|
|
1497
|
-
else {
|
|
1498
|
-
console.log('AsyncTaskMonitorService: WebSocket already connected');
|
|
1499
|
-
}
|
|
1500
|
-
this.websocket.isConnected$.pipe(takeUntil(this.destroy$), filter$1(connected => connected)).subscribe(() => {
|
|
1501
|
-
console.log('AsyncTaskMonitorService: WebSocket connected, subscribing to async_task_updates');
|
|
1502
|
-
this.websocket.subscribe('async_task_updates');
|
|
1503
|
-
});
|
|
1504
1496
|
this.websocket.filterMessages('async_task.update').pipe(takeUntil(this.destroy$)).subscribe((message) => {
|
|
1505
1497
|
console.log('AsyncTaskMonitorService: Received async_task.update message:', message);
|
|
1506
1498
|
this.handleTaskUpdate(message);
|
|
1507
1499
|
});
|
|
1500
|
+
this.websocket.isConnected$.pipe(takeUntil(this.destroy$)).subscribe(isConnected => {
|
|
1501
|
+
if (isConnected) {
|
|
1502
|
+
console.log('AsyncTaskMonitorService: WebSocket connected, subscribing to async_task_updates channel');
|
|
1503
|
+
this.websocket.subscribe('async_task_updates');
|
|
1504
|
+
}
|
|
1505
|
+
});
|
|
1508
1506
|
this.loadAllTasks();
|
|
1509
1507
|
}
|
|
1510
1508
|
stopRealtimeUpdates() {
|
|
@@ -1535,7 +1533,14 @@ class AsyncTaskMonitorService extends BaseApiService {
|
|
|
1535
1533
|
console.log('AsyncTaskMonitorService: Current tasks in subject:', currentTasks.length);
|
|
1536
1534
|
const existingTaskIndex = currentTasks.findIndex(t => t.id === taskId);
|
|
1537
1535
|
console.log('AsyncTaskMonitorService: Existing task index:', existingTaskIndex);
|
|
1538
|
-
|
|
1536
|
+
const isTaskCompleted = message.status === TaskStatus.SUCCESS ||
|
|
1537
|
+
message.status === TaskStatus.FAILURE ||
|
|
1538
|
+
message.status === TaskStatus.CANCELLED;
|
|
1539
|
+
if (isTaskCompleted) {
|
|
1540
|
+
console.log('AsyncTaskMonitorService: Task completed, fetching full task details from API');
|
|
1541
|
+
this.loadSingleTask(taskId);
|
|
1542
|
+
}
|
|
1543
|
+
else if (existingTaskIndex >= 0) {
|
|
1539
1544
|
const existingTask = currentTasks[existingTaskIndex];
|
|
1540
1545
|
const updatedTask = {
|
|
1541
1546
|
...existingTask,
|
|
@@ -1555,7 +1560,30 @@ class AsyncTaskMonitorService extends BaseApiService {
|
|
|
1555
1560
|
this.loadAllTasks();
|
|
1556
1561
|
}
|
|
1557
1562
|
}
|
|
1558
|
-
|
|
1563
|
+
loadSingleTask(taskId) {
|
|
1564
|
+
this.get(`${this.apiUrl}/async-tasks/${taskId}/`).subscribe({
|
|
1565
|
+
next: (task) => {
|
|
1566
|
+
console.log('AsyncTaskMonitorService: Loaded single task from API:', task);
|
|
1567
|
+
const currentTasks = this.tasksSubject.value;
|
|
1568
|
+
const existingTaskIndex = currentTasks.findIndex(t => t.id === taskId);
|
|
1569
|
+
if (existingTaskIndex >= 0) {
|
|
1570
|
+
const updatedTasks = [...currentTasks];
|
|
1571
|
+
updatedTasks[existingTaskIndex] = task;
|
|
1572
|
+
console.log('AsyncTaskMonitorService: Updated task in list with full details');
|
|
1573
|
+
this.tasksSubject.next(updatedTasks);
|
|
1574
|
+
}
|
|
1575
|
+
else {
|
|
1576
|
+
console.log('AsyncTaskMonitorService: Adding new task to list');
|
|
1577
|
+
this.tasksSubject.next([task, ...currentTasks]);
|
|
1578
|
+
}
|
|
1579
|
+
},
|
|
1580
|
+
error: (error) => {
|
|
1581
|
+
console.error('AsyncTaskMonitorService: Error loading single task:', error);
|
|
1582
|
+
this.loadAllTasks();
|
|
1583
|
+
}
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: AsyncTaskMonitorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1559
1587
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: AsyncTaskMonitorService, providedIn: 'root' });
|
|
1560
1588
|
}
|
|
1561
1589
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: AsyncTaskMonitorService, decorators: [{
|
|
@@ -1563,7 +1591,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.7", ngImpor
|
|
|
1563
1591
|
args: [{
|
|
1564
1592
|
providedIn: 'root'
|
|
1565
1593
|
}]
|
|
1566
|
-
}] });
|
|
1594
|
+
}], ctorParameters: () => [] });
|
|
1567
1595
|
|
|
1568
1596
|
class ToastService {
|
|
1569
1597
|
toastsSignal = signal([], ...(ngDevMode ? [{ debugName: "toastsSignal" }] : []));
|
|
@@ -1939,8 +1967,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.7", ngImpor
|
|
|
1939
1967
|
|
|
1940
1968
|
const WEBSOCKET_ENDPOINTS = new InjectionToken('WEBSOCKET_ENDPOINTS');
|
|
1941
1969
|
class WebSocketEndpoints {
|
|
1942
|
-
static CORE_NOTIFICATIONS = 'notifications';
|
|
1943
|
-
static CORE_ADMIN = 'admin';
|
|
1970
|
+
static CORE_NOTIFICATIONS = 'ccc/notifications';
|
|
1971
|
+
static CORE_ADMIN = 'ccc/admin';
|
|
1944
1972
|
}
|
|
1945
1973
|
class WebSocketConfigService {
|
|
1946
1974
|
endpoints = new Map();
|
|
@@ -1992,6 +2020,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.7", ngImpor
|
|
|
1992
2020
|
}]
|
|
1993
2021
|
}], ctorParameters: () => [] });
|
|
1994
2022
|
|
|
2023
|
+
class AdminWebSocketService extends WebSocketService {
|
|
2024
|
+
constructor(authService) {
|
|
2025
|
+
super(authService);
|
|
2026
|
+
this.endpoint = 'ccc/admin';
|
|
2027
|
+
this.config.endpoint = 'ccc/admin';
|
|
2028
|
+
this.config.url = this.getWebSocketUrl();
|
|
2029
|
+
}
|
|
2030
|
+
getAdminNotifications() {
|
|
2031
|
+
return this.filterMessages('admin.notification');
|
|
2032
|
+
}
|
|
2033
|
+
getSystemNotifications() {
|
|
2034
|
+
return this.filterMessages('system.notification');
|
|
2035
|
+
}
|
|
2036
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: AdminWebSocketService, deps: [{ token: AuthService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2037
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: AdminWebSocketService, providedIn: 'root' });
|
|
2038
|
+
}
|
|
2039
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: AdminWebSocketService, decorators: [{
|
|
2040
|
+
type: Injectable,
|
|
2041
|
+
args: [{
|
|
2042
|
+
providedIn: 'root'
|
|
2043
|
+
}]
|
|
2044
|
+
}], ctorParameters: () => [{ type: AuthService }] });
|
|
2045
|
+
|
|
1995
2046
|
class LabGroupService extends BaseApiService {
|
|
1996
2047
|
// LAB GROUPS
|
|
1997
2048
|
getLabGroups(params) {
|
|
@@ -3601,5 +3652,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.7", ngImpor
|
|
|
3601
3652
|
* Generated bundle index. Do not edit.
|
|
3602
3653
|
*/
|
|
3603
3654
|
|
|
3604
|
-
export { AnnotationType, ApiService, AsyncTaskMonitorService, AuthService, BaseApiService, CUPCAKE_CORE_CONFIG, CupcakeCoreModule, InvitationStatus, InvitationStatusLabels, LabGroupService, LabGroupsComponent, LoginComponent, NotificationService, PoweredByFooterComponent, RegisterComponent, ResourceRole, ResourceRoleLabels, ResourceService, ResourceType, ResourceTypeLabels, ResourceVisibility, ResourceVisibilityLabels, SiteConfigComponent, SiteConfigService, TASK_STATUS_COLORS, TASK_STATUS_LABELS, TASK_TYPE_LABELS, TaskStatus, TaskType, ThemeService, ToastContainerComponent, ToastService, UserManagementComponent, UserManagementService, UserProfileComponent, WEBSOCKET_ENDPOINT, WEBSOCKET_ENDPOINTS, WebSocketConfigService, WebSocketEndpoints, WebSocketService, adminGuard, authGuard, authInterceptor, resetRefreshState };
|
|
3655
|
+
export { AdminWebSocketService, AnnotationType, ApiService, AsyncTaskMonitorService, AuthService, BaseApiService, CUPCAKE_CORE_CONFIG, CupcakeCoreModule, InvitationStatus, InvitationStatusLabels, LabGroupService, LabGroupsComponent, LoginComponent, NotificationService, PoweredByFooterComponent, RegisterComponent, ResourceRole, ResourceRoleLabels, ResourceService, ResourceType, ResourceTypeLabels, ResourceVisibility, ResourceVisibilityLabels, SiteConfigComponent, SiteConfigService, TASK_STATUS_COLORS, TASK_STATUS_LABELS, TASK_TYPE_LABELS, TaskStatus, TaskType, ThemeService, ToastContainerComponent, ToastService, UserManagementComponent, UserManagementService, UserProfileComponent, WEBSOCKET_ENDPOINT, WEBSOCKET_ENDPOINTS, WebSocketConfigService, WebSocketEndpoints, WebSocketService, adminGuard, authGuard, authInterceptor, resetRefreshState };
|
|
3605
3656
|
//# sourceMappingURL=noatgnu-cupcake-core.mjs.map
|