@@ -247,6 +247,9 @@ <h6><b>Methods</b></h6>
247247 < li >
248248 < a href ="#confirmAndDownload " > confirmAndDownload</ a >
249249 </ li >
250+ < li >
251+ < a href ="#downloadAllData " > downloadAllData</ a >
252+ </ li >
250253 < li >
251254 < a href ="#downloadData " > downloadData</ a >
252255 </ li >
@@ -494,6 +497,48 @@ <h3 id="methods">
494497 < td class ="col-md-4 ">
495498 < div class ="io-description "> < p > Validates date range and triggers the appropriate
496499export function (JSON, PDF, Excel) based on user selection.</ p >
500+ </ div >
501+
502+ < div class ="io-description ">
503+ < b > Returns : </ b > < code > < a href ="https://www.typescriptlang.org/docs/handbook/basic-types.html " target ="_blank " > void</ a > </ code >
504+
505+ </ div >
506+ </ td >
507+ </ tr >
508+ </ tbody >
509+ </ table >
510+ < table class ="table table-sm table-bordered ">
511+ < tbody >
512+ < tr >
513+ < td class ="col-md-4 ">
514+ < a name ="downloadAllData "> </ a >
515+ < span class ="name ">
516+ < span > < b > downloadAllData</ b > </ span >
517+ < a href ="#downloadAllData "> < span class ="icon ion-ios-link "> </ span > </ a >
518+ </ span >
519+ </ td >
520+ </ tr >
521+ < tr >
522+ < td class ="col-md-4 ">
523+ < code > downloadAllData()</ code >
524+ </ td >
525+ </ tr >
526+
527+
528+ < tr >
529+ < td class ="col-md-4 ">
530+ < div class ="io-line "> Defined in < a href ="" data-line ="342 "
531+ class ="link-to-prism "> src/app/component/settings-components/download-component/download-component.component.ts:342</ a > </ div >
532+ </ td >
533+ </ tr >
534+
535+
536+ < tr >
537+ < td class ="col-md-4 ">
538+ < div class ="io-description "> < p > Populates the date fields with the entire expense history range.</ p >
539+ < p > Fetches all expenses, determines the earliest and latest expense dates,
540+ and sets the 'From Date' and 'To Date' fields in the form to cover
541+ the full date range of the user's data, defaulting the file type to JSON.</ p >
497542</ div >
498543
499544 < div class ="io-description ">
@@ -1050,7 +1095,7 @@ <h3 id="inputs">
10501095
10511096 /** Category data */
10521097 categoryData: Category[] | [],
1053-
1098+
10541099 /** Budget data */
10551100 budgetData: Budget[] | []
10561101};
@@ -1121,7 +1166,7 @@ <h3 id="inputs">
11211166 this.downloadDataForm = this.fb.group({
11221167 fromDate: ['', [Validators.required]],
11231168 toDate: ['', [Validators.required]],
1124- fileType: ['JSON ', [Validators.required]],
1169+ fileType: ['PDF ', [Validators.required]],
11251170 });
11261171 }
11271172
@@ -1174,7 +1219,7 @@ <h3 id="inputs">
11741219 expense_id: expense.expense_id,
11751220 isExtraSpending: expense.isExtraSpending
11761221 }));
1177-
1222+
11781223 // Prepare final data object
11791224 const finalData: UserData = {
11801225 userData: userData || {},
@@ -1237,7 +1282,7 @@ <h3 id="inputs">
12371282 this.downloadDataForm.reset({
12381283 fromDate: '',
12391284 toDate: '',
1240- fileType: 'JSON '
1285+ fileType: 'PDF '
12411286 });
12421287 this.downloadDataForm.markAsPristine();
12431288 this.downloadDataForm.markAsUntouched();
@@ -1358,6 +1403,26 @@ <h3 id="inputs">
13581403 XLSX.writeFile(workbook, filename);
13591404 }
13601405
1406+ /**
1407+ * Populates the date fields with the entire expense history range.
1408+ *
1409+ * Fetches all expenses, determines the earliest and latest expense dates,
1410+ * and sets the 'From Date' and 'To Date' fields in the form to cover
1411+ * the full date range of the user's data, defaulting the file type to JSON.
1412+ */
1413+ downloadAllData(): void {
1414+ const expenseData: Expense[] = this.expenseService.getAll();
1415+ if (expenseData.length > 0) {
1416+ expenseData.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
1417+ const fromDate = expenseData[expenseData.length - 1].date;
1418+ const toDate = expenseData[0].date;
1419+ this.downloadDataForm.reset({
1420+ fromDate: fromDate,
1421+ toDate: toDate,
1422+ fileType: this.downloadDataForm.get('fileType')?.value || 'PDF'
1423+ });
1424+ }
1425+ }
13611426}
13621427</ code > </ pre >
13631428 </ div >
@@ -1392,14 +1457,14 @@ <h3 id="inputs">
13921457 <label class="block mb-1 font-medium">File Type</label>
13931458 <select formControlName="fileType"
13941459 class="w-full p-2 rounded border text-[var(--input-text)] bg-[var(--input-bg)] border-[var(--input-border)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-color)] transition-all duration-200">
1395- <option value="JSON">JSON</option>
13961460 <option value="PDF">PDF</option>
13971461 <option value="EXCEL">EXCEL</option>
1462+ <option value="JSON">JSON</option>
13981463 </select>
13991464
14001465 <div class="flex justify-end mt-2">
1401- <button type="button" (click)="closeDownloadDataModal ()"
1402- class="mr-2 px-4 py-2 bg-[var(--color-gray-500)] text-white rounded">Cancel </button>
1466+ <button type="button" (click)="downloadAllData ()"
1467+ class="mr-2 px-4 py-2 bg-[var(--color-gray-500)] text-white rounded">All Data </button>
14031468 <button type="submit" class="px-4 py-2 bg-[var(--color-accent)] text-white rounded">Download</button>
14041469 </div>
14051470 </form>
@@ -1432,7 +1497,7 @@ <h3 id="inputs">
14321497< script src ="../js/libs/htmlparser.js "> </ script >
14331498< script src ="../js/libs/deep-iterator.js "> </ script >
14341499< script >
1435- var COMPONENT_TEMPLATE = '<div><button (click)="openDownloadDataModal()" class="p-2 rounded-lg bg-[var(--color-accent)] hover:opacity-90 transition flex items-center justify-center"> <img src="assets/img/icon/icons8-download-48.png" alt="Download" class="w-5 h-5" style="filter: invert(100%);" /></button><app-form-model *ngIf="showDownloadDataModal" [label]="\'Download Data\'" (close)="closeDownloadDataModal()"> <form [formGroup]="downloadDataForm" (ngSubmit)="downloadData()"> <label class="block mb-1 font-medium">From Date</label> <input formControlName="fromDate" type="date" autocomplete="off" [max]="today" placeholder="From Date" class="w-full p-2 rounded border text-[var(--input-text)] bg-[var(--input-bg)] border-[var(--input-border)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-color)] transition-all duration-200" /> <div class="error-message text-[var(--color-error)]" *ngIf="downloadDataForm.get(\'fromDate\')?.touched && downloadDataForm.get(\'fromDate\')?.errors?.[\'required\']"> From Date is required </div> <label class="block mb-1 font-medium">To Date</label> <input formControlName="toDate" type="date" autocomplete="off" [max]="today" [min]="downloadDataForm.get(\'fromDate\')?.value" placeholder="To Date" class="w-full p-2 rounded border text-[var(--input-text)] bg-[var(--input-bg)] border-[var(--input-border)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-color)] transition-all duration-200" /> <div class="error-message text-[var(--color-error)]" *ngIf="downloadDataForm.get(\'toDate\')?.touched && downloadDataForm.get(\'toDate\')?.errors?.[\'required\']"> To Date is required </div> <label class="block mb-1 font-medium">File Type</label> <select formControlName="fileType" class="w-full p-2 rounded border text-[var(--input-text)] bg-[var(--input-bg)] border-[var(--input-border)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-color)] transition-all duration-200"> <option value="JSON">JSON</option> <option value="PDF">PDF</option> <option value="EXCEL">EXCEL</option> </select> <div class="flex justify-end mt-2"> <button type="button" (click)="closeDownloadDataModal()" class="mr-2 px-4 py-2 bg-[var(--color-gray-500)] text-white rounded">Cancel</button> <button type="submit" class="px-4 py-2 bg-[var(--color-accent)] text-white rounded">Download</button> </div> </form></app-form-model></div>'
1500+ var COMPONENT_TEMPLATE = '<div><button (click)="openDownloadDataModal()" class="p-2 rounded-lg bg-[var(--color-accent)] hover:opacity-90 transition flex items-center justify-center"> <img src="assets/img/icon/icons8-download-48.png" alt="Download" class="w-5 h-5" style="filter: invert(100%);" /></button><app-form-model *ngIf="showDownloadDataModal" [label]="\'Download Data\'" (close)="closeDownloadDataModal()"> <form [formGroup]="downloadDataForm" (ngSubmit)="downloadData()"> <label class="block mb-1 font-medium">From Date</label> <input formControlName="fromDate" type="date" autocomplete="off" [max]="today" placeholder="From Date" class="w-full p-2 rounded border text-[var(--input-text)] bg-[var(--input-bg)] border-[var(--input-border)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-color)] transition-all duration-200" /> <div class="error-message text-[var(--color-error)]" *ngIf="downloadDataForm.get(\'fromDate\')?.touched && downloadDataForm.get(\'fromDate\')?.errors?.[\'required\']"> From Date is required </div> <label class="block mb-1 font-medium">To Date</label> <input formControlName="toDate" type="date" autocomplete="off" [max]="today" [min]="downloadDataForm.get(\'fromDate\')?.value" placeholder="To Date" class="w-full p-2 rounded border text-[var(--input-text)] bg-[var(--input-bg)] border-[var(--input-border)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-color)] transition-all duration-200" /> <div class="error-message text-[var(--color-error)]" *ngIf="downloadDataForm.get(\'toDate\')?.touched && downloadDataForm.get(\'toDate\')?.errors?.[\'required\']"> To Date is required </div> <label class="block mb-1 font-medium">File Type</label> <select formControlName="fileType" class="w-full p-2 rounded border text-[var(--input-text)] bg-[var(--input-bg)] border-[var(--input-border)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-color)] transition-all duration-200"> <option value="PDF">PDF</option> <option value="EXCEL">EXCEL</option> <option value="JSON">JSON</option> </select> <div class="flex justify-end mt-2"> <button type="button" (click)="downloadAllData()" class="mr-2 px-4 py-2 bg-[var(--color-gray-500)] text-white rounded">All Data</button> <button type="submit" class="px-4 py-2 bg-[var(--color-accent)] text-white rounded">Download</button> </div> </form></app-form-model></div>'
14361501 var COMPONENTS = [ { 'name' : 'AddExpenseComponent' , 'selector' : 'app-add-expense' } , { 'name' : 'AiComponent' , 'selector' : 'app-ai' } , { 'name' : 'AppComponent' , 'selector' : 'app-root' } , { 'name' : 'BudgetComponent' , 'selector' : 'app-budget' } , { 'name' : 'CalendarComponent' , 'selector' : 'app-calendar' } , { 'name' : 'CategoryDropdownComponent' , 'selector' : 'app-category-dropdown' } , { 'name' : 'DownloadComponentComponent' , 'selector' : 'app-download-component' } , { 'name' : 'ExpenseDetailsModalComponent' , 'selector' : 'app-expense-details-modal' } , { 'name' : 'ExpenseListComponent' , 'selector' : 'app-expense-list' } , { 'name' : 'ExpenseWiseComponent' , 'selector' : 'app-expense-wise' } , { 'name' : 'FooterComponent' , 'selector' : 'app-footer' } , { 'name' : 'FormModelComponent' , 'selector' : 'app-form-model' } , { 'name' : 'GlobalLoaderComponent' , 'selector' : 'app-global-loader' } , { 'name' : 'GraphsComponent' , 'selector' : 'app-graphs' } , { 'name' : 'HamburgerMenuComponent' , 'selector' : 'app-hamburger-menu' } , { 'name' : 'HomeComponent' , 'selector' : 'app-home' } , { 'name' : 'InstallAppPopupComponentComponent' , 'selector' : 'app-install-app-popup-component' } , { 'name' : 'ListExpensesComponent' , 'selector' : 'app-list-expenses' } , { 'name' : 'MusicComponent' , 'selector' : 'app-music' } , { 'name' : 'NavbarComponent' , 'selector' : 'app-navbar' } , { 'name' : 'PieChartComponent' , 'selector' : 'app-pie-chart' } , { 'name' : 'PlaylistMusicComponent' , 'selector' : 'app-playlist-music' } , { 'name' : 'SearchButtonComponent' , 'selector' : 'app-search-button' } , { 'name' : 'SearchMusicComponent' , 'selector' : 'app-search-music' } , { 'name' : 'SettingItemComponent' , 'selector' : 'app-setting-item' } , { 'name' : 'SettingsComponent' , 'selector' : 'app-settings' } , { 'name' : 'SidebarComponent' , 'selector' : 'app-sidebar' } , { 'name' : 'TemplatePlaygroundComponent' , 'selector' : 'template-playground-root' } , { 'name' : 'ToastComponent' , 'selector' : 'app-toast' } ] ;
14371502 var DIRECTIVES = [ ] ;
14381503 var ACTUAL_COMPONENT = { 'name' : 'DownloadComponentComponent' } ;
0 commit comments