cloud-ide-element 1.0.90 → 1.0.92
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/fesm2022/cloud-ide-element.mjs +179 -17
- package/fesm2022/cloud-ide-element.mjs.map +1 -1
- package/index.d.ts +49 -4
- package/package.json +1 -1
|
@@ -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
|
-
//
|
|
3359
|
-
|
|
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
|
}
|
|
@@ -3701,13 +3807,22 @@ class CideEleFileInputComponent {
|
|
|
3701
3807
|
writeValue(value) {
|
|
3702
3808
|
console.log('📝 [FileInput] writeValue called with:', value);
|
|
3703
3809
|
if (typeof value === 'string') {
|
|
3704
|
-
//
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3810
|
+
// Check if this is a group ID for multiple files or single file ID
|
|
3811
|
+
if (this.isMultipleFileMode()) {
|
|
3812
|
+
// Multiple file mode - value is group ID
|
|
3813
|
+
console.log('📁 [FileInput] Value is group ID for multiple files:', value);
|
|
3814
|
+
this.groupId.set(value);
|
|
3815
|
+
this.loadFilesFromGroupId(value);
|
|
3816
|
+
}
|
|
3817
|
+
else {
|
|
3818
|
+
// Single file mode - value is file ID
|
|
3819
|
+
console.log('📝 [FileInput] Value is single file ID:', value);
|
|
3820
|
+
this.files.set(null);
|
|
3821
|
+
this.fileNames.set([]);
|
|
3822
|
+
this.clearPreviews();
|
|
3823
|
+
// Fetch file details to get base64 and set preview
|
|
3824
|
+
this.loadFileDetailsFromId(value);
|
|
3825
|
+
}
|
|
3711
3826
|
}
|
|
3712
3827
|
else if (value instanceof FileList) {
|
|
3713
3828
|
// Value is a FileList
|
|
@@ -3715,6 +3830,14 @@ class CideEleFileInputComponent {
|
|
|
3715
3830
|
this.files.set(value);
|
|
3716
3831
|
this.fileNames.set(Array.from(value).map(f => f.name));
|
|
3717
3832
|
this.generatePreviews();
|
|
3833
|
+
// For multiple files, use group ID API to fetch files
|
|
3834
|
+
if (value.length > 1) {
|
|
3835
|
+
const groupId = this.groupId();
|
|
3836
|
+
if (groupId) {
|
|
3837
|
+
console.log('📁 [FileInput] Multiple files detected, fetching files for group:', groupId);
|
|
3838
|
+
this.loadFilesFromGroupId(groupId);
|
|
3839
|
+
}
|
|
3840
|
+
}
|
|
3718
3841
|
}
|
|
3719
3842
|
else {
|
|
3720
3843
|
// Value is null
|
|
@@ -4117,6 +4240,42 @@ class CideEleFileInputComponent {
|
|
|
4117
4240
|
}
|
|
4118
4241
|
});
|
|
4119
4242
|
}
|
|
4243
|
+
/**
|
|
4244
|
+
* Check if the component is in multiple file mode
|
|
4245
|
+
*/
|
|
4246
|
+
isMultipleFileMode() {
|
|
4247
|
+
// Check if multiple attribute is set or if we have a group ID
|
|
4248
|
+
return this.multiple || this.groupId() !== null;
|
|
4249
|
+
}
|
|
4250
|
+
/**
|
|
4251
|
+
* Load files from group ID using the group API
|
|
4252
|
+
*/
|
|
4253
|
+
loadFilesFromGroupId(groupId) {
|
|
4254
|
+
console.log('🔍 [FileInput] Loading files for group ID:', groupId);
|
|
4255
|
+
if (!groupId)
|
|
4256
|
+
return;
|
|
4257
|
+
this.fileManagerService.fetchAndStoreFilesByGroupId(groupId)
|
|
4258
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
4259
|
+
.subscribe({
|
|
4260
|
+
next: (files) => {
|
|
4261
|
+
console.log('📋 [FileInput] Files loaded for group:', files.length);
|
|
4262
|
+
// Set file names to show count in input
|
|
4263
|
+
if (files && files.length > 0) {
|
|
4264
|
+
const fileNames = files.map(file => file.file_name || file.name || 'Unknown file');
|
|
4265
|
+
this.fileNames.set(fileNames);
|
|
4266
|
+
console.log('📝 [FileInput] File names set for display:', fileNames);
|
|
4267
|
+
}
|
|
4268
|
+
else {
|
|
4269
|
+
this.fileNames.set([]);
|
|
4270
|
+
}
|
|
4271
|
+
// Files are now stored in service state and will be displayed by floating uploader
|
|
4272
|
+
},
|
|
4273
|
+
error: (error) => {
|
|
4274
|
+
console.error('❌ [FileInput] Failed to load files for group:', error);
|
|
4275
|
+
this.fileNames.set([]);
|
|
4276
|
+
}
|
|
4277
|
+
});
|
|
4278
|
+
}
|
|
4120
4279
|
isImageFileFromName(fileName) {
|
|
4121
4280
|
if (!fileName)
|
|
4122
4281
|
return false;
|
|
@@ -4197,8 +4356,9 @@ class CideEleFileInputComponent {
|
|
|
4197
4356
|
// If no group ID, return all uploads
|
|
4198
4357
|
return this.fileManagerService.activeUploads().size;
|
|
4199
4358
|
}
|
|
4200
|
-
//
|
|
4201
|
-
|
|
4359
|
+
// Use service method to get all files for this group
|
|
4360
|
+
const allFiles = this.fileManagerService.getAllFilesForGroup(groupId);
|
|
4361
|
+
return allFiles.length;
|
|
4202
4362
|
}
|
|
4203
4363
|
/**
|
|
4204
4364
|
* Check if there are active uploads for this component's group ID
|
|
@@ -4209,8 +4369,9 @@ class CideEleFileInputComponent {
|
|
|
4209
4369
|
// If no group ID, check all uploads
|
|
4210
4370
|
return Array.from(this.fileManagerService.activeUploads().values()).some(upload => upload.stage !== 'complete');
|
|
4211
4371
|
}
|
|
4212
|
-
//
|
|
4213
|
-
|
|
4372
|
+
// Use service method to get all files and check for active ones
|
|
4373
|
+
const allFiles = this.fileManagerService.getAllFilesForGroup(groupId);
|
|
4374
|
+
return allFiles.some(file => file.stage !== 'complete');
|
|
4214
4375
|
}
|
|
4215
4376
|
/**
|
|
4216
4377
|
* Get count of active (non-completed) uploads for this component's group ID
|
|
@@ -4221,8 +4382,9 @@ class CideEleFileInputComponent {
|
|
|
4221
4382
|
// If no group ID, return all active uploads
|
|
4222
4383
|
return Array.from(this.fileManagerService.activeUploads().values()).filter(upload => upload.stage !== 'complete').length;
|
|
4223
4384
|
}
|
|
4224
|
-
//
|
|
4225
|
-
|
|
4385
|
+
// Use service method to get all files and filter active ones
|
|
4386
|
+
const allFiles = this.fileManagerService.getAllFilesForGroup(groupId);
|
|
4387
|
+
return allFiles.filter(file => file.stage !== 'complete').length;
|
|
4226
4388
|
}
|
|
4227
4389
|
/**
|
|
4228
4390
|
* Show floating uploader (alias for showUploader for template)
|