]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Use ng-bootstrap for Typeahead 35300/head
authorTiago Melo <tmelo@suse.com>
Thu, 28 May 2020 20:18:55 +0000 (20:18 +0000)
committerTiago Melo <tmelo@suse.com>
Fri, 29 May 2020 14:25:45 +0000 (14:25 +0000)
Removed semicolon tslint rule, since it was conflicting with prettier.

Fixes: https://tracker.ceph.com/issues/45756
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/package-lock.json
src/pybind/mgr/dashboard/frontend/package.json
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/cluster.module.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-matcher-modal/silence-matcher-modal.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-matcher-modal/silence-matcher-modal.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-matcher-modal/silence-matcher-modal.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs.module.ts
src/pybind/mgr/dashboard/frontend/tslint.json

index 16e7f4d296c81eaa81048ac97ae99554ee7f1026..57b383da505e6dcc12ada0891791f652249e0c2e 100644 (file)
         "glob-to-regexp": "^0.3.0"
       }
     },
+    "@ng-bootstrap/ng-bootstrap": {
+      "version": "6.1.0",
+      "resolved": "https://registry.npmjs.org/@ng-bootstrap/ng-bootstrap/-/ng-bootstrap-6.1.0.tgz",
+      "integrity": "sha512-2GzkNJBKdeHkaUqaCAqSILPft0IzzHjMfAlAuGY6/ZLlVQ0glt5MTbIXtIhSbjR+OvlrljoXFLrvzs1LGdmE+A=="
+    },
     "@ngtools/webpack": {
       "version": "9.1.5",
       "resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-9.1.5.tgz",
       "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
       "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
     },
-    "fsevents": {
-      "dev": true,
-      "optional": true,
-      "version": "2.1.2"
-    },
     "function-bind": {
       "version": "1.1.1",
       "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
index 432905b5c9e0adcabcab54f18e0b0687a6e5ae3d..3e30c38c170ff85b969864e4a00b04d1f9baf316 100644 (file)
@@ -75,6 +75,7 @@
     "@angular/platform-browser-dynamic": "9.1.6",
     "@angular/router": "9.1.6",
     "@auth0/angular-jwt": "2.1.1",
+    "@ng-bootstrap/ng-bootstrap": "6.1.0",
     "@ngx-translate/i18n-polyfill": "1.0.0",
     "@swimlane/ngx-datatable": "17.0.0",
     "@types/file-saver": "2.0.1",
index 5eb59c9e7f54e8f83e533fed6bcc97a95d12bfb2..3bc76953b81c141ed0de4be9530055f93d233b7b 100644 (file)
@@ -3,6 +3,7 @@ import { NgModule } from '@angular/core';
 import { FormsModule, ReactiveFormsModule } from '@angular/forms';
 import { RouterModule } from '@angular/router';
 
+import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
 import { TreeModule } from 'angular-tree-component';
 import { NgBootstrapFormValidationModule } from 'ng-bootstrap-form-validation';
 import { AlertModule } from 'ngx-bootstrap/alert';
@@ -12,7 +13,6 @@ import { ModalModule } from 'ngx-bootstrap/modal';
 import { TabsModule } from 'ngx-bootstrap/tabs';
 import { TimepickerModule } from 'ngx-bootstrap/timepicker';
 import { TooltipModule } from 'ngx-bootstrap/tooltip';
-import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
 
 import { OrchestratorDocModalComponent } from '../../shared/components/orchestrator-doc-modal/orchestrator-doc-modal.component';
 import { SharedModule } from '../../shared/shared.module';
@@ -81,7 +81,7 @@ import { TelemetryComponent } from './telemetry/telemetry.component';
     AlertModule.forRoot(),
     TooltipModule.forRoot(),
     MgrModulesModule,
-    TypeaheadModule.forRoot(),
+    NgbTypeaheadModule,
     TimepickerModule.forRoot(),
     TreeModule.forRoot(),
     BsDatepickerModule.forRoot(),
index e6e4764b73ff8f1ed86263ccd6787e84b7666d0b..9285f3ff2b1d3b44cdbd89bdea54beac1e0c7e1b 100644 (file)
@@ -40,8 +40,7 @@
             <input id="value"
                    class="form-control"
                    type="text"
-                   [typeahead]="possibleValues"
-                   [typeaheadMinLength]="0"
+                   [ngbTypeahead]="search"
                    formControlName="value">
             <span *ngIf="form.showError('value', formDir, 'required')"
                   class="help-block"
index d7d9a86ab7bb4762bef1f58dff3fc34348335de6..112626ff6e928788889cadba18ed1089b3f08699 100644 (file)
@@ -3,8 +3,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
 import { ReactiveFormsModule } from '@angular/forms';
 import { RouterTestingModule } from '@angular/router/testing';
 
+import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
 import { BsModalRef } from 'ngx-bootstrap/modal';
-import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
 
 import {
   configureTestBed,
@@ -29,7 +29,7 @@ describe('SilenceMatcherModalComponent', () => {
     imports: [
       HttpClientTestingModule,
       SharedModule,
-      TypeaheadModule.forRoot(),
+      NgbTypeaheadModule,
       RouterTestingModule,
       ReactiveFormsModule
     ],
index 139a3ee23a87dd0648d99423bfe72cf63c240968..9621b4acaa67cb09c57171e85d21c5a8774f312e 100644 (file)
@@ -3,6 +3,8 @@ import { FormControl, Validators } from '@angular/forms';
 
 import * as _ from 'lodash';
 import { BsModalRef } from 'ngx-bootstrap/modal';
+import { Observable } from 'rxjs';
+import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators';
 
 import { CdFormBuilder } from '../../../../shared/forms/cd-form-builder';
 import { CdFormGroup } from '../../../../shared/forms/cd-form-group';
@@ -76,4 +78,16 @@ export class SilenceMatcherModalComponent {
     this.submitAction.emit(this.form.value);
     this.bsModalRef.hide();
   }
+
+  search = (text$: Observable<string>) => {
+    return text$.pipe(
+      debounceTime(200),
+      distinctUntilChanged(),
+      map((term) =>
+        this.possibleValues
+          .filter((v) => v.toLowerCase().indexOf(term.toLowerCase()) > -1)
+          .slice(0, 10)
+      )
+    );
+  };
 }
index f351ea9f059c2c27642a11e492f39c1cb4731af1..df48700c607acac942cd5a596898f2e53140c8d0 100644 (file)
                    name="path"
                    id="path"
                    formControlName="path"
-                   [typeahead]="pathDataSource"
-                   (typeaheadOnSelect)="pathChangeHandler()"
+                   [ngbTypeahead]="pathDataSource"
+                   (selectItem)="pathChangeHandler()"
                    (blur)="pathChangeHandler()">
             <span class="invalid-feedback"
                   *ngIf="nfsForm.showError('path', formDir, 'required')"
                    name="path"
                    id="path"
                    formControlName="path"
-                   [typeahead]="bucketDataSource"
-                   (typeaheadOnSelect)="bucketChangeHandler()"
+                   [ngbTypeahead]="bucketDataSource"
+                   (selectItem)="bucketChangeHandler()"
                    (blur)="bucketChangeHandler()">
 
             <span class="invalid-feedback"
index bb20702800b17e8dddb27c92d8c8652ce2ffacd6..e623f8b94dc5f2723e99fe6748de20cd96bcf0b7 100644 (file)
@@ -4,7 +4,7 @@ import { ReactiveFormsModule } from '@angular/forms';
 import { ActivatedRoute } from '@angular/router';
 import { RouterTestingModule } from '@angular/router/testing';
 
-import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
+import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
 import { ToastrModule } from 'ngx-toastr';
 
 import { ActivatedRouteStub } from '../../../../testing/activated-route-stub';
@@ -29,7 +29,7 @@ describe('NfsFormComponent', () => {
       RouterTestingModule,
       SharedModule,
       ToastrModule.forRoot(),
-      TypeaheadModule.forRoot()
+      NgbTypeaheadModule
     ],
     providers: [
       {
index 0df8b002be6c776a3217339c1f75aadaccef3741..4cf1c39adbce27cc65680bf324e684e94db24790 100644 (file)
@@ -5,7 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router';
 import { I18n } from '@ngx-translate/i18n-polyfill';
 import * as _ from 'lodash';
 import { forkJoin, Observable, of } from 'rxjs';
-import { map, mergeMap } from 'rxjs/operators';
+import { debounceTime, distinctUntilChanged, map, mergeMap } from 'rxjs/operators';
 
 import { NfsService } from '../../../shared/api/nfs.service';
 import { RgwUserService } from '../../../shared/api/rgw-user.service';
@@ -68,16 +68,22 @@ export class NfsFormComponent extends CdForm implements OnInit {
     this.i18n
   );
 
-  pathDataSource: Observable<any> = Observable.create((observer: any) => {
-    observer.next(this.nfsForm.getValue('path'));
-  }).pipe(
-    mergeMap((token: string) => this.getPathTypeahead(token)),
-    map((val: any) => val.paths)
-  );
+  pathDataSource = (text$: Observable<string>) => {
+    return text$.pipe(
+      debounceTime(200),
+      distinctUntilChanged(),
+      mergeMap((token: string) => this.getPathTypeahead(token)),
+      map((val: any) => val.paths)
+    );
+  };
 
-  bucketDataSource: Observable<any> = Observable.create((observer: any) => {
-    observer.next(this.nfsForm.getValue('path'));
-  }).pipe(mergeMap((token: string) => this.getBucketTypeahead(token)));
+  bucketDataSource = (text$: Observable<string>) => {
+    return text$.pipe(
+      debounceTime(200),
+      distinctUntilChanged(),
+      mergeMap((token: string) => this.getBucketTypeahead(token))
+    );
+  };
 
   constructor(
     private authStorageService: AuthStorageService,
index 79d6562641a6ccea50645113e9ead56b265a6732..ac66522bb447dd5d4bfefa5475e409dc0ef8d792 100644 (file)
@@ -3,9 +3,9 @@ import { NgModule } from '@angular/core';
 import { ReactiveFormsModule } from '@angular/forms';
 import { RouterModule } from '@angular/router';
 
+import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
 import { NgBootstrapFormValidationModule } from 'ng-bootstrap-form-validation';
 import { TabsModule } from 'ngx-bootstrap/tabs';
-import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
 
 import { SharedModule } from '../../shared/shared.module';
 import { Nfs501Component } from './nfs-501/nfs-501.component';
@@ -21,7 +21,7 @@ import { NfsListComponent } from './nfs-list/nfs-list.component';
     SharedModule,
     TabsModule.forRoot(),
     CommonModule,
-    TypeaheadModule.forRoot(),
+    NgbTypeaheadModule,
     NgBootstrapFormValidationModule
   ],
   declarations: [
index f3e62b3a92e3af4ea6d9064ba20f67fee5bac94d..cc3f6582c779e42327edc294226858c3ea0728c5 100644 (file)
@@ -47,7 +47,6 @@
     "prefer-const": true,
     "quotemark": [true, "single", "avoid-escape"],
     "radix": true,
-    "semicolon": [true, "always"],
     "triple-equals": [true, "allow-null-check"],
     "typedef-whitespace": [
       true,