cloud-ide-element 1.0.90 → 1.0.91

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 i0 from '@angular/core';
4
4
  import { Pipe, Injectable, inject, EventEmitter, ViewContainerRef, forwardRef, ViewChild, Output, Input, Component, HostListener, ContentChildren, signal, DestroyRef, computed, effect, afterRenderEffect, afterNextRender, ElementRef, Directive, viewChild } from '@angular/core';
5
5
  import * as i2 from '@angular/forms';
6
6
  import { FormsModule, NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
7
- import { BehaviorSubject, Subject, debounceTime, takeUntil, distinctUntilChanged, Observable, retry, catchError, finalize, throwError } from 'rxjs';
7
+ import { BehaviorSubject, Subject, debounceTime, takeUntil, distinctUntilChanged, Observable, retry, catchError, finalize, throwError, map } from 'rxjs';
8
8
  import * as i2$1 from '@angular/router';
9
9
  import * as i1$1 from '@angular/common/http';
10
10
  import { HttpClient, HttpEventType, HttpRequest } from '@angular/common/http';
@@ -2631,6 +2631,7 @@ class CideEleFileManagerService {
2631
2631
  _isUploading = signal(false, ...(ngDevMode ? [{ debugName: "_isUploading" }] : []));
2632
2632
  _uploadQueue = signal([], ...(ngDevMode ? [{ debugName: "_uploadQueue" }] : []));
2633
2633
  _activeUploads = signal(new Map(), ...(ngDevMode ? [{ debugName: "_activeUploads" }] : []));
2634
+ _fetchedFiles = signal(new Map(), ...(ngDevMode ? [{ debugName: "_fetchedFiles" }] : [])); // Group ID -> Files mapping
2634
2635
  _error = signal(null, ...(ngDevMode ? [{ debugName: "_error" }] : []));
2635
2636
  // Angular 20: Computed values
2636
2637
  baseUrl = this._baseUrl.asReadonly();
@@ -2639,13 +2640,20 @@ class CideEleFileManagerService {
2639
2640
  isUploading = this._isUploading.asReadonly();
2640
2641
  uploadQueue = this._uploadQueue.asReadonly();
2641
2642
  activeUploads = this._activeUploads.asReadonly();
2643
+ fetchedFiles = this._fetchedFiles.asReadonly();
2642
2644
  error = this._error.asReadonly();
2643
2645
  hasActiveUploads = computed(() => this._activeUploads().size > 0, ...(ngDevMode ? [{ debugName: "hasActiveUploads" }] : []));
2644
2646
  queueLength = computed(() => this._uploadQueue().length, ...(ngDevMode ? [{ debugName: "queueLength" }] : []));
2647
+ totalFetchedFiles = computed(() => {
2648
+ let total = 0;
2649
+ this._fetchedFiles().forEach(files => total += files.length);
2650
+ return total;
2651
+ }, ...(ngDevMode ? [{ debugName: "totalFetchedFiles" }] : []));
2645
2652
  serviceState = computed(() => ({
2646
2653
  isUploading: this._isUploading(),
2647
2654
  uploadQueue: this._uploadQueue(),
2648
2655
  activeUploads: this._activeUploads(),
2656
+ fetchedFiles: this._fetchedFiles(),
2649
2657
  error: this._error()
2650
2658
  }), ...(ngDevMode ? [{ debugName: "serviceState" }] : []));
2651
2659
  constructor() {
@@ -2892,6 +2900,87 @@ class CideEleFileManagerService {
2892
2900
  console.log('🔍 [FileManagerService] Fetching file details for ID:', payload.cyfm_id);
2893
2901
  return this.http.post(`${this._baseUrl()}`, payload).pipe(retry(2), catchError(this.handleError.bind(this)), takeUntilDestroyed(this.destroyRef));
2894
2902
  }
2903
+ /**
2904
+ * Get files by group ID and store them in service state
2905
+ * @param groupId The group ID to fetch files for
2906
+ * @returns Observable with files list
2907
+ */
2908
+ getFilesByGroupId(groupId) {
2909
+ console.log('🔍 [FileManagerService] Fetching files for group ID:', groupId);
2910
+ const payload = {
2911
+ cyfm_group_id: groupId
2912
+ };
2913
+ return this.http.post(`${this._baseUrl()}/group/${groupId}`, payload).pipe(retry(2), catchError(this.handleError.bind(this)), takeUntilDestroyed(this.destroyRef));
2914
+ }
2915
+ /**
2916
+ * Fetch and store files by group ID in service state
2917
+ * @param groupId The group ID to fetch files for
2918
+ * @returns Observable that completes when files are stored
2919
+ */
2920
+ fetchAndStoreFilesByGroupId(groupId) {
2921
+ console.log('📡 [FileManagerService] Fetching and storing files for group:', groupId);
2922
+ return this.getFilesByGroupId(groupId).pipe(map(response => {
2923
+ if (response.success && response.data && response.data.files) {
2924
+ // Store files in service state
2925
+ const currentFetchedFiles = new Map(this._fetchedFiles());
2926
+ currentFetchedFiles.set(groupId, response.data.files);
2927
+ this._fetchedFiles.set(currentFetchedFiles);
2928
+ console.log('📁 [FileManagerService] Stored', response.data.files.length, 'files for group:', groupId);
2929
+ return response.data.files;
2930
+ }
2931
+ return [];
2932
+ }), catchError(error => {
2933
+ console.error('❌ [FileManagerService] Failed to fetch files for group:', groupId, error);
2934
+ return [];
2935
+ }));
2936
+ }
2937
+ /**
2938
+ * Get fetched files for a specific group ID
2939
+ * @param groupId The group ID to get files for
2940
+ * @returns Array of files for the group
2941
+ */
2942
+ getFetchedFilesByGroupId(groupId) {
2943
+ return this._fetchedFiles().get(groupId) || [];
2944
+ }
2945
+ /**
2946
+ * Get all files (active uploads + fetched files) for a group ID
2947
+ * @param groupId The group ID to get files for
2948
+ * @returns Combined array of active and fetched files
2949
+ */
2950
+ getAllFilesForGroup(groupId) {
2951
+ const files = [];
2952
+ // Add active uploads for this group
2953
+ this._activeUploads().forEach((upload, fileId) => {
2954
+ if (upload.groupId === groupId) {
2955
+ files.push({
2956
+ fileId,
2957
+ fileName: this.getFileNameFromId(fileId),
2958
+ stage: upload.stage,
2959
+ percentage: upload.percentage
2960
+ });
2961
+ }
2962
+ });
2963
+ // Add fetched files for this group
2964
+ const fetchedFiles = this.getFetchedFilesByGroupId(groupId);
2965
+ fetchedFiles.forEach(file => {
2966
+ files.push({
2967
+ fileId: file.cyfm_id || file.id,
2968
+ fileName: file.cyfm_name || file.name,
2969
+ stage: 'complete' // Fetched files are already completed
2970
+ });
2971
+ });
2972
+ return files;
2973
+ }
2974
+ /**
2975
+ * Get file name from file ID (extract from the ID format)
2976
+ */
2977
+ getFileNameFromId(fileId) {
2978
+ const parts = fileId.split('_');
2979
+ if (parts.length >= 3) {
2980
+ return parts.slice(0, -2).join('_');
2981
+ }
2982
+ return fileId;
2983
+ }
2895
2984
  /**
2896
2985
  * Angular 20: Service utility methods
2897
2986
  */
@@ -3355,8 +3444,8 @@ class CideEleFloatingFileUploaderComponent {
3355
3444
  * Close the floating uploader
3356
3445
  */
3357
3446
  close() {
3358
- // Clear all completed uploads when closing
3359
- this.fileManagerService.clearCompletedUploads();
3447
+ // Don't clear files from service - just hide the uploader
3448
+ // Files will be fetched from API when "Show Files" is clicked
3360
3449
  this.hideWithAnimation();
3361
3450
  }
3362
3451
  /**
@@ -3435,9 +3524,15 @@ class CideEleFloatingFileUploaderComponent {
3435
3524
  return fileId;
3436
3525
  }
3437
3526
  /**
3438
- * Get all files from service state (pending + active uploads)
3527
+ * Get all files from service state (pending + active uploads + fetched files)
3439
3528
  */
3440
3529
  getAllFiles() {
3530
+ const groupId = this.currentGroupId();
3531
+ if (groupId) {
3532
+ // Use service method to get all files for this group
3533
+ return this.fileManagerService.getAllFilesForGroup(groupId);
3534
+ }
3535
+ // Fallback to general files if no group ID
3441
3536
  const files = [];
3442
3537
  // Add pending files
3443
3538
  this.uploadQueue().forEach(fileId => {
@@ -3510,6 +3605,17 @@ class CideEleFloatingFileUploaderComponent {
3510
3605
  console.log('👁️ [FloatingFileUploader] Manually showing uploader', groupId ? `for group: ${groupId}` : '');
3511
3606
  if (groupId) {
3512
3607
  this.currentGroupId.set(groupId);
3608
+ // Use service to fetch and store files
3609
+ this.fileManagerService.fetchAndStoreFilesByGroupId(groupId)
3610
+ .pipe(takeUntilDestroyed(this.destroyRef))
3611
+ .subscribe({
3612
+ next: (files) => {
3613
+ console.log('✅ [FloatingFileUploader] Files fetched and stored:', files.length);
3614
+ },
3615
+ error: (error) => {
3616
+ console.error('❌ [FloatingFileUploader] Failed to fetch files:', error);
3617
+ }
3618
+ });
3513
3619
  }
3514
3620
  this.showWithAnimation();
3515
3621
  }
@@ -4197,8 +4303,9 @@ class CideEleFileInputComponent {
4197
4303
  // If no group ID, return all uploads
4198
4304
  return this.fileManagerService.activeUploads().size;
4199
4305
  }
4200
- // Filter uploads by this component's group ID
4201
- return Array.from(this.fileManagerService.activeUploads().values()).filter(upload => upload.groupId === groupId).length;
4306
+ // Use service method to get all files for this group
4307
+ const allFiles = this.fileManagerService.getAllFilesForGroup(groupId);
4308
+ return allFiles.length;
4202
4309
  }
4203
4310
  /**
4204
4311
  * Check if there are active uploads for this component's group ID
@@ -4209,8 +4316,9 @@ class CideEleFileInputComponent {
4209
4316
  // If no group ID, check all uploads
4210
4317
  return Array.from(this.fileManagerService.activeUploads().values()).some(upload => upload.stage !== 'complete');
4211
4318
  }
4212
- // Filter by this component's group ID and check for active uploads
4213
- return Array.from(this.fileManagerService.activeUploads().values()).some(upload => upload.groupId === groupId && upload.stage !== 'complete');
4319
+ // Use service method to get all files and check for active ones
4320
+ const allFiles = this.fileManagerService.getAllFilesForGroup(groupId);
4321
+ return allFiles.some(file => file.stage !== 'complete');
4214
4322
  }
4215
4323
  /**
4216
4324
  * Get count of active (non-completed) uploads for this component's group ID
@@ -4221,8 +4329,9 @@ class CideEleFileInputComponent {
4221
4329
  // If no group ID, return all active uploads
4222
4330
  return Array.from(this.fileManagerService.activeUploads().values()).filter(upload => upload.stage !== 'complete').length;
4223
4331
  }
4224
- // Filter by this component's group ID and active uploads
4225
- return Array.from(this.fileManagerService.activeUploads().values()).filter(upload => upload.groupId === groupId && upload.stage !== 'complete').length;
4332
+ // Use service method to get all files and filter active ones
4333
+ const allFiles = this.fileManagerService.getAllFilesForGroup(groupId);
4334
+ return allFiles.filter(file => file.stage !== 'complete').length;
4226
4335
  }
4227
4336
  /**
4228
4337
  * Show floating uploader (alias for showUploader for template)