From: Tiago Melo Date: Mon, 30 Dec 2019 13:13:59 +0000 (-0100) Subject: mgr/dashboard: Enable noImplicitAny TS compiler option X-Git-Tag: v15.1.1~573^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0cb288e09c6d1b3d9b77ae1cb9bb24106bbf56cd;p=ceph.git mgr/dashboard: Enable noImplicitAny TS compiler option Fixes: https://tracker.ceph.com/issues/43525 Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts index 1390ae6d41e1f..85ed005cb9135 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts @@ -9,7 +9,7 @@ export class ImagesPageHelper extends PageHelper { // Creates a block image and fills in the name, pool, and size fields. Then checks // if the image is present in the Images table. - async createImage(name, pool, size) { + async createImage(name: string, pool: string, size: string) { await this.navigateTo('create'); // Need the string '[value=""]' to find the pool in the dropdown menu @@ -31,7 +31,7 @@ export class ImagesPageHelper extends PageHelper { return this.waitPresence(this.getFirstTableCellWithText(name)); } - async editImage(name, pool, newName, newSize) { + async editImage(name: string, pool: string, newName: string, newSize: string) { const base_url = '/#/block/rbd/edit/'; const editURL = base_url .concat(encodeURIComponent(pool)) @@ -59,7 +59,7 @@ export class ImagesPageHelper extends PageHelper { // Selects RBD image and moves it to the trash, checks that it is present in the // trash table - async moveToTrash(name) { + async moveToTrash(name: string) { await this.navigateTo(); // wait for image to be created await this.waitTextNotPresent($$('.datatable-body').first(), '(Creating...)'); @@ -79,7 +79,7 @@ export class ImagesPageHelper extends PageHelper { // Checks trash tab table for image and then restores it to the RBD Images table // (could change name if new name is given) - async restoreImage(name, newName?: string) { + async restoreImage(name: string, newName?: string) { await this.navigateTo(); // clicks on trash tab await element(by.cssContainingText('.nav-link', 'Trash')).click(); @@ -104,7 +104,7 @@ export class ImagesPageHelper extends PageHelper { // Enters trash tab and purges trash, thus emptying the trash table. Checks if // Image is still in the table. - async purgeTrash(name, pool?: string) { + async purgeTrash(name: string, pool?: string) { await this.navigateTo(); // clicks trash tab await element(by.cssContainingText('.nav-link', 'Trash')).click(); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts index 22de6dcb8864d..d27a1dc6e3afe 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts @@ -11,7 +11,7 @@ export class MirroringPageHelper extends PageHelper { * pool and chooses an option (either pool, image, or disabled) */ @PageHelper.restrictTo(pages.index) - async editMirror(name, option) { + async editMirror(name: string, option: string) { // Clicks the pool in the table await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.po.ts index c92dbfcaae320..2354f07bffa07 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.po.ts @@ -6,7 +6,7 @@ export class ConfigurationPageHelper extends PageHelper { index: '/#/configuration' }; - async configClear(name) { + async configClear(name: string) { // Clears out all the values in a config to reset before and after testing // Does not work for configs with checkbox only, possible future PR @@ -45,7 +45,7 @@ export class ConfigurationPageHelper extends PageHelper { } } - async edit(name, ...values: [string, string][]) { + async edit(name: string, ...values: [string, string][]) { // Clicks the designated config, then inputs the values passed into the edit function. // Then checks if the edit is reflected in the config table. Takes in name of config and // a list of tuples of values the user wants edited, each tuple having the desired value along diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.po.ts index 279fd85621e2b..20790fa3fe602 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.po.ts @@ -8,7 +8,7 @@ export class CrushMapPageHelper extends PageHelper { return $('cd-crushmap .card-header').getText(); } - getCrushNode(idx) { + getCrushNode(idx: number) { return $$('.node-name.type-osd').get(idx); } } diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/logs.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/logs.po.ts index e25e76644baa9..5fd18abd8dea5 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/logs.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/logs.po.ts @@ -4,7 +4,12 @@ import { PageHelper } from '../page-helper.po'; export class LogsPageHelper extends PageHelper { pages = { index: '/#/logs' }; - async checkAuditForPoolFunction(poolname, poolfunction, hour, minute) { + async checkAuditForPoolFunction( + poolname: string, + poolfunction: string, + hour: number, + minute: number + ) { await this.navigateTo(); // sometimes the modal from deleting pool is still present at this point. @@ -64,7 +69,12 @@ export class LogsPageHelper extends PageHelper { await expect(logs.getText()).toMatch(`pool ${poolfunction}`); } - async checkAuditForConfigChange(configname, setting, hour, minute) { + async checkAuditForConfigChange( + configname: string, + setting: string, + hour: number, + minute: number + ) { await this.navigateTo(); // go to audit logs tab diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/mgr-modules.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/mgr-modules.po.ts index f9ff2690fa5ec..9d001db5748e0 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/mgr-modules.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/mgr-modules.po.ts @@ -92,7 +92,7 @@ export class ManagerModulesPageHelper extends PageHelper { await this.waitVisibility(this.getFirstTableCellWithText('devicehealth')); // Checks for visibility of devicehealth in table await this.getFirstTableCellWithText('devicehealth').click(); - for (let i = 0, devHealthTuple; (devHealthTuple = devHealthArray[i]); i++) { + for (let i = 0, devHealthTuple: [string, string]; (devHealthTuple = devHealthArray[i]); i++) { if (devHealthTuple[0] !== undefined) { await this.waitFn(async () => { // Repeatedly reclicks the module to check if edits has been done @@ -132,7 +132,7 @@ export class ManagerModulesPageHelper extends PageHelper { await this.navigateTo(); await this.waitVisibility(this.getFirstTableCellWithText('devicehealth')); await this.getFirstTableCellWithText('devicehealth').click(); - for (let i = 0, devHealthTuple; (devHealthTuple = devHealthArray[i]); i++) { + for (let i = 0, devHealthTuple: [string, string]; (devHealthTuple = devHealthArray[i]); i++) { if (devHealthTuple[0] !== undefined) { await this.waitFn(async () => { // Repeatedly reclicks the module to check if clearing has been done diff --git a/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts index 45bbd7e6edef2..5f6204d415be1 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts @@ -45,10 +45,10 @@ export abstract class PageHelper { * help developers to prevent and highlight mistakes. It also reduces boilerplate code and by * thus, increases readability. */ - static restrictTo(page): Function { + static restrictTo(page: string): Function { return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => { const fn: Function = descriptor.value; - descriptor.value = function(...args) { + descriptor.value = function(...args: any) { return browser .getCurrentUrl() .then((url) => @@ -70,7 +70,7 @@ export abstract class PageHelper { return $('.breadcrumb-item.active'); } - async getTabText(index): Promise { + async getTabText(index: number): Promise { return $$('.nav.nav-tabs li') .get(index) .getText(); @@ -96,7 +96,7 @@ export abstract class PageHelper { return element.all(by.cssContainingText('.datatable-body-cell-label', content)).first(); } - getTableRow(content) { + getTableRow(content: string) { return element(by.cssContainingText('.datatable-body-row', content)); } @@ -206,7 +206,7 @@ export abstract class PageHelper { } } - async navigateTo(page = null) { + async navigateTo(page: string = null) { page = page || 'index'; const url = this.pages[page]; await browser.get(url); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.po.ts index 13be04baefcb5..430fe850b9719 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.po.ts @@ -177,7 +177,7 @@ export class BucketsPageHelper extends PageHelper { return element(by.cssContainingText('button', 'Cancel')).click(); } - async testInvalidEdit(name) { + async testInvalidEdit(name: string) { await this.navigateTo(); await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); // wait for table to load and click diff --git a/src/pybind/mgr/dashboard/frontend/e2e/rgw/users.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/rgw/users.po.ts index b742aa84a0eb2..96f9c537a2fe5 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/rgw/users.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/rgw/users.po.ts @@ -11,7 +11,7 @@ export class UsersPageHelper extends PageHelper { pages = pages; @PageHelper.restrictTo(pages.create) - async create(username, fullname, email, maxbuckets) { + async create(username: string, fullname: string, email: string, maxbuckets: string) { // Enter in username await element(by.id('uid')).sendKeys(username); @@ -34,7 +34,7 @@ export class UsersPageHelper extends PageHelper { } @PageHelper.restrictTo(pages.index) - async edit(name, new_fullname, new_email, new_maxbuckets) { + async edit(name: string, new_fullname: string, new_email: string, new_maxbuckets: string) { await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); // wait for table to load and click await element(by.cssContainingText('button', 'Edit')).click(); // click button to move to edit page diff --git a/src/pybind/mgr/dashboard/frontend/e2e/ui/role-mgmt.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/ui/role-mgmt.po.ts index 552285af8dbe2..dbec067ed0a7f 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/ui/role-mgmt.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/ui/role-mgmt.po.ts @@ -7,7 +7,7 @@ export class RoleMgmtPageHelper extends PageHelper { create: '/#/user-management/roles/create' }; - async create(name, description): Promise { + async create(name: string, description: string): Promise { await this.navigateTo('create'); // fill in fields @@ -21,7 +21,7 @@ export class RoleMgmtPageHelper extends PageHelper { await this.waitPresence(this.getFirstTableCellWithText(name)); } - async edit(name, description): Promise { + async edit(name: string, description: string): Promise { await this.navigateTo(); await this.getFirstTableCellWithText(name).click(); // select role from table diff --git a/src/pybind/mgr/dashboard/frontend/e2e/ui/user-mgmt.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/ui/user-mgmt.po.ts index 2c38bf16d048c..d59eddb39af96 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/ui/user-mgmt.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/ui/user-mgmt.po.ts @@ -7,7 +7,7 @@ export class UserMgmtPageHelper extends PageHelper { create: '/#/user-management/users/create' }; - async create(username, password, name, email): Promise { + async create(username: string, password: string, name: string, email: string): Promise { await this.navigateTo('create'); // fill in fields @@ -23,7 +23,7 @@ export class UserMgmtPageHelper extends PageHelper { await this.waitPresence(this.getFirstTableCellWithText(username)); } - async edit(username, password, name, email): Promise { + async edit(username: string, password: string, name: string, email: string): Promise { await this.navigateTo(); await this.getFirstTableCellWithText(username).click(); // select user from table diff --git a/src/pybind/mgr/dashboard/frontend/package-lock.json b/src/pybind/mgr/dashboard/frontend/package-lock.json index 9c12cbe4dd544..2e9506f0d58e5 100644 --- a/src/pybind/mgr/dashboard/frontend/package-lock.json +++ b/src/pybind/mgr/dashboard/frontend/package-lock.json @@ -2859,6 +2859,11 @@ "integrity": "sha512-lMC2G0ItF2xv4UCiwbJGbnJlIuUixHrioOhNGHSCsYCJ8l4t9hMCUimCytvFv7qy6AfSzRxhRHoGa+UqaqwyeA==", "dev": true }, + "@types/simplebar": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/@types/simplebar/-/simplebar-2.4.2.tgz", + "integrity": "sha512-omSnWgcQ5hGANK8MijABHDNtj7bM2GH80g8wVqeRmaePJ2lPN4RmbrVihEbYtnovW2aS51a0joITsb6+Q1HnnA==" + }, "@types/source-list-map": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz", diff --git a/src/pybind/mgr/dashboard/frontend/package.json b/src/pybind/mgr/dashboard/frontend/package.json index 96f6be8c2250f..1d77fef928af1 100644 --- a/src/pybind/mgr/dashboard/frontend/package.json +++ b/src/pybind/mgr/dashboard/frontend/package.json @@ -123,6 +123,7 @@ "@types/jest": "24.0.23", "@types/lodash": "4.14.141", "@types/node": "12.7.8", + "@types/simplebar": "2.4.2", "codelyzer": "5.1.2", "html-linter": "1.1.1", "htmllint-cli": "0.0.7", diff --git a/src/pybind/mgr/dashboard/frontend/src/app/app.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/app.module.ts index a2bed3306e93c..3152a1233e3ef 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/app.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/app.module.ts @@ -72,7 +72,7 @@ export function jwtTokenGetter() { }, { provide: TRANSLATIONS, - useFactory: (locale) => { + useFactory: (locale: string) => { locale = locale || environment.default_lang; try { return require(`raw-loader!locale/messages.${locale}.xlf`).default; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-tabs/iscsi-tabs.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-tabs/iscsi-tabs.component.ts index b5dc3cff36495..06835d3c8278c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-tabs/iscsi-tabs.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-tabs/iscsi-tabs.component.ts @@ -16,7 +16,7 @@ export class IscsiTabsComponent implements OnInit { this.url = this.router.url; } - navigateTo(url) { + navigateTo(url: string) { this.router.navigate([url]); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts index d1504afb916b4..929340a15b6ec 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts @@ -115,7 +115,7 @@ export class IscsiTargetDetailsComponent implements OnChanges, OnInit { } }; - const disks = []; + const disks: any[] = []; _.forEach(this.selectedItem.disks, (disk) => { const id = 'disk_' + disk.pool + '_' + disk.image; this.metadata[id] = { @@ -133,12 +133,12 @@ export class IscsiTargetDetailsComponent implements OnChanges, OnInit { }); }); - const portals = []; + const portals: any[] = []; _.forEach(this.selectedItem.portals, (portal) => { portals.push({ value: `${portal.host}:${portal.ip}` }); }); - const clients = []; + const clients: any[] = []; _.forEach(this.selectedItem.clients, (client) => { const client_metadata = _.cloneDeep(client.auth); if (client.info) { @@ -150,8 +150,8 @@ export class IscsiTargetDetailsComponent implements OnChanges, OnInit { } this.metadata['client_' + client.client_iqn] = client_metadata; - const luns = []; - client.luns.forEach((lun) => { + const luns: any[] = []; + client.luns.forEach((lun: Record) => { luns.push({ value: `${lun.pool}/${lun.image}`, id: 'disk_' + lun.pool + '_' + lun.image, @@ -173,18 +173,18 @@ export class IscsiTargetDetailsComponent implements OnChanges, OnInit { }); }); - const groups = []; + const groups: any[] = []; _.forEach(this.selectedItem.groups, (group) => { - const luns = []; - group.disks.forEach((disk) => { + const luns: any[] = []; + group.disks.forEach((disk: Record) => { luns.push({ value: `${disk.pool}/${disk.image}`, id: 'disk_' + disk.pool + '_' + disk.image }); }); - const initiators = []; - group.members.forEach((member) => { + const initiators: any[] = []; + group.members.forEach((member: string) => { initiators.push({ value: member, id: 'client_' + member @@ -258,7 +258,7 @@ export class IscsiTargetDetailsComponent implements OnChanges, OnInit { }; } - private format(value) { + private format(value: any) { if (typeof value === 'boolean') { return this.booleanTextPipe.transform(value); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-discovery-modal/iscsi-target-discovery-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-discovery-modal/iscsi-target-discovery-modal.component.spec.ts index f6236e707f070..ff683b9c87c8b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-discovery-modal/iscsi-target-discovery-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-discovery-modal/iscsi-target-discovery-modal.component.spec.ts @@ -22,8 +22,8 @@ describe('IscsiTargetDiscoveryModalComponent', () => { let httpTesting: HttpTestingController; let req: TestRequest; - const elem = (css) => fixture.debugElement.query(By.css(css)); - const elemDisabled = (css) => elem(css).nativeElement.disabled; + const elem = (css: string) => fixture.debugElement.query(By.css(css)); + const elemDisabled = (css: string) => elem(css).nativeElement.disabled; configureTestBed({ declarations: [IscsiTargetDiscoveryModalComponent], diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts index e95f5dc206555..47c61ad120ba1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts @@ -46,7 +46,7 @@ describe('IscsiTargetFormComponent', () => { api_version: 1 }; - const LIST_TARGET = [ + const LIST_TARGET: any[] = [ { target_iqn: 'iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw', portals: [{ host: 'node1', ip: '192.168.100.201' }], @@ -85,7 +85,7 @@ describe('IscsiTargetFormComponent', () => { ceph_iscsi_config_version: 11 }; - const RBD_LIST = [ + const RBD_LIST: any[] = [ { status: 0, value: [], pool_name: 'ganesha' }, { status: 0, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.ts index ea0eaf030ac0e..ca2168ddd01e1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.ts @@ -166,8 +166,8 @@ export class IscsiTargetFormComponent implements OnInit { // iscsiService.portals() const portals: SelectOption[] = []; - data[2].forEach((portal) => { - portal.ip_addresses.forEach((ip) => { + data[2].forEach((portal: Record) => { + portal.ip_addresses.forEach((ip: string) => { portals.push(new SelectOption(false, portal.name + ':' + ip, '')); }); }); @@ -193,7 +193,7 @@ export class IscsiTargetFormComponent implements OnInit { target_controls: new FormControl({}), portals: new FormControl([], { validators: [ - CdValidators.custom('minGateways', (value) => { + CdValidators.custom('minGateways', (value: any[]) => { const gateways = _.uniq(value.map((elem) => elem.split(':')[0])); return gateways.length < Math.max(1, this.minimum_gateways); }) @@ -201,11 +201,11 @@ export class IscsiTargetFormComponent implements OnInit { }), disks: new FormControl([], { validators: [ - CdValidators.custom('dupLunId', (value) => { + CdValidators.custom('dupLunId', (value: any[]) => { const lunIds = this.getLunIds(value); return lunIds.length !== _.uniq(lunIds).length; }), - CdValidators.custom('dupWwn', (value) => { + CdValidators.custom('dupWwn', (value: any[]) => { const wwns = this.getWwns(value); return wwns.length !== _.uniq(wwns).length; }) @@ -228,7 +228,7 @@ export class IscsiTargetFormComponent implements OnInit { } } - resolveModel(res) { + resolveModel(res: Record) { this.targetForm.patchValue({ target_iqn: res.target_iqn, target_controls: res.target_controls, @@ -240,7 +240,7 @@ export class IscsiTargetFormComponent implements OnInit { auth: res.auth }); } - const portals = []; + const portals: any[] = []; _.forEach(res.portals, (portal) => { const id = `${portal.host}:${portal.ip}`; portals.push(id); @@ -249,7 +249,7 @@ export class IscsiTargetFormComponent implements OnInit { portals: portals }); - const disks = []; + const disks: any[] = []; _.forEach(res.disks, (disk) => { const id = `${disk.pool}/${disk.image}`; disks.push(id); @@ -329,14 +329,14 @@ export class IscsiTargetFormComponent implements OnInit { return false; } - removeImageRefs(name) { + removeImageRefs(name: string) { this.initiators.controls.forEach((element) => { - const newImages = element.value.luns.filter((item) => item !== name); + const newImages = element.value.luns.filter((item: string) => item !== name); element.get('luns').setValue(newImages); }); this.groups.controls.forEach((element) => { - const newDisks = element.value.disks.filter((item) => item !== name); + const newDisks = element.value.disks.filter((item: string) => item !== name); element.get('disks').setValue(newDisks); }); @@ -348,7 +348,7 @@ export class IscsiTargetFormComponent implements OnInit { }); } - getDefaultBackstore(imageId) { + getDefaultBackstore(imageId: string) { let result = this.default_backstore; const image = this.getImageById(imageId); if (!this.validFeatures(image, this.default_backstore)) { @@ -363,17 +363,17 @@ export class IscsiTargetFormComponent implements OnInit { return result; } - isLunIdInUse(lunId, imageId) { - const images = this.disks.value.filter((currentImageId) => currentImageId !== imageId); + isLunIdInUse(lunId: string, imageId: string) { + const images = this.disks.value.filter((currentImageId: string) => currentImageId !== imageId); return this.getLunIds(images).includes(lunId); } - getLunIds(images) { + getLunIds(images: object) { return _.map(images, (image) => this.imagesSettings[image]['lun']); } - nextLunId(imageId) { - const images = this.disks.value.filter((currentImageId) => currentImageId !== imageId); + nextLunId(imageId: string) { + const images = this.disks.value.filter((currentImageId: string) => currentImageId !== imageId); const lunIdsInUse = this.getLunIds(images); let lunIdCandidate = 0; while (lunIdsInUse.includes(lunIdCandidate)) { @@ -382,12 +382,12 @@ export class IscsiTargetFormComponent implements OnInit { return lunIdCandidate; } - getWwns(images) { + getWwns(images: object) { const wwns = _.map(images, (image) => this.imagesSettings[image]['wwn']); return wwns.filter((wwn) => _.isString(wwn) && wwn !== ''); } - onImageSelection($event) { + onImageSelection($event: any) { const option = $event.option; if (option.selected) { @@ -428,7 +428,7 @@ export class IscsiTargetFormComponent implements OnInit { client_iqn: new FormControl('', { validators: [ Validators.required, - CdValidators.custom('notUnique', (client_iqn) => { + CdValidators.custom('notUnique', (client_iqn: string) => { const flattened = this.initiators.controls.reduce(function(accumulator, currentValue) { return accumulator.concat(currentValue.value.client_iqn); }, []); @@ -500,7 +500,7 @@ export class IscsiTargetFormComponent implements OnInit { ); } - removeInitiator(index) { + removeInitiator(index: number) { const removed = this.initiators.value[index]; this.initiators.removeAt(index); @@ -511,7 +511,9 @@ export class IscsiTargetFormComponent implements OnInit { }); this.groups.controls.forEach((element) => { - const newMembers = element.value.members.filter((item) => item !== removed.client_iqn); + const newMembers = element.value.members.filter( + (item: string) => item !== removed.client_iqn + ); element.get('members').setValue(newMembers); }); @@ -544,12 +546,12 @@ export class IscsiTargetFormComponent implements OnInit { }); } - removeInitiatorImage(initiator: any, lun_index: number, initiator_index: string, image: string) { + removeInitiatorImage(initiator: any, lun_index: number, initiator_index: number, image: string) { const luns = initiator.getValue('luns'); luns.splice(lun_index, 1); initiator.patchValue({ luns: luns }); - this.imagesInitiatorSelections[initiator_index].forEach((value) => { + this.imagesInitiatorSelections[initiator_index].forEach((value: Record) => { if (value.name === image) { value.selected = false; } @@ -587,12 +589,12 @@ export class IscsiTargetFormComponent implements OnInit { return fg; } - removeGroup(index) { + removeGroup(index: number) { this.groups.removeAt(index); this.groupDiskSelections.splice(index, 1); } - onGroupMemberSelection($event) { + onGroupMemberSelection($event: any) { const option = $event.option; let initiator_index: number; @@ -611,7 +613,7 @@ export class IscsiTargetFormComponent implements OnInit { }); } - removeGroupInitiator(group, member_index, group_index) { + removeGroupInitiator(group: CdFormGroup, member_index: number, group_index: number) { const name = group.getValue('members')[member_index]; group.getValue('members').splice(member_index, 1); @@ -625,7 +627,7 @@ export class IscsiTargetFormComponent implements OnInit { this.onGroupMemberSelection({ option: new SelectOption(false, name, '') }); } - removeGroupDisk(group, disk_index, group_index) { + removeGroupDisk(group: CdFormGroup, disk_index: number, group_index: number) { const name = group.getValue('disks')[disk_index]; group.getValue('disks').splice(disk_index, 1); @@ -640,7 +642,7 @@ export class IscsiTargetFormComponent implements OnInit { submit() { const formValue = _.cloneDeep(this.targetForm.value); - const request = { + const request: Record = { target_iqn: this.targetForm.getValue('target_iqn'), target_controls: this.targetForm.getValue('target_controls'), acl_enabled: this.targetForm.getValue('acl_enabled'), @@ -675,7 +677,7 @@ export class IscsiTargetFormComponent implements OnInit { } // Disks - formValue.disks.forEach((disk) => { + formValue.disks.forEach((disk: string) => { const imageSplit = disk.split('/'); const backstore = this.imagesSettings[disk].backstore; request.disks.push({ @@ -689,7 +691,7 @@ export class IscsiTargetFormComponent implements OnInit { }); // Portals - formValue.portals.forEach((portal) => { + formValue.portals.forEach((portal: string) => { const index = portal.indexOf(':'); request.portals.push({ host: portal.substring(0, index), @@ -699,7 +701,7 @@ export class IscsiTargetFormComponent implements OnInit { // Clients if (request.acl_enabled) { - formValue.initiators.forEach((initiator) => { + formValue.initiators.forEach((initiator: Record) => { if (!initiator.auth.user) { initiator.auth.user = ''; } @@ -714,8 +716,8 @@ export class IscsiTargetFormComponent implements OnInit { } delete initiator.cdIsInGroup; - const newLuns = []; - initiator.luns.forEach((lun) => { + const newLuns: any[] = []; + initiator.luns.forEach((lun: string) => { const imageSplit = lun.split('/'); newLuns.push({ pool: imageSplit[0], @@ -730,9 +732,9 @@ export class IscsiTargetFormComponent implements OnInit { // Groups if (request.acl_enabled) { - formValue.groups.forEach((group) => { - const newDisks = []; - group.disks.forEach((disk) => { + formValue.groups.forEach((group: Record) => { + const newDisks: any[] = []; + group.disks.forEach((disk: string) => { const imageSplit = disk.split('/'); newDisks.push({ pool: imageSplit[0], @@ -783,7 +785,7 @@ export class IscsiTargetFormComponent implements OnInit { this.modalRef = this.modalService.show(IscsiTargetIqnSettingsModalComponent, { initialState }); } - imageSettingsModal(image) { + imageSettingsModal(image: string) { const initialState = { imagesSettings: this.imagesSettings, image: image, @@ -799,7 +801,7 @@ export class IscsiTargetFormComponent implements OnInit { }); } - validFeatures(image, backstore) { + validFeatures(image: Record, backstore: string) { const imageFeatures = image.features; const requiredFeatures = this.required_rbd_features[backstore]; const unsupportedFeatures = this.unsupported_rbd_features[backstore]; @@ -810,11 +812,11 @@ export class IscsiTargetFormComponent implements OnInit { return validRequiredFeatures && validSupportedFeatures; } - getImageById(imageId) { + getImageById(imageId: string) { return this.imagesAll.find((image) => imageId === `${image.pool_name}/${image.name}`); } - getValidBackstores(image) { + getValidBackstores(image: object) { return this.backstores.filter((backstore) => this.validFeatures(image, backstore)); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-image-settings-modal/iscsi-target-image-settings-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-image-settings-modal/iscsi-target-image-settings-modal.component.ts index b8b527623fc1e..f238d3b4c698c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-image-settings-modal/iscsi-target-image-settings-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-image-settings-modal/iscsi-target-image-settings-modal.component.ts @@ -26,7 +26,7 @@ export class IscsiTargetImageSettingsModalComponent implements OnInit { constructor(public modalRef: BsModalRef, public iscsiService: IscsiService) {} ngOnInit() { - const fg = { + const fg: Record = { backstore: new FormControl(this.imagesSettings[this.image]['backstore']), lun: new FormControl(this.imagesSettings[this.image]['lun']), wwn: new FormControl(this.imagesSettings[this.image]['wwn']) @@ -41,7 +41,7 @@ export class IscsiTargetImageSettingsModalComponent implements OnInit { this.settingsForm = new CdFormGroup(fg); } - getDiskControlLimits(backstore, setting) { + getDiskControlLimits(backstore: string, setting: string) { if (this.disk_controls_limits) { return this.disk_controls_limits[backstore][setting]; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-iqn-settings-modal/iscsi-target-iqn-settings-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-iqn-settings-modal/iscsi-target-iqn-settings-modal.component.ts index 26e3cb0f3c9b9..8e92f707ce07f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-iqn-settings-modal/iscsi-target-iqn-settings-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-iqn-settings-modal/iscsi-target-iqn-settings-modal.component.ts @@ -22,7 +22,7 @@ export class IscsiTargetIqnSettingsModalComponent implements OnInit { constructor(public modalRef: BsModalRef, public iscsiService: IscsiService) {} ngOnInit() { - const fg = {}; + const fg: Record = {}; _.forIn(this.target_default_controls, (_value, key) => { fg[key] = new FormControl(this.target_controls.value[key]); }); @@ -42,7 +42,7 @@ export class IscsiTargetIqnSettingsModalComponent implements OnInit { this.modalRef.hide(); } - getTargetControlLimits(setting) { + getTargetControlLimits(setting: string) { if (this.target_controls_limits) { return this.target_controls_limits[setting]; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.spec.ts index 3c4a7227d481f..c1413f96a7ef2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.spec.ts @@ -29,7 +29,7 @@ describe('IscsiTargetListComponent', () => { let summaryService: SummaryService; let iscsiService: IscsiService; - const refresh = (data) => { + const refresh = (data: any) => { summaryService['summaryDataSource'].next(data); }; @@ -91,7 +91,7 @@ describe('IscsiTargetListComponent', () => { describe('handling of executing tasks', () => { let targets: any[]; - const addTarget = (name) => { + const addTarget = (name: string) => { const model: any = { target_iqn: name, portals: [{ host: 'node1', ip: '192.168.100.201' }], diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts index 12a8b3be7c55e..f3911d58a9dc8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts @@ -16,6 +16,7 @@ import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { FinishedTask } from '../../../shared/models/finished-task'; import { Permission } from '../../../shared/models/permissions'; +import { Task } from '../../../shared/models/task'; import { CephReleaseNamePipe } from '../../../shared/pipes/ceph-release-name.pipe'; import { NotAvailablePipe } from '../../../shared/pipes/not-available.pipe'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; @@ -45,11 +46,11 @@ export class IscsiTargetListComponent implements OnInit, OnDestroy { status: string; summaryDataSubscription: Subscription; tableActions: CdTableAction[]; - targets = []; + targets: any[] = []; icons = Icons; builders = { - 'iscsi/target/create': (metadata) => { + 'iscsi/target/create': (metadata: object) => { return { target_iqn: metadata['target_iqn'] }; @@ -185,9 +186,13 @@ export class IscsiTargetListComponent implements OnInit, OnDestroy { } prepareResponse(resp: any): any[] { - resp.forEach((element) => { - element.cdPortals = element.portals.map((portal) => `${portal.host}:${portal.ip}`); - element.cdImages = element.disks.map((disk) => `${disk.pool}/${disk.image}`); + resp.forEach((element: Record) => { + element.cdPortals = element.portals.map( + (portal: Record) => `${portal.host}:${portal.ip}` + ); + element.cdImages = element.disks.map( + (disk: Record) => `${disk.pool}/${disk.image}` + ); }); return resp; @@ -197,11 +202,11 @@ export class IscsiTargetListComponent implements OnInit, OnDestroy { this.table.reset(); // Disable loading indicator. } - itemFilter(entry, task) { + itemFilter(entry: Record, task: Task) { return entry.target_iqn === task.metadata['target_iqn']; } - taskFilter(task) { + taskFilter(task: Task) { return ['iscsi/target/create', 'iscsi/target/edit', 'iscsi/target/delete'].includes(task.name); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.spec.ts index 528f0a77a4f8a..f599c7f00a975 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.spec.ts @@ -17,7 +17,7 @@ describe('IscsiComponent', () => { let component: IscsiComponent; let fixture: ComponentFixture; let iscsiService: IscsiService; - let tcmuiscsiData; + let tcmuiscsiData: Record; const fakeService = { overview: () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts index 014e0911b2495..a8dc711a832f5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts @@ -20,9 +20,9 @@ export class IscsiComponent implements OnInit { @ViewChild('iscsiRelativeDateTpl', { static: true }) iscsiRelativeDateTpl: TemplateRef; - gateways = []; + gateways: any[] = []; gatewaysColumns: any; - images = []; + images: any[] = []; imagesColumns: any; constructor( @@ -104,13 +104,13 @@ export class IscsiComponent implements OnInit { } refresh() { - this.iscsiService.overview().subscribe((overview: Array) => { + this.iscsiService.overview().subscribe((overview: object) => { this.gateways = overview['gateways']; this.images = overview['images']; this.images.map((image) => { if (image.stats_history) { - image.stats_history.rd_bytes = image.stats_history.rd_bytes.map((i) => i[1]); - image.stats_history.wr_bytes = image.stats_history.wr_bytes.map((i) => i[1]); + image.stats_history.rd_bytes = image.stats_history.rd_bytes.map((i: any) => i[1]); + image.stats_history.wr_bytes = image.stats_history.wr_bytes.map((i: any) => i[1]); } image.cdIsBinary = true; return image; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/bootstrap-create-modal/bootstrap-create-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/bootstrap-create-modal/bootstrap-create-modal.component.ts index ce573f820bb86..b2130f8b51576 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/bootstrap-create-modal/bootstrap-create-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/bootstrap-create-modal/bootstrap-create-modal.component.ts @@ -10,6 +10,7 @@ import { RbdMirroringService } from '../../../../shared/api/rbd-mirroring.servic import { CdFormGroup } from '../../../../shared/forms/cd-form-group'; import { FinishedTask } from '../../../../shared/models/finished-task'; import { TaskWrapperService } from '../../../../shared/services/task-wrapper.service'; +import { Pool } from '../../../pool/pool'; @Component({ selector: 'cd-bootstrap-create-modal', @@ -60,7 +61,7 @@ export class BootstrapCreateModalComponent implements OnDestroy, OnInit { } const pools = data.content_data.pools; - this.pools = pools.reduce((acc, pool) => { + this.pools = pools.reduce((acc: any[], pool: Pool) => { acc.push({ name: pool['name'], mirror_mode: pool['mirror_mode'] @@ -139,7 +140,7 @@ export class BootstrapCreateModalComponent implements OnDestroy, OnInit { ), this.rbdMirroringService .createBootstrapToken(bootstrapPoolName) - .pipe(tap((data) => this.createBootstrapForm.get('token').setValue(data['token']))) + .pipe(tap((data: any) => this.createBootstrapForm.get('token').setValue(data['token']))) ).pipe(last()); const finishHandler = () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/bootstrap-import-modal/bootstrap-import-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/bootstrap-import-modal/bootstrap-import-modal.component.ts index 9effef71d0cd2..0e7d56d408730 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/bootstrap-import-modal/bootstrap-import-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/bootstrap-import-modal/bootstrap-import-modal.component.ts @@ -10,6 +10,7 @@ import { RbdMirroringService } from '../../../../shared/api/rbd-mirroring.servic import { CdFormGroup } from '../../../../shared/forms/cd-form-group'; import { FinishedTask } from '../../../../shared/models/finished-task'; import { TaskWrapperService } from '../../../../shared/services/task-wrapper.service'; +import { Pool } from '../../../pool/pool'; @Component({ selector: 'cd-bootstrap-import-modal', @@ -67,7 +68,7 @@ export class BootstrapImportModalComponent implements OnInit, OnDestroy { } const pools = data.content_data.pools; - this.pools = pools.reduce((acc, pool) => { + this.pools = pools.reduce((acc: any[], pool: Pool) => { acc.push({ name: pool['name'], mirror_mode: pool['mirror_mode'] diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/image-list/image-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/image-list/image-list.component.ts index b2aaecb2486bc..5acdd1ea29d21 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/image-list/image-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/image-list/image-list.component.ts @@ -20,15 +20,15 @@ export class ImageListComponent implements OnInit, OnDestroy { subs: Subscription; - image_error = { + image_error: Record = { data: [], columns: {} }; - image_syncing = { + image_syncing: Record = { data: [], columns: {} }; - image_ready = { + image_ready: Record = { data: [], columns: {} }; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/overview/overview.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/overview/overview.component.ts index 5e2297082c910..6a3c7ef210ed1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/overview/overview.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/overview/overview.component.ts @@ -11,6 +11,7 @@ import { CdTableAction } from '../../../../shared/models/cd-table-action'; import { CdTableSelection } from '../../../../shared/models/cd-table-selection'; import { Permission } from '../../../../shared/models/permissions'; import { AuthStorageService } from '../../../../shared/services/auth-storage.service'; +import { Pool } from '../../../pool/pool'; import { BootstrapCreateModalComponent } from '../bootstrap-create-modal/bootstrap-create-modal.component'; import { BootstrapImportModalComponent } from '../bootstrap-import-modal/bootstrap-import-modal.component'; import { EditSiteNameModalComponent } from '../edit-site-name-modal/edit-site-name-modal.component'; @@ -74,7 +75,7 @@ export class OverviewComponent implements OnInit, OnDestroy { this.status = data.content_data.status; this.siteName = data.site_name; - this.peersExist = !!data.content_data.pools.find((o) => o['peer_uuids'].length > 0); + this.peersExist = !!data.content_data.pools.find((o: Pool) => o['peer_uuids'].length > 0); }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-edit-mode-modal/pool-edit-mode-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-edit-mode-modal/pool-edit-mode-modal.component.ts index 443b71f41331a..3a393170b87f5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-edit-mode-modal/pool-edit-mode-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-edit-mode-modal/pool-edit-mode-modal.component.ts @@ -66,7 +66,7 @@ export class PoolEditModeModalComponent implements OnInit, OnDestroy { } const poolData = data.content_data.pools; - const pool = poolData.find((o) => this.poolName === o['name']); + const pool = poolData.find((o: any) => this.poolName === o['name']); this.peerExists = pool && pool['peer_uuids'].length; }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-list/pool-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-list/pool-list.component.ts index 7c0830ce1cdc3..efa0beba8c75b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-list/pool-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-list/pool-list.component.ts @@ -117,7 +117,7 @@ export class PoolListComponent implements OnInit, OnDestroy { this.modalRef = this.modalService.show(PoolEditModeModalComponent, { initialState }); } - editPeersModal(mode) { + editPeersModal(mode: string) { const initialState = { poolName: this.selection.first().name, mode: mode @@ -158,7 +158,7 @@ export class PoolListComponent implements OnInit, OnDestroy { }); } - getPeerUUID() { + getPeerUUID(): any { const selection = this.selection.first(); const pool = this.data.find((o) => selection && selection.name === o['name']); if (pool && pool['peer_uuids']) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-form/rbd-configuration-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-form/rbd-configuration-form.component.spec.ts index dbce86384d251..60926a043ed52 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-form/rbd-configuration-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-form/rbd-configuration-form.component.spec.ts @@ -56,7 +56,7 @@ describe('RbdConfigurationFormComponent', () => { const expected = sections .map((section) => section.options) .reduce((a, b) => a.concat(b)) - .map((option) => option.name); + .map((option: Record) => option.name); expect(actual).toEqual(expected); /* Test form creation on a template level */ @@ -85,7 +85,7 @@ describe('RbdConfigurationFormComponent', () => { it('should return dirty values without any units', () => { let dirtyValues = {}; - component.changes.subscribe((getDirtyValues) => { + component.changes.subscribe((getDirtyValues: Function) => { dirtyValues = getDirtyValues(); }); @@ -213,7 +213,7 @@ describe('RbdConfigurationFormComponent', () => { }); describe('should verify that getDirtyValues() returns correctly', () => { - let data; + let data: any; beforeEach(() => { component.initializeData = new EventEmitter(); @@ -280,7 +280,7 @@ describe('RbdConfigurationFormComponent', () => { it('should also return all local values if they do not contain their initial values', () => { // Change value for all options - data.initialData = data.initialData.map((o) => { + data.initialData = data.initialData.map((o: Record) => { o.value = 22; return o; }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-form/rbd-configuration-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-form/rbd-configuration-form.component.ts index c92f2453f92fe..67c6411735985 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-form/rbd-configuration-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-form/rbd-configuration-form.component.ts @@ -49,12 +49,14 @@ export class RbdConfigurationFormComponent implements OnInit { }); if (this.initializeData) { - this.initializeData.subscribe((data) => { + this.initializeData.subscribe((data: Record) => { this.initialData = data.initialData; const dataType = data.sourceType; this.rbdConfigurationService.getWritableOptionFields().forEach((option) => { - const optionData = data.initialData.filter((entry) => entry.name === option.name).pop(); + const optionData = data.initialData + .filter((entry: Record) => entry.name === option.name) + .pop(); if (optionData && optionData['source'] === dataType) { this.form.get(`configuration.${option.name}`).setValue(optionData['value']); } @@ -77,7 +79,7 @@ export class RbdConfigurationFormComponent implements OnInit { const result = {}; this.rbdConfigurationService.getWritableOptionFields().forEach((config) => { - const control = this.form.get('configuration').get(config.name); + const control: any = this.form.get('configuration').get(config.name); const dirty = control.dirty; if (this.initialData && this.initialData[config.name] === control.value) { @@ -131,7 +133,7 @@ export class RbdConfigurationFormComponent implements OnInit { * Reset the value. The inherited value will be used instead. */ reset(optionName: string) { - const formControl = this.form.get('configuration').get(optionName); + const formControl: any = this.form.get('configuration').get(optionName); if (formControl.disabled) { formControl.setValue(formControl['previousValue'] || 0); formControl.enable(); @@ -150,7 +152,7 @@ export class RbdConfigurationFormComponent implements OnInit { return this.form.get('configuration').get(optionName).disabled; } - toggleSectionVisibility(className) { + toggleSectionVisibility(className: string) { this.sectionVisibility[className] = !this.sectionVisibility[className]; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.spec.ts index e0cc67d97855e..27b5650a397cb 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.spec.ts @@ -88,7 +88,7 @@ describe('RbdConfigurationListComponent', () => { value: '100' } ]; - const filter = (keyword) => { + const filter = (keyword: string) => { poolConfTable.search = keyword; poolConfTable.updateFilter(); return poolConfTable.rows; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts index e9d9e1f24a0d5..77330e648d670 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts @@ -17,6 +17,7 @@ import { RbdService } from '../../../shared/api/rbd.service'; import { ImageSpec } from '../../../shared/models/image-spec'; import { SharedModule } from '../../../shared/shared.module'; import { RbdConfigurationFormComponent } from '../rbd-configuration-form/rbd-configuration-form.component'; +import { RbdImageFeature } from './rbd-feature.interface'; import { RbdFormMode } from './rbd-form-mode.enum'; import { RbdFormComponent } from './rbd-form.component'; @@ -25,7 +26,7 @@ describe('RbdFormComponent', () => { let fixture: ComponentFixture; let activatedRoute: ActivatedRouteStub; - const queryNativeElement = (cssSelector) => + const queryNativeElement = (cssSelector: string) => fixture.debugElement.query(By.css(cssSelector)).nativeElement; configureTestBed({ @@ -59,11 +60,11 @@ describe('RbdFormComponent', () => { }); describe('create/edit/clone/copy image', () => { - let createAction; - let editAction; - let cloneAction; - let copyAction; - let rbdServiceGetSpy; + let createAction: jasmine.Spy; + let editAction: jasmine.Spy; + let cloneAction: jasmine.Spy; + let copyAction: jasmine.Spy; + let rbdServiceGetSpy: jasmine.Spy; beforeEach(() => { createAction = spyOn(component, 'createAction').and.stub(); @@ -211,7 +212,12 @@ describe('RbdFormComponent', () => { }); describe('tests for feature flags', () => { - let deepFlatten, layering, exclusiveLock, objectMap, journaling, fastDiff; + let deepFlatten: any, + layering: any, + exclusiveLock: any, + objectMap: any, + journaling: any, + fastDiff: any; const defaultFeatures = [ // Supposed to be enabled by default 'deep-flatten', @@ -228,7 +234,7 @@ describe('RbdFormComponent', () => { 'journaling', 'fast-diff' ]; - const setFeatures = (features) => { + const setFeatures = (features: Record) => { component.features = features; component.featuresList = component.objToArray(features); component.createForm(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts index 82dbe49bdd6be..967796c89e6e9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts @@ -24,6 +24,7 @@ import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; import { FormatterService } from '../../../shared/services/formatter.service'; import { TaskWrapperService } from '../../../shared/services/task-wrapper.service'; +import { Pool } from '../../pool/pool'; import { RbdImageFeature } from './rbd-feature.interface'; import { RbdFormCloneRequestModel } from './rbd-form-clone-request.model'; import { RbdFormCopyRequestModel } from './rbd-form-copy-request.model'; @@ -47,8 +48,8 @@ export class RbdFormComponent implements OnInit { namespaces: Array = []; namespacesByPoolCache = {}; - pools: Array = null; - allPools: Array = null; + pools: Array = null; + allPools: Array = null; dataPools: Array = null; allDataPools: Array = null; features: { [key: string]: RbdImageFeature }; @@ -174,7 +175,7 @@ export class RbdFormComponent implements OnInit { }), obj_size: new FormControl(this.defaultObjectSize), features: new CdFormGroup( - this.featuresList.reduce((acc, e) => { + this.featuresList.reduce((acc: object, e) => { acc[e.key] = new FormControl({ value: false, disabled: !!e.initDisabled }); return acc; }, {}) @@ -260,7 +261,7 @@ export class RbdFormComponent implements OnInit { forkJoin(promisses).subscribe((data: object) => { // poolService.list if (data[Promisse.PoolServiceList]) { - const pools = []; + const pools: Pool[] = []; const dataPools = []; for (const pool of data[Promisse.PoolServiceList]) { if (this.rbdService.isRBDPool(pool)) { @@ -280,7 +281,7 @@ export class RbdFormComponent implements OnInit { this.dataPools = dataPools; this.allDataPools = dataPools; if (this.pools.length === 1) { - const poolName = this.pools[0]['pool_name']; + const poolName = this.pools[0].pool_name; this.rbdForm.get('pool').setValue(poolName); this.onPoolChange(poolName); } @@ -302,7 +303,7 @@ export class RbdFormComponent implements OnInit { }); } - onPoolChange(selectedPoolName) { + onPoolChange(selectedPoolName: string) { const newDataPools = this.allDataPools ? this.allDataPools.filter((dataPool: any) => { return dataPool.pool_name !== selectedPoolName; @@ -332,8 +333,8 @@ export class RbdFormComponent implements OnInit { } } - onDataPoolChange(selectedDataPoolName) { - const newPools = this.allPools.filter((pool: any) => { + onDataPoolChange(selectedDataPoolName: string) { + const newPools = this.allPools.filter((pool: Pool) => { return pool.pool_name !== selectedDataPoolName; }); if (this.rbdForm.getValue('pool') === selectedDataPoolName) { @@ -398,7 +399,7 @@ export class RbdFormComponent implements OnInit { return _.filter(this.features, (f) => f.requires === featureKey) || []; } - deepBoxCheck(key, checked) { + deepBoxCheck(key: string, checked: boolean) { const childFeatures = this.getDependendChildFeatures(key); childFeatures.forEach((feature) => { const featureControl = this.rbdForm.get(feature.key); @@ -424,7 +425,7 @@ export class RbdFormComponent implements OnInit { }); } - interlockCheck(key, checked) { + interlockCheck(key: string, checked: boolean) { // Adds a compatibility layer for Ceph cluster where the feature interlock of features hasn't // been implemented yet. It disables the feature interlock for images which only have one of // both interlocked features (at the time of this writing: object-map and fast-diff) enabled. @@ -471,7 +472,7 @@ export class RbdFormComponent implements OnInit { } } - featureFormUpdate(key, checked) { + featureFormUpdate(key: string, checked: boolean) { if (checked) { const required = this.features[key].requires; if (required && !this.rbdForm.getValue(required)) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts index 8a8b6a5c94c42..5710164d3185f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts @@ -35,7 +35,7 @@ describe('RbdListComponent', () => { let summaryService: SummaryService; let rbdService: RbdService; - const refresh = (data) => { + const refresh = (data: any) => { summaryService['summaryDataSource'].next(data); }; @@ -102,7 +102,7 @@ describe('RbdListComponent', () => { describe('handling of executing tasks', () => { let images: RbdModel[]; - const addImage = (name) => { + const addImage = (name: string) => { const model = new RbdModel(); model.id = '-1'; model.name = name; @@ -159,7 +159,7 @@ describe('RbdListComponent', () => { it('should gets all images without tasks', () => { expect(component.images.length).toBe(3); - expect(component.images.every((image) => !image.cdExecuting)).toBeTruthy(); + expect(component.images.every((image: any) => !image.cdExecuting)).toBeTruthy(); }); it('should add a new image from a task', () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts index 4e178f3fb7cbd..56187a69e5124 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts @@ -18,6 +18,7 @@ import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { FinishedTask } from '../../../shared/models/finished-task'; import { ImageSpec } from '../../../shared/models/image-spec'; import { Permission } from '../../../shared/models/permissions'; +import { Task } from '../../../shared/models/task'; import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe'; import { DimlessPipe } from '../../../shared/pipes/dimless.pipe'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; @@ -62,16 +63,16 @@ export class RbdListComponent implements OnInit { modalRef: BsModalRef; builders = { - 'rbd/create': (metadata) => + 'rbd/create': (metadata: object) => this.createRbdFromTask(metadata['pool_name'], metadata['namespace'], metadata['image_name']), - 'rbd/delete': (metadata) => this.createRbdFromTaskImageSpec(metadata['image_spec']), - 'rbd/clone': (metadata) => + 'rbd/delete': (metadata: object) => this.createRbdFromTaskImageSpec(metadata['image_spec']), + 'rbd/clone': (metadata: object) => this.createRbdFromTask( metadata['child_pool_name'], metadata['child_namespace'], metadata['child_image_name'] ), - 'rbd/copy': (metadata) => + 'rbd/copy': (metadata: object) => this.createRbdFromTask( metadata['dest_pool_name'], metadata['dest_namespace'], @@ -226,7 +227,7 @@ export class RbdListComponent implements OnInit { } ]; - const itemFilter = (entry, task) => { + const itemFilter = (entry: Record, task: Task) => { let taskImageSpec: string; switch (task.name) { case 'rbd/copy': @@ -259,7 +260,7 @@ export class RbdListComponent implements OnInit { ); }; - const taskFilter = (task) => { + const taskFilter = (task: Task) => { return [ 'rbd/clone', 'rbd/copy', @@ -288,7 +289,7 @@ export class RbdListComponent implements OnInit { } prepareResponse(resp: any[]): any[] { - let images = []; + let images: any[] = []; const viewCacheStatusMap = {}; resp.forEach((pool) => { if (_.isUndefined(viewCacheStatusMap[pool.status])) { @@ -297,7 +298,7 @@ export class RbdListComponent implements OnInit { viewCacheStatusMap[pool.status].push(pool.pool_name); images = images.concat(pool.value); }); - const viewCacheStatusList = []; + const viewCacheStatusList: any[] = []; _.forEach(viewCacheStatusMap, (value: any, key) => { viewCacheStatusList.push({ status: parseInt(key, 10), diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-form/rbd-namespace-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-form/rbd-namespace-form.component.ts index 023dc7faa1eea..acaf334a203d2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-form/rbd-namespace-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-form/rbd-namespace-form.component.ts @@ -19,6 +19,7 @@ import { FinishedTask } from '../../../shared/models/finished-task'; import { Permission } from '../../../shared/models/permissions'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; import { NotificationService } from '../../../shared/services/notification.service'; +import { Pool } from '../../pool/pool'; @Component({ selector: 'cd-rbd-namespace-form', @@ -27,7 +28,7 @@ import { NotificationService } from '../../../shared/services/notification.servi }) export class RbdNamespaceFormComponent implements OnInit { poolPermission: Permission; - pools: Array = null; + pools: Array = null; pool: string; namespace: string; @@ -101,7 +102,7 @@ export class RbdNamespaceFormComponent implements OnInit { if (this.poolPermission.read) { this.poolService.list(['pool_name', 'type', 'application_metadata']).then((resp) => { - const pools = []; + const pools: Pool[] = []; for (const pool of resp) { if (this.rbdService.isRBDPool(pool) && pool.type === 'replicated') { pools.push(pool); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-list/rbd-namespace-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-list/rbd-namespace-list.component.ts index 36a241eb8322d..3dd514ee46166 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-list/rbd-namespace-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-list/rbd-namespace-list.component.ts @@ -4,7 +4,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'; import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; import * as _ from 'lodash'; -import { forkJoin } from 'rxjs'; +import { forkJoin, Observable } from 'rxjs'; import { PoolService } from '../../../shared/api/pool.service'; import { RbdService } from '../../../shared/api/rbd.service'; import { CriticalConfirmationModalComponent } from '../../../shared/components/critical-confirmation-modal/critical-confirmation-modal.component'; @@ -84,14 +84,16 @@ export class RbdNamespaceListComponent implements OnInit { refresh() { this.poolService.list(['pool_name', 'type', 'application_metadata']).then((pools: any) => { - pools = pools.filter((pool) => this.rbdService.isRBDPool(pool) && pool.type === 'replicated'); - const promisses = []; - pools.forEach((pool) => { + pools = pools.filter( + (pool: any) => this.rbdService.isRBDPool(pool) && pool.type === 'replicated' + ); + const promisses: Observable[] = []; + pools.forEach((pool: any) => { promisses.push(this.rbdService.listNamespaces(pool['pool_name'])); }); if (promisses.length > 0) { forkJoin(promisses).subscribe((data: Array>) => { - const result = []; + const result: any[] = []; for (let i = 0; i < data.length; i++) { const namespaces = data[i]; const pool_name = pools[i]['pool_name']; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts index 8b267a187390b..0dcb9ad1f3ff5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts @@ -57,7 +57,7 @@ export class RbdSnapshotFormComponent implements OnInit { this.onSubmit = new Subject(); } - setSnapName(snapName) { + setSnapName(snapName: string) { this.snapName = snapName; this.snapshotForm.get('snapshotName').setValue(snapName); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts index 37b09c6378011..b85d15d92091c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts @@ -75,7 +75,7 @@ describe('RbdSnapshotListComponent', () => { }); describe('api delete request', () => { - let called; + let called: boolean; let rbdService: RbdService; let notificationService: NotificationService; let authStorageService: AuthStorageService; @@ -121,7 +121,7 @@ describe('RbdSnapshotListComponent', () => { describe('handling of executing tasks', () => { let snapshots: RbdSnapshotModel[]; - const addSnapshot = (name) => { + const addSnapshot = (name: string) => { const model = new RbdSnapshotModel(); model.id = 1; model.name = name; @@ -138,7 +138,7 @@ describe('RbdSnapshotListComponent', () => { summaryService.addRunningTask(task); }; - const refresh = (data) => { + const refresh = (data: any) => { summaryService['summaryDataSource'].next(data); }; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts index f228eef4f5bcc..6dfc82423b50e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts @@ -17,6 +17,7 @@ import { ExecutingTask } from '../../../shared/models/executing-task'; import { FinishedTask } from '../../../shared/models/finished-task'; import { ImageSpec } from '../../../shared/models/image-spec'; import { Permission } from '../../../shared/models/permissions'; +import { Task } from '../../../shared/models/task'; import { CdDatePipe } from '../../../shared/pipes/cd-date.pipe'; import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; @@ -61,7 +62,7 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges { modalRef: BsModalRef; builders = { - 'rbd/snap/create': (metadata) => { + 'rbd/snap/create': (metadata: any) => { const model = new RbdSnapshotModel(); model.name = metadata['snapshot_name']; return model; @@ -144,11 +145,11 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges { actions.deleteSnap.click = () => this.deleteSnapshotModal(); this.tableActions = actions.ordering; - const itemFilter = (entry, task) => { + const itemFilter = (entry: any, task: Task) => { return entry.name === task.metadata['snapshot_name']; }; - const taskFilter = (task) => { + const taskFilter = (task: Task) => { return ( ['rbd/snap/create', 'rbd/snap/delete', 'rbd/snap/edit', 'rbd/snap/rollback'].includes( task.name diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.spec.ts index 136b3aa4443f9..d98d338683877 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.spec.ts @@ -59,7 +59,7 @@ describe('RbdTrashListComponent', () => { describe('handling of executing tasks', () => { let images: any[]; - const addImage = (id) => { + const addImage = (id: string) => { images.push({ id: id, pool_name: 'pl' @@ -89,7 +89,9 @@ describe('RbdTrashListComponent', () => { it('should gets all images without tasks', () => { expect(component.images.length).toBe(2); - expect(component.images.every((image) => !image.cdExecuting)).toBeTruthy(); + expect( + component.images.every((image: Record) => !image.cdExecuting) + ).toBeTruthy(); }); it('should show when an existing image is being modified', () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts index 6813c3507e573..90f37facd054d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts @@ -19,6 +19,7 @@ import { ExecutingTask } from '../../../shared/models/executing-task'; import { FinishedTask } from '../../../shared/models/finished-task'; import { ImageSpec } from '../../../shared/models/image-spec'; import { Permission } from '../../../shared/models/permissions'; +import { Task } from '../../../shared/models/task'; import { CdDatePipe } from '../../../shared/pipes/cd-date.pipe'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; import { TaskListService } from '../../../shared/services/task-list.service'; @@ -115,12 +116,12 @@ export class RbdTrashListComponent implements OnInit { } ]; - const itemFilter = (entry, task) => { + const itemFilter = (entry: any, task: Task) => { const imageSpec = new ImageSpec(entry.pool_name, entry.namespace, entry.id); return imageSpec.toString() === task.metadata['image_id_spec']; }; - const taskFilter = (task) => { + const taskFilter = (task: Task) => { return ['rbd/trash/remove', 'rbd/trash/restore'].includes(task.name); }; @@ -136,9 +137,9 @@ export class RbdTrashListComponent implements OnInit { } prepareResponse(resp: any[]): any[] { - let images = []; + let images: any[] = []; const viewCacheStatusMap = {}; - resp.forEach((pool) => { + resp.forEach((pool: Record) => { if (_.isUndefined(viewCacheStatusMap[pool.status])) { viewCacheStatusMap[pool.status] = []; } @@ -146,7 +147,7 @@ export class RbdTrashListComponent implements OnInit { images = images.concat(pool.value); }); - const viewCacheStatusList = []; + const viewCacheStatusList: any[] = []; _.forEach(viewCacheStatusMap, (value: any, key) => { viewCacheStatusList.push({ status: parseInt(key, 10), @@ -208,7 +209,7 @@ export class RbdTrashListComponent implements OnInit { }); } - isExpired(expiresAt): boolean { + isExpired(expiresAt: string): boolean { return moment().isAfter(expiresAt); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.spec.ts index b02e3b73ebc82..458e3852d9104 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.spec.ts @@ -52,7 +52,7 @@ describe('RbdTrashMoveModalComponent', () => { }); describe('should call moveImage', () => { - let notificationService; + let notificationService: NotificationService; beforeEach(() => { notificationService = TestBed.get(NotificationService); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.ts index 7ec5fe5b96ecc..a968fe55698eb 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.ts @@ -47,11 +47,11 @@ export class RbdTrashMoveModalComponent implements OnInit { expiresAt: [ '', [ - CdValidators.custom('format', (expiresAt) => { + CdValidators.custom('format', (expiresAt: string) => { const result = expiresAt === '' || moment(expiresAt, 'YYYY-MM-DD HH:mm:ss').isValid(); return !result; }), - CdValidators.custom('expired', (expiresAt) => { + CdValidators.custom('expired', (expiresAt: string) => { const result = moment().isAfter(expiresAt); return result; }) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.spec.ts index 32969f10d7c5e..0202b080a2e30 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.spec.ts @@ -1,4 +1,8 @@ -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { + HttpClientTestingModule, + HttpTestingController, + TestRequest +} from '@angular/common/http/testing'; import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { ReactiveFormsModule } from '@angular/forms'; import { RouterTestingModule } from '@angular/router/testing'; @@ -69,7 +73,7 @@ describe('RbdTrashPurgeModalComponent', () => { describe('should call purge', () => { let notificationService: NotificationService; let modalRef: BsModalRef; - let req; + let req: TestRequest; beforeEach(() => { fixture.detectChanges(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.ts index 730ee62f2530e..fdb629c6f5391 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.ts @@ -10,6 +10,7 @@ import { FinishedTask } from '../../../shared/models/finished-task'; import { Permission } from '../../../shared/models/permissions'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; import { TaskWrapperService } from '../../../shared/services/task-wrapper.service'; +import { Pool } from '../../pool/pool'; @Component({ selector: 'cd-rbd-trash-purge-modal', @@ -42,8 +43,8 @@ export class RbdTrashPurgeModalComponent implements OnInit { if (this.poolPermission.read) { this.poolService.list(['pool_name', 'application_metadata']).then((resp) => { this.pools = resp - .filter((pool) => pool.application_metadata.includes('rbd')) - .map((pool) => pool.pool_name); + .filter((pool: Pool) => pool.application_metadata.includes('rbd')) + .map((pool: Pool) => pool.pool_name); }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-restore-modal/rbd-trash-restore-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-restore-modal/rbd-trash-restore-modal.component.spec.ts index 9dbab72e98cdc..79d800279b4da 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-restore-modal/rbd-trash-restore-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-restore-modal/rbd-trash-restore-modal.component.spec.ts @@ -1,4 +1,8 @@ -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { + HttpClientTestingModule, + HttpTestingController, + TestRequest +} from '@angular/common/http/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ReactiveFormsModule } from '@angular/forms'; import { RouterTestingModule } from '@angular/router/testing'; @@ -41,7 +45,7 @@ describe('RbdTrashRestoreModalComponent', () => { let httpTesting: HttpTestingController; let notificationService: NotificationService; let modalRef: BsModalRef; - let req; + let req: TestRequest; beforeEach(() => { httpTesting = TestBed.get(HttpTestingController); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts index 976cdb0b9ba1e..8255b442713a5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts @@ -123,8 +123,8 @@ export class CephfsChartComponent implements OnChanges, OnInit { const chartTooltip = new ChartTooltip( this.chartCanvas, this.chartTooltip, - (tooltip) => tooltip.caretX + 'px', - (tooltip) => tooltip.caretY - tooltip.height - 23 + 'px' + (tooltip: any) => tooltip.caretX + 'px', + (tooltip: any) => tooltip.caretY - tooltip.height - 23 + 'px' ); chartTooltip.getTitle = (ts) => moment(ts, 'x').format('LTS'); chartTooltip.checkOffset = true; @@ -160,8 +160,8 @@ export class CephfsChartComponent implements OnChanges, OnInit { * can handle (list of objects with millisecs-since-epoch * timestamps) */ - private convertTimeSeries(sourceSeries) { - const data = []; + private convertTimeSeries(sourceSeries: any) { + const data: any[] = []; _.each(sourceSeries, (dp) => { data.push({ x: dp[0] * 1000, @@ -179,7 +179,7 @@ export class CephfsChartComponent implements OnChanges, OnInit { return data; } - private deltaTimeSeries(sourceSeries) { + private deltaTimeSeries(sourceSeries: any) { let i; let prev = sourceSeries[0]; const result = []; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.spec.ts index 9a593d86f2c00..1d80097c92bbf 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.spec.ts @@ -15,7 +15,13 @@ describe('CephfsDetailComponent', () => { let component: CephfsDetailComponent; let fixture: ComponentFixture; - const updateDetails = (standbys, pools, ranks, mdsCounters, name) => { + const updateDetails = ( + standbys: string, + pools: any[], + ranks: any[], + mdsCounters: object, + name: string + ) => { component.data = { standbys, pools, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts index 2261c0727fe61..d45fb70bf9c0f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts @@ -31,7 +31,7 @@ export class CephfsDetailComponent implements OnChanges, OnInit { ranks: CdTableColumn[]; pools: CdTableColumn[]; }; - standbys = []; + standbys: any[] = []; objectValues = Object.values; @@ -71,7 +71,7 @@ export class CephfsDetailComponent implements OnChanges, OnInit { { name: this.i18n('Usage'), cellTemplate: this.poolUsageTpl, - comparator: (_valueA, _valueB, rowA, rowB) => { + comparator: (_valueA: any, _valueB: any, rowA: any, rowB: any) => { const valA = rowA.used / rowA.avail; const valB = rowB.used / rowB.avail; @@ -90,7 +90,7 @@ export class CephfsDetailComponent implements OnChanges, OnInit { }; } - trackByFn(_index, item) { + trackByFn(_index: any, item: any) { return item.name; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.spec.ts index ed277400548e4..92d583b24f430 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.spec.ts @@ -35,15 +35,15 @@ describe('CephfsDirectoriesComponent', () => { let component: CephfsDirectoriesComponent; let fixture: ComponentFixture; let cephfsService: CephfsService; - let lsDirSpy; - let modalShowSpy; - let notificationShowSpy; - let minValidator; - let maxValidator; - let minBinaryValidator; - let maxBinaryValidator; - let originalDate; - let modal; + let lsDirSpy: jasmine.Spy; + let modalShowSpy: jasmine.Spy; + let notificationShowSpy: jasmine.Spy; + let minValidator: jasmine.Spy; + let maxValidator: jasmine.Spy; + let minBinaryValidator: jasmine.Spy; + let maxBinaryValidator: jasmine.Spy; + let originalDate: any; + let modal: any; // Get's private attributes or functions const get = { @@ -123,7 +123,7 @@ describe('CephfsDirectoriesComponent', () => { }); return of(data); }, - mkSnapshot: (_id, path, name) => { + mkSnapshot: (_id: any, path: string, name: string) => { mockData.createdSnaps.push({ name, path, @@ -131,7 +131,7 @@ describe('CephfsDirectoriesComponent', () => { }); return of(name); }, - rmSnapshot: (_id, path, name) => { + rmSnapshot: (_id: any, path: string, name: string) => { mockData.deletedSnaps.push({ name, path, @@ -139,15 +139,15 @@ describe('CephfsDirectoriesComponent', () => { }); return of(name); }, - updateQuota: (_id, path, updated: CephfsQuotas) => { + updateQuota: (_id: any, path: string, updated: CephfsQuotas) => { mockData.updatedQuotas[path] = Object.assign(mockData.updatedQuotas[path] || {}, updated); return of('Response'); }, - modalShow: (comp, init) => { + modalShow: (comp: any, init: any) => { modal = modalServiceShow(comp, init); return modal.ref; }, - date: (arg) => (arg ? new originalDate(arg) : new Date('2022-02-22T00:00:00')), + date: (arg: string) => (arg ? new originalDate(arg) : new Date('2022-02-22T00:00:00')), getControllerByPath: (path: string) => { return { expand: () => mockLib.expand(path), @@ -251,12 +251,12 @@ describe('CephfsDirectoriesComponent', () => { noQuota: (key: 'bytes' | 'files') => { assert.quotaRow(key, '', 0, ''); }, - quotaIsNotInherited: (key: 'bytes' | 'files', shownValue, nextMaximum) => { + quotaIsNotInherited: (key: 'bytes' | 'files', shownValue: any, nextMaximum: number) => { const dir = component.selectedDir; const path = dir.path; assert.quotaRow(key, shownValue, nextMaximum, path); }, - quotaIsInherited: (key: 'bytes' | 'files', shownValue, path) => { + quotaIsInherited: (key: 'bytes' | 'files', shownValue: any, path: string) => { const isBytes = key === 'bytes'; const nextMaximum = get.nodeIds()[path].quotas[isBytes ? 'max_bytes' : 'max_files']; assert.quotaRow(key, shownValue, nextMaximum, path); @@ -282,7 +282,7 @@ describe('CephfsDirectoriesComponent', () => { } }); }, - quotaUnsetModalTexts: (titleText, message, notificationMsg) => { + quotaUnsetModalTexts: (titleText: string, message: string, notificationMsg: string) => { expect(modalShowSpy).toHaveBeenCalledWith(ConfirmationModalComponent, { initialState: expect.objectContaining({ titleText, @@ -292,7 +292,7 @@ describe('CephfsDirectoriesComponent', () => { }); expect(notificationShowSpy).toHaveBeenCalledWith(NotificationType.success, notificationMsg); }, - quotaUpdateModalTexts: (titleText, message, notificationMsg) => { + quotaUpdateModalTexts: (titleText: string, message: string, notificationMsg: string) => { expect(modalShowSpy).toHaveBeenCalledWith(FormModalComponent, { initialState: expect.objectContaining({ titleText, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.ts index 5c90d143ee2a6..97debd6e40c0e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.ts @@ -271,7 +271,7 @@ export class CephfsDirectoriesComponent implements OnInit, OnChanges { return this.dirs.filter((d) => d.parent.startsWith(path)); } - selectOrigin(path) { + selectOrigin(path: string) { this.treeComponent.getControllerByNodeId(path).select(); } @@ -284,7 +284,7 @@ export class CephfsDirectoriesComponent implements OnInit, OnChanges { } private setSettings(node: Tree) { - const readable = (value: number, fn?: (number) => number | string): number | string => + const readable = (value: number, fn?: (number: number) => number | string): number | string => value ? (fn ? fn(value) : value) : ''; this.settings = [ @@ -298,7 +298,7 @@ export class CephfsDirectoriesComponent implements OnInit, OnChanges { private getQuota( tree: Tree, quotaKey: string, - valueConvertFn: (number) => number | string + valueConvertFn: (number: number) => number | string ): QuotaSetting { // Get current maximum const currentPath = tree.id; @@ -374,7 +374,7 @@ export class CephfsDirectoriesComponent implements OnInit, OnChanges { : undefined, fields: [this.getQuotaFormField(selection.row.name, key, value, nextMax.value)], submitButtonText: this.i18n('Save'), - onSubmit: (values) => this.updateQuota(values) + onSubmit: (values: CephfsQuotas) => this.updateQuota(values) } }); } @@ -498,7 +498,7 @@ export class CephfsDirectoriesComponent implements OnInit, OnChanges { } ], submitButtonText: this.i18n('Create Snapshot'), - onSubmit: (values) => { + onSubmit: (values: CephfsSnapshot) => { this.cephfsService.mkSnapshot(this.id, path, values.name).subscribe((name) => { this.notificationService.show( NotificationType.success, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-tabs/cephfs-tabs.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-tabs/cephfs-tabs.component.spec.ts index bb394e2424115..4d5c4c171ec9a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-tabs/cephfs-tabs.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-tabs/cephfs-tabs.component.spec.ts @@ -32,8 +32,8 @@ describe('CephfsTabsComponent', () => { }; let old: any; - const getReload = () => component['reloadSubscriber']; - const setReload = (sth?) => (component['reloadSubscriber'] = sth); + const getReload: any = () => component['reloadSubscriber']; + const setReload = (sth?: any) => (component['reloadSubscriber'] = sth); const mockRunOutside = () => { component['subscribeInterval'] = () => { // It's mocked because the rxjs timer subscription ins't called through the use of 'tick'. @@ -143,14 +143,14 @@ describe('CephfsTabsComponent', () => { }); it('should set default values on id change before api request', () => { - const defaultDetails = { + const defaultDetails: Record = { standbys: '', pools: [], ranks: [], mdsCounters: {}, name: '' }; - const defaultClients = { + const defaultClients: Record = { data: [], status: ViewCacheStatus.ValueNone }; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-tabs/cephfs-tabs.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-tabs/cephfs-tabs.component.ts index 56132b969b9ad..9d606ae6af12b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-tabs/cephfs-tabs.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-tabs/cephfs-tabs.component.ts @@ -1,7 +1,7 @@ import { Component, Input, NgZone, OnChanges, OnDestroy } from '@angular/core'; import * as _ from 'lodash'; -import { timer } from 'rxjs'; +import { Subscription, timer } from 'rxjs'; import { CephfsService } from '../../../shared/api/cephfs.service'; import { ViewCacheStatus } from '../../../shared/enum/view-cache-status.enum'; @@ -25,13 +25,13 @@ export class CephfsTabsComponent implements OnChanges, OnDestroy { // Client tab id: number; - clients = { + clients: Record = { data: [], status: ViewCacheStatus.ValueNone }; // Details tab - details = { + details: Record = { standbys: '', pools: [], ranks: [], @@ -40,7 +40,7 @@ export class CephfsTabsComponent implements OnChanges, OnDestroy { }; private data: any; - private reloadSubscriber; + private reloadSubscriber: Subscription; constructor( private ngZone: NgZone, @@ -61,9 +61,9 @@ export class CephfsTabsComponent implements OnChanges, OnDestroy { } } - private setupSelected(id, mdsInfo) { + private setupSelected(id: number, mdsInfo: any) { this.id = id; - const firstMds = _.first(Object.values(mdsInfo)); + const firstMds: any = _.first(Object.values(mdsInfo)); this.grafanaId = firstMds && firstMds['name']; this.details = { standbys: '', diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts index d0652cb00beba..e99ff3cee971f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts @@ -133,7 +133,7 @@ export class ConfigurationFormComponent implements OnInit { } createRequest(): ConfigFormCreateRequestModel | null { - const values = []; + const values: any[] = []; this.availSections.forEach((section) => { const sectionValue = this.configForm.getValue(section); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts index 712d0d8a064cb..63d1ee750fed1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts @@ -21,7 +21,7 @@ import { AuthStorageService } from '../../../shared/services/auth-storage.servic export class ConfigurationComponent implements OnInit { permission: Permission; tableActions: CdTableAction[]; - data = []; + data: any[] = []; icons = Icons; columns: CdTableColumn[]; selection = new CdTableSelection(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts index 6f488f8932e44..52359f269d6f8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts @@ -13,7 +13,7 @@ export class CrushmapComponent implements OnInit { tree: TreeModel; metadata: any; metadataTitle: string; - metadataKeyMap: { [key: number]: number } = {}; + metadataKeyMap: { [key: number]: any } = {}; constructor(private healthService: HealthService) {} @@ -34,8 +34,8 @@ export class CrushmapComponent implements OnInit { }; } - const roots = []; - nodes.reverse().forEach((node) => { + const roots: any[] = []; + nodes.reverse().forEach((node: any) => { if (node.type === 'root') { roots.push(node.id); } @@ -52,7 +52,7 @@ export class CrushmapComponent implements OnInit { }; } - private generateTreeLeaf(node: any, treeNodeMap) { + private generateTreeLeaf(node: any, treeNodeMap: any) { const id = node.id; this.metadataKeyMap[id] = node; const settings = { static: true }; @@ -63,7 +63,7 @@ export class CrushmapComponent implements OnInit { const children: any[] = []; const resultNode = { value, status, settings, id, type: node.type }; if (node.children) { - node.children.sort().forEach((childId) => { + node.children.sort().forEach((childId: any) => { children.push(treeNodeMap[childId]); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts index b2247f90b9ad9..889f60610ba78 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts @@ -20,7 +20,7 @@ import { HostsComponent } from './hosts.component'; describe('HostsComponent', () => { let component: HostsComponent; let fixture: ComponentFixture; - let hostListSpy; + let hostListSpy: jasmine.Spy; const fakeAuthStorageService = { getPermissions: () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts index 40ccb8b8ddc22..6af6eff886f67 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts @@ -136,7 +136,7 @@ export class HostsComponent implements OnInit { this.hostService.list().subscribe( (resp: any[]) => { resp.map((host) => { - host.services.map((service) => { + host.services.map((service: any) => { service.cdLink = `/perf_counters/${service.type}/${encodeURIComponent(service.id)}`; const permission = this.permissions[typeToPermissionKey[service.type]]; service.canRead = permission ? permission.read : false; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/inventory/inventory-devices/inventory-devices.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/inventory/inventory-devices/inventory-devices.component.ts index fcaf0400eda46..ce5d3c2cfe326 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/inventory/inventory-devices/inventory-devices.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/inventory/inventory-devices/inventory-devices.component.ts @@ -179,7 +179,7 @@ export class InventoryDevicesComponent implements OnInit, OnChanges { } ], submitButtonText: this.i18n('Execute'), - onSubmit: (values) => { + onSubmit: (values: any) => { this.orchService.identifyDevice(hostname, device, values.duration).subscribe(() => { this.notificationService.show( NotificationType.success, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/logs/logs.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/logs/logs.component.spec.ts index 8b4436cc7ef47..e4f69fc920dae 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/logs/logs.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/logs/logs.component.spec.ts @@ -57,7 +57,7 @@ describe('LogsComponent', () => { }); describe('filterLogs', () => { - const contentData = { + const contentData: Record = { clog: [ { name: 'priority', diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.ts index 71424b84e99b1..4810c5f8f8fbd 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.ts @@ -23,7 +23,7 @@ export class MgrModuleFormComponent implements OnInit { error = false; loading = false; moduleName = ''; - moduleOptions = []; + moduleOptions: any[] = []; constructor( private route: ActivatedRoute, @@ -58,7 +58,7 @@ export class MgrModuleFormComponent implements OnInit { }); } - getValidators(moduleOption): ValidatorFn[] { + getValidators(moduleOption: any): ValidatorFn[] { const result = []; switch (moduleOption.type) { case 'addr': diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/monitor/monitor.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/monitor/monitor.component.spec.ts index b3f4ee53901a4..b7ade11d31dd2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/monitor/monitor.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/monitor/monitor.component.spec.ts @@ -23,7 +23,7 @@ describe('MonitorComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(MonitorComponent); component = fixture.componentInstance; - const getMonitorPayload = { + const getMonitorPayload: Record = { in_quorum: [ { stats: { num_sessions: [[1, 5]] } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/monitor/monitor.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/monitor/monitor.component.ts index d53f862616875..c9a95592224ab 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/monitor/monitor.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/monitor/monitor.component.ts @@ -28,7 +28,7 @@ export class MonitorComponent { prop: 'cdOpenSessions', name: this.i18n('Open Sessions'), cellTransformation: CellTemplate.sparkline, - comparator: (dataA, dataB) => { + comparator: (dataA: any, dataB: any) => { // We get the last value of time series to compare: const lastValueA = _.last(dataA); const lastValueB = _.last(dataB); @@ -56,14 +56,14 @@ export class MonitorComponent { refresh() { this.monitorService.getMonitor().subscribe((data: any) => { - data.in_quorum.map((row) => { - row.cdOpenSessions = row.stats.num_sessions.map((i) => i[1]); + data.in_quorum.map((row: any) => { + row.cdOpenSessions = row.stats.num_sessions.map((i: string) => i[1]); row.cdLink = '/perf_counters/mon/' + row.name; row.cdParams = { fromLink: '/monitor' }; return row; }); - data.out_quorum.map((row) => { + data.out_quorum.map((row: any) => { row.cdLink = '/perf_counters/mon/' + row.name; row.cdParams = { fromLink: '/monitor' }; return row; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.spec.ts index b372dde17fa4f..16b7f20e331a1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.spec.ts @@ -20,7 +20,7 @@ describe('OsdDetailsComponent', () => { let fixture: ComponentFixture; let debugElement: DebugElement; let osdService: OsdService; - let getDetailsSpy; + let getDetailsSpy: jasmine.Spy; configureTestBed({ imports: [HttpClientTestingModule, TabsModule.forRoot(), SharedModule], diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.spec.ts index 6895a4bd85d3a..d454899c549d0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.spec.ts @@ -10,6 +10,7 @@ import { i18nProviders } from '../../../../../testing/unit-test-helper'; import { SharedModule } from '../../../../shared/shared.module'; +import { InventoryDevice } from '../../inventory/inventory-devices/inventory-device.model'; import { InventoryDevicesComponent } from '../../inventory/inventory-devices/inventory-devices.component'; import { OsdDevicesSelectionGroupsComponent } from './osd-devices-selection-groups.component'; @@ -17,7 +18,7 @@ describe('OsdDevicesSelectionGroupsComponent', () => { let component: OsdDevicesSelectionGroupsComponent; let fixture: ComponentFixture; let fixtureHelper: FixtureHelper; - const devices = [ + const devices: InventoryDevice[] = [ { hostname: 'node0', uid: '1', @@ -126,7 +127,7 @@ describe('OsdDevicesSelectionGroupsComponent', () => { spyOn(component.cleared, 'emit'); fixtureHelper.clickElement(clearTextSelector); fixtureHelper.expectElementVisible('cd-inventory-devices', false); - const event = { + const event: Record = { type: undefined, clearedDevices: devices }; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.ts index fffd7db565989..dd3e711d72f75 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.ts @@ -36,7 +36,7 @@ export class OsdDevicesSelectionGroupsComponent { icons = Icons; devices: InventoryDevice[] = []; - appliedFilters = []; + appliedFilters: any[] = []; constructor(private bsModalService: BsModalService) {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.ts index 24049bd8c9d35..82e5a0b24d133 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.ts @@ -49,9 +49,9 @@ export class OsdFormComponent implements OnInit { allDevices: InventoryDevice[] = []; availDevices: InventoryDevice[] = []; - dataDeviceFilters = []; - dbDeviceFilters = []; - walDeviceFilters = []; + dataDeviceFilters: any[] = []; + dbDeviceFilters: any[] = []; + walDeviceFilters: any[] = []; hostname = ''; driveGroup = new DriveGroup(); @@ -129,7 +129,7 @@ export class OsdFormComponent implements OnInit { validators: [Validators.min(0)] }), features: new CdFormGroup( - this.featureList.reduce((acc, e) => { + this.featureList.reduce((acc: object, e) => { // disable initially because no data devices are selected acc[e.key] = new FormControl({ value: false, disabled: true }); return acc; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts index e747c66416ff8..7064628e38dd2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts @@ -45,7 +45,8 @@ describe('OsdListComponent', () => { } }; - const getTableAction = (name) => component.tableActions.find((action) => action.name === name); + const getTableAction = (name: string) => + component.tableActions.find((action) => action.name === name); const setFakeSelection = () => { // Default data and selection @@ -59,7 +60,7 @@ describe('OsdListComponent', () => { component.permissions = fakeAuthStorageService.getPermissions(); }; - const openActionModal = (actionName) => { + const openActionModal = (actionName: string) => { setFakeSelection(); getTableAction(actionName).click(); }; @@ -118,24 +119,25 @@ describe('OsdListComponent', () => { }); describe('getOsdList', () => { - let osds; - - const createOsd = (n: number) => ({ - in: 'in', - up: 'up', - tree: { - device_class: 'ssd' - }, - stats_history: { - op_out_bytes: [[n, n], [n * 2, n * 2]], - op_in_bytes: [[n * 3, n * 3], [n * 4, n * 4]] - }, - stats: { - stat_bytes_used: n * n, - stat_bytes: n * n * n - }, - state: [] - }); + let osds: any[]; + + const createOsd = (n: number) => + >{ + in: 'in', + up: 'up', + tree: { + device_class: 'ssd' + }, + stats_history: { + op_out_bytes: [[n, n], [n * 2, n * 2]], + op_in_bytes: [[n * 3, n * 3], [n * 4, n * 4]] + }, + stats: { + stat_bytes_used: n * n, + stat_bytes: n * n * n + }, + state: [] + }; const expectAttributeOnEveryOsd = (attr: string) => expect(component.osds.every((osd) => Boolean(_.get(osd, attr)))).toBeTruthy(); @@ -354,7 +356,7 @@ describe('OsdListComponent', () => { * * @param modalClass - The expected class of the modal */ - const expectOpensModal = (actionName: string, modalClass): void => { + const expectOpensModal = (actionName: string, modalClass: any): void => { openActionModal(actionName); // @TODO: check why tsc is complaining when passing 'expectationFailOutput' param. diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts index 025615e496edb..0c77fdcf94f1d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts @@ -58,9 +58,9 @@ export class OsdListComponent implements OnInit { icons = Icons; selection = new CdTableSelection(); - osds = []; + osds: any[] = []; - protected static collectStates(osd) { + protected static collectStates(osd: any) { const states = [osd['in'] ? 'in' : 'out']; if (osd['up']) { states.push('up'); @@ -325,8 +325,8 @@ export class OsdListComponent implements OnInit { this.osdService.getList().subscribe((data: any[]) => { this.osds = data.map((osd) => { osd.collectedStates = OsdListComponent.collectStates(osd); - osd.stats_history.out_bytes = osd.stats_history.op_out_bytes.map((i) => i[1]); - osd.stats_history.in_bytes = osd.stats_history.op_in_bytes.map((i) => i[1]); + osd.stats_history.out_bytes = osd.stats_history.op_out_bytes.map((i: string) => i[1]); + osd.stats_history.in_bytes = osd.stats_history.op_in_bytes.map((i: string) => i[1]); osd.stats.usage = osd.stats.stat_bytes_used / osd.stats.stat_bytes; osd.cdIsBinary = true; return osd; @@ -352,7 +352,7 @@ export class OsdListComponent implements OnInit { } ], submitButtonText: this.i18n('Edit OSD'), - onSubmit: (values) => { + onSubmit: (values: any) => { this.osdService.update(selectedOsd.id, values.deviceClass).subscribe(() => { this.notificationService.show( NotificationType.success, @@ -367,7 +367,7 @@ export class OsdListComponent implements OnInit { }); } - scrubAction(deep) { + scrubAction(deep: boolean) { if (!this.hasOsdSelected) { return; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-performance-histogram/osd-performance-histogram.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-performance-histogram/osd-performance-histogram.component.ts index 584446f9202ef..f81d51c2c0055 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-performance-histogram/osd-performance-histogram.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-performance-histogram/osd-performance-histogram.component.ts @@ -19,12 +19,12 @@ export class OsdPerformanceHistogramComponent implements OnChanges { this.render(); } - hexdigits(v): string { + hexdigits(v: number): string { const i = Math.floor(v * 255).toString(16); return i.length === 1 ? '0' + i : i; } - hexcolor(r, g, b) { + hexcolor(r: number, g: number, b: number) { return '#' + this.hexdigits(r) + this.hexdigits(g) + this.hexdigits(b); } @@ -46,8 +46,8 @@ export class OsdPerformanceHistogramComponent implements OnChanges { }); }); - this.valuesStyle = this.histogram.values.map((row, i) => { - return row.map((col, j) => { + this.valuesStyle = this.histogram.values.map((row: any, i: number) => { + return row.map((col: any, j: number) => { const val = this.last && this.last[i] && this.last[i][j] ? col - this.last[i][j] : col; const g = max ? val / max : 0; const r = 1 - g; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-recv-speed-modal/osd-recv-speed-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-recv-speed-modal/osd-recv-speed-modal.component.spec.ts index 57855adbddcbd..bae23227ada34 100755 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-recv-speed-modal/osd-recv-speed-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-recv-speed-modal/osd-recv-speed-modal.component.spec.ts @@ -31,7 +31,7 @@ describe('OsdRecvSpeedModalComponent', () => { providers: [BsModalRef, i18nProviders] }); - let configOptions = []; + let configOptions: any[] = []; beforeEach(() => { fixture = TestBed.createComponent(OsdRecvSpeedModalComponent); @@ -72,8 +72,8 @@ describe('OsdRecvSpeedModalComponent', () => { }); describe('ngOnInit', () => { - let setPriority; - let setValidators; + let setPriority: jasmine.Spy; + let setValidators: jasmine.Spy; beforeEach(() => { setPriority = spyOn(component, 'setPriority').and.callThrough(); @@ -192,35 +192,35 @@ describe('OsdRecvSpeedModalComponent', () => { }; it('should return priority "low" if the config option values have been set accordingly', () => { - component.detectPriority(configOptionsLow, (priority) => { + component.detectPriority(configOptionsLow, (priority: Record) => { expect(priority.name).toBe('low'); }); expect(component.osdRecvSpeedForm.getValue('customizePriority')).toBeFalsy(); }); it('should return priority "default" if the config option values have been set accordingly', () => { - component.detectPriority(configOptionsDefault, (priority) => { + component.detectPriority(configOptionsDefault, (priority: Record) => { expect(priority.name).toBe('default'); }); expect(component.osdRecvSpeedForm.getValue('customizePriority')).toBeFalsy(); }); it('should return priority "high" if the config option values have been set accordingly', () => { - component.detectPriority(configOptionsHigh, (priority) => { + component.detectPriority(configOptionsHigh, (priority: Record) => { expect(priority.name).toBe('high'); }); expect(component.osdRecvSpeedForm.getValue('customizePriority')).toBeFalsy(); }); it('should return priority "custom" if the config option values do not match any priority', () => { - component.detectPriority(configOptionsCustom, (priority) => { + component.detectPriority(configOptionsCustom, (priority: Record) => { expect(priority.name).toBe('custom'); }); expect(component.osdRecvSpeedForm.getValue('customizePriority')).toBeTruthy(); }); it('should return no priority if the config option values are incomplete', () => { - component.detectPriority(configOptionsIncomplete, (priority) => { + component.detectPriority(configOptionsIncomplete, (priority: Record) => { expect(priority.name).toBeNull(); }); expect(component.osdRecvSpeedForm.getValue('customizePriority')).toBeFalsy(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-recv-speed-modal/osd-recv-speed-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-recv-speed-modal/osd-recv-speed-modal.component.ts index d98ea39a85539..f23430800e01a 100755 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-recv-speed-modal/osd-recv-speed-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-recv-speed-modal/osd-recv-speed-modal.component.ts @@ -23,7 +23,7 @@ export class OsdRecvSpeedModalComponent implements OnInit { osdRecvSpeedForm: CdFormGroup; permissions: Permissions; - priorities = []; + priorities: any[] = []; priorityAttrs = {}; constructor( @@ -82,7 +82,7 @@ export class OsdRecvSpeedModalComponent implements OnInit { ngOnInit() { this.configService.filter(Object.keys(this.priorityAttrs)).subscribe((data: any) => { const config_option_values = this.getCurrentValues(data); - this.detectPriority(config_option_values.values, (priority) => { + this.detectPriority(config_option_values.values, (priority: any) => { this.setPriority(priority); }); this.setDescription(config_option_values.configOptions); @@ -112,12 +112,12 @@ export class OsdRecvSpeedModalComponent implements OnInit { } getCurrentValues(configOptions: any) { - const currentValues = { values: {}, configOptions: [] }; - configOptions.forEach((configOption) => { + const currentValues: Record = { values: {}, configOptions: [] }; + configOptions.forEach((configOption: any) => { currentValues.configOptions.push(configOption); if ('value' in configOption) { - configOption.value.forEach((value) => { + configOption.value.forEach((value: any) => { if (value.section === 'osd') { currentValues.values[configOption.name] = Number(value.value); } @@ -194,13 +194,13 @@ export class OsdRecvSpeedModalComponent implements OnInit { }; this.setPriority(customPriority); } else { - this.detectPriority(values, (priority) => { + this.detectPriority(values, (priority: any) => { this.setPriority(priority); }); } } - onPriorityChange(selectedPriorityName) { + onPriorityChange(selectedPriorityName: string) { const selectedPriority = _.find(this.priorities, (p) => { return p.name === selectedPriorityName; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-scrub-modal/osd-scrub-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-scrub-modal/osd-scrub-modal.component.ts index 340dff9e615c1..c19e523744527 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-scrub-modal/osd-scrub-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-scrub-modal/osd-scrub-modal.component.ts @@ -18,7 +18,7 @@ import { NotificationService } from '../../../../shared/services/notification.se export class OsdScrubModalComponent implements OnInit { deep: boolean; scrubForm: FormGroup; - selected = []; + selected: any[] = []; constructor( public bsModalRef: BsModalRef, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-form/silence-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-form/silence-form.component.spec.ts index 73d5fd8a620ca..b160a67caa201 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-form/silence-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-form/silence-form.component.spec.ts @@ -41,15 +41,15 @@ describe('SilenceFormComponent', () => { let notificationService: NotificationService; let router: Router; // Spies - let rulesSpy; - let ifPrometheusSpy; + let rulesSpy: jasmine.Spy; + let ifPrometheusSpy: jasmine.Spy; // Helper let prometheus: PrometheusHelper; let formHelper: FormHelper; let fixtureH: FixtureHelper; - let params; + let params: Record; // Date mocking related - let originalDate; + let originalDate: any; const baseTime = new Date('2022-02-22T00:00:00'); const beginningDate = new Date('2022-02-22T00:00:12.35'); @@ -69,14 +69,14 @@ describe('SilenceFormComponent', () => { i18nProviders, { provide: ActivatedRoute, - useValue: { params: { subscribe: (fn) => fn(params) } } + useValue: { params: { subscribe: (fn: Function) => fn(params) } } } ] }); - const createMatcher = (name, value, isRegex) => ({ name, value, isRegex }); + const createMatcher = (name: string, value: any, isRegex: boolean) => ({ name, value, isRegex }); - const addMatcher = (name, value, isRegex) => + const addMatcher = (name: string, value: any, isRegex: boolean) => component['setMatcher'](createMatcher(name, value, isRegex)); const callInit = () => @@ -160,7 +160,7 @@ describe('SilenceFormComponent', () => { }); it('should remind user if prometheus is not set when it is not configured', () => { - ifPrometheusSpy.and.callFake((_x, fn) => fn()); + ifPrometheusSpy.and.callFake((_x: any, fn: Function) => fn()); callInit(); expect(component.rules).toEqual([]); expect(notificationService.show).toHaveBeenCalledWith( @@ -174,7 +174,7 @@ describe('SilenceFormComponent', () => { describe('redirect not allowed users', () => { let prometheusPermissions: Permission; - let navigateSpy; + let navigateSpy: jasmine.Spy; const expectRedirect = (action: string, redirected: boolean) => { changeAction(action); @@ -300,13 +300,13 @@ describe('SilenceFormComponent', () => { describe('time', () => { // Can't be used to set accurate UTC dates in unit tests as Date uses timezones, // this means the UTC time changes depending on the timezone you are in. - const changeDatePicker = (el, text) => { + const changeDatePicker = (el: any, text: string) => { el.triggerEventHandler('change', { target: { value: text } }); }; - const getDatePicker = (i) => + const getDatePicker = (i: number) => fixture.debugElement.queryAll(By.directive(BsDatepickerDirective))[i]; - const changeEndDate = (text) => changeDatePicker(getDatePicker(1), text); - const changeStartDate = (text) => changeDatePicker(getDatePicker(0), text); + const changeEndDate = (text: string) => changeDatePicker(getDatePicker(1), text); + const changeStartDate = (text: string) => changeDatePicker(getDatePicker(0), text); it('have all dates set at beginning', () => { expect(form.getValue('startsAt')).toEqual(baseTime); @@ -390,7 +390,7 @@ describe('SilenceFormComponent', () => { }); describe('matchers', () => { - const expectMatch = (helpText) => { + const expectMatch = (helpText: string) => { expect(fixtureH.getText('#match-state')).toBe(helpText); }; @@ -464,7 +464,7 @@ describe('SilenceFormComponent', () => { spyOn(modalService, 'show').and.callFake(() => { return { content: { - preFillControls: (matcher) => { + preFillControls: (matcher: any) => { expect(matcher).toBe(component.matchers[0]); }, submitAction: of({ name: 'alertname', value: 'alert0', isRegex: false }) @@ -514,7 +514,7 @@ describe('SilenceFormComponent', () => { let silence: AlertmanagerSilence; const silenceId = '50M3-10N6-1D'; - const expectSuccessNotification = (titleStartsWith) => + const expectSuccessNotification = (titleStartsWith: string) => expect(notificationService.show).toHaveBeenCalledWith( NotificationType.success, `${titleStartsWith} silence ${silenceId}`, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-list/silence-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-list/silence-list.component.spec.ts index d063b7309c1a5..4573d71b2fe5c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-list/silence-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-list/silence-list.component.spec.ts @@ -105,7 +105,7 @@ describe('SilenceListComponent', () => { deletion.callSubmitAction(); }; - const expectSilenceToExpire = (silenceId) => { + const expectSilenceToExpire = (silenceId: string) => { setSelectedSilence(silenceId); expireSilence(); expect(prometheusService.expireSilence).toHaveBeenCalledWith(silenceId); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-matcher-modal/silence-matcher-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-matcher-modal/silence-matcher-modal.component.spec.ts index cd8fa2802117a..d7d9a86ab7bb4 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-matcher-modal/silence-matcher-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-matcher-modal/silence-matcher-modal.component.spec.ts @@ -78,7 +78,7 @@ describe('SilenceMatcherModalComponent', () => { }); describe('test rule matching', () => { - const expectMatch = (name, value, helpText) => { + const expectMatch = (name: string, value: string, helpText: string) => { component.preFillControls({ name: name, value: value, @@ -154,7 +154,7 @@ describe('SilenceMatcherModalComponent', () => { isRegex: false }; component.preFillControls(controlValues); - component.submitAction.subscribe((resp) => { + component.submitAction.subscribe((resp: object) => { expect(resp).toEqual(controlValues); done(); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-matcher-modal/silence-matcher-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-matcher-modal/silence-matcher-modal.component.ts index d04537fca1e36..139a3ee23a87d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-matcher-modal/silence-matcher-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/silence-matcher-modal/silence-matcher-modal.component.ts @@ -62,7 +62,7 @@ export class SilenceMatcherModalComponent { }); } - private setPossibleValues(name) { + private setPossibleValues(name: string) { this.possibleValues = _.sortedUniq( this.rules.map((r) => _.get(r, this.silenceMatcher.getAttributePath(name))).filter((x) => x) ); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health-pie/health-pie.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health-pie/health-pie.component.ts index 4a3eb707609ec..6dce33439b2f2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health-pie/health-pie.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health-pie/health-pie.component.ts @@ -54,7 +54,7 @@ export class HealthPieComponent implements OnChanges, OnInit { display: true, position: 'right', labels: { usePointStyle: true }, - onClick: (event, legendItem) => { + onClick: (event: any, legendItem: any) => { this.onLegendClick(event, legendItem); } }, @@ -67,7 +67,7 @@ export class HealthPieComponent implements OnChanges, OnInit { } } }; - private hiddenSlices = []; + private hiddenSlices: any[] = []; constructor(private dimlessBinary: DimlessBinaryPipe, private dimless: DimlessPipe) {} @@ -98,11 +98,11 @@ export class HealthPieComponent implements OnChanges, OnInit { } }); - const getStyleTop = (tooltip, positionY) => { + const getStyleTop = (tooltip: any, positionY: number) => { return positionY + tooltip.caretY - tooltip.height - 10 + 'px'; }; - const getStyleLeft = (tooltip, positionX) => { + const getStyleLeft = (tooltip: any, positionX: number) => { return positionX + tooltip.caretX + 'px'; }; @@ -113,13 +113,13 @@ export class HealthPieComponent implements OnChanges, OnInit { getStyleTop ); - const getBody = (body) => { + const getBody = (body: any) => { return this.getChartTooltipBody(body); }; chartTooltip.getBody = getBody; - this.chartConfig.options.tooltips.custom = (tooltip) => { + this.chartConfig.options.tooltips.custom = (tooltip: any) => { chartTooltip.customTooltips(tooltip); }; @@ -146,7 +146,7 @@ export class HealthPieComponent implements OnChanges, OnInit { this.setChartSliceBorderWidth(); } - private getChartTooltipBody(body) { + private getChartTooltipBody(body: string[]) { const bodySplit = body[0].split(': '); if (this.showLabelAsTooltip) { @@ -171,14 +171,14 @@ export class HealthPieComponent implements OnChanges, OnInit { this.chartConfig.dataset[0].borderWidth = nonZeroValueSlices > 1 ? 1 : 0; } - private onLegendClick(event, legendItem) { + private onLegendClick(event: any, legendItem: any) { event.stopPropagation(); this.hiddenSlices[legendItem.index] = !legendItem.hidden; this.ngOnChanges(); } private hideSlices() { - _.forEach(this.chartConfig.dataset[0].data, (_slice, sliceIndex) => { + _.forEach(this.chartConfig.dataset[0].data, (_slice, sliceIndex: number) => { if (this.hiddenSlices[sliceIndex]) { this.chartConfig.dataset[0].data[sliceIndex] = undefined; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts index de7892a07a682..17bc30b9f6afe 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts @@ -25,8 +25,8 @@ import { HealthComponent } from './health.component'; describe('HealthComponent', () => { let component: HealthComponent; let fixture: ComponentFixture; - let getHealthSpy; - const healthPayload = { + let getHealthSpy: jasmine.Spy; + const healthPayload: Record = { health: { status: 'HEALTH_OK' }, mon_status: { monmap: { mons: [] }, quorum: [] }, osd_map: { osds: [] }, @@ -46,7 +46,7 @@ describe('HealthComponent', () => { return new Permissions({ log: ['read'] }); } }; - let fakeFeatureTogglesService; + let fakeFeatureTogglesService: jasmine.Spy; configureTestBed({ imports: [SharedModule, HttpClientTestingModule, PopoverModule.forRoot()], @@ -176,7 +176,7 @@ describe('HealthComponent', () => { }); it('should render all groups and 1 card per group', () => { - const payload = { hosts: 0, scrub_status: 'Inactive', pools: [] }; + const payload: Record = { hosts: 0, scrub_status: 'Inactive', pools: [] }; getHealthSpy.and.returnValue(of(payload)); fixture.detectChanges(); @@ -256,7 +256,7 @@ describe('HealthComponent', () => { }); describe('preparePgStatus', () => { - const calcPercentage = (data) => Math.round((data / 10) * 100) || 0; + const calcPercentage = (data: number) => Math.round((data / 10) * 100) || 0; const expectedChart = (data: number[]) => ({ labels: [ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.ts index 3906e559cf878..7b6e5f8a0fbc9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.ts @@ -94,7 +94,7 @@ export class HealthComponent implements OnInit, OnDestroy { }); } - prepareReadWriteRatio(chart) { + prepareReadWriteRatio(chart: Record) { const ratioLabels = []; const ratioData = []; @@ -120,7 +120,7 @@ export class HealthComponent implements OnInit, OnDestroy { chart.labels = ratioLabels; } - prepareRawUsage(chart, data) { + prepareRawUsage(chart: Record, data: Record) { const percentAvailable = this.calcPercentage( data.df.stats.total_bytes - data.df.stats.total_used_raw_bytes, data.df.stats.total_bytes @@ -146,8 +146,8 @@ export class HealthComponent implements OnInit, OnDestroy { )} ${this.i18n('total')}`; } - preparePgStatus(chart, data) { - const categoryPgAmount = {}; + preparePgStatus(chart: Record, data: Record) { + const categoryPgAmount: Record = {}; let totalPgs = 0; _.forEach(data.pg_info.statuses, (pgAmount, pgStatesText) => { @@ -172,7 +172,7 @@ export class HealthComponent implements OnInit, OnDestroy { ]; } - prepareObjects(chart, data) { + prepareObjects(chart: Record, data: Record) { const totalReplicas = data.pg_info.object_stats.num_object_copies; const healthy = totalReplicas - diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mds-summary.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mds-summary.pipe.spec.ts index 98e903ec96371..159438c7776a7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mds-summary.pipe.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mds-summary.pipe.spec.ts @@ -46,7 +46,7 @@ describe('MdsSummaryPipe', () => { }); it('transforms with 0 filesystems', () => { - const payload = { + const payload: Record = { standbys: [0], filesystems: [] }; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mgr-summary.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mgr-summary.pipe.spec.ts index 689f9da44b79c..ffa58d918768f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mgr-summary.pipe.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mgr-summary.pipe.spec.ts @@ -24,7 +24,7 @@ describe('MgrSummaryPipe', () => { }); it('transforms with active_name undefined', () => { - const payload = { + const payload: Record = { active_name: undefined, standbys: [] }; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-details/nfs-details.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-details/nfs-details.component.spec.ts index f3f2829414803..a1d1c6d349b80 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-details/nfs-details.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-details/nfs-details.component.spec.ts @@ -14,7 +14,7 @@ describe('NfsDetailsComponent', () => { let component: NfsDetailsComponent; let fixture: ComponentFixture; - const elem = (css) => fixture.debugElement.query(By.css(css)); + const elem = (css: string) => fixture.debugElement.query(By.css(css)); configureTestBed({ declarations: [NfsDetailsComponent], diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-details/nfs-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-details/nfs-details.component.ts index 0219585c3bb8a..db91c7d53388c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-details/nfs-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-details/nfs-details.component.ts @@ -19,7 +19,7 @@ export class NfsDetailsComponent implements OnChanges { data: any; clientsColumns: CdTableColumn[]; - clients = []; + clients: any[] = []; constructor(private i18n: I18n) { this.clientsColumns = [ @@ -51,7 +51,7 @@ export class NfsDetailsComponent implements OnChanges { this.data[this.i18n('Cluster')] = this.selectedItem.cluster_id; this.data[this.i18n('Daemons')] = this.selectedItem.daemons; this.data[this.i18n('NFS Protocol')] = this.selectedItem.protocols.map( - (protocol) => 'NFSv' + protocol + (protocol: string) => 'NFSv' + protocol ); this.data[this.i18n('Pseudo')] = this.selectedItem.pseudo; this.data[this.i18n('Access Type')] = this.selectedItem.access_type; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form-client/nfs-form-client.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form-client/nfs-form-client.component.ts index 5067f5a2ba743..0c9bc088dc50c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form-client/nfs-form-client.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form-client/nfs-form-client.component.ts @@ -1,5 +1,5 @@ import { Component, Input } from '@angular/core'; -import { FormArray, FormControl, Validators } from '@angular/forms'; +import { FormArray, FormControl, NgForm, Validators } from '@angular/forms'; import { I18n } from '@ngx-translate/i18n-polyfill'; import * as _ from 'lodash'; @@ -30,7 +30,7 @@ export class NfsFormClientComponent { return this.i18n('-- Select the access type --'); } - getAccessTypeHelp(index) { + getAccessTypeHelp(index: number) { const accessTypeItem = this.nfsAccessType.find((currentAccessTypeItem) => { return this.getValue(index, 'access_type') === currentAccessTypeItem.value; }); @@ -62,16 +62,16 @@ export class NfsFormClientComponent { return fg; } - removeClient(index) { + removeClient(index: number) { const clients = this.form.get('clients') as FormArray; clients.removeAt(index); } - showError(index, control, formDir, x) { + showError(index: number, control: string, formDir: NgForm, x: string) { return (this.form.controls.clients).controls[index].showError(control, formDir, x); } - getValue(index, control) { + getValue(index: number, control: string) { const clients = this.form.get('clients') as FormArray; const client = clients.at(index) as CdFormGroup; return client.getValue(control); @@ -84,7 +84,7 @@ export class NfsFormClientComponent { }); } - trackByFn(index) { + trackByFn(index: number) { return index; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts index 5a4dbaf20058e..d152eaa96e611 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts @@ -37,8 +37,8 @@ export class NfsFormComponent implements OnInit { nfsForm: CdFormGroup; isEdit = false; - cluster_id = null; - export_id = null; + cluster_id: string = null; + export_id: string = null; isNewDirectory = false; isNewBucket = false; @@ -98,7 +98,7 @@ export class NfsFormComponent implements OnInit { } ngOnInit() { - const promises: any[] = [ + const promises: Observable[] = [ this.nfsService.daemon(), this.nfsService.fsals(), this.nfsService.clients(), @@ -128,7 +128,7 @@ export class NfsFormComponent implements OnInit { this.docsUrl = `http://docs.ceph.com/docs/${releaseName}/radosgw/nfs/`; } - getData(promises) { + getData(promises: Observable[]) { forkJoin(promises).subscribe((data: any[]) => { this.resolveDaemons(data[0]); this.resolvefsals(data[1]); @@ -175,14 +175,14 @@ export class NfsFormComponent implements OnInit { path: new FormControl(''), protocolNfsv3: new FormControl(true, { validators: [ - CdValidators.requiredIf({ protocolNfsv4: false }, (value) => { + CdValidators.requiredIf({ protocolNfsv4: false }, (value: boolean) => { return !value; }) ] }), protocolNfsv4: new FormControl(true, { validators: [ - CdValidators.requiredIf({ protocolNfsv3: false }, (value) => { + CdValidators.requiredIf({ protocolNfsv3: false }, (value: boolean) => { return !value; }) ] @@ -202,14 +202,14 @@ export class NfsFormComponent implements OnInit { }), transportUDP: new FormControl(true, { validators: [ - CdValidators.requiredIf({ transportTCP: false }, (value) => { + CdValidators.requiredIf({ transportTCP: false }, (value: boolean) => { return !value; }) ] }), transportTCP: new FormControl(true, { validators: [ - CdValidators.requiredIf({ transportUDP: false }, (value) => { + CdValidators.requiredIf({ transportUDP: false }, (value: boolean) => { return !value; }) ] @@ -223,7 +223,7 @@ export class NfsFormComponent implements OnInit { }); } - resolveModel(res) { + resolveModel(res: any) { if (res.fsal.name === 'CEPH') { res.sec_label_xattr = res.fsal.sec_label_xattr; } @@ -242,9 +242,9 @@ export class NfsFormComponent implements OnInit { res.transportUDP = res.transports.indexOf('UDP') !== -1; delete res.transports; - res.clients.forEach((client) => { + res.clients.forEach((client: any) => { let addressStr = ''; - client.addresses.forEach((address) => { + client.addresses.forEach((address: string) => { addressStr += address + ', '; }); if (addressStr.length >= 2) { @@ -258,7 +258,7 @@ export class NfsFormComponent implements OnInit { this.nfsClients.resolveModel(res.clients); } - resolveDaemons(daemons) { + resolveDaemons(daemons: Record) { daemons = _.sortBy(daemons, ['daemon_id']); this.allClusters = _(daemons) @@ -294,7 +294,7 @@ export class NfsFormComponent implements OnInit { this.allFsals.push(fsalItem); if (fsalItem.value === 'RGW') { this.rgwUserService.list().subscribe((result: any) => { - result.forEach((user) => { + result.forEach((user: Record) => { if (user.suspended === 0 && user.keys.length > 0) { this.allRgwUsers.push(user.user_id); } @@ -311,11 +311,11 @@ export class NfsFormComponent implements OnInit { } } - resolveClients(clients) { + resolveClients(clients: any[]) { this.allCephxClients = clients; } - resolveFilesystems(filesystems) { + resolveFilesystems(filesystems: any[]) { this.allFsNames = filesystems; if (filesystems.length === 1) { this.nfsForm.patchValue({ @@ -362,7 +362,7 @@ export class NfsFormComponent implements OnInit { }); } - getAccessTypeHelp(accessType) { + getAccessTypeHelp(accessType: string) { const accessTypeItem = this.nfsAccessType.find((currentAccessTypeItem) => { if (accessType === currentAccessTypeItem.value) { return currentAccessTypeItem; @@ -381,7 +381,7 @@ export class NfsFormComponent implements OnInit { return ''; } - getPathTypeahead(path) { + getPathTypeahead(path: any) { if (!_.isString(path) || path === '/') { return of([]); } @@ -475,7 +475,7 @@ export class NfsFormComponent implements OnInit { this.nfsForm.patchValue({ daemons: [] }); } - removeDaemon(index, daemon) { + removeDaemon(index: number, daemon: string) { this.daemonsSelections.forEach((value) => { if (value.name === daemon) { value.selected = false; @@ -566,7 +566,7 @@ export class NfsFormComponent implements OnInit { } delete requestModel.transportUDP; - requestModel.clients.forEach((client) => { + requestModel.clients.forEach((client: any) => { if (_.isString(client.addresses)) { client.addresses = _(client.addresses) .split(/[ ,]+/) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.spec.ts index ffda63de6298f..cbf38d72b5d3f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.spec.ts @@ -28,7 +28,7 @@ describe('NfsListComponent', () => { let nfsService: NfsService; let httpTesting: HttpTestingController; - const refresh = (data) => { + const refresh = (data: object) => { summaryService['summaryDataSource'].next(data); }; @@ -96,7 +96,7 @@ describe('NfsListComponent', () => { describe('handling of executing tasks', () => { let exports: any[]; - const addExport = (export_id) => { + const addExport = (export_id: string) => { const model = { export_id: export_id, path: 'path_' + export_id, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.ts index ea5740f1c9876..2a5c874051d88 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.ts @@ -17,6 +17,7 @@ import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { FinishedTask } from '../../../shared/models/finished-task'; import { Permission } from '../../../shared/models/permissions'; +import { Task } from '../../../shared/models/task'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; import { TaskListService } from '../../../shared/services/task-list.service'; import { TaskWrapperService } from '../../../shared/services/task-wrapper.service'; @@ -48,7 +49,7 @@ export class NfsListComponent implements OnInit, OnDestroy { modalRef: BsModalRef; builders = { - 'nfs/create': (metadata) => { + 'nfs/create': (metadata: any) => { return { path: metadata['path'], cluster_id: metadata['cluster_id'], @@ -170,8 +171,8 @@ export class NfsListComponent implements OnInit, OnDestroy { } prepareResponse(resp: any): any[] { - let result = []; - resp.forEach((nfs) => { + let result: any[] = []; + resp.forEach((nfs: any) => { nfs.id = `${nfs.cluster_id}:${nfs.export_id}`; nfs.state = 'LOADING'; result = result.concat(nfs); @@ -185,14 +186,14 @@ export class NfsListComponent implements OnInit, OnDestroy { this.viewCacheStatus = { status: ViewCacheStatus.ValueException }; } - itemFilter(entry, task) { + itemFilter(entry: any, task: Task) { return ( entry.cluster_id === task.metadata['cluster_id'] && entry.export_id === task.metadata['export_id'] ); } - taskFilter(task) { + taskFilter(task: Task) { return ['nfs/create', 'nfs/delete', 'nfs/edit'].includes(task.name); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/erasure-code-profile-form/erasure-code-profile-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/erasure-code-profile-form/erasure-code-profile-form.component.spec.ts index 1bfcd20f624a4..0ef4e37184dd1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/erasure-code-profile-form/erasure-code-profile-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/erasure-code-profile-form/erasure-code-profile-form.component.spec.ts @@ -87,7 +87,7 @@ describe('ErasureCodeProfileFormComponent', () => { }); it(`should show all default form controls`, () => { - const showDefaults = (plugin) => { + const showDefaults = (plugin: string) => { formHelper.setValue('plugin', plugin); fixtureHelper.expectIdElementsVisible( [ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/erasure-code-profile-form/erasure-code-profile-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/erasure-code-profile-form/erasure-code-profile-form.component.ts index d707bf901e6f0..614902e0c8bed 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/erasure-code-profile-form/erasure-code-profile-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/erasure-code-profile-form/erasure-code-profile-form.component.ts @@ -64,7 +64,7 @@ export class ErasureCodeProfileFormComponent implements OnInit { Validators.pattern('[A-Za-z0-9_-]+'), CdValidators.custom( 'uniqueName', - (value) => this.names && this.names.indexOf(value) !== -1 + (value: string) => this.names && this.names.indexOf(value) !== -1 ) ] ], @@ -88,7 +88,7 @@ export class ErasureCodeProfileFormComponent implements OnInit { this.form.get('plugin').valueChanges.subscribe((plugin) => this.onPluginChange(plugin)); } - onPluginChange(plugin) { + onPluginChange(plugin: string) { this.plugin = plugin; if (plugin === this.PLUGIN.JERASURE) { this.setJerasureDefaults(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts index d8c4624d4ee75..adcc50b51828e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts @@ -45,13 +45,13 @@ describe('PoolFormComponent', () => { let router: Router; let ecpService: ErasureCodeProfileService; - const setPgNum = (pgs): AbstractControl => { + const setPgNum = (pgs: number): AbstractControl => { const control = formHelper.setValue('pgNum', pgs); fixture.debugElement.query(By.css('#pgNum')).nativeElement.dispatchEvent(new Event('blur')); return control; }; - const testPgUpdate = (pgs, jump, returnValue) => { + const testPgUpdate = (pgs: number, jump: number, returnValue: number) => { if (pgs) { setPgNum(pgs); } @@ -278,7 +278,7 @@ describe('PoolFormComponent', () => { component.ngOnInit(); // Switches form into edit mode formHelper.setValue('poolType', 'erasure'); fixture.detectChanges(); - formHelper.expectValid(setPgNum('8')); + formHelper.expectValid(setPgNum(8)); }); it('is valid if pgNum, poolType and name are valid', () => { @@ -379,7 +379,7 @@ describe('PoolFormComponent', () => { }); it('validates that odd size validator works as expected', () => { - const odd = (min, max) => component['oddBlobSize'](min, max); + const odd = (min: string, max: string) => component['oddBlobSize'](min, max); expect(odd('10', '8')).toBe(true); expect(odd('8', '-')).toBe(false); expect(odd('8', '10')).toBe(false); @@ -683,7 +683,7 @@ describe('PoolFormComponent', () => { expected: 256 }); - const testPgCalc = ({ type, osds, size, ecp, expected }) => { + const testPgCalc = ({ type, osds, size, ecp, expected }: Record) => { component.info.osd_count = osds; formHelper.setValue('poolType', type); if (type === 'replicated') { @@ -813,7 +813,7 @@ describe('PoolFormComponent', () => { deletion.submitActionObservable(); }; - const testPoolDeletion = (name) => { + const testPoolDeletion = (name: string) => { setSelectedEcp(name); callDeletion(); expect(ecpService.delete).toHaveBeenCalledWith(name); @@ -848,12 +848,12 @@ describe('PoolFormComponent', () => { }); describe('submit - create', () => { - const setMultipleValues = (settings: {}) => { + const setMultipleValues = (settings: object) => { Object.keys(settings).forEach((name) => { formHelper.setValue(name, settings[name]); }); }; - const testCreate = (pool) => { + const testCreate = (pool: object) => { expectValidSubmit(pool, 'pool/create', 'create'); }; @@ -1006,7 +1006,7 @@ describe('PoolFormComponent', () => { }); describe('edit mode', () => { - const setUrl = (url) => { + const setUrl = (url: string) => { Object.defineProperty(router, 'url', { value: url }); setUpPoolComponent(); // Renew of component needed because the constructor has to be called }; @@ -1071,12 +1071,9 @@ describe('PoolFormComponent', () => { }); it('should include the custom app as valid option', () => { - expect(component.data.applications.available.map((app) => app.name)).toEqual([ - 'cephfs', - 'ownApp', - 'rbd', - 'rgw' - ]); + expect( + component.data.applications.available.map((app: Record) => app.name) + ).toEqual(['cephfs', 'ownApp', 'rbd', 'rgw']); }); it('set all control values to the given pool', () => { @@ -1105,7 +1102,8 @@ describe('PoolFormComponent', () => { }); describe('submit', () => { - const markControlAsPreviouslySet = (controlName) => form.get(controlName).markAsPristine(); + const markControlAsPreviouslySet = (controlName: string) => + form.get(controlName).markAsPristine(); beforeEach(() => { ['algorithm', 'maxBlobSize', 'minBlobSize', 'mode', 'pgNum', 'ratio', 'name'].forEach( diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts index 78784867983dc..34500296125e8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts @@ -58,7 +58,7 @@ export class PoolFormComponent implements OnInit { data = new PoolFormData(this.i18n); externalPgChange = false; private modalSubscription: Subscription; - current = { + current: Record = { rules: [] }; initializeConfigData = new EventEmitter<{ @@ -141,7 +141,7 @@ export class PoolFormComponent implements OnInit { validators: [ CdValidators.custom( 'tooFewOsds', - (rule) => this.info && rule && this.info.osd_count < rule.min_size + (rule: any) => this.info && rule && this.info.osd_count < rule.min_size ) ] }), @@ -160,7 +160,7 @@ export class PoolFormComponent implements OnInit { validators: [Validators.min(0)] }) }, - [CdValidators.custom('form', () => null)] + [CdValidators.custom('form', (): null => null)] ); } @@ -411,7 +411,7 @@ export class PoolFormComponent implements OnInit { } } - private replicatedPgCalc(pgs): number { + private replicatedPgCalc(pgs: number): number { const sizeControl = this.form.get('size'); const size = sizeControl.value; if (sizeControl.valid && size > 0) { @@ -421,7 +421,7 @@ export class PoolFormComponent implements OnInit { return undefined; } - private erasurePgCalc(pgs): number { + private erasurePgCalc(pgs: number): number { const ecpControl = this.form.get('erasureProfile'); const ecp = ecpControl.value; if ((ecpControl.valid || ecpControl.disabled) && ecp) { @@ -443,7 +443,7 @@ export class PoolFormComponent implements OnInit { this.form.get('name').validator, CdValidators.custom( 'uniqueName', - (name) => + (name: string) => this.data.pool && this.info && this.info.pool_names.indexOf(name) !== -1 && @@ -458,11 +458,11 @@ export class PoolFormComponent implements OnInit { [ CdValidators.custom( 'min', - (value) => this.form.getValue('size') && value < this.getMinSize() + (value: number) => this.form.getValue('size') && value < this.getMinSize() ), CdValidators.custom( 'max', - (value) => this.form.getValue('size') && this.getMaxSize() < value + (value: number) => this.form.getValue('size') && this.getMaxSize() < value ) ] ); @@ -472,7 +472,7 @@ export class PoolFormComponent implements OnInit { this.form.get('name').validator, CdValidators.custom( 'uniqueName', - (name) => this.info && this.info.pool_names.indexOf(name) !== -1 + (name: string) => this.info && this.info.pool_names.indexOf(name) !== -1 ) ]); } @@ -482,13 +482,13 @@ export class PoolFormComponent implements OnInit { private setCompressionValidators() { CdValidators.validateIf(this.form.get('minBlobSize'), () => this.hasCompressionEnabled(), [ Validators.min(0), - CdValidators.custom('maximum', (size) => + CdValidators.custom('maximum', (size: string) => this.oddBlobSize(size, this.form.getValue('maxBlobSize')) ) ]); CdValidators.validateIf(this.form.get('maxBlobSize'), () => this.hasCompressionEnabled(), [ Validators.min(0), - CdValidators.custom('minimum', (size) => + CdValidators.custom('minimum', (size: string) => this.oddBlobSize(this.form.getValue('minBlobSize'), size) ) ]); @@ -498,10 +498,10 @@ export class PoolFormComponent implements OnInit { ]); } - private oddBlobSize(minimum, maximum) { - minimum = this.formatter.toBytes(minimum); - maximum = this.formatter.toBytes(maximum); - return Boolean(minimum && maximum && minimum >= maximum); + private oddBlobSize(minimum: string, maximum: string) { + const min = this.formatter.toBytes(minimum); + const max = this.formatter.toBytes(maximum); + return Boolean(min && max && min >= max); } hasCompressionEnabled() { @@ -564,7 +564,7 @@ export class PoolFormComponent implements OnInit { { externalFieldName: 'pg_num', formControlName: 'pgNum', - replaceFn: (value) => (this.form.getValue('pgAutoscaleMode') === 'on' ? 1 : value), + replaceFn: (value: number) => (this.form.getValue('pgAutoscaleMode') === 'on' ? 1 : value), editable: true }, this.form.getValue('poolType') === 'replicated' @@ -603,7 +603,7 @@ export class PoolFormComponent implements OnInit { externalFieldName: 'compression_mode', formControlName: 'mode', editable: true, - replaceFn: (value) => this.hasCompressionEnabled() && value + replaceFn: (value: boolean) => this.hasCompressionEnabled() && value }, { externalFieldName: 'compression_algorithm', @@ -706,7 +706,7 @@ export class PoolFormComponent implements OnInit { pool[externalFieldName] = apiValue; } - private triggerApiTask(pool) { + private triggerApiTask(pool: Record) { this.taskWrapper .wrapTaskAroundCall({ task: new FinishedTask('pool/' + (this.editing ? URLVerbs.EDIT : URLVerbs.CREATE), { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts index e38ca50e881bb..d31eed16658f9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts @@ -32,7 +32,7 @@ describe('PoolListComponent', () => { let fixture: ComponentFixture; let poolService: PoolService; - const createPool = (name, id): Pool => { + const createPool = (name: string, id: number): Pool => { return _.merge(new Pool(name), { pool: id, pg_num: 256, @@ -149,7 +149,7 @@ describe('PoolListComponent', () => { deletion.submitActionObservable(); }; - const testPoolDeletion = (poolName) => { + const testPoolDeletion = (poolName: string) => { setSelectedPool(poolName); callDeletion(); expect(poolService.delete).toHaveBeenCalledWith(poolName); @@ -243,7 +243,7 @@ describe('PoolListComponent', () => { }); describe('getPgStatusCellClass', () => { - const testMethod = (value, expected) => + const testMethod = (value: string, expected: string) => expect(component.getPgStatusCellClass('', '', value)).toEqual({ 'text-right': true, [expected]: true @@ -271,7 +271,7 @@ describe('PoolListComponent', () => { describe('custom row comparators', () => { const expectCorrectComparator = (statsAttribute: string) => { - const mockPool = (v) => ({ stats: { [statsAttribute]: { latest: v } } }); + const mockPool = (v: number) => ({ stats: { [statsAttribute]: { latest: v } } }); const columnDefinition = _.find( component.columns, (column) => column.prop === `stats.${statsAttribute}.rates` @@ -292,7 +292,7 @@ describe('PoolListComponent', () => { describe('transformPoolsData', () => { let pool: Pool; - const getPoolData = (o) => [ + const getPoolData = (o: object) => [ _.merge( _.merge(createPool('a', 0), { cdIsBinary: true, @@ -411,7 +411,7 @@ describe('PoolListComponent', () => { }); it('returns empty string', () => { - const pgStatus = undefined; + const pgStatus: any = undefined; const expected = ''; expect(component.transformPgStatus(pgStatus)).toEqual(expected); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts index ee7cfe7a4619d..df27218ddcea6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts @@ -25,7 +25,7 @@ import { TaskWrapperService } from '../../../shared/services/task-wrapper.servic import { URLBuilderService } from '../../../shared/services/url-builder.service'; import { PgCategoryService } from '../../shared/pg-category.service'; import { Pool } from '../pool'; -import { PoolStats } from '../pool-stat'; +import { PoolStat, PoolStats } from '../pool-stat'; const BASE_URL = 'pool'; @@ -169,7 +169,7 @@ export class PoolListComponent implements OnInit { { prop: 'stats.rd_bytes.rates', name: this.i18n('Read bytes'), - comparator: (_valueA, _valueB, rowA: Pool, rowB: Pool) => + comparator: (_valueA: any, _valueB: any, rowA: Pool, rowB: Pool) => compare('stats.rd_bytes.latest', rowA, rowB), cellTransformation: CellTemplate.sparkline, flexGrow: 3 @@ -177,7 +177,7 @@ export class PoolListComponent implements OnInit { { prop: 'stats.wr_bytes.rates', name: this.i18n('Write bytes'), - comparator: (_valueA, _valueB, rowA: Pool, rowB: Pool) => + comparator: (_valueA: any, _valueB: any, rowA: Pool, rowB: Pool) => compare('stats.wr_bytes.latest', rowA, rowB), cellTransformation: CellTemplate.sparkline, flexGrow: 3 @@ -232,7 +232,7 @@ export class PoolListComponent implements OnInit { }); } - getPgStatusCellClass(_row, _column, value): object { + getPgStatusCellClass(_row: any, _column: any, value: string): object { return { 'text-right': true, [`pg-${this.pgCategoryService.getTypeByStates(value)}`]: true @@ -241,7 +241,7 @@ export class PoolListComponent implements OnInit { transformPoolsData(pools: any) { const requiredStats = ['bytes_used', 'max_avail', 'rd_bytes', 'wr_bytes', 'rd', 'wr']; - const emptyStat = { latest: 0, rate: 0, rates: [] }; + const emptyStat: PoolStat = { latest: 0, rate: 0, rates: [] }; _.forEach(pools, (pool: Pool) => { pool['pg_status'] = this.transformPgStatus(pool['pg_status']); @@ -261,7 +261,7 @@ export class PoolListComponent implements OnInit { } ['rd_bytes', 'wr_bytes'].forEach((stat) => { - pool.stats[stat].rates = pool.stats[stat].rates.map((point) => point[1]); + pool.stats[stat].rates = pool.stats[stat].rates.map((point: any) => point[1]); }); pool.cdIsBinary = true; }); @@ -270,7 +270,7 @@ export class PoolListComponent implements OnInit { } transformPgStatus(pgStatus: any): string { - const strings = []; + const strings: string[] = []; _.forEach(pgStatus, (count, state) => { strings.push(`${count} ${state}`); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.ts index 0808a89dcfe55..b822812c19a2b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.ts @@ -67,7 +67,7 @@ export class Pool { cdIsBinary?: boolean; configuration: { source: number; name: string; value: string }[]; - constructor(name) { + constructor(name: string) { this.pool_name = name; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts index 7f28e4b53d0a2..0b6358568ad6b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts @@ -20,7 +20,7 @@ describe('RgwBucketFormComponent', () => { let component: RgwBucketFormComponent; let fixture: ComponentFixture; let rgwBucketService: RgwBucketService; - let getPlacementTargetsSpy; + let getPlacementTargetsSpy: jasmine.Spy; configureTestBed({ declarations: [RgwBucketFormComponent], @@ -46,7 +46,7 @@ describe('RgwBucketFormComponent', () => { }); describe('bucketNameValidator', () => { - const testValidator = (name, valid) => { + const testValidator = (name: string, valid: boolean) => { const validatorFn = component.bucketNameValidator(); const ctrl = new FormControl(name); ctrl.markAsDirty(); @@ -136,7 +136,7 @@ describe('RgwBucketFormComponent', () => { }); it('should get zonegroup and placement targets', () => { - const payload = { + const payload: Record = { zonegroup: 'default', placement_targets: [ { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts index 685bd9e2e7da6..34437e42a65f3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts @@ -25,11 +25,11 @@ export class RgwBucketFormComponent implements OnInit { editing = false; error = false; loading = false; - owners = null; + owners: string[] = null; action: string; resource: string; zonegroup: string; - placementTargets: Object[] = []; + placementTargets: object[] = []; constructor( private route: ActivatedRoute, @@ -66,7 +66,7 @@ export class RgwBucketFormComponent implements OnInit { if (!this.editing) { // Get placement targets: - this.rgwSiteService.getPlacementTargets().subscribe((placementTargets) => { + this.rgwSiteService.getPlacementTargets().subscribe((placementTargets: any) => { this.zonegroup = placementTargets['zonegroup']; _.forEach(placementTargets['placement_targets'], (placementTarget) => { placementTarget['description'] = `${placementTarget['name']} (${this.i18n('pool')}: ${ @@ -95,7 +95,7 @@ export class RgwBucketFormComponent implements OnInit { // Get the default values. const defaults = _.clone(this.bucketForm.value); // Extract the values displayed in the form. - let value = _.pick(resp, _.keys(this.bucketForm.value)); + let value: object = _.pick(resp, _.keys(this.bucketForm.value)); value['placement-target'] = resp['placement_rule']; // Append default values. value = _.merge(defaults, value); @@ -182,19 +182,19 @@ export class RgwBucketFormComponent implements OnInit { } const constraints = []; // - Bucket names cannot be formatted as IP address. - constraints.push((name) => { + constraints.push((name: AbstractControl) => { const validatorFn = CdValidators.ip(); return !validatorFn(name); }); // - Bucket names can be between 3 and 63 characters long. - constraints.push((name) => _.inRange(name.length, 3, 64)); + constraints.push((name: string) => _.inRange(name.length, 3, 64)); // - Bucket names must not contain uppercase characters or underscores. // - Bucket names must start with a lowercase letter or number. // - Bucket names must be a series of one or more labels. Adjacent // labels are separated by a single period (.). Bucket names can // contain lowercase letters, numbers, and hyphens. Each label must // start and end with a lowercase letter or a number. - constraints.push((name) => { + constraints.push((name: string) => { const labels = _.split(name, '.'); return _.every(labels, (label) => { // Bucket names must not contain uppercase characters or underscores. @@ -211,7 +211,7 @@ export class RgwBucketFormComponent implements OnInit { }); }); }); - if (!_.every(constraints, (func) => func(control.value))) { + if (!_.every(constraints, (func: Function) => func(control.value))) { resolve({ bucketNameInvalid: true }); return; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts index ff9badf3d8977..c78754890dbc5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts @@ -38,7 +38,7 @@ export class RgwDaemonDetailsComponent implements OnChanges { if (_.isEmpty(this.serviceId)) { return; } - this.rgwDaemonService.get(this.serviceId).subscribe((resp) => { + this.rgwDaemonService.get(this.serviceId).subscribe((resp: any) => { this.metadata = resp['rgw_metadata']; }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts index d890aa902eeff..7666fc85eccfd 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts @@ -74,7 +74,7 @@ export class RgwUserCapabilityModalComponent { setCapabilities(capabilities: RgwUserCapability[]) { // Parse the configured capabilities to get a list of types that // should be displayed. - const usedTypes = []; + const usedTypes: string[] = []; capabilities.forEach((capability) => { usedTypes.push(capability.type); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts index 9fc911669cfba..12ce4da8c87e8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts @@ -195,7 +195,7 @@ export class RgwUserFormComponent implements OnInit { // Process the capabilities. const mapPerm = { 'read, write': '*' }; - resp[0].caps.forEach((cap) => { + resp[0].caps.forEach((cap: any) => { if (cap.perm in mapPerm) { cap.perm = mapPerm[cap.perm]; } @@ -278,7 +278,7 @@ export class RgwUserFormComponent implements OnInit { * Add/Update a subuser. */ setSubuser(subuser: RgwUserSubuser, index?: number) { - const mapPermissions = { + const mapPermissions: Record = { 'full-control': 'full', 'read-write': 'readwrite' }; @@ -592,7 +592,7 @@ export class RgwUserFormComponent implements OnInit { * configuration has been modified. */ private _getUpdateArgs() { - const result = {}; + const result: Record = {}; const keys = ['display_name', 'email', 'max_buckets', 'suspended']; for (const key of keys) { result[key] = this.userForm.getValue(key); @@ -604,7 +604,7 @@ export class RgwUserFormComponent implements OnInit { * Helper function to get the arguments for the API request when the user * quota configuration has been modified. */ - private _getUserQuotaArgs(): object { + private _getUserQuotaArgs(): Record { const result = { quota_type: 'user', enabled: this.userForm.getValue('user_quota_enabled'), @@ -627,7 +627,7 @@ export class RgwUserFormComponent implements OnInit { * Helper function to get the arguments for the API request when the bucket * quota configuration has been modified. */ - private _getBucketQuotaArgs(): object { + private _getBucketQuotaArgs(): Record { const result = { quota_type: 'bucket', enabled: this.userForm.getValue('bucket_quota_enabled'), diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.ts index 2626c168e2b38..d16ee7cbe8d38 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.ts @@ -16,7 +16,7 @@ export class DeviceListComponent implements OnInit { @Input() hostname = ''; @Input() - osdId = null; + osdId: number = null; @ViewChild('deviceLocation', { static: true }) locationTemplate: TemplateRef; @@ -40,7 +40,7 @@ export class DeviceListComponent implements OnInit { ) {} ngOnInit() { - const updateDevicesFn = (devices) => (this.devices = devices); + const updateDevicesFn = (devices: CdDevice[]) => (this.devices = devices); if (this.hostname) { this.hostService.getDevices(this.hostname).subscribe(updateDevicesFn); } else if (this.osdId !== null) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/pg-category.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/pg-category.service.spec.ts index 5a71c208c0836..fa185d045dda3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/pg-category.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/pg-category.service.spec.ts @@ -26,7 +26,7 @@ describe('PgCategoryService', () => { }); describe('getTypeByStates', () => { - const testMethod = (value, expected) => + const testMethod = (value: string, expected: string) => expect(service.getTypeByStates(value)).toEqual(expected); it(PgCategory.CATEGORY_CLEAN, () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/pg-category.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/pg-category.service.ts index 79c2bcc984b5d..cf77649502a59 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/pg-category.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/pg-category.service.ts @@ -52,7 +52,7 @@ export class PgCategoryService { ); } - private getPgStatesFromText(pgStatesText) { + private getPgStatesFromText(pgStatesText: string) { const pgStates = pgStatesText .replace(/[^a-z]+/g, ' ') .trim() diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/smart-list/smart-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/smart-list/smart-list.component.spec.ts index a3a6856465078..d862c5ae9eea8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/smart-list/smart-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/smart-list/smart-list.component.spec.ts @@ -2,9 +2,9 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { SimpleChange, SimpleChanges } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { TabsetComponent, TabsetConfig, TabsModule } from 'ngx-bootstrap/tabs'; import * as _ from 'lodash'; +import { TabsetComponent, TabsetConfig, TabsModule } from 'ngx-bootstrap/tabs'; import { of } from 'rxjs'; import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper'; @@ -37,7 +37,7 @@ describe('OsdSmartListComponent', () => { const patchData = (path: string, newValue: any): any => { return _.reduce( _.cloneDeep(SMART_DATA_HDD_VERSION_1_0), - (result, dataObj, deviceId) => { + (result: object, dataObj, deviceId) => { result[deviceId] = _.set(dataObj, path, newValue); return result; }, @@ -54,7 +54,7 @@ describe('OsdSmartListComponent', () => { patch: { [path: string]: any } = null, simpleChanges?: SimpleChanges ) => { - let data = null; + let data: HddSmartDataV1 | NvmeSmartDataV1; switch (dataType) { case 'hdd_v1': data = SMART_DATA_HDD_VERSION_1_0; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/smart-list/smart-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/smart-list/smart-list.component.ts index 15734e9388ad0..95281203cf519 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/smart-list/smart-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/smart-list/smart-list.component.ts @@ -1,6 +1,8 @@ import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; + import { I18n } from '@ngx-translate/i18n-polyfill'; import * as _ from 'lodash'; + import { HostService } from '../../../shared/api/host.service'; import { OsdService } from '../../../shared/api/osd.service'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; @@ -48,7 +50,7 @@ export class SmartListComponent implements OnInit, OnChanges { return _.get(data, 'device.protocol', '').toLowerCase() === 'ata'; } - private fetchData(data) { + private fetchData(data: any) { const result: { [deviceId: string]: SmartDataResult | SmartErrorResult } = {}; _.each(data, (smartData, deviceId) => { if (this.isSmartError(smartData)) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/login/login.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/login/login.component.ts index 70180ea5ebd68..db095550f550e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/login/login.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/login/login.component.ts @@ -40,7 +40,7 @@ export class LoginComponent implements OnInit { // Make sure notification sidebar is closed. this.notificationService.toggleSidebar(true); - let token = null; + let token: string = null; if (window.location.hash.indexOf('access_token=') !== -1) { token = window.location.hash.split('access_token=')[1]; const uri = window.location.toString(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-details/role-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-details/role-details.component.ts index 4a8e026877574..1ed0568f773bf 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-details/role-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-details/role-details.component.ts @@ -66,9 +66,9 @@ export class RoleDetailsComponent implements OnChanges, OnInit { if (this.selection.hasSelection) { this.selectedItem = this.selection.first(); // Build the scopes/permissions data used by the data table. - const scopes_permissions = []; + const scopes_permissions: any[] = []; _.each(this.scopes, (scope) => { - const scope_permission = { read: false, create: false, update: false, delete: false }; + const scope_permission: any = { read: false, create: false, update: false, delete: false }; scope_permission['scope'] = scope; if (scope in this.selectedItem['scopes_permissions']) { _.each(this.selectedItem['scopes_permissions'][scope], (permission) => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.spec.ts index b5d36b5861e21..10b5e3b776d72 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.spec.ts @@ -24,7 +24,7 @@ describe('RoleFormComponent', () => { let httpTesting: HttpTestingController; let roleService: RoleService; let router: Router; - const setUrl = (url) => Object.defineProperty(router, 'url', { value: url }); + const setUrl = (url: string) => Object.defineProperty(router, 'url', { value: url }); @Component({ selector: 'cd-fake', template: '' }) class FakeComponent {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.ts index 1145a86dfff9c..a5b5fb7a9123d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.ts @@ -155,10 +155,10 @@ export class RoleFormComponent implements OnInit { // Create/Update the data which is used by the data table to display the // scopes/permissions every time the form field value has been changed. this.roleForm.get('scopes_permissions').valueChanges.subscribe((value) => { - const scopes_permissions = []; + const scopes_permissions: any[] = []; _.each(this.scopes, (scope) => { // Set the defaults values. - const scope_permission = { read: false, create: false, update: false, delete: false }; + const scope_permission: any = { read: false, create: false, update: false, delete: false }; scope_permission['scope'] = scope; // Apply settings from the given value if they exist. if (scope in value) { @@ -214,7 +214,7 @@ export class RoleFormComponent implements OnInit { }); } - onClickCellCheckbox(scope: string, property: string, event: Event = null) { + onClickCellCheckbox(scope: string, property: string, event: any = null) { // Use a copy of the form field data to do not trigger the redrawing of the // data table with every change. const scopes_permissions = _.cloneDeep(this.roleForm.getValue('scopes_permissions')); @@ -241,7 +241,7 @@ export class RoleFormComponent implements OnInit { this.roleForm.get('scopes_permissions').setValue(scopes_permissions); } - onClickHeaderCheckbox(property: 'scope' | 'read' | 'create' | 'update' | 'delete', event: Event) { + onClickHeaderCheckbox(property: 'scope' | 'read' | 'create' | 'update' | 'delete', event: any) { // Use a copy of the form field data to do not trigger the redrawing of the // data table with every change. const scopes_permissions = _.cloneDeep(this.roleForm.getValue('scopes_permissions')); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-list/role-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-list/role-list.component.ts index c4bc066254b6e..8e966cbaa5672 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-list/role-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-list/role-list.component.ts @@ -160,7 +160,7 @@ export class RoleListComponent implements OnInit { ], titleText: this.i18n('Clone Role'), submitButtonText: this.i18n('Clone Role'), - onSubmit: (values) => { + onSubmit: (values: object) => { this.roleService.clone(name, values['newName']).subscribe(() => { this.getRoles(); this.notificationService.show( diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form-role.model.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form-role.model.ts index ea32b634b3ec2..9394174226527 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form-role.model.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form-role.model.ts @@ -7,7 +7,7 @@ export class UserFormRoleModel implements SelectOption { scopes_permissions: object; enabled = true; - constructor(name, description) { + constructor(name: string, description: string) { this.name = name; this.description = description; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.spec.ts index b106527aa8b8a..75489abbb4003 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.spec.ts @@ -33,7 +33,7 @@ describe('UserFormComponent', () => { let router: Router; let formHelper: FormHelper; - const setUrl = (url) => Object.defineProperty(router, 'url', { value: url }); + const setUrl = (url: string) => Object.defineProperty(router, 'url', { value: url }); @Component({ selector: 'cd-fake', template: '' }) class FakeComponent {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-tabs/user-tabs.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-tabs/user-tabs.component.ts index 16a3094dfa182..c1302a5ccc616 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-tabs/user-tabs.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-tabs/user-tabs.component.ts @@ -16,7 +16,7 @@ export class UserTabsComponent implements OnInit { this.url = this.router.url; } - navigateTo(url) { + navigateTo(url: string) { this.router.navigate([url]); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.spec.ts index ccb92d13aec46..996accd2230b1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/about/about.component.spec.ts @@ -18,7 +18,7 @@ export class SummaryServiceMock { }); summaryData$ = this.summaryDataSource.asObservable(); - subscribe(call) { + subscribe(call: any) { return this.summaryData$.subscribe(call); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/breadcrumbs/breadcrumbs.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/breadcrumbs/breadcrumbs.component.ts index 94f3c4ae48542..52a1c2ded1c08 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/breadcrumbs/breadcrumbs.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/breadcrumbs/breadcrumbs.component.ts @@ -109,7 +109,7 @@ export class BreadcrumbsComponent implements OnDestroy { } postProcess(breadcrumbs: IBreadcrumb[]) { - const result = []; + const result: IBreadcrumb[] = []; breadcrumbs.forEach((element) => { const split = element.text.split('/'); if (split.length > 1) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts index 0f1b86469c6be..cb6d0085dc91c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts @@ -15,7 +15,7 @@ import { AboutComponent } from '../about/about.component'; }) export class DashboardHelpComponent implements OnInit { @ViewChild('docsForm', { static: true }) - docsFormElement; + docsFormElement: any; docsUrl: string; modalRef: BsModalRef; icons = Icons; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.spec.ts index 8c10ed127eaa5..77becb6f91bce 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.spec.ts @@ -51,7 +51,7 @@ describe('CephfsService', () => { }); it('should call getMdsCounters', () => { - service.getMdsCounters(1).subscribe(); + service.getMdsCounters('1').subscribe(); const req = httpTesting.expectOne('api/cephfs/1/mds_counters'); expect(req.request.method).toBe('GET'); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.ts index b851610103ed1..d109ba32bc492 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.ts @@ -21,7 +21,7 @@ export class CephfsService { return this.http.get(`${this.baseURL}`); } - lsDir(id, path?): Observable { + lsDir(id: number, path?: string): Observable { let apiPath = `${this.baseURL}/${id}/ls_dir?depth=2`; if (path) { apiPath += `&path=${encodeURIComponent(path)}`; @@ -29,27 +29,27 @@ export class CephfsService { return this.http.get(apiPath); } - getCephfs(id) { + getCephfs(id: number) { return this.http.get(`${this.baseURL}/${id}`); } - getTabs(id) { + getTabs(id: number) { return this.http.get(`ui-api/cephfs/${id}/tabs`); } - getClients(id) { + getClients(id: number) { return this.http.get(`${this.baseURL}/${id}/clients`); } - evictClient(fsId, clientId) { + evictClient(fsId: number, clientId: number) { return this.http.delete(`${this.baseURL}/${fsId}/client/${clientId}`); } - getMdsCounters(id) { + getMdsCounters(id: string) { return this.http.get(`${this.baseURL}/${id}/mds_counters`); } - mkSnapshot(id, path, name?) { + mkSnapshot(id: number, path: string, name?: string) { let params = new HttpParams(); params = params.append('path', path); if (!_.isUndefined(name)) { @@ -58,14 +58,14 @@ export class CephfsService { return this.http.post(`${this.baseURL}/${id}/mk_snapshot`, null, { params }); } - rmSnapshot(id, path, name) { + rmSnapshot(id: number, path: string, name: string) { let params = new HttpParams(); params = params.append('path', path); params = params.append('name', name); return this.http.post(`${this.baseURL}/${id}/rm_snapshot`, null, { params }); } - updateQuota(id, path, quotas: CephfsQuotas) { + updateQuota(id: number, path: string, quotas: CephfsQuotas) { let params = new HttpParams(); params = params.append('path', path); return this.http.post(`${this.baseURL}/${id}/set_quotas`, quotas, { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/configuration.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/configuration.service.ts index 01d95afcf604c..68be515101db1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/configuration.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/configuration.service.ts @@ -10,14 +10,14 @@ import { ApiModule } from './api.module'; export class ConfigurationService { constructor(private http: HttpClient) {} - private findValue(config, section: string) { + private findValue(config: any, section: string) { if (!config.value) { return undefined; } - return config.value.find((v) => v.section === section); + return config.value.find((v: any) => v.section === section); } - getValue(config, section: string) { + getValue(config: any, section: string) { let val = this.findValue(config, section); if (!val) { const indexOfDot = section.indexOf('.'); @@ -54,7 +54,7 @@ export class ConfigurationService { return this.http.delete(`api/cluster_conf/${configOption}?section=${section}`); } - bulkCreate(configOptions: Object) { + bulkCreate(configOptions: object) { return this.http.put('api/cluster_conf/', configOptions); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.ts index 089a6a99d5ff7..01e432990e0e7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.ts @@ -21,11 +21,11 @@ export class HostService { return this.http.get(this.baseURL); } - add(hostname) { + add(hostname: string) { return this.http.post(this.baseURL, { hostname: hostname }, { observe: 'response' }); } - remove(hostname) { + remove(hostname: string) { return this.http.delete(`${this.baseURL}/${hostname}`, { observe: 'response' }); } @@ -35,7 +35,7 @@ export class HostService { .pipe(map((devices) => devices.map((device) => this.deviceService.prepareDevice(device)))); } - getSmartData(hostname) { + getSmartData(hostname: string) { return this.http.get(`${this.baseURL}/${hostname}/smart`); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/iscsi.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/iscsi.service.ts index 6b31eaad23e70..991b7e2e06206 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/iscsi.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/iscsi.service.ts @@ -15,11 +15,11 @@ export class IscsiService { return this.http.get(`api/iscsi/target`); } - getTarget(target_iqn) { + getTarget(target_iqn: string) { return this.http.get(`api/iscsi/target/${target_iqn}`); } - updateTarget(target_iqn, target) { + updateTarget(target_iqn: string, target: any) { return this.http.put(`api/iscsi/target/${target_iqn}`, target, { observe: 'response' }); } @@ -39,11 +39,11 @@ export class IscsiService { return this.http.get(`ui-api/iscsi/portals`); } - createTarget(target) { + createTarget(target: any) { return this.http.post(`api/iscsi/target`, target, { observe: 'response' }); } - deleteTarget(target_iqn) { + deleteTarget(target_iqn: string) { return this.http.delete(`api/iscsi/target/${target_iqn}`, { observe: 'response' }); } @@ -51,7 +51,7 @@ export class IscsiService { return this.http.get(`api/iscsi/discoveryauth`); } - updateDiscovery(auth) { + updateDiscovery(auth: any) { return this.http.put(`api/iscsi/discoveryauth`, auth); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logging.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logging.service.ts index 3ed2a17264306..7c3bdc586ec05 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logging.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logging.service.ts @@ -9,7 +9,7 @@ import { ApiModule } from './api.module'; export class LoggingService { constructor(private http: HttpClient) {} - jsError(url, message, stack) { + jsError(url: string, message: string, stack: any) { const request = { url: url, message: message, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logs.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logs.service.ts index 04dfa82a0551b..4571c37dfeb07 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logs.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logs.service.ts @@ -13,7 +13,7 @@ export class LogsService { return this.http.get('api/logs/all'); } - validateDashboardUrl(uid) { + validateDashboardUrl(uid: string) { return this.http.get(`api/grafana/validation/${uid}`); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.ts index 782ee737b76e6..ef937d8d159fd 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.ts @@ -36,7 +36,7 @@ export class MgrModuleService { * @param {object} config The configuration. * @return {Observable} */ - updateConfig(module: string, config: Object): Observable { + updateConfig(module: string, config: object): Observable { return this.http.put(`${this.url}/${module}`, { config: config }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/nfs.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/nfs.service.ts index 3ad1aadcd3c53..1a53047ecdce0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/nfs.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/nfs.service.ts @@ -57,29 +57,29 @@ export class NfsService { return this.http.get(`${this.apiPath}/export`); } - get(clusterId, exportId) { + get(clusterId: string, exportId: string) { return this.http.get(`${this.apiPath}/export/${clusterId}/${exportId}`); } - create(nfs) { + create(nfs: any) { return this.http.post(`${this.apiPath}/export`, nfs, { observe: 'response' }); } - update(clusterId, id, nfs) { + update(clusterId: string, id: string, nfs: any) { return this.http.put(`${this.apiPath}/export/${clusterId}/${id}`, nfs, { observe: 'response' }); } - delete(clusterId, exportId) { + delete(clusterId: string, exportId: string) { return this.http.delete(`${this.apiPath}/export/${clusterId}/${exportId}`, { observe: 'response' }); } - lsDir(root_dir) { + lsDir(root_dir: string) { return this.http.get(`${this.uiApiPath}/lsdir?root_dir=${root_dir}`); } - buckets(user_id) { + buckets(user_id: string) { return this.http.get(`${this.uiApiPath}/rgw/buckets?user_id=${user_id}`); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts index 0994ba5b223fc..2a03ea66c655e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts @@ -83,7 +83,7 @@ export class OsdService { return this.http.get(`${this.path}/${id}/smart`); } - scrub(id, deep) { + scrub(id: string, deep: boolean) { return this.http.post(`${this.path}/${id}/scrub?deep=${deep}`, null); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts index 5cf4207a05bab..49c6816faee0f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts @@ -22,7 +22,7 @@ export class PerformanceCounterService { get(service_type: string, service_id: string) { return this.http.get(`${this.url}/${service_type}/${service_id}`).pipe( - mergeMap((resp) => { + mergeMap((resp: any) => { return observableOf(resp['counters']); }) ); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.ts index 8d81b3167afbc..4d85ec483374f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.ts @@ -18,11 +18,11 @@ export class PoolService { constructor(private http: HttpClient, private rbdConfigurationService: RbdConfigurationService) {} - create(pool) { + create(pool: any) { return this.http.post(this.apiPath, pool, { observe: 'response' }); } - update(pool) { + update(pool: any) { let name: string; if (pool.hasOwnProperty('srcpool')) { name = pool.srcpool; @@ -36,11 +36,11 @@ export class PoolService { }); } - delete(name) { + delete(name: string) { return this.http.delete(`${this.apiPath}/${name}`, { observe: 'response' }); } - get(poolName) { + get(poolName: string) { return this.http.get(`${this.apiPath}/${poolName}`); } @@ -63,7 +63,7 @@ export class PoolService { return this.http.get(`${this.apiPath}/_info` + (pool_name ? `?pool_name=${pool_name}` : '')); } - list(attrs = []) { + list(attrs: string[] = []) { const attrsStr = attrs.join(','); return this.http .get(`${this.apiPath}?attrs=${attrsStr}`) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.spec.ts index 93e3c43c0c896..b7e4e565ac057 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.spec.ts @@ -162,7 +162,7 @@ describe('PrometheusService', () => { describe('ifAlertmanagerConfigured', () => { let x: any; - let host; + let host: string; const receiveConfig = () => { const req = httpTesting.expectOne('api/settings/alertmanager-api-host'); @@ -200,7 +200,7 @@ describe('PrometheusService', () => { describe('ifPrometheusConfigured', () => { let x: any; - let host; + let host: string; const receiveConfig = () => { const req = httpTesting.expectOne('api/settings/prometheus-api-host'); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts index 08e8f6147a5cb..7b56161d4cfba 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts @@ -25,7 +25,7 @@ export class PrometheusService { constructor(private http: HttpClient, private settingsService: SettingsService) {} - ifAlertmanagerConfigured(fn, elseFn?): void { + ifAlertmanagerConfigured(fn: (value?: string) => void, elseFn?: () => void): void { this.settingsService.ifSettingConfigured(this.settingsKey.alertmanager, fn, elseFn); } @@ -33,7 +33,7 @@ export class PrometheusService { this.settingsService.disableSetting(this.settingsKey.alertmanager); } - ifPrometheusConfigured(fn, elseFn?): void { + ifPrometheusConfigured(fn: (value?: string) => void, elseFn?: () => void): void { this.settingsService.ifSettingConfigured(this.settingsKey.prometheus, fn, elseFn); } @@ -65,7 +65,7 @@ export class PrometheusService { } setSilence(silence: AlertmanagerSilence) { - return this.http.post(`${this.baseURL}/silence`, silence, { observe: 'response' }); + return this.http.post(`${this.baseURL}/silence`, silence, { observe: 'response' }); } expireSilence(silenceId: string) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.spec.ts index 03f6b9d6557d3..5bd9abad2e204 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.spec.ts @@ -8,7 +8,7 @@ describe('RbdMirroringService', () => { let service: RbdMirroringService; let httpTesting: HttpTestingController; - const summary = { + const summary: Record = { status: 0, content_data: { daemons: [], @@ -46,7 +46,7 @@ describe('RbdMirroringService', () => { }); it('should periodically poll summary', fakeAsync(() => { - const calledWith = []; + const calledWith: any[] = []; service.subscribeSummary((data) => { calledWith.push(data); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts index 0dd04e9798e99..d32b09487e867 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts @@ -54,11 +54,11 @@ export class RbdMirroringService { return this.summaryData$.subscribe(next, error); } - getPool(poolName) { + getPool(poolName: string) { return this.http.get(`api/block/mirroring/pool/${poolName}`); } - updatePool(poolName, request) { + updatePool(poolName: string, request: any) { return this.http.put(`api/block/mirroring/pool/${poolName}`, request, { observe: 'response' }); } @@ -66,7 +66,7 @@ export class RbdMirroringService { return this.http.get(`api/block/mirroring/site_name`); } - setSiteName(@cdEncodeNot siteName) { + setSiteName(@cdEncodeNot siteName: string) { return this.http.put( `api/block/mirroring/site_name`, { site_name: siteName }, @@ -74,11 +74,15 @@ export class RbdMirroringService { ); } - createBootstrapToken(poolName) { + createBootstrapToken(poolName: string) { return this.http.post(`api/block/mirroring/pool/${poolName}/bootstrap/token`, {}); } - importBootstrapToken(poolName, @cdEncodeNot direction, @cdEncodeNot token) { + importBootstrapToken( + poolName: string, + @cdEncodeNot direction: string, + @cdEncodeNot token: string + ) { const request = { direction: direction, token: token @@ -88,23 +92,23 @@ export class RbdMirroringService { }); } - getPeer(poolName, peerUUID) { + getPeer(poolName: string, peerUUID: string) { return this.http.get(`api/block/mirroring/pool/${poolName}/peer/${peerUUID}`); } - addPeer(poolName, request) { + addPeer(poolName: string, request: any) { return this.http.post(`api/block/mirroring/pool/${poolName}/peer`, request, { observe: 'response' }); } - updatePeer(poolName, peerUUID, request) { + updatePeer(poolName: string, peerUUID: string, request: any) { return this.http.put(`api/block/mirroring/pool/${poolName}/peer/${peerUUID}`, request, { observe: 'response' }); } - deletePeer(poolName, peerUUID) { + deletePeer(poolName: string, peerUUID: string) { return this.http.delete(`api/block/mirroring/pool/${poolName}/peer/${peerUUID}`, { observe: 'response' }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts index fb2497a8395a6..5a3a8747e9a3e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts @@ -17,11 +17,11 @@ import { RbdPool } from './rbd.model'; export class RbdService { constructor(private http: HttpClient, private rbdConfigurationService: RbdConfigurationService) {} - isRBDPool(pool) { + isRBDPool(pool: any) { return _.indexOf(pool.application_metadata, 'rbd') !== -1 && !pool.pool_name.includes('/'); } - create(rbd) { + create(rbd: any) { return this.http.post('api/block/image', rbd, { observe: 'response' }); } @@ -31,7 +31,7 @@ export class RbdService { }); } - update(imageSpec: ImageSpec, rbd) { + update(imageSpec: ImageSpec, rbd: any) { return this.http.put(`api/block/image/${imageSpec.toStringEncoded()}`, rbd, { observe: 'response' }); @@ -60,7 +60,7 @@ export class RbdService { ); } - copy(imageSpec: ImageSpec, rbd) { + copy(imageSpec: ImageSpec, rbd: any) { return this.http.post(`api/block/image/${imageSpec.toStringEncoded()}/copy`, rbd, { observe: 'response' }); @@ -76,7 +76,7 @@ export class RbdService { return this.http.get('api/block/image/default_features'); } - createSnapshot(imageSpec: ImageSpec, @cdEncodeNot snapshotName) { + createSnapshot(imageSpec: ImageSpec, @cdEncodeNot snapshotName: string) { const request = { snapshot_name: snapshotName }; @@ -85,7 +85,7 @@ export class RbdService { }); } - renameSnapshot(imageSpec: ImageSpec, snapshotName, @cdEncodeNot newSnapshotName) { + renameSnapshot(imageSpec: ImageSpec, snapshotName: string, @cdEncodeNot newSnapshotName: string) { const request = { new_snap_name: newSnapshotName }; @@ -98,7 +98,7 @@ export class RbdService { ); } - protectSnapshot(imageSpec: ImageSpec, snapshotName, @cdEncodeNot isProtected) { + protectSnapshot(imageSpec: ImageSpec, snapshotName: string, @cdEncodeNot isProtected: boolean) { const request = { is_protected: isProtected }; @@ -111,7 +111,7 @@ export class RbdService { ); } - rollbackSnapshot(imageSpec: ImageSpec, snapshotName) { + rollbackSnapshot(imageSpec: ImageSpec, snapshotName: string) { return this.http.post( `api/block/image/${imageSpec.toStringEncoded()}/snap/${snapshotName}/rollback`, null, @@ -119,7 +119,7 @@ export class RbdService { ); } - cloneSnapshot(imageSpec: ImageSpec, snapshotName, request) { + cloneSnapshot(imageSpec: ImageSpec, snapshotName: string, request: any) { return this.http.post( `api/block/image/${imageSpec.toStringEncoded()}/snap/${snapshotName}/clone`, request, @@ -127,7 +127,7 @@ export class RbdService { ); } - deleteSnapshot(imageSpec: ImageSpec, snapshotName) { + deleteSnapshot(imageSpec: ImageSpec, snapshotName: string) { return this.http.delete(`api/block/image/${imageSpec.toStringEncoded()}/snap/${snapshotName}`, { observe: 'response' }); @@ -137,24 +137,24 @@ export class RbdService { return this.http.get(`api/block/image/trash/`); } - createNamespace(pool, namespace) { + createNamespace(pool: string, namespace: string) { const request = { namespace: namespace }; return this.http.post(`api/block/pool/${pool}/namespace`, request, { observe: 'response' }); } - listNamespaces(pool) { + listNamespaces(pool: string) { return this.http.get(`api/block/pool/${pool}/namespace/`); } - deleteNamespace(pool, namespace) { + deleteNamespace(pool: string, namespace: string) { return this.http.delete(`api/block/pool/${pool}/namespace/${namespace}`, { observe: 'response' }); } - moveTrash(imageSpec: ImageSpec, delay) { + moveTrash(imageSpec: ImageSpec, delay: number) { return this.http.post( `api/block/image/${imageSpec.toStringEncoded()}/move_trash`, { delay: delay }, @@ -162,7 +162,7 @@ export class RbdService { ); } - purgeTrash(poolName) { + purgeTrash(poolName: string) { return this.http.post(`api/block/image/trash/purge/?pool_name=${poolName}`, null, { observe: 'response' }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts index 25891d2649af9..b58c15dffb455 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts @@ -56,7 +56,7 @@ export class RgwUserService { return this.http.get(`${this.url}/${uid}/quota`); } - create(args: object) { + create(args: Record) { let params = new HttpParams(); _.keys(args).forEach((key) => { params = params.append(key, args[key]); @@ -64,7 +64,7 @@ export class RgwUserService { return this.http.post(this.url, null, { params: params }); } - update(uid: string, args: object) { + update(uid: string, args: Record) { let params = new HttpParams(); _.keys(args).forEach((key) => { params = params.append(key, args[key]); @@ -72,7 +72,7 @@ export class RgwUserService { return this.http.put(`${this.url}/${uid}`, null, { params: params }); } - updateQuota(uid: string, args: object) { + updateQuota(uid: string, args: Record) { let params = new HttpParams(); _.keys(args).forEach((key) => { params = params.append(key, args[key]); @@ -84,7 +84,7 @@ export class RgwUserService { return this.http.delete(`${this.url}/${uid}`); } - createSubuser(uid: string, args: object) { + createSubuser(uid: string, args: Record) { let params = new HttpParams(); _.keys(args).forEach((key) => { params = params.append(key, args[key]); @@ -110,7 +110,7 @@ export class RgwUserService { return this.http.delete(`${this.url}/${uid}/capability`, { params: params }); } - addS3Key(uid: string, args: object) { + addS3Key(uid: string, args: Record) { let params = new HttpParams(); params = params.append('key_type', 's3'); _.keys(args).forEach((key) => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.spec.ts index 122f2691cfcd1..979671b3f9318 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.spec.ts @@ -39,7 +39,7 @@ describe('SettingsService', () => { }); describe('getSettingsValue', () => { - const testMethod = (data, expected: string) => { + const testMethod = (data: object, expected: string) => { expect(service['getSettingsValue'](data)).toBe(expected); }; @@ -65,7 +65,7 @@ describe('SettingsService', () => { describe('isSettingConfigured', () => { let increment: number; - const testConfig = (url, value) => { + const testConfig = (url: string, value: string) => { service.ifSettingConfigured( url, (setValue) => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.ts index 75b88c61d266a..7d591542a6990 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.ts @@ -38,7 +38,7 @@ export class SettingsService { } // Easiest way to stop reloading external content that can't be reached - disableSetting(url) { + disableSetting(url: string) { this.settings[url] = ''; } @@ -46,7 +46,7 @@ export class SettingsService { return data.value || data.instance || ''; } - validateGrafanaDashboardUrl(uid) { + validateGrafanaDashboardUrl(uid: string) { return this.http.get(`api/grafana/validation/${uid}`); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/user.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/user.service.ts index 9e23bd0cbcdea..05c53de0cca22 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/user.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/user.service.ts @@ -30,7 +30,7 @@ export class UserService { return this.http.put(`api/user/${user.username}`, user); } - changePassword(username, oldPassword, newPassword) { + changePassword(username: string, oldPassword: string, newPassword: string) { // Note, the specified user MUST be logged in to be able to change // the password. The backend ensures that the password of another // user can not be changed, otherwise an error will be thrown. diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.component.spec.ts index bc2d1ce330398..89019bf1d69a2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.component.spec.ts @@ -30,7 +30,7 @@ describe('ConfigOptionComponent', () => { fixture.detectChanges(); configurationService = TestBed.get(ConfigurationService); - const configOptions = [ + const configOptions: Record = [ { name: 'osd_scrub_auto_repair_num_errors', type: 'uint', diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.component.ts index 3c28b82761beb..7778deccb3cc5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.component.ts @@ -58,7 +58,7 @@ export class ConfigOptionComponent implements OnInit { private loadStoredData() { this.configService.filter(this.optionNames).subscribe((data: any) => { - this.options = data.map((configOption) => { + this.options = data.map((configOption: any) => { const formControl = this.optionsForm.get(configOption.name); const typeValidators = ConfigOptionTypes.getTypeValidators(configOption); configOption.additionalTypeInfo = ConfigOptionTypes.getType(configOption.type); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.types.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.types.ts index cfe1b4747f340..eb1bce5748d22 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.types.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/config-option/config-option.types.ts @@ -89,7 +89,10 @@ export class ConfigOptionTypes { return; } - const typeValidators = { validators: [], patternHelpText: typeParams.patternHelpText }; + const typeValidators: Record = { + validators: [], + patternHelpText: typeParams.patternHelpText + }; if (typeParams.isNumberType) { if (configOption.max && configOption.max !== '') { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.spec.ts index ece9a5305ec79..f25c1ecdcd944 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.spec.ts @@ -38,7 +38,7 @@ class MockComponent { // Normally private, but public is needed by tests constructor(public modalService: BsModalService) {} - private openModal(extendBaseState: object = {}) { + private openModal(extendBaseState = {}) { this.modalRef = this.modalService.show(ConfirmationModalComponent, { initialState: Object.assign( { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.ts index 23a1bf1bc59db..87383eedff3d7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.ts @@ -32,7 +32,7 @@ export class ConfirmationModalComponent implements OnInit, OnDestroy { constructor(public modalRef: BsModalRef, private modalService: BsModalService) { this.confirmationForm = new FormGroup({}); - this.onHide = this.modalService.onHide.subscribe((e) => { + this.onHide = this.modalService.onHide.subscribe((e: any) => { if (this.onCancel && (e || this.canceled)) { this.onCancel(); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component.spec.ts index faf48936bcfbc..adcb95632cd4c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component.spec.ts @@ -151,7 +151,7 @@ describe('CriticalConfirmationModalComponent', () => { }); describe('component functions', () => { - const changeValue = (value) => { + const changeValue = (value: boolean) => { const ctrl = component.deletionForm.get('confirmation'); ctrl.setValue(value); ctrl.markAsDirty(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-modal/form-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-modal/form-modal.component.spec.ts index 48dfb26fda8db..227076c1bdb0c 100755 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-modal/form-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-modal/form-modal.component.spec.ts @@ -20,7 +20,7 @@ describe('InputModalComponent', () => { let fixture: ComponentFixture; let fh: FixtureHelper; let formHelper: FormHelper; - let submitted; + let submitted: object; const initialState = { titleText: 'Some title', @@ -48,7 +48,7 @@ describe('InputModalComponent', () => { } ], submitButtonText: 'Submit button name', - onSubmit: (values) => (submitted = values) + onSubmit: (values: object) => (submitted = values) }; configureTestBed({ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-modal/form-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-modal/form-modal.component.ts index 6488819edbbbc..7bc5d06b7caf5 100755 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-modal/form-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-modal/form-modal.component.ts @@ -5,10 +5,10 @@ import { I18n } from '@ngx-translate/i18n-polyfill'; import * as _ from 'lodash'; import { BsModalRef } from 'ngx-bootstrap/modal'; -import { DimlessBinaryPipe } from 'app/shared/pipes/dimless-binary.pipe'; import { CdFormBuilder } from '../../forms/cd-form-builder'; import { CdFormGroup } from '../../forms/cd-form-group'; import { CdFormModalFieldConfig } from '../../models/cd-form-modal-field-config'; +import { DimlessBinaryPipe } from '../../pipes/dimless-binary.pipe'; import { FormatterService } from '../../services/formatter.service'; @Component({ @@ -40,7 +40,7 @@ export class FormModalComponent implements OnInit { } createForm() { - const controlsConfig = {}; + const controlsConfig: Record = {}; this.fields.forEach((field) => { controlsConfig[field.name] = this.createFormControl(field); }); @@ -94,7 +94,7 @@ export class FormModalComponent implements OnInit { return this.i18n('An error occurred.'); } - onSubmitForm(values) { + onSubmitForm(values: any) { const binaries = this.fields .filter((field) => field.type === 'binary') .map((field) => field.name); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.ts index a813653ee9e77..4c4b5ecedfa2d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.ts @@ -24,7 +24,7 @@ export class GrafanaComponent implements OnInit, OnChanges { grafanaExist = false; mode = '&kiosk'; loading = true; - styles = {}; + styles: Record = {}; dashboardExist = true; time: string; grafanaTimes: any; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.spec.ts index a39868046c182..3eb95c9bbb493 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.spec.ts @@ -34,7 +34,7 @@ describe('LanguageSelectorComponent', () => { expect(listLocales()).toEqual([]); }); - const expectLanguageChange = (lang) => { + const expectLanguageChange = (lang: string) => { component.changeLanguage(lang); const cookie = document.cookie.split(';').filter((item) => item.includes(`cd-lang=${lang}`)); expect(cookie.length).toBe(1); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.ts index 032ae4207a668..b696405cafe06 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.ts @@ -16,7 +16,7 @@ export class LanguageSelectorComponent implements OnInit { @Input() isDropdown = true; - supportedLanguages: Object = SupportedLanguages; + supportedLanguages: Record = SupportedLanguages; selectedLanguage: string; constructor(private localeService: BsLocaleService, private languageService: LanguageService) {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/notifications-sidebar/notifications-sidebar.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/notifications-sidebar/notifications-sidebar.component.ts index 59ce5963ec48a..7bb1624b3219a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/notifications-sidebar/notifications-sidebar.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/notifications-sidebar/notifications-sidebar.component.ts @@ -130,7 +130,7 @@ export class NotificationsSidebarComponent implements OnInit, OnDestroy { this.notificationService.toggleSidebar(true); } - trackByFn(index) { + trackByFn(index: number) { return index; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select-badges/select-badges.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select-badges/select-badges.component.ts index 5348a5d5973bc..9c4e381aa9b30 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select-badges/select-badges.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select-badges/select-badges.component.ts @@ -6,6 +6,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'; import { Icons } from '../../../shared/enum/icons.enum'; import { SelectMessages } from '../select/select-messages.model'; import { SelectOption } from '../select/select-option.model'; +import { SelectComponent } from '../select/select.component'; @Component({ selector: 'cd-select-badges', @@ -30,7 +31,7 @@ export class SelectBadgesComponent { selection = new EventEmitter(); @ViewChild('cdSelect', { static: true }) - cdSelect; + cdSelect: SelectComponent; icons = Icons; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/sparkline/sparkline.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/sparkline/sparkline.component.ts index d863199dd58d3..3a477f06589dd 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/sparkline/sparkline.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/sparkline/sparkline.component.ts @@ -36,7 +36,7 @@ export class SparklineComponent implements OnInit, OnChanges { } ]; - options = { + options: Record = { animation: { duration: 0 }, @@ -56,7 +56,7 @@ export class SparklineComponent implements OnInit, OnChanges { intersect: false, custom: undefined, callbacks: { - label: (tooltipItem) => { + label: (tooltipItem: any) => { if (this.isBinary) { return this.dimlessBinaryPipe.transform(tooltipItem.yLabel); } else { @@ -91,11 +91,11 @@ export class SparklineComponent implements OnInit, OnChanges { constructor(private dimlessBinaryPipe: DimlessBinaryPipe) {} ngOnInit() { - const getStyleTop = (tooltip) => { + const getStyleTop = (tooltip: any) => { return tooltip.caretY - tooltip.height - tooltip.yPadding - 5 + 'px'; }; - const getStyleLeft = (tooltip, positionX) => { + const getStyleLeft = (tooltip: any, positionX: number) => { return positionX + tooltip.caretX + 'px'; }; @@ -111,7 +111,7 @@ export class SparklineComponent implements OnInit, OnChanges { borderColor: this.colors[0].pointBorderColor }; - this.options.tooltips.custom = (tooltip) => { + this.options.tooltips.custom = (tooltip: any) => { chartTooltip.customTooltips(tooltip); }; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/submit-button/submit-button.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/submit-button/submit-button.component.ts index 9e9f75f04f657..5d62b892dd6ac 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/submit-button/submit-button.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/submit-button/submit-button.component.ts @@ -55,7 +55,7 @@ export class SubmitButtonComponent implements OnInit { }); } - submit($event) { + submit($event: any) { this.focusButton(); // Special handling for Template driven forms. diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.spec.ts index 4b6e109a03608..90511da46f5cc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.spec.ts @@ -43,11 +43,12 @@ describe('TableKeyValueComponent', () => { it('should make key value object pairs out of arrays with length two', () => { component.data = [['someKey', 0], ['arrayKey', [1, 2, 3]], [3, 'something']]; component.ngOnInit(); - expect(component.tableData).toEqual([ + const expected: any = [ { key: 'arrayKey', value: '1, 2, 3' }, { key: 'someKey', value: 0 }, { key: 3, value: 'something' } - ]); + ]; + expect(component.tableData).toEqual(expected); }); it('should not show data supposed to be have hidden by key', () => { @@ -60,7 +61,7 @@ describe('TableKeyValueComponent', () => { it('should remove items with objects as values', () => { component.data = [[3, 'something'], ['will be removed', { a: 3, b: 4, c: 5 }]]; component.ngOnInit(); - expect(component.tableData).toEqual([{ key: 3, value: 'something' }]); + expect(component.tableData).toEqual([{ key: 3, value: 'something' }]); }); it('makes key value object pairs out of an object', () => { @@ -88,7 +89,7 @@ describe('TableKeyValueComponent', () => { }); it('tests makePairs()', () => { - const makePairs = (data) => component['makePairs'](data); + const makePairs = (data: any) => component['makePairs'](data); expect(makePairs([['dash', 'board']])).toEqual([{ key: 'dash', value: 'board' }]); const pair = [{ key: 'dash', value: 'board' }, { key: 'ceph', value: 'mimic' }]; const pairInverse = [{ key: 'ceph', value: 'mimic' }, { key: 'dash', value: 'board' }]; @@ -98,14 +99,14 @@ describe('TableKeyValueComponent', () => { }); it('tests makePairsFromArray()', () => { - const makePairsFromArray = (data) => component['makePairsFromArray'](data); + const makePairsFromArray = (data: any[]) => component['makePairsFromArray'](data); expect(makePairsFromArray([['dash', 'board']])).toEqual([{ key: 'dash', value: 'board' }]); const pair = [{ key: 'dash', value: 'board' }, { key: 'ceph', value: 'mimic' }]; expect(makePairsFromArray(pair)).toEqual(pair); }); it('tests makePairsFromObject()', () => { - const makePairsFromObject = (data) => component['makePairsFromObject'](data); + const makePairsFromObject = (data: object) => component['makePairsFromObject'](data); expect(makePairsFromObject({ dash: 'board' })).toEqual([{ key: 'dash', value: 'board' }]); expect(makePairsFromObject({ dash: 'board', ceph: 'mimic' })).toEqual([ { key: 'dash', value: 'board' }, @@ -114,8 +115,8 @@ describe('TableKeyValueComponent', () => { }); describe('tests convertValue()', () => { - const convertValue = (data) => component['convertValue'](data); - const expectConvertValue = (value, expectation) => + const convertValue = (data: any) => component['convertValue'](data); + const expectConvertValue = (value: any, expectation: any) => expect(convertValue(value)).toBe(expectation); it('should not convert strings', () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.ts index b3b4acd2cb3a1..38bd942b20ae4 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.ts @@ -49,11 +49,11 @@ export class TableKeyValueComponent implements OnInit, OnChanges { @Input() hideEmpty = false; @Input() - hideKeys = []; // Keys of pairs not to be displayed + hideKeys: string[] = []; // Keys of pairs not to be displayed // If set, the classAddingTpl is used to enable different css for different values @Input() - customCss?: { [css: string]: number | string | ((any) => boolean) }; + customCss?: { [css: string]: number | string | ((any: any) => boolean) }; columns: Array = []; tableData: KeyValueItem[]; @@ -130,7 +130,7 @@ export class TableKeyValueComponent implements OnInit, OnChanges { } private makePairsFromArray(data: any[]): KeyValueItem[] { - let temp = []; + let temp: any[] = []; const first = data[0]; if (_.isArray(first)) { if (first.length === 2) { @@ -157,7 +157,7 @@ export class TableKeyValueComponent implements OnInit, OnChanges { return temp; } - private makePairsFromObject(data: object): KeyValueItem[] { + private makePairsFromObject(data: any): KeyValueItem[] { return Object.keys(data).map((k) => ({ key: k, value: data[k] @@ -215,7 +215,7 @@ export class TableKeyValueComponent implements OnInit, OnChanges { return value; } - private isDate(s) { + private isDate(s: string) { const sep = '[ -:.TZ]'; const n = '\\d{2}' + sep; // year - m - d - h : m : s . someRest Z (if UTC) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts index c4d9fc9b5fed0..e87467396733d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts @@ -17,7 +17,7 @@ describe('TableComponent', () => { let component: TableComponent; let fixture: ComponentFixture; - const createFakeData = (n) => { + const createFakeData = (n: number) => { const data = []; for (let i = 0; i < n; i++) { data.push({ @@ -413,7 +413,7 @@ describe('TableComponent', () => { }); describe('after ngInit', () => { - const toggleColumn = (prop, checked) => { + const toggleColumn = (prop: string, checked: boolean) => { component.toggleColumn({ target: { name: prop, @@ -491,7 +491,7 @@ describe('TableComponent', () => { }); it('should call fetchData callback function', () => { - component.fetchData.subscribe((context) => { + component.fetchData.subscribe((context: any) => { expect(context instanceof CdTableFetchDataContext).toBeTruthy(); }); component.reloadData(); @@ -499,7 +499,7 @@ describe('TableComponent', () => { it('should call error function', () => { component.data = createFakeData(5); - component.fetchData.subscribe((context) => { + component.fetchData.subscribe((context: any) => { context.error(); expect(component.loadingError).toBeTruthy(); expect(component.data.length).toBe(0); @@ -511,7 +511,7 @@ describe('TableComponent', () => { it('should call error function with custom config', () => { component.data = createFakeData(10); - component.fetchData.subscribe((context) => { + component.fetchData.subscribe((context: any) => { context.errorConfig.resetData = false; context.errorConfig.displayError = false; context.error(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts index cbde65c4aff55..371893692dd2e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts @@ -23,7 +23,7 @@ import { } from '@swimlane/ngx-datatable'; import { getterForProp } from '@swimlane/ngx-datatable/release/utils'; import * as _ from 'lodash'; -import { Observable, timer as observableTimer } from 'rxjs'; +import { Observable, Subject, Subscription, timer as observableTimer } from 'rxjs'; import { Icons } from '../../../shared/enum/icons.enum'; import { CellTemplate } from '../../enum/cell-template.enum'; @@ -124,7 +124,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O // Only needed to set if the classAddingTpl is used @Input() - customCss?: { [css: string]: number | string | ((any) => boolean) }; + customCss?: { [css: string]: number | string | ((any: any) => boolean) }; // Columns that aren't displayed but can be used as filters @Input() @@ -174,7 +174,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O [key: string]: TemplateRef; } = {}; search = ''; - rows = []; + rows: any[] = []; loadingIndicator = true; loadingError = false; paginationClasses = { @@ -186,8 +186,8 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O userConfig: CdUserConfig = {}; tableName: string; localStorage = window.localStorage; - private saveSubscriber; - private reloadSubscriber; + private saveSubscriber: Subscription; + private reloadSubscriber: Subscription; private updating = false; // Internal variable to check if it is necessary to recalculate the @@ -291,8 +291,8 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O } } - _calculateUniqueTableName(columns) { - const stringToNumber = (s) => { + _calculateUniqueTableName(columns: any[]) { + const stringToNumber = (s: string) => { if (!_.isString(s)) { return 0; } @@ -319,13 +319,13 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O } _initUserConfigAutoSave() { - const source = Observable.create(this._initUserConfigProxy.bind(this)); + const source: Observable = Observable.create(this._initUserConfigProxy.bind(this)); this.saveSubscriber = source.subscribe(this._saveUserConfig.bind(this)); } - _initUserConfigProxy(observer) { + _initUserConfigProxy(observer: Subject) { this.userConfig = new Proxy(this.userConfig, { - set(config, prop, value) { + set(config, prop: string, value) { config[prop] = value; observer.next(config); return true; @@ -333,7 +333,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O }); } - _saveUserConfig(config) { + _saveUserConfig(config: any) { this.localStorage.setItem(this.tableName, JSON.stringify(config)); } @@ -430,7 +430,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O doColumnFiltering() { const appliedFilters: CdTableColumnFiltersChange['filters'] = []; let data = [...this.data]; - let dataOut = []; + let dataOut: any[] = []; this.columnFilters.forEach((filter) => { if (filter.value === undefined) { return; @@ -528,7 +528,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O this.useData(); } - setLimit(e) { + setLimit(e: any) { const value = parseInt(e.target.value, 10); if (value > 0) { this.userConfig.limit = value; @@ -560,7 +560,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O } rowIdentity() { - return (row) => { + return (row: any) => { const id = row[this.identifier]; if (_.isUndefined(id)) { throw new Error(`Wrong identifier "${this.identifier}" -> "${id}"`); @@ -598,7 +598,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O if (this.updateSelectionOnRefresh === 'never') { return; } - const newSelected = []; + const newSelected: any[] = []; this.selection.selected.forEach((selectedItem) => { for (const row of this.data) { if (selectedItem[this.identifier] === row[this.identifier]) { @@ -616,7 +616,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O this.onSelect(this.selection); } - onSelect($event) { + onSelect($event: any) { this.selection.selected = $event['selected']; this.updateSelection.emit(_.clone(this.selection)); } @@ -652,7 +652,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O ]; } - changeSorting({ sorts }) { + changeSorting({ sorts }: any) { this.userConfig.sorts = sorts; } @@ -683,7 +683,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O this.rows = rows; } - subSearch(data: any[], currentSearch: string[], columns: CdTableColumn[]) { + subSearch(data: any[], currentSearch: string[], columns: CdTableColumn[]): any[] { if (currentSearch.length === 0 || data.length === 0) { return data; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts index a4aa06c244514..1c8dc15c5f03d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts @@ -31,7 +31,7 @@ export function cdEncode(...args: any[]): any { * @param {string} propertyKey * @param {number} index */ -export function cdEncodeNot(target: Object, propertyKey: string, index: number) { +export function cdEncodeNot(target: object, propertyKey: string, index: number) { const metadataKey = `__ignore_${propertyKey}`; if (Array.isArray(target[metadataKey])) { target[metadataKey].push(index); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/dimless-binary-per-second.directive.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/dimless-binary-per-second.directive.ts index 6355fd74cd575..011439248fa61 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/dimless-binary-per-second.directive.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/dimless-binary-per-second.directive.ts @@ -93,7 +93,7 @@ export class DimlessBinaryPerSecondDirective implements OnInit { } } - setValue(value) { + setValue(value: string) { if (/^[\d.]+$/.test(value)) { value += this.defaultUnit || 'm'; } @@ -109,7 +109,7 @@ export class DimlessBinaryPerSecondDirective implements OnInit { } } - round(size) { + round(size: number) { if (size !== null && size !== 0) { if (!_.isUndefined(this.minBytes) && size < this.minBytes) { return this.minBytes; @@ -126,7 +126,7 @@ export class DimlessBinaryPerSecondDirective implements OnInit { } @HostListener('blur', ['$event.target.value']) - onBlur(value) { + onBlur(value: string) { this.setValue(value); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/dimless-binary.directive.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/dimless-binary.directive.ts index efe7e8da2f2bb..cda47925cc862 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/dimless-binary.directive.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/dimless-binary.directive.ts @@ -83,7 +83,7 @@ export class DimlessBinaryDirective implements OnInit { this.setValue(this.el.value); } - setValue(value) { + setValue(value: string) { if (/^[\d.]+$/.test(value)) { value += this.defaultUnit || 'm'; } @@ -99,7 +99,7 @@ export class DimlessBinaryDirective implements OnInit { } } - round(size) { + round(size: number) { if (size !== null && size !== 0) { if (!_.isUndefined(this.minBytes) && size < this.minBytes) { return this.minBytes; @@ -116,7 +116,7 @@ export class DimlessBinaryDirective implements OnInit { } @HostListener('blur', ['$event.target.value']) - onBlur(value) { + onBlur(value: string) { this.setValue(value); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/iops.directive.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/iops.directive.ts index 5d5d22dba87e7..4faf6916447b1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/iops.directive.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/iops.directive.ts @@ -25,7 +25,7 @@ export class IopsDirective implements OnInit { } @HostListener('blur', ['$event.target.value']) - onUpdate(value) { + onUpdate(value: string) { this.setValue(value); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/milliseconds.directive.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/milliseconds.directive.ts index 4d84499bc8ae0..d5bb4aff52ae1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/milliseconds.directive.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/milliseconds.directive.ts @@ -25,7 +25,7 @@ export class MillisecondsDirective implements OnInit { } @HostListener('blur', ['$event.target.value']) - onUpdate(value) { + onUpdate(value: string) { this.setValue(value); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/trim.directive.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/trim.directive.ts index eadac251a4a3c..7731721dd902e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/trim.directive.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/trim.directive.ts @@ -10,7 +10,7 @@ export class TrimDirective { constructor(private ngControl: NgControl) {} @HostListener('input', ['$event.target.value']) - onInput(value) { + onInput(value: string) { this.setValue(value); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-form-group.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-form-group.spec.ts index e9d4b204bdc0c..240da3af84935 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-form-group.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-form-group.spec.ts @@ -39,7 +39,7 @@ describe('CdFormGroup', () => { }); describe('CdFormGroup tests', () => { - let x, nested, a, c; + let x: CdFormGroup, nested: CdFormGroup, a: FormControl, c: FormGroup; beforeEach(() => { a = new FormControl('a'); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-form-group.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-form-group.ts index 9f2c1e633542d..9869f398c82da 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-form-group.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-form-group.ts @@ -30,7 +30,7 @@ export class CdFormGroup extends FormGroup { return control; } - _get(controlName): AbstractControl { + _get(controlName: string): AbstractControl { return ( super.get(controlName) || Object.values(this.controls) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.spec.ts index 3e68f44357a67..6890a4d09a751 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.spec.ts @@ -11,9 +11,9 @@ describe('CdValidators', () => { let formHelper: FormHelper; let form: CdFormGroup; - const expectValid = (value) => formHelper.expectValidChange('x', value); - const expectPatternError = (value) => formHelper.expectErrorChange('x', value, 'pattern'); - const updateValidity = (controlName) => form.get(controlName).updateValueAndValidity(); + const expectValid = (value: any) => formHelper.expectValidChange('x', value); + const expectPatternError = (value: any) => formHelper.expectErrorChange('x', value, 'pattern'); + const updateValidity = (controlName: string) => form.get(controlName).updateValueAndValidity(); beforeEach(() => { form = new CdFormGroup({ @@ -117,7 +117,7 @@ describe('CdValidators', () => { }); describe('uuid validator', () => { - const expectUuidError = (value) => + const expectUuidError = (value: string) => formHelper.expectErrorChange('x', value, 'invalidUuid', true); beforeEach(() => { form.get('x').setValidators(CdValidators.uuid()); @@ -302,7 +302,7 @@ describe('CdValidators', () => { }); it('should error because of successful condition', () => { - const conditionFn = (value) => { + const conditionFn = (value: string) => { return value === 'abc'; }; // Define prereqs that force the validator to validate the value of @@ -321,10 +321,10 @@ describe('CdValidators', () => { describe('custom validation', () => { beforeEach(() => { form = new CdFormGroup({ - x: new FormControl(3, CdValidators.custom('odd', (x) => x % 2 === 1)), + x: new FormControl(3, CdValidators.custom('odd', (x: number) => x % 2 === 1)), y: new FormControl( 5, - CdValidators.custom('not-dividable-by-x', (y) => { + CdValidators.custom('not-dividable-by-x', (y: number) => { const x = (form && form.get('x').value) || 1; return y % x !== 0; }) @@ -352,8 +352,8 @@ describe('CdValidators', () => { y: new FormControl(5) }); CdValidators.validateIf(form.get('x'), () => ((form && form.get('y').value) || 0) > 10, [ - CdValidators.custom('min', (x) => x < 7), - CdValidators.custom('max', (x) => x > 12) + CdValidators.custom('min', (x: number) => x < 7), + CdValidators.custom('max', (x: number) => x > 12) ]); formHelper = new FormHelper(form); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.ts index 7ec202b0874ad..b0cd8133edad2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.ts @@ -103,7 +103,7 @@ export class CdValidators { * argument. The function must return true to set the validation error. * @return {ValidatorFn} Returns the validator function. */ - static requiredIf(prerequisites: Object, condition?: Function | undefined): ValidatorFn { + static requiredIf(prerequisites: object, condition?: Function | undefined): ValidatorFn { let isWatched = false; return (control: AbstractControl): ValidationErrors | null => { @@ -150,7 +150,7 @@ export class CdValidators { * into action when the prerequisites are met. * @return {ValidatorFn} Returns the validator function. */ - static composeIf(prerequisites: Object, validators: ValidatorFn[]): ValidatorFn { + static composeIf(prerequisites: object, validators: ValidatorFn[]): ValidatorFn { let isWatched = false; return (control: AbstractControl): ValidationErrors | null => { if (!isWatched && control.parent) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-pwd-expiration-settings.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-pwd-expiration-settings.ts index eaa1454a36518..1df472d660dc2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-pwd-expiration-settings.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-pwd-expiration-settings.ts @@ -3,7 +3,7 @@ export class CdPwdExpirationSettings { pwdExpirationWarning1: number; pwdExpirationWarning2: number; - constructor(data) { + constructor(data: any) { this.pwdExpirationSpan = data.user_pwd_expiration_span; this.pwdExpirationWarning1 = data.user_pwd_expiration_warning_1; this.pwdExpirationWarning2 = data.user_pwd_expiration_warning_2; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/chart-tooltip.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/chart-tooltip.ts index 9b6552dd93c33..93a259e79d62d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/chart-tooltip.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/chart-tooltip.ts @@ -5,7 +5,7 @@ export class ChartTooltip { chartEl: any; getStyleLeft: Function; getStyleTop: Function; - customColors = { + customColors: Record = { backgroundColor: undefined, borderColor: undefined }; @@ -37,7 +37,7 @@ export class ChartTooltip { * @param {any} tooltip * @memberof ChartTooltip */ - customTooltips(tooltip) { + customTooltips(tooltip: any) { // Hide if no tooltip if (tooltip.opacity === 0) { this.tooltipEl.style.opacity = 0; @@ -55,18 +55,18 @@ export class ChartTooltip { // Set Text if (tooltip.body) { const titleLines = tooltip.title || []; - const bodyLines = tooltip.body.map((bodyItem) => { + const bodyLines = tooltip.body.map((bodyItem: any) => { return bodyItem.lines; }); let innerHtml = ''; - titleLines.forEach((title) => { + titleLines.forEach((title: string) => { innerHtml += '' + this.getTitle(title) + ''; }); innerHtml += ''; - bodyLines.forEach((body, i) => { + bodyLines.forEach((body: string, i: number) => { const colors = tooltip.labelColors[i]; let style = 'background:' + (this.customColors.backgroundColor || colors.backgroundColor); style += '; border-color:' + (this.customColors.borderColor || colors.borderColor); @@ -105,11 +105,11 @@ export class ChartTooltip { this.tooltipEl.style.padding = tooltip.yPadding + 'px ' + tooltip.xPadding + 'px'; } - getBody(body) { + getBody(body: string) { return body; } - getTitle(title) { + getTitle(title: string) { return title; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/task.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/task.ts index fab76717f73d1..0adec5a0f59a6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/task.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/task.ts @@ -1,5 +1,5 @@ export class Task { - constructor(name?, metadata?) { + constructor(name?: string, metadata?: object) { this.name = name; this.metadata = metadata; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/empty.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/empty.pipe.spec.ts index 462907906f367..e73420f6a35c0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/empty.pipe.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/empty.pipe.spec.ts @@ -8,8 +8,7 @@ describe('EmptyPipe', () => { }); it('transforms with empty value', () => { - const value = undefined; - expect(pipe.transform(value)).toBe('-'); + expect(pipe.transform(undefined)).toBe('-'); }); it('transforms with some value', () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.spec.ts index 94e5f8bdfec61..58d7ff95fcdbf 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.spec.ts @@ -12,7 +12,7 @@ describe('FilterPipe', () => { const filters = [ { value: 'foo', - applyFilter: (row, val) => { + applyFilter: (row: any[], val: any) => { return row.indexOf(val) !== -1; } } @@ -25,13 +25,13 @@ describe('FilterPipe', () => { const filters = [ { value: 'foo', - applyFilter: (row, val) => { + applyFilter: (row: any[], val: any) => { return row.indexOf(val) !== -1; } }, { value: 'bar', - applyFilter: (row, val) => { + applyFilter: (row: any[], val: any) => { return row.indexOf(val) !== -1; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts index f3dd70f3fb70d..313ac4c0dc2db 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts @@ -5,10 +5,10 @@ import { Pipe, PipeTransform } from '@angular/core'; }) export class FilterPipe implements PipeTransform { transform(value: any, args?: any): any { - return value.filter((row) => { + return value.filter((row: any) => { let result = true; - args.forEach((filter): boolean | void => { + args.forEach((filter: any): boolean | void => { if (!filter.value) { return undefined; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/relative-date.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/relative-date.pipe.spec.ts index a05657dde0bb3..0bb7930893a69 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/relative-date.pipe.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/relative-date.pipe.spec.ts @@ -10,8 +10,7 @@ describe('RelativeDatePipe', () => { }); it('transforms without value', () => { - const value = undefined; - expect(pipe.transform(value)).toBe('unknown'); + expect(pipe.transform(undefined)).toBe('unknown'); }); it('transforms "in 7 days"', () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.spec.ts index 744f2137b5a5f..8c6ec61743dda 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.spec.ts @@ -7,6 +7,7 @@ import { ToastrService } from 'ngx-toastr'; import { configureTestBed, i18nProviders } from '../../../testing/unit-test-helper'; import { AppModule } from '../../app.module'; +import { NotificationType } from '../enum/notification-type.enum'; import { CdNotification, CdNotificationConfig } from '../models/cd-notification'; import { ApiInterceptorService } from './api-interceptor.service'; import { NotificationService } from './notification.service'; @@ -18,7 +19,7 @@ describe('ApiInterceptorService', () => { let router: Router; const url = 'api/xyz'; - const httpError = (error, errorOpts, done = (_resp) => {}) => { + const httpError = (error: any, errorOpts: object, done = (_resp: any) => {}) => { httpClient.get(url).subscribe( () => {}, (resp) => { @@ -30,20 +31,30 @@ describe('ApiInterceptorService', () => { httpTesting.expectOne(url).error(error, errorOpts); }; - const runRouterTest = (errorOpts, expectedCallParams) => { + const runRouterTest = (errorOpts: object, expectedCallParams: any[]) => { httpError(new ErrorEvent('abc'), errorOpts); httpTesting.verify(); expect(router.navigate).toHaveBeenCalledWith(...expectedCallParams); }; - const runNotificationTest = (error, errorOpts, expectedCallParams) => { + const runNotificationTest = ( + error: any, + errorOpts: object, + expectedCallParams: CdNotification + ) => { httpError(error, errorOpts); httpTesting.verify(); expect(notificationService.show).toHaveBeenCalled(); expect(notificationService.save).toHaveBeenCalledWith(expectedCallParams); }; - const createCdNotification = (type, title?, message?, options?, application?) => { + const createCdNotification = ( + type: NotificationType, + title?: string, + message?: string, + options?: any, + application?: string + ) => { return new CdNotification(new CdNotificationConfig(type, title, message, options, application)); }; @@ -170,7 +181,7 @@ describe('ApiInterceptorService', () => { }); describe('interceptor error handling', () => { - const expectSaveToHaveBeenCalled = (called) => { + const expectSaveToHaveBeenCalled = (called: boolean) => { tick(510); if (called) { expect(notificationService.save).toHaveBeenCalled(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts index f93cffc5ec52c..c65f8c0518827 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts @@ -92,7 +92,7 @@ export class ApiInterceptorService implements HttpInterceptor { ); } - private prepareNotification(resp): number { + private prepareNotification(resp: any): number { return this.notificationService.show(() => { let message = ''; if (_.isPlainObject(resp.error) && _.isString(resp.error.detail)) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-storage.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-storage.service.ts index 79e11cda1a52e..b603e7fec42fe 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-storage.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-storage.service.ts @@ -16,7 +16,7 @@ export class AuthStorageService { set( username: string, token: string, - permissions: object = {}, + permissions = {}, sso = false, pwdExpirationDate: number = null ) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/device.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/device.service.spec.ts index 79927505e58a4..ed8260761f83b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/device.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/device.service.spec.ts @@ -18,7 +18,7 @@ describe('DeviceService', () => { }); describe('should test getDevices pipe', () => { - let now = null; + let now: jasmine.Spy = null; const newDevice = (data: object): CdDevice => { const device: CdDevice = { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/feature-toggles-guard.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/feature-toggles-guard.service.spec.ts index 6665647bb2a9b..474926ce952f0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/feature-toggles-guard.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/feature-toggles-guard.service.spec.ts @@ -46,7 +46,7 @@ describe('FeatureTogglesGuardService', () => { expect(service).toBeTruthy(); }); - function testCanActivate(path, feature_toggles_map) { + function testCanActivate(path: string, feature_toggles_map: object) { let result: boolean; spyOn(fakeFeatureTogglesService, 'get').and.returnValue(observableOf(feature_toggles_map)); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/feature-toggles.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/feature-toggles.service.ts index 2b9885aa8672c..8ead06e646c5d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/feature-toggles.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/feature-toggles.service.ts @@ -4,7 +4,7 @@ import { Injectable, NgZone } from '@angular/core'; import { Observable } from 'rxjs'; import { shareReplay } from 'rxjs/operators'; -export type FeatureTogglesMap = Map; +export type FeatureTogglesMap = Record; export type FeatureTogglesMap$ = Observable; @Injectable({ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/formatter.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/formatter.service.ts index 6c9ce12b20962..67d6a17b0bfe1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/formatter.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/formatter.service.ts @@ -35,7 +35,7 @@ export class FormatterService { * @returns Returns the given value in bytes without any unit appended or the defined error value * in case xof an error. */ - toBytes(value: string, error_value = null): number | null { + toBytes(value: string, error_value: number = null): number | null { const base = 1024; const units = ['b', 'k', 'm', 'g', 't', 'p', 'e', 'z', 'y']; const m = RegExp('^(\\d+(.\\d+)?) ?([' + units.join('') + ']?(b|ib|B/s)?)?$', 'i').exec(value); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/js-error-handler.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/js-error-handler.service.ts index 87e95bf6706ef..597e259f856ad 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/js-error-handler.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/js-error-handler.service.ts @@ -5,7 +5,7 @@ import { LoggingService } from '../api/logging.service'; export class JsErrorHandler implements ErrorHandler { constructor(private injector: Injector) {} - handleError(error) { + handleError(error: any) { const loggingService = this.injector.get(LoggingService); const url = window.location.href; const message = error && error.message; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.spec.ts index b1cdf8f177512..da48ac0fbe6b9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.spec.ts @@ -26,7 +26,7 @@ describe('NotificationService', () => { NotificationService, TaskMessageService, { provide: ToastrService, useValue: toastFakeService }, - { provide: CdDatePipe, useValue: { transform: (d) => d } }, + { provide: CdDatePipe, useValue: { transform: (d: any) => d } }, i18nProviders, RbdService ], @@ -64,7 +64,7 @@ describe('NotificationService', () => { })); describe('Saved notifications', () => { - const expectSavedNotificationToHave = (expected: {}) => { + const expectSavedNotificationToHave = (expected: object) => { tick(510); expect(service['dataSource'].getValue().length).toBe(1); const notification = service['dataSource'].getValue()[0]; @@ -73,7 +73,7 @@ describe('NotificationService', () => { }); }; - const addNotifications = (quantity) => { + const addNotifications = (quantity: number) => { for (let index = 0; index < quantity; index++) { service.show(NotificationType.info, `${index}`); tick(510); @@ -82,7 +82,7 @@ describe('NotificationService', () => { beforeEach(() => { spyOn(service, 'show').and.callThrough(); - service.cancel(service['justShownTimeoutId']); + service.cancel((service)['justShownTimeoutId']); }); it('should create a success notification and save it', fakeAsync(() => { @@ -186,7 +186,7 @@ describe('NotificationService', () => { const n1 = new CdNotificationConfig(NotificationType.success, 'Some success'); const n2 = new CdNotificationConfig(NotificationType.info, 'Some info'); - const showArray = (arr) => arr.forEach((n) => service.show(n)); + const showArray = (arr: any[]) => arr.forEach((n) => service.show(n)); beforeEach(() => { spyOn(service, 'save').and.stub(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts index 9f9c5e36bc819..fddc55f52f8c9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts @@ -219,7 +219,7 @@ export class NotificationService { * Prevent the notification from being shown. * @param {number} timeoutId A number representing the ID of the timeout to be canceled. */ - cancel(timeoutId) { + cancel(timeoutId: number) { window.clearTimeout(timeoutId); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert.service.spec.ts index 100c8299d1211..8bf4c41a82227 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert.service.spec.ts @@ -39,12 +39,12 @@ describe('PrometheusAlertService', () => { }); describe('test failing status codes and verify disabling of the alertmanager', () => { - const isDisabledByStatusCode = (statusCode: number, expectedStatus: boolean, done) => { + const isDisabledByStatusCode = (statusCode: number, expectedStatus: boolean, done: any) => { service = TestBed.get(PrometheusAlertService); prometheusService = TestBed.get(PrometheusService); spyOn(prometheusService, 'ifAlertmanagerConfigured').and.callFake((fn) => fn()); spyOn(prometheusService, 'getAlerts').and.returnValue( - Observable.create((observer) => observer.error({ status: statusCode, error: {} })) + Observable.create((observer: any) => observer.error({ status: statusCode, error: {} })) ); const disableFn = spyOn(prometheusService, 'disableAlertmanagerConfig').and.callFake(() => { expect(expectedStatus).toBe(true); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-notification.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-notification.service.spec.ts index f8d70d1d0e9c2..9e5e09a230386 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-notification.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-notification.service.spec.ts @@ -111,7 +111,7 @@ describe('PrometheusNotificationService', () => { tick(20); }; - const expectShown = (expected: {}[]) => { + const expectShown = (expected: object[]) => { tick(500); expect(shown.length).toBe(expected.length); expected.forEach((e, i) => diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-silence-matcher.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-silence-matcher.service.spec.ts index 684a7daa193d8..6ac9314024314 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-silence-matcher.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-silence-matcher.service.spec.ts @@ -19,7 +19,7 @@ describe('PrometheusSilenceMatcherService', () => { providers: [i18nProviders] }); - const addMatcher = (name, value) => ({ + const addMatcher = (name: string, value: any) => ({ name: name, value: value, isRegex: false @@ -40,7 +40,12 @@ describe('PrometheusSilenceMatcherService', () => { }); describe('test rule matching with one matcher', () => { - const expectSingleMatch = (name, value, helpText, successClass: boolean) => { + const expectSingleMatch = ( + name: string, + value: any, + helpText: string, + successClass: boolean + ) => { const match = service.singleMatch(addMatcher(name, value), rules); expect(match.status).toBe(helpText); expect(match.cssClass).toBe(successClass ? 'has-success' : 'has-warning'); @@ -85,7 +90,7 @@ describe('PrometheusSilenceMatcherService', () => { }); describe('test rule matching with multiple matcher', () => { - const expectMultiMatch = (matchers, helpText, successClass: boolean) => { + const expectMultiMatch = (matchers: any[], helpText: string, successClass: boolean) => { const match = service.multiMatch(matchers, rules); expect(match.status).toBe(helpText); expect(match.cssClass).toBe(successClass ? 'has-success' : 'has-warning'); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts index d4439416d9873..9741084b2a885 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts @@ -13,7 +13,7 @@ describe('SummaryService', () => { let summaryService: SummaryService; let authStorageService: AuthStorageService; - const summary = { + const summary: Record = { executing_tasks: [], health_status: 'HEALTH_OK', mgr_id: 'x', @@ -49,7 +49,7 @@ describe('SummaryService', () => { it('should call refresh', fakeAsync(() => { summaryService.enablePolling(); authStorageService.set('foobar', undefined, undefined); - const calledWith = []; + const calledWith: any[] = []; summaryService.subscribe((data) => { calledWith.push(data); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts index 8124ecc8db42a..1d090d96d8dce 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts @@ -70,7 +70,7 @@ export class SummaryService { } if (_.isArray(current.executing_tasks)) { - const exists = current.executing_tasks.find((element) => { + const exists = current.executing_tasks.find((element: any) => { return element.name === task.name && _.isEqual(element.metadata, task.metadata); }); if (!exists) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.spec.ts index f18d9b6096ddc..b25766f95c0c1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.spec.ts @@ -24,7 +24,7 @@ describe('TaskListService', () => { let apiResp: any; let tasks: any[]; - const addItem = (name) => { + const addItem = (name: string) => { apiResp.push({ name: name }); }; @@ -58,7 +58,7 @@ describe('TaskListService', () => { (task) => task.name.startsWith('test'), (item, task) => item.name === task.metadata['name'], { - default: (metadata) => ({ name: metadata['name'] }) + default: (metadata: object) => ({ name: metadata['name'] }) } ); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.ts index 05cd7398f302c..6d1f74b9fb1f0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.ts @@ -15,7 +15,7 @@ export class TaskListService implements OnDestroy { setList: (_: any[]) => void; onFetchError: (error: any) => void; taskFilter: (task: ExecutingTask) => boolean; - itemFilter: (item, task: ExecutingTask) => boolean; + itemFilter: (item: any, task: ExecutingTask) => boolean; builders: object; constructor( @@ -45,7 +45,7 @@ export class TaskListService implements OnDestroy { setList: (_: any[]) => void, onFetchError: (error: any) => void, taskFilter: (task: ExecutingTask) => boolean, - itemFilter: (item, task: ExecutingTask) => boolean, + itemFilter: (item: any, task: ExecutingTask) => boolean, builders: object ) { this.getUpdate = getUpdate; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts index 1fab5d39e3cd9..235d001f12e4a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts @@ -7,7 +7,7 @@ import { configureTestBed } from '../../../testing/unit-test-helper'; import { SummaryService } from './summary.service'; import { TaskManagerService } from './task-manager.service'; -const summary = { +const summary: Record = { executing_tasks: [], health_status: 'HEALTH_OK', mgr_id: 'x', @@ -25,7 +25,7 @@ export class SummaryServiceMock { refresh() { this.summaryDataSource.next(summary); } - subscribe(call) { + subscribe(call: any) { return this.summaryData$.subscribe(call); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.ts index 20ecd9d9891d6..d23b5b49fb9a5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.ts @@ -12,7 +12,7 @@ class TaskSubscription { metadata: object; onTaskFinished: (finishedTask: FinishedTask) => any; - constructor(name, metadata, onTaskFinished) { + constructor(name: string, metadata: object, onTaskFinished: any) { this.name = name; this.metadata = metadata; this.onTaskFinished = onTaskFinished; @@ -47,7 +47,7 @@ export class TaskManagerService { }); } - subscribe(name, metadata, onTaskFinished: (finishedTask: FinishedTask) => any) { + subscribe(name: string, metadata: object, onTaskFinished: (finishedTask: FinishedTask) => any) { this.subscriptions.push(new TaskSubscription(name, metadata, onTaskFinished)); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.spec.ts index 6ca2c4d02dcc5..a88bfbf14761c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.spec.ts @@ -127,7 +127,7 @@ describe('TaskManagerMessageService', () => { }); describe('rbd tasks', () => { - let metadata; + let metadata: Record; let childMsg: string; let destinationMsg: string; let snapMsg: string; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.ts index e5ef683774250..51d1ff06dfec1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.ts @@ -23,29 +23,29 @@ class TaskMessage { i18n: I18n; operation: TaskMessageOperation; - involves: (object) => string; - errors: (metadata) => object; + involves: (object: any) => string; + errors: (metadata: any) => object; - failure(metadata): string { + failure(metadata: any): string { return this.i18n('Failed to {{failure}} {{metadata}}', { failure: this.operation.failure, metadata: this.involves(metadata) }); } - running(metadata): string { + running(metadata: any): string { return `${this.operation.running} ${this.involves(metadata)}`; } - success(metadata): string { + success(metadata: any): string { return `${this.operation.success} ${this.involves(metadata)}`; } constructor( i18n: I18n, operation: TaskMessageOperation, - involves: (metadata) => string, - errors?: (metadata) => object + involves: (metadata: any) => string, + errors?: (metadata: any) => object ) { this.i18n = i18n; this.operation = operation; @@ -103,11 +103,11 @@ export class TaskMessageService { }; rbd = { - default: (metadata) => + default: (metadata: any) => this.i18n(`RBD '{{id}}'`, { id: `${metadata.image_spec}` }), - create: (metadata) => { + create: (metadata: any) => { const id = new ImageSpec( metadata.pool_name, metadata.namespace, @@ -117,7 +117,7 @@ export class TaskMessageService { id: id }); }, - child: (metadata) => { + child: (metadata: any) => { const id = new ImageSpec( metadata.child_pool_name, metadata.child_namespace, @@ -127,7 +127,7 @@ export class TaskMessageService { id: id }); }, - destination: (metadata) => { + destination: (metadata: any) => { const id = new ImageSpec( metadata.dest_pool_name, metadata.dest_namespace, @@ -137,7 +137,7 @@ export class TaskMessageService { id: id }); }, - snapshot: (metadata) => + snapshot: (metadata: any) => this.i18n(`RBD snapshot '{{id}}'`, { id: `${metadata.image_spec}@${metadata.snapshot_name}` }) @@ -146,11 +146,11 @@ export class TaskMessageService { rbd_mirroring = { site_name: () => this.i18n('mirroring site name'), bootstrap: () => this.i18n('bootstrap token'), - pool: (metadata) => + pool: (metadata: any) => this.i18n(`mirror mode for pool '{{id}}'`, { id: `${metadata.pool_name}` }), - pool_peer: (metadata) => + pool_peer: (metadata: any) => this.i18n(`mirror peer for pool '{{id}}'`, { id: `${metadata.pool_name}` }) @@ -407,33 +407,33 @@ export class TaskMessageService { newTaskMessage( operation: TaskMessageOperation, - involves: (metadata) => string, - errors?: (metadata) => object + involves: (metadata: any) => string, + errors?: (metadata: any) => object ) { return new TaskMessage(this.i18n, operation, involves, errors); } - host(metadata) { + host(metadata: any) { return this.i18n(`host '{{hostname}}'`, { hostname: metadata.hostname }); } - pool(metadata) { + pool(metadata: any) { return this.i18n(`pool '{{pool_name}}'`, { pool_name: metadata.pool_name }); } - ecp(metadata) { + ecp(metadata: any) { return this.i18n(`erasure code profile '{{name}}'`, { name: metadata.name }); } - iscsiTarget(metadata) { + iscsiTarget(metadata: any) { return this.i18n(`target '{{target_iqn}}'`, { target_iqn: metadata.target_iqn }); } - nfs(metadata) { + nfs(metadata: any) { return this.i18n(`NFS {{nfs_id}}`, { nfs_id: `'${metadata.cluster_id}:${metadata.export_id ? metadata.export_id : metadata.path}'` }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts index 747964e1c7eb2..93800260d6510 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts @@ -34,7 +34,7 @@ describe('TaskWrapperService', () => { let passed: boolean; let summaryService: SummaryService; - const fakeCall = (status?) => + const fakeCall = (status?: number) => new Observable((observer) => { if (!status) { observer.error({ error: 'failed' }); @@ -43,7 +43,7 @@ describe('TaskWrapperService', () => { observer.complete(); }); - const callWrapTaskAroundCall = (status, name) => { + const callWrapTaskAroundCall = (status: number, name: string) => { return service.wrapTaskAroundCall({ task: new FinishedTask(name, { sth: 'else' }), call: fakeCall(status) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.spec.ts index 335b85cecddae..8909ca8edf62c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.spec.ts @@ -49,7 +49,7 @@ describe('TimeDiffService', () => { const days = 24 * hours; it('should allow different writings', () => { - const expectDurationToBeMs = (duration, ms) => + const expectDurationToBeMs = (duration: string, ms: number) => expect(service['getDurationMs'](duration)).toBe(ms); expectDurationToBeMs('2h', 2 * hours); expectDurationToBeMs('4 Days', 4 * days); @@ -59,7 +59,7 @@ describe('TimeDiffService', () => { }); it('should create duration string from ms', () => { - const expectMsToBeDuration = (ms, duration) => + const expectMsToBeDuration = (ms: number, duration: string) => expect(service['getDuration'](ms)).toBe(duration); expectMsToBeDuration(2 * hours, '2h'); expectMsToBeDuration(4 * days, '4d'); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.ts index 4081a81829b3c..8d3079a251cc3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.ts @@ -30,7 +30,7 @@ export class TimeDiffService { const m = date.getUTCMinutes(); const d = Math.floor(ms / (24 * 3600 * 1000)); - const format = (n, s) => (n ? n + s : n); + const format = (n: number, s: string) => (n ? n + s : n); return [format(d, 'd'), format(h, 'h'), format(m, 'm')].filter((x) => x).join(' '); } @@ -50,8 +50,8 @@ export class TimeDiffService { return ((d * 24 + h) * 60 + m) * 60000; } - private getNumbersFromString(duration, prefix): number { + private getNumbersFromString(duration: string, prefix: string): number { const match = duration.match(new RegExp(`[0-9 ]+${prefix}`, 'i')); - return match ? parseInt(match, 10) : 0; + return match ? parseInt(match[0], 10) : 0; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/jestGlobalMocks.ts b/src/pybind/mgr/dashboard/frontend/src/jestGlobalMocks.ts index 6c6750adbbd56..3006ecaf7e9d5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/jestGlobalMocks.ts +++ b/src/pybind/mgr/dashboard/frontend/src/jestGlobalMocks.ts @@ -1,9 +1,9 @@ const mock = () => { let storage = {}; return { - getItem: (key) => (key in storage ? storage[key] : null), - setItem: (key, value) => (storage[key] = value || ''), - removeItem: (key) => delete storage[key], + getItem: (key: string) => (key in storage ? storage[key] : null), + setItem: (key: string, value: any) => (storage[key] = value || ''), + removeItem: (key: string) => delete storage[key], clear: () => (storage = {}) }; }; diff --git a/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts b/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts index b21c5a2a8dc4a..c3e5750a32171 100644 --- a/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts +++ b/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts @@ -20,7 +20,7 @@ import { } from '../app/shared/models/prometheus-alerts'; import { _DEV_ } from '../unit-test-configuration'; -export function configureTestBed(configuration, useOldMethod?) { +export function configureTestBed(configuration: any, useOldMethod?: boolean) { if (_DEV_ && !useOldMethod) { const resetTestingModule = TestBed.resetTestingModule; beforeAll((done) => @@ -190,7 +190,7 @@ export class FormHelper { * * Please make sure to call this function *inside* your mock and return the reference at the end. */ -export function modalServiceShow(componentClass: Type, modalConfig) { +export function modalServiceShow(componentClass: Type, modalConfig: any) { const ref = new BsModalRef(); const fixture = TestBed.createComponent(componentClass); let component = fixture.componentInstance; @@ -276,7 +276,7 @@ export class FixtureHelper { } export class PrometheusHelper { - createSilence(id) { + createSilence(id: string) { return { id: id, createdBy: `Creator of ${id}`, @@ -293,7 +293,7 @@ export class PrometheusHelper { }; } - createRule(name, severity, alerts: any[]): PrometheusRule { + createRule(name: string, severity: string, alerts: any[]): PrometheusRule { return { name: name, labels: { @@ -303,7 +303,7 @@ export class PrometheusHelper { } as PrometheusRule; } - createAlert(name, state = 'active', timeMultiplier = 1): AlertmanagerAlert { + createAlert(name: string, state = 'active', timeMultiplier = 1): AlertmanagerAlert { return { fingerprint: name, status: { state }, @@ -321,7 +321,7 @@ export class PrometheusHelper { } as AlertmanagerAlert; } - createNotificationAlert(name, status = 'firing'): AlertmanagerNotificationAlert { + createNotificationAlert(name: string, status = 'firing'): AlertmanagerNotificationAlert { return { status: status, labels: { @@ -342,7 +342,7 @@ export class PrometheusHelper { return { alerts, status } as AlertmanagerNotification; } - createLink(url) { + createLink(url: string) { return ``; } } diff --git a/src/pybind/mgr/dashboard/frontend/tsconfig.json b/src/pybind/mgr/dashboard/frontend/tsconfig.json index 7c38858a5e04d..b72faa4b0f213 100644 --- a/src/pybind/mgr/dashboard/frontend/tsconfig.json +++ b/src/pybind/mgr/dashboard/frontend/tsconfig.json @@ -15,6 +15,8 @@ "noFallthroughCasesInSwitch": true, "noImplicitThis": true, "noImplicitReturns": true, + "noImplicitAny": true, + "suppressImplicitAnyIndexErrors": true, "target": "es2015", "typeRoots": [ "node_modules/@types"