more delinting and a Create New Session post-dialog summary. TODO: swap the window...
authorJason Etheridge <phasefx@gmail.com>
Fri, 12 May 2023 14:43:58 +0000 (10:43 -0400)
committerJason Etheridge <phasefx@gmail.com>
Sun, 14 May 2023 13:04:51 +0000 (09:04 -0400)
Signed-off-by: Jason Etheridge <phasefx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/linkchecker/linkchecker.component.ts
Open-ILS/src/eg2/src/app/staff/cat/linkchecker/new-session-dialog.component.ts

index 037934d..5cbf8b3 100644 (file)
@@ -156,12 +156,20 @@ export class LinkCheckerComponent implements OnInit {
        newSessionWrapper(optionalSessionToClone?: any) {
         this.newSessionDialog.sessionToClone = optionalSessionToClone;
                this.newSessionDialog.open({size: 'lg'}).subscribe( (res) => {
-            console.log('dialog res', res);
+            console.log('new dialog res', res);
+            if (res['sessionId']) {
+                window.alert( // TODO: replace this with an angular dialog
+                      $localize`Session ID = ` + res['sessionId'] + '\n'
+                    + $localize`Title Hits = ` + res['number_of_hits'] + '\n'
+                    + $localize`URLs Extracted = ` + res['urls_extracted'] + '\n'
+                    + $localize`URLs Verified = ` + res['verified_total_processed'] + '\n'
+                );
+            }
             if (res && res['sessionId']) {
-                if (res['viewURLs']) {
+                if (res['viewURLs'] && res['urls_extracted'] > 0) {
                     this.router.navigate(['/staff/cat/linkchecker/urls/'],
                         { queryParams: { sessions: JSON.stringify([ Number(res['sessionId']) ]) } });
-                } else if (res['viewAttempts']) {
+                } else if (res['viewAttempts'] && res['verified_total_processed'] > 0) {
                     this.router.navigate(['/staff/cat/linkchecker/attempts/'],
                         { queryParams: { sessions: JSON.stringify([ Number(res['sessionId']) ]) } });
                 } else {
index affe138..e1e1862 100644 (file)
@@ -62,6 +62,7 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
         private renderer: Renderer2,
     ) {
         super(modal);
+        if (this.modal) {} // noop for linting
     }
 
     ngOnInit() {
@@ -137,9 +138,11 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
 
     applyOwningLibrary(p: any) {
         // [applyOrgId]="sessionOwningLibrary" is working fine
+        if (p) {} // noop for linting
     }
 
     applySessionSearch(p: any) {
+        if (p) {} // noop for linting
     }
 
     applySearchScope(p: any) {
@@ -169,7 +172,8 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
 
     // https://stackoverflow.com/questions/42322968/angular2-dynamic-input-field-lose-focus-when-input-changes
     trackByIdx(index: any, item: any) {
-       return index;
+        if (item) {} // noop for linting
+        return index;
     }
 
     addSelectorRow(index: number): void {
@@ -200,6 +204,9 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
 
     createNewSession(options: any) {
         ///////////////////////////////////////////////
+        options['verified_total_processed'] = 0;
+        options['url_selectors_created'] = 0;
+        options['urls_extracted'] = 0;
         this.startProgressMeter($localize`Creating session...`);
         this.subscriptions.push(this.net.request(
             'open-ils.url_verify',
@@ -229,7 +236,8 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
                                     this.stopProgressMeter();
                                     this.close(false);
                                 } else {
-                                    console.log('url_selector',res2);
+                                    //console.log('url_selector',res2);
+                                    options['url_selectors_created'] += 1;
                                 }
                             },
                             error: (err2) => {
@@ -251,11 +259,17 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
                                         console.log('res3',res3);
                                         if (!this.progress.hasMax()) {
                                             // first response returned by the API is the number of search results
+                                            options['number_of_hits'] = Number(res3);
                                             // We'll become a determinate progress meter for this section
                                             this.progress.update({max: res3, value: 0});
                                         } else {
                                             // subsequent responses are the number of URLs extracted from each search result
                                             this.progress.increment();
+                                            if (Array.isArray(res3)) {
+                                                res3.forEach( c => options['urls_extracted'] += Number(c) );
+                                            } else {
+                                                options['urls_extracted'] += Number(res3);
+                                            }
                                         }
                                     },
                                     error: (err3) => {
@@ -278,6 +292,7 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
                                                 next: (res4) => {
                                                     console.log('res4',res4);
                                                     this.progress.update({max: res4['url_count'], value: res4['total_processed']});
+                                                    options['verified_total_processed'] = Number(res4['total_processed']);
                                                 },
                                                 error: (err4) => {
                                                     this.stopProgressMeter();