cloud-ide-element 1.1.27 → 1.1.29

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.
@@ -6,10 +6,11 @@ import * as i2 from '@angular/forms';
6
6
  import { FormsModule, NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
7
7
  import { BehaviorSubject, Subject, debounceTime, distinctUntilChanged, takeUntil, Observable, retry, catchError, finalize, throwError, map, of } from 'rxjs';
8
8
  import * as i1$1 from '@angular/common/http';
9
- import { HttpClient, HttpEventType, HttpRequest } from '@angular/common/http';
9
+ import { HttpClient, HttpEventType, HttpParams, HttpRequest } from '@angular/common/http';
10
10
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
11
- import { generateStringFromObject, coreRoutesUrl, cidePath, hostManagerRoutesUrl } from 'cloud-ide-lms-model';
11
+ import { generateStringFromObject, coreRoutesUrl, cidePath as cidePath$1, hostManagerRoutesUrl as hostManagerRoutesUrl$1 } from 'cloud-ide-lms-model';
12
12
  import * as i2$1 from '@angular/router';
13
+ import { io } from 'socket.io-client';
13
14
  import { tap, catchError as catchError$1 } from 'rxjs/operators';
14
15
  import { trigger, state, transition, style, animate } from '@angular/animations';
15
16
 
@@ -6886,6 +6887,40 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImpor
6886
6887
  args: ['mousedown', ['$event']]
6887
6888
  }] } });
6888
6889
 
6890
+ /**
6891
+ * Path Helper Utility
6892
+ * Cloned from cloud-ide-lms-model to avoid dependencies
6893
+ */
6894
+ const cidePath = {
6895
+ join: (path) => {
6896
+ return path.join("/");
6897
+ }
6898
+ };
6899
+
6900
+ /**
6901
+ * Host Manager Routes
6902
+ * Cloned from cloud-ide-lms-model to avoid dependencies
6903
+ *
6904
+ * Base path for host name to interceptor and replace with actual URL
6905
+ * for more details refer https://docs.google.com/document/d/1CwB4evLsQuatG4jI0U1faRtmqtNmIfZOE4fDWiz9-sQ/edit?pli=1#bookmark=id.j3vzaryhajl1
6906
+ * __version__ need to add in future
6907
+ */
6908
+ const hostManagerRoutesUrl = {
6909
+ cideSuiteHost: "__cloud_ide_suite_layout__"
6910
+ };
6911
+ Object.freeze(hostManagerRoutesUrl);
6912
+
6913
+ /**
6914
+ * Notification Routes
6915
+ * Cloned from cloud-ide-lms-model to avoid dependencies
6916
+ */
6917
+ const notificationRoutesUrl = {
6918
+ module: 'notifications',
6919
+ notifications: "notifications",
6920
+ unreadCount: "unread-count",
6921
+ };
6922
+ Object.freeze(notificationRoutesUrl);
6923
+
6889
6924
  /**
6890
6925
  * Advanced Angular button component that provides a comprehensive button implementation
6891
6926
  * with loading state, styling variants, animations, tooltips, and other features.
@@ -7134,6 +7169,302 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImpor
7134
7169
  args: ['click', ['$event']]
7135
7170
  }] } });
7136
7171
 
7172
+ /**
7173
+ * Notification API Service
7174
+ * HTTP client for notification API endpoints
7175
+ */
7176
+ class NotificationApiService {
7177
+ http = inject(HttpClient);
7178
+ apiUrl = cidePath.join([
7179
+ hostManagerRoutesUrl.cideSuiteHost,
7180
+ notificationRoutesUrl.module
7181
+ ]);
7182
+ /**
7183
+ * Get user notifications
7184
+ */
7185
+ getNotifications(params) {
7186
+ let httpParams = new HttpParams();
7187
+ if (params) {
7188
+ Object.keys(params).forEach(key => {
7189
+ const value = params[key];
7190
+ if (value !== undefined && value !== null) {
7191
+ httpParams = httpParams.set(key, value.toString());
7192
+ }
7193
+ });
7194
+ }
7195
+ // Debug: Log the URL being used
7196
+ console.log('[NotificationApi] Request URL:', this.apiUrl);
7197
+ console.log('[NotificationApi] Full URL with params:', `${this.apiUrl}?${httpParams.toString()}`);
7198
+ return this.http.get(this.apiUrl, { params: httpParams });
7199
+ }
7200
+ /**
7201
+ * Get notification by ID
7202
+ */
7203
+ getNotificationById(id) {
7204
+ return this.http.get(`${this.apiUrl}/${id}`);
7205
+ }
7206
+ /**
7207
+ * Get unread count
7208
+ */
7209
+ getUnreadCount() {
7210
+ return this.http.get(`${this.apiUrl}/${notificationRoutesUrl.unreadCount}`);
7211
+ }
7212
+ /**
7213
+ * Create notification
7214
+ */
7215
+ createNotification(payload) {
7216
+ return this.http.post(this.apiUrl, payload);
7217
+ }
7218
+ /**
7219
+ * Mark notification as read
7220
+ */
7221
+ markAsRead(id) {
7222
+ return this.http.put(`${this.apiUrl}/${id}/read`, {});
7223
+ }
7224
+ /**
7225
+ * Mark all notifications as read
7226
+ */
7227
+ markAllAsRead() {
7228
+ return this.http.put(`${this.apiUrl}/read-all`, {});
7229
+ }
7230
+ /**
7231
+ * Archive notification
7232
+ */
7233
+ archiveNotification(id) {
7234
+ return this.http.put(`${this.apiUrl}/${id}/archive`, {});
7235
+ }
7236
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: NotificationApiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
7237
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: NotificationApiService, providedIn: 'root' });
7238
+ }
7239
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: NotificationApiService, decorators: [{
7240
+ type: Injectable,
7241
+ args: [{
7242
+ providedIn: 'root'
7243
+ }]
7244
+ }] });
7245
+
7246
+ /**
7247
+ * WebSocket Notification Service
7248
+ * Socket.IO client for real-time notifications
7249
+ */
7250
+ class WebSocketNotificationService {
7251
+ socket = null;
7252
+ notificationSubject = new Subject();
7253
+ connectionStatusSubject = new BehaviorSubject({
7254
+ connected: false
7255
+ });
7256
+ // Signals for reactive state
7257
+ notifications = signal([], ...(ngDevMode ? [{ debugName: "notifications" }] : []));
7258
+ unreadNotifications = signal([], ...(ngDevMode ? [{ debugName: "unreadNotifications" }] : []));
7259
+ // Public observables
7260
+ notification$ = this.notificationSubject.asObservable();
7261
+ connectionStatus$ = this.connectionStatusSubject.asObservable();
7262
+ // Computed signals
7263
+ allNotifications = computed(() => this.notifications(), ...(ngDevMode ? [{ debugName: "allNotifications" }] : []));
7264
+ unreadNotificationsCount = computed(() => this.unreadNotifications().length, ...(ngDevMode ? [{ debugName: "unreadNotificationsCount" }] : []));
7265
+ isConnected = computed(() => this.connectionStatusSubject.value.connected, ...(ngDevMode ? [{ debugName: "isConnected" }] : []));
7266
+ /**
7267
+ * Connect to Socket.IO server
7268
+ */
7269
+ connect(token, userId) {
7270
+ if (this.socket?.connected) {
7271
+ console.log('Socket already connected');
7272
+ return;
7273
+ }
7274
+ // Resolve actual API URL from placeholder
7275
+ // The placeholder is replaced by host interceptor for HTTP, but WebSocket needs direct resolution
7276
+ // Based on host-manager.json: "__cloud_ide_suite_layout__" -> "http://localhost:3001"
7277
+ const placeholder = hostManagerRoutesUrl.cideSuiteHost;
7278
+ let apiUrl = 'http://localhost:3001'; // Default from host-manager.json
7279
+ // Try to resolve from host-manager.json via fetch (same as HTTP interceptor)
7280
+ if (typeof window !== 'undefined') {
7281
+ // Try to fetch host-manager.json to get the actual URL
7282
+ fetch('/routes/host-manager.json')
7283
+ .then(res => res.json())
7284
+ .then((hostManagerRoutes) => {
7285
+ const hostManagerRoutesEntry = hostManagerRoutes?.hosts?.find((hostRoute) => placeholder?.includes(hostRoute?.url));
7286
+ if (hostManagerRoutesEntry?.replace) {
7287
+ apiUrl = hostManagerRoutesEntry.replace;
7288
+ }
7289
+ // Remove /api suffix if present (Socket.IO connects to base server)
7290
+ apiUrl = apiUrl.replace(/\/api\/?$/, '');
7291
+ this.connectWithUrl(apiUrl, token, userId);
7292
+ })
7293
+ .catch(() => {
7294
+ // Fallback if fetch fails - use default or try localStorage
7295
+ this.resolveUrlFallback(token, userId);
7296
+ });
7297
+ }
7298
+ else {
7299
+ // Server-side or fallback
7300
+ this.resolveUrlFallback(token, userId);
7301
+ }
7302
+ }
7303
+ /**
7304
+ * Fallback URL resolution
7305
+ */
7306
+ resolveUrlFallback(token, userId) {
7307
+ let apiUrl = 'http://localhost:3001'; // Default from host-manager.json
7308
+ // Try to get from current window location
7309
+ if (typeof window !== 'undefined') {
7310
+ const currentOrigin = window.location.origin;
7311
+ // Check if we're on localhost (development)
7312
+ if (currentOrigin.includes('localhost') || currentOrigin.includes('127.0.0.1')) {
7313
+ // Use localhost:3001 for development (from host-manager.json)
7314
+ apiUrl = 'http://localhost:3001';
7315
+ }
7316
+ else {
7317
+ // In production, use the same origin (assuming API is on same domain)
7318
+ apiUrl = currentOrigin || 'http://localhost:3001';
7319
+ }
7320
+ // Try to get from localStorage (if set by app initialization)
7321
+ const storedApiUrl = localStorage.getItem('api_base_url');
7322
+ if (storedApiUrl) {
7323
+ apiUrl = storedApiUrl.replace(/\/api\/?$/, '');
7324
+ }
7325
+ }
7326
+ this.connectWithUrl(apiUrl, token, userId);
7327
+ }
7328
+ /**
7329
+ * Connect with resolved URL
7330
+ */
7331
+ connectWithUrl(apiUrl, token, userId) {
7332
+ console.log('[WebSocket] Connecting to:', apiUrl);
7333
+ this.socket = io(apiUrl, {
7334
+ path: '/notifications-socket',
7335
+ transports: ['websocket', 'polling'],
7336
+ auth: {
7337
+ token: token
7338
+ },
7339
+ reconnection: true,
7340
+ reconnectionDelay: 1000,
7341
+ reconnectionAttempts: 5,
7342
+ reconnectionDelayMax: 5000
7343
+ });
7344
+ this.setupEventHandlers(userId);
7345
+ }
7346
+ /**
7347
+ * Setup Socket.IO event handlers
7348
+ */
7349
+ setupEventHandlers(userId) {
7350
+ if (!this.socket)
7351
+ return;
7352
+ // Connection established
7353
+ this.socket.on('connect', () => {
7354
+ console.log('Socket.IO connected:', this.socket?.id);
7355
+ this.connectionStatusSubject.next({
7356
+ connected: true,
7357
+ socketId: this.socket?.id,
7358
+ userId: userId,
7359
+ timestamp: new Date()
7360
+ });
7361
+ });
7362
+ // Connection confirmation
7363
+ this.socket.on('connected', (data) => {
7364
+ console.log('Notification service connected:', data);
7365
+ this.connectionStatusSubject.next({
7366
+ connected: true,
7367
+ socketId: data.socketId,
7368
+ userId: data.userId,
7369
+ timestamp: data.timestamp
7370
+ });
7371
+ });
7372
+ // Receive notification
7373
+ this.socket.on('notification', (notification) => {
7374
+ console.log('Received notification:', notification);
7375
+ // Add to notifications list
7376
+ this.notifications.update(notifications => [notification, ...notifications]);
7377
+ // Add to unread list
7378
+ this.unreadNotifications.update(unread => [notification, ...unread]);
7379
+ // Emit to subscribers
7380
+ this.notificationSubject.next(notification);
7381
+ // Acknowledge receipt
7382
+ this.acknowledgeNotification(notification.id);
7383
+ });
7384
+ // Disconnect
7385
+ this.socket.on('disconnect', (reason) => {
7386
+ console.log('Socket.IO disconnected:', reason);
7387
+ this.connectionStatusSubject.next({
7388
+ connected: false,
7389
+ timestamp: new Date()
7390
+ });
7391
+ });
7392
+ // Connection error
7393
+ this.socket.on('connect_error', (error) => {
7394
+ console.error('Socket.IO connection error:', error);
7395
+ this.connectionStatusSubject.next({
7396
+ connected: false,
7397
+ timestamp: new Date()
7398
+ });
7399
+ });
7400
+ }
7401
+ /**
7402
+ * Acknowledge notification receipt
7403
+ */
7404
+ acknowledgeNotification(notificationId) {
7405
+ if (this.socket?.connected) {
7406
+ this.socket.emit('notification:ack', { notificationId });
7407
+ }
7408
+ }
7409
+ /**
7410
+ * Mark notification as read
7411
+ */
7412
+ markAsRead(notificationId) {
7413
+ if (this.socket?.connected) {
7414
+ this.socket.emit('notification:read', { notificationId });
7415
+ // Remove from unread list
7416
+ this.unreadNotifications.update(unread => unread.filter(n => n.id !== notificationId));
7417
+ }
7418
+ }
7419
+ /**
7420
+ * Mark all as read
7421
+ */
7422
+ markAllAsRead() {
7423
+ const unreadIds = this.unreadNotifications().map(n => n.id);
7424
+ unreadIds.forEach(id => this.markAsRead(id));
7425
+ }
7426
+ /**
7427
+ * Disconnect from server
7428
+ */
7429
+ disconnect() {
7430
+ if (this.socket) {
7431
+ this.socket.disconnect();
7432
+ this.socket = null;
7433
+ this.connectionStatusSubject.next({
7434
+ connected: false,
7435
+ timestamp: new Date()
7436
+ });
7437
+ }
7438
+ }
7439
+ /**
7440
+ * Clear all notifications
7441
+ */
7442
+ clearNotifications() {
7443
+ this.notifications.set([]);
7444
+ this.unreadNotifications.set([]);
7445
+ }
7446
+ /**
7447
+ * Remove notification from list
7448
+ */
7449
+ removeNotification(notificationId) {
7450
+ this.notifications.update(notifications => notifications.filter(n => n.id !== notificationId));
7451
+ this.unreadNotifications.update(unread => unread.filter(n => n.id !== notificationId));
7452
+ }
7453
+ ngOnDestroy() {
7454
+ this.disconnect();
7455
+ this.notificationSubject.complete();
7456
+ this.connectionStatusSubject.complete();
7457
+ }
7458
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: WebSocketNotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
7459
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: WebSocketNotificationService, providedIn: 'root' });
7460
+ }
7461
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: WebSocketNotificationService, decorators: [{
7462
+ type: Injectable,
7463
+ args: [{
7464
+ providedIn: 'root'
7465
+ }]
7466
+ }] });
7467
+
7137
7468
  class CideCoreFileManagerService {
7138
7469
  http;
7139
7470
  apiUrl = `${coreRoutesUrl?.fileManager}`;
@@ -7148,7 +7479,7 @@ class CideCoreFileManagerService {
7148
7479
  */
7149
7480
  getFileList(body) {
7150
7481
  const query = generateStringFromObject(body);
7151
- return this.http?.get(cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, query]))
7482
+ return this.http?.get(cidePath$1?.join([hostManagerRoutesUrl$1?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, query]))
7152
7483
  .pipe(tap((response) => {
7153
7484
  if (response?.success) {
7154
7485
  this.fileListSubject.next(response?.data || []);
@@ -7181,7 +7512,7 @@ class CideCoreFileManagerService {
7181
7512
  formData.append('tags', JSON.stringify(request.tags || []));
7182
7513
  formData.append('permissions', JSON.stringify(request.permissions || []));
7183
7514
  formData.append('userId', request.userId || '');
7184
- const url = cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, 'upload']);
7515
+ const url = cidePath$1?.join([hostManagerRoutesUrl$1?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, 'upload']);
7185
7516
  const req = new HttpRequest('POST', url, formData, {
7186
7517
  reportProgress: true
7187
7518
  });
@@ -7199,7 +7530,7 @@ class CideCoreFileManagerService {
7199
7530
  */
7200
7531
  updateFile(request) {
7201
7532
  console.log('Updating file:', request);
7202
- const url = cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager]);
7533
+ const url = cidePath$1?.join([hostManagerRoutesUrl$1?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager]);
7203
7534
  return this.http.post(url, request)
7204
7535
  .pipe(tap((response) => {
7205
7536
  if (response.success) {
@@ -7213,7 +7544,7 @@ class CideCoreFileManagerService {
7213
7544
  deleteFile(id) {
7214
7545
  const payload = { cyfm_id: id };
7215
7546
  const query = generateStringFromObject(payload);
7216
- const url = cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, query]);
7547
+ const url = cidePath$1?.join([hostManagerRoutesUrl$1?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, query]);
7217
7548
  return this.http.delete(url)
7218
7549
  .pipe(tap((response) => {
7219
7550
  if (response.success) {
@@ -7228,7 +7559,7 @@ class CideCoreFileManagerService {
7228
7559
  console.log('Deleting multiple files:', ids);
7229
7560
  const payload = { ids };
7230
7561
  const query = generateStringFromObject(payload);
7231
- const url = cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, query]);
7562
+ const url = cidePath$1?.join([hostManagerRoutesUrl$1?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, query]);
7232
7563
  return this.http.delete(url)
7233
7564
  .pipe(tap((response) => {
7234
7565
  if (response.success) {
@@ -7243,7 +7574,7 @@ class CideCoreFileManagerService {
7243
7574
  console.log('Toggling file status:', id);
7244
7575
  const payload = { id };
7245
7576
  const query = generateStringFromObject(payload);
7246
- const url = cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, query]);
7577
+ const url = cidePath$1?.join([hostManagerRoutesUrl$1?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, query]);
7247
7578
  return this.http.put(url, {})
7248
7579
  .pipe(tap((response) => {
7249
7580
  if (response.success) {
@@ -7258,7 +7589,7 @@ class CideCoreFileManagerService {
7258
7589
  console.log('Getting file by ID:', id);
7259
7590
  const payload = { cyfm_id: id };
7260
7591
  const query = generateStringFromObject(payload);
7261
- const url = cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, 'byId', query]);
7592
+ const url = cidePath$1?.join([hostManagerRoutesUrl$1?.cideSuiteHost, coreRoutesUrl?.module, coreRoutesUrl?.fileManager, 'byId', query]);
7262
7593
  return this.http.get(url)
7263
7594
  .pipe(catchError$1(this.handleError));
7264
7595
  }
@@ -13122,5 +13453,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImpor
13122
13453
  * Generated bundle index. Do not edit.
13123
13454
  */
13124
13455
 
13125
- export { CapitalizePipe, CideCoreFileManagerService, CideEleBreadcrumbComponent, CideEleButtonComponent, CideEleConfirmationModalComponent, CideEleDataGridComponent, CideEleDropdownComponent, CideEleFileImageDirective, CideEleFileInputComponent, CideEleFileManagerService, CideEleFloatingContainerComponent, CideEleFloatingContainerDynamicDirective, CideEleFloatingContainerManagerComponent, CideEleFloatingContainerService, CideEleFloatingFeaturesService, CideEleFloatingFileUploaderComponent, CideEleFloatingFileUploaderService, CideEleGlobalNotificationsComponent, CideEleJsonEditorComponent, CideEleResizerDirective, CideEleSkeletonLoaderComponent, CideEleTabComponent, CideEleToastNotificationComponent, CideElementsService, CideFormFieldErrorComponent, CideIconComponent, CideInputComponent, CideSelectComponent, CideSelectOptionComponent, CideSpinnerComponent, CideTextareaComponent, ConfirmationService, CoreFileManagerInsertUpdatePayload, DEFAULT_GRID_CONFIG, DropdownManagerService, ExportService, ICoreCyfmSave, KeyboardShortcutService, MFileManager, NotificationService, PortalService, TooltipDirective };
13456
+ export { CapitalizePipe, CideCoreFileManagerService, CideEleBreadcrumbComponent, CideEleButtonComponent, CideEleConfirmationModalComponent, CideEleDataGridComponent, CideEleDropdownComponent, CideEleFileImageDirective, CideEleFileInputComponent, CideEleFileManagerService, CideEleFloatingContainerComponent, CideEleFloatingContainerDynamicDirective, CideEleFloatingContainerManagerComponent, CideEleFloatingContainerService, CideEleFloatingFeaturesService, CideEleFloatingFileUploaderComponent, CideEleFloatingFileUploaderService, CideEleGlobalNotificationsComponent, CideEleJsonEditorComponent, CideEleResizerDirective, CideEleSkeletonLoaderComponent, CideEleTabComponent, CideEleToastNotificationComponent, CideElementsService, CideFormFieldErrorComponent, CideIconComponent, CideInputComponent, CideSelectComponent, CideSelectOptionComponent, CideSpinnerComponent, CideTextareaComponent, ConfirmationService, CoreFileManagerInsertUpdatePayload, DEFAULT_GRID_CONFIG, DropdownManagerService, ExportService, ICoreCyfmSave, KeyboardShortcutService, MFileManager, NotificationApiService, NotificationService, PortalService, TooltipDirective, WebSocketNotificationService, cidePath, hostManagerRoutesUrl, notificationRoutesUrl };
13126
13457
  //# sourceMappingURL=cloud-ide-element.mjs.map