Skip to content

Commit d7dbfe7

Browse files
committed
feat: add loading
1 parent 514eef5 commit d7dbfe7

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/app/afip/afip.component.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
</div>
1313
</div>
1414

15-
<button mat-raised-button color="primary" class="w-100" (click)="test()">TEST</button>
15+
<!--button mat-raised-button color="primary" class="w-100" (click)="test()">TEST</button-->
1616

17-
<div *ngIf="invoices.length > 0" class="row">
17+
<div *ngIf="invoices.length > 0 && !loading" class="row">
1818
<div class="col-12">
1919
<table mat-table [dataSource]="invoices" class="mat-elevation-z8 w-100" multiTemplateDataRows>
2020

@@ -56,4 +56,7 @@ <h5 class="mb-1"><b>Receptor:</b> {{element.nameRec}}</h5>
5656

5757
</table>
5858
</div>
59+
</div>
60+
<div class="row text-center" *ngIf="loading">
61+
<mat-spinner class="mx-auto" diameter="40"></mat-spinner>
5962
</div>

src/app/afip/afip.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export class AfipComponent implements OnInit {
4141
expandedElement: InvoiceElement | null | undefined;
4242
@ViewChild(MatTable) table: MatTable<InvoiceElement> | undefined;
4343

44+
loading = false;
45+
4446
constructor(private barcodeScanner: BarcodeScanner, public dialog: MatDialog, private http: HttpClient) { }
4547

4648
ngOnInit(): void {
@@ -75,6 +77,7 @@ export class AfipComponent implements OnInit {
7577
}
7678

7779
async processQR(t: string) {
80+
this.loading = true;
7881
const url = new URL(t);
7982
const p: any = url.searchParams.get('p');
8083
let encode = p.replace(/b\'(.*)\'/, '$1').replace(/\n/g, '');
@@ -91,15 +94,18 @@ export class AfipComponent implements OnInit {
9194
newinvoice.nameRec = dataR.Contribuyente.nombre;
9295
this.invoices.push(newinvoice);
9396
localStorage.setItem('invoices', JSON.stringify(this.invoices));
97+
this.loading = false;
9498
if (this.table) {
9599
this.table!.renderRows();
96100
}
97101
}
98102
}, (err: any) => {
103+
this.loading = false;
99104
this.openDialog(err);
100105
});
101106
}
102107
}, (err: any) => {
108+
this.loading = false;
103109
this.openDialog(err);
104110
})
105111
} else {

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { MatButtonModule } from '@angular/material/button';
2020
import { MatTableModule } from '@angular/material/table';
2121
import { MatIconModule } from '@angular/material/icon';
2222
import { MatDialogModule } from '@angular/material/dialog';
23+
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
2324

2425
import { AfipComponent } from './afip/afip.component';
2526
import { DialogContent } from './afip/afip.component';
@@ -47,7 +48,8 @@ const routes: Routes = [
4748
MatButtonModule,
4849
MatTableModule,
4950
MatIconModule,
50-
MatDialogModule
51+
MatDialogModule,
52+
MatProgressSpinnerModule
5153
],
5254
providers: [BarcodeScanner, FileOpener],
5355
bootstrap: [AppComponent]

0 commit comments

Comments
 (0)