de-linting and session names in view urls view
authorJason Etheridge <jason@EquinoxOLI.org>
Thu, 11 May 2023 19:01:44 +0000 (15:01 -0400)
committerJason Etheridge <phasefx@gmail.com>
Sun, 14 May 2023 13:04:51 +0000 (09:04 -0400)
Signed-off-by: Jason Etheridge <jason@EquinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/cat/linkchecker/attempts.component.ts
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
Open-ILS/src/eg2/src/app/staff/cat/linkchecker/urls.component.html
Open-ILS/src/eg2/src/app/staff/cat/linkchecker/urls.component.ts

index b80296b..1125625 100644 (file)
@@ -1,32 +1,11 @@
-import * as Moment from 'moment-timezone';
 import {ActivatedRoute} from '@angular/router';
-import {AuthService} from '@eg/core/auth.service';
-import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
-import {Component, OnInit, ViewChild, Input, TemplateRef} from '@angular/core';
-import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
-import {DateSelectComponent} from '@eg/share/date-select/date-select.component';
-import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
-import {FormGroup, FormControl} from '@angular/forms';
-import {FormatService} from '@eg/core/format.service';
+import {Component, OnInit, ViewChild} from '@angular/core';
 import {GridComponent} from '@eg/share/grid/grid.component';
-import {GridDataSource, GridColumn, GridRowFlairEntry, GridCellTextGenerator} from '@eg/share/grid/grid';
+import {GridDataSource} from '@eg/share/grid/grid';
 import {GridFlatDataService} from '@eg/share/grid/grid-flat-data.service';
-import {HtmlToTxtService} from '@eg/share/util/htmltotxt.service';
-import {IdlService, IdlObject} from '@eg/core/idl.service';
-import {NgbDate} from '@ng-bootstrap/ng-bootstrap';
-import {OrgFamily} from '@eg/share/org-family-select/org-family-select.component';
-import {OrgService} from '@eg/core/org.service';
+import {IdlService} from '@eg/core/idl.service';
 import {Pager} from '@eg/share/util/pager';
 import {PcrudService} from '@eg/core/pcrud.service';
-import {PermService} from '@eg/core/perm.service';
-import {PrintService} from '@eg/share/print/print.service';
-import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
-import {SampleDataService} from '@eg/share/util/sample-data.service';
-import {StringComponent} from '@eg/share/string/string.component';
-import {StringService} from '@eg/share/string/string.service';
-import {ToastService} from '@eg/share/toast/toast.service';
-import {map, take} from 'rxjs/operators';
-import {timer as observableTimer, Observable, of} from 'rxjs';
 
 @Component({
   templateUrl: 'attempts.component.html'
@@ -60,13 +39,9 @@ export class LinkCheckerAttemptsComponent implements OnInit {
     oneSelectedRow: boolean;
 
     constructor(
-        private auth: AuthService,
         private flatData: GridFlatDataService,
-        private format: FormatService,
         private idl: IdlService,
-        private org: OrgService,
         private pcrud: PcrudService,
-        private perm: PermService,
         private route: ActivatedRoute,
     ) {}
 
@@ -84,21 +59,21 @@ export class LinkCheckerAttemptsComponent implements OnInit {
                 }
                 var batchSearch = {};
                 batchSearch[ this.batchesSessionField ] = JSON.parse( params.sessions );
-                this.pcrud.search(this.batchesIdlClass,batchSearch).subscribe(
-                    (batch) => {
+                this.pcrud.search(this.batchesIdlClass,batchSearch).subscribe({
+                    next: (batch) => {
                         if (this.batches.length === 1 && this.batches[0] === -1) {
                             this.batches = []; // undo our kludge, otherwise -1 would be in the dialog title
                         }
                         this.batches.push( batch.id() ); 
                     },
-                    (err) => {
+                    error: (err) => {
                         console.log('pcrud.search.uvs err', err);
                     },
-                    () => {
+                    complete: () => {
                         this.batches = Array.from( new Set( this.batches ) );
                         this.grid.reload();
                     }
-                );
+                });
             }
         });
 
@@ -117,7 +92,7 @@ export class LinkCheckerAttemptsComponent implements OnInit {
     gridSelectionChange(keys: string[]) {
         this.noSelectedRows = (keys.length === 0);
         this.oneSelectedRow = (keys.length === 1);
-        var rows = this.grid.context.getSelectedRows();
+        //var rows = this.grid.context.getSelectedRows();
     }
 
     initDataSource() {
index e4c7a84..037934d 100644 (file)
@@ -1,34 +1,18 @@
-import * as Moment from 'moment-timezone';
 import {Router, ActivatedRoute} from '@angular/router';
 import {AuthService} from '@eg/core/auth.service';
-import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
-import {Component, OnInit, ViewChild, Input, TemplateRef} from '@angular/core';
+import {Component, OnInit, ViewChild} from '@angular/core';
 import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
-import {DateSelectComponent} from '@eg/share/date-select/date-select.component';
-import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
 import {NewSessionDialogComponent} from './new-session-dialog.component';
-import {FormGroup, FormControl} from '@angular/forms';
-import {FormatService} from '@eg/core/format.service';
 import {GridComponent} from '@eg/share/grid/grid.component';
-import {GridDataSource, GridColumn, GridRowFlairEntry, GridCellTextGenerator} from '@eg/share/grid/grid';
+import {GridDataSource} from '@eg/share/grid/grid';
 import {GridFlatDataService} from '@eg/share/grid/grid-flat-data.service';
-import {HtmlToTxtService} from '@eg/share/util/htmltotxt.service';
 import {IdlService, IdlObject} from '@eg/core/idl.service';
 import {NetService} from '@eg/core/net.service';
-import {NgbDate} from '@ng-bootstrap/ng-bootstrap';
 import {OrgFamily} from '@eg/share/org-family-select/org-family-select.component';
 import {OrgService} from '@eg/core/org.service';
 import {Pager} from '@eg/share/util/pager';
-import {PcrudService} from '@eg/core/pcrud.service';
 import {PermService} from '@eg/core/perm.service';
-import {PrintService} from '@eg/share/print/print.service';
-import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
-import {SampleDataService} from '@eg/share/util/sample-data.service';
 import {StringComponent} from '@eg/share/string/string.component';
-import {StringService} from '@eg/share/string/string.service';
-import {ToastService} from '@eg/share/toast/toast.service';
-import {map, take} from 'rxjs/operators';
-import {timer as observableTimer, Observable, of} from 'rxjs';
 
 @Component({
   templateUrl: 'linkchecker.component.html'
@@ -71,15 +55,12 @@ export class LinkCheckerComponent implements OnInit {
     constructor(
         private auth: AuthService,
         private flatData: GridFlatDataService,
-        private format: FormatService,
         private idl: IdlService,
         private net: NetService,
         private org: OrgService,
-        private pcrud: PcrudService,
         private perm: PermService,
         private route: ActivatedRoute,
         private router: Router,
-        private toast: ToastService,
     ) {}
 
     ngOnInit() {
@@ -129,6 +110,7 @@ export class LinkCheckerComponent implements OnInit {
 
     gridSelectionChange(keys: string[]) {
         var rows = this.grid.context.getSelectedRows();
+        console.log('keys.length = ' + keys.length + ', rows.length = ' + rows.length);
 
         this.noSelectedRows = (rows.length === 0);
         this.oneSelectedRow = (rows.length === 1);
@@ -171,7 +153,7 @@ export class LinkCheckerComponent implements OnInit {
         });
     }
 
-       newSessionWrapper(optionalSessionToClone?) {
+       newSessionWrapper(optionalSessionToClone?: any) {
         this.newSessionDialog.sessionToClone = optionalSessionToClone;
                this.newSessionDialog.open({size: 'lg'}).subscribe( (res) => {
             console.log('dialog res', res);
@@ -205,7 +187,7 @@ export class LinkCheckerComponent implements OnInit {
             var session_ids = rows.map(r => r.session_id );
 
             var that = this;
-            function delete_next(ids) {
+            function delete_next(ids: number[]) {
                 var id = ids.pop();
                 if (id) {
                     that.net.request(
@@ -213,20 +195,20 @@ export class LinkCheckerComponent implements OnInit {
                         'open-ils.url_verify.session.delete',
                         that.auth.token(),
                         id,
-                    ).subscribe(
-                        (res) => {
+                    ).subscribe({
+                        next: (res) => {
                             console.log('session.delete res', res);
                             // toast
                         },
-                        (err) => {
+                        error: (err) => {
                             console.log('session.delete err', err);
                             // toast
                         },
-                        () => {
+                        complete: () => {
                             console.log('session.delete finis');
                             delete_next(ids);
                         }
-                    );
+                    });
                 } else {
                     setTimeout( () => { that.grid.reload(); } );
                 }
index 62420b5..affe138 100644 (file)
@@ -1,27 +1,24 @@
 import {AlertDialogComponent} from '@eg/share/dialog/alert.component';
 import {AuthService} from '@eg/core/auth.service';
 import {ComboboxEntry, ComboboxComponent} from '@eg/share/combobox/combobox.component';
-import {Component, Input, OnInit, ViewChild, Renderer2} from '@angular/core';
+import {Component, Input, OnInit, ViewChild, Renderer2, OnDestroy} from '@angular/core';
 import {DialogComponent} from '@eg/share/dialog/dialog.component';
+import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
 import {EventService} from '@eg/core/event.service';
-import {FormControl} from '@angular/forms';
 import {IdlService, IdlObject} from '@eg/core/idl.service';
 import {NetService} from '@eg/core/net.service';
 import {NgForm} from '@angular/forms';
-import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
-import {StringComponent} from '@eg/share/string/string.component';
-import {Subject, Subscription, Observable, from, EMPTY, throwError} from 'rxjs';
-import {ToastService} from '@eg/share/toast/toast.service';
-import {debounceTime, distinctUntilChanged, switchMap, takeLast, finalize} from 'rxjs/operators';
+import {Subject, Subscription, Observable} from 'rxjs';
+import {debounceTime, distinctUntilChanged} from 'rxjs/operators';
 
 @Component({
   selector: 'eg-new-session-dialog',
   templateUrl: './new-session-dialog.component.html'
 })
 
-export class NewSessionDialogComponent extends DialogComponent implements OnInit {
+export class NewSessionDialogComponent extends DialogComponent implements OnInit, OnDestroy {
 
     @Input() sessionToClone: IdlObject; // not really a "session", but a combined session/batch view
 
@@ -60,7 +57,6 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
         private auth: AuthService,
         private evt: EventService,
         private net: NetService,
-        private toast: ToastService,
         private idl: IdlService,
         private pcrud: PcrudService,
         private renderer: Renderer2,
@@ -81,7 +77,7 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
                     this.pcrud.search('uvus', {'session':this.sessionToClone.session_id()},{},{'atomic':true}).subscribe(
                         (list) => {
                             console.log('list',list);
-                            list.forEach( (s,idx) => {
+                            list.forEach( (s: any,idx: number) => {
                                 let xpath = s.xpath();
                                 this.selectorModels.tag[idx] = xpath.match(/tag='(\d+)'/)[1];
                                 this.selectorModels.subfields[idx] = '';
@@ -126,9 +122,7 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
                     this.pcrud.search('uvs',{
                         owning_lib: this.sessionOwningLibrary,
                         name: this.sessionName},{})
-                    .subscribe(
-                        result => { this.nameCollision = true; }
-                    )
+                    .subscribe( () => { this.nameCollision = true; })
                 );
             })
         );
@@ -145,6 +139,9 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
         // [applyOrgId]="sessionOwningLibrary" is working fine
     }
 
+    applySessionSearch(p: any) {
+    }
+
     applySearchScope(p: any) {
         // [applyOrgId]="sessionSearchScope" was not working fine.
         // This also preserves null's, which is important since we'll
@@ -159,7 +156,6 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
             if (! this.sessionSearch.match(/site\(.+?\)/)) {
                 this.sessionSearch += ' site(' + p.shortname() + ')'
             }
-            this.applySessionSearch( this.sessionSearch );
         }
     }
 
@@ -171,9 +167,6 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
         }
     }
 
-    applySessionSearch(p: any) {
-    }
-
     // https://stackoverflow.com/questions/42322968/angular2-dynamic-input-field-lose-focus-when-input-changes
     trackByIdx(index: any, item: any) {
        return index;
@@ -205,7 +198,7 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
         this.progress.open();
     }
 
-    createNewSession(options) {
+    createNewSession(options: any) {
         ///////////////////////////////////////////////
         this.startProgressMeter($localize`Creating session...`);
         this.subscriptions.push(this.net.request(
@@ -215,8 +208,8 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
             this.sessionName,
             this.sessionSearch,
             this.sessionOwningLibrary
-        ).subscribe(
-            (res) => {
+        ).subscribe({
+            next: (res) => {
                 if (this.evt.parse(res)) {
                     console.error('session.create ils_event',res);
                     this.fail.open();
@@ -228,8 +221,8 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
                     /////////////////////////////////////////////////////
                     this.resetProgressMeter($localize`Creating URL selectors...`);
                     this.subscriptions.push(
-                        this.createUrlSelectors().subscribe(
-                            (res2) => {
+                        this.createUrlSelectors().subscribe({
+                            next: (res2) => {
                                 if (this.evt.parse(res2)) {
                                     console.error('url_selector.create error',res2);
                                     this.fail.open();
@@ -239,13 +232,13 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
                                     console.log('url_selector',res2);
                                 }
                             },
-                            (err2) => {
+                            error: (err2) => {
                                 console.error('url_selector.create error',err2);
                                 this.fail.open();
                                 this.stopProgressMeter();
                                 this.close(false);
                             },
-                            () => {
+                            complete: () => {
                                 ////////////////////////////////////////////////////////////
                                 this.resetProgressMeter($localize`Searching and extracting URLs...`);
                                 this.subscriptions.push(this.net.request(
@@ -253,8 +246,8 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
                                     'open-ils.url_verify.session.search_and_extract',
                                     this.auth.token(),
                                     this.sessionId
-                                ).subscribe(
-                                    (res3) => {
+                                ).subscribe({
+                                    next: (res3) => {
                                         console.log('res3',res3);
                                         if (!this.progress.hasMax()) {
                                             // first response returned by the API is the number of search results
@@ -265,12 +258,12 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
                                             this.progress.increment();
                                         }
                                     },
-                                    (err3) => {
+                                    error: (err3) => {
                                         console.log('err3',err3);
                                         this.stopProgressMeter();
                                         this.close(false);
                                     },
-                                    () => {
+                                    complete: () => {
                                         if (options['fullAuto']) {
                                             options['viewURLs'] = false;
                                             options['viewAttempts'] = true;
@@ -281,41 +274,42 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
                                                 'open-ils.url_verify.session.verify',
                                                 this.auth.token(),
                                                 this.sessionId
-                                            ).subscribe(
-                                                (res4) => {
+                                            ).subscribe({
+                                                next: (res4) => {
                                                     console.log('res4',res4);
                                                     this.progress.update({max: res4['url_count'], value: res4['total_processed']});
                                                 },
-                                                (err4) => {
+                                                error: (err4) => {
                                                     this.stopProgressMeter();
                                                     console.log('err4',err4);
                                                     this.close(false);
                                                 },
-                                                () => {
+                                                complete: () => {
                                                     this.nameCollision = true;
                                                     this.stopProgressMeter();
                                                     this.close(options);
                                                 }
-                                            ));
+                                            }));
                                         } else {
                                             this.nameCollision = true;
                                             this.stopProgressMeter();
                                             this.close(options);
                                         }
                                     }
-                                ));
+                                }));
                             }
-                        )
+                        })
                     );
                 }
             },
-            (err) => {
+            error: (err) => {
                 console.error('session.create error',err);
                 this.fail.open();
                 this.stopProgressMeter();
                 this.close(false);
-            }
-        ));
+            },
+            complete: () => {}
+        }));
     }
 
     createUrlSelectors(): Observable<any> {
@@ -328,7 +322,7 @@ export class NewSessionDialogComponent extends DialogComponent implements OnInit
         for (var i = 0; i < this.selectorModels['tag'].length; i++) {
             let tag = this.selectorModels['tag'][i];
             let subfields = this.selectorModels['subfields'][i];
-            let xpath = "//*[@tag='" + tag + "']/*[" + subfields.split('').map( e => "@code='" + e + "'" ).join(' or ') + ']';
+            let xpath = "//*[@tag='" + tag + "']/*[" + subfields.split('').map( (e: string) => "@code='" + e + "'" ).join(' or ') + ']';
             xpaths.push(xpath);
         }
         xpaths = Array.from( new Set( xpaths ) ); // dedupe
index 6551f5c..ece8896 100644 (file)
@@ -1,7 +1,7 @@
 <!-- how should we do i18n with eg-staff-banner? -->
 <div class="lead alert alert-primary text-center pt-1 pb-1">
    <span class="align-middle">
-    {sessions, plural, =0 {URLs for All Sessions} =1 {URLs for Session ID {{sessions}}} other {URLs for Session IDs {{sessions}}}}
+    {session_names, plural, =0 {URLs for All Sessions} =1 {URLs for Session: {{session_names.join(', ')}}} other {URLs for Sessions: {{session_names.join(', ')}}}}
    </span>
 </div>
 
index 0126d23..c3d9f66 100644 (file)
@@ -1,33 +1,14 @@
-import * as Moment from 'moment-timezone';
 import {Router, ActivatedRoute} from '@angular/router';
 import {AuthService} from '@eg/core/auth.service';
-import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
-import {Component, OnInit, ViewChild, Input, TemplateRef} from '@angular/core';
-import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
-import {DateSelectComponent} from '@eg/share/date-select/date-select.component';
-import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
-import {FormGroup, FormControl} from '@angular/forms';
-import {FormatService} from '@eg/core/format.service';
+import {Component, ChangeDetectorRef, OnInit, ViewChild} from '@angular/core';
 import {GridComponent} from '@eg/share/grid/grid.component';
-import {GridDataSource, GridColumn, GridRowFlairEntry, GridCellTextGenerator} from '@eg/share/grid/grid';
+import {GridDataSource} from '@eg/share/grid/grid';
 import {GridFlatDataService} from '@eg/share/grid/grid-flat-data.service';
-import {HtmlToTxtService} from '@eg/share/util/htmltotxt.service';
-import {IdlService, IdlObject} from '@eg/core/idl.service';
+import {IdlService} from '@eg/core/idl.service';
 import {NetService} from '@eg/core/net.service';
-import {NgbDate} from '@ng-bootstrap/ng-bootstrap';
-import {OrgFamily} from '@eg/share/org-family-select/org-family-select.component';
-import {OrgService} from '@eg/core/org.service';
 import {Pager} from '@eg/share/util/pager';
 import {PcrudService} from '@eg/core/pcrud.service';
-import {PermService} from '@eg/core/perm.service';
-import {PrintService} from '@eg/share/print/print.service';
 import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
-import {SampleDataService} from '@eg/share/util/sample-data.service';
-import {StringComponent} from '@eg/share/string/string.component';
-import {StringService} from '@eg/share/string/string.service';
-import {ToastService} from '@eg/share/toast/toast.service';
-import {map, take} from 'rxjs/operators';
-import {timer as observableTimer, Observable, of} from 'rxjs';
 
 @Component({
   templateUrl: 'urls.component.html'
@@ -35,6 +16,8 @@ import {timer as observableTimer, Observable, of} from 'rxjs';
 export class LinkCheckerUrlsComponent implements OnInit {
 
     sessions: number[];
+    session_names: string[] = [];
+    sessionIdlClass = 'uvs';
     newBatches: number[] = [];
     urlsIdlClass = 'uvu';
     urlsSortField = 'name';
@@ -62,14 +45,12 @@ export class LinkCheckerUrlsComponent implements OnInit {
     constructor(
         private auth: AuthService,
         private flatData: GridFlatDataService,
-        private format: FormatService,
         private idl: IdlService,
         private net: NetService,
-        private org: OrgService,
         private pcrud: PcrudService,
-        private perm: PermService,
         private route: ActivatedRoute,
         private router: Router,
+        private cdr: ChangeDetectorRef,
     ) {}
 
     ngOnInit() {
@@ -77,6 +58,10 @@ export class LinkCheckerUrlsComponent implements OnInit {
             if (params.sessions) {
                 this.sessions = JSON.parse( params.sessions );
                 this.grid.reload();
+                this.pcrud.search(this.sessionIdlClass, { id: this.sessions }).subscribe((n) => {
+                    this.session_names.push(n.name());
+                    this.cdr.detectChanges();
+                });
             }
         });
 
@@ -90,12 +75,13 @@ export class LinkCheckerUrlsComponent implements OnInit {
 
         this.initDataSource();
         this.gridSelectionChange( [] );
+        //console.log('phasefx',this);
     }
 
     gridSelectionChange(keys: string[]) {
         this.noSelectedRows = (keys.length === 0);
         this.oneSelectedRow = (keys.length === 1);
-        var rows = this.grid.context.getSelectedRows();
+        //var rows = this.grid.context.getSelectedRows();
     }
 
     initDataSource() {
@@ -137,7 +123,7 @@ export class LinkCheckerUrlsComponent implements OnInit {
         this.progress.open();
     }
 
-    verifyUrlsFilteredForSession(rows,ses_ids) {
+    verifyUrlsFilteredForSession(rows: any[], ses_ids: any[]) {
         var ses_id = ses_ids.pop();
         if (ses_id) {
             this.resetProgressMeter($localize`Verifying selected URLs for Session ${ses_id}...`);
@@ -148,22 +134,22 @@ export class LinkCheckerUrlsComponent implements OnInit {
                 this.auth.token(),
                 ses_id,
                 rows.filter( url => url.session === ses_id ).map( url => url.id )
-            ).subscribe(
-                (res) => {
+            ).subscribe({
+                next: (res) => {
                     console.log('res',res);
                     this.progress.update({max: res['url_count'], value: res['total_processed']});
                     if (res['attempt']) { // last response
                         this.newBatches.push(res.attempt.id());
                     }
                 },
-                (err) => {
+                error: (err) => {
                     this.stopProgressMeter();
                     console.log('err',err);
                 },
-                () => {
+                complete: () => {
                     this.verifyUrlsFilteredForSession(rows,ses_ids);
                 }
-            );
+            });
         } else {
             console.log('go to attempts page');
             this.stopProgressMeter();