From 583590d29f5e3bfe54b1915b8a4d4791fb8feba1 Mon Sep 17 00:00:00 2001 From: dweinholz Date: Thu, 15 Aug 2024 11:34:51 +0200 Subject: [PATCH] Updated for eslint 9 --- .eslintignore | 5 - .eslintrc.json | 6 +- eslint.config.mjs | 203 +++ package-lock.json | 1517 ++--------------- package.json | 4 +- src/app/api-connector/applications.service.ts | 220 +-- src/app/api-connector/bioconda.service.ts | 83 +- src/app/api-connector/client.service.ts | 76 +- src/app/api-connector/credits.service.ts | 80 +- src/app/api-connector/email.service.ts | 56 +- src/app/api-connector/facility.service.ts | 404 ++--- src/app/api-connector/flavor.service.ts | 46 +- src/app/api-connector/group.service.ts | 254 +-- src/app/api-connector/image.service.ts | 180 +- src/app/api-connector/key.service.ts | 40 +- src/app/api-connector/maintenance.service.ts | 39 +- src/app/api-connector/news.service.ts | 134 +- src/app/api-connector/numbers.service.ts | 20 +- src/app/api-connector/playbook.service.ts | 20 +- src/app/api-connector/token-interceptor.ts | 58 +- src/app/api-connector/user.service.ts | 126 +- .../api-connector/virtualmachine.service.ts | 326 ++-- src/app/api-connector/vo.service.ts | 218 +-- src/app/api-connector/workshop.service.ts | 114 +- src/app/app.component.ts | 27 +- src/app/app.interceptor.component.ts | 24 +- src/app/app.module.ts | 96 +- .../application-card.component.spec.ts | 26 +- .../application-card.component.ts | 84 +- .../adjustment-detail.component.ts | 12 +- .../application-detail.component.ts | 160 +- .../application-pi-detail.component.ts | 8 +- .../credits-extension-detail.component.ts | 10 +- .../information-detail.component.ts | 18 +- .../lifetime-extension-detail.component.ts | 18 +- .../modification-detail.component.ts | 24 +- .../resource-detail.component.ts | 54 +- ...ication-facility-actions.component.spec.ts | 26 +- .../application-facility-actions.component.ts | 240 ++- .../application-formular.component.ts | 450 +++-- .../kubernetes-formular.component.ts | 10 +- .../addcloudapplication.component.ts | 8 +- .../addsimplevm.component.ts | 8 +- .../application-header.component.spec.ts | 26 +- .../application-header.component.ts | 4 +- .../application-list.component.spec.ts | 26 +- .../application-list.component.ts | 78 +- .../application-ressource-usage.ts | 160 +- .../application-vo-actions.component.spec.ts | 26 +- .../application-vo-actions.component.ts | 396 ++--- .../application.model/application.model.ts | 326 ++-- .../application.model/dissemination.ts | 82 +- .../applications-routing.module.ts | 51 +- .../applications/applications.component.ts | 271 +-- src/app/applications/applications.module.ts | 72 +- .../numberValidations.directive.ts | 88 +- .../applications/type-overview.component.ts | 80 +- src/app/consent-info.component.ts | 9 +- .../credits-calculator.component.ts | 238 +-- .../credits-calculator.module.ts | 30 +- .../resource-weights.model.ts | 69 +- .../facility.application.component.ts | 190 +-- .../facilitymanager-routing.module.ts | 46 +- .../facilitymanager.module.ts | 60 +- .../facilityprojectsoverview.component.ts | 477 +++--- .../facility_manager/imagetags.component.ts | 224 ++- .../newsmanagement/news-manager.component.ts | 358 ++-- ...generalstoragefactor-overview.component.ts | 100 +- .../gpu-specification-overview.component.ts | 174 +- .../objectstoragefactor-overview.component.ts | 101 +- .../resourcemachine-overview.component.ts | 376 ++-- .../resources/resources.component.ts | 268 ++- .../volumestoragefactor-overview.component.ts | 100 +- src/app/help/help-routing.module.ts | 20 +- src/app/help/help.component.ts | 26 +- src/app/help/help.module.ts | 31 +- src/app/layouts/full-layout.component.ts | 264 +-- src/app/logged-in-guard.service.ts | 30 +- .../maintenance-alert.component.ts | 104 +- src/app/member-guard.service.ts | 66 +- .../news/news-slide/news-slide.component.ts | 14 +- src/app/news/news.component.ts | 80 +- src/app/news/news.module.ts | 14 +- src/app/pipe-module/pipe-module.module.ts | 46 +- src/app/pipe-module/pipes/flavorcounter.ts | 12 +- .../pipe-module/pipes/floor-integer.pipe.ts | 7 +- src/app/pipe-module/pipes/futureTime.pipe.ts | 8 +- .../pipe-module/pipes/has-flavor-type.pipe.ts | 24 +- .../pipes/has-status-not-in-list.pipe.ts | 12 +- src/app/pipe-module/pipes/has-status.pipe.ts | 12 +- .../pipes/has-unavailable-flavors.pipe.ts | 12 +- .../pipe-module/pipes/hasstatusinlist.pipe.ts | 12 +- src/app/pipe-module/pipes/in-allowed.pipe.ts | 12 +- src/app/pipe-module/pipes/in-list.pipe.ts | 8 +- src/app/pipe-module/pipes/is-pi-approved.ts | 12 +- .../pipe-module/pipes/isMigratedProject.ts | 8 +- src/app/pipe-module/pipes/migratedList.ts | 6 +- src/app/pipe-module/pipes/publicKey.pipe.ts | 20 +- src/app/pipe-module/pipes/ressources.ts | 20 +- .../pipes/social-consent-given.pipe.ts | 12 +- .../pipe-module/pipes/validTimeFrame.pipe.ts | 16 +- .../application-progress.component.ts | 16 +- .../adjust-application.component.ts | 172 +- .../adjust-lifetime-request.component.ts | 60 +- .../credits-request.component.ts | 122 +- .../lifetime-request.component.ts | 144 +- .../modification-request.component.ts | 267 +-- .../modals/result/result.component.ts | 142 +- .../testimonial/extension-entry.component.ts | 87 +- .../withdraw/withdraw-modal.component.ts | 38 +- .../projectmanagement/overview.component.ts | 935 +++++----- .../project-os-details.component.ts | 50 +- .../projectmanagement-routing.module.ts | 22 +- .../projectmanagement.module.ts | 62 +- src/app/registration-info.component.ts | 9 +- src/app/shared/aside.directive.ts | 11 +- src/app/shared/breadcrumb.component.ts | 82 +- .../datepicking/datepicker.component.ts | 24 +- .../datepicking/timepicker.component.ts | 14 +- src/app/shared/guards/vo-guard.service.ts | 20 +- .../modal/confirmation-modal.component.ts | 112 +- ...ect-csv-templated-email-modal.component.ts | 78 +- .../project-email-modal.component.ts | 56 +- .../members/members-list-modal.component.ts | 38 +- src/app/shared/modal/notification-modal.ts | 54 +- .../baseClass/abstract-base-class.ts | 81 +- .../application-base-class.component.ts | 233 +-- .../baseClass/filter-base-class.ts | 90 +- .../shared_modules/baseClass/shared-modal.ts | 23 +- .../application-badges.component.ts | 20 +- .../maintenance-notification.component.ts | 14 +- .../significance-pipe/significance.pipe.ts | 10 +- .../nbd-sortable-header.directive.ts | 26 +- .../migration-information.component.ts | 36 +- .../public-key/public-key.component.ts | 112 +- .../public-key/public-key.module.ts | 22 +- .../services/project-sort.service.ts | 158 +- .../shared_modules/shared-module.module.ts | 48 +- .../shared_directives.module.ts | 14 +- .../testimonial-form.component.ts | 288 ++-- src/app/shared/sidebar.directive.ts | 59 +- src/app/shared/title-headbar.component.ts | 20 +- .../toaster/information-toast.component.ts | 28 +- src/app/userinfo/userinfo-routing.module.ts | 20 +- src/app/userinfo/userinfo.component.ts | 265 +-- src/app/userinfo/userinfo.module.ts | 35 +- .../validation-application.component.ts | 60 +- src/app/virtualmachines/addvm.component.ts | 791 +++++---- .../clustercard/clustercard.component.ts | 118 +- .../add-cluster/add-cluster.component.ts | 516 +++--- .../cluster-actions.component.spec.ts | 26 +- .../cluster-actions.component.ts | 242 ++- .../clusterdetail/clusterdetail.component.ts | 224 ++- .../virtualmachines/clusters/clusterinfo.ts | 148 +- .../clusterinfo/clusterinfo.component.ts | 9 +- .../clusterOverview.component.ts | 246 ++- .../clusterstatus/clusterstatus.component.ts | 18 +- .../conda/bioconda.component.ts | 193 +-- .../conda/res-env.component.ts | 146 +- .../virtualmachines/conda/template-names.ts | 36 +- .../virtualmachines/flavordetail.component.ts | 132 +- .../imageCarouselSlide.component.ts | 40 +- .../virtualmachines/imagedetail.component.ts | 155 +- .../delete-cluster.component.ts | 32 +- .../modals/delete-vm/delete-vm.component.ts | 32 +- .../password-cluster.component.ts | 44 +- .../modals/reboot-vm/reboot-vm.component.ts | 50 +- .../recreate-backend-vm.component.ts | 24 +- .../rename-cluster.component.ts | 30 +- .../resume-cluster.component.ts | 28 +- .../modals/resume-vm/resume-vm.component.ts | 28 +- .../scale-cluster/scale-cluster.component.ts | 246 +-- .../snapshot-vm/snapshot-vm.component.ts | 75 +- .../stop-cluster/stop-cluster.component.ts | 26 +- .../modals/stop-vm/stop-vm.component.ts | 27 +- .../modals/volume-vm/volume-vm.component.ts | 79 +- .../project-user-list.component.ts | 47 +- .../resource-overview.component.ts | 35 +- .../snapshots/snapshotOverview.component.ts | 254 +-- .../virtualmachinemodels/virtualmachine.ts | 152 +- .../virtualmachinestates.ts | 150 +- src/app/virtualmachines/vm.module.ts | 112 +- .../virtualmachines/vmOverview.component.ts | 280 ++- src/app/virtualmachines/vm_routing.module.ts | 82 +- .../vmcard/vmcard.component.ts | 450 ++--- .../virtualmachineinfo.component.ts | 48 +- .../vmdetail/vmdetail.component.ts | 619 +++---- .../vmdetail/vmstatus/vmstatus.component.ts | 18 +- .../volum-status/volum-status.component.ts | 20 +- .../volumes/volumeOverview.component.ts | 649 +++---- .../virtualmachines/volumes/volume_states.ts | 72 +- .../add-workshop/add-workshop.component.ts | 468 +++-- .../workshop-overview.component.ts | 436 +++-- .../vo_manager/VoManager-routing.module.ts | 42 +- src/app/vo_manager/VoManager.module.ts | 50 +- src/app/vo_manager/VoOverviewComponent.ts | 574 ++++--- .../clients/clientOverview.component.ts | 128 +- .../modals/client-limits..component.ts | 122 +- .../maintenance/maintenance.component.ts | 230 +-- .../number-charts/number-charts.component.ts | 342 ++-- .../resources/resources.component.ts | 52 +- src/environments/environment.custom.ts | 14 +- src/environments/environment.ts | 12 +- src/links/links.ts | 123 +- src/test.ts | 28 +- 205 files changed, 11700 insertions(+), 12893 deletions(-) delete mode 100644 .eslintignore create mode 100644 eslint.config.mjs diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 961203b0a6..0000000000 --- a/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules -build -dist -res -coverage diff --git a/.eslintrc.json b/.eslintrc.json index 0274b5e2bb..3fac3ebdd8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,7 +19,6 @@ "extends": [ "plugin:@angular-eslint/template/process-inline-templates", "eslint:recommended", - "airbnb-base", "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-requiring-type-checking" ], @@ -28,6 +27,9 @@ "@typescript-eslint" ], "rules": { + "import/newline-after-import": "off", + "import/no-named-as-default": "off", + "import/no-named-as-default-member": "off", "@angular-eslint/directive-selector": [ "error", @@ -59,7 +61,7 @@ ], "no-shadow": "off", "@typescript-eslint/no-shadow": "warn", - "require-jsdoc": "warn", + // "require-jsdoc": "warn", "guard-for-in": "off", "jsdoc/newline-after-description": "off", "jsdoc/no-types": "off", diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000000..64107ce6c7 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,203 @@ +import noNull from "eslint-plugin-no-null"; +import typescriptEslint from "@typescript-eslint/eslint-plugin"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [{ + ignores: ["projects/**/*", "**/package-lock.json","node_modules/**","build/**","dist/**","res/**","coverage/**"], +}, ...compat.extends( + "plugin:@angular-eslint/template/process-inline-templates", + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", +).map(config => ({ + ...config, + files: ["**/*.ts"], +})), { + files: ["**/*.ts"], + + plugins: { + "no-null": noNull, + "@typescript-eslint": typescriptEslint, + }, + + languageOptions: { + ecmaVersion: 5, + sourceType: "script", + + parserOptions: { + project: ["tsconfig.json", "e2e/tsconfig.e2e.json"], + createDefaultProgram: true, + }, + }, + + rules: { + "import/newline-after-import": "off", + "import/no-named-as-default": "off", + "import/no-named-as-default-member": "off", + "@angular-eslint/directive-selector": "off", + "@angular-eslint/no-forward-ref": "off", + "no-return-await": "off", + "@typescript-eslint/naming-convention": "off", + "@typescript-eslint/ban-types": "off", + camelcase: "off", + "class-methods-use-this": "off", + "dot-notation": "off", + eqeqeq: "error", + "lines-between-class-members": "off", + "padded-blocks": "off", + + "max-len": ["error", { + code: 200, + ignoreComments: true, + ignoreUrls: true, + ignoreTemplateLiterals: true, + ignoreRegExpLiterals: true, + }], + + "no-shadow": "off", + "@typescript-eslint/no-shadow": "warn", + "guard-for-in": "off", + "jsdoc/newline-after-description": "off", + "jsdoc/no-types": "off", + "@typescript-eslint/consistent-type-assertions": "warn", + "@typescript-eslint/no-unsafe-enum-comparison": "off", + + "@typescript-eslint/array-type": ["error", { + default: "array", + }], + + "@typescript-eslint/await-thenable": "error", + "@typescript-eslint/consistent-type-definitions": "error", + "@typescript-eslint/dot-notation": "off", + + "@typescript-eslint/explicit-member-accessibility": ["off", { + accessibility: "explicit", + }], + + "@typescript-eslint/member-delimiter-style": ["off", { + multiline: { + delimiter: "none", + requireLast: true, + }, + + singleline: { + delimiter: "semi", + requireLast: false, + }, + }], + + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": ["error"], + "@typescript-eslint/member-ordering": "off", + "@typescript-eslint/no-floating-promises": "error", + "@typescript-eslint/no-for-in-array": "off", + "@typescript-eslint/no-inferrable-types": "off", + "@typescript-eslint/no-require-imports": "error", + "@typescript-eslint/no-unnecessary-qualifier": "error", + "@typescript-eslint/no-var-requires": "error", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/no-explicit-any": "off", + " @typescript-eslint/no-empty-function": "off", + "@angular-eslint/component-selector": "off", + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-unsafe-call": "off", + "no-console": "off", + + "@typescript-eslint/ban-ts-comment": ["off", { + "ts-ignore": "allow-with-description", + }], + + "@typescript-eslint/no-implied-eval": "off", + "@typescript-eslint/no-misused-promises": "off", + "@typescript-eslint/require-await": "off", + "no-empty": "off", + "no-unused-expressions": "off", + "@typescript-eslint/no-unsafe-argument": "off", + + "@typescript-eslint/unbound-method": ["off", { + ignoreStatic: true, + }], + + "@typescript-eslint/promise-function-async": "error", + "@typescript-eslint/restrict-plus-operands": "error", + "@typescript-eslint/semi": ["off", null], + "@typescript-eslint/strict-boolean-expressions": "off", + "arrow-parens": ["off", "always"], + "brace-style": ["error", "1tbs"], + "comma-dangle": "error", + "default-case": "warn", + "default-param-last": "off", + "id-blacklist": "off", + "id-match": "off", + "import/no-default-export": "off", + "import/prefer-default-export": "off", + "import/no-unassigned-import": "off", + "import/no-unresolved": "off", + "import/no-mutable-exports": "off", + "import/extensions": "off", + "import/no-amd": "off", + "import/no-extraneous-dependencies": "off", + + indent: ["error", "tab", { + SwitchCase: 1, + }], + + "linebreak-style": "error", + "max-lines": "off", + "no-continue": "off", + "no-constant-condition": "error", + "no-control-regex": "warn", + "no-else-return": "off", + "no-invalid-regexp": "error", + "no-invalid-this": "off", + "no-irregular-whitespace": "error", + "no-multiple-empty-lines": "error", + "@angular-eslint/no-empty-lifecycle-method": "off", + "no-empty-function": "off", + "no-null/no-null": "off", + "no-nested-ternary": "off", + "no-param-reassign": "off", + "no-redeclare": "error", + "no-regex-spaces": "error", + "no-restricted-syntax": ["off", "ForInStatement"], + "no-sparse-arrays": "error", + "no-tabs": "off", + "no-template-curly-in-string": "error", + "no-underscore-dangle": "off", + "no-use-before-define": "off", + "no-useless-constructor": "off", + "no-void": "off", + "@typescript-eslint/no-useless-constructor": ["error"], + "no-mixed-spaces-and-tabs": [2, "smart-tabs"], + + "padding-line-between-statements": ["error", { + blankLine: "always", + prev: "*", + next: "return", + }], + + "prefer-arrow/prefer-arrow-functions": "off", + "prefer-template": "error", + "prefer-destructuring": "off", + }, +}, ...compat.extends("plugin:@angular-eslint/template/recommended").map(config => ({ + ...config, + files: ["**/*.html"], +})), { + files: ["**/*.html"], + rules: {}, +}]; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a4053839c7..4d9bde54a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@denbi/cloud-portal-webapp", - "version": "4.856.0", + "version": "4.857.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@denbi/cloud-portal-webapp", - "version": "4.856.0", + "version": "4.857.0", "dependencies": { "@angular-eslint/eslint-plugin": "^18.3.0", "@angular/animations": "18.2.0", @@ -76,6 +76,8 @@ "@angular-eslint/template-parser": "18.3.0", "@angular/cli": "^18.1.4", "@angular/compiler-cli": "18.2.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.9.0", "@playwright/test": "1.46.0", "@types/jasmine": "5.1.4", "@types/node": "20.14.15", @@ -84,9 +86,7 @@ "async": "3.2.5", "audit-ci": "7.1.0", "autoprefixer": "10.4.20", - "eslint": "^8.57.0", - "eslint-config-airbnb-base": "15.0.0", - "eslint-plugin-import": "^2.29.0", + "eslint": "^9.0.0", "eslint-plugin-jsdoc": "50.2.2", "eslint-plugin-no-null": "latest", "eslint-plugin-prefer-arrow": "1.2.3", @@ -3918,15 +3918,48 @@ "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, + "node_modules/@eslint/config-array": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.17.1.tgz", + "integrity": "sha512-BlYOpej8AQ8Ev9xVqroV7a02JK3SkBAaN9GfMMH9W6Ch8FlQlkjGw4Ir7+FgYwfirivAf4t+GtzuAxqfukmISA==", + "dependencies": { + "@eslint/object-schema": "^2.1.4", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/config-array/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/config-array/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@eslint/eslintrc": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", - "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.6.0", - "globals": "^13.19.0", + "espree": "^10.0.1", + "globals": "^14.0.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", @@ -3934,7 +3967,7 @@ "strip-json-comments": "^3.1.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -3965,14 +3998,11 @@ } }, "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", - "dependencies": { - "type-fest": "^0.20.2" - }, + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", "engines": { - "node": ">=8" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -3994,57 +4024,20 @@ "node": "*" } }, - "node_modules/@eslint/eslintrc/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@eslint/js": { - "version": "8.57.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", - "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", + "version": "9.9.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.9.0.tgz", + "integrity": "sha512-hhetes6ZHP3BlXLxmd8K2SNgkhNSi+UcecbnwWKwpP7kyi/uC75DJ1lOOBO3xrC4jyojtGE3YxKZPHfk4yrgug==", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/@humanwhocodes/config-array": { - "version": "0.11.14", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", - "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", - "deprecated": "Use @eslint/config-array instead", - "dependencies": { - "@humanwhocodes/object-schema": "^2.0.2", - "debug": "^4.3.1", - "minimatch": "^3.0.5" - }, - "engines": { - "node": ">=10.10.0" - } - }, - "node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "node_modules/@humanwhocodes/config-array/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, + "node_modules/@eslint/object-schema": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", + "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", "engines": { - "node": "*" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@humanwhocodes/module-importer": { @@ -4059,11 +4052,17 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", - "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", - "deprecated": "Use @eslint/object-schema instead" + "node_modules/@humanwhocodes/retry": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.0.tgz", + "integrity": "sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } }, "node_modules/@inquirer/checkbox": { "version": "2.4.7", @@ -5875,12 +5874,6 @@ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "devOptional": true }, - "node_modules/@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", - "dev": true - }, "node_modules/@types/mime": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", @@ -6182,11 +6175,6 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@ungap/structured-clone": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", - "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==" - }, "node_modules/@vitejs/plugin-basic-ssl": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@vitejs/plugin-basic-ssl/-/plugin-basic-ssl-1.1.0.tgz", @@ -6687,48 +6675,12 @@ "dequal": "^2.0.3" } }, - "node_modules/array-buffer-byte-length": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.1.tgz", - "integrity": "sha512-ahC5W1xgou+KTXix4sAO8Ki12Q+jf4i0+tmk3sC+zgcynshkHxzpXdImBehiUYKKKDwvfFiJl1tZt6ewscS1Mg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.5", - "is-array-buffer": "^3.0.4" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", "dev": true }, - "node_modules/array-includes": { - "version": "3.1.8", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.8.tgz", - "integrity": "sha512-itaWrbYbqpGXkGhZPGUulwnhVf5Hpy1xiCFsGqyIGglbBxmG5vSjxQen3/WGOjPpNEv1RtBLKxbmVXm8HpJStQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-abstract": "^1.23.2", - "es-object-atoms": "^1.0.0", - "get-intrinsic": "^1.2.4", - "is-string": "^1.0.7" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -6737,84 +6689,6 @@ "node": ">=8" } }, - "node_modules/array.prototype.findlastindex": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.5.tgz", - "integrity": "sha512-zfETvRFA8o7EiNn++N5f/kaCw221hrpGsDmcpndVupkPzEc1Wuf3VgC0qby1BbHs7f5DVYjgtEU2LLh5bqeGfQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-abstract": "^1.23.2", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.0.0", - "es-shim-unscopables": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/array.prototype.flat": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz", - "integrity": "sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "es-abstract": "^1.22.1", - "es-shim-unscopables": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/array.prototype.flatmap": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.2.tgz", - "integrity": "sha512-Ewyx0c9PmpcsByhSW4r+9zDU7sGjFc86qf/kKtuSCRdhfbk0SNLLkaT5qvcHnRGgc5NP/ly/y+qkXkqONX54CQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "es-abstract": "^1.22.1", - "es-shim-unscopables": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/arraybuffer.prototype.slice": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.3.tgz", - "integrity": "sha512-bMxMKAjg13EBSVscxTaYA4mRc5t1UAXa2kXiGTNfZ079HIWXEkKmkgFrh/nJqamaLSrXO5H4WFFkPEaLJWbs3A==", - "dev": true, - "dependencies": { - "array-buffer-byte-length": "^1.0.1", - "call-bind": "^1.0.5", - "define-properties": "^1.2.1", - "es-abstract": "^1.22.3", - "es-errors": "^1.2.1", - "get-intrinsic": "^1.2.3", - "is-array-buffer": "^3.0.4", - "is-shared-array-buffer": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/async": { "version": "3.2.5", "resolved": "https://registry.npmjs.org/async/-/async-3.2.5.tgz", @@ -6907,21 +6781,6 @@ "postcss": "^8.1.0" } }, - "node_modules/available-typed-arrays": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", - "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", - "dev": true, - "dependencies": { - "possible-typed-array-names": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/axobject-query": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz", @@ -7836,12 +7695,6 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, - "node_modules/confusing-browser-globals": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz", - "integrity": "sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA==", - "dev": true - }, "node_modules/connect": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", @@ -8779,57 +8632,6 @@ "node": ">=12" } }, - "node_modules/data-view-buffer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.1.tgz", - "integrity": "sha512-0lht7OugA5x3iJLOWFhWK/5ehONdprk0ISXqVFn/NFrDu+cuc8iADFrGQz5BnRK7LLU3JmkbXSxaqX+/mXYtUA==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.6", - "es-errors": "^1.3.0", - "is-data-view": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/data-view-byte-length": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/data-view-byte-length/-/data-view-byte-length-1.0.1.tgz", - "integrity": "sha512-4J7wRJD3ABAzr8wP+OcIcqq2dlUKp4DVflx++hs5h5ZKydWMI6/D/fAot+yh6g2tHh8fLFTvNOaVN357NvSrOQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "es-errors": "^1.3.0", - "is-data-view": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/data-view-byte-offset": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/data-view-byte-offset/-/data-view-byte-offset-1.0.0.tgz", - "integrity": "sha512-t/Ygsytq+R995EJ5PZlD4Cu56sWa8InXySaViRzw9apusqsOO2bQP+SbYzAhR0pFKoB+43lYy8rWban9JSuXnA==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.6", - "es-errors": "^1.3.0", - "is-data-view": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/date-format": { "version": "4.0.14", "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz", @@ -9048,23 +8850,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/define-properties": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", - "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", - "dev": true, - "dependencies": { - "define-data-property": "^1.0.1", - "has-property-descriptors": "^1.0.0", - "object-keys": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/delaunator": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.0.1.tgz", @@ -9155,17 +8940,6 @@ "node": ">=6" } }, - "node_modules/doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/dom-converter": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", @@ -9444,66 +9218,6 @@ "is-arrayish": "^0.2.1" } }, - "node_modules/es-abstract": { - "version": "1.23.3", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz", - "integrity": "sha512-e+HfNH61Bj1X9/jLc5v1owaLYuHdeHHSQlkhCBiTK8rBvKaULl/beGMxwrMXjpYrv4pz22BlY570vVePA2ho4A==", - "dev": true, - "dependencies": { - "array-buffer-byte-length": "^1.0.1", - "arraybuffer.prototype.slice": "^1.0.3", - "available-typed-arrays": "^1.0.7", - "call-bind": "^1.0.7", - "data-view-buffer": "^1.0.1", - "data-view-byte-length": "^1.0.1", - "data-view-byte-offset": "^1.0.0", - "es-define-property": "^1.0.0", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.0.0", - "es-set-tostringtag": "^2.0.3", - "es-to-primitive": "^1.2.1", - "function.prototype.name": "^1.1.6", - "get-intrinsic": "^1.2.4", - "get-symbol-description": "^1.0.2", - "globalthis": "^1.0.3", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.2", - "has-proto": "^1.0.3", - "has-symbols": "^1.0.3", - "hasown": "^2.0.2", - "internal-slot": "^1.0.7", - "is-array-buffer": "^3.0.4", - "is-callable": "^1.2.7", - "is-data-view": "^1.0.1", - "is-negative-zero": "^2.0.3", - "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.3", - "is-string": "^1.0.7", - "is-typed-array": "^1.1.13", - "is-weakref": "^1.0.2", - "object-inspect": "^1.13.1", - "object-keys": "^1.1.1", - "object.assign": "^4.1.5", - "regexp.prototype.flags": "^1.5.2", - "safe-array-concat": "^1.1.2", - "safe-regex-test": "^1.0.3", - "string.prototype.trim": "^1.2.9", - "string.prototype.trimend": "^1.0.8", - "string.prototype.trimstart": "^1.0.8", - "typed-array-buffer": "^1.0.2", - "typed-array-byte-length": "^1.0.1", - "typed-array-byte-offset": "^1.0.2", - "typed-array-length": "^1.0.6", - "unbox-primitive": "^1.0.2", - "which-typed-array": "^1.1.15" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/es-define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", @@ -9531,81 +9245,29 @@ "integrity": "sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==", "devOptional": true }, - "node_modules/es-object-atoms": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", - "integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==", - "dev": true, + "node_modules/es5-ext": { + "version": "0.10.64", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz", + "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==", + "hasInstallScript": true, "dependencies": { - "es-errors": "^1.3.0" + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "esniff": "^2.0.1", + "next-tick": "^1.1.0" }, "engines": { - "node": ">= 0.4" + "node": ">=0.10" } }, - "node_modules/es-set-tostringtag": { + "node_modules/es6-iterator": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.3.tgz", - "integrity": "sha512-3T8uNMC3OQTHkFUsFq8r/BwAXLHvU/9O9mE0fBc/MY5iq/8H7ncvO947LmYA6ldWw9Uh8Yhf25zu6n7nML5QWQ==", - "dev": true, + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", "dependencies": { - "get-intrinsic": "^1.2.4", - "has-tostringtag": "^1.0.2", - "hasown": "^2.0.1" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-shim-unscopables": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.2.tgz", - "integrity": "sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==", - "dev": true, - "dependencies": { - "hasown": "^2.0.0" - } - }, - "node_modules/es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "dependencies": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/es5-ext": { - "version": "0.10.64", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz", - "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==", - "hasInstallScript": true, - "dependencies": { - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.3", - "esniff": "^2.0.1", - "next-tick": "^1.1.0" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/es6-iterator": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", - "dependencies": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" } }, "node_modules/es6-symbol": { @@ -9708,40 +9370,36 @@ } }, "node_modules/eslint": { - "version": "8.57.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", - "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", + "version": "9.9.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.9.0.tgz", + "integrity": "sha512-JfiKJrbx0506OEerjK2Y1QlldtBxkAlLxT5OEcRF8uaQ86noDe2k31Vw9rnSWv+MXZHj7OOUV/dA0AhdLFcyvA==", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.57.0", - "@humanwhocodes/config-array": "^0.11.14", + "@eslint-community/regexpp": "^4.11.0", + "@eslint/config-array": "^0.17.1", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "9.9.0", "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.3.0", "@nodelib/fs.walk": "^1.2.8", - "@ungap/structured-clone": "^1.2.0", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", - "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.3", - "espree": "^9.6.1", - "esquery": "^1.4.2", + "eslint-scope": "^8.0.2", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.1.0", + "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", + "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "graphemer": "^1.4.0", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", @@ -9755,169 +9413,20 @@ "eslint": "bin/eslint.js" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-config-airbnb-base": { - "version": "15.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-15.0.0.tgz", - "integrity": "sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig==", - "dev": true, - "dependencies": { - "confusing-browser-globals": "^1.0.10", - "object.assign": "^4.1.2", - "object.entries": "^1.1.5", - "semver": "^6.3.0" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" + "url": "https://eslint.org/donate" }, "peerDependencies": { - "eslint": "^7.32.0 || ^8.2.0", - "eslint-plugin-import": "^2.25.2" - } - }, - "node_modules/eslint-config-airbnb-base/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/eslint-import-resolver-node": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", - "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", - "dev": true, - "dependencies": { - "debug": "^3.2.7", - "is-core-module": "^2.13.0", - "resolve": "^1.22.4" - } - }, - "node_modules/eslint-import-resolver-node/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/eslint-module-utils": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.1.tgz", - "integrity": "sha512-rXDXR3h7cs7dy9RNpUlQf80nX31XWJEyGq1tRMo+6GsO5VmTe4UTwtmonAD4ZkAsrfMVDA2wlGJ3790Ys+D49Q==", - "dev": true, - "dependencies": { - "debug": "^3.2.7" - }, - "engines": { - "node": ">=4" + "jiti": "*" }, "peerDependenciesMeta": { - "eslint": { + "jiti": { "optional": true } } }, - "node_modules/eslint-module-utils/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/eslint-plugin-import": { - "version": "2.29.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz", - "integrity": "sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==", - "dev": true, - "dependencies": { - "array-includes": "^3.1.7", - "array.prototype.findlastindex": "^1.2.3", - "array.prototype.flat": "^1.3.2", - "array.prototype.flatmap": "^1.3.2", - "debug": "^3.2.7", - "doctrine": "^2.1.0", - "eslint-import-resolver-node": "^0.3.9", - "eslint-module-utils": "^2.8.0", - "hasown": "^2.0.0", - "is-core-module": "^2.13.1", - "is-glob": "^4.0.3", - "minimatch": "^3.1.2", - "object.fromentries": "^2.0.7", - "object.groupby": "^1.0.1", - "object.values": "^1.1.7", - "semver": "^6.3.1", - "tsconfig-paths": "^3.15.0" - }, - "engines": { - "node": ">=4" - }, - "peerDependencies": { - "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" - } - }, - "node_modules/eslint-plugin-import/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/eslint-plugin-import/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/eslint-plugin-import/node_modules/doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dev": true, - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/eslint-plugin-import/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/eslint-plugin-import/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/eslint-plugin-jsdoc": { "version": "50.2.2", "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-50.2.2.tgz", @@ -9957,37 +9466,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint-plugin-jsdoc/node_modules/eslint-visitor-keys": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", - "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-plugin-jsdoc/node_modules/espree": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", - "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "acorn": "^8.12.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.0.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/eslint-plugin-no-null": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/eslint-plugin-no-null/-/eslint-plugin-no-null-1.0.2.tgz", @@ -10013,7 +9491,6 @@ "version": "8.0.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.2.tgz", "integrity": "sha512-6E4xmrTw5wtxnLA5wYL3WDfhZ/1bUBGOXV0zQvVRDOtrR8D0p6W7fs3JweNYhwRYeGvd/1CKX2se0/2s7Q/nJA==", - "dev": true, "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" @@ -10116,16 +9593,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint/node_modules/eslint-scope": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", - "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -10142,20 +9615,6 @@ "node": ">=10.13.0" } }, - "node_modules/eslint/node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/eslint/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -10191,17 +9650,6 @@ "node": ">=8" } }, - "node_modules/eslint/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/esniff": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz", @@ -10217,16 +9665,27 @@ } }, "node_modules/espree": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", - "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", "dependencies": { - "acorn": "^8.9.0", + "acorn": "^8.12.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.1" + "eslint-visitor-keys": "^4.0.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -10587,14 +10046,14 @@ "integrity": "sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==" }, "node_modules/file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", "dependencies": { - "flat-cache": "^3.0.4" + "flat-cache": "^4.0.0" }, "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": ">=16.0.0" } }, "node_modules/file-loader": { @@ -10782,16 +10241,15 @@ } }, "node_modules/flat-cache": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", - "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", "dependencies": { "flatted": "^3.2.9", - "keyv": "^4.5.3", - "rimraf": "^3.0.2" + "keyv": "^4.5.4" }, "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": ">=16" } }, "node_modules/flatted": { @@ -10823,15 +10281,6 @@ "resolved": "https://registry.npmjs.org/font-family-papandreou/-/font-family-papandreou-0.2.0-patch2.tgz", "integrity": "sha512-l/YiRdBSH/eWv6OF3sLGkwErL+n0MqCICi9mppTZBOCL5vixWGDqCYvRcuxB2h7RGCTzaTKOHT2caHvCXQPRlw==" }, - "node_modules/for-each": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", - "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", - "dev": true, - "dependencies": { - "is-callable": "^1.1.3" - } - }, "node_modules/foreground-child": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", @@ -10914,7 +10363,8 @@ "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true }, "node_modules/fsevents": { "version": "2.3.3", @@ -10938,33 +10388,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/function.prototype.name": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.6.tgz", - "integrity": "sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "es-abstract": "^1.22.1", - "functions-have-names": "^1.2.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/functions-have-names": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", - "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -11024,28 +10447,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/get-symbol-description": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.2.tgz", - "integrity": "sha512-g0QYk1dZBxGwk+Ngc+ltRH2IBp2f7zBkBMBJZCDerh6EhlhSR6+9irMCuT/09zD6qkarHUSn529sK/yL4S27mg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.5", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.4" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -11082,6 +10489,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -11091,6 +10499,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -11106,22 +10515,6 @@ "node": ">=4" } }, - "node_modules/globalthis": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", - "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==", - "dev": true, - "dependencies": { - "define-properties": "^1.2.1", - "gopd": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -11170,7 +10563,8 @@ "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", - "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==" + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true }, "node_modules/handle-thing": { "version": "2.0.1", @@ -11178,15 +10572,6 @@ "integrity": "sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==", "dev": true }, - "node_modules/has-bigints": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", - "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -11231,21 +10616,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/has-tostringtag": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", - "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", - "dev": true, - "dependencies": { - "has-symbols": "^1.0.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", @@ -11777,6 +11147,7 @@ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -11785,7 +11156,8 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "node_modules/ini": { "version": "4.1.3", @@ -11796,20 +11168,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/internal-slot": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.7.tgz", - "integrity": "sha512-NGnrKwXzSms2qUUih/ILZ5JBqNTSa1+ZmP6flaIp6KmSElgE9qdndzS3cqjrDovwFdmwsGsLdeFgB6suw+1e9g==", - "dev": true, - "dependencies": { - "es-errors": "^1.3.0", - "hasown": "^2.0.0", - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/internmap": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", @@ -11849,39 +11207,11 @@ "node": ">= 10" } }, - "node_modules/is-array-buffer": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz", - "integrity": "sha512-wcjaerHw0ydZwfhiKbXJWLDY8A7yV7KhjQOpb83hGgGfId/aQa4TOvwyzn2PuswW2gPCYEL/nEAiSVpdOj1lXw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.2.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" }, - "node_modules/is-bigint": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", - "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", - "dev": true, - "dependencies": { - "has-bigints": "^1.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -11893,34 +11223,6 @@ "node": ">=8" } }, - "node_modules/is-boolean-object": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", - "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-callable": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", - "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-core-module": { "version": "2.15.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", @@ -11936,36 +11238,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-data-view": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-data-view/-/is-data-view-1.0.1.tgz", - "integrity": "sha512-AHkaJrsUVW6wq6JS8y3JnM/GJF/9cf+k20+iDzlSaJrinEo5+7vRiteOSwBhHRiAyQATN1AmY4hwzxJKPmYf+w==", - "dev": true, - "dependencies": { - "is-typed-array": "^1.1.13" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-date-object": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", - "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", - "dev": true, - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-docker": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", @@ -12045,18 +11317,6 @@ "integrity": "sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==", "dev": true }, - "node_modules/is-negative-zero": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz", - "integrity": "sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-network-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-network-error/-/is-network-error-1.1.0.tgz", @@ -12077,21 +11337,6 @@ "node": ">=0.12.0" } }, - "node_modules/is-number-object": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", - "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", - "dev": true, - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", @@ -12129,92 +11374,16 @@ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==" }, - "node_modules/is-regex": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", - "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-shared-array-buffer": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.3.tgz", - "integrity": "sha512-nA2hv5XIhLR3uVzDDfCIknerhx8XUKnstuOERPNNIinXG7v9u+ohXF67vxm4TPTEPU6lm61ZkwP3c9PCB97rhg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-stream": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", "dev": true, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-string": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", - "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", - "dev": true, - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-symbol": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", - "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", - "dev": true, - "dependencies": { - "has-symbols": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-typed-array": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.13.tgz", - "integrity": "sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==", - "dev": true, - "dependencies": { - "which-typed-array": "^1.1.14" - }, - "engines": { - "node": ">= 0.4" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, "funding": { - "url": "https://github.com/sponsors/ljharb" + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/is-unicode-supported": { @@ -12229,18 +11398,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-weakref": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", - "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-what": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/is-what/-/is-what-3.14.1.tgz", @@ -12262,12 +11419,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/isarray": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", - "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", - "dev": true - }, "node_modules/isbinaryfile": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", @@ -14565,96 +13716,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object.assign": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.5.tgz", - "integrity": "sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.5", - "define-properties": "^1.2.1", - "has-symbols": "^1.0.3", - "object-keys": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.entries": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.8.tgz", - "integrity": "sha512-cmopxi8VwRIAw/fkijJohSfpef5PdN0pMQJN6VC/ZKvn0LIknWD8KtgY6KlQdEc4tIjcQ3HxSMmnvtzIscdaYQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object.fromentries": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.8.tgz", - "integrity": "sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-abstract": "^1.23.2", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object.groupby": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.3.tgz", - "integrity": "sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-abstract": "^1.23.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object.values": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.2.0.tgz", - "integrity": "sha512-yBYjY9QX2hnRmZHAjG/f13MzmBzxzYgQhFrke06TTyKY5zSTEqkOeukBzIdVA3j3ulu8Qa3MbVFShV7T2RmGtQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/obuf": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz", @@ -14686,6 +13747,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, "dependencies": { "wrappy": "1" } @@ -15153,6 +14215,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -15413,15 +14476,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/possible-typed-array-names": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", - "integrity": "sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==", - "dev": true, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/postcss": { "version": "8.4.41", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.41.tgz", @@ -16442,24 +15496,6 @@ "integrity": "sha512-TVILVSz2jY5D47F4mA4MppkBrafEaiUWJO/TcZHEIuI13AqoZMkK1WMA4Om1YkYbTx+9Ki1/tSUXbceyr9saRg==", "dev": true }, - "node_modules/regexp.prototype.flags": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.2.tgz", - "integrity": "sha512-NcDiDkTLuPR+++OCKB0nWafEmhg/Da8aUPLPMQbK+bxKKCm1/S5he+AqYa4PlMCVBalb4/yxIRub6qkEx5yJbw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.6", - "define-properties": "^1.2.1", - "es-errors": "^1.3.0", - "set-function-name": "^2.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/regexpu-core": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.3.2.tgz", @@ -16783,6 +15819,7 @@ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "deprecated": "Rimraf versions prior to v4 are no longer supported", + "dev": true, "dependencies": { "glob": "^7.1.3" }, @@ -16881,24 +15918,6 @@ "tslib": "^2.1.0" } }, - "node_modules/safe-array-concat": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.2.tgz", - "integrity": "sha512-vj6RsCsWBCf19jIeHEfkRMw8DPiBb+DMXklQ/1SGDHOMlHdPUkZXFQ2YdplS23zESTijAcurb1aSgJA3AgMu1Q==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "get-intrinsic": "^1.2.4", - "has-symbols": "^1.0.3", - "isarray": "^2.0.5" - }, - "engines": { - "node": ">=0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -16919,23 +15938,6 @@ } ] }, - "node_modules/safe-regex-test": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.3.tgz", - "integrity": "sha512-CdASjNJPvRa7roO6Ra/gLYBTzYzzPyyBXxIMdGW3USQLyjWEls2RgW5UBTXaQVp+OrpeCK3bLem8smtmheoRuw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.6", - "es-errors": "^1.3.0", - "is-regex": "^1.1.4" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -17269,21 +16271,6 @@ "node": ">= 0.4" } }, - "node_modules/set-function-name": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz", - "integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==", - "dev": true, - "dependencies": { - "define-data-property": "^1.1.4", - "es-errors": "^1.3.0", - "functions-have-names": "^1.2.3", - "has-property-descriptors": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", @@ -17813,55 +16800,6 @@ "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, - "node_modules/string.prototype.trim": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.9.tgz", - "integrity": "sha512-klHuCNxiMZ8MlsOihJhJEBJAiMVqU3Z2nEXWfWnIqjN0gEFS9J9+IxKozWWtQGcgoa1WUZzLjKPTr4ZHNFTFxw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-abstract": "^1.23.0", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/string.prototype.trimend": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.8.tgz", - "integrity": "sha512-p73uL5VCHCO2BZZ6krwwQE3kCzM7NKmis8S//xEC6fQonchbum4eP6kR4DLEjQFO3Wnj3Fuo8NM0kOSjVdHjZQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-object-atoms": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/string.prototype.trimstart": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.8.tgz", - "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -17886,15 +16824,6 @@ "node": ">=8" } }, - "node_modules/strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/strip-final-newline": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", @@ -18487,30 +17416,6 @@ } } }, - "node_modules/tsconfig-paths": { - "version": "3.15.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", - "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", - "dev": true, - "dependencies": { - "@types/json5": "^0.0.29", - "json5": "^1.0.2", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - } - }, - "node_modules/tsconfig-paths/node_modules/json5": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", - "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", - "dev": true, - "dependencies": { - "minimist": "^1.2.0" - }, - "bin": { - "json5": "lib/cli.js" - } - }, "node_modules/tslib": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", @@ -18572,79 +17477,6 @@ "node": ">= 0.6" } }, - "node_modules/typed-array-buffer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.2.tgz", - "integrity": "sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "es-errors": "^1.3.0", - "is-typed-array": "^1.1.13" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/typed-array-byte-length": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.1.tgz", - "integrity": "sha512-3iMJ9q0ao7WE9tWcaYKIptkNBuOIcZCCT0d4MRvuuH88fEoEH62IuQe0OtraD3ebQEoTRk8XCBoknUNc1Y67pw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "for-each": "^0.3.3", - "gopd": "^1.0.1", - "has-proto": "^1.0.3", - "is-typed-array": "^1.1.13" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/typed-array-byte-offset": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.2.tgz", - "integrity": "sha512-Ous0vodHa56FviZucS2E63zkgtgrACj7omjwd/8lTEMEPFFyjfixMZ1ZXenpgCFBBt4EC1J2XsyVS2gkG0eTFA==", - "dev": true, - "dependencies": { - "available-typed-arrays": "^1.0.7", - "call-bind": "^1.0.7", - "for-each": "^0.3.3", - "gopd": "^1.0.1", - "has-proto": "^1.0.3", - "is-typed-array": "^1.1.13" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/typed-array-length": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.6.tgz", - "integrity": "sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "for-each": "^0.3.3", - "gopd": "^1.0.1", - "has-proto": "^1.0.3", - "is-typed-array": "^1.1.13", - "possible-typed-array-names": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/typed-assert": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/typed-assert/-/typed-assert-1.0.9.tgz", @@ -18699,21 +17531,6 @@ "node": ">=0.8.0" } }, - "node_modules/unbox-primitive": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", - "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "has-bigints": "^1.0.2", - "has-symbols": "^1.0.3", - "which-boxed-primitive": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", @@ -19544,41 +18361,6 @@ "node": ">= 8" } }, - "node_modules/which-boxed-primitive": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", - "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", - "dev": true, - "dependencies": { - "is-bigint": "^1.0.1", - "is-boolean-object": "^1.1.0", - "is-number-object": "^1.0.4", - "is-string": "^1.0.5", - "is-symbol": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/which-typed-array": { - "version": "1.1.15", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.15.tgz", - "integrity": "sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==", - "dev": true, - "dependencies": { - "available-typed-arrays": "^1.0.7", - "call-bind": "^1.0.7", - "for-each": "^0.3.3", - "gopd": "^1.0.1", - "has-tostringtag": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/wildcard": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.1.tgz", @@ -19752,7 +18534,8 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true }, "node_modules/ws": { "version": "8.17.1", diff --git a/package.json b/package.json index 45ee90bb4b..7973aa2177 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,8 @@ "@angular-eslint/template-parser": "18.3.0", "@angular/cli": "^18.1.4", "@angular/compiler-cli": "18.2.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.9.0", "@playwright/test": "1.46.0", "@types/jasmine": "5.1.4", "@types/node": "20.14.15", @@ -95,8 +97,6 @@ "audit-ci": "7.1.0", "autoprefixer": "10.4.20", "eslint": "^9.0.0", - "eslint-config-airbnb-base": "15.0.0", - "eslint-plugin-import": "^2.29.0", "eslint-plugin-jsdoc": "50.2.2", "eslint-plugin-no-null": "latest", "eslint-plugin-prefer-arrow": "1.2.3", diff --git a/src/app/api-connector/applications.service.ts b/src/app/api-connector/applications.service.ts index 027032fc5e..7e739f440d 100644 --- a/src/app/api-connector/applications.service.ts +++ b/src/app/api-connector/applications.service.ts @@ -1,14 +1,14 @@ -import { Injectable } from '@angular/core'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { ApiSettings } from './api-settings.service'; -import { EdamOntologyTerm } from '../applications/edam-ontology-term'; -import { Application } from '../applications/application.model/application.model'; -import { ApplicationLifetimeExtension } from '../applications/application_extension.model'; -import { ApplicationModification } from '../applications/application_modification.model'; -import { ApplicationCreditRequest } from '../applications/application_credit_request'; -import { User } from '../applications/application.model/user.model'; +import { Injectable } from '@angular/core' +import { HttpClient, HttpParams } from '@angular/common/http' +import { Observable } from 'rxjs' +import { map } from 'rxjs/operators' +import { ApiSettings } from './api-settings.service' +import { EdamOntologyTerm } from '../applications/edam-ontology-term' +import { Application } from '../applications/application.model/application.model' +import { ApplicationLifetimeExtension } from '../applications/application_extension.model' +import { ApplicationModification } from '../applications/application_modification.model' +import { ApplicationCreditRequest } from '../applications/application_credit_request' +import { User } from '../applications/application.model/user.model' /** * Service which provides methods for creating application. @@ -16,13 +16,13 @@ import { User } from '../applications/application.model/user.model'; @Injectable() export class ApplicationsService { constructor(private http: HttpClient) { - this.http = http; + this.http = http } adjustApplication(application: Application): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}project_applications/adjust/`, application, { - withCredentials: true, - }); + withCredentials: true + }) } adjustLifetimeExtension(application: ApplicationLifetimeExtension): Observable { @@ -30,9 +30,9 @@ export class ApplicationsService { `${ApiSettings.getApiBaseURL()}project_applications/adjust/lifetime/`, application, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } adjustModification(application: ApplicationModification): Observable { @@ -40,41 +40,41 @@ export class ApplicationsService { `${ApiSettings.getApiBaseURL()}project_applications/adjust/modification/`, application, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getApplicationPI(application_id: string | number): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/${application_id}/pi/`, { - withCredentials: true, - }); + withCredentials: true + }) } getApplicationUser(application_id: string | number): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/${application_id}/user/`, { - withCredentials: true, - }); + withCredentials: true + }) } getLifetimeExtensionUser(lifetimeextension_id: string | number): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}project_applications/lifetime/extensions/${lifetimeextension_id}/user/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getModificationUser(project_id: string | number): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/modifications/${project_id}/user/`, { - withCredentials: true, - }); + withCredentials: true + }) } getApplicationValidationByHash(hash: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/validation/${hash}/`, { - withCredentials: true, - }); + withCredentials: true + }) } resetPIValidation(application: Application): Observable { @@ -82,72 +82,72 @@ export class ApplicationsService { `${ApiSettings.getApiBaseURL()}project_applications/validation/${application.project_application_id}/reset/`, null, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } validateApplicationAsPIByHash(hash: string, application: Application): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}project_applications/validation/${hash}/`, application, { - withCredentials: true, - }); + withCredentials: true + }) } getApplication(app_id: string): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}project_applications/${app_id}/`, { - withCredentials: true, + withCredentials: true }) - .pipe(map((app: Application) => new Application(app))); + .pipe(map((app: Application) => new Application(app))) } getApplicationMigratedByGroupId(group_id: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/migrated/${group_id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } getApplicationsMigratedByProjectIds(project_ids: string[]): Observable { - const params: HttpParams = new HttpParams().set('project_ids', project_ids.join()); + const params: HttpParams = new HttpParams().set('project_ids', project_ids.join()) return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/migrated/byList/`, { withCredentials: true, - params, - }); + params + }) } getFullApplicationByUserPermissions(app_id: string): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}project_applications/${app_id}/byPermission/`, { - withCredentials: true, + withCredentials: true }) - .pipe(map((app: Application) => new Application(app))); + .pipe(map((app: Application) => new Application(app))) } getApplicationPerunId(app_id: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/${app_id}/perun/`, { - withCredentials: true, - }); + withCredentials: true + }) } getApplicationClient(app_id: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/${app_id}/client/`, { - withCredentials: true, - }); + withCredentials: true + }) } getEdamOntologyTerms(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}edam_ontology/`, { - withCredentials: true, - }); + withCredentials: true + }) } addEdamOntologyTerms(application_id: number | string, data: EdamOntologyTerm[]): Observable { - const params: any = { edam_ontology_terms: data }; + const params: any = { edam_ontology_terms: data } return this.http.post(`${ApiSettings.getApiBaseURL()}project_applications/${application_id}/edam_terms/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } /** @@ -158,74 +158,74 @@ export class ApplicationsService { */ getApplicationClientAvaiable(app_id: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/${app_id}/clients/resource/`, { - withCredentials: true, - }); + withCredentials: true + }) } getAllApplications(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/`, { - withCredentials: true, - }); + withCredentials: true + }) } getSubmittedApplications(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/submitted/`, { - withCredentials: true, - }); + withCredentials: true + }) } getExtensionRequestsCounter(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/extensions_counter/`, { - withCredentials: true, - }); + withCredentials: true + }) } getLifetimeRequestedApplications(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/lifetime_requests/`, { - withCredentials: true, - }); + withCredentials: true + }) } getModificationRequestedApplications(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/modifications_requests/`, { - withCredentials: true, - }); + withCredentials: true + }) } getCreditsExtensionRequest(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/credits_requests/`, { - withCredentials: true, - }); + withCredentials: true + }) } addNewApplication(application: Application): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}project_applications/`, application, { - withCredentials: true, - }); + withCredentials: true + }) } requestModification(modification: ApplicationModification): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}project_applications/modifications/`, modification, { - withCredentials: true, - }); + withCredentials: true + }) } requestAdditionalLifetime(lifetimeRequest: ApplicationLifetimeExtension): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}project_applications/lifetime/extensions/`, lifetimeRequest, { - withCredentials: true, - }); + withCredentials: true + }) } requestAdditionalCredits(creditRequest: ApplicationCreditRequest): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}project_applications/credits/extensions/`, creditRequest, { - withCredentials: true, - }); + withCredentials: true + }) } deleteAdditionalCreditsRequests(request_id: number | string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}project_applications/credits/extensions/${request_id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } declineAdditionalCredits(request_id: number | string): Observable { @@ -233,15 +233,15 @@ export class ApplicationsService { `${ApiSettings.getApiBaseURL()}project_applications/credits/extensions/${request_id}/decline/`, null, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } declineApplication(app_id: number | string): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}project_applications/${app_id}/decline/`, null, { - withCredentials: true, - }); + withCredentials: true + }) } approveAdditionalCreditsRequest(request_id: number | string): Observable { @@ -250,9 +250,9 @@ export class ApplicationsService { null, { withCredentials: true, - observe: 'response', - }, - ); + observe: 'response' + } + ) } approveAdditionalLifetime(request_id: number | string): Observable { @@ -261,9 +261,9 @@ export class ApplicationsService { null, { withCredentials: true, - observe: 'response', - }, - ); + observe: 'response' + } + ) } withdrawExtensionRequest(request_id: number | string): Observable { @@ -271,9 +271,9 @@ export class ApplicationsService { `${ApiSettings.getApiBaseURL()}project_applications/lifetime/extensions/${request_id}/withdraw/`, null, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } withdrawModificationRequest(request_id: number | string): Observable { @@ -281,9 +281,9 @@ export class ApplicationsService { `${ApiSettings.getApiBaseURL()}project_applications/modifications/${request_id}/withdraw/`, null, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } declineAdditionalLifetime(request_id: number | string): Observable { @@ -291,15 +291,15 @@ export class ApplicationsService { `${ApiSettings.getApiBaseURL()}project_applications/lifetime/extensions/${request_id}/decline/`, null, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } deleteAdditionalLifetimeRequests(request_id: number | string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}project_applications/lifetime/extensions/${request_id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } approveModificationRequest(request_id: number | string): Observable { @@ -308,9 +308,9 @@ export class ApplicationsService { null, { withCredentials: true, - observe: 'response', - }, - ); + observe: 'response' + } + ) } declineModificationRequest(request_id: number | string): Observable { @@ -318,20 +318,20 @@ export class ApplicationsService { `${ApiSettings.getApiBaseURL()}project_applications/modifications/${request_id}/decline/`, null, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } deleteModificationRequest(request_id: number | string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}project_applications/modifications/${request_id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } deleteApplication(application_id: string | number): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}project_applications/${application_id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } } diff --git a/src/app/api-connector/bioconda.service.ts b/src/app/api-connector/bioconda.service.ts index 217010bdaa..ad63d0ba47 100644 --- a/src/app/api-connector/bioconda.service.ts +++ b/src/app/api-connector/bioconda.service.ts @@ -1,91 +1,86 @@ -import { Injectable } from '@angular/core'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { ApiSettings } from './api-settings.service'; -import { ResearchEnvironment } from '../virtualmachines/virtualmachinemodels/res-env'; -import { VirtualMachine } from '../virtualmachines/virtualmachinemodels/virtualmachine'; -import { Backend } from '../virtualmachines/conda/backend/backend'; +import { Injectable } from '@angular/core' +import { HttpClient, HttpParams } from '@angular/common/http' +import { Observable } from 'rxjs' +import { map } from 'rxjs/operators' +import { ApiSettings } from './api-settings.service' +import { ResearchEnvironment } from '../virtualmachines/virtualmachinemodels/res-env' +import { VirtualMachine } from '../virtualmachines/virtualmachinemodels/virtualmachine' +import { Backend } from '../virtualmachines/conda/backend/backend' /** * Bioconda service. */ @Injectable() export class BiocondaService { - constructor(private http: HttpClient) { - this.http = http; + this.http = http } getAllTools(page: number, name?: string): Observable { - const params: HttpParams = new HttpParams() - .set('page', page.toString()) - .set('name', name); + const params: HttpParams = new HttpParams().set('page', page.toString()).set('name', name) return this.http.get(`${ApiSettings.getApiBaseURL()}conda/all/`, { withCredentials: true, - params, - }); + params + }) } getForcTemplates(clientid: string): Observable { - const params: HttpParams = new HttpParams() - .set('clientid', clientid); - - return this.http.get(`${ApiSettings.getApiBaseURL()}forc/templates/`, { - withCredentials: true, - params, - }).pipe( - map( - (resenvs: ResearchEnvironment[]): ResearchEnvironment[] => resenvs.map( - (resenv: ResearchEnvironment): ResearchEnvironment => new ResearchEnvironment(resenv), - ), - ), - ); + const params: HttpParams = new HttpParams().set('clientid', clientid) + + return this.http + .get(`${ApiSettings.getApiBaseURL()}forc/templates/`, { + withCredentials: true, + params + }) + .pipe( + map((resenvs: ResearchEnvironment[]): ResearchEnvironment[] => + resenvs.map((resenv: ResearchEnvironment): ResearchEnvironment => new ResearchEnvironment(resenv)) + ) + ) } getSuggestedForcTemplates(facility_id?: string): Observable { - const params: HttpParams = new HttpParams() - .set('facility_id', facility_id); + const params: HttpParams = new HttpParams().set('facility_id', facility_id) return this.http.get(`${ApiSettings.getApiBaseURL()}forc/templates/allowed/`, { withCredentials: true, - params, - }); + params + }) } getTemplateNameByVmName(vm: VirtualMachine): Observable { - const params: HttpParams = new HttpParams().set('vm', vm.name); + const params: HttpParams = new HttpParams().set('vm', vm.name) return this.http.get(`${ApiSettings.getApiBaseURL()}forc/backends/vm_name/`, { withCredentials: true, - params, - }); + params + }) } getUsersForBackend(vmId: string): Observable { - const params: HttpParams = new HttpParams().set('vm_id', vmId); + const params: HttpParams = new HttpParams().set('vm_id', vmId) return this.http.get(`${ApiSettings.getApiBaseURL()}forc/backs/users/`, { withCredentials: true, - params, - }); + params + }) } addUserToBackend(vmId: string, user_id: string): Observable { - const params: HttpParams = new HttpParams().set('vm_id', vmId).set('user_id', user_id); + const params: HttpParams = new HttpParams().set('vm_id', vmId).set('user_id', user_id) return this.http.post(`${ApiSettings.getApiBaseURL()}forc/backs/users/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } deleteUserFromBackend(vmId: string, user_id: string): Observable { - const params: HttpParams = new HttpParams().set('vm_id', vmId).set('user_id', user_id); + const params: HttpParams = new HttpParams().set('vm_id', vmId).set('user_id', user_id) return this.http.delete(`${ApiSettings.getApiBaseURL()}forc/backs/users/`, { withCredentials: true, - params, - }); + params + }) } } diff --git a/src/app/api-connector/client.service.ts b/src/app/api-connector/client.service.ts index 7847b72c7f..aa730fea7e 100644 --- a/src/app/api-connector/client.service.ts +++ b/src/app/api-connector/client.service.ts @@ -1,86 +1,78 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { map } from 'rxjs/operators'; -import { ApiSettings } from './api-settings.service'; -import { Client } from '../vo_manager/clients/client.model'; -import { IResponseTemplate } from './response-template'; +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { HttpClient, HttpParams } from '@angular/common/http' +import { map } from 'rxjs/operators' +import { ApiSettings } from './api-settings.service' +import { Client } from '../vo_manager/clients/client.model' +import { IResponseTemplate } from './response-template' /** * Service which provides client methods. */ @Injectable() export class ClientService { - clientURL: string = `${ApiSettings.getApiBaseURL()}clients/`; + clientURL: string = `${ApiSettings.getApiBaseURL()}clients/` constructor(private http: HttpClient) { - this.http = http; + this.http = http } isClientAvaiable(): Observable { return this.http.get(`${this.clientURL}active/`, { - withCredentials: true, - }); + withCredentials: true + }) } getClientsChecked(): Observable { - - return this.http.get(this.clientURL, { - withCredentials: true, - }).pipe( - map( - (clients: Client[]): Client[] => clients.map( - (client: Client): Client => new Client(client), - ), - ), - ); + return this.http + .get(this.clientURL, { + withCredentials: true + }) + .pipe(map((clients: Client[]): Client[] => clients.map((client: Client): Client => new Client(client)))) } checkClient(host: string, port: string): Observable { - const params: HttpParams = new HttpParams().set('host', host).set('port', port); + const params: HttpParams = new HttpParams().set('host', host).set('port', port) return this.http.post(`${this.clientURL}checkClient/`, params, { - withCredentials: true, - }); - + withCredentials: true + }) } getClientLimits(client_id: number | string): Observable { - return this.http.get(`${this.clientURL}${client_id}/limits/`, { - withCredentials: true, - }); - + withCredentials: true + }) } postClient(host: string, port: string, location: string): Observable { - - const params: HttpParams = new HttpParams().set('host', host).set('port', port).set('location', location); + const params: HttpParams = new HttpParams().set('host', host).set('port', port).set('location', location) return this.http.post(this.clientURL, params, { - withCredentials: true, - }); + withCredentials: true + }) } deleteClient(client_id: number): Observable { return this.http.delete(`${this.clientURL}${client_id}/`, { - withCredentials: true, - }); - + withCredentials: true + }) } updateClient(client: Client): Observable { - const params: HttpParams = new HttpParams().set('host', client.host).set('port', client.port).set('location', client.location); + const params: HttpParams = new HttpParams() + .set('host', client.host) + .set('port', client.port) + .set('location', client.location) return this.http.patch(`${this.clientURL}${client.id}/`, params, { - withCredentials: true, - }); - + withCredentials: true + }) } switchActive(client_id: string): Observable { return this.http.post(`${this.clientURL}${client_id}/switchActive/`, null, { - withCredentials: true, - }); + withCredentials: true + }) } } diff --git a/src/app/api-connector/credits.service.ts b/src/app/api-connector/credits.service.ts index d89ea521c6..19c722d345 100644 --- a/src/app/api-connector/credits.service.ts +++ b/src/app/api-connector/credits.service.ts @@ -1,10 +1,10 @@ -import { Injectable } from '@angular/core'; -import { map } from 'rxjs/operators'; -import { Observable } from 'rxjs'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { ApiSettings } from './api-settings.service'; -import { Flavor } from '../virtualmachines/virtualmachinemodels/flavor'; -import { ResourceWeight, IResourceWeight } from '../credits-calculator/resource-weights.model/resource-weights.model'; +import { Injectable } from '@angular/core' +import { map } from 'rxjs/operators' +import { Observable } from 'rxjs' +import { HttpClient, HttpParams } from '@angular/common/http' +import { ApiSettings } from './api-settings.service' +import { Flavor } from '../virtualmachines/virtualmachinemodels/flavor' +import { ResourceWeight, IResourceWeight } from '../credits-calculator/resource-weights.model/resource-weights.model' /** * Service which delivers functions for services related to the credit service. @@ -12,7 +12,7 @@ import { ResourceWeight, IResourceWeight } from '../credits-calculator/resource- @Injectable({ providedIn: 'root' }) export class CreditsService { constructor(private http: HttpClient) { - this.http = http; + this.http = http } /** @@ -25,9 +25,9 @@ export class CreditsService { `${ApiSettings.getApiBaseURL()}creditManager/getCreditsForApplication/`, { flavors, months }, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -39,18 +39,18 @@ export class CreditsService { cpus: number, ram: number, months: number, - projectApplicationId: string, + projectApplicationId: string ): Observable { const params: HttpParams = new HttpParams() .set('new_cpu', cpus.toString()) .set('new_ram', ram.toString()) .set('new_lifetime', months.toString()) - .set('project_application_id', projectApplicationId); + .set('project_application_id', projectApplicationId) return this.http.get(`${ApiSettings.getApiBaseURL()}creditManager/getExtraCreditsNumber/`, { withCredentials: true, - params, - }); + params + }) } /** @@ -61,12 +61,12 @@ export class CreditsService { public getExtraCreditsForLifetimeExtension(months: number, projectApplicationId: string): Observable { const params: HttpParams = new HttpParams() .set('new_lifetime', months.toString()) - .set('project_application_id', projectApplicationId); + .set('project_application_id', projectApplicationId) return this.http.get(`${ApiSettings.getApiBaseURL()}creditManager/getExtraCreditsNumberLifetime/`, { withCredentials: true, - params, - }); + params + }) } /** @@ -78,8 +78,8 @@ export class CreditsService { return this.http.post( `${ApiSettings.getApiBaseURL()}creditManager/getExtraCreditsNumberResource/`, { flavors, projectApplicationId }, - { withCredentials: true }, - ); + { withCredentials: true } + ) } /** @@ -89,12 +89,12 @@ export class CreditsService { * @param ram Amount of ram */ public getCreditsPerHour(cpus: number, ram: number): Observable { - const params: HttpParams = new HttpParams().set('cpu', cpus.toString()).set('ram', ram.toString()); + const params: HttpParams = new HttpParams().set('cpu', cpus.toString()).set('ram', ram.toString()) return this.http.get(`${ApiSettings.getApiBaseURL()}creditManager/getCreditsPerHour/`, { withCredentials: true, - params, - }); + params + }) } /** @@ -104,8 +104,8 @@ export class CreditsService { */ public getCurrentCreditsOfProject(group_id: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}creditManager/${group_id}/getUsedCredits/`, { - withCredentials: true, - }); + withCredentials: true + }) } /** @@ -115,51 +115,53 @@ export class CreditsService { */ public getCreditsUsageHistoryOfProject(group_id: number): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}creditManager/${group_id}/getCreditsHistory/`, { - withCredentials: true, - }); + withCredentials: true + }) } public getPublicCreditsNeeded( hours: number, flavor_pairs: [string, number][], compute_center_name: string, - start_timestamp: number, + start_timestamp: number ): Observable { const params: object = { hours, flavor_pairs, compute_center_name, - start_timestamp, - }; + start_timestamp + } return this.http.post(`${ApiSettings.getApiBase()}public/credits_calculator/needed/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } public getPublicHoursPossible( credits: number, flavor_pairs: [string, number][], compute_center_name: string, - start_timestamp: number, + start_timestamp: number ): Observable { const params: object = { credits, flavor_pairs, compute_center_name, - start_timestamp, - }; + start_timestamp + } return this.http.post(`${ApiSettings.getApiBase()}public/credits_calculator/time/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } public getCreditsWeights(): Observable { return this.http .get(`${ApiSettings.getApiBase()}public/creditsweights/`) .pipe( - map((weights: IResourceWeight[]): ResourceWeight[] => weights.map((weight: IResourceWeight): ResourceWeight => new ResourceWeight(weight))), - ); + map((weights: IResourceWeight[]): ResourceWeight[] => + weights.map((weight: IResourceWeight): ResourceWeight => new ResourceWeight(weight)) + ) + ) } } diff --git a/src/app/api-connector/email.service.ts b/src/app/api-connector/email.service.ts index eb313a36d2..0ec65ba499 100644 --- a/src/app/api-connector/email.service.ts +++ b/src/app/api-connector/email.service.ts @@ -1,32 +1,32 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { HttpClient } from '@angular/common/http'; -import { ApiSettings } from './api-settings.service'; -import { IResponseTemplate } from './response-template'; -import { CsvMailTemplateModel } from '../shared/classes/csvMailTemplate.model'; +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { HttpClient } from '@angular/common/http' +import { ApiSettings } from './api-settings.service' +import { IResponseTemplate } from './response-template' +import { CsvMailTemplateModel } from '../shared/classes/csvMailTemplate.model' /** * Service which provides methods for Flavors. */ @Injectable({ - providedIn: 'root', + providedIn: 'root' }) export class EmailService { constructor(private http: HttpClient) {} getMailTemplates(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}emails/templates/`, { - withCredentials: true, - }); + withCredentials: true + }) } sendCsvTemplate(csvFile: File): Observable { - const formData = new FormData(); - formData.append('csv_file', csvFile, csvFile.name); + const formData = new FormData() + formData.append('csv_file', csvFile, csvFile.name) return this.http.post(`${ApiSettings.getApiBaseURL()}emails/templated/csv/`, formData, { - withCredentials: true, - }); + withCredentials: true + }) } sendCsvTemplatedMail( @@ -35,21 +35,21 @@ export class EmailService { subject: string, message: string, adminsOnly: boolean, - reply?: string, + reply?: string ): Observable { - const formData = new FormData(); - formData.append('csv_file', csvFile, csvFile.name); - formData.append('project_ids', JSON.stringify(projectIds)); - formData.append('subject', subject); - formData.append('message', message); - formData.append('adminsOnly', String(adminsOnly)); + const formData = new FormData() + formData.append('csv_file', csvFile, csvFile.name) + formData.append('project_ids', JSON.stringify(projectIds)) + formData.append('subject', subject) + formData.append('message', message) + formData.append('adminsOnly', String(adminsOnly)) if (reply !== undefined) { - formData.append('reply', reply); + formData.append('reply', reply) } return this.http.post(`${ApiSettings.getApiBaseURL()}emails/templated/csv/projects/`, formData, { - withCredentials: true, - }); + withCredentials: true + }) } sendMailToProjects( @@ -57,7 +57,7 @@ export class EmailService { subject: string, message: string, adminsOnly: boolean, - reply?: string, + reply?: string ): Observable { return this.http.post( `${ApiSettings.getApiBaseURL()}emails/templated/projects/`, @@ -66,11 +66,11 @@ export class EmailService { subject, message, adminsOnly, - reply, + reply }, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } } diff --git a/src/app/api-connector/facility.service.ts b/src/app/api-connector/facility.service.ts index 014f5b4657..d619368c46 100644 --- a/src/app/api-connector/facility.service.ts +++ b/src/app/api-connector/facility.service.ts @@ -1,18 +1,18 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { ApiSettings } from './api-settings.service'; -import { Application } from '../applications/application.model/application.model'; -import { VolumeStorageFactor } from '../facility_manager/resources/volume-storage-factor'; -import { ObjectStorageFactor } from '../facility_manager/resources/object-storage-factor'; -import { ResourceMachine } from '../facility_manager/resources/resource-machine'; -import { ProjectMember } from '../projectmanagement/project_member.model'; -import { GPUSpecification } from '../facility_manager/resources/gpu-specification'; -import { GeneralStorageFactor } from '../facility_manager/resources/general-storage-factor'; -import { ClusterPage } from '../virtualmachines/clusters/clusterPage.model'; -import { VolumePage } from '../virtualmachines/volumes/volumePage.model'; -import { SnapshotPage } from '../virtualmachines/snapshots/snapshotPage.model'; +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { map } from 'rxjs/operators' +import { HttpClient, HttpParams } from '@angular/common/http' +import { ApiSettings } from './api-settings.service' +import { Application } from '../applications/application.model/application.model' +import { VolumeStorageFactor } from '../facility_manager/resources/volume-storage-factor' +import { ObjectStorageFactor } from '../facility_manager/resources/object-storage-factor' +import { ResourceMachine } from '../facility_manager/resources/resource-machine' +import { ProjectMember } from '../projectmanagement/project_member.model' +import { GPUSpecification } from '../facility_manager/resources/gpu-specification' +import { GeneralStorageFactor } from '../facility_manager/resources/general-storage-factor' +import { ClusterPage } from '../virtualmachines/clusters/clusterPage.model' +import { VolumePage } from '../virtualmachines/volumes/volumePage.model' +import { SnapshotPage } from '../virtualmachines/snapshots/snapshotPage.model' /** * Service which provides methods for the facilities. @@ -20,7 +20,7 @@ import { SnapshotPage } from '../virtualmachines/snapshots/snapshotPage.model'; @Injectable() export class FacilityService { constructor(private http: HttpClient) { - this.http = http; + this.http = http } /** @@ -30,20 +30,20 @@ export class FacilityService { */ getComputeCenters(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}computecenters/`, { - withCredentials: true, - }); + withCredentials: true + }) } /** * Sets support e-mail addresses for computecenter. */ setSupportMails(facilityId: string, supportMails: string): Observable { - const params: HttpParams = new HttpParams().set('mails', supportMails); + const params: HttpParams = new HttpParams().set('mails', supportMails) return this.http.post(`${ApiSettings.getApiBaseURL()}computecenters/${facilityId}/supportMails/`, params, { withCredentials: true, - observe: 'response', - }); + observe: 'response' + }) } /** @@ -52,32 +52,32 @@ export class FacilityService { getSupportMails(facilityId: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}computecenters/${facilityId}/supportMails/`, { withCredentials: true, - observe: 'response', - }); + observe: 'response' + }) } getWfcSubmittedApplications(facility_id: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}computecenters/${facility_id}/wfc/submitted/`, { - withCredentials: true, - }); + withCredentials: true + }) } getWfcLifetimeRequestedApplications(facility_id: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility_id}/wfc/lifetime_requests/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getWfcTerminationRequestedApplications(facility_id: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility_id}/wfc/termination_requests/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getClustersFacility( @@ -85,64 +85,64 @@ export class FacilityService { page: number, vm_per_site: number, filter?: string, - filter_status?: string[], + filter_status?: string[] ): Observable { let params: HttpParams = new HttpParams() .set('page', page.toString()) - .set('cluster_per_site', vm_per_site.toString()); + .set('cluster_per_site', vm_per_site.toString()) if (filter) { - params = params.set('filter', filter); + params = params.set('filter', filter) } if (filter_status) { - params = params.append('filter_status', JSON.stringify(filter_status)); + params = params.append('filter_status', JSON.stringify(filter_status)) } return this.http .get(`${ApiSettings.getApiBaseURL()}computecenters/${facility_id}/clusters/`, { withCredentials: true, - params, + params }) - .pipe(map((cluster_page: ClusterPage): ClusterPage => new ClusterPage(cluster_page))); + .pipe(map((cluster_page: ClusterPage): ClusterPage => new ClusterPage(cluster_page))) } getComputeCenterClientLimits(facility_id): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}computecenters/${facility_id}/simpleVM/limits/`, { - withCredentials: true, - }); + withCredentials: true + }) } getComputeCenterClientLimitsAvailable(facility_id, application_id): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility_id}/simpleVM/${application_id}/limits/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getWfcModificationRequestedApplications(facility_id: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility_id}/wfc/modifications_requests/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getWfcCreditsRequestedApplications(facility_id: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility_id}/wfc/credits_requests/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getExtensionRequestsCounterFacility(facility_id: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}computecenters/${facility_id}/extensions_counter/`, { - withCredentials: true, - }); + withCredentials: true + }) } /** @@ -152,11 +152,11 @@ export class FacilityService { * @param newsId the id of the news containing the motd */ setMOTDForFacility(facilityID: string, newsId: string): Observable { - const httpParams: HttpParams = new HttpParams().set('facilityID', facilityID).set('newsID', newsId); + const httpParams: HttpParams = new HttpParams().set('facilityID', facilityID).set('newsID', newsId) return this.http.post(`${ApiSettings.getApiBaseURL()}wp-motd-management/`, httpParams, { - withCredentials: true, - }); + withCredentials: true + }) } /** @@ -166,15 +166,15 @@ export class FacilityService { */ getManagerFacilities(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}facilityManagers/current/facilities/`, { - withCredentials: true, - }); + withCredentials: true + }) } getAllMembersOfFacility(facility: number | string, status: number): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}computecenters/${facility}/members/`, { withCredentials: true, - params: { status: status.toString() }, - }); + params: { status: status.toString() } + }) } /** @@ -186,16 +186,18 @@ export class FacilityService { */ getFacilityAllowedGroupsWithDetailsAndSpecificStatus( facility: number | string, - status: number, + status: number ): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}computecenters/${facility}/projects/`, { withCredentials: true, - params: { status: status.toString() }, + params: { status: status.toString() } }) .pipe( - map((applications: Application[]): Application[] => applications.map((application: Application): Application => new Application(application))), - ); + map((applications: Application[]): Application[] => + applications.map((application: Application): Application => new Application(application)) + ) + ) } /** @@ -209,7 +211,7 @@ export class FacilityService { elixir_id: string, isPi: boolean, isAdmin: boolean, - isMember: boolean, + isMember: boolean ): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}computecenters/${facility}/projects/filter/`, { @@ -218,12 +220,14 @@ export class FacilityService { elixir_id, isPi, isAdmin, - isMember, - }, + isMember + } }) .pipe( - map((applications: Application[]): Application[] => applications.map((application: Application): Application => new Application(application))), - ); + map((applications: Application[]): Application[] => + applications.map((application: Application): Application => new Application(application)) + ) + ) } /** @@ -234,8 +238,8 @@ export class FacilityService { */ getFacilityResources(facility: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}computecenters/${facility}/projects/resources/`, { - withCredentials: true, - }); + withCredentials: true + }) } /** @@ -246,8 +250,8 @@ export class FacilityService { */ getFacilityApplicationsWaitingForConfirmation(facility: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}computecenters/${facility}/applications/`, { - withCredentials: true, - }); + withCredentials: true + }) } /** @@ -260,9 +264,9 @@ export class FacilityService { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/applications_history/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -275,9 +279,9 @@ export class FacilityService { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/applications/${id}/detail/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -289,14 +293,14 @@ export class FacilityService { getFacilityVolumes(facility: number | string, items_per_page: number, current_page: number): Observable { const params: HttpParams = new HttpParams() .set('items_per_page', items_per_page.toString()) - .set('page', current_page.toString()); + .set('page', current_page.toString()) return this.http .get(`${ApiSettings.getApiBaseURL()}computecenters/${facility}/volumes/`, { withCredentials: true, - params, + params }) - .pipe(map((volume_page: VolumePage): VolumePage => new VolumePage(volume_page))); + .pipe(map((volume_page: VolumePage): VolumePage => new VolumePage(volume_page))) } /** @@ -311,21 +315,21 @@ export class FacilityService { facility: number | string, currentPage: number, snapsPerSite: number, - filter?: string, + filter?: string ): Observable { let params: HttpParams = new HttpParams() .set('page', currentPage.toString()) - .set('snaps_per_site', snapsPerSite.toString()); + .set('snaps_per_site', snapsPerSite.toString()) if (filter) { - params = params.set('filter', filter); + params = params.set('filter', filter) } return this.http .get(`${ApiSettings.getApiBaseURL()}computecenters/${facility}/snapshots/`, { withCredentials: true, - params, + params }) - .pipe(map((snapshot_page: SnapshotPage): SnapshotPage => new SnapshotPage(snapshot_page))); + .pipe(map((snapshot_page: SnapshotPage): SnapshotPage => new SnapshotPage(snapshot_page))) } /** @@ -338,9 +342,9 @@ export class FacilityService { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/modification_applications/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -351,46 +355,46 @@ export class FacilityService { * @returns */ approveFacilityApplication(facility: number | string, application_id: number | string): Observable { - const params: HttpParams = new HttpParams().set('action', 'approve'); + const params: HttpParams = new HttpParams().set('action', 'approve') return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/applications/${application_id}/status/`, params, { withCredentials: true, - observe: 'response', - }, - ); + observe: 'response' + } + ) } addVolumeStorageFactor( facility: number | string, - volumeStorageFactor: VolumeStorageFactor, + volumeStorageFactor: VolumeStorageFactor ): Observable { - const params: HttpParams = new HttpParams().set('volumeStorageFactor', JSON.stringify(volumeStorageFactor)); + const params: HttpParams = new HttpParams().set('volumeStorageFactor', JSON.stringify(volumeStorageFactor)) return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/volumeStorageFactors/`, params, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } addObjectStorageFactor( facility: number | string, - objectStorageFactor: ObjectStorageFactor, + objectStorageFactor: ObjectStorageFactor ): Observable { - const params: HttpParams = new HttpParams().set('objectStorageFactor', JSON.stringify(objectStorageFactor)); + const params: HttpParams = new HttpParams().set('objectStorageFactor', JSON.stringify(objectStorageFactor)) return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/objectStorageFactors/`, params, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -402,126 +406,126 @@ export class FacilityService { */ deleteResourceMachine( facility: number | string, - resource_machine_id: number | string, + resource_machine_id: number | string ): Observable { return this.http.delete( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/resourcesMachine/${resource_machine_id}/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } addResourceMachine(facility: number | string, resource_machine: ResourceMachine): Observable { - const params: HttpParams = new HttpParams().set('resource_machine', JSON.stringify(resource_machine)); + const params: HttpParams = new HttpParams().set('resource_machine', JSON.stringify(resource_machine)) return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/resourcesMachine/`, params, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } updateResourceMachine(facility: number | string, resource_machine: ResourceMachine): Observable { - const params: HttpParams = new HttpParams().set('resource_machine', JSON.stringify(resource_machine)); + const params: HttpParams = new HttpParams().set('resource_machine', JSON.stringify(resource_machine)) // tslint:disable-next-line:max-line-length return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/resourcesMachine/${resource_machine.id}/`, params, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getResourceMachine(facility: number | string, resource_machine_id: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/resourcesMachine/${resource_machine_id}/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getResourceMachines(facility: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/resourcesMachine/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } updateGPUSpecification(facility: number | string, gpu_specification: GPUSpecification): Observable { - const params: HttpParams = new HttpParams().set('gpu_specification', JSON.stringify(gpu_specification)); + const params: HttpParams = new HttpParams().set('gpu_specification', JSON.stringify(gpu_specification)) return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/gpuSpecification/${gpu_specification.id}/`, params, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getGPUSpecification(facility: number | string, gpu_spec_id: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/gpuSpecification/${gpu_spec_id}/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getGPUSpecifications(facility: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/gpuSpecification/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } deleteGPUSpecification(facility: number | string, gpu_spec_id: number | string): Observable { return this.http.delete( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/gpuSpecification/${gpu_spec_id}/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } addGPUSpecification(facility: number | string, gpu_specification: GPUSpecification): Observable { - const params: HttpParams = new HttpParams().set('gpu_specification', JSON.stringify(gpu_specification)); + const params: HttpParams = new HttpParams().set('gpu_specification', JSON.stringify(gpu_specification)) return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/gpuSpecification/`, params, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getVolumeStorageFactor(facility: number | string, factor_id: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/volumeStorageFactors/${factor_id}/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getObjectStorageFactor(facility: number | string, factor_id: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/objectStorageFactors/${factor_id}/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -531,16 +535,16 @@ export class FacilityService { * @param factor */ updateVolumeStorageFactor(facility: number | string, factor: VolumeStorageFactor): Observable { - const params: HttpParams = new HttpParams().set('factor', JSON.stringify(factor)); + const params: HttpParams = new HttpParams().set('factor', JSON.stringify(factor)) // tslint:disable-next-line:max-line-length return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/volumeStorageFactors/${factor.id}/`, params, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -550,16 +554,16 @@ export class FacilityService { * @param factor */ updateObjectStorageFactor(facility: number | string, factor: ObjectStorageFactor): Observable { - const params: HttpParams = new HttpParams().set('factor', JSON.stringify(factor)); + const params: HttpParams = new HttpParams().set('factor', JSON.stringify(factor)) // tslint:disable-next-line:max-line-length return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/objectStorageFactors/${factor.id}/`, params, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -573,9 +577,9 @@ export class FacilityService { return this.http.delete( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/volumeStorageFactors/${factor_id}/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -589,70 +593,70 @@ export class FacilityService { return this.http.delete( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/objectStorageFactors/${factor_id}/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getGeneralStorageFactors(facility: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/generalStorageFactors/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getGeneralStorageFactor(facility: number | string, factor_id: number | string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/generalStorageFactors/${factor_id}/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } updateGeneralStorageFactor( facility: number | string, - factor: GeneralStorageFactor, + factor: GeneralStorageFactor ): Observable { - const params: HttpParams = new HttpParams().set('factor', JSON.stringify(factor)); + const params: HttpParams = new HttpParams().set('factor', JSON.stringify(factor)) // tslint:disable-next-line:max-line-length return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/generalStorageFactors/${factor.id}/`, params, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } deleteGeneralStorageFactor( facility: number | string, - factor_id: number | string, + factor_id: number | string ): Observable { return this.http.delete( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/generalStorageFactors/${factor_id}/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } addGeneralStorageFactor( facility: number | string, - generalStorageFactor: GeneralStorageFactor, + generalStorageFactor: GeneralStorageFactor ): Observable { - const params: HttpParams = new HttpParams().set('generalStorageFactor', JSON.stringify(generalStorageFactor)); + const params: HttpParams = new HttpParams().set('generalStorageFactor', JSON.stringify(generalStorageFactor)) return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/generalStorageFactors/`, params, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -665,9 +669,9 @@ export class FacilityService { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/volumeStorageFactors/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -680,9 +684,9 @@ export class FacilityService { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/resources/objectStorageFactors/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } /** @@ -693,16 +697,16 @@ export class FacilityService { * @returns */ declineFacilityApplication(facility: string | number, application_id: number | string): Observable { - const params: HttpParams = new HttpParams().set('action', 'decline'); + const params: HttpParams = new HttpParams().set('action', 'decline') return this.http.post( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/applications/${application_id}/status/`, params, { withCredentials: true, - observe: 'response', - }, - ); + observe: 'response' + } + ) } /** @@ -726,7 +730,7 @@ export class FacilityService { reply?: string, sendNews?: any, alternative_news_text?: string, - tags?: string, + tags?: string ): Observable { const params: HttpParams = new HttpParams() .set('subject', subject) @@ -736,12 +740,12 @@ export class FacilityService { .set('type', project_type) .set('sendNews', sendNews) .set('alternative_message', alternative_news_text) - .set('tags', tags); + .set('tags', tags) return this.http.post(`${ApiSettings.getApiBaseURL()}facilityManagers/current/facilityMail/`, params, { withCredentials: true, - observe: 'response', - }); + observe: 'response' + }) } /** @@ -755,29 +759,29 @@ export class FacilityService { return this.http.get( `${ApiSettings.getApiBaseURL()}computecenters/${facility}/projects/${groupid}/members/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getFilteredMembersOfFacility(searchString: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}users/filterFacility/`, { withCredentials: true, params: { - searchString, - }, - }); + searchString + } + }) } approveTerminationByFM(groupId: number | string, facility: number | string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}computecenters/${facility}/projects/${groupId}/`, { - withCredentials: true, - }); + withCredentials: true + }) } declineTerminationByFM(groupId: number | string, facility: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}computecenters/${facility}/projects/${groupId}/`, { - withCredentials: true, - }); + withCredentials: true + }) } } diff --git a/src/app/api-connector/flavor.service.ts b/src/app/api-connector/flavor.service.ts index daf58f10ad..51585d8b8e 100644 --- a/src/app/api-connector/flavor.service.ts +++ b/src/app/api-connector/flavor.service.ts @@ -1,10 +1,10 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { map } from 'rxjs/operators'; -import { Flavor } from '../virtualmachines/virtualmachinemodels/flavor'; -import { ApiSettings } from './api-settings.service'; -import { FlavorType } from '../virtualmachines/virtualmachinemodels/flavorType'; +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { HttpClient, HttpParams } from '@angular/common/http' +import { map } from 'rxjs/operators' +import { Flavor } from '../virtualmachines/virtualmachinemodels/flavor' +import { ApiSettings } from './api-settings.service' +import { FlavorType } from '../virtualmachines/virtualmachinemodels/flavorType' /** * Service which provides methods for Flavors. @@ -12,61 +12,63 @@ import { FlavorType } from '../virtualmachines/virtualmachinemodels/flavorType'; @Injectable({ providedIn: 'root' }) export class FlavorService { constructor(private http: HttpClient) { - this.http = http; + this.http = http } getFlavors(project_id: number | string): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}projects/${project_id}/flavors/`, { - withCredentials: true, + withCredentials: true }) - .pipe(map((flavors: Flavor[]): Flavor[] => flavors.map((flavor: Flavor): Flavor => new Flavor(flavor)))); + .pipe(map((flavors: Flavor[]): Flavor[] => flavors.map((flavor: Flavor): Flavor => new Flavor(flavor)))) } getAllFlavors(): Observable { return this.http .get(`${ApiSettings.getApiBase()}public/flavors/`) - .pipe(map((flavors: Flavor[]): Flavor[] => flavors.map((flavor: Flavor): Flavor => new Flavor(flavor)))); + .pipe(map((flavors: Flavor[]): Flavor[] => flavors.map((flavor: Flavor): Flavor => new Flavor(flavor)))) } getListOfTypesAvailable(): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}project_applications/flavorTypes/`, { - withCredentials: true, + withCredentials: true }) .pipe( - map((flavors: FlavorType[]): FlavorType[] => flavors.map((flavor: FlavorType): FlavorType => new FlavorType(flavor))), - ); + map((flavors: FlavorType[]): FlavorType[] => + flavors.map((flavor: FlavorType): FlavorType => new FlavorType(flavor)) + ) + ) } getListOfFlavorsAvailable( project_id: string = '', specific: boolean = false, - custom: boolean = false, + custom: boolean = false ): Observable { const params: HttpParams = new HttpParams() .set('project_id', project_id) .set('specific', JSON.stringify(specific)) - .set('custom', custom); + .set('custom', custom) return this.http .get(`${ApiSettings.getApiBaseURL()}project_applications/flavors/`, { withCredentials: true, - params, + params }) - .pipe(map((flavors: Flavor[]): Flavor[] => flavors.map((flavor: Flavor): Flavor => new Flavor(flavor)))); + .pipe(map((flavors: Flavor[]): Flavor[] => flavors.map((flavor: Flavor): Flavor => new Flavor(flavor)))) } sortFlavors(flavors: Flavor[]): { [name: string]: Flavor[] } { - const flavor_types: { [name: string]: Flavor[] } = {}; + const flavor_types: { [name: string]: Flavor[] } = {} for (const flavor of flavors) { if (flavor.type.long_name in flavor_types) { - flavor_types[flavor.type.long_name].push(flavor); + flavor_types[flavor.type.long_name].push(flavor) } else { - flavor_types[flavor.type.long_name] = [flavor]; + flavor_types[flavor.type.long_name] = [flavor] } } - return flavor_types; + return flavor_types } } diff --git a/src/app/api-connector/group.service.ts b/src/app/api-connector/group.service.ts index 044f03284a..7670c1fbf8 100644 --- a/src/app/api-connector/group.service.ts +++ b/src/app/api-connector/group.service.ts @@ -1,13 +1,13 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { ApiSettings } from './api-settings.service'; -import { IResponseTemplate } from './response-template'; -import { Client } from '../vo_manager/clients/client.model'; -import { ProjectEnumeration } from '../projectmanagement/project-enumeration'; -import { Doi } from '../applications/doi/doi'; -import { ApplicationRessourceUsage } from '../applications/application-ressource-usage/application-ressource-usage'; -import { ProjectMember } from '../projectmanagement/project_member.model'; +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { HttpClient, HttpParams } from '@angular/common/http' +import { ApiSettings } from './api-settings.service' +import { IResponseTemplate } from './response-template' +import { Client } from '../vo_manager/clients/client.model' +import { ProjectEnumeration } from '../projectmanagement/project-enumeration' +import { Doi } from '../applications/doi/doi' +import { ApplicationRessourceUsage } from '../applications/application-ressource-usage/application-ressource-usage' +import { ProjectMember } from '../projectmanagement/project_member.model' /** * Service which provides Group methods. @@ -15,144 +15,144 @@ import { ProjectMember } from '../projectmanagement/project_member.model'; @Injectable() export class GroupService { constructor(private http: HttpClient) { - this.http = http; + this.http = http } toggleVisibility(groupId: string | number): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}projects/${groupId}/toggle_member_names_visibility/`, { - withCredentials: true, - }); + withCredentials: true + }) } toggleStartingMachines(groupId: string | number): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}projects/${groupId}/toggle_starting_machines/`, { - withCredentials: true, - }); + withCredentials: true + }) } getProjectOSDetails(groupId: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupId}/os_details/`, { - withCredentials: true, - }); + withCredentials: true + }) } requestProjectTermination(appId: number | string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}projects/${appId}/`, { - withCredentials: true, - }); + withCredentials: true + }) } getFacilityByGroup(groupid: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/computecenter/`, { - withCredentials: true, - }); + withCredentials: true + }) } getClient(groupid: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/client/`, { - withCredentials: true, - }); + withCredentials: true + }) } getClientBibigrid(groupid: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/cluster/client/`, { - withCredentials: true, - }); + withCredentials: true + }) } getClientForcUrl(groupid: string, isClient?: string): Observable { if (isClient) { - const params: HttpParams = new HttpParams().set('client', isClient); + const params: HttpParams = new HttpParams().set('client', isClient) return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/client/getForc/`, { withCredentials: true, - params, - }); + params + }) } else { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/client/getForc/`, { - withCredentials: true, - }); + withCredentials: true + }) } } assignGroupToResource(groupid: number, computecenter: string): Observable { - const params: HttpParams = new HttpParams().set('compute_center', computecenter); + const params: HttpParams = new HttpParams().set('compute_center', computecenter) return this.http.post(`${ApiSettings.getApiBaseURL()}projects/${groupid}/resource/`, params, { - withCredentials: true, + withCredentials: true // headers: header - }); + }) } removeGroupFromResource(groupid: string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}projects/${groupid}/resource/`, { - withCredentials: true, - }); + withCredentials: true + }) } getCreditsAllowedByPerunId(groupid: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/credits_allowed_perun/`, { - withCredentials: true, - }); + withCredentials: true + }) } getGroupAdminIds(groupid: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/admins/ids/`, { - withCredentials: true, - }); + withCredentials: true + }) } isLoggedUserGroupAdmin(groupid: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/admin/`, { - withCredentials: true, - }); + withCredentials: true + }) } addMember(group_id: string | number, member_id: string | number, facility_id?: string | number): Observable { - const params: HttpParams = new HttpParams(); + const params: HttpParams = new HttpParams() if (facility_id !== null) { - params.set('facility_id', facility_id.toString()); + params.set('facility_id', facility_id.toString()) } return this.http.post(`${ApiSettings.getApiBaseURL()}projects/${group_id}/members/${member_id}/`, params, { withCredentials: true, - observe: 'response', - }); + observe: 'response' + }) } addAdmin(group_id: string | number, user_id: string | number, facility_id?: string | number): Observable { - const params: HttpParams = new HttpParams(); + const params: HttpParams = new HttpParams() if (facility_id !== null) { - params.set('facility_id', facility_id.toString()); + params.set('facility_id', facility_id.toString()) } return this.http.post(`${ApiSettings.getApiBaseURL()}projects/${group_id}/admins/${user_id}/`, params, { withCredentials: true, - observe: 'response', - }); + observe: 'response' + }) } removeMember(group_id: number | string, member_id: number | string, facility_id?: number | string): Observable { - const params: HttpParams = new HttpParams(); + const params: HttpParams = new HttpParams() if (facility_id !== null) { - params.set('facility_id', facility_id.toString()); + params.set('facility_id', facility_id.toString()) } return this.http.request('delete', `${ApiSettings.getApiBaseURL()}projects/${group_id}/members/${member_id}/`, { withCredentials: true, body: params, responseType: 'text', - observe: 'response', - }); + observe: 'response' + }) } leaveGroup(group_id: number | string, member_id: number | string, facility_id?: number | string): Observable { - const params: HttpParams = new HttpParams(); + const params: HttpParams = new HttpParams() if (facility_id !== null) { - params.set('facility_id', facility_id.toString()); + params.set('facility_id', facility_id.toString()) } return this.http.request( @@ -162,42 +162,42 @@ export class GroupService { withCredentials: true, body: params, responseType: 'text', - observe: 'response', - }, - ); + observe: 'response' + } + ) } removeAdmin(group_id: number | string, user_id: number | string, facility_id?: number | string): Observable { - const params: HttpParams = new HttpParams(); + const params: HttpParams = new HttpParams() if (facility_id !== null) { - params.set('facility_id', facility_id.toString()); + params.set('facility_id', facility_id.toString()) } return this.http.request('delete', `${ApiSettings.getApiBaseURL()}projects/${group_id}/admins/${user_id}/`, { withCredentials: true, responseType: 'text', body: params, - observe: 'response', - }); + observe: 'response' + }) } getGroupsEnumeration(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/enumeration/`, { - withCredentials: true, - }); + withCredentials: true + }) } getGroupDetails(groupid: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/details/`, { - withCredentials: true, - }); + withCredentials: true + }) } getGroupApplications(group: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${group}/applications/`, { - withCredentials: true, - }); + withCredentials: true + }) } approveGroupApplication(groupid: number, application: number): Observable { @@ -205,177 +205,177 @@ export class GroupService { `${ApiSettings.getApiBaseURL()}projects/${groupid}/applications/${application}/status/`, null, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } rejectGroupApplication(groupid: number, application: number): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}projects/${groupid}/applications/${application}/status/`, { - withCredentials: true, - }); + withCredentials: true + }) } getSimpleVmByUser(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/simpleVm/`, { - withCredentials: true, - }); + withCredentials: true + }) } getSimpleVmByUserWithClusterAllowed(): Observable { - const params: HttpParams = new HttpParams().set('cluster_allowed_required', true); + const params: HttpParams = new HttpParams().set('cluster_allowed_required', true) return this.http.get(`${ApiSettings.getApiBaseURL()}projects/simpleVm/`, { withCredentials: true, - params, - }); + params + }) } getSimpleVmAllowedByUserWithClusterAllowed(): Observable { - const params: HttpParams = new HttpParams().set('cluster_allowed_required', true); + const params: HttpParams = new HttpParams().set('cluster_allowed_required', true) return this.http.get(`${ApiSettings.getApiBaseURL()}projects/simpleVmAllowed/`, { withCredentials: true, - params, - }); + params + }) } getSimpleVmAllowedByUser(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/simpleVmAllowed/`, { - withCredentials: true, - }); + withCredentials: true + }) } getSimpleVmByUserWhereWorkshopAndAdmin(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/simpleVmWorkshops/`, { - withCredentials: true, - }); + withCredentials: true + }) } getGroupDois(application_id: string | number): Observable { - const params: HttpParams = new HttpParams().set('application', application_id.toString()); + const params: HttpParams = new HttpParams().set('application', application_id.toString()) return this.http.get(`${ApiSettings.getApiBaseURL()}doi/`, { withCredentials: true, - params, - }); + params + }) } addGroupDoi(application_id: string | number, doi: string): Observable { - const params: HttpParams = new HttpParams().set('application', application_id.toString()).set('doi', doi); + const params: HttpParams = new HttpParams().set('application', application_id.toString()).set('doi', doi) return this.http.post(`${ApiSettings.getApiBaseURL()}doi/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } deleteGroupDoi(id: string | number): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}doi/${id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } createGroupOpenStack(application_id: string | number, compute_center_id: string | number): Observable { const params: HttpParams = new HttpParams() .set('application_id', application_id.toString()) - .set('compute_center_id', compute_center_id.toString()); + .set('compute_center_id', compute_center_id.toString()) return this.http.post(`${ApiSettings.getApiBaseURL()}projects/openStack/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } createGroupByApplication(application_id: string | number, compute_center_id?: string): Observable { const params: HttpParams = new HttpParams() .set('application_id', application_id.toString()) - .set('compute_center_id', compute_center_id); + .set('compute_center_id', compute_center_id) return this.http.post(`${ApiSettings.getApiBaseURL()}projects/simple_vm/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } getLifetime(groupid: string | number): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/attributes/lifetime/`, { - withCredentials: true, - }); + withCredentials: true + }) } getGroupMembers(groupid: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/members/`, { - withCredentials: true, - }); + withCredentials: true + }) } getWorkshopMembers(groupid: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/workshopmembers/`, { - withCredentials: true, - }); + withCredentials: true + }) } getGroupMaxDiskspace(groupid: string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}projects/${groupid}/attributes/approvedDiskspace/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getGroupUsedDiskspace(groupid: string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}projects/${groupid}/attributes/usedDiskspace/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getGroupResources(groupid: string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}projects/${groupid}/attributes/all/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getVolumesUsed(groupid: string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}projects/${groupid}/attributes/usedVolumes/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getVolumeCounter(groupid: string): Observable { return this.http.get( `${ApiSettings.getApiBaseURL()}projects/${groupid}/attributes/volumesCounter/`, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } isFreemiumActive(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}freemium/`, { - withCredentials: true, - }); + withCredentials: true + }) } addMemberToFreemium(): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}freemium/`, { - withCredentials: true, - }); + withCredentials: true + }) } getFilteredMembersByProject(searchString: string, groupid: string | number): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/members/filter/`, { withCredentials: true, params: { - searchString, - }, - }); + searchString + } + }) } } diff --git a/src/app/api-connector/image.service.ts b/src/app/api-connector/image.service.ts index 45546a426e..ebc4e8aea3 100644 --- a/src/app/api-connector/image.service.ts +++ b/src/app/api-connector/image.service.ts @@ -1,260 +1,258 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { map } from 'rxjs/operators'; -import { Image } from '../virtualmachines/virtualmachinemodels/image'; -import { SnapshotModel } from '../virtualmachines/snapshots/snapshot.model'; -import { ApiSettings } from './api-settings.service'; -import { IResponseTemplate } from './response-template'; -import { - BlockedImageTag, BlockedImageTagResenv, ImageLogo, ImageMode, ImageTag, -} from '../facility_manager/image-tag'; -import { SnapshotPage } from '../virtualmachines/snapshots/snapshotPage.model'; -import { ImageTypes } from '../virtualmachines/virtualmachinemodels/imageTypes'; +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { HttpClient, HttpParams } from '@angular/common/http' +import { map } from 'rxjs/operators' +import { Image } from '../virtualmachines/virtualmachinemodels/image' +import { SnapshotModel } from '../virtualmachines/snapshots/snapshot.model' +import { ApiSettings } from './api-settings.service' +import { IResponseTemplate } from './response-template' +import { BlockedImageTag, BlockedImageTagResenv, ImageLogo, ImageMode, ImageTag } from '../facility_manager/image-tag' +import { SnapshotPage } from '../virtualmachines/snapshots/snapshotPage.model' +import { ImageTypes } from '../virtualmachines/virtualmachinemodels/imageTypes' /** * Service which provides image methods. */ @Injectable() export class ImageService { - BASE_IMAGE_TAG = 'base_image'; - BASE_CLUSTER_IMAGE_TAG = 'base_cluster'; + BASE_IMAGE_TAG = 'base_image' + BASE_CLUSTER_IMAGE_TAG = 'base_cluster' constructor(private http: HttpClient) { - this.http = http; + this.http = http } getImages(project_id: number, filter?: string): Observable { - let params: HttpParams = new HttpParams().set('project_id', project_id.toString()); + let params: HttpParams = new HttpParams().set('project_id', project_id.toString()) if (filter) { - params = new HttpParams().set('project_id', project_id.toString()).set('filter', filter); + params = new HttpParams().set('project_id', project_id.toString()).set('filter', filter) } return this.http .get(`${ApiSettings.getApiBaseURL()}images/`, { withCredentials: true, - params, + params }) - .pipe(map((images: Image[]): Image[] => images.map((image: Image): Image => new Image(image)))); + .pipe(map((images: Image[]): Image[] => images.map((image: Image): Image => new Image(image)))) } getImageByProjectAndName(project_id: number, name: string): Observable { - const params: HttpParams = new HttpParams().set('name', name); + const params: HttpParams = new HttpParams().set('name', name) return this.http .get(`${ApiSettings.getApiBaseURL()}images/project/${project_id}/`, { withCredentials: true, - params, + params }) - .pipe(map((image: Image): Image => new Image(image))); + .pipe(map((image: Image): Image => new Image(image))) } checkSnapshotNameAvailable(snapshot_name: string, client_id: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}snapshots/names/`, { withCredentials: true, - params: { snapshot_name, client_id }, - }); + params: { snapshot_name, client_id } + }) } getSnapshot(openstack_id: string): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}snapshots/${openstack_id}/status/`, { - withCredentials: true, + withCredentials: true }) - .pipe(map((image: Image): Image => new Image(image))); + .pipe(map((image: Image): Image => new Image(image))) } getImageTags(facility: number): Observable { - const params: HttpParams = new HttpParams().set('facility', facility.toString()); + const params: HttpParams = new HttpParams().set('facility', facility.toString()) return this.http.get(`${ApiSettings.getApiBaseURL()}imageTags/`, { withCredentials: true, - params, - }); + params + }) } getImageModes(facility: number): Observable { - const params: HttpParams = new HttpParams().set('facility', facility.toString()); + const params: HttpParams = new HttpParams().set('facility', facility.toString()) return this.http.get(`${ApiSettings.getApiBaseURL()}imageModes/`, { withCredentials: true, - params, - }); + params + }) } getBlockedImageTags(facility_id: number): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}blockedImageTags/`, { withCredentials: true, - params: { facility_id: facility_id.toString() }, - }); + params: { facility_id: facility_id.toString() } + }) } getBlockedImageTagsResenv(facility_id: number, is_client?: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}blockedImageTagsResenv/`, { withCredentials: true, - params: { facility_id: facility_id.toString(), is_client }, - }); + params: { facility_id: facility_id.toString(), is_client } + }) } addImageMode(mode: ImageMode, facility: number): Observable { - const params: HttpParams = new HttpParams().set('facility', facility.toString()).set('mode', JSON.stringify(mode)); + const params: HttpParams = new HttpParams().set('facility', facility.toString()).set('mode', JSON.stringify(mode)) return this.http.post(`${ApiSettings.getApiBaseURL()}imageModes/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } updateImageMode(mode: ImageMode): Observable { - const params: HttpParams = new HttpParams().set('mode', JSON.stringify(mode)); + const params: HttpParams = new HttpParams().set('mode', JSON.stringify(mode)) return this.http.patch(`${ApiSettings.getApiBaseURL()}imageModes/${mode.id}/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } addImageTags(imageTag: string, imageModes: ImageMode[], facility: number): Observable { const params: HttpParams = new HttpParams() .set('imageTag', imageTag) .set('facility', facility.toString()) - .set('imageModes', JSON.stringify(imageModes)); + .set('imageModes', JSON.stringify(imageModes)) return this.http.post(`${ApiSettings.getApiBaseURL()}imageTags/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } addBlockedImageTag(imageTag: string, facility_id: number): Observable { - const params: HttpParams = new HttpParams().set('imageTag', imageTag).set('facility_id', facility_id.toString()); + const params: HttpParams = new HttpParams().set('imageTag', imageTag).set('facility_id', facility_id.toString()) return this.http.post(`${ApiSettings.getApiBaseURL()}blockedImageTags/`, params, { - withCredentials: true, + withCredentials: true // headers: header - }); + }) } addBlockedImageTagResenv( imageTag: string, resenvs: string[], - facility_id: number, + facility_id: number ): Observable { const params: HttpParams = new HttpParams() .set('imageTag', imageTag) .set('facility_id', facility_id.toString()) - .set('resenvs', resenvs.toString()); + .set('resenvs', resenvs.toString()) return this.http.post(`${ApiSettings.getApiBaseURL()}blockedImageTagsResenv/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } getImageLogos(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}imageLogoTags/`, { - withCredentials: true, - }); + withCredentials: true + }) } addImageLogos(imageTag: string, url: string): Observable { - const params: HttpParams = new HttpParams().set('tag', imageTag).set('url', url); + const params: HttpParams = new HttpParams().set('tag', imageTag).set('url', url) return this.http.post(`${ApiSettings.getApiBaseURL()}imageLogoTags/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } deleteImageLogoTag(imageTag: string | number): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}imageLogoTags/${imageTag}/`, { - withCredentials: true, - }); + withCredentials: true + }) } deleteImageTag(id: string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}imageTags/${id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } deleteImageMode(id: string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}imageModes/${id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } deleteBlockedImageTag(imageTag: string, facility_id: number): Observable { - const params: HttpParams = new HttpParams().set('facility_id', facility_id.toString()); + const params: HttpParams = new HttpParams().set('facility_id', facility_id.toString()) return this.http.delete(`${ApiSettings.getApiBaseURL()}blockedImageTags/${imageTag}/`, { withCredentials: true, - params, - }); + params + }) } deleteBlockedImageTagResenv(imageTag: string, facility_id: number): Observable { - const params: HttpParams = new HttpParams().set('facility_id', facility_id.toString()); + const params: HttpParams = new HttpParams().set('facility_id', facility_id.toString()) return this.http.delete(`${ApiSettings.getApiBaseURL()}blockedImageTagsResenv/${imageTag}/`, { withCredentials: true, - params, - }); + params + }) } createSnapshot(snaptshot_instance: string, snapshot_name: string, description: string): Observable { const params: HttpParams = new HttpParams() .set('snapshot_name', snapshot_name) .set('snapshot_instance', snaptshot_instance) - .set('description', description); + .set('description', description) return this.http .post(`${ApiSettings.getApiBaseURL()}snapshots/`, params, { - withCredentials: true, + withCredentials: true }) - .pipe(map((snapshot: SnapshotModel): SnapshotModel => new SnapshotModel(snapshot))); + .pipe(map((snapshot: SnapshotModel): SnapshotModel => new SnapshotModel(snapshot))) } deleteSnapshot(snapshot_id: string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}snapshots/${snapshot_id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } getSnapshotsByUser(currentPage: number, snapsPerSite: number, filter?: string): Observable { let params: HttpParams = new HttpParams() .set('page', currentPage.toString()) - .set('snaps_per_site', snapsPerSite.toString()); + .set('snaps_per_site', snapsPerSite.toString()) if (filter) { - params = params.set('filter', filter); + params = params.set('filter', filter) } return this.http .get(`${ApiSettings.getApiBaseURL()}snapshots/`, { withCredentials: true, - params, + params }) - .pipe(map((snapshot_page: SnapshotPage): SnapshotPage => new SnapshotPage(snapshot_page))); + .pipe(map((snapshot_page: SnapshotPage): SnapshotPage => new SnapshotPage(snapshot_page))) } sortImages(images: Image[], resenv_names: string[] = []): { [name: string]: Image[] } { - const image_types: { [name: string]: Image[] } = {}; - image_types[ImageTypes.IMAGE] = []; - image_types[ImageTypes.SNAPSHOT] = []; - image_types[ImageTypes.CUSTOM] = []; - image_types[ImageTypes.CLUSTER_IMAGE] = []; - image_types[ImageTypes.RESENV] = []; + const image_types: { [name: string]: Image[] } = {} + image_types[ImageTypes.IMAGE] = [] + image_types[ImageTypes.SNAPSHOT] = [] + image_types[ImageTypes.CUSTOM] = [] + image_types[ImageTypes.CLUSTER_IMAGE] = [] + image_types[ImageTypes.RESENV] = [] for (const image of images) { if (image.is_snapshot) { - image_types[ImageTypes.SNAPSHOT].push(image); + image_types[ImageTypes.SNAPSHOT].push(image) } else if (image.tags.includes(this.BASE_IMAGE_TAG)) { - image_types[ImageTypes.IMAGE].push(image); + image_types[ImageTypes.IMAGE].push(image) } else if (image.tags.includes(this.BASE_CLUSTER_IMAGE_TAG)) { - image_types[ImageTypes.CLUSTER_IMAGE].push(image); + image_types[ImageTypes.CLUSTER_IMAGE].push(image) } else if (image.tags.filter(x => resenv_names.includes(x)).length > 0) { - image_types[ImageTypes.RESENV].push(image); + image_types[ImageTypes.RESENV].push(image) } else { - image_types[ImageTypes.CUSTOM].push(image); + image_types[ImageTypes.CUSTOM].push(image) } } - return image_types; + return image_types } } diff --git a/src/app/api-connector/key.service.ts b/src/app/api-connector/key.service.ts index 5d461a9efd..54099f17cd 100644 --- a/src/app/api-connector/key.service.ts +++ b/src/app/api-connector/key.service.ts @@ -1,9 +1,9 @@ -import { Injectable } from '@angular/core'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { Observable } from 'rxjs'; -import { ApiSettings } from './api-settings.service'; -import { IResponseTemplate } from './response-template'; -import { BlacklistedResponse } from './response-interfaces'; +import { Injectable } from '@angular/core' +import { HttpClient, HttpParams } from '@angular/common/http' +import { Observable } from 'rxjs' +import { ApiSettings } from './api-settings.service' +import { IResponseTemplate } from './response-template' +import { BlacklistedResponse } from './response-interfaces' /** * Service which provides public key methods. @@ -14,17 +14,17 @@ export class KeyService { getKey(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}users/current/public_key/`, { - withCredentials: true, - }); + withCredentials: true + }) } postKey(public_key_param: string): Observable { - const public_key: string = public_key_param.replace(/\r?\n|\r/gi, ''); - const params: HttpParams = new HttpParams().set('public_key', public_key); + const public_key: string = public_key_param.replace(/\r?\n|\r/gi, '') + const params: HttpParams = new HttpParams().set('public_key', public_key) return this.http.put(`${ApiSettings.getApiBaseURL()}users/current/public_key/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } validateKey(public_key_param: string): Observable { @@ -32,9 +32,9 @@ export class KeyService { `${ApiSettings.getApiBaseURL()}users/current/public_key/validate/`, { public_key: public_key_param }, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } isBlocked(public_key_param: string): Observable { @@ -42,14 +42,14 @@ export class KeyService { `${ApiSettings.getApiBaseURL()}users/current/public_key/blacklisted/`, { public_key: public_key_param }, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } generateKey(): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}users/current/public_key/generate/`, { - withCredentials: true, - }); + withCredentials: true + }) } } diff --git a/src/app/api-connector/maintenance.service.ts b/src/app/api-connector/maintenance.service.ts index 17b5f0e3d1..9abbfab787 100644 --- a/src/app/api-connector/maintenance.service.ts +++ b/src/app/api-connector/maintenance.service.ts @@ -1,15 +1,15 @@ -import { HttpClient, HttpParams } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { ApiSettings } from './api-settings.service'; -import { MaintenanceTimeFrame } from '../vo_manager/maintenance/maintenanceTimeFrame.model'; +import { HttpClient, HttpParams } from '@angular/common/http' +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { map } from 'rxjs/operators' +import { ApiSettings } from './api-settings.service' +import { MaintenanceTimeFrame } from '../vo_manager/maintenance/maintenanceTimeFrame.model' /** * Service which provides the newest maintenance timeframes, e.g. to show in userInformation */ @Injectable({ - providedIn: 'root', + providedIn: 'root' }) export class MaintenanceService { constructor(private http: HttpClient) {} @@ -20,32 +20,35 @@ export class MaintenanceService { getFutureMaintenanceTimeFrames(): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}maintenance/`, { - withCredentials: true, + withCredentials: true }) .pipe( - map((maintenanceTimeFrames: MaintenanceTimeFrame[]): MaintenanceTimeFrame[] => maintenanceTimeFrames.map( - (maintenanceTimeFrame: MaintenanceTimeFrame): MaintenanceTimeFrame => new MaintenanceTimeFrame(maintenanceTimeFrame), - )), - ); + map((maintenanceTimeFrames: MaintenanceTimeFrame[]): MaintenanceTimeFrame[] => + maintenanceTimeFrames.map( + (maintenanceTimeFrame: MaintenanceTimeFrame): MaintenanceTimeFrame => + new MaintenanceTimeFrame(maintenanceTimeFrame) + ) + ) + ) } getNumberOfUnconfirmedTimeFrames(elixir_id: string): Observable { - const params: HttpParams = new HttpParams().set('elixir_id', elixir_id); + const params: HttpParams = new HttpParams().set('elixir_id', elixir_id) return this.http.get(`${ApiSettings.getApiBaseURL()}maintenance/confirmable/`, { withCredentials: true, - params, - }); + params + }) } confirmNote(elixir_id: string, timeframes: MaintenanceTimeFrame[]): Observable { const params: HttpParams = new HttpParams() .set('elixir_id', elixir_id) - .set('ids', JSON.stringify(timeframes.map((tf: MaintenanceTimeFrame) => tf.id))); + .set('ids', JSON.stringify(timeframes.map((tf: MaintenanceTimeFrame) => tf.id))) return this.http.get(`${ApiSettings.getApiBaseURL()}maintenance/confirm/`, { withCredentials: true, - params, - }); + params + }) } } diff --git a/src/app/api-connector/news.service.ts b/src/app/api-connector/news.service.ts index 50d1363400..2272870151 100644 --- a/src/app/api-connector/news.service.ts +++ b/src/app/api-connector/news.service.ts @@ -1,11 +1,11 @@ -import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable, of } from 'rxjs'; -import { map, catchError } from 'rxjs/operators'; -import { SocialConsent } from 'app/shared/shared_modules/testimonial-forms/social-consent.model'; -import { ApiSettings } from './api-settings.service'; -import { FacilityNews } from '../facility_manager/newsmanagement/facility-news'; -import { News } from '../news/news.model'; +import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http' +import { Injectable } from '@angular/core' +import { Observable, of } from 'rxjs' +import { map, catchError } from 'rxjs/operators' +import { SocialConsent } from 'app/shared/shared_modules/testimonial-forms/social-consent.model' +import { ApiSettings } from './api-settings.service' +import { FacilityNews } from '../facility_manager/newsmanagement/facility-news' +import { News } from '../news/news.model' /** * Service which provides methods for the facilities. @@ -13,95 +13,97 @@ import { News } from '../news/news.model'; @Injectable() export class NewsService { constructor(private http: HttpClient) { - this.http = http; + this.http = http } updateFacilityNews(news: FacilityNews): Observable { return this.http.patch(`${ApiSettings.getApiBaseURL()}facility-news-management/`, news, { - withCredentials: true, - }); + withCredentials: true + }) } addFacilityNews(news: FacilityNews): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}facility-news-management/`, news, { - withCredentials: true, - }); + withCredentials: true + }) } getFacilityNews(facility_ids: string): Observable { - const params: HttpParams = new HttpParams().set('facility_ids', facility_ids); + const params: HttpParams = new HttpParams().set('facility_ids', facility_ids) return this.http .get(`${ApiSettings.getApiBaseURL()}facility-news-management/`, { withCredentials: true, - params, + params }) .pipe( - map((facilityNewsArray: FacilityNews[]): FacilityNews[] => facilityNewsArray.map((facilityNew: FacilityNews): FacilityNews => new FacilityNews(facilityNew))), - ); + map((facilityNewsArray: FacilityNews[]): FacilityNews[] => + facilityNewsArray.map((facilityNew: FacilityNews): FacilityNews => new FacilityNews(facilityNew)) + ) + ) } deleteNewsFromAPI(news_id: string): Observable { - const params: HttpParams = new HttpParams().set('news_id', news_id); + const params: HttpParams = new HttpParams().set('news_id', news_id) return this.http.delete(`${ApiSettings.getApiBaseURL()}facility-news-management/`, { withCredentials: true, - params, - }); + params + }) } getFacilitiesFromWagtail(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}facility-management/`, { - withCredentials: true, - }); + withCredentials: true + }) } updateFacilityMOTD(news: number, facility: number): Observable { - const request_object: { news_id: number; facility_id: number } = { news_id: news, facility_id: facility }; + const request_object: { news_id: number; facility_id: number } = { news_id: news, facility_id: facility } return this.http.post(`${ApiSettings.getApiBaseURL()}facility-management/`, request_object, { - withCredentials: true, - }); + withCredentials: true + }) } getNewsByTags(numberOfNews: number, tags: string[], facility_ids: number[] = []): Observable { const params: HttpParams = new HttpParams() .set('number_of_news', numberOfNews) .set('tags', tags.toString()) - .set('facility_ids', facility_ids.toString()); - let skip_header: HttpHeaders = new HttpHeaders(); + .set('facility_ids', facility_ids.toString()) + let skip_header: HttpHeaders = new HttpHeaders() skip_header = skip_header .append('skip', 'true') .append('Accept', 'application/json') - .append('Content-Type', 'application/json'); + .append('Content-Type', 'application/json') return this.http .get(`${ApiSettings.getWagtailBase()}get_news/`, { params, - headers: skip_header, + headers: skip_header }) .pipe( map((news: News[]): News[] => news.map((one_news: News): News => new News(one_news))), - catchError(this.handleError([])), - ); + catchError(this.handleError([])) + ) } getTestimonial(project_application_id: string): Observable { - const params: HttpParams = new HttpParams().set('project_application_id', project_application_id); + const params: HttpParams = new HttpParams().set('project_application_id', project_application_id) return this.http.get(`${ApiSettings.getApiBaseURL()}wagtail-management/testimonial/`, { params, - withCredentials: true, - }); + withCredentials: true + }) } getPossibleSocialConsents(): Observable { - const params: HttpParams = new HttpParams(); + const params: HttpParams = new HttpParams() return this.http.get(`${ApiSettings.getApiBaseURL()}wagtail-management/testimonial/social_consents/`, { params, - withCredentials: true, - }); + withCredentials: true + }) } sendTestimonialDraft( @@ -115,27 +117,27 @@ export class NewsService { image_url: string, project_application_id: string, soc_consents: SocialConsent[], - file: File, + file: File ): Observable { - const consents_list = soc_consents.map(soc => soc.id); - const consents = JSON.stringify(consents_list); - - const formData: FormData = new FormData(); - formData.append('file', file); - formData.append('title', title); - formData.append('text', text); - formData.append('excerpt', excerpt); - formData.append('contributor', contributor); - formData.append('institution', institution); - formData.append('workgroup', workgroup); - formData.append('simple_vm', JSON.stringify(simple_vm)); - formData.append('project_application_id', project_application_id); - formData.append('consents', consents); - console.log(formData); + const consents_list = soc_consents.map(soc => soc.id) + const consents = JSON.stringify(consents_list) + + const formData: FormData = new FormData() + formData.append('file', file) + formData.append('title', title) + formData.append('text', text) + formData.append('excerpt', excerpt) + formData.append('contributor', contributor) + formData.append('institution', institution) + formData.append('workgroup', workgroup) + formData.append('simple_vm', JSON.stringify(simple_vm)) + formData.append('project_application_id', project_application_id) + formData.append('consents', consents) + console.log(formData) return this.http.post(`${ApiSettings.getApiBaseURL()}wagtail-management/testimonial/`, formData, { - withCredentials: true, - }); + withCredentials: true + }) } autoSaveTestimonialDraft( @@ -147,10 +149,10 @@ export class NewsService { workgroup: string, simple_vm: boolean, project_application_id: string, - soc_consents: SocialConsent[], + soc_consents: SocialConsent[] ): Observable { - const consents_list = soc_consents.map(soc => soc.id); - const consents = JSON.stringify(consents_list); + const consents_list = soc_consents.map(soc => soc.id) + const consents = JSON.stringify(consents_list) const testimonialData: any = { title, @@ -161,24 +163,24 @@ export class NewsService { workgroup, simple_vm, project_application_id, - consents, - }; + consents + } return this.http.post( `${ApiSettings.getApiBaseURL()}wagtail-management/testimonial/autosave/`, testimonialData, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } private handleError(result?: T) { return (error: any): Observable => { - console.error(error); // log to console instead + console.error(error) // log to console instead // Let the app keep running by returning an empty result. - return of(result); - }; + return of(result) + } } } diff --git a/src/app/api-connector/numbers.service.ts b/src/app/api-connector/numbers.service.ts index aa6e291920..dca3e48c5f 100644 --- a/src/app/api-connector/numbers.service.ts +++ b/src/app/api-connector/numbers.service.ts @@ -1,28 +1,26 @@ -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { ApiSettings } from './api-settings.service'; +import { HttpClient } from '@angular/common/http' +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { ApiSettings } from './api-settings.service' /** * Class to get numbers from the api for graphs */ @Injectable() export class NumbersService { - constructor(private http: HttpClient) { - this.http = http; + this.http = http } getProjectCounterTimeline(): Observable { return this.http.get(`${ApiSettings.getApiBase()}public/statistic/projectcounter_timeline/`, { - withCredentials: true, - }); + withCredentials: true + }) } getRamCoresTimeline(): Observable { return this.http.get(`${ApiSettings.getApiBase()}public/statistic/counter_cores_ram/`, { - withCredentials: true, - }); + withCredentials: true + }) } - } diff --git a/src/app/api-connector/playbook.service.ts b/src/app/api-connector/playbook.service.ts index ea796be4da..3e98637a70 100644 --- a/src/app/api-connector/playbook.service.ts +++ b/src/app/api-connector/playbook.service.ts @@ -1,25 +1,23 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { HttpClient } from '@angular/common/http'; -import { ApiSettings } from './api-settings.service'; +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { HttpClient } from '@angular/common/http' +import { ApiSettings } from './api-settings.service' /** * Service which provides playbooks from database */ @Injectable() export class PlaybookService { - data: string; - baseUrl: string = `${ApiSettings.getApiBaseURL()}playbooks/`; + data: string + baseUrl: string = `${ApiSettings.getApiBaseURL()}playbooks/` constructor(private http: HttpClient) { - this.http = http; + this.http = http } getPlaybookForVM(vm_id: string): Observable { - return this.http.get(`${this.baseUrl}${vm_id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } - } diff --git a/src/app/api-connector/token-interceptor.ts b/src/app/api-connector/token-interceptor.ts index e47076deaa..e13a8f2546 100644 --- a/src/app/api-connector/token-interceptor.ts +++ b/src/app/api-connector/token-interceptor.ts @@ -1,10 +1,8 @@ -import { Injectable } from '@angular/core'; -import { - HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, -} from '@angular/common/http'; -import { Observable, throwError } from 'rxjs'; -import { Cookie } from 'ng2-cookies'; -import { catchError } from 'rxjs/operators'; +import { Injectable } from '@angular/core' +import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http' +import { Observable, throwError } from 'rxjs' +import { Cookie } from 'ng2-cookies' +import { catchError } from 'rxjs/operators' /** * Interceptor which inserts withCredentials and csrf header @@ -12,65 +10,65 @@ import { catchError } from 'rxjs/operators'; @Injectable() export class TokenInterceptor implements HttpInterceptor { intercept(req: HttpRequest, next: HttpHandler): Observable> { - const skipIntercept: boolean = req.headers.has('skip'); - const skipXRequestedWith: boolean = req.headers.has('skip-x-requested-with'); + const skipIntercept: boolean = req.headers.has('skip') + const skipXRequestedWith: boolean = req.headers.has('skip-x-requested-with') if (skipIntercept) { req = req.clone({ - headers: req.headers.delete('skip'), - }); + headers: req.headers.delete('skip') + }) return next.handle(req).pipe( catchError((errorResponse: HttpErrorResponse) => { if (errorResponse instanceof HttpErrorResponse) { if (errorResponse.status === 0) { - return throwError('Unable to Connect to the Server'); + return throwError('Unable to Connect to the Server') } else { - return throwError(errorResponse); + return throwError(errorResponse) } } - return throwError('Unknown error'); - }), - ); + return throwError('Unknown error') + }) + ) } else if (skipXRequestedWith) { const modifiedReq: HttpRequest = req.clone({ withCredentials: true, - headers: req.headers.set('X-CSRFToken', Cookie.get('csrftoken')).delete('skip-x-requested-with'), - }); + headers: req.headers.set('X-CSRFToken', Cookie.get('csrftoken')).delete('skip-x-requested-with') + }) return next.handle(modifiedReq).pipe( catchError((errorResponse: HttpErrorResponse) => { if (errorResponse instanceof HttpErrorResponse) { if (errorResponse.status === 0) { - return throwError('Unable to Connect to the Server'); + return throwError('Unable to Connect to the Server') } else { - return throwError(errorResponse); + return throwError(errorResponse) } } - return throwError('Unknown error'); - }), - ); + return throwError('Unknown error') + }) + ) } else { const modifiedReq: HttpRequest = req.clone({ withCredentials: true, - headers: req.headers.set('X-CSRFToken', Cookie.get('csrftoken')).set('X-Requested-With', 'XMLHttpRequest'), - }); + headers: req.headers.set('X-CSRFToken', Cookie.get('csrftoken')).set('X-Requested-With', 'XMLHttpRequest') + }) return next.handle(modifiedReq).pipe( catchError((errorResponse: HttpErrorResponse) => { if (errorResponse instanceof HttpErrorResponse) { if (errorResponse.status === 0) { - return throwError('Unable to Connect to the Server'); + return throwError('Unable to Connect to the Server') } else { - return throwError(errorResponse); + return throwError(errorResponse) } } - return throwError('Unknown error'); - }), - ); + return throwError('Unknown error') + }) + ) } } } diff --git a/src/app/api-connector/user.service.ts b/src/app/api-connector/user.service.ts index 0449e80cee..ea8be8a59b 100644 --- a/src/app/api-connector/user.service.ts +++ b/src/app/api-connector/user.service.ts @@ -1,12 +1,10 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { - HttpClient, HttpHeaders, HttpParams, HttpResponse, -} from '@angular/common/http'; -import { map } from 'rxjs/operators'; -import { ApiSettings } from './api-settings.service'; -import { IResponseTemplate } from './response-template'; -import { Userinfo } from '../userinfo/userinfo.model'; +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http' +import { map } from 'rxjs/operators' +import { ApiSettings } from './api-settings.service' +import { IResponseTemplate } from './response-template' +import { Userinfo } from '../userinfo/userinfo.model' /** * Service which provides user methods. @@ -14,162 +12,162 @@ import { Userinfo } from '../userinfo/userinfo.model'; @Injectable() export class UserService { constructor(private http: HttpClient) { - this.http = http; + this.http = http } deleteUserFromVO(memberId: number): Observable { - const params: HttpParams = new HttpParams().set('member_id', memberId); + const params: HttpParams = new HttpParams().set('member_id', memberId) return this.http.post>(`${ApiSettings.getApiBaseURL()}users/current/delete/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } getLoginElixirName(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}users/current/logins/`, { - withCredentials: true, - }); + withCredentials: true + }) } getMissingConsents(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}users/current/consents/`, { - withCredentials: true, - }); + withCredentials: true + }) } getPreferredMailUser(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}users/current/preferredEmail/`, { - withCredentials: true, - }); + withCredentials: true + }) } requestChangePreferredMailUser(email: string): Observable { - const params: HttpParams = new HttpParams().set('newPreferredEmail', email); + const params: HttpParams = new HttpParams().set('newPreferredEmail', email) return this.http.post(`${ApiSettings.getApiBaseURL()}users/current/preferredEmail/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } logoutUser(): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}users/current/logout/`, null, { - withCredentials: true, - }); + withCredentials: true + }) } getPendingPreferredMailUser(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}users/current/pendingPreferredEmails/`, { - withCredentials: true, - }); + withCredentials: true + }) } getMemberDetailsByElixirId(elixir_id_param: string): Observable { - const elixir_id: string = elixir_id_param.substring(0, elixir_id_param.indexOf('@')); + const elixir_id: string = elixir_id_param.substring(0, elixir_id_param.indexOf('@')) return this.http.get(`${ApiSettings.getApiBaseURL()}users/${elixir_id}/member/`, { - withCredentials: true, - }); + withCredentials: true + }) } getUserInfo(): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}users/current/userInfo/`, { - withCredentials: true, + withCredentials: true }) - .pipe(map((userinfo: Userinfo): Userinfo => new Userinfo(userinfo))); + .pipe(map((userinfo: Userinfo): Userinfo => new Userinfo(userinfo))) } getLoggedUserElixirId(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}users/current/elixir_id/`, { - withCredentials: true, - }); + withCredentials: true + }) } getLoggedUser(): Observable { - const params: HttpParams = new HttpParams().set('redirect_after_login', 'redirect'); + const params: HttpParams = new HttpParams().set('redirect_after_login', 'redirect') return this.http.get(`${ApiSettings.getApiBaseURL()}users/current/`, { withCredentials: true, - params, - }); + params + }) } getOnlyLoggedUserWithRedirect(redirect?: string): Observable { - let skip_header: HttpHeaders = new HttpHeaders(); - skip_header = skip_header.append('skip-x-requested-with', 'true'); + let skip_header: HttpHeaders = new HttpHeaders() + skip_header = skip_header.append('skip-x-requested-with', 'true') if (redirect && redirect !== '/userinfo' && redirect !== 'redirect') { - const params: HttpParams = new HttpParams().set('redirect_after_login', redirect); + const params: HttpParams = new HttpParams().set('redirect_after_login', redirect) return this.http.get(`${ApiSettings.getApiBase()}loggedUser/`, { withCredentials: true, params, - headers: skip_header, - }); + headers: skip_header + }) } else { return this.http.get(`${ApiSettings.getApiBase()}loggedUser/`, { withCredentials: true, - headers: skip_header, - }); + headers: skip_header + }) } } getIsCurrentUserVoMember(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}users/current/member/status/`, { - withCredentials: true, - }); + withCredentials: true + }) } getMemberByUser(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}users/current/member/`, { - withCredentials: true, - }); + withCredentials: true + }) } getMemberByExtSourceNameAndExtLogin(ext_login: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}users/current/extLogin/member/`, { withCredentials: true, params: { - extLogin: ext_login, - }, - }); + extLogin: ext_login + } + }) } setNewsletterSubscriptionWhenSubscribed(): Observable { - const params: HttpParams = new HttpParams().set('subscribed', true.toString()); + const params: HttpParams = new HttpParams().set('subscribed', true.toString()) return this.http.post(`${ApiSettings.getApiBaseURL()}newsletter/subscription/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } setNewsletterSubscriptionWhenNotSubscribed(): Observable { - const params: HttpParams = new HttpParams().set('subscribed', false.toString()); + const params: HttpParams = new HttpParams().set('subscribed', false.toString()) return this.http.post(`${ApiSettings.getApiBaseURL()}newsletter/subscription/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } getNewsletterSubscription(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}newsletter/subscription/`, { - withCredentials: true, - }); + withCredentials: true + }) } sendHelpMail(subject: string, message: string, reply: string): Observable { - const params: HttpParams = new HttpParams().set('subject', subject).set('message', message).set('reply', reply); + const params: HttpParams = new HttpParams().set('subject', subject).set('message', message).set('reply', reply) return this.http.post(`${ApiSettings.getApiBaseURL()}users/current/helpMail/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } getFilteredMembersOfdeNBIVo(searchString: string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}users/filter/`, { withCredentials: true, params: { - searchString, - }, - }); + searchString + } + }) } } diff --git a/src/app/api-connector/virtualmachine.service.ts b/src/app/api-connector/virtualmachine.service.ts index 1be56155dd..49b686d2c5 100644 --- a/src/app/api-connector/virtualmachine.service.ts +++ b/src/app/api-connector/virtualmachine.service.ts @@ -1,46 +1,46 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { map } from 'rxjs/operators'; -import { ApiSettings } from './api-settings.service'; -import { VirtualMachine } from '../virtualmachines/virtualmachinemodels/virtualmachine'; -import { Volume } from '../virtualmachines/volumes/volume'; -import { IResponseTemplate } from './response-template'; -import { Clusterinfo, WorkerBatch } from '../virtualmachines/clusters/clusterinfo'; -import { Image } from '../virtualmachines/virtualmachinemodels/image'; -import { Condalog } from '../virtualmachines/conda/condalog'; -import { VirtualMachinePage } from '../virtualmachines/virtualmachinemodels/virtualMachinePage'; -import { VolumePage } from '../virtualmachines/volumes/volumePage.model'; -import { ClusterPage } from '../virtualmachines/clusters/clusterPage.model'; +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { HttpClient, HttpParams } from '@angular/common/http' +import { map } from 'rxjs/operators' +import { ApiSettings } from './api-settings.service' +import { VirtualMachine } from '../virtualmachines/virtualmachinemodels/virtualmachine' +import { Volume } from '../virtualmachines/volumes/volume' +import { IResponseTemplate } from './response-template' +import { Clusterinfo, WorkerBatch } from '../virtualmachines/clusters/clusterinfo' +import { Image } from '../virtualmachines/virtualmachinemodels/image' +import { Condalog } from '../virtualmachines/conda/condalog' +import { VirtualMachinePage } from '../virtualmachines/virtualmachinemodels/virtualMachinePage' +import { VolumePage } from '../virtualmachines/volumes/volumePage.model' +import { ClusterPage } from '../virtualmachines/clusters/clusterPage.model' /** * Service which provides vm methods. */ @Injectable({ - providedIn: 'root', + providedIn: 'root' }) export class VirtualmachineService { - data: string; - baseVmUrl: string = `${ApiSettings.getApiBaseURL()}vms/`; + data: string + baseVmUrl: string = `${ApiSettings.getApiBaseURL()}vms/` constructor(private http: HttpClient) { - this.http = http; + this.http = http } getClusterAllowed(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}clusters/allowed/`, { - withCredentials: true, - }); + withCredentials: true + }) } triggerVolumeUpdate(volumeIds: string[]): Observable { - const params: HttpParams = new HttpParams().set('volume_ids', volumeIds.join()); + const params: HttpParams = new HttpParams().set('volume_ids', volumeIds.join()) return this.http.get(`${ApiSettings.getApiBaseURL()}volumes/trigger_update/`, { withCredentials: true, params, - observe: 'response', - }); + observe: 'response' + }) } startCluster( @@ -49,7 +49,7 @@ export class VirtualmachineService { workerBatches: WorkerBatch[], project_id: string | number, name: string, - additional_elixir_ids: string[], + additional_elixir_ids: string[] ): Observable { return this.http.post( `${ApiSettings.getApiBaseURL()}clusters/`, @@ -59,98 +59,98 @@ export class VirtualmachineService { worker_batches: workerBatches, project_id, name, - additional_elixir_ids, + additional_elixir_ids }, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getClusterInfo(cluster_id: string): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}clusters/${cluster_id}/`, { - withCredentials: true, + withCredentials: true }) - .pipe(map((clusterinfo: Clusterinfo): Clusterinfo => new Clusterinfo(clusterinfo))); + .pipe(map((clusterinfo: Clusterinfo): Clusterinfo => new Clusterinfo(clusterinfo))) } renameCluster(cluster_id: string, name: string): Observable { - const params: HttpParams = new HttpParams().set('name', name); + const params: HttpParams = new HttpParams().set('name', name) return this.http.post(`${ApiSettings.getApiBaseURL()}clusters/${cluster_id}/name/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } scaleCluster(cluster_id: string, worker_flavor_name: string, upscale_count: number): Observable { const params: HttpParams = new HttpParams() .set('worker_flavor_name', worker_flavor_name) - .set('upscale_count', upscale_count); + .set('upscale_count', upscale_count) return this.http.post(`${ApiSettings.getApiBaseURL()}clusters/${cluster_id}/scale-up/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } generatePasswordCluster(cluster_id: string) { return this.http.post(`${ApiSettings.getApiBaseURL()}clusters/${cluster_id}/password/`, { - withCredentials: true, - }); + withCredentials: true + }) } scaleDownCluster(cluster_id: string, downscale_list: any): Observable { const params: HttpParams = new HttpParams().set( 'downscale_list', - encodeURIComponent(JSON.stringify(downscale_list)), - ); + encodeURIComponent(JSON.stringify(downscale_list)) + ) return this.http.post(`${ApiSettings.getApiBaseURL()}clusters/${cluster_id}/scale-down/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } getClusters( page: number, cluster_per_site: number, filter?: string, - filter_status?: string[], + filter_status?: string[] ): Observable { let params: HttpParams = new HttpParams() .set('page', page.toString()) - .set('cluster_per_site', cluster_per_site.toString()); + .set('cluster_per_site', cluster_per_site.toString()) if (filter) { - params = params.set('filter', filter); + params = params.set('filter', filter) } if (filter_status) { - params = params.append('filter_status', JSON.stringify(filter_status)); + params = params.append('filter_status', JSON.stringify(filter_status)) } return this.http .get(`${ApiSettings.getApiBaseURL()}clusters/`, { withCredentials: true, - params, + params }) - .pipe(map((clusters: ClusterPage): ClusterPage => new ClusterPage(clusters))); + .pipe(map((clusters: ClusterPage): ClusterPage => new ClusterPage(clusters))) } deleteCluster(cluster_id: string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}clusters/${cluster_id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } resumeCluster(cluster_id: string): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}clusters/${cluster_id}/resume/`, { - withCredentials: true, - }); + withCredentials: true + }) } stopCluster(cluster_id: string): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}clusters/${cluster_id}/stop/`, { - withCredentials: true, - }); + withCredentials: true + }) } startVM( @@ -165,7 +165,7 @@ export class VirtualmachineService { new_volumes: Volume[], attach_volumes: Volume[], playbook_information?: string, - additional_elixir_ids?: string[], + additional_elixir_ids?: string[] ): Observable { const params: HttpParams = new HttpParams() .set('flavor', flavor) @@ -179,11 +179,11 @@ export class VirtualmachineService { .set('https_allowed', https.toString()) .set('udp_allowed', udp.toString()) .set('playbook_information', playbook_information) - .set('additional_elixir_ids', JSON.stringify(additional_elixir_ids)); + .set('additional_elixir_ids', JSON.stringify(additional_elixir_ids)) return this.http.post(this.baseVmUrl, params, { - withCredentials: true, - }); + withCredentials: true + }) } startWorkshopVMs( @@ -192,7 +192,7 @@ export class VirtualmachineService { servers: { [key: string]: string }[], project: string, projectid: string, - workshopShortname: string, + workshopShortname: string ): Observable { const params: HttpParams = new HttpParams() .set('flavor', flavor) @@ -200,11 +200,11 @@ export class VirtualmachineService { .set('servers', JSON.stringify(servers)) .set('project', project) .set('projectid', projectid) - .set('workshopShortname', workshopShortname); + .set('workshopShortname', workshopShortname) return this.http.post(`${this.baseVmUrl}workshop/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } getAllVM( @@ -213,61 +213,61 @@ export class VirtualmachineService { filter?: string, filter_status?: string[], filter_cluster: boolean = false, - filter_set_for_termination: boolean = false, + filter_set_for_termination: boolean = false ): Observable { - let params: HttpParams = new HttpParams().set('page', page.toString()).set('vm_per_site', vm_per_site.toString()); + let params: HttpParams = new HttpParams().set('page', page.toString()).set('vm_per_site', vm_per_site.toString()) if (filter) { - params = params.append('filter', filter); + params = params.append('filter', filter) } if (filter_status) { - params = params.append('filter_status', JSON.stringify(filter_status)); + params = params.append('filter_status', JSON.stringify(filter_status)) } if (filter_cluster) { - params = params.append('filter_cluster', 'true'); + params = params.append('filter_cluster', 'true') } if (filter_set_for_termination) { - params = params.append('filter_set_for_termination', 'true'); + params = params.append('filter_set_for_termination', 'true') } return this.http .get(`${ApiSettings.getApiBaseURL()}voManager/vms/`, { withCredentials: true, - params, + params }) - .pipe(map((vm_page: VirtualMachinePage): VirtualMachinePage => new VirtualMachinePage(vm_page))); + .pipe(map((vm_page: VirtualMachinePage): VirtualMachinePage => new VirtualMachinePage(vm_page))) } getAllClusters( page: number, vm_per_site: number, filter?: string, - filter_status?: string[], + filter_status?: string[] ): Observable { let params: HttpParams = new HttpParams() .set('page', page.toString()) - .set('cluster_per_site', vm_per_site.toString()); + .set('cluster_per_site', vm_per_site.toString()) if (filter) { - params = params.set('filter', filter); + params = params.set('filter', filter) } if (filter_status) { - params = params.append('filter_status', JSON.stringify(filter_status)); + params = params.append('filter_status', JSON.stringify(filter_status)) } return this.http .get(`${ApiSettings.getApiBaseURL()}voManager/vms/clusters/`, { withCredentials: true, - params, + params }) - .pipe(map((clusters: ClusterPage): ClusterPage => new ClusterPage(clusters))); + .pipe(map((clusters: ClusterPage): ClusterPage => new ClusterPage(clusters))) } getVmById(openstackId: string): Observable { return this.http .get(`${this.baseVmUrl}${openstackId}/details/`, { - withCredentials: true, + withCredentials: true }) - .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))); + .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))) } getVmsFromLoggedInUser( @@ -277,45 +277,45 @@ export class VirtualmachineService { filter_status?: string[], filter_cluster: boolean = false, filter_set_for_termination: boolean = false, - not_paginated: boolean = false, + not_paginated: boolean = false ): Observable { - let params: HttpParams = new HttpParams().set('page', page.toString()).set('vm_per_site', vm_per_site.toString()); + let params: HttpParams = new HttpParams().set('page', page.toString()).set('vm_per_site', vm_per_site.toString()) if (filter) { - params = params.set('filter', filter); + params = params.set('filter', filter) } if (filter_status) { - params = params.append('filter_status', JSON.stringify(filter_status)); + params = params.append('filter_status', JSON.stringify(filter_status)) } if (filter_cluster) { - params = params.append('filter_cluster', 'true'); + params = params.append('filter_cluster', 'true') } if (filter_set_for_termination) { - params = params.append('filter_set_for_termination', 'true'); + params = params.append('filter_set_for_termination', 'true') } if (not_paginated) { - params = params.append('not_paginated', JSON.stringify(not_paginated)); + params = params.append('not_paginated', JSON.stringify(not_paginated)) } const temp_resp: any = this.http.get(this.baseVmUrl, { withCredentials: true, - params, - }); + params + }) if (not_paginated) { - return temp_resp; + return temp_resp } else { - return temp_resp.pipe(map((vm_page: VirtualMachinePage) => new VirtualMachinePage(vm_page))); + return temp_resp.pipe(map((vm_page: VirtualMachinePage) => new VirtualMachinePage(vm_page))) } } getCondaLogs(openstack_id: string): Observable { return this.http .post(`${this.baseVmUrl}${openstack_id}/logs/`, null, { - withCredentials: true, + withCredentials: true }) - .pipe(map((condaLog: Condalog): Condalog => new Condalog(condaLog))); + .pipe(map((condaLog: Condalog): Condalog => new Condalog(condaLog))) } getVmsFromFacilitiesOfLoggedUser( @@ -325,233 +325,235 @@ export class VirtualmachineService { filter?: string, filter_status?: string[], filter_cluster: boolean = false, - filter_set_for_termination: boolean = false, + filter_set_for_termination: boolean = false ): Observable { - let params: HttpParams = new HttpParams().set('page', page.toString()).set('vm_per_site', vm_per_site.toString()); + let params: HttpParams = new HttpParams().set('page', page.toString()).set('vm_per_site', vm_per_site.toString()) if (filter) { - params = params.set('filter', filter); + params = params.set('filter', filter) } if (filter_status) { - params = params.append('filter_status', JSON.stringify(filter_status)); + params = params.append('filter_status', JSON.stringify(filter_status)) } if (filter_cluster) { - params = params.append('filter_cluster', 'true'); + params = params.append('filter_cluster', 'true') } if (filter_set_for_termination) { - params = params.append('filter_set_for_termination', 'true'); + params = params.append('filter_set_for_termination', 'true') } return this.http .get(`${ApiSettings.getApiBaseURL()}computecenters/${facility_id}/vms/`, { withCredentials: true, - params, + params }) - .pipe(map((vm_page: VirtualMachinePage): VirtualMachinePage => new VirtualMachinePage(vm_page))); + .pipe(map((vm_page: VirtualMachinePage): VirtualMachinePage => new VirtualMachinePage(vm_page))) } getActiveVmsByProject(groupid: string): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}projects/${groupid}/vms/`, { - withCredentials: true, + withCredentials: true }) .pipe( - map((vms: VirtualMachine[]): VirtualMachine[] => vms.map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))), - ); + map((vms: VirtualMachine[]): VirtualMachine[] => + vms.map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm)) + ) + ) } checkVmStatus(openstack_id: string, name?: string): Observable { if (openstack_id) { return this.http .post(`${this.baseVmUrl}${openstack_id}/status/`, null, { - withCredentials: true, + withCredentials: true }) - .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))); + .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))) } else if (name) { return this.http .post(`${this.baseVmUrl}${name}/status/`, null, { - withCredentials: true, + withCredentials: true }) - .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))); + .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))) } else { - return null; + return null } } deleteVms(vm_ids: string[]): Observable { - const params: HttpParams = new HttpParams().set('vm_ids', JSON.stringify(vm_ids)); + const params: HttpParams = new HttpParams().set('vm_ids', JSON.stringify(vm_ids)) return this.http.post(`${this.baseVmUrl}/delete/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } checkVmStatusWhenReboot(openstack_id: string): Observable { - const params: HttpParams = new HttpParams().set('reboot', 'true'); + const params: HttpParams = new HttpParams().set('reboot', 'true') return this.http.post(`${this.baseVmUrl}${openstack_id}/status/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } deleteVM(openstack_id: string): Observable { return this.http .delete(`${this.baseVmUrl}${openstack_id}/`, { - withCredentials: true, + withCredentials: true }) - .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))); + .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))) } setVmNeeded(openstack_id: string): Observable { return this.http.post(`${this.baseVmUrl}${openstack_id}/need/`, { - withCredentials: true, - }); + withCredentials: true + }) } stopVM(openstack_id: string): Observable { - const params: HttpParams = new HttpParams().set('os_action', 'stop'); + const params: HttpParams = new HttpParams().set('os_action', 'stop') return this.http .post(`${this.baseVmUrl}${openstack_id}/action/`, params, { - withCredentials: true, + withCredentials: true }) - .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))); + .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))) } rebootVM(openstack_id: string, reboot_type: string): Observable { - const params: HttpParams = new HttpParams().set('os_action', 'reboot').set('reboot_type', reboot_type); + const params: HttpParams = new HttpParams().set('os_action', 'reboot').set('reboot_type', reboot_type) return this.http.post(`${this.baseVmUrl}${openstack_id}/action/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } recreateVmBackend(openstack_id: string): Observable { return this.http .post(`${this.baseVmUrl}${openstack_id}/backend/`, null, { - withCredentials: true, + withCredentials: true }) - .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))); + .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))) } resumeVM(openstack_id: string): Observable { - const params: HttpParams = new HttpParams().set('os_action', 'resume'); + const params: HttpParams = new HttpParams().set('os_action', 'resume') return this.http .post(`${this.baseVmUrl}${openstack_id}/action/`, params, { - withCredentials: true, + withCredentials: true }) - .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))); + .pipe(map((vm: VirtualMachine): VirtualMachine => new VirtualMachine(vm))) } getDetachedVolumesByProject(project_id: string | number): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}volumes/project/${project_id}/`, { - withCredentials: true, + withCredentials: true }) - .pipe(map((volumes: Volume[]): Volume[] => volumes.map((volume: Volume): Volume => new Volume(volume)))); + .pipe(map((volumes: Volume[]): Volume[] => volumes.map((volume: Volume): Volume => new Volume(volume)))) } getVolumesByUser(items_per_page: number, current_page: number, filter?: string): Observable { let params: HttpParams = new HttpParams() .set('items_per_page', items_per_page.toString()) - .set('page', current_page.toString()); + .set('page', current_page.toString()) if (filter) { - params = params.set('filter', filter); + params = params.set('filter', filter) } return this.http .get(`${ApiSettings.getApiBaseURL()}volumes/`, { withCredentials: true, - params, + params }) - .pipe(map((volume_page: VolumePage): VolumePage => new VolumePage(volume_page))); + .pipe(map((volume_page: VolumePage): VolumePage => new VolumePage(volume_page))) } getVolumeById(id: string): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}volumes/${id}/`, { - withCredentials: true, + withCredentials: true }) - .pipe(map((volume: Volume): Volume => new Volume(volume))); + .pipe(map((volume: Volume): Volume => new Volume(volume))) } getVolumeByNameAndVmName(volume_name: string, virtualmachine_name: string): Observable { - const params: HttpParams = new HttpParams().set('volume_name', volume_name); + const params: HttpParams = new HttpParams().set('volume_name', volume_name) return this.http .get(`${ApiSettings.getApiBaseURL()}volumes/vms/${virtualmachine_name}/`, { withCredentials: true, - params, + params }) - .pipe(map((volume: Volume): Volume => new Volume(volume))); + .pipe(map((volume: Volume): Volume => new Volume(volume))) } createVolume(volume_name: string, volume_storage: string, vm_openstackid: string): Observable { const params: HttpParams = new HttpParams() .set('volume_name', volume_name) .set('volume_storage', volume_storage) - .set('vm_openstackid', vm_openstackid); + .set('vm_openstackid', vm_openstackid) return this.http .post(`${ApiSettings.getApiBaseURL()}volumes/`, params, { - withCredentials: true, + withCredentials: true }) - .pipe(map((volume: Volume): Volume => new Volume(volume))); + .pipe(map((volume: Volume): Volume => new Volume(volume))) } extendVolume(volume_id: string, new_size: string): Observable { - const params: HttpParams = new HttpParams().set('os_action', 'extend').set('new_size', new_size); + const params: HttpParams = new HttpParams().set('os_action', 'extend').set('new_size', new_size) return this.http.post(`${ApiSettings.getApiBaseURL()}volumes/${volume_id}/action/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } attachVolumetoServer(volume_id: string, instance_id: string): Observable { - const params: HttpParams = new HttpParams().set('instance_id', instance_id).set('os_action', 'attach'); + const params: HttpParams = new HttpParams().set('instance_id', instance_id).set('os_action', 'attach') return this.http.post(`${ApiSettings.getApiBaseURL()}volumes/${volume_id}/action/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } renameVolume(volume_id: string, new_volume_name: string): Observable { - const params: HttpParams = new HttpParams().set('new_volume_name', new_volume_name); + const params: HttpParams = new HttpParams().set('new_volume_name', new_volume_name) return this.http .patch(`${ApiSettings.getApiBaseURL()}volumes/${volume_id}/`, params, { - withCredentials: true, + withCredentials: true }) - .pipe(map((volume: Volume): Volume => new Volume(volume))); + .pipe(map((volume: Volume): Volume => new Volume(volume))) } deleteVolume(volume_id: string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}volumes/${volume_id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } deleteVolumes(volume_ids: string[]): Observable { - const params: HttpParams = new HttpParams().set('volume_ids', JSON.stringify(volume_ids)); + const params: HttpParams = new HttpParams().set('volume_ids', JSON.stringify(volume_ids)) return this.http.post(`${ApiSettings.getApiBaseURL()}volumes/delete/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } deleteVolumeAttachment(volume_id: string, instance_id: string): Observable { - const params: HttpParams = new HttpParams().set('instance_id', instance_id).set('os_action', 'detach'); + const params: HttpParams = new HttpParams().set('instance_id', instance_id).set('os_action', 'detach') return this.http.post(`${ApiSettings.getApiBaseURL()}volumes/${volume_id}/action/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } deleteVolumeAttachments(volume_ids: string[]): Observable { - const params: HttpParams = new HttpParams().set('volume_ids', JSON.stringify(volume_ids)); + const params: HttpParams = new HttpParams().set('volume_ids', JSON.stringify(volume_ids)) return this.http.post(`${ApiSettings.getApiBaseURL()}volumes/attachments/delete/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } } diff --git a/src/app/api-connector/vo.service.ts b/src/app/api-connector/vo.service.ts index f472afce24..967a6cbf9f 100644 --- a/src/app/api-connector/vo.service.ts +++ b/src/app/api-connector/vo.service.ts @@ -1,133 +1,144 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { map } from 'rxjs/operators'; -import { ApiSettings } from './api-settings.service'; -import { IResponseTemplate } from './response-template'; -import { Resources } from '../vo_manager/resources/resources'; -import { ProjectMember } from '../projectmanagement/project_member.model'; -import { Application } from '../applications/application.model/application.model'; -import { MaintenanceTimeFrame } from '../vo_manager/maintenance/maintenanceTimeFrame.model'; +import { Injectable } from '@angular/core' +import { Observable } from 'rxjs' +import { HttpClient, HttpParams } from '@angular/common/http' +import { map } from 'rxjs/operators' +import { ApiSettings } from './api-settings.service' +import { IResponseTemplate } from './response-template' +import { Resources } from '../vo_manager/resources/resources' +import { ProjectMember } from '../projectmanagement/project_member.model' +import { Application } from '../applications/application.model/application.model' +import { MaintenanceTimeFrame } from '../vo_manager/maintenance/maintenanceTimeFrame.model' /** * Service which provides vo methods. */ @Injectable() export class VoService { - constructor(private http: HttpClient) { - } + constructor(private http: HttpClient) {} getTsvInformation(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}voManagers/tsv_information/`, { - withCredentials: true, - }); + withCredentials: true + }) } getAllProjectsForTsvExport(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}voManagers/all_projects/`, { - withCredentials: true, - }); + withCredentials: true + }) } downloadProjectsTsv(): Observable { - return this.http.get(`${ApiSettings.getApiBaseURL()}voManagers/get_current_tsv/`, {}); + return this.http.get(`${ApiSettings.getApiBaseURL()}voManagers/get_current_tsv/`, {}) } sendTestError(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}voManagers/test_bug/`, { - withCredentials: true, - }); + withCredentials: true + }) } isVo(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}voManagers/current/status/`, { - withCredentials: true, - }); + withCredentials: true + }) } getNewsletterSubscriptionCounter(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}newsletter/subscription/counter/`, { - withCredentials: true, - }); + withCredentials: true + }) } terminateProject(groupId: number | string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}vo/projects/${groupId}/`, { - withCredentials: true, - }); + withCredentials: true + }) } removeResourceFromGroup(groupid: number | string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}vo/projects/${groupid}/resource/`, { - withCredentials: true, - }); + withCredentials: true + }) } resumeProject(groupid: number | string): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}vo/projects/${groupid}/resource/`, null, { - withCredentials: true, - }); + withCredentials: true + }) } getAllGroupsWithDetails(): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}vo/projects/details/`, { - withCredentials: true, + withCredentials: true }) .pipe( - map((applications: Application[]): Application[] => applications.map((application: Application): Application => new Application(application))), - ); - } - - getGroupsByMemberElixirId(elixir_id: string, isPi: boolean, isAdmin: boolean, isMember: boolean): Observable { + map((applications: Application[]): Application[] => + applications.map((application: Application): Application => new Application(application)) + ) + ) + } + + getGroupsByMemberElixirId( + elixir_id: string, + isPi: boolean, + isAdmin: boolean, + isMember: boolean + ): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}vo/projects/filter/`, { withCredentials: true, params: { - elixir_id, isPi, isAdmin, isMember, - }, + elixir_id, + isPi, + isAdmin, + isMember + } }) .pipe( - map((applications: Application[]): Application[] => applications.map((application: Application): Application => new Application(application))), - ); + map((applications: Application[]): Application[] => + applications.map((application: Application): Application => new Application(application)) + ) + ) } getProjectStatus(groupid: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}vo/projects/${groupid}/status/`, { - withCredentials: true, - }); + withCredentials: true + }) } getVoProjectResources(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}vo/projects/resources/`, { - withCredentials: true, - }); + withCredentials: true + }) } getVoProjectResourcesTimeframes(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}vo/projects/resources/timeFrames/`, { - withCredentials: true, - }); + withCredentials: true + }) } getVoProjectDates(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}vo/projects/dates/`, { - withCredentials: true, - }); + withCredentials: true + }) } getVoProjectCounter(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}vo/projects/counter/`, { - withCredentials: true, - }); + withCredentials: true + }) } setProjectStatus(groupid: number | string, status: number): Observable { - const params: HttpParams = new HttpParams().set('status', status.toString()); + const params: HttpParams = new HttpParams().set('status', status.toString()) return this.http.post(`${ApiSettings.getApiBaseURL()}vo/projects/${groupid}/status/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } sendNewsletterToVo( @@ -135,18 +146,18 @@ export class VoService { message: string, type: string, adminsOnly: boolean, - reply?: string, + reply?: string ): Observable { const params: HttpParams = new HttpParams() .set('subject', subject) .set('message', message) .set('admins_only', adminsOnly) .set('reply', reply) - .set('type', type); + .set('type', type) return this.http.post(`${ApiSettings.getApiBaseURL()}voManagers/current/newsletter/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } sendMailToVo( @@ -157,7 +168,7 @@ export class VoService { adminsOnly: boolean, expiredTemplate: boolean, removalDate: Date, - reply?: string, + reply?: string ): Observable { const params: HttpParams = new HttpParams() .set('subject', subject) @@ -167,11 +178,11 @@ export class VoService { .set('facility', facility) .set('expired_template', expiredTemplate) .set('removal_date', removalDate.toUTCString()) - .set('type', type); + .set('type', type) return this.http.post(`${ApiSettings.getApiBaseURL()}voManagers/current/voMail/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } sendMailToProjects( @@ -179,7 +190,7 @@ export class VoService { subject: string, message: string, adminsOnly: boolean, - reply?: string, + reply?: string ): Observable { return this.http.post( `${ApiSettings.getApiBaseURL()}voManagers/current/voMail/projects/`, @@ -188,110 +199,113 @@ export class VoService { subject, message, adminsOnly, - reply, + reply }, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } getMailTemplates(): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}voManagers/current/voMail/projects/templates/`, { - withCredentials: true, - }); + withCredentials: true + }) } /** - * Get members of a project with emails. - * - * @param groupid id of the group - * @returns - */ + * Get members of a project with emails. + * + * @param groupid id of the group + * @returns + */ getVoGroupRichMembers(groupid: number | string): Observable { return this.http.get(`${ApiSettings.getApiBaseURL()}vo/projects/${groupid}/members/`, { - withCredentials: true, - }); + withCredentials: true + }) } setCurrentUserProcessingVoManager(application_id: number | string): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}vo/projects/${application_id}/vo_manager/`, null, { - withCredentials: true, - }); + withCredentials: true + }) } unsetProcessingVoManager(application_id: number | string): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}vo/projects/${application_id}/vo_manager/`, { - withCredentials: true, - }); + withCredentials: true + }) } setDisabledProject(groupid: number | string): Observable { return this.http.post( `${ApiSettings.getApiBaseURL()}vo/projects/${groupid}/disabled/`, { - action: 'set', + action: 'set' }, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } unsetDisabledProject(groupid: number | string): Observable { return this.http.post( `${ApiSettings.getApiBaseURL()}vo/projects/${groupid}/disabled/`, { - action: 'unset', + action: 'unset' }, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } setProtected(groupid: number | string, set: boolean): Observable { - const parameters: HttpParams = new HttpParams().set('action', set ? 'set' : 'unset'); + const parameters: HttpParams = new HttpParams().set('action', set ? 'set' : 'unset') return this.http.get(`${ApiSettings.getApiBaseURL()}vo/projects/${groupid}/protected/`, { withCredentials: true, - params: parameters, - }); + params: parameters + }) } declineTermination(groupid: number | string): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}vo/projects/${groupid}/termination/decline/`, { - withCredentials: true, - }); + withCredentials: true + }) } loadMaintenanceTimeFrames(): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}voManagers/maintenance/`, { - withCredentials: true, + withCredentials: true }) .pipe( - map((maintenanceTimeFrames: MaintenanceTimeFrame[]): MaintenanceTimeFrame[] => maintenanceTimeFrames.map( - (maintenanceTimeFrame: MaintenanceTimeFrame): MaintenanceTimeFrame => new MaintenanceTimeFrame(maintenanceTimeFrame), - )), - ); + map((maintenanceTimeFrames: MaintenanceTimeFrame[]): MaintenanceTimeFrame[] => + maintenanceTimeFrames.map( + (maintenanceTimeFrame: MaintenanceTimeFrame): MaintenanceTimeFrame => + new MaintenanceTimeFrame(maintenanceTimeFrame) + ) + ) + ) } addMaintenanceTimeFrame(timeframe: MaintenanceTimeFrame): Observable { return this.http.post(`${ApiSettings.getApiBaseURL()}voManagers/maintenance/`, timeframe, { - withCredentials: true, - }); + withCredentials: true + }) } deleteMaintenanceTimeFrame(timeframe: MaintenanceTimeFrame): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}voManagers/maintenance/${timeframe.id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } adjustMaintenanceTimeFrame(timeframe: MaintenanceTimeFrame): Observable { return this.http.patch(`${ApiSettings.getApiBaseURL()}voManagers/maintenance/`, timeframe, { - withCredentials: true, - }); + withCredentials: true + }) } } diff --git a/src/app/api-connector/workshop.service.ts b/src/app/api-connector/workshop.service.ts index 37793ed14c..6d88c7c0e7 100644 --- a/src/app/api-connector/workshop.service.ts +++ b/src/app/api-connector/workshop.service.ts @@ -1,86 +1,92 @@ -import { Injectable } from '@angular/core'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { UrlData, WorkshopUrlInfoModel } from '../virtualmachines/workshop/workshop-urlinfo.model'; -import { ApiSettings } from './api-settings.service'; -import { Workshop } from '../virtualmachines/workshop/workshop.model'; -import { WorkshopVM } from '../virtualmachines/workshop/workshop-vm.model'; -import { WorkshopTimeFrame } from '../virtualmachines/workshop/workshopTimeFrame.model'; +import { Injectable } from '@angular/core' +import { HttpClient, HttpParams } from '@angular/common/http' +import { Observable } from 'rxjs' +import { map } from 'rxjs/operators' +import { UrlData, WorkshopUrlInfoModel } from '../virtualmachines/workshop/workshop-urlinfo.model' +import { ApiSettings } from './api-settings.service' +import { Workshop } from '../virtualmachines/workshop/workshop.model' +import { WorkshopVM } from '../virtualmachines/workshop/workshop-vm.model' +import { WorkshopTimeFrame } from '../virtualmachines/workshop/workshopTimeFrame.model' @Injectable() export class WorkshopService { constructor(private http: HttpClient) { - this.http = http; + this.http = http } getWorkshopInfoUrl(application_id: string | number): Observable { - const params: HttpParams = new HttpParams().set('application_id', application_id); + const params: HttpParams = new HttpParams().set('application_id', application_id) return this.http .get(`${ApiSettings.getApiBaseURL()}workshops/url_info/all_vms/`, { withCredentials: true, - params, + params }) .pipe( - map((workshops_infos: WorkshopUrlInfoModel[]): WorkshopUrlInfoModel[] => workshops_infos.map( - (workshop_info: WorkshopUrlInfoModel): WorkshopUrlInfoModel => new WorkshopUrlInfoModel(workshop_info), - )), - ); + map((workshops_infos: WorkshopUrlInfoModel[]): WorkshopUrlInfoModel[] => + workshops_infos.map( + (workshop_info: WorkshopUrlInfoModel): WorkshopUrlInfoModel => new WorkshopUrlInfoModel(workshop_info) + ) + ) + ) } getUrlDataForWorkshopVm(workshop_id: number, openstackid: string): Observable { - const params: HttpParams = new HttpParams().set('openstackid', openstackid); + const params: HttpParams = new HttpParams().set('openstackid', openstackid) return this.http .get(`${ApiSettings.getApiBaseURL()}workshops/${workshop_id}/url_info/one_vm/`, { withCredentials: true, - params, + params }) - .pipe(map((urlData: UrlData): UrlData => new UrlData(urlData))); + .pipe(map((urlData: UrlData): UrlData => new UrlData(urlData))) } getResenvUrlForWorkshopVm(workshop_id: number, openstackid: string): Observable { - const params: HttpParams = new HttpParams().set('openstackid', openstackid); + const params: HttpParams = new HttpParams().set('openstackid', openstackid) return this.http .get(`${ApiSettings.getApiBaseURL()}workshops/${workshop_id}/url_info/one_vm/resenv_only/`, { withCredentials: true, - params, + params }) - .pipe(map((urlData: UrlData): UrlData => new UrlData(urlData))); + .pipe(map((urlData: UrlData): UrlData => new UrlData(urlData))) } loadWorkshopWithVms(workshop_id: number): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}workshops/${workshop_id}/vms/`, { - withCredentials: true, + withCredentials: true }) - .pipe(map((workshop: Workshop): Workshop => new Workshop(workshop))); + .pipe(map((workshop: Workshop): Workshop => new Workshop(workshop))) } loadWorkshopCalender(workshop_id: number): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}workshops/${workshop_id}/calender/`, { - withCredentials: true, + withCredentials: true }) .pipe( - map((workshopTimeFrames: WorkshopTimeFrame[]): WorkshopTimeFrame[] => workshopTimeFrames.map( - (workshopTimeFrame: WorkshopTimeFrame): WorkshopTimeFrame => new WorkshopTimeFrame(workshopTimeFrame), - )), - ); + map((workshopTimeFrames: WorkshopTimeFrame[]): WorkshopTimeFrame[] => + workshopTimeFrames.map( + (workshopTimeFrame: WorkshopTimeFrame): WorkshopTimeFrame => new WorkshopTimeFrame(workshopTimeFrame) + ) + ) + ) } loadWorkshopTimeFrames(): Observable { return this.http .get(`${ApiSettings.getApiBaseURL()}workshops/calender/all/`, { - withCredentials: true, + withCredentials: true }) .pipe( - map((workshopTimeFrames: WorkshopTimeFrame[]): WorkshopTimeFrame[] => workshopTimeFrames.map( - (workshopTimeFrame: WorkshopTimeFrame): WorkshopTimeFrame => new WorkshopTimeFrame(workshopTimeFrame), - )), - ); + map((workshopTimeFrames: WorkshopTimeFrame[]): WorkshopTimeFrame[] => + workshopTimeFrames.map( + (workshopTimeFrame: WorkshopTimeFrame): WorkshopTimeFrame => new WorkshopTimeFrame(workshopTimeFrame) + ) + ) + ) } addWorkshopTimeFrame(application_id: number | string, timeframe: WorkshopTimeFrame): Observable { @@ -89,63 +95,65 @@ export class WorkshopService { .set('end_time', timeframe.end_time.toJSON()) .set('description', timeframe.description) .set('process', 'add') - .set('workshop_id', timeframe.workshop?.id); + .set('workshop_id', timeframe.workshop?.id) return this.http.post( `${ApiSettings.getApiBaseURL()}workshops/${application_id}/calender/`, params, { - withCredentials: true, - }, - ); + withCredentials: true + } + ) } removeWorkshopTimeFrame(application_id: number | string, timeframe: WorkshopTimeFrame): Observable { - const params: HttpParams = new HttpParams().set('timeframe_id', timeframe.id).set('process', 'delete'); + const params: HttpParams = new HttpParams().set('timeframe_id', timeframe.id).set('process', 'delete') return this.http.post(`${ApiSettings.getApiBaseURL()}workshops/${application_id}/calender/`, params, { - withCredentials: true, - }); + withCredentials: true + }) } getWorkshops(application_id: string | number): Observable { - const params: HttpParams = new HttpParams().set('application_id', application_id); + const params: HttpParams = new HttpParams().set('application_id', application_id) return this.http .get(`${ApiSettings.getApiBaseURL()}workshops/`, { withCredentials: true, - params, + params }) .pipe( - map((workshops: Workshop[]): Workshop[] => workshops.map((workshop: Workshop): Workshop => new Workshop(workshop))), - ); + map((workshops: Workshop[]): Workshop[] => + workshops.map((workshop: Workshop): Workshop => new Workshop(workshop)) + ) + ) } createWorkshop(application_id: string | number, workshop: Workshop): Observable { const params: HttpParams = new HttpParams() .set('application_id', application_id) - .set('workshop', encodeURIComponent(JSON.stringify(workshop))); + .set('workshop', encodeURIComponent(JSON.stringify(workshop))) return this.http .post(`${ApiSettings.getApiBaseURL()}workshops/`, params, { - withCredentials: true, + withCredentials: true }) - .pipe(map((workshop_new: Workshop): Workshop => new Workshop(workshop_new))); + .pipe(map((workshop_new: Workshop): Workshop => new Workshop(workshop_new))) } sendWorkshopVmEmail(workshop_id: number, openstackid: string): Observable { - const params: HttpParams = new HttpParams().set('openstackid', openstackid); + const params: HttpParams = new HttpParams().set('openstackid', openstackid) return this.http .post(`${ApiSettings.getApiBaseURL()}workshops/${workshop_id}/email/`, params, { - withCredentials: true, + withCredentials: true }) - .pipe(map((workshop_new: WorkshopVM): WorkshopVM => new WorkshopVM(workshop_new))); + .pipe(map((workshop_new: WorkshopVM): WorkshopVM => new WorkshopVM(workshop_new))) } deleteWorkshop(workshop_id: number): Observable { return this.http.delete(`${ApiSettings.getApiBaseURL()}workshops/${workshop_id}/`, { - withCredentials: true, - }); + withCredentials: true + }) } } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index b52b8626bf..4e5b031342 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,9 +1,7 @@ -import { - AfterViewInit, ApplicationRef, Component, OnInit, ViewChild, -} from '@angular/core'; -import { ModalDirective } from 'ngx-bootstrap/modal'; -import { Angulartics2Matomo } from 'angulartics2'; -import { VoService } from './api-connector/vo.service'; +import { AfterViewInit, ApplicationRef, Component, OnInit, ViewChild } from '@angular/core' +import { ModalDirective } from 'ngx-bootstrap/modal' +import { Angulartics2Matomo } from 'angulartics2' +import { VoService } from './api-connector/vo.service' /** * App component. @@ -11,18 +9,19 @@ import { VoService } from './api-connector/vo.service'; @Component({ selector: 'body', templateUrl: 'app.component.html', - providers: [VoService], + providers: [VoService] }) export class AppComponent implements AfterViewInit, OnInit { - notificationModalTitle: string = 'Update available'; - notificationModalMessage: string = 'A new update is available. Please reload the site to use the new version of the portal.'; - notificationModalType: string = 'info'; + notificationModalTitle: string = 'Update available' + notificationModalMessage: string = + 'A new update is available. Please reload the site to use the new version of the portal.' + notificationModalType: string = 'info' - @ViewChild('notificationModal', { static: true }) modal: ModalDirective; + @ViewChild('notificationModal', { static: true }) modal: ModalDirective constructor( private appRef: ApplicationRef, - private angulartics2Matomo: Angulartics2Matomo, + private angulartics2Matomo: Angulartics2Matomo ) { /* if (environment.production) { const isStable = appRef.isStable.pipe(first(isStable => isStable === true)); @@ -38,11 +37,11 @@ export class AppComponent implements AfterViewInit, OnInit { } reloadSite(): void { - window.location.reload(); + window.location.reload() } ngOnInit(): void { - this.angulartics2Matomo.startTracking(); + this.angulartics2Matomo.startTracking() // this.voService.isVo().subscribe((result: IResponseTemplate) => { // setVO(result.value); // }) diff --git a/src/app/app.interceptor.component.ts b/src/app/app.interceptor.component.ts index 2084020401..7816d43a3f 100644 --- a/src/app/app.interceptor.component.ts +++ b/src/app/app.interceptor.component.ts @@ -1,15 +1,15 @@ -import { Injectable } from '@angular/core'; +import { Injectable } from '@angular/core' import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, - HttpResponse, -} from '@angular/common/http'; -import { Observable } from 'rxjs'; -import { tap } from 'rxjs/operators'; -import { environment } from '../environments/environment'; + HttpResponse +} from '@angular/common/http' +import { Observable } from 'rxjs' +import { tap } from 'rxjs/operators' +import { environment } from '../environments/environment' /** * AppInterceptor @@ -28,19 +28,19 @@ export class AppInterceptor implements HttpInterceptor { (event: HttpEvent): void => { if (event instanceof HttpResponse) { if (event.status === 302) { - console.log('redirect'); - console.log(event.url); + console.log('redirect') + console.log(event.url) } } }, (err: any): void => { if (err instanceof HttpErrorResponse) { if (err.status === 401 || err.status === 0) { - window.location.href = environment.login; + window.location.href = environment.login } } - }, - ), - ); + } + ) + ) } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8794a550eb..94429a6ae3 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,51 +1,51 @@ -import { HashLocationStrategy, LocationStrategy, CommonModule } from '@angular/common'; -import { ErrorHandler, NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; -import { TabsModule } from 'ngx-bootstrap/tabs'; -import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; -import { NgChartsModule } from 'ng2-charts'; -import { ModalModule } from 'ngx-bootstrap/modal'; -import { PaginationModule } from 'ngx-bootstrap/pagination'; -import { ClipboardModule } from 'ngx-clipboard'; -import { NgScrollbarModule } from 'ngx-scrollbar'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { Angulartics2Module } from 'angulartics2'; -import { CookieService } from 'ngx-cookie-service'; -import { TimepickerModule } from 'ngx-bootstrap/timepicker'; -import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'; -import { NgSelectModule } from '@ng-select/ng-select'; -import { AlertModule } from 'ngx-bootstrap/alert'; -import { MatomoModule, MatomoRouterModule } from 'ngx-matomo-client'; -import { environment } from '../environments/environment'; +import { HashLocationStrategy, LocationStrategy, CommonModule } from '@angular/common' +import { ErrorHandler, NgModule } from '@angular/core' +import { BrowserModule } from '@angular/platform-browser' +import { BsDropdownModule } from 'ngx-bootstrap/dropdown' +import { TabsModule } from 'ngx-bootstrap/tabs' +import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http' +import { NgChartsModule } from 'ng2-charts' +import { ModalModule } from 'ngx-bootstrap/modal' +import { PaginationModule } from 'ngx-bootstrap/pagination' +import { ClipboardModule } from 'ngx-clipboard' +import { NgScrollbarModule } from 'ngx-scrollbar' +import { BrowserAnimationsModule } from '@angular/platform-browser/animations' +import { Angulartics2Module } from 'angulartics2' +import { CookieService } from 'ngx-cookie-service' +import { TimepickerModule } from 'ngx-bootstrap/timepicker' +import { BsDatepickerModule } from 'ngx-bootstrap/datepicker' +import { NgSelectModule } from '@ng-select/ng-select' +import { AlertModule } from 'ngx-bootstrap/alert' +import { MatomoModule, MatomoRouterModule } from 'ngx-matomo-client' +import { environment } from '../environments/environment' -import { AppComponent } from './app.component'; +import { AppComponent } from './app.component' -import { ApiSettings } from './api-connector/api-settings.service'; -import { UserService } from './api-connector/user.service'; -import { AppInterceptor } from './app.interceptor.component'; +import { ApiSettings } from './api-connector/api-settings.service' +import { UserService } from './api-connector/user.service' +import { AppInterceptor } from './app.interceptor.component' // Routing Module -import { AppRoutingModule } from './app.routing'; -import { ConsentInfoComponent } from './consent-info.component'; +import { AppRoutingModule } from './app.routing' +import { ConsentInfoComponent } from './consent-info.component' // Layouts -import { FullLayoutComponent } from './layouts/full-layout.component'; -import { RegistrationInfoComponent } from './registration-info.component'; -import { AsideToggleDirective } from './shared/aside.directive'; -import { SharedModuleModule } from './shared/shared_modules/shared-module.module'; -import { BreadcrumbsComponent } from './shared/breadcrumb.component'; +import { FullLayoutComponent } from './layouts/full-layout.component' +import { RegistrationInfoComponent } from './registration-info.component' +import { AsideToggleDirective } from './shared/aside.directive' +import { SharedModuleModule } from './shared/shared_modules/shared-module.module' +import { BreadcrumbsComponent } from './shared/breadcrumb.component' import { MobileSidebarToggleDirective, SidebarMinimizeDirective, SidebarOffCanvasCloseDirective, - SidebarToggleDirective, -} from './shared/sidebar.directive'; -import { UncaughtExceptionHandler } from './error-handler/UncaughtExceptionHandler.service'; + SidebarToggleDirective +} from './shared/sidebar.directive' +import { UncaughtExceptionHandler } from './error-handler/UncaughtExceptionHandler.service' -import { TitleHeadbarComponent } from './shared/title-headbar.component'; -import { VoService } from './api-connector/vo.service'; -import { TokenInterceptor } from './api-connector/token-interceptor'; -import { PipeModuleModule } from './pipe-module/pipe-module.module'; -import { FacilityService } from './api-connector/facility.service'; +import { TitleHeadbarComponent } from './shared/title-headbar.component' +import { VoService } from './api-connector/vo.service' +import { TokenInterceptor } from './api-connector/token-interceptor' +import { PipeModuleModule } from './pipe-module/pipe-module.module' +import { FacilityService } from './api-connector/facility.service' /** * App module. @@ -62,7 +62,7 @@ import { FacilityService } from './api-connector/facility.service'; SidebarMinimizeDirective, MobileSidebarToggleDirective, SidebarOffCanvasCloseDirective, - TitleHeadbarComponent, + TitleHeadbarComponent ], bootstrap: [AppComponent], imports: [ @@ -86,35 +86,35 @@ import { FacilityService } from './api-connector/facility.service'; AlertModule, MatomoModule.forRoot({ siteId: environment.MATOMO_SITE_ID, - trackerUrl: environment.MATOMO_TRACKING_URL, + trackerUrl: environment.MATOMO_TRACKING_URL }), - MatomoRouterModule, + MatomoRouterModule ], providers: [ { provide: HTTP_INTERCEPTORS, useClass: AppInterceptor, - multi: true, + multi: true }, { provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, - multi: true, + multi: true }, { provide: LocationStrategy, - useClass: HashLocationStrategy, + useClass: HashLocationStrategy }, { provide: ErrorHandler, - useClass: UncaughtExceptionHandler, + useClass: UncaughtExceptionHandler }, ApiSettings, UserService, CookieService, VoService, FacilityService, - provideHttpClient(withInterceptorsFromDi()), - ], + provideHttpClient(withInterceptorsFromDi()) + ] }) export class AppModule {} diff --git a/src/app/applications/application-card/application-card.component.spec.ts b/src/app/applications/application-card/application-card.component.spec.ts index 9460a0c08c..d56ae23126 100644 --- a/src/app/applications/application-card/application-card.component.spec.ts +++ b/src/app/applications/application-card/application-card.component.spec.ts @@ -1,22 +1,22 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing' -import { ApplicationCardComponent } from './application-card.component'; +import { ApplicationCardComponent } from './application-card.component' describe('ApplicationCardComponent', () => { - let component: ApplicationCardComponent; - let fixture: ComponentFixture; + let component: ApplicationCardComponent + let fixture: ComponentFixture beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ApplicationCardComponent], - }).compileComponents(); + imports: [ApplicationCardComponent] + }).compileComponents() - fixture = TestBed.createComponent(ApplicationCardComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + fixture = TestBed.createComponent(ApplicationCardComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) it('should create', () => { - expect(component).toBeTruthy(); - }); -}); + expect(component).toBeTruthy() + }) +}) diff --git a/src/app/applications/application-card/application-card.component.ts b/src/app/applications/application-card/application-card.component.ts index f31f4024ae..869cf40db4 100644 --- a/src/app/applications/application-card/application-card.component.ts +++ b/src/app/applications/application-card/application-card.component.ts @@ -1,89 +1,87 @@ -import { - Component, EventEmitter, Input, OnInit, Output, ViewChild, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { AbstractBaseClass, Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class'; -import { ConfirmationActions } from '../../shared/modal/confirmation_actions'; -import { Application } from '../application.model/application.model'; -import { ApplicationTabStates } from '../../shared/enums/application-tab-states'; -import { ApplicationsService } from '../../api-connector/applications.service'; -import { is_vo } from '../../shared/globalvar'; -import { ComputecenterComponent } from '../../projectmanagement/computecenter.component'; -import { User } from '../application.model/user.model'; -import { ApplicationDetailComponent } from '../application-detail/application-detail.component'; +import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { AbstractBaseClass, Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class' +import { ConfirmationActions } from '../../shared/modal/confirmation_actions' +import { Application } from '../application.model/application.model' +import { ApplicationTabStates } from '../../shared/enums/application-tab-states' +import { ApplicationsService } from '../../api-connector/applications.service' +import { is_vo } from '../../shared/globalvar' +import { ComputecenterComponent } from '../../projectmanagement/computecenter.component' +import { User } from '../application.model/user.model' +import { ApplicationDetailComponent } from '../application-detail/application-detail.component' @Component({ selector: 'app-application-card', templateUrl: './application-card.component.html', - styleUrl: './application-card.component.scss', + styleUrl: './application-card.component.scss' }) export class ApplicationCardComponent extends AbstractBaseClass implements OnInit { - @Input() application: Application; - @Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED; - @Input() computeCenters: ComputecenterComponent[] = []; - @Output() reloadNumbersTrigger: EventEmitter = new EventEmitter(); - @Output() removeApplicationTrigger: EventEmitter = new EventEmitter(); - @Input() facilityView: boolean = false; - @Input() voView: boolean = false; - @ViewChild('applicationdetail') applicationDetailComponent: ApplicationDetailComponent; + @Input() application: Application + @Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED + @Input() computeCenters: ComputecenterComponent[] = [] + @Output() reloadNumbersTrigger: EventEmitter = new EventEmitter() + @Output() removeApplicationTrigger: EventEmitter = new EventEmitter() + @Input() facilityView: boolean = false + @Input() voView: boolean = false + @ViewChild('applicationdetail') applicationDetailComponent: ApplicationDetailComponent - bsModalRef: BsModalRef; - is_vo_admin: boolean = false; + bsModalRef: BsModalRef + is_vo_admin: boolean = false ngOnInit() { - this.is_vo_admin = is_vo; - this.getAndSetPiAndUserApplication(); + this.is_vo_admin = is_vo + this.getAndSetPiAndUserApplication() } getAndSetPiAndUserApplication() { if (!this.application.project_application_user) { - this.getAndSetApplicationUser(); + this.getAndSetApplicationUser() } if (!this.application.project_application_pi) { - this.getAndSetApplicationPi(); + this.getAndSetApplicationPi() } } getAndSetApplicationPi() { this.applicationsService.getApplicationPI(this.application.project_application_id).subscribe((pi: User) => { - this.application.project_application_pi = pi; - }); + this.application.project_application_pi = pi + }) } getAndSetApplicationUser() { this.applicationsService.getApplicationUser(this.application.project_application_id).subscribe((user: User) => { - this.application.project_application_user = user; - }); + this.application.project_application_user = user + }) } constructor(private applicationsService: ApplicationsService) { - super(); + super() } triggerRemoveApplication() { - this.removeApplicationTrigger.emit(this.application.project_application_id); + this.removeApplicationTrigger.emit(this.application.project_application_id) } triggerReloadNumbers() { - this.reloadNumbersTrigger.emit(); + this.reloadNumbersTrigger.emit() } getApplication(): void { this.applicationsService.getApplication(this.application.project_application_id.toString()).subscribe( (aj: Application): void => { - this.application = aj; + this.application = aj }, (error: any): void => { - console.log(error); - }, - ); + console.log(error) + } + ) } switchCollaps() { - this.isCollapsed = !this.isCollapsed; + this.isCollapsed = !this.isCollapsed } - isCollapsed: boolean = true; - protected readonly Application_States = Application_States; - protected readonly ConfirmationActions = ConfirmationActions; + isCollapsed: boolean = true + protected readonly Application_States = Application_States + protected readonly ConfirmationActions = ConfirmationActions } diff --git a/src/app/applications/application-detail/adjustment-detail/adjustment-detail.component.ts b/src/app/applications/application-detail/adjustment-detail/adjustment-detail.component.ts index 640464e032..c61297424f 100644 --- a/src/app/applications/application-detail/adjustment-detail/adjustment-detail.component.ts +++ b/src/app/applications/application-detail/adjustment-detail/adjustment-detail.component.ts @@ -1,17 +1,17 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { is_vo, elixir_id } from '../../../shared/globalvar'; +import { Component, Input, OnInit } from '@angular/core' +import { is_vo, elixir_id } from '../../../shared/globalvar' /** * Application informations. */ @Component({ selector: 'app-adjustment-detail', - templateUrl: './adjustment-detail.component.html', + templateUrl: './adjustment-detail.component.html' }) export class AdjustmentDetailComponent implements OnInit { - is_vo: boolean = is_vo; - @Input() comment: string; - elixir_id: string = elixir_id; + is_vo: boolean = is_vo + @Input() comment: string + elixir_id: string = elixir_id ngOnInit() {} } diff --git a/src/app/applications/application-detail/application-detail.component.ts b/src/app/applications/application-detail/application-detail.component.ts index c30f9414b4..852229b750 100644 --- a/src/app/applications/application-detail/application-detail.component.ts +++ b/src/app/applications/application-detail/application-detail.component.ts @@ -1,15 +1,13 @@ -import { - ChangeDetectorRef, Component, Input, OnInit, -} from '@angular/core'; -import { Application } from '../application.model/application.model'; -import { ApplicationBaseClassComponent } from '../../shared/shared_modules/baseClass/application-base-class.component'; -import { ApplicationsService } from '../../api-connector/applications.service'; -import { UserService } from '../../api-connector/user.service'; -import { FacilityService } from '../../api-connector/facility.service'; -import { is_vo } from '../../shared/globalvar'; -import { CreditsService } from '../../api-connector/credits.service'; -import { Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class'; -import { User } from '../application.model/user.model'; +import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core' +import { Application } from '../application.model/application.model' +import { ApplicationBaseClassComponent } from '../../shared/shared_modules/baseClass/application-base-class.component' +import { ApplicationsService } from '../../api-connector/applications.service' +import { UserService } from '../../api-connector/user.service' +import { FacilityService } from '../../api-connector/facility.service' +import { is_vo } from '../../shared/globalvar' +import { CreditsService } from '../../api-connector/credits.service' +import { Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class' +import { User } from '../application.model/user.model' /** * Class which displays the details of an application. @@ -18,80 +16,80 @@ import { User } from '../application.model/user.model'; selector: 'app-application-detail', templateUrl: './application-detail.component.html', styleUrls: ['./application-detail.component.scss'], - providers: [FacilityService, UserService, ApplicationsService, CreditsService], + providers: [FacilityService, UserService, ApplicationsService, CreditsService] }) export class ApplicationDetailComponent extends ApplicationBaseClassComponent implements OnInit { - PI_USER_TAB: number = 0; - INFORMATION_TAB: number = 1; - RESOURCE_TAB: number = 2; - CREDITS_TAB: number = 3; - MODIFICATION_TAB: number = 4; - EXTENSION_TAB: number = 5; - COMMENT_TAB: number = 6; - MODIFICATION_COMMENT_TAB: number = 7; - LIFETIME_COMMENT_TAB: number = 8; - PI_USER_TAB_ACTIVE: boolean = true; - INFORMATION_TAB_ACTIVE: boolean = false; - RESOURCE_TAB_ACTIVE: boolean = false; - CREDITS_TAB_ACTIVE: boolean = false; - MODIFICATION_TAB_ACTIVE: boolean = false; - EXTENSION_TAB_ACTIVE: boolean = false; - COMMENT_TAB_ACTIVE: boolean = false; - MODIFICATION_COMMENT_TAB_ACTIVE: boolean = false; - LIFETIME_COMMENT_TAB_ACTIVE: boolean = false; - @Input() application: Application; - @Input() default_tab: number = this.PI_USER_TAB; + PI_USER_TAB: number = 0 + INFORMATION_TAB: number = 1 + RESOURCE_TAB: number = 2 + CREDITS_TAB: number = 3 + MODIFICATION_TAB: number = 4 + EXTENSION_TAB: number = 5 + COMMENT_TAB: number = 6 + MODIFICATION_COMMENT_TAB: number = 7 + LIFETIME_COMMENT_TAB: number = 8 + PI_USER_TAB_ACTIVE: boolean = true + INFORMATION_TAB_ACTIVE: boolean = false + RESOURCE_TAB_ACTIVE: boolean = false + CREDITS_TAB_ACTIVE: boolean = false + MODIFICATION_TAB_ACTIVE: boolean = false + EXTENSION_TAB_ACTIVE: boolean = false + COMMENT_TAB_ACTIVE: boolean = false + MODIFICATION_COMMENT_TAB_ACTIVE: boolean = false + LIFETIME_COMMENT_TAB_ACTIVE: boolean = false + @Input() application: Application + @Input() default_tab: number = this.PI_USER_TAB - creditsService: CreditsService; - is_vo_admin: boolean = false; - current_credits: number = 0; - Application_States: typeof Application_States = Application_States; + creditsService: CreditsService + is_vo_admin: boolean = false + current_credits: number = 0 + Application_States: typeof Application_States = Application_States setAllTabsFalse(): void { - this.PI_USER_TAB_ACTIVE = false; - this.INFORMATION_TAB_ACTIVE = false; - this.RESOURCE_TAB_ACTIVE = false; - this.CREDITS_TAB_ACTIVE = false; - this.MODIFICATION_TAB_ACTIVE = false; - this.EXTENSION_TAB_ACTIVE = false; - this.COMMENT_TAB_ACTIVE = false; - this.MODIFICATION_COMMENT_TAB_ACTIVE = false; - this.LIFETIME_COMMENT_TAB_ACTIVE = false; + this.PI_USER_TAB_ACTIVE = false + this.INFORMATION_TAB_ACTIVE = false + this.RESOURCE_TAB_ACTIVE = false + this.CREDITS_TAB_ACTIVE = false + this.MODIFICATION_TAB_ACTIVE = false + this.EXTENSION_TAB_ACTIVE = false + this.COMMENT_TAB_ACTIVE = false + this.MODIFICATION_COMMENT_TAB_ACTIVE = false + this.LIFETIME_COMMENT_TAB_ACTIVE = false } setTab(tab_num: number): void { - this.setAllTabsFalse(); - console.log(tab_num); + this.setAllTabsFalse() + console.log(tab_num) switch (tab_num) { case this.PI_USER_TAB: - this.PI_USER_TAB_ACTIVE = true; - break; + this.PI_USER_TAB_ACTIVE = true + break case this.INFORMATION_TAB: - this.INFORMATION_TAB_ACTIVE = true; - break; + this.INFORMATION_TAB_ACTIVE = true + break case this.RESOURCE_TAB: - this.RESOURCE_TAB_ACTIVE = true; - break; + this.RESOURCE_TAB_ACTIVE = true + break case this.CREDITS_TAB: - this.CREDITS_TAB_ACTIVE = true; - break; + this.CREDITS_TAB_ACTIVE = true + break case this.MODIFICATION_TAB: - this.MODIFICATION_TAB_ACTIVE = true; - break; + this.MODIFICATION_TAB_ACTIVE = true + break case this.EXTENSION_TAB: - this.EXTENSION_TAB_ACTIVE = true; - break; + this.EXTENSION_TAB_ACTIVE = true + break case this.COMMENT_TAB: - this.COMMENT_TAB_ACTIVE = true; - break; + this.COMMENT_TAB_ACTIVE = true + break case this.LIFETIME_COMMENT_TAB: - this.LIFETIME_COMMENT_TAB_ACTIVE = true; - break; + this.LIFETIME_COMMENT_TAB_ACTIVE = true + break case this.MODIFICATION_COMMENT_TAB: - this.MODIFICATION_COMMENT_TAB_ACTIVE = true; - break; + this.MODIFICATION_COMMENT_TAB_ACTIVE = true + break default: - break; + break } } @@ -100,36 +98,36 @@ export class ApplicationDetailComponent extends ApplicationBaseClassComponent im userService: UserService, facilityService: FacilityService, creditsService: CreditsService, - cdrRef: ChangeDetectorRef, + cdrRef: ChangeDetectorRef ) { - super(userService, applicationsService, facilityService, cdrRef); - this.creditsService = creditsService; + super(userService, applicationsService, facilityService, cdrRef) + this.creditsService = creditsService } ngOnInit(): void { - this.setTab(this.default_tab); + this.setTab(this.default_tab) - this.getPi(); - this.getUser(); + this.getPi() + this.getUser() if (this.application.credits_allowed) { - this.getCurrentCredits(); + this.getCurrentCredits() } - this.is_vo_admin = is_vo; + this.is_vo_admin = is_vo } getUser() { if (!this.application.project_application_user) { this.applicationsService.getApplicationUser(this.application.project_application_id).subscribe((user: User) => { - this.application.project_application_user = user; - }); + this.application.project_application_user = user + }) } } getPi() { if (!this.application.project_application_pi.email) { this.applicationsService.getApplicationPI(this.application.project_application_id).subscribe((pi: User) => { - this.application.project_application_pi = pi; - }); + this.application.project_application_pi = pi + }) } } @@ -138,8 +136,8 @@ export class ApplicationDetailComponent extends ApplicationBaseClassComponent im .getCurrentCreditsOfProject(Number(this.application.project_application_perun_id.toString())) .toPromise() .then((credits: number): void => { - this.current_credits = credits; + this.current_credits = credits }) - .catch((err: Error): void => console.log(err.message)); + .catch((err: Error): void => console.log(err.message)) } } diff --git a/src/app/applications/application-detail/application-pi-detail/application-pi-detail.component.ts b/src/app/applications/application-detail/application-pi-detail/application-pi-detail.component.ts index b1676e8b25..a42a9a9516 100644 --- a/src/app/applications/application-detail/application-pi-detail/application-pi-detail.component.ts +++ b/src/app/applications/application-detail/application-pi-detail/application-pi-detail.component.ts @@ -1,13 +1,13 @@ -import { Component, Input } from '@angular/core'; -import { Application } from '../../application.model/application.model'; +import { Component, Input } from '@angular/core' +import { Application } from '../../application.model/application.model' /** * PI/User informations */ @Component({ selector: 'app-application-pi-detail', - templateUrl: './application-pi-detail.component.html', + templateUrl: './application-pi-detail.component.html' }) export class ApplicationPiDetailComponent { - @Input() application: Application; + @Input() application: Application } diff --git a/src/app/applications/application-detail/credits-extension-detail/credits-extension-detail.component.ts b/src/app/applications/application-detail/credits-extension-detail/credits-extension-detail.component.ts index 6a0872866e..efa86dd04f 100644 --- a/src/app/applications/application-detail/credits-extension-detail/credits-extension-detail.component.ts +++ b/src/app/applications/application-detail/credits-extension-detail/credits-extension-detail.component.ts @@ -1,14 +1,14 @@ -import { Component, Input } from '@angular/core'; -import { Application } from '../../application.model/application.model'; +import { Component, Input } from '@angular/core' +import { Application } from '../../application.model/application.model' /** * Credits extension request. */ @Component({ selector: 'app-credits-extension-detail', - templateUrl: './credits-extension-detail.component.html', + templateUrl: './credits-extension-detail.component.html' }) export class CreditsExtensionDetailComponent { - @Input() application: Application; - @Input() is_vo_admin: boolean; + @Input() application: Application + @Input() is_vo_admin: boolean } diff --git a/src/app/applications/application-detail/information-detail/information-detail.component.ts b/src/app/applications/application-detail/information-detail/information-detail.component.ts index c8d646fc3b..042e4dca5a 100644 --- a/src/app/applications/application-detail/information-detail/information-detail.component.ts +++ b/src/app/applications/application-detail/information-detail/information-detail.component.ts @@ -1,21 +1,21 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { Application } from '../../application.model/application.model'; -import { is_vo, elixir_id } from '../../../shared/globalvar'; -import { environment } from '../../../../environments/environment'; +import { Component, Input, OnInit } from '@angular/core' +import { Application } from '../../application.model/application.model' +import { is_vo, elixir_id } from '../../../shared/globalvar' +import { environment } from '../../../../environments/environment' /** * Application informations. */ @Component({ selector: 'app-information-detail', - templateUrl: './information-detail.component.html', + templateUrl: './information-detail.component.html' }) export class InformationDetailComponent implements OnInit { - @Input() application: Application; - is_vo: boolean = is_vo; - elixir_id: string = elixir_id; + @Input() application: Application + is_vo: boolean = is_vo + elixir_id: string = elixir_id - environment: any = environment; + environment: any = environment ngOnInit() {} } diff --git a/src/app/applications/application-detail/lifetime-extension-detail/lifetime-extension-detail.component.ts b/src/app/applications/application-detail/lifetime-extension-detail/lifetime-extension-detail.component.ts index 3f2a0e6f1c..f089fa22c2 100644 --- a/src/app/applications/application-detail/lifetime-extension-detail/lifetime-extension-detail.component.ts +++ b/src/app/applications/application-detail/lifetime-extension-detail/lifetime-extension-detail.component.ts @@ -1,20 +1,20 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { Application } from '../../application.model/application.model'; -import { ApplicationBaseClassComponent } from '../../../shared/shared_modules/baseClass/application-base-class.component'; -import { User } from '../../application.model/user.model'; +import { Component, Input, OnInit } from '@angular/core' +import { Application } from '../../application.model/application.model' +import { ApplicationBaseClassComponent } from '../../../shared/shared_modules/baseClass/application-base-class.component' +import { User } from '../../application.model/user.model' /** * Lifetime extension details. */ @Component({ selector: 'app-lifetime-extension-detail', - templateUrl: './lifetime-extension-detail.component.html', + templateUrl: './lifetime-extension-detail.component.html' }) export class LifetimeExtensionDetailComponent extends ApplicationBaseClassComponent implements OnInit { - @Input() application: Application; + @Input() application: Application ngOnInit() { - this.getRequestingUser(); + this.getRequestingUser() } getRequestingUser() { @@ -22,8 +22,8 @@ export class LifetimeExtensionDetailComponent extends ApplicationBaseClassCompon this.applicationsService .getLifetimeExtensionUser(this.application.project_application_id) .subscribe((user: User) => { - this.application.project_lifetime_request.user = user; - }); + this.application.project_lifetime_request.user = user + }) } } } diff --git a/src/app/applications/application-detail/modification-detail/modification-detail.component.ts b/src/app/applications/application-detail/modification-detail/modification-detail.component.ts index ef1eccb51d..99610a5367 100644 --- a/src/app/applications/application-detail/modification-detail/modification-detail.component.ts +++ b/src/app/applications/application-detail/modification-detail/modification-detail.component.ts @@ -1,30 +1,30 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { Application } from '../../application.model/application.model'; -import { Application_States } from '../../../shared/shared_modules/baseClass/abstract-base-class'; -import { ApplicationBaseClassComponent } from '../../../shared/shared_modules/baseClass/application-base-class.component'; -import { User } from '../../application.model/user.model'; +import { Component, Input, OnInit } from '@angular/core' +import { Application } from '../../application.model/application.model' +import { Application_States } from '../../../shared/shared_modules/baseClass/abstract-base-class' +import { ApplicationBaseClassComponent } from '../../../shared/shared_modules/baseClass/application-base-class.component' +import { User } from '../../application.model/user.model' /** * Application modification details. */ @Component({ selector: 'app-modification-detail', - templateUrl: './modification-detail.component.html', + templateUrl: './modification-detail.component.html' }) export class ModificationDetailComponent extends ApplicationBaseClassComponent implements OnInit { - @Input() application: Application; - @Input() is_vo_admin: boolean; - Application_States: typeof Application_States = Application_States; + @Input() application: Application + @Input() is_vo_admin: boolean + Application_States: typeof Application_States = Application_States ngOnInit() { - this.getRequestingUser(); + this.getRequestingUser() } getRequestingUser() { if (this.application.project_modification_request && !this.application.project_modification_request.user) { this.applicationsService.getModificationUser(this.application.project_application_id).subscribe((user: User) => { - this.application.project_modification_request.user = user; - }); + this.application.project_modification_request.user = user + }) } } } diff --git a/src/app/applications/application-detail/resource-detail/resource-detail.component.ts b/src/app/applications/application-detail/resource-detail/resource-detail.component.ts index 1c0b6e4a3a..ca36d8404d 100644 --- a/src/app/applications/application-detail/resource-detail/resource-detail.component.ts +++ b/src/app/applications/application-detail/resource-detail/resource-detail.component.ts @@ -1,8 +1,8 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { Application } from '../../application.model/application.model'; -import { User } from '../../application.model/user.model'; -import { ApplicationBaseClassComponent } from '../../../shared/shared_modules/baseClass/application-base-class.component'; -import { Flavor } from '../../../virtualmachines/virtualmachinemodels/flavor'; +import { Component, Input, OnInit } from '@angular/core' +import { Application } from '../../application.model/application.model' +import { User } from '../../application.model/user.model' +import { ApplicationBaseClassComponent } from '../../../shared/shared_modules/baseClass/application-base-class.component' +import { Flavor } from '../../../virtualmachines/virtualmachinemodels/flavor' interface FlavorDiff { name: string @@ -16,30 +16,30 @@ interface FlavorDiff { */ @Component({ selector: 'app-resource-detail', - templateUrl: './resource-detail.component.html', + templateUrl: './resource-detail.component.html' }) export class ResourceDetailComponent extends ApplicationBaseClassComponent implements OnInit { - @Input() application: Application; - @Input() is_vo_admin: boolean; - @Input() current_credits: number; - protected readonly Math = Math; - flavorDiffs: FlavorDiff[] = []; + @Input() application: Application + @Input() is_vo_admin: boolean + @Input() current_credits: number + protected readonly Math = Math + flavorDiffs: FlavorDiff[] = [] ngOnInit() { - this.getFlavorChanges(); - this.getModificationRequestingUser(); + this.getFlavorChanges() + this.getModificationRequestingUser() } getModificationRequestingUser() { if (this.application.project_modification_request && !this.application.project_modification_request.user) { this.applicationsService.getModificationUser(this.application.project_application_id).subscribe((user: User) => { - this.application.project_modification_request.user = user; - }); + this.application.project_modification_request.user = user + }) } } getFlavorChanges() { - this.flavorDiffs = []; + this.flavorDiffs = [] // Initialize flavorDiffs with current flavors this.application.flavors.forEach((flavor: Flavor) => { @@ -47,32 +47,32 @@ export class ResourceDetailComponent extends ApplicationBaseClassComponent imple name: flavor.name, current: flavor.counter, diff: 0, - new: 0, - }); - }); + new: 0 + }) + }) // Iterate over modification request flavors if (this.application.project_modification_request) { this.application.project_modification_request.flavors.forEach((modificationFlavor: Flavor) => { const existingFlavorDiffIndex = this.flavorDiffs.findIndex( - flavorDiff => flavorDiff.name === modificationFlavor.name, - ); + flavorDiff => flavorDiff.name === modificationFlavor.name + ) if (existingFlavorDiffIndex !== -1) { // Flavor diff with same name exists - const existingFlavorDiff = this.flavorDiffs[existingFlavorDiffIndex]; - existingFlavorDiff.new = modificationFlavor.counter; - existingFlavorDiff.diff = existingFlavorDiff.new - existingFlavorDiff.current; + const existingFlavorDiff = this.flavorDiffs[existingFlavorDiffIndex] + existingFlavorDiff.new = modificationFlavor.counter + existingFlavorDiff.diff = existingFlavorDiff.new - existingFlavorDiff.current } else { // Flavor diff with same name does not exist, add new flavor diff this.flavorDiffs.push({ name: modificationFlavor.name, current: 0, // Set current as 0 as it's not present in the application flavors diff: modificationFlavor.counter, - new: modificationFlavor.counter, - }); + new: modificationFlavor.counter + }) } - }); + }) } } } diff --git a/src/app/applications/application-facility-actions/application-facility-actions.component.spec.ts b/src/app/applications/application-facility-actions/application-facility-actions.component.spec.ts index 6c62c90e08..f98304d762 100644 --- a/src/app/applications/application-facility-actions/application-facility-actions.component.spec.ts +++ b/src/app/applications/application-facility-actions/application-facility-actions.component.spec.ts @@ -1,22 +1,22 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing' -import { ApplicationFacilityActionsComponent } from './application-facility-actions.component'; +import { ApplicationFacilityActionsComponent } from './application-facility-actions.component' describe('ApplicationFacilityActionsComponent', () => { - let component: ApplicationFacilityActionsComponent; - let fixture: ComponentFixture; + let component: ApplicationFacilityActionsComponent + let fixture: ComponentFixture beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ApplicationFacilityActionsComponent], - }).compileComponents(); + imports: [ApplicationFacilityActionsComponent] + }).compileComponents() - fixture = TestBed.createComponent(ApplicationFacilityActionsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + fixture = TestBed.createComponent(ApplicationFacilityActionsComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) it('should create', () => { - expect(component).toBeTruthy(); - }); -}); + expect(component).toBeTruthy() + }) +}) diff --git a/src/app/applications/application-facility-actions/application-facility-actions.component.ts b/src/app/applications/application-facility-actions/application-facility-actions.component.ts index a3b3ea5f4e..fdc1b0ef57 100644 --- a/src/app/applications/application-facility-actions/application-facility-actions.component.ts +++ b/src/app/applications/application-facility-actions/application-facility-actions.component.ts @@ -1,97 +1,95 @@ -import { - Component, EventEmitter, Input, Output, -} from '@angular/core'; +import { Component, EventEmitter, Input, Output } from '@angular/core' -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { ConfirmationActions } from 'app/shared/modal/confirmation_actions'; -import { Subscription } from 'rxjs'; -import { Application } from '../application.model/application.model'; -import { ComputecenterComponent } from '../../projectmanagement/computecenter.component'; -import { ApplicationTabStates } from '../../shared/enums/application-tab-states'; -import { AbstractBaseClass, Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class'; -import { FacilityService } from '../../api-connector/facility.service'; -import { NotificationModalComponent } from '../../shared/modal/notification-modal'; -import { ConfirmationModalComponent } from '../../shared/modal/confirmation-modal.component'; -import { ApplicationsService } from '../../api-connector/applications.service'; +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { ConfirmationActions } from 'app/shared/modal/confirmation_actions' +import { Subscription } from 'rxjs' +import { Application } from '../application.model/application.model' +import { ComputecenterComponent } from '../../projectmanagement/computecenter.component' +import { ApplicationTabStates } from '../../shared/enums/application-tab-states' +import { AbstractBaseClass, Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class' +import { FacilityService } from '../../api-connector/facility.service' +import { NotificationModalComponent } from '../../shared/modal/notification-modal' +import { ConfirmationModalComponent } from '../../shared/modal/confirmation-modal.component' +import { ApplicationsService } from '../../api-connector/applications.service' @Component({ selector: 'app-application-facility-actions', templateUrl: './application-facility-actions.component.html', - styleUrl: './application-facility-actions.component.scss', + styleUrl: './application-facility-actions.component.scss' }) export class ApplicationFacilityActionsComponent extends AbstractBaseClass { - private subscription: Subscription = new Subscription(); + private subscription: Subscription = new Subscription() - protected readonly ConfirmationActions = ConfirmationActions; - protected readonly ApplicationTabStates = ApplicationTabStates; - @Input() application: Application; - @Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED; - @Input() computeCenters: ComputecenterComponent[] = []; - @Output() reloadNumbersTrigger: EventEmitter = new EventEmitter(); - @Output() removeApplicationTrigger: EventEmitter = new EventEmitter(); - isCollapsed: boolean = true; - bsModalRef: BsModalRef; - @Output() switchCollapseEvent: EventEmitter = new EventEmitter(); - @Output() reloadApplicationTrigger: EventEmitter = new EventEmitter(); + protected readonly ConfirmationActions = ConfirmationActions + protected readonly ApplicationTabStates = ApplicationTabStates + @Input() application: Application + @Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED + @Input() computeCenters: ComputecenterComponent[] = [] + @Output() reloadNumbersTrigger: EventEmitter = new EventEmitter() + @Output() removeApplicationTrigger: EventEmitter = new EventEmitter() + isCollapsed: boolean = true + bsModalRef: BsModalRef + @Output() switchCollapseEvent: EventEmitter = new EventEmitter() + @Output() reloadApplicationTrigger: EventEmitter = new EventEmitter() constructor( private facilityService: FacilityService, private modalService: BsModalService, - private applicationsService: ApplicationsService, + private applicationsService: ApplicationsService ) { - super(); + super() } switchCollaps() { - this.switchCollapseEvent.emit(); + this.switchCollapseEvent.emit() } triggerRemoveApplication() { - this.removeApplicationTrigger.emit(this.application.project_application_id); + this.removeApplicationTrigger.emit(this.application.project_application_id) } triggerReloadNumbers() { - this.reloadNumbersTrigger.emit(); + this.reloadNumbersTrigger.emit() } triggerReloadApplication(): void { - this.reloadApplicationTrigger.emit(); + this.reloadApplicationTrigger.emit() } declineApplication(): void { - this.showNotificationModal('Decline Application', 'Waiting..', 'info'); + this.showNotificationModal('Decline Application', 'Waiting..', 'info') this.facilityService .declineFacilityApplication( this.application.project_application_compute_center.FacilityId, - this.application.project_application_id, + this.application.project_application_id ) .subscribe( (): void => { - this.showNotificationModal('Success', 'Successfully declined the application.', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); + this.showNotificationModal('Success', 'Successfully declined the application.', 'success') + this.triggerReloadNumbers() + this.triggerRemoveApplication() // this.getAllApplicationsHistory(this.selectedFacility['FacilityId']); }, (): void => { - this.showNotificationModal('Failed', 'Failed to decline the application.', 'danger'); - }, - ); + this.showNotificationModal('Failed', 'Failed to decline the application.', 'danger') + } + ) } public approveExtension(): void { this.applicationsService.approveAdditionalLifetime(this.application.project_application_id).subscribe( (): void => { - this.showNotificationModal('Success', 'Successfully approved extension!', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); + this.showNotificationModal('Success', 'Successfully approved extension!', 'success') + this.triggerReloadNumbers() + this.triggerRemoveApplication() }, (): void => { - this.showNotificationModal('Failed', 'The approval of the extension request has failed.', 'danger'); - }, - ); + this.showNotificationModal('Failed', 'The approval of the extension request has failed.', 'danger') + } + ) } /** @@ -102,98 +100,98 @@ export class ApplicationFacilityActionsComponent extends AbstractBaseClass { public declineExtension(): void { this.applicationsService.declineAdditionalLifetime(this.application.project_application_id).subscribe( (): void => { - this.showNotificationModal('Success', 'Successfully declined extension!', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); + this.showNotificationModal('Success', 'Successfully declined extension!', 'success') + this.triggerReloadNumbers() + this.triggerRemoveApplication() }, (): void => { - this.showNotificationModal('Failed', 'The decline of the extension request has failed.', 'danger'); - }, - ); + this.showNotificationModal('Failed', 'The decline of the extension request has failed.', 'danger') + } + ) } showNotificationModal( notificationModalTitle: string, notificationModalMessage: string, - notificationModalType: string, + notificationModalType: string ) { - const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage }; + const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage } if (this.bsModalRef) { - this.bsModalRef.hide(); + this.bsModalRef.hide() } - this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); + this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') } approveApplication(): void { - this.showNotificationModal('Approving Application', 'Waiting..', 'info'); + this.showNotificationModal('Approving Application', 'Waiting..', 'info') this.facilityService .approveFacilityApplication( this.application.project_application_compute_center.FacilityId, - this.application.project_application_id, + this.application.project_application_id ) .subscribe( (): void => { - this.showNotificationModal('Success', 'Successfully approved the application.', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); + this.showNotificationModal('Success', 'Successfully approved the application.', 'success') + this.triggerReloadNumbers() + this.triggerRemoveApplication() // this.getAllApplicationsHistory(this.selectedFacility['FacilityId']); }, (): void => { - this.showNotificationModal('Failed', 'Failed to approve the application.', 'danger'); - }, - ); + this.showNotificationModal('Failed', 'Failed to approve the application.', 'danger') + } + ) } showConfirmationModal(action: ConfirmationActions): void { const initialState = { application: this.application, - action, - }; + action + } - this.bsModalRef = this.modalService.show(ConfirmationModalComponent, { initialState, class: 'modal-lg' }); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(ConfirmationModalComponent, { initialState, class: 'modal-lg' }) + this.subscribeToBsModalRef() } approveModification(): void { this.applicationsService.approveModificationRequest(this.application.project_application_id).subscribe( (): void => { - this.showNotificationModal('Success', 'Successfully approved modification!', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); + this.showNotificationModal('Success', 'Successfully approved modification!', 'success') + this.triggerReloadNumbers() + this.triggerRemoveApplication() }, (): void => { - this.showNotificationModal('Failed', 'The approval of the modification request has failed.', 'danger'); - }, - ); + this.showNotificationModal('Failed', 'The approval of the modification request has failed.', 'danger') + } + ) } declineModification(): void { this.applicationsService.declineModificationRequest(this.application.project_application_id).subscribe( (): void => { - this.showNotificationModal('Success', 'Successfully declined modification!', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); + this.showNotificationModal('Success', 'Successfully declined modification!', 'success') + this.triggerReloadNumbers() + this.triggerRemoveApplication() }, (): void => { - this.showNotificationModal('Failed', 'The decline of the modification request has failed.', 'danger'); - }, - ); + this.showNotificationModal('Failed', 'The decline of the modification request has failed.', 'danger') + } + ) } approveTermination(): void { this.facilityService .approveTerminationByFM( this.application.project_application_perun_id, - this.application.project_application_compute_center.FacilityId, + this.application.project_application_compute_center.FacilityId ) .subscribe( (): void => { - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); - this.showNotificationModal('Success', 'The project was terminated.', 'success'); + this.triggerReloadNumbers() + this.triggerRemoveApplication() + this.showNotificationModal('Success', 'The project was terminated.', 'success') }, (error: any): void => { if (error['status'] === 409) { @@ -201,26 +199,26 @@ export class ApplicationFacilityActionsComponent extends AbstractBaseClass { 'Failed', `The project could not be terminated. Reason: ${error['error']['reason']} for ${error['error']['openstackid']}`, - 'danger', - ); + 'danger' + ) } else { - this.showNotificationModal('Failed', 'The project could not be terminated.', 'danger'); + this.showNotificationModal('Failed', 'The project could not be terminated.', 'danger') } - }, - ); + } + ) } declineTermination(): void { this.facilityService .declineTerminationByFM( this.application.project_application_perun_id, - this.application.project_application_compute_center.FacilityId, + this.application.project_application_compute_center.FacilityId ) .subscribe( (): void => { - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); - this.showNotificationModal('Success', 'The termination of the project was declined.', 'success'); + this.triggerReloadNumbers() + this.triggerRemoveApplication() + this.showNotificationModal('Success', 'The termination of the project was declined.', 'success') }, (error: any): void => { if (error['status'] === 409) { @@ -228,60 +226,60 @@ export class ApplicationFacilityActionsComponent extends AbstractBaseClass { 'Failed', `The decline of the project was not successful. Reason: ${error['error']['reason']} for ${error['error']['openstackid']}`, - 'danger', - ); + 'danger' + ) } else { - this.showNotificationModal('Failed', 'The decline of the project failed.', 'danger'); + this.showNotificationModal('Failed', 'The decline of the project failed.', 'danger') } - }, - ); + } + ) } subscribeToBsModalRef(): void { this.subscription.add( this.bsModalRef.content.event.subscribe((event: any) => { - const action: ConfirmationActions = event.action; + const action: ConfirmationActions = event.action switch (action) { case ConfirmationActions.APPROVE_APPLICATION: { - this.approveApplication(); - break; + this.approveApplication() + break } case ConfirmationActions.DECLINE_APPLICATION: { - this.declineApplication(); - break; + this.declineApplication() + break } case ConfirmationActions.DECLINE_EXTENSION: { - this.declineExtension(); - break; + this.declineExtension() + break } case ConfirmationActions.APPROVE_EXTENSION: { - this.approveExtension(); - break; + this.approveExtension() + break } case ConfirmationActions.DECLINE_MODIFICATION: { - this.declineModification(); - break; + this.declineModification() + break } case ConfirmationActions.APPROVE_MODIFICATION: { - this.approveModification(); - break; + this.approveModification() + break } case ConfirmationActions.APPROVE_TERMINATION: { - this.approveTermination(); - break; + this.approveTermination() + break } case ConfirmationActions.DECLINE_TERMINATION: { - this.declineTermination(); - break; + this.declineTermination() + break } default: - break; + break } - }), - ); + }) + ) } ngOnInit() {} - protected readonly Application_States = Application_States; + protected readonly Application_States = Application_States } diff --git a/src/app/applications/application-formular/application-formular.component.ts b/src/app/applications/application-formular/application-formular.component.ts index 314a352a6d..a02952aa7d 100644 --- a/src/app/applications/application-formular/application-formular.component.ts +++ b/src/app/applications/application-formular/application-formular.component.ts @@ -1,19 +1,17 @@ -import { - ChangeDetectorRef, Component, Input, OnInit, ViewChild, inject, -} from '@angular/core'; -import { NgForm } from '@angular/forms'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { Flavor } from '../../virtualmachines/virtualmachinemodels/flavor'; -import { FlavorService } from '../../api-connector/flavor.service'; -import { FlavorType } from '../../virtualmachines/virtualmachinemodels/flavorType'; -import { environment } from '../../../environments/environment'; -import { EdamOntologyTerm } from '../edam-ontology-term'; -import { ApplicationsService } from '../../api-connector/applications.service'; -import { ApplicationBaseClassComponent } from '../../shared/shared_modules/baseClass/application-base-class.component'; -import { FullLayoutComponent } from '../../layouts/full-layout.component'; -import { CreditsService } from '../../api-connector/credits.service'; -import { Application } from '../application.model/application.model'; -import { is_vo } from '../../shared/globalvar'; +import { ChangeDetectorRef, Component, Input, OnInit, ViewChild, inject } from '@angular/core' +import { NgForm } from '@angular/forms' +import { MatomoTracker } from 'ngx-matomo-client' +import { Flavor } from '../../virtualmachines/virtualmachinemodels/flavor' +import { FlavorService } from '../../api-connector/flavor.service' +import { FlavorType } from '../../virtualmachines/virtualmachinemodels/flavorType' +import { environment } from '../../../environments/environment' +import { EdamOntologyTerm } from '../edam-ontology-term' +import { ApplicationsService } from '../../api-connector/applications.service' +import { ApplicationBaseClassComponent } from '../../shared/shared_modules/baseClass/application-base-class.component' +import { FullLayoutComponent } from '../../layouts/full-layout.component' +import { CreditsService } from '../../api-connector/credits.service' +import { Application } from '../application.model/application.model' +import { is_vo } from '../../shared/globalvar' import { CREDITS_WIKI, OPENSTACK_LINK, @@ -29,11 +27,11 @@ import { WIKI_LINKING_ACCOUNTS, WIKI_PRINCIPAL_INVESTIGATOR, WIKI_CLOUD_TERMS_LINK, - WIKI_BACKUP_LINK, -} from '../../../links/links'; -import { UserService } from '../../api-connector/user.service'; -import { Userinfo } from '../../userinfo/userinfo.model'; -import { User } from '../application.model/user.model'; + WIKI_BACKUP_LINK +} from '../../../links/links' +import { UserService } from '../../api-connector/user.service' +import { Userinfo } from '../../userinfo/userinfo.model' +import { User } from '../application.model/user.model' /** * Application formular component. @@ -42,64 +40,64 @@ import { User } from '../application.model/user.model'; selector: 'app-application-formular', templateUrl: './application-formular.component.html', styleUrls: ['./application-formular.component.scss'], - providers: [FlavorService, ApplicationsService, CreditsService], + providers: [FlavorService, ApplicationsService, CreditsService] }) export class ApplicationFormularComponent extends ApplicationBaseClassComponent implements OnInit { - @Input() openstack_project: boolean = false; - @Input() simple_vm_project: boolean = false; - @Input() kubernetes_access: boolean = false; - @Input() title: string; - @Input() application: Application; - @Input() is_validation: boolean = false; - @Input() hash: string; - - private readonly tracker = inject(MatomoTracker); - - userinfo: Userinfo; - valid_pi_affiliations; - unknownPiAffiliationsConfirmation: boolean = false; - pi_responsibility_checked: boolean = false; - edam_ontology_terms: EdamOntologyTerm[] = []; - isLoaded: boolean = false; - submitting: boolean = false; - test_name: string = ''; - all_dissemination_checked: boolean = false; - initiated_validation: boolean = false; - dissemination_platform_count: number = 0; - flavorList: Flavor[] = []; - production: boolean = environment.production; - dissemination_information_open: boolean = true; - invalid_shortname: boolean = false; - invalid_longname: boolean = false; - invalid_description: boolean = false; - simple_vm_min_vm: boolean = false; - error: string[]; - CREDITS_WIKI: string = CREDITS_WIKI; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - LIFESCIENCE_LINKING_ACCOUNTS: string = LIFESCIENCE_LINKING_ACCOUNTS; - WIKI_LINKING_ACCOUNTS: string = WIKI_LINKING_ACCOUNTS; - WIKI_PRINCIPAL_INVESTIGATOR: string = WIKI_PRINCIPAL_INVESTIGATOR; - SURVEY_LINK: string = SURVEY_LINK; - POLICY_LINK: string = POLICY_LINK; - WIKI_WORKSHOPS: string = WIKI_WORKSHOPS; - OPENSTACK_LINK: string = OPENSTACK_LINK; - PROJECT_TYPES_LINK: string = PROJECT_TYPES_LINK; - SIMPLE_VM_LINK: string = SIMPLE_VM_LINK; - WIKI_CLOUD_TERMS_LINK: string = WIKI_CLOUD_TERMS_LINK; - WIKI_PERSONAL_DATA: string = WIKI_PERSONAL_DATA; - WIKI_BACKUP_LINK: string = WIKI_BACKUP_LINK; - GDPR_LINK: string = GDPR_LINK; - survey_link_visible: boolean = false; - - MAX_LIFETIME_DEFAULT: number = 6; - max_lifetime: number = this.MAX_LIFETIME_DEFAULT; - - acknowledgeModalTitle: string = 'Acknowledge'; - acknowledgeModalType: string = 'info'; - - application_id: string | number; - ontology_search_keyword: string = 'term'; - @ViewChild(NgForm, { static: true }) application_form: NgForm; + @Input() openstack_project: boolean = false + @Input() simple_vm_project: boolean = false + @Input() kubernetes_access: boolean = false + @Input() title: string + @Input() application: Application + @Input() is_validation: boolean = false + @Input() hash: string + + private readonly tracker = inject(MatomoTracker) + + userinfo: Userinfo + valid_pi_affiliations + unknownPiAffiliationsConfirmation: boolean = false + pi_responsibility_checked: boolean = false + edam_ontology_terms: EdamOntologyTerm[] = [] + isLoaded: boolean = false + submitting: boolean = false + test_name: string = '' + all_dissemination_checked: boolean = false + initiated_validation: boolean = false + dissemination_platform_count: number = 0 + flavorList: Flavor[] = [] + production: boolean = environment.production + dissemination_information_open: boolean = true + invalid_shortname: boolean = false + invalid_longname: boolean = false + invalid_description: boolean = false + simple_vm_min_vm: boolean = false + error: string[] + CREDITS_WIKI: string = CREDITS_WIKI + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + LIFESCIENCE_LINKING_ACCOUNTS: string = LIFESCIENCE_LINKING_ACCOUNTS + WIKI_LINKING_ACCOUNTS: string = WIKI_LINKING_ACCOUNTS + WIKI_PRINCIPAL_INVESTIGATOR: string = WIKI_PRINCIPAL_INVESTIGATOR + SURVEY_LINK: string = SURVEY_LINK + POLICY_LINK: string = POLICY_LINK + WIKI_WORKSHOPS: string = WIKI_WORKSHOPS + OPENSTACK_LINK: string = OPENSTACK_LINK + PROJECT_TYPES_LINK: string = PROJECT_TYPES_LINK + SIMPLE_VM_LINK: string = SIMPLE_VM_LINK + WIKI_CLOUD_TERMS_LINK: string = WIKI_CLOUD_TERMS_LINK + WIKI_PERSONAL_DATA: string = WIKI_PERSONAL_DATA + WIKI_BACKUP_LINK: string = WIKI_BACKUP_LINK + GDPR_LINK: string = GDPR_LINK + survey_link_visible: boolean = false + + MAX_LIFETIME_DEFAULT: number = 6 + max_lifetime: number = this.MAX_LIFETIME_DEFAULT + + acknowledgeModalTitle: string = 'Acknowledge' + acknowledgeModalType: string = 'info' + + application_id: string | number + ontology_search_keyword: string = 'term' + @ViewChild(NgForm, { static: true }) application_form: NgForm // /** // * List of flavor types. // */ @@ -111,130 +109,130 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent private fullLayout: FullLayoutComponent, userService: UserService, applicationsService: ApplicationsService, - cdrRef: ChangeDetectorRef, + cdrRef: ChangeDetectorRef ) { - super(userService, applicationsService, null, cdrRef); + super(userService, applicationsService, null, cdrRef) } ngOnInit(): void { if (!this.is_validation) { - const typeStr: string = this.openstack_project ? ' Openstack' : 'SimpleVM'; - this.tracker.trackPageView(`New Application Formular: ${typeStr}`); + const typeStr: string = this.openstack_project ? ' Openstack' : 'SimpleVM' + this.tracker.trackPageView(`New Application Formular: ${typeStr}`) } - this.getUserinfo(); - this.getListOfFlavors(); - this.getListOfTypes(); - this.is_vo_admin = is_vo; + this.getUserinfo() + this.getListOfFlavors() + this.getListOfTypes() + this.is_vo_admin = is_vo if (this.openstack_project) { - this.simple_vm_min_vm = true; + this.simple_vm_min_vm = true } this.applicationsService.getEdamOntologyTerms().subscribe((terms: EdamOntologyTerm[]): void => { - this.edam_ontology_terms = terms; - this.initiateFormWithApplication(); - }); + this.edam_ontology_terms = terms + this.initiateFormWithApplication() + }) } // eslint-disable-next-line @typescript-eslint/no-unused-vars onAllDissChange(event: any): void { if (this.all_dissemination_checked) { - this.application.dissemination.setAllInformationTrue(); + this.application.dissemination.setAllInformationTrue() } else { - this.application.dissemination.setAllInformationFalse(); + this.application.dissemination.setAllInformationFalse() } } checkValidityComment(): boolean { if (this.extraResourceCommentRequired) { if (this.application.project_application_comment?.length < 50) { - return false; + return false } else { - const regExp = /[a-zA-Z]/g; + const regExp = /[a-zA-Z]/g - return regExp.test(this.application.project_application_comment); + return regExp.test(this.application.project_application_comment) } } else { - return true; + return true } } getUserinfo(): void { this.userService.getUserInfo().subscribe((userinfo: Userinfo) => { - this.userinfo = userinfo; - this.valid_pi_affiliations = this.userinfo.validateAffiliations(); - }); + this.userinfo = userinfo + this.valid_pi_affiliations = this.userinfo.validateAffiliations() + }) } clearApplication(): void { - this.application = new Application(null); - this.application.project_application_openstack_project = this.openstack_project; + this.application = new Application(null) + this.application.project_application_openstack_project = this.openstack_project if (this.openstack_project) { - this.application.project_application_object_storage = 0; + this.application.project_application_object_storage = 0 } - this.application.project_application_volume_counter = 3; - this.application.project_application_volume_limit = 20; + this.application.project_application_volume_counter = 3 + this.application.project_application_volume_limit = 20 } initiateFormWithApplication(): void { if (this.application && !this.initiated_validation && this.is_validation) { - this.openstack_project = this.application.project_application_openstack_project; + this.openstack_project = this.application.project_application_openstack_project - this.simple_vm_project = !this.openstack_project; - this.application.project_application_pi = new User(); + this.simple_vm_project = !this.openstack_project + this.application.project_application_pi = new User() // this.searchTermsInEdamTerms(); if (this.application.dissemination.someAllowed()) { - this.project_application_report_allowed = true; + this.project_application_report_allowed = true } if (this.simple_vm_project) { - this.simple_vm_min_vm = this.application.flavors.length > 0; + this.simple_vm_min_vm = this.application.flavors.length > 0 } if (this.application.project_application_nfdi && this.application.project_application_nfdi.length > 0) { - this.max_lifetime = 12; + this.max_lifetime = 12 } - this.initiated_validation = true; + this.initiated_validation = true } else { - this.application = new Application(null); - this.application.project_application_openstack_project = this.openstack_project; - this.application.project_application_kubernetes_access = this.kubernetes_access; + this.application = new Application(null) + this.application.project_application_openstack_project = this.openstack_project + this.application.project_application_kubernetes_access = this.kubernetes_access if (this.openstack_project) { - this.application.project_application_object_storage = 0; + this.application.project_application_object_storage = 0 } - this.application.project_application_volume_counter = 0; - this.application.project_application_volume_limit = 0; + this.application.project_application_volume_counter = 0 + this.application.project_application_volume_limit = 0 } - this.isLoaded = true; + this.isLoaded = true } checkIfTypeGotSimpleVmFlavor(type: FlavorType): boolean { for (const flav of this.flavorList) { if (flav.type.shortcut === type.shortcut && flav.simple_vm) { - return true; + return true } } - return false; + return false } selectEvent(item: EdamOntologyTerm): void { - this.application.addEdamTerm(item); + this.application.addEdamTerm(item) } onChangeFlavor(flavor: Flavor, value: number): void { - this.application.setFlavorInFlavors(flavor, value); - this.valuesChanged(flavor, value); + this.application.setFlavorInFlavors(flavor, value) + this.valuesChanged(flavor, value) if (this.simple_vm_project) { - this.checkIfMinVmIsSelected(); + this.checkIfMinVmIsSelected() } } count_platform(checked: boolean): void { if (checked) { - this.dissemination_platform_count += 1; + this.dissemination_platform_count += 1 } else { - this.dissemination_platform_count += 1; + this.dissemination_platform_count += 1 } } @@ -244,25 +242,25 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent * @param shortname */ public checkShortname(shortname: string): void { - this.invalid_shortname = !/^[a-zA-Z0-9\s]*$/.test(shortname); + this.invalid_shortname = !/^[a-zA-Z0-9\s]*$/.test(shortname) } public checkLongname(longname: string): void { - this.invalid_longname = !/^[a-zA-Z0-9-_\s]*$/.test(longname); + this.invalid_longname = !/^[a-zA-Z0-9-_\s]*$/.test(longname) } public checkDescription(description: string): void { - this.invalid_description = !this.isASCII(description); + this.invalid_description = !this.isASCII(description) } /** * gets a list of all available Flavors from the flavorservice and puts them into the array flavorList */ getListOfFlavors(): void { - // eslint-disable-next-line no-return-assign + this.flavorService.getListOfFlavorsAvailable().subscribe((flavors: Flavor[]): void => { - this.flavorList = flavors; - }); + this.flavorList = flavors + }) } /** @@ -270,67 +268,67 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent */ getListOfTypes(): void { this.flavorService.getListOfTypesAvailable().subscribe((types: FlavorType[]): void => { - this.setListOfTypes(types); - }); + this.setListOfTypes(types) + }) } checkIfMinVmIsSelected(): void { - this.simple_vm_min_vm = this.application.flavors.length > 0; + this.simple_vm_min_vm = this.application.flavors.length > 0 } searchTermsInEdamTerms(): void { - const tmp: EdamOntologyTerm[] = []; + const tmp: EdamOntologyTerm[] = [] // tslint:disable-next-line:no-for-each-push typedef this.application.project_application_edam_terms.forEach(ele => { // tslint:disable-next-line:typedef // @ts-ignore // tslint:disable-next-line:typedef - const td = this.edam_ontology_terms.find(term => term.term === ele); - tmp.push(td); - }); - this.application.project_application_edam_terms = tmp; + const td = this.edam_ontology_terms.find(term => term.term === ele) + tmp.push(td) + }) + this.application.project_application_edam_terms = tmp } onSubmit(): void { - this.error = null; - this.submitting = true; + this.error = null + this.submitting = true if ( - this.application.project_application_volume_counter <= 0 - || this.application.project_application_volume_counter == null + this.application.project_application_volume_counter <= 0 || + this.application.project_application_volume_counter === null ) { - this.application.project_application_volume_limit = 0; + this.application.project_application_volume_limit = 0 } this.applicationsService.addNewApplication(this.application).subscribe( (application: Application): void => { - this.clearApplication(); - this.submitting = false; - this.survey_link_visible = true; - this.application_id = application.project_application_id; + this.clearApplication() + this.submitting = false + this.survey_link_visible = true + this.application_id = application.project_application_id - this.updateNotificationModal('Success', 'The application was submitted', true, 'success'); - this.fullLayout.getGroupsEnumeration(); + this.updateNotificationModal('Success', 'The application was submitted', true, 'success') + this.fullLayout.getGroupsEnumeration() - this.notificationModalStay = false; + this.notificationModalStay = false }, (error: object): void => { - this.survey_link_visible = false; + this.survey_link_visible = false - const error_json: object = error; - this.error = []; + const error_json: object = error + this.error = [] for (const key of Object.keys(error_json)) { - this.error.push(key.split('_')[2]); + this.error.push(key.split('_')[2]) } this.updateNotificationModal( 'Failed', 'The application was not submitted, please check the required fields and try again.', true, - 'danger', - ); - this.notificationModalStay = true; - }, - ); + 'danger' + ) + this.notificationModalStay = true + } + ) } /** @@ -342,26 +340,26 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent .getCreditsForApplication(this.application.flavors, this.application.project_application_lifetime) .toPromise() .then((credits: number): void => { - this.application.project_application_initial_credits = credits; + this.application.project_application_initial_credits = credits }) - .catch((err: any): void => console.log(err)); + .catch((err: any): void => console.log(err)) } approveApplication(form: NgForm): any { - this.calculateInitialCredits(form); - this.application_id = this.application.project_application_id; + this.calculateInitialCredits(form) + this.application_id = this.application.project_application_id this.applicationsService.validateApplicationAsPIByHash(this.hash, this.application).subscribe( (): void => { - this.fullLayout.getGroupsEnumeration(); + this.fullLayout.getGroupsEnumeration() - this.updateNotificationModal('Success', 'The application was successfully approved.', true, 'success'); - this.notificationModalStay = false; + this.updateNotificationModal('Success', 'The application was successfully approved.', true, 'success') + this.notificationModalStay = false }, (): void => { - this.updateNotificationModal('Failed', 'The application was not successfully approved.', true, 'danger'); - this.notificationModalStay = true; - }, - ); + this.updateNotificationModal('Failed', 'The application was not successfully approved.', true, 'danger') + this.notificationModalStay = true + } + ) } /** @@ -370,83 +368,83 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent * @param name of the new test application */ sendTestApplication(name: string): void { - const default_flav: Flavor = this.flavorList.find((fl: Flavor): boolean => fl.name === 'de.NBI default'); - - this.application.project_application_bmbf_project = 'BMBF'; - this.application.project_application_horizon2020 = 'horizon'; - this.application.setFlavorInFlavors(default_flav, 3); - this.application.project_application_pi_approved = true; - this.application.project_application_comment = 'TestApplication'; - this.application.project_application_description = 'TestApplication'; - this.application.project_application_institute = 'TestApplication'; - this.application.project_application_lifetime = 3; - this.application.project_application_name = name; - this.application.project_application_openstack_project = this.openstack_project; - this.application.project_application_report_allowed = false; - this.application.project_application_shortname = name.substr(0, 15); - this.application.project_application_volume_counter = 3; - this.application.project_application_volume_limit = 20; - this.application.project_application_workgroup = 'TestApplication'; - this.application.project_application_initial_credits = 5952; + const default_flav: Flavor = this.flavorList.find((fl: Flavor): boolean => fl.name === 'de.NBI default') + + this.application.project_application_bmbf_project = 'BMBF' + this.application.project_application_horizon2020 = 'horizon' + this.application.setFlavorInFlavors(default_flav, 3) + this.application.project_application_pi_approved = true + this.application.project_application_comment = 'TestApplication' + this.application.project_application_description = 'TestApplication' + this.application.project_application_institute = 'TestApplication' + this.application.project_application_lifetime = 3 + this.application.project_application_name = name + this.application.project_application_openstack_project = this.openstack_project + this.application.project_application_report_allowed = false + this.application.project_application_shortname = name.substr(0, 15) + this.application.project_application_volume_counter = 3 + this.application.project_application_volume_limit = 20 + this.application.project_application_workgroup = 'TestApplication' + this.application.project_application_initial_credits = 5952 this.applicationsService.addNewApplication(this.application).subscribe( (application: Application): void => { - this.clearApplication(); - this.submitting = false; - this.application_id = application.project_application_id; - this.updateNotificationModal('Success', 'The application was submitted', true, 'success'); - this.notificationModalStay = false; - this.fullLayout.getGroupsEnumeration(); + this.clearApplication() + this.submitting = false + this.application_id = application.project_application_id + this.updateNotificationModal('Success', 'The application was submitted', true, 'success') + this.notificationModalStay = false + this.fullLayout.getGroupsEnumeration() }, (error: object): void => { - const error_json: object = error; - this.error = []; + const error_json: object = error + this.error = [] for (const key of Object.keys(error_json)) { - this.error.push(key.split('_')[2]); + this.error.push(key.split('_')[2]) } this.updateNotificationModal( 'Failed', 'The application was not submitted, please check the required fields and try again.', true, - 'danger', - ); - this.notificationModalStay = true; - }, - ); + 'danger' + ) + this.notificationModalStay = true + } + ) } toggleProjectPart(checked: boolean, project_part: string): void { switch (project_part) { case 'horizon': { if (!checked) { - this.application.project_application_horizon2020 = ''; + this.application.project_application_horizon2020 = '' } - break; + break } case 'elixir': { if (!checked) { - this.application.project_application_elixir_project = ''; + this.application.project_application_elixir_project = '' } - break; + break } case 'bmbf': { if (!checked) { - this.application.project_application_bmbf_project = ''; + this.application.project_application_bmbf_project = '' } - break; + break } case 'nfdi': { if (!checked) { - this.application.project_application_nfdi = ''; - this.max_lifetime = this.MAX_LIFETIME_DEFAULT; + this.application.project_application_nfdi = '' + this.max_lifetime = this.MAX_LIFETIME_DEFAULT } else { - this.max_lifetime = 12; + this.max_lifetime = 12 } - break; + break } default: { - break; + break } } } @@ -455,33 +453,33 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent switch (data_type) { case 'person_related': { if (!checked) { - this.application.project_application_no_personal_data = false; - this.application.project_application_nonsensitive_data = false; - this.application.project_application_sensitive_data = false; + this.application.project_application_no_personal_data = false + this.application.project_application_nonsensitive_data = false + this.application.project_application_sensitive_data = false } - break; + break } case 'no_personal_data': { if (checked) { - this.application.project_application_nonsensitive_data = false; - this.application.project_application_sensitive_data = false; + this.application.project_application_nonsensitive_data = false + this.application.project_application_sensitive_data = false } - break; + break } case 'nonsensitive': { if (checked) { - this.application.project_application_no_personal_data = false; + this.application.project_application_no_personal_data = false } - break; + break } case 'sensitive': { if (checked) { - this.application.project_application_no_personal_data = false; + this.application.project_application_no_personal_data = false } - break; + break } default: - break; + break } } } diff --git a/src/app/applications/application-formular/kubernetes-formular/kubernetes-formular.component.ts b/src/app/applications/application-formular/kubernetes-formular/kubernetes-formular.component.ts index d433c3023d..d7bc07fad9 100644 --- a/src/app/applications/application-formular/kubernetes-formular/kubernetes-formular.component.ts +++ b/src/app/applications/application-formular/kubernetes-formular/kubernetes-formular.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component } from '@angular/core' /** * This components provides the functions to create a new Kubernetes Cloud Application. @@ -6,11 +6,11 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-kubernetes-formular', templateUrl: 'kubernetes-formular.component.html', - styleUrls: ['kubernetes-formular.component.css'], + styleUrls: ['kubernetes-formular.component.css'] }) export class KubernetesFormularComponent { - openstack_application: boolean = true; - kubernetes_access: boolean = true; + openstack_application: boolean = true + kubernetes_access: boolean = true - title: string = 'New Kubernetes Application'; + title: string = 'New Kubernetes Application' } diff --git a/src/app/applications/application-formular/openstack-formular/addcloudapplication.component.ts b/src/app/applications/application-formular/openstack-formular/addcloudapplication.component.ts index 0c83c5299f..e7ab64c356 100644 --- a/src/app/applications/application-formular/openstack-formular/addcloudapplication.component.ts +++ b/src/app/applications/application-formular/openstack-formular/addcloudapplication.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component } from '@angular/core' /** * This components provides the functions to create a new Cloud Application. @@ -6,10 +6,10 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-addcloudapplication', templateUrl: 'addcloudapplication.component.html', - styleUrls: ['addcloudapplication.component.css'], + styleUrls: ['addcloudapplication.component.css'] }) export class AddcloudapplicationComponent { - openstack_application: boolean = true; + openstack_application: boolean = true - title: string = 'New OpenStack Application'; + title: string = 'New OpenStack Application' } diff --git a/src/app/applications/application-formular/simplevm-formular/addsimplevm.component.ts b/src/app/applications/application-formular/simplevm-formular/addsimplevm.component.ts index b340668e0c..d4ea763795 100644 --- a/src/app/applications/application-formular/simplevm-formular/addsimplevm.component.ts +++ b/src/app/applications/application-formular/simplevm-formular/addsimplevm.component.ts @@ -1,13 +1,13 @@ -import { Component } from '@angular/core'; +import { Component } from '@angular/core' /** * Component to create single vm applications. */ @Component({ selector: 'app-addsimplevm', - templateUrl: 'addsimplevm.component.html', + templateUrl: 'addsimplevm.component.html' }) export class AddsimplevmComponent { - simple_vm_application: boolean = true; - title: string = 'New Simple Vm Application'; + simple_vm_application: boolean = true + title: string = 'New Simple Vm Application' } diff --git a/src/app/applications/application-header/application-header.component.spec.ts b/src/app/applications/application-header/application-header.component.spec.ts index 06c39a25c4..929ce2c2e1 100644 --- a/src/app/applications/application-header/application-header.component.spec.ts +++ b/src/app/applications/application-header/application-header.component.spec.ts @@ -1,22 +1,22 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing' -import { ApplicationHeaderComponent } from './application-header.component'; +import { ApplicationHeaderComponent } from './application-header.component' describe('ApplicationHeaderComponent', () => { - let component: ApplicationHeaderComponent; - let fixture: ComponentFixture; + let component: ApplicationHeaderComponent + let fixture: ComponentFixture beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ApplicationHeaderComponent], - }).compileComponents(); + imports: [ApplicationHeaderComponent] + }).compileComponents() - fixture = TestBed.createComponent(ApplicationHeaderComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + fixture = TestBed.createComponent(ApplicationHeaderComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) it('should create', () => { - expect(component).toBeTruthy(); - }); -}); + expect(component).toBeTruthy() + }) +}) diff --git a/src/app/applications/application-header/application-header.component.ts b/src/app/applications/application-header/application-header.component.ts index 408fec6e6d..965cebea0b 100644 --- a/src/app/applications/application-header/application-header.component.ts +++ b/src/app/applications/application-header/application-header.component.ts @@ -1,10 +1,10 @@ -import { Component } from '@angular/core'; +import { Component } from '@angular/core' @Component({ selector: 'app-application-header', standalone: true, imports: [], templateUrl: './application-header.component.html', - styleUrl: './application-header.component.scss', + styleUrl: './application-header.component.scss' }) export class ApplicationHeaderComponent {} diff --git a/src/app/applications/application-list/application-list.component.spec.ts b/src/app/applications/application-list/application-list.component.spec.ts index 4ee910f899..3810753bb3 100644 --- a/src/app/applications/application-list/application-list.component.spec.ts +++ b/src/app/applications/application-list/application-list.component.spec.ts @@ -1,22 +1,22 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing' -import { ApplicationListComponent } from './application-list.component'; +import { ApplicationListComponent } from './application-list.component' describe('ApplicationListComponent', () => { - let component: ApplicationListComponent; - let fixture: ComponentFixture; + let component: ApplicationListComponent + let fixture: ComponentFixture beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ApplicationListComponent], - }).compileComponents(); + imports: [ApplicationListComponent] + }).compileComponents() - fixture = TestBed.createComponent(ApplicationListComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + fixture = TestBed.createComponent(ApplicationListComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) it('should create', () => { - expect(component).toBeTruthy(); - }); -}); + expect(component).toBeTruthy() + }) +}) diff --git a/src/app/applications/application-list/application-list.component.ts b/src/app/applications/application-list/application-list.component.ts index c1c4a11e4d..3792311fc0 100644 --- a/src/app/applications/application-list/application-list.component.ts +++ b/src/app/applications/application-list/application-list.component.ts @@ -1,87 +1,85 @@ -import { - Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, -} from '@angular/core'; -import { Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class'; +import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core' +import { Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class' -import { Application } from '../application.model/application.model'; -import { ApplicationTabStates } from '../../shared/enums/application-tab-states'; -import { ComputecenterComponent } from '../../projectmanagement/computecenter.component'; -import { is_vo } from '../../shared/globalvar'; +import { Application } from '../application.model/application.model' +import { ApplicationTabStates } from '../../shared/enums/application-tab-states' +import { ComputecenterComponent } from '../../projectmanagement/computecenter.component' +import { is_vo } from '../../shared/globalvar' @Component({ selector: 'app-application-list', templateUrl: './application-list.component.html', - styleUrl: './application-list.component.scss', + styleUrl: './application-list.component.scss' }) export class ApplicationListComponent implements OnInit, OnChanges { - @Output() reloadNumbersTrigger: EventEmitter = new EventEmitter(); + @Output() reloadNumbersTrigger: EventEmitter = new EventEmitter() - @Input() applications: Application[] = []; - @Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED; - @Input() computeCenters: ComputecenterComponent[] = []; - @Input() facilityView: boolean = false; - @Input() voView: boolean = false; + @Input() applications: Application[] = [] + @Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED + @Input() computeCenters: ComputecenterComponent[] = [] + @Input() facilityView: boolean = false + @Input() voView: boolean = false - dataTestId: string = ''; + dataTestId: string = '' - is_vo_admin: boolean = false; + is_vo_admin: boolean = false ngOnInit() { - this.is_vo_admin = is_vo; - this.setDataTestId(); + this.is_vo_admin = is_vo + this.setDataTestId() } // eslint-disable-next-line @typescript-eslint/no-unused-vars ngOnChanges(changes: SimpleChanges) { - this.setDataTestId(); + this.setDataTestId() } setDataTestId(): void { - console.log('set data test id'); + console.log('set data test id') switch (this.tabState) { case ApplicationTabStates.SUBMITTED: { - this.dataTestId = 'submitted_applications_container'; - break; + this.dataTestId = 'submitted_applications_container' + break } case ApplicationTabStates.CREDITS_EXTENSION: { - this.dataTestId = 'credits_requests_applications_container'; - break; + this.dataTestId = 'credits_requests_applications_container' + break } case ApplicationTabStates.LIFETIME_EXTENSION: { - this.dataTestId = 'lifetime_requests_applications_container'; - break; + this.dataTestId = 'lifetime_requests_applications_container' + break } case ApplicationTabStates.MODIFICATION_EXTENSION: { - this.dataTestId = 'modification_requests_applications_container'; - break; + this.dataTestId = 'modification_requests_applications_container' + break } case ApplicationTabStates.TERMINATION_REQUEST: { - this.dataTestId = 'termination_requests_applications_container'; - break; + this.dataTestId = 'termination_requests_applications_container' + break } default: { - break; + break } } - console.log(this.dataTestId); + console.log(this.dataTestId) } triggerReloadNumbers() { - console.log('trigger reload 2'); - this.reloadNumbersTrigger.emit(); + console.log('trigger reload 2') + this.reloadNumbersTrigger.emit() } removeApplicationFromList(application_id: string | number) { const idx: number = this.applications.findIndex( - (application: Application) => application.project_application_id === application_id, - ); + (application: Application) => application.project_application_id === application_id + ) if (idx !== -1) { - console.log('remove index'); - this.applications.splice(idx, 1); + console.log('remove index') + this.applications.splice(idx, 1) } } - protected readonly Application_States = Application_States; + protected readonly Application_States = Application_States } diff --git a/src/app/applications/application-ressource-usage/application-ressource-usage.ts b/src/app/applications/application-ressource-usage/application-ressource-usage.ts index 320e167b8a..01a9248c00 100644 --- a/src/app/applications/application-ressource-usage/application-ressource-usage.ts +++ b/src/app/applications/application-ressource-usage/application-ressource-usage.ts @@ -1,72 +1,72 @@ -import { Flavor } from '../../virtualmachines/virtualmachinemodels/flavor'; -import { WorkerBatch } from '../../virtualmachines/clusters/clusterinfo'; +import { Flavor } from '../../virtualmachines/virtualmachinemodels/flavor' +import { WorkerBatch } from '../../virtualmachines/clusters/clusterinfo' /** * Ressourceusage. */ export class ApplicationRessourceUsage { - number_vms: number; - used_vms: number; - max_volume_storage: number; - used_volume_storage: number; - volume_counter: number; - used_volumes: number; - cores_total: number; - cores_used: number; - ram_total: number; - ram_used: number; - gpus_max: number; - gpus_used: number; + number_vms: number + used_vms: number + max_volume_storage: number + used_volume_storage: number + volume_counter: number + used_volumes: number + cores_total: number + cores_used: number + ram_total: number + ram_used: number + gpus_max: number + gpus_used: number constructor(usage: ApplicationRessourceUsage) { - this.number_vms = usage.number_vms; - this.used_vms = usage.used_vms; - this.max_volume_storage = usage.max_volume_storage; - this.used_volume_storage = usage.used_volume_storage; - this.volume_counter = usage.volume_counter; - this.used_volumes = usage.used_volumes; - this.cores_total = usage.cores_total; - this.cores_used = usage.cores_used; - this.ram_total = usage.ram_total; - this.ram_used = usage.ram_used; - this.gpus_max = usage.gpus_max; - this.gpus_used = usage.gpus_used; + this.number_vms = usage.number_vms + this.used_vms = usage.used_vms + this.max_volume_storage = usage.max_volume_storage + this.used_volume_storage = usage.used_volume_storage + this.volume_counter = usage.volume_counter + this.used_volumes = usage.used_volumes + this.cores_total = usage.cores_total + this.cores_used = usage.cores_used + this.ram_total = usage.ram_total + this.ram_used = usage.ram_used + this.gpus_max = usage.gpus_max + this.gpus_used = usage.gpus_used } filterFlavorsTest(flavor: Flavor, worker_batches?: WorkerBatch[], master_flavor?: Flavor): boolean { - let batches_ram: number = 0; - let batches_cpu: number = 0; - let batches_gpus: number = 0; + let batches_ram: number = 0 + let batches_cpu: number = 0 + let batches_gpus: number = 0 if (master_flavor) { - batches_ram += master_flavor.ram_gib; - batches_cpu += master_flavor.vcpus; - batches_gpus += master_flavor.gpu; + batches_ram += master_flavor.ram_gib + batches_cpu += master_flavor.vcpus + batches_gpus += master_flavor.gpu } if (worker_batches) { worker_batches.forEach((batch: WorkerBatch): void => { if (batch.flavor) { - batches_ram += batch.flavor.ram_gib * batch.worker_count; - batches_cpu += batch.flavor.vcpus * batch.worker_count; - batches_gpus += batch.flavor.gpu * batch.worker_count; + batches_ram += batch.flavor.ram_gib * batch.worker_count + batches_cpu += batch.flavor.vcpus * batch.worker_count + batches_gpus += batch.flavor.gpu * batch.worker_count } - }); + }) } - const available_cores: number = this.cores_total - (flavor.vcpus + this.cores_used + batches_cpu); - const available_ram: number = this.ram_total - (flavor.ram_gib + this.ram_used + batches_ram); - const available_gpu: number = this.gpus_max - (flavor.gpu + this.gpus_used + batches_gpus); + const available_cores: number = this.cores_total - (flavor.vcpus + this.cores_used + batches_cpu) + const available_ram: number = this.ram_total - (flavor.ram_gib + this.ram_used + batches_ram) + const available_gpu: number = this.gpus_max - (flavor.gpu + this.gpus_used + batches_gpus) - return available_cores >= 0 && available_ram >= 0 && available_gpu >= 0; + return available_cores >= 0 && available_ram >= 0 && available_gpu >= 0 } filterFlavorsTestUpScaling(flavor: Flavor): boolean { - const available_cores: number = this.cores_total - (flavor.vcpus + this.cores_used); - const available_ram: number = this.ram_total - (flavor.ram_gib + this.ram_used); - const available_gpu: number = this.gpus_max - (flavor.gpu + this.gpus_used); + const available_cores: number = this.cores_total - (flavor.vcpus + this.cores_used) + const available_ram: number = this.ram_total - (flavor.ram_gib + this.ram_used) + const available_gpu: number = this.gpus_max - (flavor.gpu + this.gpus_used) - return available_cores >= 0 && available_ram >= 0 && available_gpu >= 0; + return available_cores >= 0 && available_ram >= 0 && available_gpu >= 0 } filterFlavors( @@ -74,75 +74,77 @@ export class ApplicationRessourceUsage { new_ram: number, new_gpus: number, possible_flavors: Flavor[], - worker_batches: WorkerBatch[], + worker_batches: WorkerBatch[] ): Flavor[] { - let batches_ram: number = 0; - let batches_cpu: number = 0; - let batches_gpus: number = 0; + let batches_ram: number = 0 + let batches_cpu: number = 0 + let batches_gpus: number = 0 worker_batches.forEach((batch: WorkerBatch): void => { if (batch.flavor) { - batches_ram += batch.flavor.ram_gib * batch.worker_count; - batches_cpu += batch.flavor.vcpus * batch.worker_count; - batches_gpus += batch.flavor.gpu * batch.worker_count; + batches_ram += batch.flavor.ram_gib * batch.worker_count + batches_cpu += batch.flavor.vcpus * batch.worker_count + batches_gpus += batch.flavor.gpu * batch.worker_count } - }); - const tmp_flavors: Flavor[] = []; - const available_cores: number = this.cores_total - (new_cores + this.cores_used + batches_cpu); - const available_ram: number = this.ram_total - (new_ram + this.ram_used + batches_ram); - const available_gpu: number = this.gpus_max - (new_gpus + this.gpus_used + batches_gpus); + }) + const tmp_flavors: Flavor[] = [] + const available_cores: number = this.cores_total - (new_cores + this.cores_used + batches_cpu) + const available_ram: number = this.ram_total - (new_ram + this.ram_used + batches_ram) + const available_gpu: number = this.gpus_max - (new_gpus + this.gpus_used + batches_gpus) for (const fl of possible_flavors) { if (fl.vcpus <= available_cores && fl.ram_gib <= available_ram && fl.gpu <= available_gpu) { - tmp_flavors.push(fl); + tmp_flavors.push(fl) } } - return tmp_flavors; + return tmp_flavors } calcMaxWorkerInstancesByFlavor( master_flavor: Flavor, selectedBatch: WorkerBatch, - worker_batches: WorkerBatch[], + worker_batches: WorkerBatch[] ): number { - let batches_ram: number = 0; - let batches_cpu: number = 0; - let batches_vms: number = 0; - let batches_gpus: number = 0; + let batches_ram: number = 0 + let batches_cpu: number = 0 + let batches_vms: number = 0 + let batches_gpus: number = 0 worker_batches.forEach((batch: WorkerBatch): void => { if (batch.flavor && batch !== selectedBatch) { - batches_ram += Math.ceil(batch.flavor.ram_gib * batch.worker_count); - batches_cpu += batch.flavor.vcpus * batch.worker_count; - batches_vms += batch.worker_count; - batches_gpus += batch.worker_count * batch.flavor.gpu; + batches_ram += Math.ceil(batch.flavor.ram_gib * batch.worker_count) + batches_cpu += batch.flavor.vcpus * batch.worker_count + batches_vms += batch.worker_count + batches_gpus += batch.worker_count * batch.flavor.gpu } - }); - const ram_max_vms: number = (this.ram_total - this.ram_used - master_flavor.ram_gib - batches_ram) / selectedBatch.flavor.ram_gib; + }) + const ram_max_vms: number = + (this.ram_total - this.ram_used - master_flavor.ram_gib - batches_ram) / selectedBatch.flavor.ram_gib // just set to ram max if gpu will be zero - let gpu_max_vms: number = ram_max_vms; + let gpu_max_vms: number = ram_max_vms - const cpu_max_vms: number = (this.cores_total - this.cores_used - master_flavor.vcpus - batches_cpu) / selectedBatch.flavor.vcpus; + const cpu_max_vms: number = + (this.cores_total - this.cores_used - master_flavor.vcpus - batches_cpu) / selectedBatch.flavor.vcpus if (selectedBatch.flavor.gpu > 0) { - gpu_max_vms = (this.gpus_max - this.gpus_used - master_flavor.gpu - batches_gpus) / selectedBatch.flavor.gpu; + gpu_max_vms = (this.gpus_max - this.gpus_used - master_flavor.gpu - batches_gpus) / selectedBatch.flavor.gpu } return Math.floor( - Math.min(ram_max_vms, cpu_max_vms, gpu_max_vms, this.number_vms - this.used_vms - 1 - batches_vms), - ); + Math.min(ram_max_vms, cpu_max_vms, gpu_max_vms, this.number_vms - this.used_vms - 1 - batches_vms) + ) } calcMaxScaleUpWorkerInstancesByFlavor(worker_flavor: Flavor): number { - const ram_max_vms: number = (this.ram_total - this.ram_used) / worker_flavor.ram_gib; - const cpu_max_vms: number = (this.cores_total - this.cores_used) / worker_flavor.vcpus; + const ram_max_vms: number = (this.ram_total - this.ram_used) / worker_flavor.ram_gib + const cpu_max_vms: number = (this.cores_total - this.cores_used) / worker_flavor.vcpus // just set to ram max if gpu will be zero - let gpu_max_vms: number = ram_max_vms; + let gpu_max_vms: number = ram_max_vms if (worker_flavor.gpu > 0) { - gpu_max_vms = (this.gpus_max - this.gpus_used) / worker_flavor.gpu; + gpu_max_vms = (this.gpus_max - this.gpus_used) / worker_flavor.gpu } - return Math.floor(Math.min(ram_max_vms, cpu_max_vms, gpu_max_vms, this.number_vms - this.used_vms)); + return Math.floor(Math.min(ram_max_vms, cpu_max_vms, gpu_max_vms, this.number_vms - this.used_vms)) } } diff --git a/src/app/applications/application-vo-actions/application-vo-actions.component.spec.ts b/src/app/applications/application-vo-actions/application-vo-actions.component.spec.ts index 29b795233c..8443466a62 100644 --- a/src/app/applications/application-vo-actions/application-vo-actions.component.spec.ts +++ b/src/app/applications/application-vo-actions/application-vo-actions.component.spec.ts @@ -1,22 +1,22 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing' -import { ApplicationVoActionsComponent } from './application-vo-actions.component'; +import { ApplicationVoActionsComponent } from './application-vo-actions.component' describe('ApplicationVoActionsComponent', () => { - let component: ApplicationVoActionsComponent; - let fixture: ComponentFixture; + let component: ApplicationVoActionsComponent + let fixture: ComponentFixture beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ApplicationVoActionsComponent], - }).compileComponents(); + imports: [ApplicationVoActionsComponent] + }).compileComponents() - fixture = TestBed.createComponent(ApplicationVoActionsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + fixture = TestBed.createComponent(ApplicationVoActionsComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) it('should create', () => { - expect(component).toBeTruthy(); - }); -}); + expect(component).toBeTruthy() + }) +}) diff --git a/src/app/applications/application-vo-actions/application-vo-actions.component.ts b/src/app/applications/application-vo-actions/application-vo-actions.component.ts index d3d8311db6..9aef00cc31 100644 --- a/src/app/applications/application-vo-actions/application-vo-actions.component.ts +++ b/src/app/applications/application-vo-actions/application-vo-actions.component.ts @@ -1,48 +1,46 @@ -import { - Component, EventEmitter, Input, OnInit, Output, -} from '@angular/core'; -import { Subscription } from 'rxjs'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { HttpStatusCode } from '@angular/common/http'; -import { ApplicationTabStates } from 'app/shared/enums/application-tab-states'; -import { ConfirmationActions } from 'app/shared/modal/confirmation_actions'; -import { AbstractBaseClass, Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class'; - -import { Application } from '../application.model/application.model'; -import { ComputecenterComponent } from '../../projectmanagement/computecenter.component'; -import { is_vo } from '../../shared/globalvar'; -import { ApplicationsService } from '../../api-connector/applications.service'; -import { VoService } from '../../api-connector/vo.service'; -import { GroupService } from '../../api-connector/group.service'; -import { AdjustLifetimeRequestComponent } from '../../projectmanagement/modals/adjust-lifetime/adjust-lifetime-request.component'; -import { AdjustApplicationComponent } from '../../projectmanagement/modals/adjust-application/adjust-application.component'; -import { ModificationRequestComponent } from '../../projectmanagement/modals/modification-request/modification-request.component'; -import { ConfirmationModalComponent } from '../../shared/modal/confirmation-modal.component'; -import { ClientLimitsComponent } from '../../vo_manager/clients/modals/client-limits..component'; -import { NotificationModalComponent } from '../../shared/modal/notification-modal'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' +import { Subscription } from 'rxjs' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { HttpStatusCode } from '@angular/common/http' +import { ApplicationTabStates } from 'app/shared/enums/application-tab-states' +import { ConfirmationActions } from 'app/shared/modal/confirmation_actions' +import { AbstractBaseClass, Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class' + +import { Application } from '../application.model/application.model' +import { ComputecenterComponent } from '../../projectmanagement/computecenter.component' +import { is_vo } from '../../shared/globalvar' +import { ApplicationsService } from '../../api-connector/applications.service' +import { VoService } from '../../api-connector/vo.service' +import { GroupService } from '../../api-connector/group.service' +import { AdjustLifetimeRequestComponent } from '../../projectmanagement/modals/adjust-lifetime/adjust-lifetime-request.component' +import { AdjustApplicationComponent } from '../../projectmanagement/modals/adjust-application/adjust-application.component' +import { ModificationRequestComponent } from '../../projectmanagement/modals/modification-request/modification-request.component' +import { ConfirmationModalComponent } from '../../shared/modal/confirmation-modal.component' +import { ClientLimitsComponent } from '../../vo_manager/clients/modals/client-limits..component' +import { NotificationModalComponent } from '../../shared/modal/notification-modal' @Component({ selector: 'app-application-vo-actions', templateUrl: './application-vo-actions.component.html', - styleUrl: './application-vo-actions.component.scss', + styleUrl: './application-vo-actions.component.scss' }) export class ApplicationVoActionsComponent extends AbstractBaseClass implements OnInit { - private subscription: Subscription = new Subscription(); + private subscription: Subscription = new Subscription() - @Input() application: Application; - @Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED; - @Input() computeCenters: ComputecenterComponent[] = []; - @Output() reloadNumbersTrigger: EventEmitter = new EventEmitter(); - @Output() reloadApplicationTrigger: EventEmitter = new EventEmitter(); - @Output() removeApplicationTrigger: EventEmitter = new EventEmitter(); - @Output() switchCollapseEvent: EventEmitter = new EventEmitter(); + @Input() application: Application + @Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED + @Input() computeCenters: ComputecenterComponent[] = [] + @Output() reloadNumbersTrigger: EventEmitter = new EventEmitter() + @Output() reloadApplicationTrigger: EventEmitter = new EventEmitter() + @Output() removeApplicationTrigger: EventEmitter = new EventEmitter() + @Output() switchCollapseEvent: EventEmitter = new EventEmitter() - bsModalRef: BsModalRef; - is_vo_admin: boolean = false; - selectedComputeCenter: ComputecenterComponent; + bsModalRef: BsModalRef + is_vo_admin: boolean = false + selectedComputeCenter: ComputecenterComponent ngOnInit() { - this.is_vo_admin = is_vo; + this.is_vo_admin = is_vo } constructor( @@ -51,13 +49,13 @@ export class ApplicationVoActionsComponent extends AbstractBaseClass implements private voService: VoService, private groupService: GroupService, private adjustLifeTimeExtensionModal: AdjustLifetimeRequestComponent, - private adjustApplicationModal: AdjustApplicationComponent, + private adjustApplicationModal: AdjustApplicationComponent ) { - super(); + super() } triggerRemoveApplication() { - this.removeApplicationTrigger.emit(this.application.project_application_id); + this.removeApplicationTrigger.emit(this.application.project_application_id) } showAdjustLifetimeExtensionModal() { @@ -65,113 +63,113 @@ export class ApplicationVoActionsComponent extends AbstractBaseClass implements .showAdjustLifetimeExtensionModal(this.application) .subscribe((eventSuccess: boolean) => { if (eventSuccess) { - this.triggerReloadApplication(); + this.triggerReloadApplication() this.showNotificationModal( 'Success', 'The lifetime of the extension request were adjusted successfully!', - 'success', - ); + 'success' + ) } else { - this.showNotificationModal('Failed', 'The adjustment of the lifetime has failed!', 'danger'); + this.showNotificationModal('Failed', 'The adjustment of the lifetime has failed!', 'danger') } - }); + }) } triggerReloadApplication(): void { - this.reloadApplicationTrigger.emit(); + this.reloadApplicationTrigger.emit() } showAdjustApplicationModal() { this.adjustApplicationModal.showAdjustApplicationModal(this.application).subscribe((changed: boolean) => { if (changed) { - this.triggerReloadApplication(); + this.triggerReloadApplication() - this.showNotificationModal('Success', 'The resources of the application were adjusted successfully!', 'success'); + this.showNotificationModal('Success', 'The resources of the application were adjusted successfully!', 'success') } else { - this.showNotificationModal('Failed', 'The adjustment of the resources has failed!', 'danger'); + this.showNotificationModal('Failed', 'The adjustment of the resources has failed!', 'danger') } - }); + }) } showModificationAdjustmentModal() { const initialState = { project: this.application, - adjustment: true, - }; + adjustment: true + } this.bsModalRef = this.modalService.show(ModificationRequestComponent, { initialState, - class: 'modal-lg', - }); - this.subscribeToBsModalRef(); + class: 'modal-lg' + }) + this.subscribeToBsModalRef() // this.subscribeForExtensionResult(this.ExtensionRequestType.MODIFICATION); } triggerReloadNumbers() { - this.reloadNumbersTrigger.emit(); + this.reloadNumbersTrigger.emit() } setCurrentUserProcessingVoManager(application: Application): void { if (this.is_vo_admin) { this.voService.setCurrentUserProcessingVoManager(application.project_application_id).subscribe((res: any) => { - application.processing_vo_initials = res['processing_vo_initials']; - }); + application.processing_vo_initials = res['processing_vo_initials'] + }) } } showConfirmationModal(action: ConfirmationActions): void { - let initialState = {}; + let initialState = {} if (action === ConfirmationActions.APPROVE_APPLICATION) { - const application_center = !this.selectedComputeCenter.FacilityId; - initialState = { application: this.application, action, application_center }; + const application_center = !this.selectedComputeCenter.FacilityId + initialState = { application: this.application, action, application_center } } else { initialState = { application: this.application, - action, - }; + action + } } - this.bsModalRef = this.modalService.show(ConfirmationModalComponent, { initialState, class: 'modal-lg' }); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(ConfirmationModalComponent, { initialState, class: 'modal-lg' }) + this.subscribeToBsModalRef() } unsetProcessingVoManager(application: Application): void { if (this.is_vo_admin) { this.voService.unsetProcessingVoManager(application.project_application_id).subscribe(() => { - application.processing_vo_initials = null; - }); + application.processing_vo_initials = null + }) } } showClientsLimitsModal(is_modification_request: boolean = false): void { - let initialState = {}; + let initialState = {} if (is_modification_request) { initialState = { compute_center_id: this.application.project_application_compute_center.FacilityId, application: this.application, - is_modification_request, - }; + is_modification_request + } } else { initialState = { compute_center_id: this.selectedComputeCenter.FacilityId, application: this.application, - is_modification_request, - }; + is_modification_request + } } - this.bsModalRef = this.modalService.show(ClientLimitsComponent, { initialState }); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(ClientLimitsComponent, { initialState }) + this.subscribeToBsModalRef() } removeApplicationFromFacilityConfirmation(): void { this.groupService.removeGroupFromResource(this.application.project_application_perun_id.toString()).subscribe( (): void => { - this.triggerReloadApplication(); - this.showNotificationModal('Success', 'The application was removed from the compute center', 'success'); + this.triggerReloadApplication() + this.showNotificationModal('Success', 'The application was removed from the compute center', 'success') }, (): void => { - this.showNotificationModal('Failed', 'The application was removed from the compute center', 'danger'); - }, - ); + this.showNotificationModal('Failed', 'The application was removed from the compute center', 'danger') + } + ) } assignGroupToFacility(): void { @@ -180,46 +178,46 @@ export class ApplicationVoActionsComponent extends AbstractBaseClass implements .assignGroupToResource(this.application.project_application_perun_id, this.selectedComputeCenter.FacilityId) .subscribe( (): void => { - this.triggerReloadApplication(); + this.triggerReloadApplication() - this.showNotificationModal('Success', 'The project was assigned to the facility.', 'success'); + this.showNotificationModal('Success', 'The project was assigned to the facility.', 'success') }, (error: object): void => { - console.log(error); - this.showNotificationModal('Failed', 'Project could not be created!', 'danger'); - }, - ); + console.log(error) + this.showNotificationModal('Failed', 'Project could not be created!', 'danger') + } + ) } else { - this.showNotificationModal('Failed', 'You need to select an compute center!', 'danger'); + this.showNotificationModal('Failed', 'You need to select an compute center!', 'danger') } } resetApplicationPI(): void { this.applicationsService.resetPIValidation(this.application).subscribe(() => { - this.triggerReloadApplication(); - }); + this.triggerReloadApplication() + }) } switchCollaps() { - this.switchCollapseEvent.emit(); + this.switchCollapseEvent.emit() } showNotificationModal( notificationModalTitle: string, notificationModalMessage: string, - notificationModalType: string, + notificationModalType: string ) { - const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage }; + const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage } if (this.bsModalRef) { - this.bsModalRef.hide(); + this.bsModalRef.hide() } - this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); + this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') } createSimpleVmProjectGroup(): void { - this.showNotificationModal('Info', 'Creating Project...', 'info'); + this.showNotificationModal('Info', 'Creating Project...', 'info') if (this.selectedComputeCenter && this.selectedComputeCenter.FacilityId) { this.groupService @@ -230,63 +228,64 @@ export class ApplicationVoActionsComponent extends AbstractBaseClass implements this.showNotificationModal( 'Failed', `The client ${res['client_name']} has not the necessary resources left!`, - 'danger', - ); + 'danger' + ) } else { - this.showNotificationModal('Success', 'The project was created!', 'success'); - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); + this.showNotificationModal('Success', 'The project was created!', 'success') + this.triggerRemoveApplication() + this.triggerReloadNumbers() } }, (error: any): void => { - console.log(error); - const errorMessage = error && error.error === 'locked' - ? 'Project is locked and could not be created!' - : 'Project could not be created!'; - - this.showNotificationModal('Failed', errorMessage, 'danger'); - console.log(error); - }, - ); + console.log(error) + const errorMessage = + error && error.error === 'locked' + ? 'Project is locked and could not be created!' + : 'Project could not be created!' + + this.showNotificationModal('Failed', errorMessage, 'danger') + console.log(error) + } + ) } } approveModificationRequest(): void { this.applicationsService.approveModificationRequest(this.application.project_application_id).subscribe( (res: Response): void => { - this.showNotificationModal('Success', 'The resource modification request was approved!', 'success'); + this.showNotificationModal('Success', 'The resource modification request was approved!', 'success') if (!this.application.project_application_openstack_project) { if (res.status === HttpStatusCode.Accepted) { - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); + this.triggerRemoveApplication() + this.triggerReloadNumbers() // this.all_applications.splice(this.all_applications.indexOf(application), 1); } } else { - this.triggerReloadApplication(); + this.triggerReloadApplication() } }, (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Approval of resource modification failed!', 'danger'); - }, - ); + console.log('error', err.status) + this.showNotificationModal('Failed', 'Approval of resource modification failed!', 'danger') + } + ) } declineModificationRequest(): void { this.applicationsService.deleteModificationRequest(this.application.project_application_id).subscribe( (): void => { - this.showNotificationModal('Declined', 'The resource modification request was declined!', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); + this.showNotificationModal('Declined', 'The resource modification request was declined!', 'success') + this.triggerReloadNumbers() + this.triggerRemoveApplication() - this.triggerReloadApplication(); + this.triggerReloadApplication() }, (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Decline of resource modification failed!', 'danger'); - }, - ); + console.log('error', err.status) + this.showNotificationModal('Failed', 'Decline of resource modification failed!', 'danger') + } + ) } deleteApplication(): void { @@ -295,102 +294,102 @@ export class ApplicationVoActionsComponent extends AbstractBaseClass implements this.subscription.add( this.applicationsService.deleteApplication(this.application.project_application_id).subscribe( (): void => { - this.showNotificationModal('Success', 'The application has been successfully removed', 'success'); - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); + this.showNotificationModal('Success', 'The application has been successfully removed', 'success') + this.triggerRemoveApplication() + this.triggerReloadNumbers() }, (): void => { - this.updateNotificationModal('Failed', 'Application could not be removed!', true, 'danger'); - }, - ), - ); + this.updateNotificationModal('Failed', 'Application could not be removed!', true, 'danger') + } + ) + ) } declineLifetimeExtension(): void { this.applicationsService.deleteAdditionalLifetimeRequests(this.application.project_application_id).subscribe( (): void => { - this.showNotificationModal('Declined', 'The project extension was declined!', 'success'); - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); + this.showNotificationModal('Declined', 'The project extension was declined!', 'success') + this.triggerRemoveApplication() + this.triggerReloadNumbers() }, (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Decline of project extension failed!', 'danger'); - }, - ); + console.log('error', err.status) + this.showNotificationModal('Failed', 'Decline of project extension failed!', 'danger') + } + ) } declineCreditExtension(): void { this.applicationsService.deleteAdditionalCreditsRequests(this.application.project_application_id).subscribe( (): void => { - this.showNotificationModal('Declined', 'The credit extension request was declined!', 'success'); - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); + this.showNotificationModal('Declined', 'The credit extension request was declined!', 'success') + this.triggerRemoveApplication() + this.triggerReloadNumbers() }, (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Decline of credit extension failed!', 'danger'); - }, - ); + console.log('error', err.status) + this.showNotificationModal('Failed', 'Decline of credit extension failed!', 'danger') + } + ) } declineApplication(): void { // const idx: number = this.all_applications.indexOf(app); this.applicationsService.declineApplication(this.application.project_application_id).subscribe( (): void => { - const message: string = 'The Application was declined.'; + const message: string = 'The Application was declined.' - this.showNotificationModal('Success', message, 'success'); - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); + this.showNotificationModal('Success', message, 'success') + this.triggerRemoveApplication() + this.triggerReloadNumbers() }, (): void => { - this.showNotificationModal('Failed', 'Application could not be declined!', 'danger'); - }, - ); + this.showNotificationModal('Failed', 'Application could not be declined!', 'danger') + } + ) } approveLifetimeExtension(): void { this.applicationsService.approveAdditionalLifetime(this.application.project_application_id).subscribe( (res: Response): void => { if (this.application.project_application_openstack_project) { - this.triggerReloadApplication(); - this.showNotificationModal('Success', 'The request has been sent to the facility manager.', 'success'); + this.triggerReloadApplication() + this.showNotificationModal('Success', 'The request has been sent to the facility manager.', 'success') } else { - this.showNotificationModal('Success', 'The project has been extended!', 'success'); + this.showNotificationModal('Success', 'The project has been extended!', 'success') } if (!this.application.project_application_openstack_project) { if (res.status === HttpStatusCode.Accepted) { - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); + this.triggerReloadNumbers() + this.triggerRemoveApplication() } } }, (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Project lifetime could not be extendend!', 'danger'); - }, - ); + console.log('error', err.status) + this.showNotificationModal('Failed', 'Project lifetime could not be extendend!', 'danger') + } + ) } approveCreditExtension(): void { this.applicationsService.approveAdditionalCreditsRequest(this.application.project_application_id).subscribe( (res: Response): void => { - this.showNotificationModal('Success', 'The credit extension request was approved!', 'success'); + this.showNotificationModal('Success', 'The credit extension request was approved!', 'success') if (!this.application.project_application_openstack_project) { if (res.status === HttpStatusCode.Accepted) { - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); + this.triggerReloadNumbers() + this.triggerRemoveApplication() } } else { - this.triggerReloadApplication(); + this.triggerReloadApplication() } }, (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Approval of credit extension failed!', 'danger'); - }, - ); + console.log('error', err.status) + this.showNotificationModal('Failed', 'Approval of credit extension failed!', 'danger') + } + ) } createOpenStackProjectGroup(): void { @@ -399,22 +398,23 @@ export class ApplicationVoActionsComponent extends AbstractBaseClass implements .subscribe( (result: { [key: string]: string }): void => { if (result['Error']) { - this.showNotificationModal('Failed', result['Error'], 'danger'); + this.showNotificationModal('Failed', result['Error'], 'danger') } else { - this.showNotificationModal('Success', 'The project was assigned to the facility.', 'success'); - this.triggerReloadApplication(); + this.showNotificationModal('Success', 'The project was assigned to the facility.', 'success') + this.triggerReloadApplication() // this.switchApproveLocked(false); } }, (error: any): void => { - const errorMessage = error && error.error === 'locked' - ? 'Project is locked and could not be created!' - : 'Project could not be created!'; + const errorMessage = + error && error.error === 'locked' + ? 'Project is locked and could not be created!' + : 'Project could not be created!' - this.showNotificationModal('Failed', errorMessage, 'danger'); - console.log(error); - }, - ); + this.showNotificationModal('Failed', errorMessage, 'danger') + console.log(error) + } + ) } /** @@ -423,61 +423,61 @@ export class ApplicationVoActionsComponent extends AbstractBaseClass implements subscribeToBsModalRef(): void { this.subscription.add( this.bsModalRef.content.event.subscribe((result: any) => { - let action = null; + let action = null if ('action' in result) { - action = result['action']; + action = result['action'] } if ('createSimpleVM' in result) { - this.createSimpleVmProjectGroup(); + this.createSimpleVmProjectGroup() } if (action === ConfirmationActions.APPROVE_MODIFICATION) { - this.approveModificationRequest(); + this.approveModificationRequest() } if ('closed' in result) { // this.switchApproveLocked(false); } if (action === ConfirmationActions.DECLINE_MODIFICATION) { - this.declineModificationRequest(); + this.declineModificationRequest() } if (action === ConfirmationActions.DELETE_APPLICATION) { - this.deleteApplication(); + this.deleteApplication() } if (action === ConfirmationActions.DECLINE_EXTENSION) { - this.declineLifetimeExtension(); + this.declineLifetimeExtension() } if (action === ConfirmationActions.DECLINE_CREDITS) { - this.declineCreditExtension(); + this.declineCreditExtension() } if (action === ConfirmationActions.DECLINE_APPLICATION) { - this.declineApplication(); + this.declineApplication() } if (action === ConfirmationActions.APPROVE_EXTENSION) { - this.approveLifetimeExtension(); + this.approveLifetimeExtension() } if (action === ConfirmationActions.RESET_PI) { - this.resetApplicationPI(); + this.resetApplicationPI() } if (action === ConfirmationActions.APPROVE_CREDITS) { - this.approveCreditExtension(); + this.approveCreditExtension() } if (action === ConfirmationActions.APPROVE_APPLICATION) { if (this.application.project_application_openstack_project) { - this.createOpenStackProjectGroup(); + this.createOpenStackProjectGroup() } } if (action === 'adjustedModificationRequest') { - this.triggerReloadApplication(); + this.triggerReloadApplication() // this.isLoaded = false; // this.changeTabState(ApplicationTabStates.MODIFICATION_EXTENSION); } - }), - ); + }) + ) } - isCollapsed: boolean = true; - protected readonly Application_States = Application_States; - protected readonly ConfirmationActions = ConfirmationActions; - protected readonly ApplicationTabStates = ApplicationTabStates; + isCollapsed: boolean = true + protected readonly Application_States = Application_States + protected readonly ConfirmationActions = ConfirmationActions + protected readonly ApplicationTabStates = ApplicationTabStates } diff --git a/src/app/applications/application.model/application.model.ts b/src/app/applications/application.model/application.model.ts index 24496f14de..a00d2fc81d 100644 --- a/src/app/applications/application.model/application.model.ts +++ b/src/app/applications/application.model/application.model.ts @@ -1,149 +1,148 @@ -import moment from 'moment'; -import { ApplicationLifetimeExtension } from '../application_extension.model'; -import { ComputecenterComponent } from '../../projectmanagement/computecenter.component'; -import { ApplicationDissemination } from '../application-dissemination'; -import { EdamOntologyTerm } from '../edam-ontology-term'; -import { Flavor } from '../../virtualmachines/virtualmachinemodels/flavor'; -import { Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class'; -import { ApplicationModification } from '../application_modification.model'; -import { ApplicationCreditRequest } from '../application_credit_request'; -import { User } from './user.model'; -import { ProjectMemberApplication } from '../../projectmanagement/project_member_application'; - +import moment from 'moment' +import { ApplicationLifetimeExtension } from '../application_extension.model' +import { ComputecenterComponent } from '../../projectmanagement/computecenter.component' +import { ApplicationDissemination } from '../application-dissemination' +import { EdamOntologyTerm } from '../edam-ontology-term' +import { Flavor } from '../../virtualmachines/virtualmachinemodels/flavor' +import { Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class' +import { ApplicationModification } from '../application_modification.model' +import { ApplicationCreditRequest } from '../application_credit_request' +import { User } from './user.model' +import { ProjectMemberApplication } from '../../projectmanagement/project_member_application' /** * Application class. */ export class Application { - project_application_id: number | string; - project_application_report_allowed: boolean = false; - project_application_name: string; - project_application_shortname: string; - project_application_institute: string; - project_application_workgroup: string; - project_application_lifetime: number; - project_application_end_date: any; - project_application_vms_requested: number; - project_application_volume_limit: number; - project_application_volume_counter: number; - project_application_object_storage: number; - project_application_description: string; - project_application_comment: string; - project_application_date_submitted: string; - project_application_date_status_changed: string; - project_application_hash: string; - project_application_user: User; - project_application_pi: User = new User(); - project_application_statuses: number[] = []; - project_application_compute_center: ComputecenterComponent; - project_application_openstack_project: boolean; - project_application_total_gpu: number = 0; - lifetime_extension_request_id: number | string; - modification_extension_request_id: number | string; - project_application_kubernetes_access: boolean = false; - - pi_approval_notification_send: boolean; - pi_approval_notification_expired: boolean; - processing_vo_initials: string; - - project_application_pi_link: string = ''; - - DaysRunning: number; - date_end: string; - lifetime_days: number; - user_is_admin: boolean; - user_is_pi: boolean; - lifetime_reached: number; - project_lifetime_request: ApplicationLifetimeExtension; - project_modification_request: ApplicationModification; - project_credit_request: ApplicationCreditRequest = null; - project_application_perun_id: number; - project_application_total_cores: number = 0; - project_application_total_ram: number = 0; - project_application_initial_credits: number = 0; - project_application_current_credits: number = 0; - project_application_date_approved: string; - project_application_openstack_basic_introduction: boolean; - project_application_horizon2020: string; - project_application_dfg: string; - project_application_bmbf_project: string; - project_application_nfdi: string; - project_application_edam_terms: EdamOntologyTerm[] = []; - project_application_person_related_data: boolean = false; - project_application_no_personal_data: boolean = false; - project_application_nonsensitive_data: boolean = false; - project_application_sensitive_data: boolean = false; - project_application_elixir_project: string; - dissemination: ApplicationDissemination; - project_application_pi_approved: boolean; - project_application_cloud_service: boolean; - project_application_cloud_service_develop: boolean; - project_application_cloud_service_user_number: number; - flavors: Flavor[] = []; - project_application_workshop: boolean = false; - credits_allowed: boolean = false; - credits_loop_started: boolean = false; - totalModificationRequestCredits: number = 0; - totalCreditsExtensionCredits: number = 0; - totalLifetimeExtensionCredits: number = 0; - show_member_names: boolean; - allow_machines_starting: boolean = false; - project_application_member_applications: ProjectMemberApplication[]; - project_application_manager_comment: string; - project_application_testimonial_submitted: boolean; - project_application_testimonial_draft_id: number; - - migrated_simple_vm_resources: boolean = false; - - migrate_to_simple_vm: boolean = false; - - is_project_selected: boolean = false; - approved_by_vo_manager = ''; - approved_by_facility_manager = ''; + project_application_id: number | string + project_application_report_allowed: boolean = false + project_application_name: string + project_application_shortname: string + project_application_institute: string + project_application_workgroup: string + project_application_lifetime: number + project_application_end_date: any + project_application_vms_requested: number + project_application_volume_limit: number + project_application_volume_counter: number + project_application_object_storage: number + project_application_description: string + project_application_comment: string + project_application_date_submitted: string + project_application_date_status_changed: string + project_application_hash: string + project_application_user: User + project_application_pi: User = new User() + project_application_statuses: number[] = [] + project_application_compute_center: ComputecenterComponent + project_application_openstack_project: boolean + project_application_total_gpu: number = 0 + lifetime_extension_request_id: number | string + modification_extension_request_id: number | string + project_application_kubernetes_access: boolean = false + + pi_approval_notification_send: boolean + pi_approval_notification_expired: boolean + processing_vo_initials: string + + project_application_pi_link: string = '' + + DaysRunning: number + date_end: string + lifetime_days: number + user_is_admin: boolean + user_is_pi: boolean + lifetime_reached: number + project_lifetime_request: ApplicationLifetimeExtension + project_modification_request: ApplicationModification + project_credit_request: ApplicationCreditRequest = null + project_application_perun_id: number + project_application_total_cores: number = 0 + project_application_total_ram: number = 0 + project_application_initial_credits: number = 0 + project_application_current_credits: number = 0 + project_application_date_approved: string + project_application_openstack_basic_introduction: boolean + project_application_horizon2020: string + project_application_dfg: string + project_application_bmbf_project: string + project_application_nfdi: string + project_application_edam_terms: EdamOntologyTerm[] = [] + project_application_person_related_data: boolean = false + project_application_no_personal_data: boolean = false + project_application_nonsensitive_data: boolean = false + project_application_sensitive_data: boolean = false + project_application_elixir_project: string + dissemination: ApplicationDissemination + project_application_pi_approved: boolean + project_application_cloud_service: boolean + project_application_cloud_service_develop: boolean + project_application_cloud_service_user_number: number + flavors: Flavor[] = [] + project_application_workshop: boolean = false + credits_allowed: boolean = false + credits_loop_started: boolean = false + totalModificationRequestCredits: number = 0 + totalCreditsExtensionCredits: number = 0 + totalLifetimeExtensionCredits: number = 0 + show_member_names: boolean + allow_machines_starting: boolean = false + project_application_member_applications: ProjectMemberApplication[] + project_application_manager_comment: string + project_application_testimonial_submitted: boolean + project_application_testimonial_draft_id: number + + migrated_simple_vm_resources: boolean = false + + migrate_to_simple_vm: boolean = false + + is_project_selected: boolean = false + approved_by_vo_manager = '' + approved_by_facility_manager = '' constructor(aj?: Partial) { - this.dissemination = new ApplicationDissemination(null); - Object.assign(this, aj); + this.dissemination = new ApplicationDissemination(null) + Object.assign(this, aj) if (aj) { if (aj.dissemination) { - this.dissemination = new ApplicationDissemination(aj.dissemination); - this.project_application_report_allowed = this.dissemination.someAllowed(); + this.dissemination = new ApplicationDissemination(aj.dissemination) + this.project_application_report_allowed = this.dissemination.someAllowed() } - this.setDaysRunning(); - this.setDates(); + this.setDaysRunning() + this.setDates() if (aj.project_application_end_date) { - this.project_application_end_date = aj.project_application_end_date; + this.project_application_end_date = aj.project_application_end_date } if (aj.project_application_edam_terms) { this.project_application_edam_terms = aj.project_application_edam_terms.map( - (term: any): EdamOntologyTerm => new EdamOntologyTerm(null, term, null), - ); + (term: any): EdamOntologyTerm => new EdamOntologyTerm(null, term, null) + ) } - console.log(this.project_application_edam_terms); + console.log(this.project_application_edam_terms) if (aj.project_lifetime_request) { - this.project_lifetime_request = new ApplicationLifetimeExtension(aj.project_lifetime_request); - this.totalLifetimeExtensionCredits = this.calcLifetimeExtensionCredits(); + this.project_lifetime_request = new ApplicationLifetimeExtension(aj.project_lifetime_request) + this.totalLifetimeExtensionCredits = this.calcLifetimeExtensionCredits() } if (aj.project_modification_request) { - this.project_modification_request = new ApplicationModification(aj.project_modification_request); - this.totalModificationRequestCredits = this.calcTotalModificationCredits(); + this.project_modification_request = new ApplicationModification(aj.project_modification_request) + this.totalModificationRequestCredits = this.calcTotalModificationCredits() } if (aj.project_credit_request) { - this.project_credit_request = new ApplicationCreditRequest(aj.project_credit_request); - this.totalCreditsExtensionCredits = this.calcCreditsExtensionCredits(); + this.project_credit_request = new ApplicationCreditRequest(aj.project_credit_request) + this.totalCreditsExtensionCredits = this.calcCreditsExtensionCredits() } if (aj.project_application_pi_link) { - this.project_application_pi_link = aj.project_application_pi_link; + this.project_application_pi_link = aj.project_application_pi_link } if (aj.flavors) { - this.flavors = []; + this.flavors = [] for (const flavor of aj.flavors) { - this.flavors.push(new Flavor(flavor)); + this.flavors.push(new Flavor(flavor)) } } @@ -152,44 +151,44 @@ export class Application { aj.project_application_compute_center['compute_center_facility_id'], aj.project_application_compute_center['compute_center_name'], aj.project_application_compute_center['compute_center_login'], - aj.project_application_compute_center['compute_center_support_mail'], - ); + aj.project_application_compute_center['compute_center_support_mail'] + ) } if (aj.migrated_simple_vm_resources) { - this.migrated_simple_vm_resources = aj.migrated_simple_vm_resources; + this.migrated_simple_vm_resources = aj.migrated_simple_vm_resources } if (aj.migrate_to_simple_vm) { - this.migrate_to_simple_vm = aj.migrate_to_simple_vm; + this.migrate_to_simple_vm = aj.migrate_to_simple_vm } - this.project_application_initial_credits = Number(aj.project_application_initial_credits); + this.project_application_initial_credits = Number(aj.project_application_initial_credits) } } public hasSubmittedStatus(): boolean { - return this.project_application_statuses?.includes(Application_States.SUBMITTED); + return this.project_application_statuses?.includes(Application_States.SUBMITTED) } public isMigrated(): boolean { - return this.migrate_to_simple_vm || this.migrated_simple_vm_resources; + return this.migrate_to_simple_vm || this.migrated_simple_vm_resources } public hasTerminatedStatus(): boolean { - return this.project_application_statuses?.includes(Application_States.TERMINATED); + return this.project_application_statuses?.includes(Application_States.TERMINATED) } public addEdamTerm(term: EdamOntologyTerm): void { if (this.project_application_edam_terms.indexOf(term) === -1) { - this.project_application_edam_terms.push(term); + this.project_application_edam_terms.push(term) } } public removeEdamTerm(term: EdamOntologyTerm): void { - const idx: number = this.project_application_edam_terms.indexOf(term); + const idx: number = this.project_application_edam_terms.indexOf(term) if (idx !== -1) { - this.project_application_edam_terms.splice(idx, 1); + this.project_application_edam_terms.splice(idx, 1) } } @@ -197,81 +196,82 @@ export class Application { if (this.flavors) { for (const flavor of this.flavors) { if (flavor.name === flavor_to_test.name) { - return flavor.counter; + return flavor.counter } } - return 0; - } else return 0; + return 0 + } else return 0 } public isApproved(): boolean { - return this.project_application_statuses.includes(Application_States.APPROVED); + return this.project_application_statuses.includes(Application_States.APPROVED) } public setFlavorInFlavors(flavor_param: Flavor, counter: number): void { - const idx: number = this.flavors.findIndex((fl: Flavor): boolean => fl.name === flavor_param.name); + const idx: number = this.flavors.findIndex((fl: Flavor): boolean => fl.name === flavor_param.name) if (idx !== -1) { if (counter > 0) { - this.flavors[idx].counter = counter; + this.flavors[idx].counter = counter } else { - this.flavors.splice(idx, 1); + this.flavors.splice(idx, 1) } } else { if (counter > 0) { - const flavor: Flavor = flavor_param; - flavor.counter = counter; - this.flavors.push(flavor); + const flavor: Flavor = flavor_param + flavor.counter = counter + this.flavors.push(flavor) } - this.setDaysRunning(); + this.setDaysRunning() } } public calcTotalModificationCredits(): number { - if (this.project_modification_request != null) { - const total_credits: number = Number(this.project_application_initial_credits) + Number(this.project_modification_request.extra_credits); + if (this.project_modification_request !== null) { + const total_credits: number = + Number(this.project_application_initial_credits) + Number(this.project_modification_request.extra_credits) if (total_credits <= 0) { - return 0; + return 0 } else { - return total_credits; + return total_credits } } else { - return Number(this.project_application_initial_credits); + return Number(this.project_application_initial_credits) } } public calcCreditsExtensionCredits(): number { - if (this.project_credit_request != null) { + if (this.project_credit_request !== null) { return ( - Math.round(this.project_application_initial_credits * 10) / 10 - + Math.round((this.project_credit_request.extra_credits * 10) / 10) - ); + Math.round(this.project_application_initial_credits * 10) / 10 + + Math.round((this.project_credit_request.extra_credits * 10) / 10) + ) } else { - return this.project_application_initial_credits; + return this.project_application_initial_credits } } public calcLifetimeExtensionCredits(): number { - if (this.project_lifetime_request != null) { + if (this.project_lifetime_request !== null) { return ( - Math.round(this.project_application_initial_credits * 10) / 10 - + Math.round((this.project_lifetime_request.extra_credits * 10) / 10) - ); + Math.round(this.project_application_initial_credits * 10) / 10 + + Math.round((this.project_lifetime_request.extra_credits * 10) / 10) + ) } else { - return this.project_application_initial_credits; + return this.project_application_initial_credits } } public setCreditsLoopStarted(): void { - this.credits_loop_started = true; + this.credits_loop_started = true } private setDaysRunning(): void { - if (this.project_application_statuses != null) { + if (this.project_application_statuses !== null) { if (this.project_application_statuses.includes(Application_States.APPROVED)) { this.DaysRunning = Math.ceil( - Math.abs(Date.now() - new Date(this.project_application_date_approved).getTime()) / (1000 * 3600 * 24), - ); + Math.abs(Date.now() - new Date(this.project_application_date_approved).getTime()) / (1000 * 3600 * 24) + ) } } } @@ -279,15 +279,15 @@ export class Application { private setDates(): void { if (this.project_application_lifetime && this.project_application_lifetime > 0) { this.date_end = moment( - moment(this.project_application_date_approved).add(this.project_application_lifetime, 'months').toDate(), - ).format('DD.MM.YYYY'); + moment(this.project_application_date_approved).add(this.project_application_lifetime, 'months').toDate() + ).format('DD.MM.YYYY') this.lifetime_days = Math.abs( moment(moment(this.date_end, 'DD.MM.YYYY').toDate()).diff( moment(this.project_application_date_approved), - 'days', - ), - ); - this.project_application_date_approved = moment(this.project_application_date_approved).format('DD.MM.YYYY'); + 'days' + ) + ) + this.project_application_date_approved = moment(this.project_application_date_approved).format('DD.MM.YYYY') } } } diff --git a/src/app/applications/application.model/dissemination.ts b/src/app/applications/application.model/dissemination.ts index 2b4c153b16..3bb4be1336 100644 --- a/src/app/applications/application.model/dissemination.ts +++ b/src/app/applications/application.model/dissemination.ts @@ -2,20 +2,19 @@ * Dissemination class. */ export class Dissemination { - - platform_denbi: boolean = false; - platform_twitter: boolean; - information_title: string; - information_resources: boolean; - information_pi_name: boolean; - information_institution: boolean; - information_workgroup: boolean; - information_project_type: boolean; - information_lifetime: boolean; - information_description: string; - information_project_affiliation: boolean; - allowed_platforms: string[] = []; - allowed_informations: string[] = []; + platform_denbi: boolean = false + platform_twitter: boolean + information_title: string + information_resources: boolean + information_pi_name: boolean + information_institution: boolean + information_workgroup: boolean + information_project_type: boolean + information_lifetime: boolean + information_description: string + information_project_affiliation: boolean + allowed_platforms: string[] = [] + allowed_informations: string[] = [] constructor( platform_denbi: boolean, @@ -28,63 +27,62 @@ export class Dissemination { information_project_type: boolean, information_lifetime: boolean, information_project_affiliation: boolean, - information_description: string, + information_description: string ) { - - this.platform_denbi = platform_denbi; - this.platform_twitter = platform_twitter; - this.information_title = information_title; - this.information_resources = information_resources; - this.information_pi_name = information_pi_name; - this.information_institution = information_institution; - this.information_description = information_description; - this.information_workgroup = information_workgroup; - this.information_project_type = information_project_type; - this.information_lifetime = information_lifetime; - this.information_project_affiliation = information_project_affiliation; - this.setAllowedPlatforms(); - this.setAllowedInformations(); + this.platform_denbi = platform_denbi + this.platform_twitter = platform_twitter + this.information_title = information_title + this.information_resources = information_resources + this.information_pi_name = information_pi_name + this.information_institution = information_institution + this.information_description = information_description + this.information_workgroup = information_workgroup + this.information_project_type = information_project_type + this.information_lifetime = information_lifetime + this.information_project_affiliation = information_project_affiliation + this.setAllowedPlatforms() + this.setAllowedInformations() } private setAllowedPlatforms(): void { - this.allowed_platforms = []; + this.allowed_platforms = [] if (this.platform_denbi) { - this.allowed_platforms.push('de.NBI Platforms '); + this.allowed_platforms.push('de.NBI Platforms ') } if (this.platform_twitter) { - this.allowed_platforms.push('Twitter'); + this.allowed_platforms.push('Twitter') } } private setAllowedInformations(): void { - this.allowed_informations = []; + this.allowed_informations = [] if (this.information_project_affiliation) { - this.allowed_informations.push('Project affiliation'); + this.allowed_informations.push('Project affiliation') } if (this.information_institution) { - this.allowed_informations.push('Institution'); + this.allowed_informations.push('Institution') } if (this.information_workgroup) { - this.allowed_informations.push('Workgroup'); + this.allowed_informations.push('Workgroup') } if (this.information_project_type) { - this.allowed_informations.push('Project Type'); + this.allowed_informations.push('Project Type') } if (this.information_title) { - this.allowed_informations.push('Title'); + this.allowed_informations.push('Title') } if (this.information_resources) { - this.allowed_informations.push('Resources'); + this.allowed_informations.push('Resources') } if (this.information_lifetime) { - this.allowed_informations.push('Lifetime'); + this.allowed_informations.push('Lifetime') } if (this.information_pi_name) { - this.allowed_informations.push('PI Name'); + this.allowed_informations.push('PI Name') } if (this.information_description) { - this.allowed_informations.push('Description'); + this.allowed_informations.push('Description') } } } diff --git a/src/app/applications/applications-routing.module.ts b/src/app/applications/applications-routing.module.ts index c66d7dc8e6..0875285ec1 100644 --- a/src/app/applications/applications-routing.module.ts +++ b/src/app/applications/applications-routing.module.ts @@ -1,67 +1,66 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; +import { NgModule } from '@angular/core' +import { RouterModule, Routes } from '@angular/router' -import { ApplicationsComponent } from './applications.component'; +import { ApplicationsComponent } from './applications.component' -import { AddsimplevmComponent } from './application-formular/simplevm-formular/addsimplevm.component'; -import { AddcloudapplicationComponent } from './application-formular/openstack-formular/addcloudapplication.component'; -import { TypeOverviewComponent } from './type-overview.component'; -import { ValidationApplicationComponent } from '../validation-application/validation-application.component'; -import { KubernetesFormularComponent } from './application-formular/kubernetes-formular/kubernetes-formular.component'; -import { VoGuardService } from '../shared/guards/vo-guard.service'; +import { AddsimplevmComponent } from './application-formular/simplevm-formular/addsimplevm.component' +import { AddcloudapplicationComponent } from './application-formular/openstack-formular/addcloudapplication.component' +import { TypeOverviewComponent } from './type-overview.component' +import { ValidationApplicationComponent } from '../validation-application/validation-application.component' +import { KubernetesFormularComponent } from './application-formular/kubernetes-formular/kubernetes-formular.component' +import { VoGuardService } from '../shared/guards/vo-guard.service' const routes: Routes = [ { path: '', component: ApplicationsComponent, data: { - title: 'Application overview', - }, + title: 'Application overview' + } }, { path: 'newCloudApplication', component: AddcloudapplicationComponent, data: { - title: 'New OpenStack Application', - }, + title: 'New OpenStack Application' + } }, { path: 'newKubernetesApplication', component: KubernetesFormularComponent, canActivate: [VoGuardService], data: { - title: 'New Kubernetes Application', - }, + title: 'New Kubernetes Application' + } }, { path: 'newSimpleVmApplication', component: AddsimplevmComponent, data: { - title: 'New SimpleVM Application', - }, + title: 'New SimpleVM Application' + } }, { path: 'type-overview', component: TypeOverviewComponent, data: { - title: 'Project Types Overview', - }, + title: 'Project Types Overview' + } }, { path: 'validation/:hash', component: ValidationApplicationComponent, data: { - title: 'Application Validation', - }, - }, -]; + title: 'Application Validation' + } + } +] /** * Application routing module. */ @NgModule({ imports: [RouterModule.forChild(routes)], - exports: [RouterModule], + exports: [RouterModule] }) -export class ApplicationsRoutingModule { -} +export class ApplicationsRoutingModule {} diff --git a/src/app/applications/applications.component.ts b/src/app/applications/applications.component.ts index 6659018b55..26e4b118b7 100644 --- a/src/app/applications/applications.component.ts +++ b/src/app/applications/applications.component.ts @@ -1,31 +1,28 @@ -/* eslint-disable no-lonely-if */ -import { - ChangeDetectorRef, Component, OnDestroy, OnInit, inject, -} from '@angular/core'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { Subscription } from 'rxjs'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { ApplicationsService } from '../api-connector/applications.service'; -import { ApiSettings } from '../api-connector/api-settings.service'; -import { Application } from './application.model/application.model'; -import { GroupService } from '../api-connector/group.service'; -import { UserService } from '../api-connector/user.service'; -import { VoService } from '../api-connector/vo.service'; -import { FacilityService } from '../api-connector/facility.service'; -import { Flavor } from '../virtualmachines/virtualmachinemodels/flavor'; -import { FlavorService } from '../api-connector/flavor.service'; -import { Client } from '../vo_manager/clients/client.model'; -import { ApplicationBaseClassComponent } from '../shared/shared_modules/baseClass/application-base-class.component'; -import { ComputecenterComponent } from '../projectmanagement/computecenter.component'; -import { is_vo } from '../shared/globalvar'; -import { Application_States } from '../shared/shared_modules/baseClass/abstract-base-class'; -import { FlavorType } from '../virtualmachines/virtualmachinemodels/flavorType'; -import { CreditsService } from '../api-connector/credits.service'; -import { NotificationModalComponent } from '../shared/modal/notification-modal'; -import { ConfirmationActions } from '../shared/modal/confirmation_actions'; -import { ApplicationTabStates } from '../shared/enums/application-tab-states'; - -// eslint-disable-next-line no-shadow + +import { ChangeDetectorRef, Component, OnDestroy, OnInit, inject } from '@angular/core' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { Subscription } from 'rxjs' +import { MatomoTracker } from 'ngx-matomo-client' +import { ApplicationsService } from '../api-connector/applications.service' +import { ApiSettings } from '../api-connector/api-settings.service' +import { Application } from './application.model/application.model' +import { GroupService } from '../api-connector/group.service' +import { UserService } from '../api-connector/user.service' +import { VoService } from '../api-connector/vo.service' +import { FacilityService } from '../api-connector/facility.service' +import { Flavor } from '../virtualmachines/virtualmachinemodels/flavor' +import { FlavorService } from '../api-connector/flavor.service' +import { Client } from '../vo_manager/clients/client.model' +import { ApplicationBaseClassComponent } from '../shared/shared_modules/baseClass/application-base-class.component' +import { ComputecenterComponent } from '../projectmanagement/computecenter.component' +import { is_vo } from '../shared/globalvar' +import { Application_States } from '../shared/shared_modules/baseClass/abstract-base-class' +import { FlavorType } from '../virtualmachines/virtualmachinemodels/flavorType' +import { CreditsService } from '../api-connector/credits.service' +import { NotificationModalComponent } from '../shared/modal/notification-modal' +import { ConfirmationActions } from '../shared/modal/confirmation_actions' +import { ApplicationTabStates } from '../shared/enums/application-tab-states' + /** * Application Overview component. @@ -41,39 +38,39 @@ import { ApplicationTabStates } from '../shared/enums/application-tab-states'; ApplicationsService, ApiSettings, FlavorService, - CreditsService, - ], + CreditsService + ] }) export class ApplicationsComponent extends ApplicationBaseClassComponent implements OnInit, OnDestroy { - private readonly tracker = inject(MatomoTracker); - title: string = 'Application Overview'; - tab_state: number = ApplicationTabStates.SUBMITTED; - ApplicationTabStates: typeof ApplicationTabStates = ApplicationTabStates; - ConfirmationActions = ConfirmationActions; + private readonly tracker = inject(MatomoTracker) + title: string = 'Application Overview' + tab_state: number = ApplicationTabStates.SUBMITTED + ApplicationTabStates: typeof ApplicationTabStates = ApplicationTabStates + ConfirmationActions = ConfirmationActions - loading_applications: boolean = false; - bsModalRef: BsModalRef; - subscription: Subscription = new Subscription(); + loading_applications: boolean = false + bsModalRef: BsModalRef + subscription: Subscription = new Subscription() /** * All Applications, just visible for a vo admin. * * @type {Array} */ - all_applications: Application[] = []; - selectedApplication: Application; - applications_history: Application[] = []; + all_applications: Application[] = [] + selectedApplication: Application + applications_history: Application[] = [] /** * Limits information for Client tested/used for Simple Vm Project creation. */ - notificationClientInfo: Client[] = []; + notificationClientInfo: Client[] = [] - numberOfExtensionRequests: number = 0; - numberOfModificationRequests: number = 0; - numberOfCreditRequests: number = 0; - numberOfProjectApplications: number = 0; - Application_States: typeof Application_States = Application_States; + numberOfExtensionRequests: number = 0 + numberOfModificationRequests: number = 0 + numberOfCreditRequests: number = 0 + numberOfProjectApplications: number = 0 + Application_States: typeof Application_States = Application_States /** * Constructor. @@ -93,32 +90,32 @@ export class ApplicationsComponent extends ApplicationBaseClassComponent impleme private modalService: BsModalService, facilityService: FacilityService, private flavorService: FlavorService, - cdrRef: ChangeDetectorRef, + cdrRef: ChangeDetectorRef ) { - super(userService, applicationsService, facilityService, cdrRef); + super(userService, applicationsService, facilityService, cdrRef) } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } ngOnInit(): void { - this.tracker.trackPageView('Application Overview'); - this.is_vo_admin = is_vo; + this.tracker.trackPageView('Application Overview') + this.is_vo_admin = is_vo if (this.is_vo_admin) { - this.getApplicationNumbers(); + this.getApplicationNumbers() - this.getSubmittedApplicationsAdmin(); - this.getApplicationHistory(); - this.getComputeCenters(); + this.getSubmittedApplicationsAdmin() + this.getApplicationHistory() + this.getComputeCenters() this.flavorService.getListOfFlavorsAvailable(undefined, undefined, true).subscribe((flavList: Flavor[]): void => { - this.flavorList = flavList; - }); + this.flavorList = flavList + }) this.flavorService.getListOfTypesAvailable().subscribe((availableTypes: FlavorType[]): void => { - this.typeList = availableTypes; - }); + this.typeList = availableTypes + }) } else { - this.isLoaded = true; + this.isLoaded = true } } @@ -126,19 +123,19 @@ export class ApplicationsComponent extends ApplicationBaseClassComponent impleme * Getting the current numbers of all Application-Request types from the API */ getApplicationNumbers(): void { - console.log('rload numbers 3'); + console.log('rload numbers 3') this.applicationsService.getExtensionRequestsCounter().subscribe((result: any): void => { - this.numberOfCreditRequests = result['credits_extension_requests_all']; - this.numberOfExtensionRequests = result['lifetime_extension_requests_all']; - this.numberOfModificationRequests = result['modification_requests_all']; - this.numberOfProjectApplications = result['applications_submitted_vo']; - }); + this.numberOfCreditRequests = result['credits_extension_requests_all'] + this.numberOfExtensionRequests = result['lifetime_extension_requests_all'] + this.numberOfModificationRequests = result['modification_requests_all'] + this.numberOfProjectApplications = result['applications_submitted_vo'] + }) } changeTabState(state: number): void { if (!this.loading_applications) { - this.tab_state = state; - this.getApplicationsByTabState(); + this.tab_state = state + this.getApplicationsByTabState() } } @@ -152,39 +149,39 @@ export class ApplicationsComponent extends ApplicationBaseClassComponent impleme this.groupservice .getFacilityByGroup(app.project_application_perun_id.toString()) .subscribe((res: object): void => { - const login: string = res['Login']; - const suport: string = res['Support']; - const facilityname: string = res['Facility']; - const facilityId: number = res['FacilityId']; + const login: string = res['Login'] + const suport: string = res['Support'] + const facilityname: string = res['Facility'] + const facilityId: number = res['FacilityId'] if (facilityId) { - // eslint-disable-next-line no-param-reassign + app.project_application_compute_center = new ComputecenterComponent( facilityId.toString(), facilityname, login, - suport, - ); + suport + ) } - }); + }) } } setApplicationByLoadedApplication(applications: Application[]) { - this.all_applications = []; + this.all_applications = [] if (applications.length === 0) { - this.isLoaded_userApplication = true; + this.isLoaded_userApplication = true } for (const application of applications) { - const newApplication = new Application(application); + const newApplication = new Application(application) - this.all_applications.push(newApplication); + this.all_applications.push(newApplication) } - this.isLoaded = true; + this.isLoaded = true for (const app of this.all_applications) { - this.getFacilityProject(app); + this.getFacilityProject(app) } - this.sortApplicationsByTabState(); - this.loading_applications = false; + this.sortApplicationsByTabState() + this.loading_applications = false } /** @@ -193,8 +190,8 @@ export class ApplicationsComponent extends ApplicationBaseClassComponent impleme getSubmittedApplicationsAdmin(): void { if (this.is_vo_admin) { this.applicationsService.getSubmittedApplications().subscribe((applications: Application[]): void => { - this.setApplicationByLoadedApplication(applications); - }); + this.setApplicationByLoadedApplication(applications) + }) } } @@ -202,17 +199,17 @@ export class ApplicationsComponent extends ApplicationBaseClassComponent impleme this.applicationsService.getAllApplications().subscribe((applications: Application[]): void => { if (applications.length > 0) { for (const application of applications) { - this.applications_history.push(application); + this.applications_history.push(application) } } - }); + }) } /** * Emptying all application lists, so applications don't get pushed to the lists multiple times. */ clearApplicationLists(): void { - this.all_applications = []; + this.all_applications = [] } /** @@ -222,41 +219,45 @@ export class ApplicationsComponent extends ApplicationBaseClassComponent impleme switch (this.tab_state) { case ApplicationTabStates.SUBMITTED: this.all_applications.sort( - (a, b) => new Date(a.project_application_date_submitted).getTime() - - new Date(b.project_application_date_submitted).getTime(), - ); - break; + (a, b) => + new Date(a.project_application_date_submitted).getTime() - + new Date(b.project_application_date_submitted).getTime() + ) + break case ApplicationTabStates.LIFETIME_EXTENSION: this.all_applications.sort( - (a, b) => new Date(a.project_lifetime_request.date_submitted).getTime() - - new Date(b.project_lifetime_request.date_submitted).getTime(), - ); - break; + (a, b) => + new Date(a.project_lifetime_request.date_submitted).getTime() - + new Date(b.project_lifetime_request.date_submitted).getTime() + ) + break case ApplicationTabStates.MODIFICATION_EXTENSION: this.all_applications.sort( - (a, b) => new Date(a.project_modification_request.date_submitted).getTime() - - new Date(b.project_modification_request.date_submitted).getTime(), - ); - break; + (a, b) => + new Date(a.project_modification_request.date_submitted).getTime() - + new Date(b.project_modification_request.date_submitted).getTime() + ) + break case ApplicationTabStates.CREDITS_EXTENSION: this.all_applications.sort( - (a, b) => new Date(a.project_credit_request.date_submitted).getTime() - - new Date(b.project_credit_request.date_submitted).getTime(), - ); - break; + (a, b) => + new Date(a.project_credit_request.date_submitted).getTime() - + new Date(b.project_credit_request.date_submitted).getTime() + ) + break default: - break; + break } } getSubmittedApplications(): void { this.applicationsService.getSubmittedApplications().subscribe((applications: Application[]): void => { - this.setApplicationByLoadedApplication(applications); - }); + this.setApplicationByLoadedApplication(applications) + }) } getCreditsExtensionRequests(): void { @@ -265,69 +266,69 @@ export class ApplicationsComponent extends ApplicationBaseClassComponent impleme // bool here? } for (const credit_application of credit_applications) { - this.all_applications.push(new Application(credit_application)); + this.all_applications.push(new Application(credit_application)) } for (const app of this.all_applications) { - this.getFacilityProject(app); + this.getFacilityProject(app) } - this.sortApplicationsByTabState(); + this.sortApplicationsByTabState() - this.isLoaded = true; - this.loading_applications = false; - }); + this.isLoaded = true + this.loading_applications = false + }) } getLifetimeExtensionRequests(): void { this.applicationsService .getLifetimeRequestedApplications() .subscribe((lifetime_applications: Application[]): void => { - this.setApplicationByLoadedApplication(lifetime_applications); - }); + this.setApplicationByLoadedApplication(lifetime_applications) + }) } getModificationRequests(): void { this.applicationsService .getModificationRequestedApplications() .subscribe((modification_applications: Application[]): void => { - this.setApplicationByLoadedApplication(modification_applications); - }); + this.setApplicationByLoadedApplication(modification_applications) + }) } getApplicationsByTabState(): void { - this.loading_applications = true; + this.loading_applications = true if (this.is_vo_admin) { - this.clearApplicationLists(); + this.clearApplicationLists() if (this.tab_state === ApplicationTabStates.SUBMITTED) { - this.getSubmittedApplications(); + this.getSubmittedApplications() } else if (this.tab_state === ApplicationTabStates.CREDITS_EXTENSION) { - this.getCreditsExtensionRequests(); + this.getCreditsExtensionRequests() } else if (this.tab_state === ApplicationTabStates.LIFETIME_EXTENSION) { - this.getLifetimeExtensionRequests(); + this.getLifetimeExtensionRequests() } else if (this.tab_state === ApplicationTabStates.MODIFICATION_EXTENSION) { - this.getModificationRequests(); + this.getModificationRequests() } } } public resetNotificationModal(): void { - this.notificationModalTitle = 'Notification'; - this.notificationModalMessage = 'Please wait...'; - this.notificationModalIsClosable = false; - this.notificationModalType = 'info'; - this.notificationClientInfo = []; + this.notificationModalTitle = 'Notification' + this.notificationModalMessage = 'Please wait...' + this.notificationModalIsClosable = false + this.notificationModalType = 'info' + this.notificationClientInfo = [] } showNotificationModal( notificationModalTitle: string, notificationModalMessage: string, - notificationModalType: string, + notificationModalType: string ) { - const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage }; + const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage } if (this.bsModalRef) { - this.bsModalRef.hide(); + this.bsModalRef.hide() } - this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); + this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') } } diff --git a/src/app/applications/applications.module.ts b/src/app/applications/applications.module.ts index 9afd81662e..884d868919 100644 --- a/src/app/applications/applications.module.ts +++ b/src/app/applications/applications.module.ts @@ -1,38 +1,38 @@ -import { NgModule } from '@angular/core'; +import { NgModule } from '@angular/core' -import { TabsModule } from 'ngx-bootstrap/tabs'; -import { AccordionModule } from 'ngx-bootstrap/accordion'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { ModalModule } from 'ngx-bootstrap/modal'; -import { NgSelectModule } from '@ng-select/ng-select'; -import { BadgeModule, TableDirective } from '@coreui/angular'; -import { TooltipModule } from 'ngx-bootstrap/tooltip'; -import { ApplicationsComponent } from './applications.component'; -import { ApplicationsRoutingModule } from './applications-routing.module'; -import { AddsimplevmComponent } from './application-formular/simplevm-formular/addsimplevm.component'; -import { AddcloudapplicationComponent } from './application-formular/openstack-formular/addcloudapplication.component'; -import { TypeOverviewComponent } from './type-overview.component'; -import { ValidationApplicationComponent } from '../validation-application/validation-application.component'; -import { ApplicationDetailComponent } from './application-detail/application-detail.component'; -import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module'; -import { ApplicationFormularComponent } from './application-formular/application-formular.component'; -import { PipeModuleModule } from '../pipe-module/pipe-module.module'; -import { ApplicationPiDetailComponent } from './application-detail/application-pi-detail/application-pi-detail.component'; -import { InformationDetailComponent } from './application-detail/information-detail/information-detail.component'; -import { AdjustmentDetailComponent } from './application-detail/adjustment-detail/adjustment-detail.component'; -import { ResourceDetailComponent } from './application-detail/resource-detail/resource-detail.component'; -import { ModificationDetailComponent } from './application-detail/modification-detail/modification-detail.component'; -import { CreditsExtensionDetailComponent } from './application-detail/credits-extension-detail/credits-extension-detail.component'; -import { LifetimeExtensionDetailComponent } from './application-detail/lifetime-extension-detail/lifetime-extension-detail.component'; -import { NewsModule } from '../news/news.module'; -import { SharedModuleModule } from '../shared/shared_modules/shared-module.module'; -import { KubernetesFormularComponent } from './application-formular/kubernetes-formular/kubernetes-formular.component'; +import { TabsModule } from 'ngx-bootstrap/tabs' +import { AccordionModule } from 'ngx-bootstrap/accordion' +import { CommonModule } from '@angular/common' +import { FormsModule } from '@angular/forms' +import { ModalModule } from 'ngx-bootstrap/modal' +import { NgSelectModule } from '@ng-select/ng-select' +import { BadgeModule, TableDirective } from '@coreui/angular' +import { TooltipModule } from 'ngx-bootstrap/tooltip' +import { ApplicationsComponent } from './applications.component' +import { ApplicationsRoutingModule } from './applications-routing.module' +import { AddsimplevmComponent } from './application-formular/simplevm-formular/addsimplevm.component' +import { AddcloudapplicationComponent } from './application-formular/openstack-formular/addcloudapplication.component' +import { TypeOverviewComponent } from './type-overview.component' +import { ValidationApplicationComponent } from '../validation-application/validation-application.component' +import { ApplicationDetailComponent } from './application-detail/application-detail.component' +import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module' +import { ApplicationFormularComponent } from './application-formular/application-formular.component' +import { PipeModuleModule } from '../pipe-module/pipe-module.module' +import { ApplicationPiDetailComponent } from './application-detail/application-pi-detail/application-pi-detail.component' +import { InformationDetailComponent } from './application-detail/information-detail/information-detail.component' +import { AdjustmentDetailComponent } from './application-detail/adjustment-detail/adjustment-detail.component' +import { ResourceDetailComponent } from './application-detail/resource-detail/resource-detail.component' +import { ModificationDetailComponent } from './application-detail/modification-detail/modification-detail.component' +import { CreditsExtensionDetailComponent } from './application-detail/credits-extension-detail/credits-extension-detail.component' +import { LifetimeExtensionDetailComponent } from './application-detail/lifetime-extension-detail/lifetime-extension-detail.component' +import { NewsModule } from '../news/news.module' +import { SharedModuleModule } from '../shared/shared_modules/shared-module.module' +import { KubernetesFormularComponent } from './application-formular/kubernetes-formular/kubernetes-formular.component' -import { ApplicationListComponent } from './application-list/application-list.component'; -import { ApplicationCardComponent } from './application-card/application-card.component'; -import { ApplicationVoActionsComponent } from './application-vo-actions/application-vo-actions.component'; -import { ApplicationFacilityActionsComponent } from './application-facility-actions/application-facility-actions.component'; +import { ApplicationListComponent } from './application-list/application-list.component' +import { ApplicationCardComponent } from './application-card/application-card.component' +import { ApplicationVoActionsComponent } from './application-vo-actions/application-vo-actions.component' +import { ApplicationFacilityActionsComponent } from './application-facility-actions/application-facility-actions.component' /** * Applications Module. @@ -52,7 +52,7 @@ import { ApplicationFacilityActionsComponent } from './application-facility-acti BadgeModule, SharedModuleModule, TableDirective, - TooltipModule, + TooltipModule ], declarations: [ ApplicationsComponent, @@ -73,8 +73,8 @@ import { ApplicationFacilityActionsComponent } from './application-facility-acti ApplicationListComponent, ApplicationCardComponent, ApplicationVoActionsComponent, - ApplicationFacilityActionsComponent, + ApplicationFacilityActionsComponent ], - exports: [ApplicationDetailComponent, ApplicationListComponent], + exports: [ApplicationDetailComponent, ApplicationListComponent] }) export class ApplicationsModule {} diff --git a/src/app/applications/numberValidations.directive.ts b/src/app/applications/numberValidations.directive.ts index 0cb4ae5560..8c076a0dd7 100644 --- a/src/app/applications/numberValidations.directive.ts +++ b/src/app/applications/numberValidations.directive.ts @@ -1,23 +1,19 @@ -// eslint-disable-next-line max-classes-per-file -import { Directive, Input } from '@angular/core'; -import { - AbstractControl, NG_VALIDATORS, Validator, ValidatorFn, -} from '@angular/forms'; + +import { Directive, Input } from '@angular/core' +import { AbstractControl, NG_VALIDATORS, Validator, ValidatorFn } from '@angular/forms' /** * Number validation directive. */ @Directive({ selector: '[appMinAmount]', - providers: [ - { provide: NG_VALIDATORS, useExisting: MinAmoutValidatorDirective, multi: true }, - ], + providers: [{ provide: NG_VALIDATORS, useExisting: MinAmoutValidatorDirective, multi: true }] }) export class MinAmoutValidatorDirective implements Validator { - @Input('appMinAmount') minAmount: number; + @Input('appMinAmount') minAmount: number validate(control: AbstractControl): { [key: string]: any } | null { - return this.minAmount ? minAmountValidator(this.minAmount)(control) : null; + return this.minAmount ? minAmountValidator(this.minAmount)(control) : null } } @@ -27,10 +23,10 @@ export class MinAmoutValidatorDirective implements Validator { */ export function minAmountValidator(val: number): ValidatorFn { return (control: AbstractControl): { [key: string]: any } | null => { - const less: boolean = control.value < val; + const less: boolean = control.value < val - return less ? { minVal: { value: control.value } } : null; - }; + return less ? { minVal: { value: control.value } } : null + } } /** @@ -38,15 +34,13 @@ export function minAmountValidator(val: number): ValidatorFn { */ @Directive({ selector: '[appMaxAmount]', - providers: [ - { provide: NG_VALIDATORS, useExisting: MaxAmoutValidatorDirective, multi: true }, - ], + providers: [{ provide: NG_VALIDATORS, useExisting: MaxAmoutValidatorDirective, multi: true }] }) export class MaxAmoutValidatorDirective implements Validator { - @Input('appMaxAmount') maxAmount: number; + @Input('appMaxAmount') maxAmount: number validate(control: AbstractControl): { [key: string]: any } | null { - return this.maxAmount ? maxAmountValidator(this.maxAmount)(control) : null; + return this.maxAmount ? maxAmountValidator(this.maxAmount)(control) : null } } @@ -56,10 +50,10 @@ export class MaxAmoutValidatorDirective implements Validator { */ export function maxAmountValidator(val: number): ValidatorFn { return (control: AbstractControl): { [key: string]: any } | null => { - const more: boolean = control.value > val; + const more: boolean = control.value > val - return more ? { maxVal: { value: control.value } } : null; - }; + return more ? { maxVal: { value: control.value } } : null + } } /** @@ -67,13 +61,11 @@ export function maxAmountValidator(val: number): ValidatorFn { */ @Directive({ selector: '[appInteger]', - providers: [ - { provide: NG_VALIDATORS, useExisting: IntegerValidatorDirective, multi: true }, - ], + providers: [{ provide: NG_VALIDATORS, useExisting: IntegerValidatorDirective, multi: true }] }) export class IntegerValidatorDirective implements Validator { validate(control: AbstractControl): { [key: string]: any } | null { - return integerValidator()(control); + return integerValidator()(control) } } @@ -82,10 +74,10 @@ export class IntegerValidatorDirective implements Validator { */ export function integerValidator(): ValidatorFn { return (control: AbstractControl): { [key: string]: any } | null => { - const integer: boolean = Number.isInteger(control.value); + const integer: boolean = Number.isInteger(control.value) - return integer ? null : { integer: { value: control.value } }; - }; + return integer ? null : { integer: { value: control.value } } + } } /** @@ -93,10 +85,11 @@ export function integerValidator(): ValidatorFn { */ export function floatValidator(): ValidatorFn { return (control: AbstractControl): { [key: string]: any } | null => { - const float: boolean = Number.isInteger(control.value) || (Number(control.value) === control.value && control.value % 1 !== 0); + const float: boolean = + Number.isInteger(control.value) || (Number(control.value) === control.value && control.value % 1 !== 0) - return float ? null : { float: { value: control.value } }; - }; + return float ? null : { float: { value: control.value } } + } } /** @@ -104,11 +97,12 @@ export function floatValidator(): ValidatorFn { */ export function floatOrNullValidator(): ValidatorFn { return (control: AbstractControl): { [key: string]: any } | null => { - const float: boolean = ((Number.isInteger(control.value) || Number(control.value) === control.value) - && control.value % 1 !== 0) || !control.value; + const float: boolean = + ((Number.isInteger(control.value) || Number(control.value) === control.value) && control.value % 1 !== 0) || + !control.value - return float ? null : { floatOrNulL: { value: control.value } }; - }; + return float ? null : { floatOrNulL: { value: control.value } } + } } /** @@ -116,13 +110,11 @@ export function floatOrNullValidator(): ValidatorFn { */ @Directive({ selector: '[appFloat]', - providers: [ - { provide: NG_VALIDATORS, useExisting: FloatValidatorDirective, multi: true }, - ], + providers: [{ provide: NG_VALIDATORS, useExisting: FloatValidatorDirective, multi: true }] }) export class FloatValidatorDirective implements Validator { validate(control: AbstractControl): { [key: string]: any } | null { - return floatValidator()(control); + return floatValidator()(control) } } @@ -131,13 +123,11 @@ export class FloatValidatorDirective implements Validator { */ @Directive({ selector: '[appFloatOrNull]', - providers: [ - { provide: NG_VALIDATORS, useExisting: FloatOrNullValidatorDirective, multi: true }, - ], + providers: [{ provide: NG_VALIDATORS, useExisting: FloatOrNullValidatorDirective, multi: true }] }) export class FloatOrNullValidatorDirective implements Validator { validate(control: AbstractControl): { [key: string]: any } | null { - return floatOrNullValidator()(control); + return floatOrNullValidator()(control) } } @@ -146,13 +136,11 @@ export class FloatOrNullValidatorDirective implements Validator { */ @Directive({ selector: '[appIntegerOrNull]', - providers: [ - { provide: NG_VALIDATORS, useExisting: IntegerOrNullValidatorDirective, multi: true }, - ], + providers: [{ provide: NG_VALIDATORS, useExisting: IntegerOrNullValidatorDirective, multi: true }] }) export class IntegerOrNullValidatorDirective implements Validator { validate(control: AbstractControl): { [key: string]: any } | null { - return integerOrNullValidator()(control); + return integerOrNullValidator()(control) } } @@ -161,8 +149,8 @@ export class IntegerOrNullValidatorDirective implements Validator { */ export function integerOrNullValidator(): ValidatorFn { return (control: AbstractControl): { [key: string]: any } | null => { - const integer: boolean = (Number.isInteger(control.value) || !control.value); + const integer: boolean = Number.isInteger(control.value) || !control.value - return integer ? null : { integerOrNull: { value: control.value } }; - }; + return integer ? null : { integerOrNull: { value: control.value } } + } } diff --git a/src/app/applications/type-overview.component.ts b/src/app/applications/type-overview.component.ts index e0d8d0d2b1..431a14d968 100644 --- a/src/app/applications/type-overview.component.ts +++ b/src/app/applications/type-overview.component.ts @@ -1,9 +1,7 @@ -import { Component, OnInit, inject } from '@angular/core'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { - WIKI_WORKSHOPS, OPENSTACK_LINK, PROJECT_TYPES_LINK, SIMPLE_VM_LINK, -} from '../../links/links'; -import { is_vo } from '../shared/globalvar'; +import { Component, OnInit, inject } from '@angular/core' +import { MatomoTracker } from 'ngx-matomo-client' +import { WIKI_WORKSHOPS, OPENSTACK_LINK, PROJECT_TYPES_LINK, SIMPLE_VM_LINK } from '../../links/links' +import { is_vo } from '../shared/globalvar' /** * The type overview of the different project classes. @@ -11,49 +9,49 @@ import { is_vo } from '../shared/globalvar'; @Component({ selector: 'app-type-overview', templateUrl: './type-overview.component.html', - styleUrls: ['./type-overview.component.css'], + styleUrls: ['./type-overview.component.css'] }) export class TypeOverviewComponent implements OnInit { - private readonly tracker = inject(MatomoTracker); + private readonly tracker = inject(MatomoTracker) - title: string = 'Project Type Overview'; - openstack_color: string = '#ed1944'; - simplevm_color: string = '#00adef'; - kubernetes_color: string = '#326ce5'; - is_vo_admin: boolean = is_vo; + title: string = 'Project Type Overview' + openstack_color: string = '#ed1944' + simplevm_color: string = '#00adef' + kubernetes_color: string = '#326ce5' + is_vo_admin: boolean = is_vo - simpleVM_logo_link: string; - simpleVM_ease_logo: string; - simpleVM_curve_logo: string; - simpleVM_remote_logo: string; + simpleVM_logo_link: string + simpleVM_ease_logo: string + simpleVM_curve_logo: string + simpleVM_remote_logo: string - kubernetes_logo_link: string; - kubernetes_logo_border: string; + kubernetes_logo_link: string + kubernetes_logo_border: string - openstack_logo_link: string; - openstack_api_logo: string; - openstack_conf_logo: string; - openstack_scale_logo: string; - static_img_folder: string = 'static/webapp/assets/img/'; + openstack_logo_link: string + openstack_api_logo: string + openstack_conf_logo: string + openstack_scale_logo: string + static_img_folder: string = 'static/webapp/assets/img/' - WIKI_WORKSHOPS: string = WIKI_WORKSHOPS; - SIMPLE_VM_LINK: string = SIMPLE_VM_LINK; - PROJECT_TYPES_LINK: string = PROJECT_TYPES_LINK; - OPENSTACK_LINK: string = OPENSTACK_LINK; + WIKI_WORKSHOPS: string = WIKI_WORKSHOPS + SIMPLE_VM_LINK: string = SIMPLE_VM_LINK + PROJECT_TYPES_LINK: string = PROJECT_TYPES_LINK + OPENSTACK_LINK: string = OPENSTACK_LINK ngOnInit(): any { - this.tracker.trackPageView('New Project - Project Type Overview'); - this.simpleVM_logo_link = `${this.static_img_folder}simpleVM_Logo.svg`; - this.simpleVM_curve_logo = `${this.static_img_folder}/simplevm-info-page/flatlearning.svg`; - this.simpleVM_ease_logo = `${this.static_img_folder}/simplevm-info-page/easytouse.svg`; - this.simpleVM_remote_logo = `${this.static_img_folder}/simplevm-info-page/remote.svg`; - - this.kubernetes_logo_link = `${this.static_img_folder}kubernetes_logo.svg`; - this.kubernetes_logo_border = `${this.static_img_folder}kubernetes_logo_border.svg`; - - this.openstack_logo_link = `${this.static_img_folder}openstack_plain_red.svg`; - this.openstack_api_logo = `${this.static_img_folder}/openstack-info-page/api.svg`; - this.openstack_conf_logo = `${this.static_img_folder}/openstack-info-page/configuration.svg`; - this.openstack_scale_logo = `${this.static_img_folder}/openstack-info-page/scale.svg`; + this.tracker.trackPageView('New Project - Project Type Overview') + this.simpleVM_logo_link = `${this.static_img_folder}simpleVM_Logo.svg` + this.simpleVM_curve_logo = `${this.static_img_folder}/simplevm-info-page/flatlearning.svg` + this.simpleVM_ease_logo = `${this.static_img_folder}/simplevm-info-page/easytouse.svg` + this.simpleVM_remote_logo = `${this.static_img_folder}/simplevm-info-page/remote.svg` + + this.kubernetes_logo_link = `${this.static_img_folder}kubernetes_logo.svg` + this.kubernetes_logo_border = `${this.static_img_folder}kubernetes_logo_border.svg` + + this.openstack_logo_link = `${this.static_img_folder}openstack_plain_red.svg` + this.openstack_api_logo = `${this.static_img_folder}/openstack-info-page/api.svg` + this.openstack_conf_logo = `${this.static_img_folder}/openstack-info-page/configuration.svg` + this.openstack_scale_logo = `${this.static_img_folder}/openstack-info-page/scale.svg` } } diff --git a/src/app/consent-info.component.ts b/src/app/consent-info.component.ts index c2c1cced4a..11e46e4878 100644 --- a/src/app/consent-info.component.ts +++ b/src/app/consent-info.component.ts @@ -1,14 +1,13 @@ -import { Component } from '@angular/core'; -import { environment } from '../environments/environment'; +import { Component } from '@angular/core' +import { environment } from '../environments/environment' /** * Consent info component. */ @Component({ selector: 'app-consent-info', - templateUrl: 'consent-info.component.html', - + templateUrl: 'consent-info.component.html' }) export class ConsentInfoComponent { - voLoginLink: string = environment.login; + voLoginLink: string = environment.login } diff --git a/src/app/credits-calculator/credits-calculator.component.ts b/src/app/credits-calculator/credits-calculator.component.ts index e3f994f75d..5d238b22a4 100644 --- a/src/app/credits-calculator/credits-calculator.component.ts +++ b/src/app/credits-calculator/credits-calculator.component.ts @@ -1,122 +1,122 @@ -import { Component, OnInit, inject } from '@angular/core'; -import { UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { FacilityService } from '../api-connector/facility.service'; -import { FlavorService } from '../api-connector/flavor.service'; -import { Flavor } from '../virtualmachines/virtualmachinemodels/flavor'; -import { FlavorType } from '../virtualmachines/virtualmachinemodels/flavorType'; -import { CreditsService } from '../api-connector/credits.service'; -import { integerValidator, minAmountValidator } from '../applications/numberValidations.directive'; -import { CREDITS_WIKI, CLOUD_PORTAL_SUPPORT_MAIL } from '../../links/links'; -import { GroupService } from '../api-connector/group.service'; -import { ProjectEnumeration } from '../projectmanagement/project-enumeration'; -import { Application_States } from '../shared/shared_modules/baseClass/abstract-base-class'; -import { ResourceWeight } from './resource-weights.model/resource-weights.model'; +import { Component, OnInit, inject } from '@angular/core' +import { UntypedFormControl, UntypedFormGroup } from '@angular/forms' +import { MatomoTracker } from 'ngx-matomo-client' +import { FacilityService } from '../api-connector/facility.service' +import { FlavorService } from '../api-connector/flavor.service' +import { Flavor } from '../virtualmachines/virtualmachinemodels/flavor' +import { FlavorType } from '../virtualmachines/virtualmachinemodels/flavorType' +import { CreditsService } from '../api-connector/credits.service' +import { integerValidator, minAmountValidator } from '../applications/numberValidations.directive' +import { CREDITS_WIKI, CLOUD_PORTAL_SUPPORT_MAIL } from '../../links/links' +import { GroupService } from '../api-connector/group.service' +import { ProjectEnumeration } from '../projectmanagement/project-enumeration' +import { Application_States } from '../shared/shared_modules/baseClass/abstract-base-class' +import { ResourceWeight } from './resource-weights.model/resource-weights.model' @Component({ selector: 'app-credits-calculator', templateUrl: './credits-calculator.component.html', styleUrls: ['./credits-calculator.component.scss'], - providers: [FacilityService, FlavorService, CreditsService, GroupService], + providers: [FacilityService, FlavorService, CreditsService, GroupService] }) export class CreditsCalculatorComponent implements OnInit { - private readonly tracker = inject(MatomoTracker); - title: string = 'Credits Calculator'; - got_all_cc: boolean = false; - got_all_flavor: boolean = false; - selected_facility: [string, number]; - all_facilities: [string, number][] = []; - flavor_types: FlavorType[] = []; - all_flavors: Flavor[] = []; - shown_flavors: { [name: string]: Flavor[] } = {}; - chosen_flavors: [string, number][] = []; - weights_open: boolean = false; - resource_weights: ResourceWeight[] = []; - - credits_needed: number = 0; - hours_possible: number = 0; - - total_cost_per_hour_needed: number = 0; - total_cost_per_hour_time: number = 0; - - CREDITS_WIKI: string = CREDITS_WIKI; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; + private readonly tracker = inject(MatomoTracker) + title: string = 'Credits Calculator' + got_all_cc: boolean = false + got_all_flavor: boolean = false + selected_facility: [string, number] + all_facilities: [string, number][] = [] + flavor_types: FlavorType[] = [] + all_flavors: Flavor[] = [] + shown_flavors: { [name: string]: Flavor[] } = {} + chosen_flavors: [string, number][] = [] + weights_open: boolean = false + resource_weights: ResourceWeight[] = [] + + credits_needed: number = 0 + hours_possible: number = 0 + + total_cost_per_hour_needed: number = 0 + total_cost_per_hour_time: number = 0 + + CREDITS_WIKI: string = CREDITS_WIKI + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL timestamp_group: UntypedFormGroup = new UntypedFormGroup({ - date_picker: new UntypedFormControl(new Date()), - }); + date_picker: new UntypedFormControl(new Date()) + }) credits_wanted_group: UntypedFormGroup = new UntypedFormGroup({ - credits_wanted_form: new UntypedFormControl(1, [integerValidator, minAmountValidator(1)]), - }); + credits_wanted_form: new UntypedFormControl(1, [integerValidator, minAmountValidator(1)]) + }) hours_wanted_group: UntypedFormGroup = new UntypedFormGroup({ - hours_wanted_form: new UntypedFormControl(1, [integerValidator, minAmountValidator(1)]), - }); + hours_wanted_form: new UntypedFormControl(1, [integerValidator, minAmountValidator(1)]) + }) constructor( private facility_service: FacilityService, private flavor_service: FlavorService, private credits_service: CreditsService, - private group_service: GroupService, + private group_service: GroupService ) { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { - this.tracker.trackPageView('Credits Calculator'); + this.tracker.trackPageView('Credits Calculator') this.flavor_service.getListOfTypesAvailable().subscribe((result: FlavorType[]) => { - this.flavor_types = result; - }); - this.all_facilities.push(['Default', null]); - this.get_facilities(); - this.get_weights(); + this.flavor_types = result + }) + this.all_facilities.push(['Default', null]) + this.get_facilities() + this.get_weights() } get_facilities(): void { - const facilities: number[] = []; + const facilities: number[] = [] this.group_service.getGroupsEnumeration().subscribe( (result: ProjectEnumeration[]): void => { result.forEach((enumeration: ProjectEnumeration): void => { if (enumeration.project_application_statuses.includes(Application_States.APPROVED)) { if (!facilities.includes(enumeration.compute_center_id)) { - this.all_facilities.push([enumeration.compute_center_name, enumeration.compute_center_id]); - facilities.push(enumeration.compute_center_id); + this.all_facilities.push([enumeration.compute_center_name, enumeration.compute_center_id]) + facilities.push(enumeration.compute_center_id) } } - }); - this.selected_facility = this.all_facilities[0]; - this.got_all_cc = true; - this.reload_data(); + }) + this.selected_facility = this.all_facilities[0] + this.got_all_cc = true + this.reload_data() }, (error: any): void => { - console.log(error); - }, - ); + console.log(error) + } + ) } get_weights(): void { this.credits_service.getCreditsWeights().subscribe((weights: ResourceWeight[]) => { - this.resource_weights = weights; - this.resource_weights.sort((a, b) => (a.resource_set_timestamp < b.resource_set_timestamp ? -1 : 1)); - const len: number = this.resource_weights.length; + this.resource_weights = weights + this.resource_weights.sort((a, b) => (a.resource_set_timestamp < b.resource_set_timestamp ? -1 : 1)) + const len: number = this.resource_weights.length for (let i = 0; i < len; i += 1) { if (this.calculate_timestamp() <= this.resource_weights[i].resource_set_timestamp || i + 1 === len) { - this.resource_weights[i].set_used(); - break; + this.resource_weights[i].set_used() + break } } - }); + }) } reset_used(): void { - const len: number = this.resource_weights.length; + const len: number = this.resource_weights.length for (let i = len - 1; i >= 0; i -= 1) { - this.resource_weights[i].set_unused(); + this.resource_weights[i].set_unused() if (this.calculate_timestamp() >= this.resource_weights[i].resource_set_timestamp || i === 0) { - this.resource_weights[i].set_used(); - this.set_rest_unused(i - 1); - break; + this.resource_weights[i].set_used() + this.set_rest_unused(i - 1) + break } } } @@ -124,77 +124,77 @@ export class CreditsCalculatorComponent implements OnInit { set_rest_unused(start: number): void { if (start >= 0) { for (let i = start; i >= 0; i -= 1) { - this.resource_weights[i].set_unused(); + this.resource_weights[i].set_unused() } } } reload_data(): void { - this.got_all_flavor = false; - this.reset_data(); + this.got_all_flavor = false + this.reset_data() this.flavor_service.getAllFlavors().subscribe( (result: any) => { - this.all_flavors = result; + this.all_flavors = result for (const flavor of this.all_flavors) { if ( - flavor.type.long_name in this.shown_flavors - && flavor['public'] !== false - && flavor['default'] !== false + flavor.type.long_name in this.shown_flavors && + flavor['public'] !== false && + flavor['default'] !== false ) { - this.shown_flavors[flavor.type.long_name].push(flavor); + this.shown_flavors[flavor.type.long_name].push(flavor) } } - this.filter_flavors_by_facility(); - this.sort_by_cph(); - this.got_all_flavor = true; + this.filter_flavors_by_facility() + this.sort_by_cph() + this.got_all_flavor = true }, (error: any) => { - console.log(error); - }, - ); + console.log(error) + } + ) } reset_data(): void { - this.all_flavors = []; + this.all_flavors = [] for (const flavor_type of this.flavor_types) { - this.shown_flavors[flavor_type.long_name] = []; + this.shown_flavors[flavor_type.long_name] = [] } - this.chosen_flavors = []; - this.credits_wanted_group.get('credits_wanted_form').setValue(1); - this.hours_wanted_group.get('hours_wanted_form').setValue(1); - this.credits_needed = 0; - this.hours_possible = 0; - this.total_cost_per_hour_needed = 0; - this.total_cost_per_hour_time = 0; + this.chosen_flavors = [] + this.credits_wanted_group.get('credits_wanted_form').setValue(1) + this.hours_wanted_group.get('hours_wanted_form').setValue(1) + this.credits_needed = 0 + this.hours_possible = 0 + this.total_cost_per_hour_needed = 0 + this.total_cost_per_hour_time = 0 } filter_flavors_by_facility(): void { // Default as facility is chosen, do not filter by facility if (this.selected_facility[1] === null) { - return; + return } for (const flavor of this.all_flavors) { - let changed: boolean = false; + let changed: boolean = false // Flavor does not belong to the facility, continue if (flavor.compute_center !== this.selected_facility[1]) { - continue; + continue } // Check if flavor with same name is already in shown_flavors list for (const flavor_type in this.shown_flavors) { for (const shown_flavor of this.shown_flavors[flavor_type]) { if (shown_flavor.name === flavor.name) { // Flavor with same name found, updating it instead of pushing - this.shown_flavors[flavor_type][this.shown_flavors[flavor_type].indexOf(shown_flavor)] = flavor; - changed = true; + this.shown_flavors[flavor_type][this.shown_flavors[flavor_type].indexOf(shown_flavor)] = flavor + changed = true } } } // Flavor with same name not found, pushing it instead of updating if (!changed) { if (flavor.type.long_name in this.shown_flavors) { - this.shown_flavors[flavor.type.long_name].push(flavor); + this.shown_flavors[flavor.type.long_name].push(flavor) } else { - this.shown_flavors[flavor.type.long_name] = [flavor]; + this.shown_flavors[flavor.type.long_name] = [flavor] } } } @@ -202,24 +202,26 @@ export class CreditsCalculatorComponent implements OnInit { sort_by_cph(): void { for (const flavor_type in this.shown_flavors) { - this.shown_flavors[flavor_type].sort((a, b) => (a['credits_costs_per_hour'] < b['credits_costs_per_hour'] ? -1 : 1)); + this.shown_flavors[flavor_type].sort((a, b) => + a['credits_costs_per_hour'] < b['credits_costs_per_hour'] ? -1 : 1 + ) } } change_flavor_pair(name: string, event: any): void { - const amount: number = Number(event.target.value); + const amount: number = Number(event.target.value) this.chosen_flavors.forEach((item, index) => { - if (item.indexOf(name) > -1) this.chosen_flavors.splice(index, 1); - }); - if (amount <= 0) return; - this.chosen_flavors.push([name, amount]); + if (item.indexOf(name) > -1) this.chosen_flavors.splice(index, 1) + }) + if (amount <= 0) return + this.chosen_flavors.push([name, amount]) } calculate_timestamp(): number { - const date: Date = this.timestamp_group.get('date_picker').value; - const date_time: Date = new Date(date.getFullYear(), date.getMonth(), date.getDate()); + const date: Date = this.timestamp_group.get('date_picker').value + const date_time: Date = new Date(date.getFullYear(), date.getMonth(), date.getDate()) - return date_time.getTime() / 1000; + return date_time.getTime() / 1000 } calculate_credits_needed(): void { @@ -228,12 +230,12 @@ export class CreditsCalculatorComponent implements OnInit { this.hours_wanted_group.get('hours_wanted_form').value, this.chosen_flavors, this.selected_facility[0], - this.calculate_timestamp(), + this.calculate_timestamp() ) .subscribe((result: any) => { - this.credits_needed = result['credits_needed']; - this.total_cost_per_hour_needed = result['cost_per_hour']; - }); + this.credits_needed = result['credits_needed'] + this.total_cost_per_hour_needed = result['cost_per_hour'] + }) } calculate_time_possible(): void { @@ -242,11 +244,11 @@ export class CreditsCalculatorComponent implements OnInit { this.credits_wanted_group.get('credits_wanted_form').value, this.chosen_flavors, this.selected_facility[0], - this.calculate_timestamp(), + this.calculate_timestamp() ) .subscribe((result: any) => { - this.hours_possible = result['max_hours']; - this.total_cost_per_hour_time = result['cost_per_hour']; - }); + this.hours_possible = result['max_hours'] + this.total_cost_per_hour_time = result['cost_per_hour'] + }) } } diff --git a/src/app/credits-calculator/credits-calculator.module.ts b/src/app/credits-calculator/credits-calculator.module.ts index 6c8a0bd0fc..5f16519cac 100644 --- a/src/app/credits-calculator/credits-calculator.module.ts +++ b/src/app/credits-calculator/credits-calculator.module.ts @@ -1,18 +1,16 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { TimepickerModule } from 'ngx-bootstrap/timepicker'; -import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'; -import { AlertModule } from 'ngx-bootstrap/alert'; -import { AccordionModule } from 'ngx-bootstrap/accordion'; -import { CreditsCalculatorComponent } from './credits-calculator.component'; -import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module'; -import { PipeModuleModule } from '../pipe-module/pipe-module.module'; +import { NgModule } from '@angular/core' +import { CommonModule } from '@angular/common' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { TimepickerModule } from 'ngx-bootstrap/timepicker' +import { BsDatepickerModule } from 'ngx-bootstrap/datepicker' +import { AlertModule } from 'ngx-bootstrap/alert' +import { AccordionModule } from 'ngx-bootstrap/accordion' +import { CreditsCalculatorComponent } from './credits-calculator.component' +import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module' +import { PipeModuleModule } from '../pipe-module/pipe-module.module' @NgModule({ - declarations: [ - CreditsCalculatorComponent, - ], + declarations: [CreditsCalculatorComponent], imports: [ CommonModule, FormsModule, @@ -22,7 +20,7 @@ import { PipeModuleModule } from '../pipe-module/pipe-module.module'; ReactiveFormsModule, PipeModuleModule, AlertModule, - AccordionModule, - ], + AccordionModule + ] }) -export class CreditsCalculatorModule { } +export class CreditsCalculatorModule {} diff --git a/src/app/credits-calculator/resource-weights.model/resource-weights.model.ts b/src/app/credits-calculator/resource-weights.model/resource-weights.model.ts index 875b0a4ed3..b371b9ed6a 100644 --- a/src/app/credits-calculator/resource-weights.model/resource-weights.model.ts +++ b/src/app/credits-calculator/resource-weights.model/resource-weights.model.ts @@ -1,81 +1,76 @@ /** * Application class. */ -// eslint-disable-next-line max-classes-per-file + export interface IResourceWeight { - vcpus: IVCPUWeight[]; - memory_mb: IRAMWeight[]; - resource_set_timestamp: number; + vcpus: IVCPUWeight[] + memory_mb: IRAMWeight[] + resource_set_timestamp: number } export interface IVCPUWeight { - value: number; - weight: number; + value: number + weight: number } export interface IRAMWeight { - value: number; - weight: number; + value: number + weight: number } export class ResourceWeight { - - vcpus: VCPUWeight[]; - memory_mb: RAMWeight[]; - resource_set_timestamp: number; - resource_set_date: Date; - used: boolean = false; + vcpus: VCPUWeight[] + memory_mb: RAMWeight[] + resource_set_timestamp: number + resource_set_date: Date + used: boolean = false constructor(rw: IResourceWeight) { - this.vcpus = []; - this.memory_mb = []; + this.vcpus = [] + this.memory_mb = [] for (const vw of rw.vcpus) { - this.vcpus.push(new VCPUWeight(vw)); + this.vcpus.push(new VCPUWeight(vw)) } for (const mw of rw.memory_mb) { - this.memory_mb.push(new RAMWeight(mw)); + this.memory_mb.push(new RAMWeight(mw)) } - this.sort_all(); + this.sort_all() - this.resource_set_timestamp = rw.resource_set_timestamp; - this.resource_set_date = new Date(rw.resource_set_timestamp * 1000); + this.resource_set_timestamp = rw.resource_set_timestamp + this.resource_set_date = new Date(rw.resource_set_timestamp * 1000) } sort_all(): void { - this.vcpus.sort( - (a, b) => (a.value < b.value ? -1 : 1), - ); - this.memory_mb.sort( - (a, b) => (a.value < b.value ? -1 : 1), - ); + this.vcpus.sort((a, b) => (a.value < b.value ? -1 : 1)) + this.memory_mb.sort((a, b) => (a.value < b.value ? -1 : 1)) } set_used(): void { - this.used = true; + this.used = true } set_unused(): void { - this.used = false; + this.used = false } } export class VCPUWeight { - value: number; - weight: number; + value: number + weight: number constructor(vw: IVCPUWeight) { - this.value = vw.value; - this.weight = vw.weight; + this.value = vw.value + this.weight = vw.weight } } export class RAMWeight { - value: number; - weight: number; + value: number + weight: number constructor(mw: IRAMWeight) { - this.value = mw.value; - this.weight = mw.weight; + this.value = mw.value + this.weight = mw.weight } } diff --git a/src/app/facility_manager/facility.application.component.ts b/src/app/facility_manager/facility.application.component.ts index 146615ab5c..5e411130dc 100644 --- a/src/app/facility_manager/facility.application.component.ts +++ b/src/app/facility_manager/facility.application.component.ts @@ -1,16 +1,14 @@ -import { - ChangeDetectorRef, Component, OnInit, inject, -} from '@angular/core'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { FacilityService } from '../api-connector/facility.service'; -import { UserService } from '../api-connector/user.service'; -import { GroupService } from '../api-connector/group.service'; -import { ApiSettings } from '../api-connector/api-settings.service'; -import { Application } from '../applications/application.model/application.model'; -import { Application_States } from '../shared/shared_modules/baseClass/abstract-base-class'; -import { ApplicationsService } from '../api-connector/applications.service'; -import { ApplicationBaseClassComponent } from '../shared/shared_modules/baseClass/application-base-class.component'; -// eslint-disable-next-line no-shadow +import { ChangeDetectorRef, Component, OnInit, inject } from '@angular/core' +import { MatomoTracker } from 'ngx-matomo-client' +import { FacilityService } from '../api-connector/facility.service' +import { UserService } from '../api-connector/user.service' +import { GroupService } from '../api-connector/group.service' +import { ApiSettings } from '../api-connector/api-settings.service' +import { Application } from '../applications/application.model/application.model' +import { Application_States } from '../shared/shared_modules/baseClass/abstract-base-class' +import { ApplicationsService } from '../api-connector/applications.service' +import { ApplicationBaseClassComponent } from '../shared/shared_modules/baseClass/application-base-class.component' + enum TabStates { 'SUBMITTED' = 0, 'CREDITS_EXTENSION' = 1, @@ -26,18 +24,18 @@ enum TabStates { selector: 'app-facility.application', templateUrl: 'facility.application.component.html', styleUrls: ['facility.application.component.scss'], - providers: [FacilityService, UserService, GroupService, ApplicationsService, ApiSettings], + providers: [FacilityService, UserService, GroupService, ApplicationsService, ApiSettings] }) export class FacilityApplicationComponent extends ApplicationBaseClassComponent implements OnInit { - private readonly tracker = inject(MatomoTracker); - numberOfExtensionRequests: number = 0; - numberOfModificationRequests: number = 0; - numberOfCreditRequests: number = 0; - numberOfProjectApplications: number = 0; - numberOfTerminationRequests: number = 0; - Application_States: typeof Application_States = Application_States; - - title: string = 'Application Overview'; + private readonly tracker = inject(MatomoTracker) + numberOfExtensionRequests: number = 0 + numberOfModificationRequests: number = 0 + numberOfCreditRequests: number = 0 + numberOfProjectApplications: number = 0 + numberOfTerminationRequests: number = 0 + Application_States: typeof Application_States = Application_States + + title: string = 'Application Overview' /** * All Applications waiting for confirmation for the selected facility. * @@ -47,49 +45,49 @@ export class FacilityApplicationComponent extends ApplicationBaseClassComponent /** * Facilitties where the user is manager ['name',id]. */ - public managerFacilities: [string, number][]; + public managerFacilities: [string, number][] /** * Chosen facility. */ - public selectedFacility: [string, number]; + public selectedFacility: [string, number] /** * List of all application modifications. * * @type {Array} */ - all_application_modifications: Application[] = []; - isHistoryLoaded: boolean = false; + all_application_modifications: Application[] = [] + isHistoryLoaded: boolean = false - applications_history: Application[] = []; + applications_history: Application[] = [] - allApplicationsToCheck: Application[] = []; + allApplicationsToCheck: Application[] = [] - tab_state: number = TabStates.SUBMITTED; - TabStates: typeof TabStates = TabStates; - loadingApplications: boolean = false; + tab_state: number = TabStates.SUBMITTED + TabStates: typeof TabStates = TabStates + loadingApplications: boolean = false - approveLocked: boolean = false; + approveLocked: boolean = false constructor( userService: UserService, facilityService: FacilityService, applicationsService: ApplicationsService, - cdrRef: ChangeDetectorRef, + cdrRef: ChangeDetectorRef ) { - super(userService, applicationsService, facilityService, cdrRef); + super(userService, applicationsService, facilityService, cdrRef) } getFacilityApplicationById(application: Application): void { if (application.project_application_description !== undefined) { - return; + return } - const idx: number = this.applications_history.indexOf(application); + const idx: number = this.applications_history.indexOf(application) this.facilityService .getFacilityApplicationById(this.selectedFacility['FacilityId'], application.project_application_id.toString()) .subscribe((app: Application): void => { - this.applications_history[idx] = new Application(app); - }); + this.applications_history[idx] = new Application(app) + }) } /** @@ -98,20 +96,20 @@ export class FacilityApplicationComponent extends ApplicationBaseClassComponent * @param facility id of the facility */ getAllApplicationsHistory(facility: number): void { - this.isHistoryLoaded = false; + this.isHistoryLoaded = false - this.applications_history = []; + this.applications_history = [] // todo check if user is VO Admin this.facilityService.getFacilityApplicationsHistory(facility).subscribe((applications: Application[]): void => { if (applications.length === 0) { - this.isHistoryLoaded = true; + this.isHistoryLoaded = true } for (const application of applications) { - this.applications_history.push(new Application(application)); + this.applications_history.push(new Application(application)) } - this.isHistoryLoaded = true; - }); + this.isHistoryLoaded = true + }) } /** @@ -120,23 +118,23 @@ export class FacilityApplicationComponent extends ApplicationBaseClassComponent * @param value */ onChangeSelectedFacility(): void { - this.isLoaded = false; - this.allApplicationsToCheck = []; - this.all_application_modifications = []; - this.applications_history = []; + this.isLoaded = false + this.allApplicationsToCheck = [] + this.all_application_modifications = [] + this.applications_history = [] this.facilityService .getExtensionRequestsCounterFacility(this.selectedFacility['FacilityId']) .subscribe((res: any): void => { - this.numberOfCreditRequests = res['credits_extension_requests']; - this.numberOfExtensionRequests = res['lifetime_extension_requests']; - this.numberOfModificationRequests = res['modification_requests']; - this.numberOfProjectApplications = res['applications_submitted']; - this.numberOfTerminationRequests = res['termination_requests']; - }); - this.changeTabState(TabStates.SUBMITTED); - this.isLoaded = true; + this.numberOfCreditRequests = res['credits_extension_requests'] + this.numberOfExtensionRequests = res['lifetime_extension_requests'] + this.numberOfModificationRequests = res['modification_requests'] + this.numberOfProjectApplications = res['applications_submitted'] + this.numberOfTerminationRequests = res['termination_requests'] + }) + this.changeTabState(TabStates.SUBMITTED) + this.isLoaded = true // this.getFullApplications(this.selectedFacility ['FacilityId']); - this.getAllApplicationsHistory(this.selectedFacility['FacilityId']); + this.getAllApplicationsHistory(this.selectedFacility['FacilityId']) } /** @@ -144,74 +142,74 @@ export class FacilityApplicationComponent extends ApplicationBaseClassComponent */ changeTabState(state: number): void { if (!this.loadingApplications) { - this.tab_state = state; - this.getApplicationsByTabState(); + this.tab_state = state + this.getApplicationsByTabState() } } getApplicationsByTabState(): void { - this.allApplicationsToCheck = []; - this.loadingApplications = true; + this.allApplicationsToCheck = [] + this.loadingApplications = true if (this.tab_state === TabStates.SUBMITTED) { this.facilityService .getWfcSubmittedApplications(this.selectedFacility['FacilityId']) .subscribe((applications: Application[]): void => { if (applications.length === 0) { - this.isLoaded_userApplication = true; + this.isLoaded_userApplication = true } for (const application of applications) { - this.allApplicationsToCheck.push(new Application(application)); + this.allApplicationsToCheck.push(new Application(application)) } - this.loadingApplications = false; - }); + this.loadingApplications = false + }) } else if (this.tab_state === TabStates.MODIFICATION_EXTENSION) { this.facilityService .getWfcModificationRequestedApplications(this.selectedFacility['FacilityId']) .subscribe((applications: Application[]): void => { if (applications.length === 0) { - this.isLoaded_userApplication = true; + this.isLoaded_userApplication = true } for (const application of applications) { - this.allApplicationsToCheck.push(new Application(application)); + this.allApplicationsToCheck.push(new Application(application)) } - this.loadingApplications = false; - }); + this.loadingApplications = false + }) } else if (this.tab_state === TabStates.CREDITS_EXTENSION) { this.facilityService .getWfcCreditsRequestedApplications(this.selectedFacility['FacilityId']) .subscribe((applications: Application[]): void => { if (applications.length === 0) { - this.isLoaded_userApplication = true; + this.isLoaded_userApplication = true } for (const application of applications) { - this.allApplicationsToCheck.push(new Application(application)); + this.allApplicationsToCheck.push(new Application(application)) } - this.loadingApplications = false; - }); + this.loadingApplications = false + }) } else if (this.tab_state === TabStates.LIFETIME_EXTENSION) { this.facilityService .getWfcLifetimeRequestedApplications(this.selectedFacility['FacilityId']) .subscribe((applications: Application[]): void => { if (applications.length === 0) { - this.isLoaded_userApplication = true; + this.isLoaded_userApplication = true } for (const application of applications) { - this.allApplicationsToCheck.push(new Application(application)); + this.allApplicationsToCheck.push(new Application(application)) } - this.loadingApplications = false; - }); + this.loadingApplications = false + }) } else if (this.tab_state === TabStates.TERMINATION_REQUEST) { this.facilityService .getWfcTerminationRequestedApplications(this.selectedFacility['FacilityId']) .subscribe((applications: Application[]): void => { if (applications.length === 0) { - this.isLoaded_userApplication = true; + this.isLoaded_userApplication = true } for (const application of applications) { - this.allApplicationsToCheck.push(new Application(application)); + this.allApplicationsToCheck.push(new Application(application)) } - this.loadingApplications = false; - }); + this.loadingApplications = false + }) } } @@ -219,25 +217,25 @@ export class FacilityApplicationComponent extends ApplicationBaseClassComponent this.facilityService .getExtensionRequestsCounterFacility(this.selectedFacility['FacilityId']) .subscribe((res: any): void => { - this.numberOfCreditRequests = res['credits_extension_requests']; - this.numberOfExtensionRequests = res['lifetime_extension_requests']; - this.numberOfModificationRequests = res['modification_requests']; - this.numberOfProjectApplications = res['applications_submitted']; - this.numberOfTerminationRequests = res['termination_requests']; - }); + this.numberOfCreditRequests = res['credits_extension_requests'] + this.numberOfExtensionRequests = res['lifetime_extension_requests'] + this.numberOfModificationRequests = res['modification_requests'] + this.numberOfProjectApplications = res['applications_submitted'] + this.numberOfTerminationRequests = res['termination_requests'] + }) } ngOnInit(): void { - this.tracker.trackPageView('Facility Application Overview'); + this.tracker.trackPageView('Facility Application Overview') this.facilityService.getManagerFacilities().subscribe((result: any): void => { - this.managerFacilities = result; - this.selectedFacility = this.managerFacilities[0]; - this.getApplicationNumbers(); - this.changeTabState(TabStates.SUBMITTED); - this.isLoaded = true; + this.managerFacilities = result + this.selectedFacility = this.managerFacilities[0] + this.getApplicationNumbers() + this.changeTabState(TabStates.SUBMITTED) + this.isLoaded = true // this.getFullApplications(this.selectedFacility ['FacilityId']); - this.getAllApplicationsHistory(this.selectedFacility['FacilityId']); - }); + this.getAllApplicationsHistory(this.selectedFacility['FacilityId']) + }) } } diff --git a/src/app/facility_manager/facilitymanager-routing.module.ts b/src/app/facility_manager/facilitymanager-routing.module.ts index ea97d1d961..63fc56bdb7 100644 --- a/src/app/facility_manager/facilitymanager-routing.module.ts +++ b/src/app/facility_manager/facilitymanager-routing.module.ts @@ -1,58 +1,54 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { FacilityProjectsOverviewComponent } from '../facility_manager/facilityprojectsoverview.component'; -import { ImageTagComponent } from '../facility_manager/imagetags.component'; -import { FacilityApplicationComponent } from './facility.application.component'; -import { ResourcesComponent } from './resources/resources.component'; -import { NewsManagerComponent } from './newsmanagement/news-manager.component'; +import { NgModule } from '@angular/core' +import { RouterModule, Routes } from '@angular/router' +import { FacilityProjectsOverviewComponent } from '../facility_manager/facilityprojectsoverview.component' +import { ImageTagComponent } from '../facility_manager/imagetags.component' +import { FacilityApplicationComponent } from './facility.application.component' +import { ResourcesComponent } from './resources/resources.component' +import { NewsManagerComponent } from './newsmanagement/news-manager.component' const routes: Routes = [ - { path: 'facilityProjects', component: FacilityProjectsOverviewComponent, data: { - title: 'Facility Projects', - }, - + title: 'Facility Projects' + } }, { path: 'imageTags', component: ImageTagComponent, data: { - title: 'Image Tags', - }, + title: 'Image Tags' + } }, { path: 'facilityApplications', component: FacilityApplicationComponent, data: { - title: 'Facility Applications', - }, + title: 'Facility Applications' + } }, { path: 'facilityResources', component: ResourcesComponent, data: { - title: 'Facility Resources', - }, + title: 'Facility Resources' + } }, { path: 'news-manager', component: NewsManagerComponent, data: { - title: 'News Management', - }, - }, - -]; + title: 'News Management' + } + } +] /** * Facilitymanager routing module. */ @NgModule({ imports: [RouterModule.forChild(routes)], - exports: [RouterModule], + exports: [RouterModule] }) -export class FacilitymanagerRoutingModule { -} +export class FacilitymanagerRoutingModule {} diff --git a/src/app/facility_manager/facilitymanager.module.ts b/src/app/facility_manager/facilitymanager.module.ts index 3ff7a9f8d8..62e8119165 100644 --- a/src/app/facility_manager/facilitymanager.module.ts +++ b/src/app/facility_manager/facilitymanager.module.ts @@ -1,31 +1,29 @@ -import { NgModule } from '@angular/core'; -import { TabsModule } from 'ngx-bootstrap/tabs'; -import { CommonModule } from '@angular/common'; -import { ModalModule } from 'ngx-bootstrap/modal'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'; -import { NgbPaginationModule, NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap'; -import { NgSelectModule } from '@ng-select/ng-select'; -import { - AlertComponent, BadgeComponent, ButtonDirective, InputGroupComponent, -} from '@coreui/angular'; -import { TooltipModule } from 'ngx-bootstrap/tooltip'; -import { FacilityProjectsOverviewComponent } from '../facility_manager/facilityprojectsoverview.component'; -import { ImageTagComponent } from '../facility_manager/imagetags.component'; -import { FacilitymanagerRoutingModule } from './facilitymanager-routing.module'; -import { FacilityApplicationComponent } from './facility.application.component'; -import { ResourcesComponent } from './resources/resources.component'; -import { ApplicationsModule } from '../applications/applications.module'; -import { NewsManagerComponent } from './newsmanagement/news-manager.component'; -import { PipeModuleModule } from '../pipe-module/pipe-module.module'; -import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module'; -import { ObjectstoragefactorOverviewComponent } from './resources/objectstoragefactor-overview/objectstoragefactor-overview.component'; -import { VolumestoragefactorOverviewComponent } from './resources/volumestoragefactor-overview/volumestoragefactor-overview.component'; -import { ResourcemachineOverviewComponent } from './resources/resourcemachine-overview/resourcemachine-overview.component'; -import { GPUSpecificationOverviewComponent } from './resources/gpu-specification-overview/gpu-specification-overview.component'; -import { GeneralstoragefactorOverviewComponent } from './resources/generalstoragefactor-overview/generalstoragefactor-overview.component'; -import { ProjectManagementModule } from '../projectmanagement/projectmanagement.module'; -import { SharedModuleModule } from '../shared/shared_modules/shared-module.module'; +import { NgModule } from '@angular/core' +import { TabsModule } from 'ngx-bootstrap/tabs' +import { CommonModule } from '@angular/common' +import { ModalModule } from 'ngx-bootstrap/modal' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { BsDatepickerModule } from 'ngx-bootstrap/datepicker' +import { NgbPaginationModule, NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap' +import { NgSelectModule } from '@ng-select/ng-select' +import { AlertComponent, BadgeComponent, ButtonDirective, InputGroupComponent } from '@coreui/angular' +import { TooltipModule } from 'ngx-bootstrap/tooltip' +import { FacilityProjectsOverviewComponent } from '../facility_manager/facilityprojectsoverview.component' +import { ImageTagComponent } from '../facility_manager/imagetags.component' +import { FacilitymanagerRoutingModule } from './facilitymanager-routing.module' +import { FacilityApplicationComponent } from './facility.application.component' +import { ResourcesComponent } from './resources/resources.component' +import { ApplicationsModule } from '../applications/applications.module' +import { NewsManagerComponent } from './newsmanagement/news-manager.component' +import { PipeModuleModule } from '../pipe-module/pipe-module.module' +import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module' +import { ObjectstoragefactorOverviewComponent } from './resources/objectstoragefactor-overview/objectstoragefactor-overview.component' +import { VolumestoragefactorOverviewComponent } from './resources/volumestoragefactor-overview/volumestoragefactor-overview.component' +import { ResourcemachineOverviewComponent } from './resources/resourcemachine-overview/resourcemachine-overview.component' +import { GPUSpecificationOverviewComponent } from './resources/gpu-specification-overview/gpu-specification-overview.component' +import { GeneralstoragefactorOverviewComponent } from './resources/generalstoragefactor-overview/generalstoragefactor-overview.component' +import { ProjectManagementModule } from '../projectmanagement/projectmanagement.module' +import { SharedModuleModule } from '../shared/shared_modules/shared-module.module' /** * Facilitymanager module. @@ -51,7 +49,7 @@ import { SharedModuleModule } from '../shared/shared_modules/shared-module.modul BadgeComponent, TooltipModule, InputGroupComponent, - ButtonDirective, + ButtonDirective ], declarations: [ FacilityProjectsOverviewComponent, @@ -64,7 +62,7 @@ import { SharedModuleModule } from '../shared/shared_modules/shared-module.modul VolumestoragefactorOverviewComponent, ResourcemachineOverviewComponent, GPUSpecificationOverviewComponent, - ResourcemachineOverviewComponent, - ], + ResourcemachineOverviewComponent + ] }) export class FacilitymanagerModule {} diff --git a/src/app/facility_manager/facilityprojectsoverview.component.ts b/src/app/facility_manager/facilityprojectsoverview.component.ts index b722a8d618..a3f0d0a506 100644 --- a/src/app/facility_manager/facilityprojectsoverview.component.ts +++ b/src/app/facility_manager/facilityprojectsoverview.component.ts @@ -1,28 +1,26 @@ -import { - Component, Input, OnInit, QueryList, ViewChildren, inject, -} from '@angular/core'; -import { Observable, take } from 'rxjs'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { ProjectMember } from '../projectmanagement/project_member.model'; -import { environment } from '../../environments/environment'; -import { ApiSettings } from '../api-connector/api-settings.service'; -import { GroupService } from '../api-connector/group.service'; -import { UserService } from '../api-connector/user.service'; -import { FacilityService } from '../api-connector/facility.service'; -import { NewsService } from '../api-connector/news.service'; -import { Application } from '../applications/application.model/application.model'; +import { Component, Input, OnInit, QueryList, ViewChildren, inject } from '@angular/core' +import { Observable, take } from 'rxjs' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { MatomoTracker } from 'ngx-matomo-client' +import { ProjectMember } from '../projectmanagement/project_member.model' +import { environment } from '../../environments/environment' +import { ApiSettings } from '../api-connector/api-settings.service' +import { GroupService } from '../api-connector/group.service' +import { UserService } from '../api-connector/user.service' +import { FacilityService } from '../api-connector/facility.service' +import { NewsService } from '../api-connector/news.service' +import { Application } from '../applications/application.model/application.model' import { NgbdSortableHeaderDirective, - SortEvent, -} from '../shared/shared_modules/directives/nbd-sortable-header.directive'; -import { ProjectSortService } from '../shared/shared_modules/services/project-sort.service'; -import { AbstractBaseClass } from '../shared/shared_modules/baseClass/abstract-base-class'; -import { ProjectEmailModalComponent } from '../shared/modal/email/project-email-modal/project-email-modal.component'; -import { MembersListModalComponent } from '../shared/modal/members/members-list-modal.component'; -import { EmailService } from '../api-connector/email.service'; -import { CsvMailTemplateModel } from '../shared/classes/csvMailTemplate.model'; -import { ProjectCsvTemplatedEmailModalComponent } from '../shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component'; + SortEvent +} from '../shared/shared_modules/directives/nbd-sortable-header.directive' +import { ProjectSortService } from '../shared/shared_modules/services/project-sort.service' +import { AbstractBaseClass } from '../shared/shared_modules/baseClass/abstract-base-class' +import { ProjectEmailModalComponent } from '../shared/modal/email/project-email-modal/project-email-modal.component' +import { MembersListModalComponent } from '../shared/modal/members/members-list-modal.component' +import { EmailService } from '../api-connector/email.service' +import { CsvMailTemplateModel } from '../shared/classes/csvMailTemplate.model' +import { ProjectCsvTemplatedEmailModalComponent } from '../shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component' /** * Facility Project overview component. @@ -30,74 +28,74 @@ import { ProjectCsvTemplatedEmailModalComponent } from '../shared/modal/email/pr @Component({ selector: 'app-facility-projects', templateUrl: 'facilityprojectsoverview.component.html', - providers: [FacilityService, UserService, GroupService, ApiSettings, NewsService, ProjectSortService], + providers: [FacilityService, UserService, GroupService, ApiSettings, NewsService, ProjectSortService] }) export class FacilityProjectsOverviewComponent extends AbstractBaseClass implements OnInit { - private readonly tracker = inject(MatomoTracker); - @Input() voRegistrationLink: string = environment.voRegistrationLink; - - title: string = 'Projects Overview'; - filter: string; - - membersLoaded: boolean = false; - public memberFilter: string = ''; - filteredMembers: object[] = []; - selectedMember: object[] = []; - - isLoaded: boolean = false; - projects: Application[] = []; - projectsCopy: Application[] = []; - show_openstack_projects: boolean = true; - show_simple_vm_projects: boolean = true; - details_loaded: boolean = false; - selectedEmailProjects: Application[] = []; - bsModalRef: BsModalRef; - userElixirSearchPI: boolean = true; - userElixirSearchAdmin: boolean = true; - userElixirSearchMember: boolean = true; - userElixirIdFilter: string; - - projectsLoaded: boolean = false; + private readonly tracker = inject(MatomoTracker) + @Input() voRegistrationLink: string = environment.voRegistrationLink + + title: string = 'Projects Overview' + filter: string + + membersLoaded: boolean = false + public memberFilter: string = '' + filteredMembers: object[] = [] + selectedMember: object[] = [] + + isLoaded: boolean = false + projects: Application[] = [] + projectsCopy: Application[] = [] + show_openstack_projects: boolean = true + show_simple_vm_projects: boolean = true + details_loaded: boolean = false + selectedEmailProjects: Application[] = [] + bsModalRef: BsModalRef + userElixirSearchPI: boolean = true + userElixirSearchAdmin: boolean = true + userElixirSearchMember: boolean = true + userElixirIdFilter: string + + projectsLoaded: boolean = false /** * Approved group status. * * @type {number} */ - STATUS_APPROVED: number = 2; + STATUS_APPROVED: number = 2 - selectedProjectType: string = 'ALL'; + selectedProjectType: string = 'ALL' // modal variables for User list - public selectedProjectForSearch: Application; - public usersModalProjectMembers: ProjectMember[] = []; - allFacilityMembers: object[] = []; - public usersModalProjectID: number; - public usersModalProjectName: string; - public selectedProject: Application; - public userSearchValue: string; - validElixirIdFilter: boolean = false; - - public emailSubject: string; - public emailText: string; - public emailStatus: number = 0; - public emailReply: string = ''; - public sendNews: boolean; - public alternative_emailText: string = ''; - public news_tags: string[] = []; - FILTER_DEBOUNCE_TIME: number = 500; - - public managerFacilities: [string, number][] = []; - public selectedFacility: [string, number]; - projects_filtered: Application[] = []; - facilitySupportMails: string = ''; - supportMailEditing: boolean = false; - PREDEFINED_TAGS: string[] = ['downtime', 'openstack', 'simplevm', 'maintenance', 'update']; - - @ViewChildren(NgbdSortableHeaderDirective) headers: QueryList; - - applictions$: Observable; - total$: Observable; + public selectedProjectForSearch: Application + public usersModalProjectMembers: ProjectMember[] = [] + allFacilityMembers: object[] = [] + public usersModalProjectID: number + public usersModalProjectName: string + public selectedProject: Application + public userSearchValue: string + validElixirIdFilter: boolean = false + + public emailSubject: string + public emailText: string + public emailStatus: number = 0 + public emailReply: string = '' + public sendNews: boolean + public alternative_emailText: string = '' + public news_tags: string[] = [] + FILTER_DEBOUNCE_TIME: number = 500 + + public managerFacilities: [string, number][] = [] + public selectedFacility: [string, number] + projects_filtered: Application[] = [] + facilitySupportMails: string = '' + supportMailEditing: boolean = false + PREDEFINED_TAGS: string[] = ['downtime', 'openstack', 'simplevm', 'maintenance', 'update'] + + @ViewChildren(NgbdSortableHeaderDirective) headers: QueryList + + applictions$: Observable + total$: Observable constructor( private groupService: GroupService, @@ -105,57 +103,58 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme private newsService: NewsService, public sortProjectService: ProjectSortService, private modalService: BsModalService, - private emailService: EmailService, + private emailService: EmailService ) { - super(); + super() } switchShowSimpleVmProjects(): void { - this.show_simple_vm_projects = !this.show_simple_vm_projects; + this.show_simple_vm_projects = !this.show_simple_vm_projects } switchOpenStackVmProjects(): void { - this.show_openstack_projects = !this.show_openstack_projects; + this.show_openstack_projects = !this.show_openstack_projects } setEmailSubject(): void { switch (this.selectedProjectType) { case 'ALL': - this.emailSubject = `[${this.selectedFacility['Facility']}]`; - break; + this.emailSubject = `[${this.selectedFacility['Facility']}]` + break case 'OVP': - this.emailSubject = `[${this.selectedFacility['Facility']}: OpenStack]`; - break; + this.emailSubject = `[${this.selectedFacility['Facility']}: OpenStack]` + break case 'SVP': - this.emailSubject = `[${this.selectedFacility['Facility']}: SimpleVm]`; - break; + this.emailSubject = `[${this.selectedFacility['Facility']}: SimpleVm]` + break case 'USER': - this.emailSubject = `[${this.selectedFacility['Facility']}: Specific Members]`; - break; + this.emailSubject = `[${this.selectedFacility['Facility']}: Specific Members]` + break default: // eslint-disable-next-line no-case-declarations const pro: Application = this.projects.find( - (project: Application): boolean => project.project_application_perun_id.toString() === this.selectedProjectType.toString(), - ); + (project: Application): boolean => + project.project_application_perun_id.toString() === this.selectedProjectType.toString() + ) if (pro) { - this.emailSubject = `[${this.selectedFacility['Facility']}: ${pro.project_application_shortname}]`; + this.emailSubject = `[${this.selectedFacility['Facility']}: ${pro.project_application_shortname}]` } else { - this.emailSubject = `[${this.selectedFacility['Facility']}]`; + this.emailSubject = `[${this.selectedFacility['Facility']}]` } - break; + break } } ngOnInit(): void { - this.tracker.trackPageView('Facility Project Overview'); + this.tracker.trackPageView('Facility Project Overview') this.facilityService.getManagerFacilities().subscribe((result: any): void => { - this.managerFacilities = result; - this.selectedFacility = this.managerFacilities[0]; - this.emailSubject = `[${this.selectedFacility['Facility']}]`; - this.getFacilityProjects(this.managerFacilities[0]['FacilityId']); - this.title = `${this.title}:${this.selectedFacility['Facility']}`; - }); - this.sendNews = true; + this.managerFacilities = result + this.selectedFacility = this.managerFacilities[0] + this.emailSubject = `[${this.selectedFacility['Facility']}]` + this.getFacilityProjects(this.managerFacilities[0]['FacilityId']) + this.title = `${this.title}:${this.selectedFacility['Facility']}` + }) + this.sendNews = true /** needs refactoring in case we introduce tags to wagtail * this.newsService.getAvailableTagsFromWordPress().subscribe((tags: WordPressTag[]): void => { @@ -168,67 +167,67 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme } onCsvFileSelected(event): void { - const inputElement = event.target as HTMLInputElement; + const inputElement = event.target as HTMLInputElement if (inputElement.files && inputElement.files.length > 0) { this.emailService.sendCsvTemplate(inputElement.files[0]).subscribe( (csvTemplate: CsvMailTemplateModel) => { - this.openProjectMailsModal(inputElement.files[0], csvTemplate); + this.openProjectMailsModal(inputElement.files[0], csvTemplate) }, (error: CsvMailTemplateModel) => { - console.log(error['error']); - this.openProjectMailsModal(inputElement.files[0], error['error']); - }, - ); + console.log(error['error']) + this.openProjectMailsModal(inputElement.files[0], error['error']) + } + ) } } openProjectCSVMailModal(): void { - console.log('show'); + console.log('show') - this.bsModalRef = this.modalService.show(ProjectCsvTemplatedEmailModalComponent, { class: 'modal-lg' }); + this.bsModalRef = this.modalService.show(ProjectCsvTemplatedEmailModalComponent, { class: 'modal-lg' }) } onSort({ column, direction }: SortEvent) { // resetting other headers this.headers.forEach(header => { if (header.appSortable !== column) { - header.direction = ''; + header.direction = '' } - }); + }) - this.sortProjectService.sortColumn = column; - this.sortProjectService.sortDirection = direction; + this.sortProjectService.sortColumn = column + this.sortProjectService.sortDirection = direction } filterMembers(bare_searchString: string): void { - this.filteredMembers = []; - const searchString: string = bare_searchString.toLowerCase(); + this.filteredMembers = [] + const searchString: string = bare_searchString.toLowerCase() this.allFacilityMembers.forEach((member: object): void => { if ( - member['elixirId'].toLowerCase().includes(searchString) - || member['email'].toLowerCase().includes(searchString) - || member['firstName'].toLowerCase().includes(searchString) - || member['lastName'].toLowerCase().includes(searchString) + member['elixirId'].toLowerCase().includes(searchString) || + member['email'].toLowerCase().includes(searchString) || + member['firstName'].toLowerCase().includes(searchString) || + member['lastName'].toLowerCase().includes(searchString) ) { - this.filteredMembers.push(member); + this.filteredMembers.push(member) } - }); + }) } checkValidElixirIdFilter(): void { - this.validElixirIdFilter = this.userElixirIdFilter && this.userElixirIdFilter.includes('@elixir-europe.org'); + this.validElixirIdFilter = this.userElixirIdFilter && this.userElixirIdFilter.includes('@elixir-europe.org') if (!this.validElixirIdFilter) { - this.sortProjectService.applications = this.projectsCopy; - this.applictions$ = this.sortProjectService.applications$; - this.total$ = this.sortProjectService.total$; - this.projectsLoaded = true; + this.sortProjectService.applications = this.projectsCopy + this.applictions$ = this.sortProjectService.applications$ + this.total$ = this.sortProjectService.total$ + this.projectsLoaded = true } } getProjectsByMemberElixirId(): void { // tslint:disable-next-line:max-line-length - this.userElixirIdFilter = this.userElixirIdFilter.trim(); + this.userElixirIdFilter = this.userElixirIdFilter.trim() if (this.userElixirIdFilter && this.userElixirIdFilter.includes('@elixir-europe.org')) { - this.projectsLoaded = false; + this.projectsLoaded = false this.facilityService .getFacilityGroupsByMemberElixirId( @@ -236,25 +235,25 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme this.userElixirIdFilter, this.userElixirSearchPI, this.userElixirSearchAdmin, - this.userElixirSearchMember, + this.userElixirSearchMember ) .subscribe((applications: Application[]): void => { - this.projects = applications; + this.projects = applications for (const group of applications) { if (group.project_application_lifetime > 0) { - group.lifetime_reached = this.lifeTimeReached(group.lifetime_days, group.DaysRunning); + group.lifetime_reached = this.lifeTimeReached(group.lifetime_days, group.DaysRunning) } } - this.sortProjectService.applications = this.projects; - this.applictions$ = this.sortProjectService.applications$; - this.total$ = this.sortProjectService.total$; - this.projectsLoaded = true; - }); + this.sortProjectService.applications = this.projects + this.applictions$ = this.sortProjectService.applications$ + this.total$ = this.sortProjectService.total$ + this.projectsLoaded = true + }) } else { - this.sortProjectService.applications = this.projectsCopy; - this.applictions$ = this.sortProjectService.applications$; - this.total$ = this.sortProjectService.total$; - this.projectsLoaded = true; + this.sortProjectService.applications = this.projectsCopy + this.applictions$ = this.sortProjectService.applications$ + this.total$ = this.sortProjectService.total$ + this.projectsLoaded = true } } @@ -262,43 +261,43 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme * Gets projects and sets email subject prefix when selected facility changes. */ onChangeSelectedFacility(): void { - this.isLoaded = false; - this.getFacilityProjects(this.selectedFacility['FacilityId']); - this.emailSubject = `[${this.selectedFacility['Facility']}]`; + this.isLoaded = false + this.getFacilityProjects(this.selectedFacility['FacilityId']) + this.emailSubject = `[${this.selectedFacility['Facility']}]` } showMembersModal(application: Application): void { const initialState = { projectId: application.project_application_perun_id, projectName: application.project_application_shortname, - facilityId: this.selectedFacility['FacilityId'], - }; + facilityId: this.selectedFacility['FacilityId'] + } - this.bsModalRef = this.modalService.show(MembersListModalComponent, { initialState, class: 'modal-lg' }); + this.bsModalRef = this.modalService.show(MembersListModalComponent, { initialState, class: 'modal-lg' }) } getProjectLifetime(): void { - this.details_loaded = true; + this.details_loaded = true } selectAllFilteredProjects(): void { - this.selectedEmailProjects = []; + this.selectedEmailProjects = [] // get all the applications this.applictions$.pipe(take(1)).subscribe(applications => { // set the selected state of all projects to true applications.forEach(application => { - application.is_project_selected = true; - this.toggleSelectedEmailApplication(application, application.is_project_selected); - }); - }); + application.is_project_selected = true + this.toggleSelectedEmailApplication(application, application.is_project_selected) + }) + }) } unselectAll(): void { this.sortProjectService.applications.forEach((pr: Application) => { - pr.is_project_selected = false; - this.toggleSelectedEmailApplication(pr, pr.is_project_selected); - }); + pr.is_project_selected = false + this.toggleSelectedEmailApplication(pr, pr.is_project_selected) + }) // this.selectedEmailProjects = []; // clear the selectedEmailProjects list } @@ -307,25 +306,25 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme this.applictions$.pipe(take(1)).subscribe(applications => { // set the selected state of all projects to false applications.forEach(application => { - application.is_project_selected = false; - this.toggleSelectedEmailApplication(application, application.is_project_selected); - }); - }); + application.is_project_selected = false + this.toggleSelectedEmailApplication(application, application.is_project_selected) + }) + }) } toggleSelectedEmailApplication(application: Application, isChecked: boolean): void { - const index = this.selectedEmailProjects.indexOf(application); + const index = this.selectedEmailProjects.indexOf(application) if (isChecked) { // checkbox was checked if (index === -1) { // application is not in the list, so add it - this.selectedEmailProjects.push(application); + this.selectedEmailProjects.push(application) } } else { // checkbox was unchecked // application is in the list, so remove it - this.selectedEmailProjects.splice(index, 1); + this.selectedEmailProjects.splice(index, 1) } } @@ -333,23 +332,23 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme * Returns the name of the project with the id of the selectedProjectType */ getProjectNameBySelectedProjectTypeAsId(): string { - const id: string = this.selectedProjectType; + const id: string = this.selectedProjectType if (!id) { - return 'NOT_FOUND'; + return 'NOT_FOUND' } const project: Application = this.projects.find( - (element: Application): boolean => element.project_application_perun_id.toString() === id.toString(), - ); + (element: Application): boolean => element.project_application_perun_id.toString() === id.toString() + ) if (project) { - return project.project_application_shortname; + return project.project_application_shortname } - return 'NOT_FOUND'; + return 'NOT_FOUND' } getFacilityProjects(facility: string): void { - this.projects = []; - this.projectsLoaded = false; + this.projects = [] + this.projectsLoaded = false // tslint:disable-next-line:max-line-length this.facilityService @@ -357,28 +356,28 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme .subscribe((applications: Application[]): void => { for (const group of applications) { if (group.project_application_lifetime > 0) { - group.lifetime_reached = this.lifeTimeReached(group.lifetime_days, group.DaysRunning); + group.lifetime_reached = this.lifeTimeReached(group.lifetime_days, group.DaysRunning) } - this.projects.push(group); + this.projects.push(group) } - this.projectsCopy = this.projects; - this.sortProjectService.applications = this.projects; - this.applictions$ = this.sortProjectService.applications$; - this.total$ = this.sortProjectService.total$; - this.projectsLoaded = true; - - this.isLoaded = true; - }); + this.projectsCopy = this.projects + this.sortProjectService.applications = this.projects + this.applictions$ = this.sortProjectService.applications$ + this.total$ = this.sortProjectService.total$ + this.projectsLoaded = true + + this.isLoaded = true + }) this.facilityService.getAllMembersOfFacility(facility, this.STATUS_APPROVED).subscribe( (result: any[]): void => { - this.membersLoaded = true; - this.allFacilityMembers = result; + this.membersLoaded = true + this.allFacilityMembers = result }, (error: any): void => { - console.log(error); - this.membersLoaded = false; - }, - ); + console.log(error) + this.membersLoaded = false + } + ) } /** @@ -404,19 +403,19 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme message: string, reply?: string, send?: any, - alternative_news_text?: string, + alternative_news_text?: string ): void { - this.emailStatus = 0; + this.emailStatus = 0 if (this.selectedProjectType === 'USER') { - const tempMailList: string[] = []; + const tempMailList: string[] = [] // tslint:disable-next-line:no-for-each-push this.selectedMember.forEach((member: object): void => { - tempMailList.push(member['email']); - }); - this.selectedProjectType = tempMailList.join(','); + tempMailList.push(member['email']) + }) + this.selectedProjectType = tempMailList.join(',') } if (reply) { - reply = reply.trim(); + reply = reply.trim() } this.facilityService @@ -428,27 +427,27 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme encodeURIComponent(reply), send, encodeURIComponent(alternative_news_text), - this.news_tags.join(), + this.news_tags.join() ) .subscribe( (result: any): void => { if (result.status === 201) { - this.emailStatus = 1; + this.emailStatus = 1 } else { - this.emailStatus = 2; + this.emailStatus = 2 } }, (): void => { - this.emailStatus = 2; + this.emailStatus = 2 }, (): void => { - this.filteredMembers = []; - this.selectedProjectType = 'ALL'; - this.emailReply = ''; - this.selectedMember = []; - this.memberFilter = ''; - }, - ); + this.filteredMembers = [] + this.selectedProjectType = 'ALL' + this.emailReply = '' + this.selectedMember = [] + this.memberFilter = '' + } + ) } /** @@ -459,14 +458,14 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme setSelectedUserForMail(member: object): void { if (!this.selectedMember.includes(member)) { - this.selectedMember.push(member); + this.selectedMember.push(member) } } removeSelectedUserForMail(member: object): void { - const index: number = this.selectedMember.indexOf(member); + const index: number = this.selectedMember.indexOf(member) if (index > -1) { - this.selectedMember.splice(index, 1); + this.selectedMember.splice(index, 1) } } @@ -474,70 +473,70 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme this.facilityService .getFacilityGroupRichMembers(projectid, this.selectedFacility['FacilityId']) .subscribe((members: ProjectMember[]): void => { - this.usersModalProjectID = projectid; - this.usersModalProjectName = projectname; - this.usersModalProjectMembers = members; - }); + this.usersModalProjectID = projectid + this.usersModalProjectName = projectname + this.usersModalProjectMembers = members + }) } public resetEmailModal(): void { - this.selectedProjectType = 'ALL'; - this.emailSubject = `[${this.selectedFacility['Facility']}]`; - this.emailText = null; - this.emailReply = null; - this.emailStatus = 0; - this.sendNews = true; - this.alternative_emailText = ''; - this.news_tags = []; - this.selectedMember = []; + this.selectedProjectType = 'ALL' + this.emailSubject = `[${this.selectedFacility['Facility']}]` + this.emailText = null + this.emailReply = null + this.emailStatus = 0 + this.sendNews = true + this.alternative_emailText = '' + this.news_tags = [] + this.selectedMember = [] } getFacilitySupportMails(): void { this.facilityService.getSupportMails(this.selectedFacility['FacilityId']).subscribe((result: any) => { - this.facilitySupportMails = result['body']; + this.facilitySupportMails = result['body'] if (this.facilitySupportMails === '' || this.facilitySupportMails === null) { - this.facilitySupportMails = 'example@mail1.com, example@mail2.com'; + this.facilitySupportMails = 'example@mail1.com, example@mail2.com' } - }); + }) } openProjectMailsModal(csvFile: File = null, csvTemplate: CsvMailTemplateModel = null): void { - let initialState = {}; + let initialState = {} if (csvFile) { initialState = { selectedProjects: csvTemplate.valid_projects, csvFile, - csvMailTemplate: csvTemplate, - }; + csvMailTemplate: csvTemplate + } } else { - initialState = { selectedProjects: this.selectedEmailProjects }; + initialState = { selectedProjects: this.selectedEmailProjects } } - this.bsModalRef = this.modalService.show(ProjectEmailModalComponent, { initialState, class: 'modal-lg' }); + this.bsModalRef = this.modalService.show(ProjectEmailModalComponent, { initialState, class: 'modal-lg' }) } setFacilitySupportMails(supportMails: string): void { - const facilityId = this.selectedFacility['FacilityId']; + const facilityId = this.selectedFacility['FacilityId'] this.facilityService.setSupportMails(facilityId, supportMails).subscribe((result: any): void => { if (result.ok) { this.updateNotificationModal( 'Facility support mails changed', 'You successfully changed the facility support mails.', true, - 'success', - ); + 'success' + ) } else { this.updateNotificationModal( "Couldn't change facility support mails", 'An error occurred while trying to change the facility support mails.', true, - 'danger', - ); + 'danger' + ) } - }); + }) } toggleSupportMailEditing(): void { - this.supportMailEditing = !this.supportMailEditing; + this.supportMailEditing = !this.supportMailEditing } } diff --git a/src/app/facility_manager/imagetags.component.ts b/src/app/facility_manager/imagetags.component.ts index 7243f0a27b..0b9a827c16 100644 --- a/src/app/facility_manager/imagetags.component.ts +++ b/src/app/facility_manager/imagetags.component.ts @@ -1,12 +1,10 @@ -import { Component, OnInit, inject } from '@angular/core'; -import { forkJoin } from 'rxjs'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { ImageService } from '../api-connector/image.service'; -import { - BlockedImageTag, BlockedImageTagResenv, ImageLogo, ImageMode, ImageTag, -} from './image-tag'; -import { FacilityService } from '../api-connector/facility.service'; -import { BiocondaService } from '../api-connector/bioconda.service'; +import { Component, OnInit, inject } from '@angular/core' +import { forkJoin } from 'rxjs' +import { MatomoTracker } from 'ngx-matomo-client' +import { ImageService } from '../api-connector/image.service' +import { BlockedImageTag, BlockedImageTagResenv, ImageLogo, ImageMode, ImageTag } from './image-tag' +import { FacilityService } from '../api-connector/facility.service' +import { BiocondaService } from '../api-connector/bioconda.service' /** * ImageTag component. @@ -14,80 +12,80 @@ import { BiocondaService } from '../api-connector/bioconda.service'; @Component({ selector: 'app-image-tags', templateUrl: 'imageTag.component.html', - providers: [ImageService, FacilityService, BiocondaService], + providers: [ImageService, FacilityService, BiocondaService] }) export class ImageTagComponent implements OnInit { - private readonly tracker = inject(MatomoTracker); + private readonly tracker = inject(MatomoTracker) - title: string = 'Image Tags'; + title: string = 'Image Tags' - isLoaded: boolean = false; - alertRed: boolean = false; - alertRed_blocked: boolean = false; - imageTags: ImageTag[]; - imageModes: ImageMode[]; - imageLogos: ImageLogo[]; - checkedModes: ImageMode[] = []; - blockedImageTags: BlockedImageTag[]; - blockedImageTagsResenv: BlockedImageTagResenv[]; - checkedBlockedImageTagResenv: string[] = []; - imageTag: string; - imageUrl: string; - show_html: boolean = false; - selectedMode: ImageMode; - suggestedModes: string[] = []; - updateModeName: string; - updateModeDescription: string; - updateModeCopy: string; - newModeName: string; - newModeDescription: string; - newModeCopy: string; + isLoaded: boolean = false + alertRed: boolean = false + alertRed_blocked: boolean = false + imageTags: ImageTag[] + imageModes: ImageMode[] + imageLogos: ImageLogo[] + checkedModes: ImageMode[] = [] + blockedImageTags: BlockedImageTag[] + blockedImageTagsResenv: BlockedImageTagResenv[] + checkedBlockedImageTagResenv: string[] = [] + imageTag: string + imageUrl: string + show_html: boolean = false + selectedMode: ImageMode + suggestedModes: string[] = [] + updateModeName: string + updateModeDescription: string + updateModeCopy: string + newModeName: string + newModeDescription: string + newModeCopy: string /** * Facilitties where the user is manager ['name',id]. */ - public managerFacilities: [string, number][]; + public managerFacilities: [string, number][] /** * Chosen facility. */ - public selectedFacility: [string, number]; + public selectedFacility: [string, number] constructor( private imageService: ImageService, private facilityService: FacilityService, - private biocondaService: BiocondaService, + private biocondaService: BiocondaService ) { // constructor for ImageTags } checkMode(mode: ImageMode): void { - const idx: number = this.checkedModes.indexOf(mode); + const idx: number = this.checkedModes.indexOf(mode) if (idx === -1) { - this.checkedModes.push(mode); + this.checkedModes.push(mode) } else { - this.checkedModes.splice(idx, 1); + this.checkedModes.splice(idx, 1) } } checkBlockedTagResenv(mode: string): void { - const idx: number = this.checkedBlockedImageTagResenv.indexOf(mode); + const idx: number = this.checkedBlockedImageTagResenv.indexOf(mode) if (idx === -1) { - this.checkedBlockedImageTagResenv.push(mode); + this.checkedBlockedImageTagResenv.push(mode) } else { - this.checkedBlockedImageTagResenv.splice(idx, 1); + this.checkedBlockedImageTagResenv.splice(idx, 1) } } resenvModeAdded(mode: string): boolean { for (const imageMode of this.imageModes) { if (imageMode.name === mode) { - return true; + return true } } - return false; + return false } reloadData(): void { @@ -96,61 +94,61 @@ export class ImageTagComponent implements OnInit { this.imageService.getImageLogos(), this.imageService.getBlockedImageTags(this.selectedFacility['FacilityId']), this.imageService.getImageModes(this.selectedFacility['FacilityId']), - this.imageService.getBlockedImageTagsResenv(this.selectedFacility['FacilityId']), + this.imageService.getBlockedImageTagsResenv(this.selectedFacility['FacilityId']) ).subscribe((res: any): void => { - this.imageTags = res[0]; - this.imageLogos = res[1]; - this.blockedImageTags = res[2]; - this.imageModes = res[3]; - this.blockedImageTagsResenv = res[4]; - this.isLoaded = true; - }); + this.imageTags = res[0] + this.imageLogos = res[1] + this.blockedImageTags = res[2] + this.imageModes = res[3] + this.blockedImageTagsResenv = res[4] + this.isLoaded = true + }) } ngOnInit(): void { - this.tracker.trackPageView('Image Tags'); + this.tracker.trackPageView('Image Tags') this.facilityService.getManagerFacilities().subscribe((result: any): void => { - this.managerFacilities = result; - this.selectedFacility = this.managerFacilities[0]; - this.getTagModeSuggestions(); + this.managerFacilities = result + this.selectedFacility = this.managerFacilities[0] + this.getTagModeSuggestions() forkJoin( this.imageService.getImageTags(this.selectedFacility['FacilityId']), this.imageService.getImageLogos(), this.imageService.getBlockedImageTags(this.selectedFacility['FacilityId']), this.imageService.getImageModes(this.selectedFacility['FacilityId']), - this.imageService.getBlockedImageTagsResenv(this.selectedFacility['FacilityId']), + this.imageService.getBlockedImageTagsResenv(this.selectedFacility['FacilityId']) ).subscribe((res: any): void => { - this.imageTags = res[0]; - this.imageLogos = res[1]; - this.blockedImageTags = res[2]; - this.imageModes = res[3]; - this.blockedImageTagsResenv = res[4]; - this.isLoaded = true; - }); - }); + this.imageTags = res[0] + this.imageLogos = res[1] + this.blockedImageTags = res[2] + this.imageModes = res[3] + this.blockedImageTagsResenv = res[4] + this.isLoaded = true + }) + }) } imageLogoTagAvailable(): boolean { for (const il of this.imageLogos) { if (il.tag === this.imageTag) { - return true; + return true } } - return false; + return false } addLogoTag(): void { this.imageService.addImageLogos(this.imageTag, this.imageUrl).subscribe((newTag: ImageLogo): void => { - this.imageLogos.push(newTag); - }); + this.imageLogos.push(newTag) + }) } removeLogoTag(logoTag: ImageLogo): void { this.imageService.deleteImageLogoTag(logoTag.id).subscribe((): void => { - const idx: number = this.imageLogos.indexOf(logoTag); - this.imageLogos.splice(idx, 1); - }); + const idx: number = this.imageLogos.indexOf(logoTag) + this.imageLogos.splice(idx, 1) + }) } addTag(tag: string, input: HTMLInputElement): void { @@ -158,12 +156,12 @@ export class ImageTagComponent implements OnInit { this.imageService .addImageTags(tag.trim(), this.checkedModes, this.selectedFacility['FacilityId']) .subscribe((newTag: ImageTag): void => { - this.checkedModes = []; - this.imageTags.push(newTag); - }); - this.alertRed = false; + this.checkedModes = [] + this.imageTags.push(newTag) + }) + this.alertRed = false } else { - this.alertRed = true; + this.alertRed = true } } @@ -171,45 +169,45 @@ export class ImageTagComponent implements OnInit { const newMode: ImageMode = { name: this.newModeName, description: this.newModeDescription, - copy_field: this.newModeCopy, - }; + copy_field: this.newModeCopy + } this.imageService .addImageMode(newMode, this.selectedFacility['FacilityId']) .subscribe((createdMode: ImageMode): void => { - this.newModeName = ''; - this.newModeDescription = ''; - this.newModeCopy = ''; - this.imageModes.push(createdMode); - this.getTagModeSuggestions(); - }); + this.newModeName = '' + this.newModeDescription = '' + this.newModeCopy = '' + this.imageModes.push(createdMode) + this.getTagModeSuggestions() + }) } deleteTag(tag: ImageTag): void { this.imageService.deleteImageTag(tag.id).subscribe((): void => { this.imageService.getImageTags(this.selectedFacility['FacilityId']).subscribe((tags: ImageTag[]): void => { - this.imageTags = tags; - }); - }); + this.imageTags = tags + }) + }) } updateMode(): void { - const idx: number = this.imageModes.indexOf(this.selectedMode); - const update_mode: ImageMode = { ...this.selectedMode }; - update_mode.description = this.updateModeDescription; - update_mode.copy_field = this.updateModeCopy; - update_mode.name = this.updateModeName; + const idx: number = this.imageModes.indexOf(this.selectedMode) + const update_mode: ImageMode = { ...this.selectedMode } + update_mode.description = this.updateModeDescription + update_mode.copy_field = this.updateModeCopy + update_mode.name = this.updateModeName this.imageService.updateImageMode(update_mode).subscribe((updated_mode: ImageMode): void => { - this.imageModes[idx] = updated_mode; - this.getTagModeSuggestions(); - }); + this.imageModes[idx] = updated_mode + this.getTagModeSuggestions() + }) } deleteMode(mode: ImageMode): void { this.imageService.deleteImageMode(mode.id).subscribe((): void => { this.imageService.getImageModes(this.selectedFacility['FacilityId']).subscribe((tags: ImageMode[]): void => { - this.imageModes = tags; - }); - }); + this.imageModes = tags + }) + }) } addBlockedTag(tag: string, input: HTMLInputElement): void { @@ -217,28 +215,28 @@ export class ImageTagComponent implements OnInit { this.imageService .addBlockedImageTag(tag.trim(), this.selectedFacility['FacilityId']) .subscribe((newTag: BlockedImageTag): void => { - this.blockedImageTags.push(newTag); - }); - this.alertRed_blocked = false; + this.blockedImageTags.push(newTag) + }) + this.alertRed_blocked = false } else { - this.alertRed_blocked = true; + this.alertRed_blocked = true } } deleteBlockedTag(tag: string, facility_id: number): void { this.imageService.deleteBlockedImageTag(tag, facility_id).subscribe((): void => { this.imageService.getBlockedImageTags(facility_id).subscribe((tags: BlockedImageTag[]): void => { - this.blockedImageTags = tags; - }); - }); + this.blockedImageTags = tags + }) + }) } getTagModeSuggestions(): void { this.biocondaService .getSuggestedForcTemplates(this.selectedFacility['FacilityId'].toString()) .subscribe((response: any[]): void => { - this.suggestedModes = response.map((template: any): any => template); - }); + this.suggestedModes = response.map((template: any): any => template) + }) } addBlockedTagResenv(tag: string, input: HTMLInputElement): void { @@ -246,16 +244,16 @@ export class ImageTagComponent implements OnInit { this.imageService .addBlockedImageTagResenv(tag.trim(), this.checkedBlockedImageTagResenv, this.selectedFacility['FacilityId']) .subscribe((newTag: BlockedImageTagResenv): void => { - this.blockedImageTagsResenv.push(newTag); - }); + this.blockedImageTagsResenv.push(newTag) + }) } } deleteBlockedTagResenv(tag: string, facility_id: number): void { this.imageService.deleteBlockedImageTagResenv(tag, facility_id).subscribe((): void => { this.imageService.getBlockedImageTagsResenv(facility_id).subscribe((tags: BlockedImageTagResenv[]): void => { - this.blockedImageTagsResenv = tags; - }); - }); + this.blockedImageTagsResenv = tags + }) + }) } } diff --git a/src/app/facility_manager/newsmanagement/news-manager.component.ts b/src/app/facility_manager/newsmanagement/news-manager.component.ts index 143829bd53..fcb16717bc 100644 --- a/src/app/facility_manager/newsmanagement/news-manager.component.ts +++ b/src/app/facility_manager/newsmanagement/news-manager.component.ts @@ -1,70 +1,68 @@ -import { - Component, OnDestroy, OnInit, ViewChild, inject, -} from '@angular/core'; -import { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'; -import { BehaviorSubject, Subscription } from 'rxjs'; -import { ModalDirective } from 'ngx-bootstrap/modal'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { NewsService } from '../../api-connector/news.service'; -import { FacilityService } from '../../api-connector/facility.service'; -import { environment } from '../../../environments/environment'; -import { FacilityNews } from './facility-news'; -import { WIKI_MOTD } from '../../../links/links'; +import { Component, OnDestroy, OnInit, ViewChild, inject } from '@angular/core' +import { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms' +import { BehaviorSubject, Subscription } from 'rxjs' +import { ModalDirective } from 'ngx-bootstrap/modal' +import { MatomoTracker } from 'ngx-matomo-client' +import { NewsService } from '../../api-connector/news.service' +import { FacilityService } from '../../api-connector/facility.service' +import { environment } from '../../../environments/environment' +import { FacilityNews } from './facility-news' +import { WIKI_MOTD } from '../../../links/links' /** * News-Manager Class to manage news in wordPress. */ @Component({ selector: 'app-news-manager', templateUrl: 'news-manager.component.html', - providers: [NewsService, FacilityService], + providers: [NewsService, FacilityService] }) export class NewsManagerComponent implements OnInit, OnDestroy { - private readonly tracker = inject(MatomoTracker); - title: string = 'News Management'; - public production: boolean = environment.production; - WIKI_MOTD: string = WIKI_MOTD; - public managerFacilities: [string, number][]; - public managerFacilitiesIdOnly: number[]; - public selectedFacilities: [string, number][] = []; - public facilityToSetMOTD: number; - public facilityMOTDPairs: { [key: number]: number } = {}; - facilityToPost: number; - returnState: number = -1; - motdChecked: boolean = false; - @ViewChild('infoModal', { static: true }) infoModal: ModalDirective; + private readonly tracker = inject(MatomoTracker) + title: string = 'News Management' + public production: boolean = environment.production + WIKI_MOTD: string = WIKI_MOTD + public managerFacilities: [string, number][] + public managerFacilitiesIdOnly: number[] + public selectedFacilities: [string, number][] = [] + public facilityToSetMOTD: number + public facilityMOTDPairs: { [key: number]: number } = {} + facilityToPost: number + returnState: number = -1 + motdChecked: boolean = false + @ViewChild('infoModal', { static: true }) infoModal: ModalDirective - computeCenters: any[] = []; - facilityNews: FacilityNews[] = []; - newFacilityNews: FacilityNews = new FacilityNews(); - selectedFacilityNews: FacilityNews = new FacilityNews(); + computeCenters: any[] = [] + facilityNews: FacilityNews[] = [] + newFacilityNews: FacilityNews = new FacilityNews() + selectedFacilityNews: FacilityNews = new FacilityNews() - PREDEFINED_TAGS: string[] = ['downtime', 'openstack', 'simplevm', 'maintenance', 'update']; - today: Date = new Date(); + PREDEFINED_TAGS: string[] = ['downtime', 'openstack', 'simplevm', 'maintenance', 'update'] + today: Date = new Date() - newsSetAsMOTD: string[] = []; + newsSetAsMOTD: string[] = [] selectedNewsForm: UntypedFormGroup = new UntypedFormGroup({ title: new UntypedFormControl({ value: this.newFacilityNews.title, disabled: false }, Validators.required), text: new UntypedFormControl({ value: this.newFacilityNews.text, disabled: false }, Validators.required), motd: new UntypedFormControl({ value: this.newFacilityNews.motd, disabled: false }), valid_till: new UntypedFormControl({ value: this.newFacilityNews.valid_till, disabled: false }), - entered_tags: new UntypedFormControl({ value: this.newFacilityNews.tags, disabled: false }), - }); + entered_tags: new UntypedFormControl({ value: this.newFacilityNews.tags, disabled: false }) + }) - allChecked: boolean = true; - deletionStatus: number = 0; - patchingStatus: number = 0; - addingStatus: number = 0; - error_string: string = ''; - reg1: RegExp = /\[/g; - reg2: RegExp = /]/g; - reg3: RegExp = /'/g; - subscription: Subscription = new Subscription(); + allChecked: boolean = true + deletionStatus: number = 0 + patchingStatus: number = 0 + addingStatus: number = 0 + error_string: string = '' + reg1: RegExp = /\[/g + reg2: RegExp = /]/g + reg3: RegExp = /'/g + subscription: Subscription = new Subscription() - public motdLength: BehaviorSubject = new BehaviorSubject(0); + public motdLength: BehaviorSubject = new BehaviorSubject(0) constructor( private newsService: NewsService, - private facilityService: FacilityService, + private facilityService: FacilityService ) { // constructor for NewsManager } @@ -73,56 +71,56 @@ export class NewsManagerComponent implements OnInit, OnDestroy { * Method on site initialization. */ ngOnInit(): void { - this.tracker.trackPageView('News Management'); + this.tracker.trackPageView('News Management') this.subscription.add( this.facilityService.getComputeCenters().subscribe((computeCenters: any[]): void => { - this.computeCenters = computeCenters; + this.computeCenters = computeCenters this.subscription.add( this.facilityService.getManagerFacilities().subscribe((result: any): void => { - this.managerFacilities = result; + this.managerFacilities = result this.selectedFacilities = this.managerFacilities.map( - (facility: [string, number]): [string, number] => facility, - ); + (facility: [string, number]): [string, number] => facility + ) this.managerFacilitiesIdOnly = this.managerFacilities.map( - (facility: [string, number]): number => facility['FacilityId'], - ); - this.setFormGroup(); - this.getNewsFromAPI(); - this.setCurrentNews(null); - }), - ); - }), - ); + (facility: [string, number]): number => facility['FacilityId'] + ) + this.setFormGroup() + this.getNewsFromAPI() + this.setCurrentNews(null) + }) + ) + }) + ) } setFacilityToSetMotd(event: any = null): void { if (event) { - this.motdChecked = event?.target.checked; + this.motdChecked = event?.target.checked } - const facilit_checkbox: HTMLElement | null = document.getElementById(`news_select_${this.facilityToPost}_motd`); + const facilit_checkbox: HTMLElement | null = document.getElementById(`news_select_${this.facilityToPost}_motd`) if (facilit_checkbox && facilit_checkbox['checked']) { - this.facilityToSetMOTD = this.facilityToPost; + this.facilityToSetMOTD = this.facilityToPost } else { - this.facilityToSetMOTD = null; + this.facilityToSetMOTD = null } } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } addNewsToAPI(bare_news: FacilityNews): void { - const news: FacilityNews = bare_news; - news.title = this.selectedNewsForm.controls['title'].value; - news.text = this.selectedNewsForm.controls['text'].value; - news.motd = this.selectedNewsForm.controls['motd'].value; - news.valid_till = this.selectedNewsForm.controls['valid_till'].value; - news.facility = this.facilityToPost; - news.tags = this.selectedFacilityNews.tags; + const news: FacilityNews = bare_news + news.title = this.selectedNewsForm.controls['title'].value + news.text = this.selectedNewsForm.controls['text'].value + news.motd = this.selectedNewsForm.controls['motd'].value + news.valid_till = this.selectedNewsForm.controls['valid_till'].value + news.facility = this.facilityToPost + news.tags = this.selectedFacilityNews.tags if (document.getElementById(`news_select_${this.facilityToPost}_motd`)['checked']) { - this.facilityToSetMOTD = this.facilityToPost; + this.facilityToSetMOTD = this.facilityToPost } else { - this.facilityToSetMOTD = null; + this.facilityToSetMOTD = null } this.subscription.add( @@ -130,112 +128,114 @@ export class NewsManagerComponent implements OnInit, OnDestroy { (result: any): void => { if (result) { if (result['id']) { - if (this.facilityToSetMOTD != null) { + if (this.facilityToSetMOTD !== null) { this.subscription.add( this.newsService.updateFacilityMOTD(result['id'], this.facilityToSetMOTD).subscribe( (): void => {}, (error: any) => { - console.log(error); + console.log(error) if ('error' in error) { - this.error_string = error['error']['error']; + this.error_string = error['error']['error'] } - }, - ), - ); + } + ) + ) } - this.returnState = 2; - this.infoModal.show(); + this.returnState = 2 + this.infoModal.show() } } - this.getNewsFromAPI(); - this.setCurrentNews(null); + this.getNewsFromAPI() + this.setCurrentNews(null) }, (error: any) => { - console.log(error); - this.returnState = -1; - this.infoModal.show(); + console.log(error) + this.returnState = -1 + this.infoModal.show() if ('error' in error) { - this.error_string = error['error']['error']; + this.error_string = error['error']['error'] } - this.getNewsFromAPI(); - }, - ), - ); + this.getNewsFromAPI() + } + ) + ) } updateNewsInAPI(bare_news: FacilityNews): void { - const news: FacilityNews = bare_news; - news.title = this.selectedNewsForm.controls['title'].value; - news.text = this.selectedNewsForm.controls['text'].value; - news.motd = this.selectedNewsForm.controls['motd'].value; - news.valid_till = this.selectedNewsForm.controls['valid_till'].value; - news.facility = this.facilityToPost; - news.tags = this.selectedFacilityNews.tags; + const news: FacilityNews = bare_news + news.title = this.selectedNewsForm.controls['title'].value + news.text = this.selectedNewsForm.controls['text'].value + news.motd = this.selectedNewsForm.controls['motd'].value + news.valid_till = this.selectedNewsForm.controls['valid_till'].value + news.facility = this.facilityToPost + news.tags = this.selectedFacilityNews.tags if (document.getElementById(`news_select_${this.facilityToPost}_motd`)['checked']) { - this.facilityToSetMOTD = this.facilityToPost; - news.is_current_motd = true; + this.facilityToSetMOTD = this.facilityToPost + news.is_current_motd = true } else { - this.facilityToSetMOTD = null; - news.is_current_motd = false; + this.facilityToSetMOTD = null + news.is_current_motd = false } this.subscription.add( this.newsService.updateFacilityNews(news).subscribe( (result: any): void => { if (result) { if (result['id']) { - if (this.facilityToSetMOTD != null) { + if (this.facilityToSetMOTD !== null) { this.subscription.add( this.newsService.updateFacilityMOTD(result['id'], this.facilityToSetMOTD).subscribe( (): void => {}, (error: any) => { - console.log(error); + console.log(error) if ('error' in error) { - this.error_string = error['error']['error']; + this.error_string = error['error']['error'] } - }, - ), - ); + } + ) + ) } - this.returnState = 2; - this.infoModal.show(); + this.returnState = 2 + this.infoModal.show() } } - this.getNewsFromAPI(); + this.getNewsFromAPI() }, (error: any) => { - console.log(error); - this.returnState = -1; - this.infoModal.show(); + console.log(error) + this.returnState = -1 + this.infoModal.show() if ('error' in error) { - this.error_string = error['error']['error']; + this.error_string = error['error']['error'] } - this.getNewsFromAPI(); - }, - ), - ); + this.getNewsFromAPI() + } + ) + ) } getFacilitiesFromWagtail(): void { - this.facilityMOTDPairs = []; + this.facilityMOTDPairs = [] this.subscription.add( this.newsService.getFacilitiesFromWagtail().subscribe((facilities: any[]): void => { for (const facility of facilities) { - this.facilityMOTDPairs[facility['id']] = facility['motd']; + this.facilityMOTDPairs[facility['id']] = facility['motd'] } - }), - ); + }) + ) } getNewsFromAPI(): void { - this.facilityNews = []; - const facility_ids: string[] = this.selectedFacilities.map((facility: [string, number]): string => facility['FacilityId'].toString()); + this.facilityNews = [] + const facility_ids: string[] = this.selectedFacilities.map((facility: [string, number]): string => + facility['FacilityId'].toString() + ) this.subscription.add( this.newsService.getFacilityNews(facility_ids.toString()).subscribe((result: FacilityNews[]): any => { - this.facilityNews = result; - }), - ); - this.getFacilitiesFromWagtail(); + this.facilityNews = result + }) + ) + this.getFacilitiesFromWagtail() } /** @@ -243,13 +243,13 @@ export class NewsManagerComponent implements OnInit, OnDestroy { */ selectAllFacilities(): void { if (this.selectedFacilities.length === this.managerFacilities.length) { - this.selectedFacilities = []; - this.allChecked = false; + this.selectedFacilities = [] + this.allChecked = false } else { - this.selectedFacilities = this.managerFacilities.map((facility: [string, number]): [string, number] => facility); - this.allChecked = true; + this.selectedFacilities = this.managerFacilities.map((facility: [string, number]): [string, number] => facility) + this.allChecked = true } - this.getNewsFromAPI(); + this.getNewsFromAPI() } /** @@ -258,36 +258,36 @@ export class NewsManagerComponent implements OnInit, OnDestroy { * @param facility the facility which gets added/deleted */ selectFacility(facility: [string, number]): void { - const index: number = this.selectedFacilities.indexOf(facility); + const index: number = this.selectedFacilities.indexOf(facility) if (index === -1) { - this.selectedFacilities.push(facility); + this.selectedFacilities.push(facility) } else { - this.selectedFacilities.splice(index, 1); + this.selectedFacilities.splice(index, 1) } if (this.selectedFacilities.length === 0) { - this.setCurrentNews(); + this.setCurrentNews() } - this.allChecked = this.selectedFacilities.length === this.managerFacilities.length; - this.getNewsFromAPI(); + this.allChecked = this.selectedFacilities.length === this.managerFacilities.length + this.getNewsFromAPI() } setCurrentNews(news?: FacilityNews): void { - this.facilityToPost = null; - this.facilityToSetMOTD = null; + this.facilityToPost = null + this.facilityToSetMOTD = null if (news) { - this.selectedFacilityNews = news; - this.facilityToPost = news.facility; + this.selectedFacilityNews = news + this.facilityToPost = news.facility } else { - this.selectedFacilityNews = new FacilityNews(); - this.selectedFacilityNews.id = null; + this.selectedFacilityNews = new FacilityNews() + this.selectedFacilityNews.id = null } if (this.selectedFacilityNews.is_current_motd) { - this.motdChecked = true; + this.motdChecked = true } else { - this.motdChecked = false; + this.motdChecked = false } - this.setFormGroup(); - this.setFacilityToSetMotd(); + this.setFormGroup() + this.setFacilityToSetMotd() } /** @@ -297,19 +297,19 @@ export class NewsManagerComponent implements OnInit, OnDestroy { * @param news the news for which the string shall be returned */ facilitiesAsString(news: FacilityNews): string { - const newsId: string = news.id.toString(); + const newsId: string = news.id.toString() if (this.newsSetAsMOTD.includes(newsId)) { - let facilitiesString: string = ''; + let facilitiesString: string = '' this.computeCenters.forEach((facility: any): void => { if (newsId.localeCompare(facility['compute_center_motd_id']) === 0) { - const temp_string: string = `${facility['compute_center_name']}, `; - facilitiesString += temp_string; + const temp_string: string = `${facility['compute_center_name']}, ` + facilitiesString += temp_string } - }); + }) - return facilitiesString.substring(0, facilitiesString.length - 2); + return facilitiesString.substring(0, facilitiesString.length - 2) } else { - return ''; + return '' } } @@ -319,15 +319,15 @@ export class NewsManagerComponent implements OnInit, OnDestroy { * @param news the news which get's checked */ listNewsSetAsMOTD(): void { - this.newsSetAsMOTD = []; + this.newsSetAsMOTD = [] this.computeCenters.forEach((facility: any): void => { - const motd_string: string = facility['compute_center_motd_id']; + const motd_string: string = facility['compute_center_motd_id'] if (!this.newsSetAsMOTD.includes(motd_string)) { if (motd_string !== '-1') { - this.newsSetAsMOTD.push(motd_string); + this.newsSetAsMOTD.push(motd_string) } } - }); + }) } /** @@ -340,13 +340,13 @@ export class NewsManagerComponent implements OnInit, OnDestroy { motd: new UntypedFormControl({ value: this.selectedFacilityNews.motd, disabled: false }), tag: new UntypedFormControl({ value: this.selectedFacilityNews.tags, disabled: false }), valid_till: new UntypedFormControl({ value: this.selectedFacilityNews.valid_till, disabled: false }), - entered_tags: new UntypedFormControl({ value: this.selectedFacilityNews.tags, disabled: false }), - }); + entered_tags: new UntypedFormControl({ value: this.selectedFacilityNews.tags, disabled: false }) + }) this.subscription.add( this.selectedNewsForm.controls['motd'].valueChanges.subscribe((value: any): void => { - this.motdLength.next(value.length); - }), - ); + this.motdLength.next(value.length) + }) + ) } /** @@ -355,27 +355,27 @@ export class NewsManagerComponent implements OnInit, OnDestroy { * @param facility the facility which gets added/deleted */ setFacility(facility: [string, number]): void { - this.facilityToPost = facility['FacilityId']; + this.facilityToPost = facility['FacilityId'] } deleteNewsFromAPI(): void { this.subscription.add( this.newsService.deleteNewsFromAPI(this.selectedFacilityNews.id).subscribe( (): void => { - this.returnState = 0; - this.infoModal.show(); - this.getNewsFromAPI(); + this.returnState = 0 + this.infoModal.show() + this.getNewsFromAPI() }, (error: any) => { - console.log(error); - this.returnState = -1; - this.infoModal.show(); + console.log(error) + this.returnState = -1 + this.infoModal.show() if ('error' in error) { - this.error_string = error['error']['error']; + this.error_string = error['error']['error'] } - this.getNewsFromAPI(); - }, - ), - ); + this.getNewsFromAPI() + } + ) + ) } } diff --git a/src/app/facility_manager/resources/generalstoragefactor-overview/generalstoragefactor-overview.component.ts b/src/app/facility_manager/resources/generalstoragefactor-overview/generalstoragefactor-overview.component.ts index 03cd5ceda6..7c9e0e1840 100644 --- a/src/app/facility_manager/resources/generalstoragefactor-overview/generalstoragefactor-overview.component.ts +++ b/src/app/facility_manager/resources/generalstoragefactor-overview/generalstoragefactor-overview.component.ts @@ -1,8 +1,6 @@ -import { - Component, EventEmitter, Input, OnInit, Output, -} from '@angular/core'; -import { FacilityService } from '../../../api-connector/facility.service'; -import { GeneralStorageFactor } from '../general-storage-factor'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' +import { FacilityService } from '../../../api-connector/facility.service' +import { GeneralStorageFactor } from '../general-storage-factor' /** * Class for GeneralStorageFactor. @@ -10,85 +8,83 @@ import { GeneralStorageFactor } from '../general-storage-factor'; @Component({ selector: 'app-generalstoragefactor-overview', templateUrl: './generalstoragefactor-overview.component.html', - providers: [FacilityService], - + providers: [FacilityService] }) export class GeneralstoragefactorOverviewComponent implements OnInit { - generalStorageFactors: GeneralStorageFactor[]; - @Input() facility_id: number; - @Output() readonly factorChanged: EventEmitter = new EventEmitter(); + generalStorageFactors: GeneralStorageFactor[] + @Input() facility_id: number + @Output() readonly factorChanged: EventEmitter = new EventEmitter() - newFactor: GeneralStorageFactor; - storageUpdateList: { [id: string]: boolean } = {}; + newFactor: GeneralStorageFactor + storageUpdateList: { [id: string]: boolean } = {} constructor(private facilityService: FacilityService) { - this.facilityService = facilityService; + this.facilityService = facilityService } ngOnInit(): void { - this.getGeneralStorageFactors(); - this.newFactor = new GeneralStorageFactor(null); - + this.getGeneralStorageFactors() + this.newFactor = new GeneralStorageFactor(null) } getGeneralStorageFactors(): void { this.facilityService.getGeneralStorageFactors(this.facility_id).subscribe((res: GeneralStorageFactor[]): void => { - this.generalStorageFactors = res; + this.generalStorageFactors = res this.generalStorageFactors.sort((a_factor: GeneralStorageFactor, b_factor: GeneralStorageFactor): number => { if (a_factor.storage > b_factor.storage) { - return 1; + return 1 } else if (a_factor.storage === b_factor.storage) { - return 0; + return 0 } else { - return -1; + return -1 } - - }); + }) this.generalStorageFactors.forEach((vF: GeneralStorageFactor): void => { - this.storageUpdateList[vF.id] = false; - }); - }); + this.storageUpdateList[vF.id] = false + }) + }) } deleteGeneralStorageFactor(id: string | number): void { - this.facilityService.deleteGeneralStorageFactor(this.facility_id, id).subscribe((res: GeneralStorageFactor[]): void => { - this.generalStorageFactors = res; - this.factorChanged.emit(); - - }); + this.facilityService + .deleteGeneralStorageFactor(this.facility_id, id) + .subscribe((res: GeneralStorageFactor[]): void => { + this.generalStorageFactors = res + this.factorChanged.emit() + }) } changeStorageToUpdate(vF: GeneralStorageFactor): void { - this.storageUpdateList[vF.id] = !this.storageUpdateList[vF.id]; + this.storageUpdateList[vF.id] = !this.storageUpdateList[vF.id] } reloadGeneralStorageFactor(vF: GeneralStorageFactor): void { - this.facilityService.getGeneralStorageFactor(this.facility_id, vF.id).subscribe((volumeFactor: GeneralStorageFactor): void => { - this.generalStorageFactors[this.generalStorageFactors.indexOf(vF)] = new GeneralStorageFactor(volumeFactor); - }); + this.facilityService + .getGeneralStorageFactor(this.facility_id, vF.id) + .subscribe((volumeFactor: GeneralStorageFactor): void => { + this.generalStorageFactors[this.generalStorageFactors.indexOf(vF)] = new GeneralStorageFactor(volumeFactor) + }) } addGeneralStorageFactor(): void { - - this.facilityService.addGeneralStorageFactor(this.facility_id, this.newFactor).subscribe((res: GeneralStorageFactor[]): void => { - this.newFactor = new GeneralStorageFactor(null); - this.generalStorageFactors = res; - this.generalStorageFactors.forEach((vF: GeneralStorageFactor): void => { - this.storageUpdateList[vF.id] = false; - }); - this.factorChanged.emit(); - }); - + this.facilityService + .addGeneralStorageFactor(this.facility_id, this.newFactor) + .subscribe((res: GeneralStorageFactor[]): void => { + this.newFactor = new GeneralStorageFactor(null) + this.generalStorageFactors = res + this.generalStorageFactors.forEach((vF: GeneralStorageFactor): void => { + this.storageUpdateList[vF.id] = false + }) + this.factorChanged.emit() + }) } updateGeneralStorageFactor(vf: GeneralStorageFactor): void { - - this.facilityService.updateGeneralStorageFactor(this.facility_id, vf).subscribe((volumeFactor: GeneralStorageFactor): void => { - this.generalStorageFactors[this.generalStorageFactors.indexOf(vf)] = new GeneralStorageFactor(volumeFactor); - this.factorChanged.emit(); - - }); - + this.facilityService + .updateGeneralStorageFactor(this.facility_id, vf) + .subscribe((volumeFactor: GeneralStorageFactor): void => { + this.generalStorageFactors[this.generalStorageFactors.indexOf(vf)] = new GeneralStorageFactor(volumeFactor) + this.factorChanged.emit() + }) } - } diff --git a/src/app/facility_manager/resources/gpu-specification-overview/gpu-specification-overview.component.ts b/src/app/facility_manager/resources/gpu-specification-overview/gpu-specification-overview.component.ts index ec72fd7ac9..c351ea459b 100644 --- a/src/app/facility_manager/resources/gpu-specification-overview/gpu-specification-overview.component.ts +++ b/src/app/facility_manager/resources/gpu-specification-overview/gpu-specification-overview.component.ts @@ -1,11 +1,7 @@ -import { - Component, EventEmitter, Input, OnInit, Output, -} from '@angular/core'; -import { - UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators, -} from '@angular/forms'; -import { FacilityService } from '../../../api-connector/facility.service'; -import { GPUSpecification } from '../gpu-specification'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' +import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms' +import { FacilityService } from '../../../api-connector/facility.service' +import { GPUSpecification } from '../gpu-specification' /** * Class for GPU-Specifications @@ -13,157 +9,157 @@ import { GPUSpecification } from '../gpu-specification'; @Component({ selector: 'app-gpu-specification-overview', templateUrl: './gpu-specification-overview.component.html', - providers: [FacilityService], + providers: [FacilityService] }) export class GPUSpecificationOverviewComponent implements OnInit { - gpuSpecifications: GPUSpecification[]; - newGPUSpecification: GPUSpecification; - newGPUFormGroup: UntypedFormGroup; - formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); - gpuFormGroups: { [id: string]: UntypedFormGroup } = {}; + gpuSpecifications: GPUSpecification[] + newGPUSpecification: GPUSpecification + newGPUFormGroup: UntypedFormGroup + formBuilder: UntypedFormBuilder = new UntypedFormBuilder() + gpuFormGroups: { [id: string]: UntypedFormGroup } = {} - @Input() facility_id: number; - @Output() readonly factorChanged: EventEmitter = new EventEmitter(); + @Input() facility_id: number + @Output() readonly factorChanged: EventEmitter = new EventEmitter() - gpuSpecificationUpdateList: { [id: string]: boolean } = {}; + gpuSpecificationUpdateList: { [id: string]: boolean } = {} constructor(private facilityService: FacilityService) { - this.facilityService = facilityService; + this.facilityService = facilityService } ngOnInit(): void { - this.getGPUSpecifications(); - this.newGPUSpecification = new GPUSpecification(null); + this.getGPUSpecifications() + this.newGPUSpecification = new GPUSpecification(null) this.newGPUFormGroup = this.formBuilder.group({ new_gpu_type: [null, Validators.compose([Validators.required, Validators.pattern(/^(([a-zA-Z0-9])+\s?)*$/)])], new_gpu_cores: [null, Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])], - new_gpu_ram: [0, Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])], - }); - this.listenToChangesForNewGPUs(); + new_gpu_ram: [0, Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])] + }) + this.listenToChangesForNewGPUs() } listenToChangesForNewGPUs(): void { this.newGPUFormGroup.get('new_gpu_type').valueChanges.subscribe((val: string): void => { - this.newGPUSpecification.type = val; - }); + this.newGPUSpecification.type = val + }) this.newGPUFormGroup.get('new_gpu_ram').valueChanges.subscribe((val: number): void => { - this.newGPUSpecification.ram = val; - }); + this.newGPUSpecification.ram = val + }) this.newGPUFormGroup.get('new_gpu_cores').valueChanges.subscribe((val: number): void => { - this.newGPUSpecification.cores = val; - }); + this.newGPUSpecification.cores = val + }) } getGPUSpecifications(): void { this.facilityService.getGPUSpecifications(this.facility_id).subscribe((gpus: GPUSpecification[]): void => { - this.gpuSpecifications = gpus.map((gpu: GPUSpecification): GPUSpecification => new GPUSpecification(gpu)); + this.gpuSpecifications = gpus.map((gpu: GPUSpecification): GPUSpecification => new GPUSpecification(gpu)) this.gpuSpecifications.forEach((gpu: GPUSpecification): void => { - this.gpuSpecificationUpdateList[gpu.id] = false; - this.setupFormGroup(gpu); - }); - }); + this.gpuSpecificationUpdateList[gpu.id] = false + this.setupFormGroup(gpu) + }) + }) } setupFormGroup(gpu: GPUSpecification): void { - this.gpuFormGroups[gpu.id] = this.formBuilder.group({}); - const gpu_ram: string = `${gpu.id}_ram`; - const gpu_type: string = `${gpu.id}_type`; - const gpu_cores: string = `${gpu.id}_cores`; + this.gpuFormGroups[gpu.id] = this.formBuilder.group({}) + const gpu_ram: string = `${gpu.id}_ram` + const gpu_type: string = `${gpu.id}_type` + const gpu_cores: string = `${gpu.id}_cores` - this.gpuFormGroups[gpu.id].addControl(gpu_ram, new UntypedFormControl([null])); + this.gpuFormGroups[gpu.id].addControl(gpu_ram, new UntypedFormControl([null])) this.gpuFormGroups[gpu.id] .get(gpu_ram) - .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]); - this.gpuFormGroups[gpu.id].addControl(gpu_type, new UntypedFormControl([null])); + .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]) + this.gpuFormGroups[gpu.id].addControl(gpu_type, new UntypedFormControl([null])) this.gpuFormGroups[gpu.id] .get(gpu_type) - .setValidators([Validators.compose([Validators.required, Validators.pattern(/^([A-Za-z0-9]+[ ]*)+$/)])]); + .setValidators([Validators.compose([Validators.required, Validators.pattern(/^([A-Za-z0-9]+[ ]*)+$/)])]) - this.gpuFormGroups[gpu.id].addControl(gpu_cores, new UntypedFormControl([null])); + this.gpuFormGroups[gpu.id].addControl(gpu_cores, new UntypedFormControl([null])) this.gpuFormGroups[gpu.id] .get(gpu_cores) - .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]); + .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]) - this.gpuFormGroups[gpu.id].get(gpu_ram).setValue(gpu.ram); - this.gpuFormGroups[gpu.id].get(gpu_type).setValue(gpu.type); - this.gpuFormGroups[gpu.id].get(gpu_cores).setValue(gpu.cores); - this.gpuFormGroups[gpu.id].disable(); + this.gpuFormGroups[gpu.id].get(gpu_ram).setValue(gpu.ram) + this.gpuFormGroups[gpu.id].get(gpu_type).setValue(gpu.type) + this.gpuFormGroups[gpu.id].get(gpu_cores).setValue(gpu.cores) + this.gpuFormGroups[gpu.id].disable() } deleteGPUSpecification(id: string | number): void { this.facilityService.deleteGPUSpecification(this.facility_id, id).subscribe((gpus: GPUSpecification[]): void => { - this.gpuFormGroups = {}; + this.gpuFormGroups = {} gpus.forEach((gpu: GPUSpecification): void => { - this.setupFormGroup(gpu); - }); - this.gpuSpecifications = gpus.map((gpu: GPUSpecification): GPUSpecification => new GPUSpecification(gpu)); - this.factorChanged.emit(); - }); + this.setupFormGroup(gpu) + }) + this.gpuSpecifications = gpus.map((gpu: GPUSpecification): GPUSpecification => new GPUSpecification(gpu)) + this.factorChanged.emit() + }) } changeGPUSpecificationToUpdate(gpu: GPUSpecification): void { if (this.gpuSpecificationUpdateList[gpu.id]) { - this.gpuFormGroups[gpu.id].disable(); + this.gpuFormGroups[gpu.id].disable() } else { - this.listenToChangesForGPU(gpu); - this.gpuFormGroups[gpu.id].enable(); + this.listenToChangesForGPU(gpu) + this.gpuFormGroups[gpu.id].enable() } - this.gpuSpecificationUpdateList[gpu.id] = !this.gpuSpecificationUpdateList[gpu.id]; + this.gpuSpecificationUpdateList[gpu.id] = !this.gpuSpecificationUpdateList[gpu.id] } listenToChangesForGPU(gpu: GPUSpecification) { this.gpuFormGroups[gpu.id].get(`${gpu.id}_ram`).valueChanges.subscribe((val: number): void => { - gpu.ram = val; - }); + gpu.ram = val + }) this.gpuFormGroups[gpu.id].get(`${gpu.id}_type`).valueChanges.subscribe((val: string): void => { - gpu.type = val; - }); + gpu.type = val + }) this.gpuFormGroups[gpu.id].get(`${gpu.id}_cores`).valueChanges.subscribe((val: number): void => { - gpu.cores = val; - }); + gpu.cores = val + }) } reloadGPUSpecification(gpu: GPUSpecification): void { this.facilityService.getGPUSpecification(this.facility_id, gpu.id).subscribe((fs_gpu: GPUSpecification): void => { - this.gpuSpecifications[this.gpuSpecifications.indexOf(gpu)] = new GPUSpecification(fs_gpu); - this.reloadGPUForm(fs_gpu); - }); + this.gpuSpecifications[this.gpuSpecifications.indexOf(gpu)] = new GPUSpecification(fs_gpu) + this.reloadGPUForm(fs_gpu) + }) } reloadGPUForm(gpu: GPUSpecification): void { - const gpu_ram: string = `${gpu.id}_ram`; - const gpu_type: string = `${gpu.id}_type`; - const gpu_cores: string = `${gpu.id}_cores`; - this.gpuFormGroups[gpu.id].get(gpu_ram).setValue(gpu.ram); - this.gpuFormGroups[gpu.id].get(gpu_type).setValue(gpu.type); - this.gpuFormGroups[gpu.id].get(gpu_cores).setValue(gpu.cores); - - this.gpuFormGroups[gpu.id].disable(); + const gpu_ram: string = `${gpu.id}_ram` + const gpu_type: string = `${gpu.id}_type` + const gpu_cores: string = `${gpu.id}_cores` + this.gpuFormGroups[gpu.id].get(gpu_ram).setValue(gpu.ram) + this.gpuFormGroups[gpu.id].get(gpu_type).setValue(gpu.type) + this.gpuFormGroups[gpu.id].get(gpu_cores).setValue(gpu.cores) + + this.gpuFormGroups[gpu.id].disable() } addGPUSpecification(): void { - this.newGPUSpecification.type = this.newGPUSpecification.type.trim(); + this.newGPUSpecification.type = this.newGPUSpecification.type.trim() this.facilityService .addGPUSpecification(this.facility_id, this.newGPUSpecification) .subscribe((res: GPUSpecification[]): void => { - this.newGPUSpecification = new GPUSpecification(null); + this.newGPUSpecification = new GPUSpecification(null) res.forEach((gpu: GPUSpecification): void => { - this.setupFormGroup(gpu); - }); - this.gpuSpecifications = res.map((gpu: GPUSpecification): GPUSpecification => new GPUSpecification(gpu)); + this.setupFormGroup(gpu) + }) + this.gpuSpecifications = res.map((gpu: GPUSpecification): GPUSpecification => new GPUSpecification(gpu)) this.gpuSpecifications.forEach((rf: GPUSpecification): void => { - this.gpuSpecificationUpdateList[rf.id] = false; - }); - this.factorChanged.emit(); - }); + this.gpuSpecificationUpdateList[rf.id] = false + }) + this.factorChanged.emit() + }) } updateGPUSpecification(gpu: GPUSpecification): void { - gpu.type = gpu.type.trim(); + gpu.type = gpu.type.trim() this.facilityService.updateGPUSpecification(this.facility_id, gpu).subscribe((machine: GPUSpecification): void => { - this.gpuSpecifications[this.gpuSpecifications.indexOf(gpu)] = machine; - this.setupFormGroup(gpu); - this.factorChanged.emit(); - }); + this.gpuSpecifications[this.gpuSpecifications.indexOf(gpu)] = machine + this.setupFormGroup(gpu) + this.factorChanged.emit() + }) } } diff --git a/src/app/facility_manager/resources/objectstoragefactor-overview/objectstoragefactor-overview.component.ts b/src/app/facility_manager/resources/objectstoragefactor-overview/objectstoragefactor-overview.component.ts index f11c26362d..aefd66a912 100644 --- a/src/app/facility_manager/resources/objectstoragefactor-overview/objectstoragefactor-overview.component.ts +++ b/src/app/facility_manager/resources/objectstoragefactor-overview/objectstoragefactor-overview.component.ts @@ -1,8 +1,6 @@ -import { - Component, EventEmitter, Input, OnInit, Output, -} from '@angular/core'; -import { ObjectStorageFactor } from '../object-storage-factor'; -import { FacilityService } from '../../../api-connector/facility.service'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' +import { ObjectStorageFactor } from '../object-storage-factor' +import { FacilityService } from '../../../api-connector/facility.service' /** * Class for objectfactors. @@ -10,86 +8,83 @@ import { FacilityService } from '../../../api-connector/facility.service'; @Component({ selector: 'app-objectstoragefactor-overview', templateUrl: './objectstoragefactor-overview.component.html', - providers: [FacilityService], - + providers: [FacilityService] }) export class ObjectstoragefactorOverviewComponent implements OnInit { - objectStorageFactors: ObjectStorageFactor[]; - newFactor: ObjectStorageFactor; - @Input() facility_id: number; - @Output() readonly factorChanged: EventEmitter = new EventEmitter(); + objectStorageFactors: ObjectStorageFactor[] + newFactor: ObjectStorageFactor + @Input() facility_id: number + @Output() readonly factorChanged: EventEmitter = new EventEmitter() - objectUpdateList: { [id: string]: boolean } = {}; + objectUpdateList: { [id: string]: boolean } = {} constructor(private facilityService: FacilityService) { - this.facilityService = facilityService; + this.facilityService = facilityService } ngOnInit(): void { - this.getObjectStorageFactors(); - this.newFactor = new ObjectStorageFactor(null); - + this.getObjectStorageFactors() + this.newFactor = new ObjectStorageFactor(null) } getObjectStorageFactors(): void { this.facilityService.getObjectStorageFactors(this.facility_id).subscribe((res: ObjectStorageFactor[]): void => { - this.objectStorageFactors = res; + this.objectStorageFactors = res this.objectStorageFactors.sort((a_factor: ObjectStorageFactor, b_factor: ObjectStorageFactor): number => { if (a_factor.storage > b_factor.storage) { - return 1; + return 1 } else if (a_factor.storage === b_factor.storage) { - return 0; + return 0 } else { - return -1; + return -1 } - - }); + }) this.objectStorageFactors.forEach((objectStorageFactor: ObjectStorageFactor): void => { - this.objectUpdateList[objectStorageFactor.id] = false; - }); - }); + this.objectUpdateList[objectStorageFactor.id] = false + }) + }) } deleteObjectStorageFactor(id: string | number): void { - this.facilityService.deleteObjectStorageFactor(this.facility_id, id).subscribe((res: ObjectStorageFactor[]): void => { - this.objectStorageFactors = res; - this.factorChanged.emit(); - - }); + this.facilityService + .deleteObjectStorageFactor(this.facility_id, id) + .subscribe((res: ObjectStorageFactor[]): void => { + this.objectStorageFactors = res + this.factorChanged.emit() + }) } changeObjectStorageToUpdate(objectStorageFactor: ObjectStorageFactor): void { - this.objectUpdateList[objectStorageFactor.id] = !this.objectUpdateList[objectStorageFactor.id]; + this.objectUpdateList[objectStorageFactor.id] = !this.objectUpdateList[objectStorageFactor.id] } reloadObjectStorageFactor(of: ObjectStorageFactor): void { - this.facilityService.getObjectStorageFactor(this.facility_id, of.id).subscribe((objectStorageFactor: ObjectStorageFactor): void => { - this.objectStorageFactors[this.objectStorageFactors.indexOf(of)] = new ObjectStorageFactor(objectStorageFactor); - }); + this.facilityService + .getObjectStorageFactor(this.facility_id, of.id) + .subscribe((objectStorageFactor: ObjectStorageFactor): void => { + this.objectStorageFactors[this.objectStorageFactors.indexOf(of)] = new ObjectStorageFactor(objectStorageFactor) + }) } addObjectStorageFactor(): void { - - this.facilityService.addObjectStorageFactor(this.facility_id, this.newFactor).subscribe((res: ObjectStorageFactor[]): void => { - this.newFactor = new ObjectStorageFactor(null); - this.objectStorageFactors = res; - this.objectStorageFactors.forEach((objectStorageFactor: ObjectStorageFactor): void => { - this.objectUpdateList[objectStorageFactor.id] = false; - }); - this.factorChanged.emit(); - - }); - + this.facilityService + .addObjectStorageFactor(this.facility_id, this.newFactor) + .subscribe((res: ObjectStorageFactor[]): void => { + this.newFactor = new ObjectStorageFactor(null) + this.objectStorageFactors = res + this.objectStorageFactors.forEach((objectStorageFactor: ObjectStorageFactor): void => { + this.objectUpdateList[objectStorageFactor.id] = false + }) + this.factorChanged.emit() + }) } updateObjectStorageFactor(of: ObjectStorageFactor): void { - - this.facilityService.updateObjectStorageFactor(this.facility_id, of).subscribe((objectStorageFactor: ObjectStorageFactor): void => { - this.objectStorageFactors[this.objectStorageFactors.indexOf(of)] = new ObjectStorageFactor(objectStorageFactor); - - }); - this.factorChanged.emit(); - + this.facilityService + .updateObjectStorageFactor(this.facility_id, of) + .subscribe((objectStorageFactor: ObjectStorageFactor): void => { + this.objectStorageFactors[this.objectStorageFactors.indexOf(of)] = new ObjectStorageFactor(objectStorageFactor) + }) + this.factorChanged.emit() } - } diff --git a/src/app/facility_manager/resources/resourcemachine-overview/resourcemachine-overview.component.ts b/src/app/facility_manager/resources/resourcemachine-overview/resourcemachine-overview.component.ts index 668327eeae..36ec8f442a 100644 --- a/src/app/facility_manager/resources/resourcemachine-overview/resourcemachine-overview.component.ts +++ b/src/app/facility_manager/resources/resourcemachine-overview/resourcemachine-overview.component.ts @@ -1,12 +1,8 @@ -import { - Component, EventEmitter, Input, OnInit, Output, -} from '@angular/core'; -import { - UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators, -} from '@angular/forms'; -import { FacilityService } from '../../../api-connector/facility.service'; -import { ResourceMachine } from '../resource-machine'; -import { GPUSpecification } from '../gpu-specification'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' +import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms' +import { FacilityService } from '../../../api-connector/facility.service' +import { ResourceMachine } from '../resource-machine' +import { GPUSpecification } from '../gpu-specification' /** * Class for ramfactors.. @@ -14,48 +10,48 @@ import { GPUSpecification } from '../gpu-specification'; @Component({ selector: 'app-resourcemachine-overview', templateUrl: './resourcemachine-overview.component.html', - providers: [FacilityService], + providers: [FacilityService] }) export class ResourcemachineOverviewComponent implements OnInit { - factor_types: string[] = ['HIGH_MEMORY', 'GENERAL_PURPOSE', 'MIDCLASS']; - gpu_types: GPUSpecification[] = []; - resourceMachines: ResourceMachine[]; - newResourceMachine: ResourceMachine; - newMachineFormGroup: UntypedFormGroup; - emptySpec: GPUSpecification = new GPUSpecification(null); - formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); - machinesFormGroups: { [id: string]: UntypedFormGroup } = {}; - name: string = ''; - @Input() facility_id: number; - @Output() readonly factorChanged: EventEmitter = new EventEmitter(); + factor_types: string[] = ['HIGH_MEMORY', 'GENERAL_PURPOSE', 'MIDCLASS'] + gpu_types: GPUSpecification[] = [] + resourceMachines: ResourceMachine[] + newResourceMachine: ResourceMachine + newMachineFormGroup: UntypedFormGroup + emptySpec: GPUSpecification = new GPUSpecification(null) + formBuilder: UntypedFormBuilder = new UntypedFormBuilder() + machinesFormGroups: { [id: string]: UntypedFormGroup } = {} + name: string = '' + @Input() facility_id: number + @Output() readonly factorChanged: EventEmitter = new EventEmitter() - resourceMachineUpdateList: { [id: string]: boolean } = {}; + resourceMachineUpdateList: { [id: string]: boolean } = {} constructor(private facilityService: FacilityService) { - this.facilityService = facilityService; + this.facilityService = facilityService } ngOnInit(): void { - this.getResourceMachines(); - this.newResourceMachine = new ResourceMachine(null); + this.getResourceMachines() + this.newResourceMachine = new ResourceMachine(null) this.newMachineFormGroup = this.formBuilder.group({ new_machine_ram: [null, Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])], new_machine_ram_private_factor: [ null, - Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]), + Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]) ], new_machine_ram_public_factor: [ null, - Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]), + Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]) ], new_machine_cores: [null, Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])], new_machine_cores_private_factor: [ null, - Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]), + Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]) ], new_machine_cores_public_factor: [ null, - Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]), + Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]) ], new_machine_gpus: [null, Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])], new_machine_local_disk_storage: [null, Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])], @@ -63,178 +59,180 @@ export class ResourcemachineOverviewComponent implements OnInit { new_machine_private_count: [null, Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])], new_machine_public_count: [null, Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])], new_machine_local_disk_encrypted: [null], - new_machine_type: [null, Validators.required], - }); + new_machine_type: [null, Validators.required] + }) - this.listenToChangesForNewMachine(); + this.listenToChangesForNewMachine() this.facilityService.getGPUSpecifications(this.facility_id).subscribe((specs: GPUSpecification[]): void => { - this.gpu_types = specs; - }); + this.gpu_types = specs + }) } listenToChangesForNewMachine(): void { this.newMachineFormGroup.get('new_machine_ram').valueChanges.subscribe((val: number): void => { - this.newResourceMachine.ram = val; - }); + this.newResourceMachine.ram = val + }) this.newMachineFormGroup.get('new_machine_ram_private_factor').valueChanges.subscribe((val: number): void => { - this.newResourceMachine.ram_private_factor = val; - }); + this.newResourceMachine.ram_private_factor = val + }) this.newMachineFormGroup.get('new_machine_ram_public_factor').valueChanges.subscribe((val: number): void => { - this.newResourceMachine.ram_public_factor = val; - }); + this.newResourceMachine.ram_public_factor = val + }) this.newMachineFormGroup.get('new_machine_cores').valueChanges.subscribe((val: number): void => { - this.newResourceMachine.cores = val; - }); + this.newResourceMachine.cores = val + }) this.newMachineFormGroup.get('new_machine_cores_private_factor').valueChanges.subscribe((val: number): void => { - this.newResourceMachine.cores_private_factor = val; - }); + this.newResourceMachine.cores_private_factor = val + }) this.newMachineFormGroup.get('new_machine_cores_public_factor').valueChanges.subscribe((val: number): void => { - this.newResourceMachine.cores_public_factor = val; - }); + this.newResourceMachine.cores_public_factor = val + }) this.newMachineFormGroup.get('new_machine_gpus').valueChanges.subscribe((val: number): void => { - this.newResourceMachine.gpu_slots = val; - this.newResourceMachine.changeGpuUsed(); - }); + this.newResourceMachine.gpu_slots = val + this.newResourceMachine.changeGpuUsed() + }) this.newMachineFormGroup.get('new_machine_name').valueChanges.subscribe((val: string): void => { - this.newResourceMachine.name = val; - }); + this.newResourceMachine.name = val + }) this.newMachineFormGroup.get('new_machine_local_disk_storage').valueChanges.subscribe((val: number): void => { - this.newResourceMachine.local_disk_storage = val; - }); + this.newResourceMachine.local_disk_storage = val + }) this.newMachineFormGroup.get('new_machine_private_count').valueChanges.subscribe((val: number): void => { - this.newResourceMachine.private_count = val; - }); + this.newResourceMachine.private_count = val + }) this.newMachineFormGroup.get('new_machine_public_count').valueChanges.subscribe((val: number): void => { - this.newResourceMachine.public_count = val; - }); + this.newResourceMachine.public_count = val + }) this.newMachineFormGroup.get('new_machine_local_disk_encrypted').valueChanges.subscribe((val: boolean): void => { - this.newResourceMachine.local_disk_encrypted = val; - }); + this.newResourceMachine.local_disk_encrypted = val + }) this.newMachineFormGroup.get('new_machine_type').valueChanges.subscribe((val: string): void => { - this.newResourceMachine.type = val; - }); + this.newResourceMachine.type = val + }) } detectGPUChanges(machine_id: number | string, slot: number | string): void { if (machine_id === -1) { - const gpu_id: string = this.newMachineFormGroup.get(`new_machine_gpu_used_${slot}`).value; + const gpu_id: string = this.newMachineFormGroup.get(`new_machine_gpu_used_${slot}`).value this.newResourceMachine.gpu_used[slot] = this.gpu_types.find( - (gpu: GPUSpecification): boolean => gpu.id === gpu_id, - ); + (gpu: GPUSpecification): boolean => gpu.id === gpu_id + ) } else { const machine: ResourceMachine = this.resourceMachines.find( - (res: ResourceMachine): boolean => res.id === machine_id, - ); - const gpu_id: string = this.machinesFormGroups[machine_id].get(`${machine.id}_gpu_used_${slot}`).value; - machine.gpu_slots[slot] = this.gpu_types.find((gpu: GPUSpecification): boolean => gpu.id === gpu_id); + (res: ResourceMachine): boolean => res.id === machine_id + ) + const gpu_id: string = this.machinesFormGroups[machine_id].get(`${machine.id}_gpu_used_${slot}`).value + machine.gpu_slots[slot] = this.gpu_types.find((gpu: GPUSpecification): boolean => gpu.id === gpu_id) } } getResourceMachines(): void { this.facilityService.getResourceMachines(this.facility_id).subscribe((res: ResourceMachine[]): void => { - this.resourceMachines = res.map((machine: ResourceMachine): ResourceMachine => new ResourceMachine(machine)); - this.resourceMachines.sort((a_machine: ResourceMachine, b_machine: ResourceMachine): number => b_machine.type.localeCompare(a_machine.type)); - this.machinesFormGroups = {}; + this.resourceMachines = res.map((machine: ResourceMachine): ResourceMachine => new ResourceMachine(machine)) + this.resourceMachines.sort((a_machine: ResourceMachine, b_machine: ResourceMachine): number => + b_machine.type.localeCompare(a_machine.type) + ) + this.machinesFormGroups = {} this.resourceMachines.forEach((machine: ResourceMachine): void => { - machine.gpu_used.slice(0, machine.gpu_slots); - this.resourceMachineUpdateList[machine.id] = false; - this.setupFormGroup(machine); - }); - }); + machine.gpu_used.slice(0, machine.gpu_slots) + this.resourceMachineUpdateList[machine.id] = false + this.setupFormGroup(machine) + }) + }) } setupFormGroup(machine: ResourceMachine): void { - this.machinesFormGroups[machine.id] = this.formBuilder.group({}); - const machine_ram: string = `${machine.id}_ram`; - const machine_ram_private_factor: string = `${machine.id}_ram_private_factor`; - const machine_ram_public_factor: string = `${machine.id}_ram_public_factor`; - const machine_cores: string = `${machine.id}_cores`; - const machine_cores_private_factor: string = `${machine.id}_cores_private_factor`; - const machine_cores_public_factor: string = `${machine.id}_cores_public_factor`; - const machine_gpus: string = `${machine.id}_gpus`; - const machine_local_disk_storage: string = `${machine.id}_local_disk_storage`; - const machine_local_disk_encrypted: string = `${machine.id}_local_disk_encrypted`; - const machine_name: string = `${machine.id}_name`; - const machine_type: string = `${machine.id}_type`; - const machine_private_count: string = `${machine.id}_private_count`; - const machine_public_count: string = `${machine.id}_public_count`; + this.machinesFormGroups[machine.id] = this.formBuilder.group({}) + const machine_ram: string = `${machine.id}_ram` + const machine_ram_private_factor: string = `${machine.id}_ram_private_factor` + const machine_ram_public_factor: string = `${machine.id}_ram_public_factor` + const machine_cores: string = `${machine.id}_cores` + const machine_cores_private_factor: string = `${machine.id}_cores_private_factor` + const machine_cores_public_factor: string = `${machine.id}_cores_public_factor` + const machine_gpus: string = `${machine.id}_gpus` + const machine_local_disk_storage: string = `${machine.id}_local_disk_storage` + const machine_local_disk_encrypted: string = `${machine.id}_local_disk_encrypted` + const machine_name: string = `${machine.id}_name` + const machine_type: string = `${machine.id}_type` + const machine_private_count: string = `${machine.id}_private_count` + const machine_public_count: string = `${machine.id}_public_count` - this.machinesFormGroups[machine.id].addControl(machine_ram, new UntypedFormControl([null])); + this.machinesFormGroups[machine.id].addControl(machine_ram, new UntypedFormControl([null])) this.machinesFormGroups[machine.id] .get(machine_ram) - .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]); - this.machinesFormGroups[machine.id].addControl(machine_ram_private_factor, new UntypedFormControl([null])); + .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]) + this.machinesFormGroups[machine.id].addControl(machine_ram_private_factor, new UntypedFormControl([null])) this.machinesFormGroups[machine.id] .get(machine_ram_private_factor) .setValidators([ - Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]), - ]); - this.machinesFormGroups[machine.id].addControl(machine_ram_public_factor, new UntypedFormControl([null])); + Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]) + ]) + this.machinesFormGroups[machine.id].addControl(machine_ram_public_factor, new UntypedFormControl([null])) this.machinesFormGroups[machine.id] .get(machine_ram_public_factor) .setValidators([ - Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]), - ]); - this.machinesFormGroups[machine.id].addControl(machine_cores, new UntypedFormControl([null])); + Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]) + ]) + this.machinesFormGroups[machine.id].addControl(machine_cores, new UntypedFormControl([null])) this.machinesFormGroups[machine.id] .get(machine_cores) - .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]); - this.machinesFormGroups[machine.id].addControl(machine_cores_private_factor, new UntypedFormControl([null])); + .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]) + this.machinesFormGroups[machine.id].addControl(machine_cores_private_factor, new UntypedFormControl([null])) this.machinesFormGroups[machine.id] .get(machine_cores_private_factor) .setValidators([ - Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]), - ]); - this.machinesFormGroups[machine.id].addControl(machine_cores_public_factor, new UntypedFormControl([null])); + Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]) + ]) + this.machinesFormGroups[machine.id].addControl(machine_cores_public_factor, new UntypedFormControl([null])) this.machinesFormGroups[machine.id] .get(machine_cores_public_factor) .setValidators([ - Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]), - ]); - this.machinesFormGroups[machine.id].addControl(machine_gpus, new UntypedFormControl([null])); + Validators.compose([Validators.required, Validators.pattern(/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/)]) + ]) + this.machinesFormGroups[machine.id].addControl(machine_gpus, new UntypedFormControl([null])) this.machinesFormGroups[machine.id] .get(machine_gpus) - .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]); - this.machinesFormGroups[machine.id].addControl(machine_local_disk_storage, new UntypedFormControl([null])); + .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]) + this.machinesFormGroups[machine.id].addControl(machine_local_disk_storage, new UntypedFormControl([null])) this.machinesFormGroups[machine.id] .get(machine_local_disk_storage) - .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]); - this.machinesFormGroups[machine.id].addControl(machine_local_disk_encrypted, new UntypedFormControl([null])); + .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]) + this.machinesFormGroups[machine.id].addControl(machine_local_disk_encrypted, new UntypedFormControl([null])) - this.machinesFormGroups[machine.id].addControl(machine_name, new UntypedFormControl([null])); + this.machinesFormGroups[machine.id].addControl(machine_name, new UntypedFormControl([null])) this.machinesFormGroups[machine.id] .get(machine_name) - .setValidators([Validators.compose([Validators.required, Validators.pattern(/^([A-Za-z0-9]+[ ]*)+$/)])]); - this.machinesFormGroups[machine.id].addControl(machine_type, new UntypedFormControl([null])); + .setValidators([Validators.compose([Validators.required, Validators.pattern(/^([A-Za-z0-9]+[ ]*)+$/)])]) + this.machinesFormGroups[machine.id].addControl(machine_type, new UntypedFormControl([null])) - this.machinesFormGroups[machine.id].addControl(machine_private_count, new UntypedFormControl([null])); + this.machinesFormGroups[machine.id].addControl(machine_private_count, new UntypedFormControl([null])) this.machinesFormGroups[machine.id] .get(machine_private_count) - .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]); - this.machinesFormGroups[machine.id].addControl(machine_public_count, new UntypedFormControl([null])); + .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]) + this.machinesFormGroups[machine.id].addControl(machine_public_count, new UntypedFormControl([null])) this.machinesFormGroups[machine.id] .get(machine_public_count) - .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]); + .setValidators([Validators.compose([Validators.required, Validators.pattern(/^\d+$/)])]) - this.machinesFormGroups[machine.id].get(machine_ram).setValue(machine.ram); - this.machinesFormGroups[machine.id].get(machine_ram_private_factor).setValue(machine.ram_private_factor); - this.machinesFormGroups[machine.id].get(machine_ram_public_factor).setValue(machine.ram_public_factor); - this.machinesFormGroups[machine.id].get(machine_cores).setValue(machine.cores); - this.machinesFormGroups[machine.id].get(machine_cores_private_factor).setValue(machine.cores_private_factor); - this.machinesFormGroups[machine.id].get(machine_cores_public_factor).setValue(machine.cores_public_factor); - this.machinesFormGroups[machine.id].get(machine_gpus).setValue(machine.gpu_slots); - this.machinesFormGroups[machine.id].get(machine_local_disk_storage).setValue(machine.local_disk_storage); - this.machinesFormGroups[machine.id].get(machine_local_disk_encrypted).setValue(machine.local_disk_encrypted); - this.machinesFormGroups[machine.id].get(machine_name).setValue(machine.name); - this.machinesFormGroups[machine.id].get(machine_type).setValue(machine.type); - this.machinesFormGroups[machine.id].get(machine_private_count).setValue(machine.private_count); - this.machinesFormGroups[machine.id].get(machine_public_count).setValue(machine.public_count); - this.machinesFormGroups[machine.id].disable(); + this.machinesFormGroups[machine.id].get(machine_ram).setValue(machine.ram) + this.machinesFormGroups[machine.id].get(machine_ram_private_factor).setValue(machine.ram_private_factor) + this.machinesFormGroups[machine.id].get(machine_ram_public_factor).setValue(machine.ram_public_factor) + this.machinesFormGroups[machine.id].get(machine_cores).setValue(machine.cores) + this.machinesFormGroups[machine.id].get(machine_cores_private_factor).setValue(machine.cores_private_factor) + this.machinesFormGroups[machine.id].get(machine_cores_public_factor).setValue(machine.cores_public_factor) + this.machinesFormGroups[machine.id].get(machine_gpus).setValue(machine.gpu_slots) + this.machinesFormGroups[machine.id].get(machine_local_disk_storage).setValue(machine.local_disk_storage) + this.machinesFormGroups[machine.id].get(machine_local_disk_encrypted).setValue(machine.local_disk_encrypted) + this.machinesFormGroups[machine.id].get(machine_name).setValue(machine.name) + this.machinesFormGroups[machine.id].get(machine_type).setValue(machine.type) + this.machinesFormGroups[machine.id].get(machine_private_count).setValue(machine.private_count) + this.machinesFormGroups[machine.id].get(machine_public_count).setValue(machine.public_count) + this.machinesFormGroups[machine.id].disable() } listenToChangesForMachine(machine: ResourceMachine): void { - /* eslint-disable */ + this.machinesFormGroups[machine.id].get(`${machine.id}_ram`).valueChanges.subscribe((val: number): void => { machine.ram = val }) @@ -291,93 +289,93 @@ export class ResourcemachineOverviewComponent implements OnInit { this.machinesFormGroups[machine.id].get(`${machine.id}_type`).valueChanges.subscribe((val: string): void => { machine.type = val }) - /* eslint-enable */ + } deleteResourceMachine(id: string | number): void { this.facilityService.deleteResourceMachine(this.facility_id, id).subscribe((res: ResourceMachine[]): void => { - this.machinesFormGroups = {}; + this.machinesFormGroups = {} res.forEach((machine: ResourceMachine): void => { - this.setupFormGroup(machine); - }); - this.resourceMachines = res.map((machine: ResourceMachine): ResourceMachine => new ResourceMachine(machine)); - this.factorChanged.emit(); - }); + this.setupFormGroup(machine) + }) + this.resourceMachines = res.map((machine: ResourceMachine): ResourceMachine => new ResourceMachine(machine)) + this.factorChanged.emit() + }) } changeResourceMachineToUpdate(machine: ResourceMachine): void { if (this.resourceMachineUpdateList[machine.id]) { - this.machinesFormGroups[machine.id].disable(); + this.machinesFormGroups[machine.id].disable() } else { - this.listenToChangesForMachine(machine); - this.machinesFormGroups[machine.id].enable(); + this.listenToChangesForMachine(machine) + this.machinesFormGroups[machine.id].enable() } - this.resourceMachineUpdateList[machine.id] = !this.resourceMachineUpdateList[machine.id]; + this.resourceMachineUpdateList[machine.id] = !this.resourceMachineUpdateList[machine.id] } reloadResourceMachine(rf: ResourceMachine): void { this.facilityService.getResourceMachine(this.facility_id, rf.id).subscribe((machine: ResourceMachine): void => { - this.resourceMachines[this.resourceMachines.indexOf(rf)] = new ResourceMachine(machine); - this.reloadMachineForm(machine); - }); + this.resourceMachines[this.resourceMachines.indexOf(rf)] = new ResourceMachine(machine) + this.reloadMachineForm(machine) + }) } reloadMachineForm(machine: ResourceMachine): void { - const machine_ram: string = `${machine.id}_ram`; - const machine_ram_private_factor: string = `${machine.id}_ram_private_factor`; - const machine_ram_public_factor: string = `${machine.id}_ram_public_factor`; - const machine_cores: string = `${machine.id}_cores`; - const machine_cores_private_factor: string = `${machine.id}_cores_private_factor`; - const machine_cores_public_factor: string = `${machine.id}_cores_public_factor`; - const machine_gpus: string = `${machine.id}_gpus`; - const machine_local_disk_storage: string = `${machine.id}_local_disk_storage`; - const machine_local_disk_encrypted: string = `${machine.id}_local_disk_encrypted`; - const machine_name: string = `${machine.id}_name`; - const machine_type: string = `${machine.id}_type`; - const machine_private_count: string = `${machine.id}_private_count`; - const machine_public_count: string = `${machine.id}_public_count`; + const machine_ram: string = `${machine.id}_ram` + const machine_ram_private_factor: string = `${machine.id}_ram_private_factor` + const machine_ram_public_factor: string = `${machine.id}_ram_public_factor` + const machine_cores: string = `${machine.id}_cores` + const machine_cores_private_factor: string = `${machine.id}_cores_private_factor` + const machine_cores_public_factor: string = `${machine.id}_cores_public_factor` + const machine_gpus: string = `${machine.id}_gpus` + const machine_local_disk_storage: string = `${machine.id}_local_disk_storage` + const machine_local_disk_encrypted: string = `${machine.id}_local_disk_encrypted` + const machine_name: string = `${machine.id}_name` + const machine_type: string = `${machine.id}_type` + const machine_private_count: string = `${machine.id}_private_count` + const machine_public_count: string = `${machine.id}_public_count` - this.machinesFormGroups[machine.id].get(machine_ram).setValue(machine.ram); - this.machinesFormGroups[machine.id].get(machine_ram_private_factor).setValue(machine.ram_private_factor); - this.machinesFormGroups[machine.id].get(machine_ram_public_factor).setValue(machine.ram_public_factor); - this.machinesFormGroups[machine.id].get(machine_cores).setValue(machine.cores); - this.machinesFormGroups[machine.id].get(machine_cores_private_factor).setValue(machine.cores_private_factor); - this.machinesFormGroups[machine.id].get(machine_cores_public_factor).setValue(machine.cores_public_factor); - this.machinesFormGroups[machine.id].get(machine_gpus).setValue(machine.gpu_slots); - this.machinesFormGroups[machine.id].get(machine_local_disk_storage).setValue(machine.local_disk_storage); - this.machinesFormGroups[machine.id].get(machine_local_disk_encrypted).setValue(machine.local_disk_encrypted); - this.machinesFormGroups[machine.id].get(machine_name).setValue(machine.name); - this.machinesFormGroups[machine.id].get(machine_type).setValue(machine.type); - this.machinesFormGroups[machine.id].get(machine_private_count).setValue(machine.private_count); - this.machinesFormGroups[machine.id].get(machine_public_count).setValue(machine.local_disk_storage); - this.machinesFormGroups[machine.id].disable(); + this.machinesFormGroups[machine.id].get(machine_ram).setValue(machine.ram) + this.machinesFormGroups[machine.id].get(machine_ram_private_factor).setValue(machine.ram_private_factor) + this.machinesFormGroups[machine.id].get(machine_ram_public_factor).setValue(machine.ram_public_factor) + this.machinesFormGroups[machine.id].get(machine_cores).setValue(machine.cores) + this.machinesFormGroups[machine.id].get(machine_cores_private_factor).setValue(machine.cores_private_factor) + this.machinesFormGroups[machine.id].get(machine_cores_public_factor).setValue(machine.cores_public_factor) + this.machinesFormGroups[machine.id].get(machine_gpus).setValue(machine.gpu_slots) + this.machinesFormGroups[machine.id].get(machine_local_disk_storage).setValue(machine.local_disk_storage) + this.machinesFormGroups[machine.id].get(machine_local_disk_encrypted).setValue(machine.local_disk_encrypted) + this.machinesFormGroups[machine.id].get(machine_name).setValue(machine.name) + this.machinesFormGroups[machine.id].get(machine_type).setValue(machine.type) + this.machinesFormGroups[machine.id].get(machine_private_count).setValue(machine.private_count) + this.machinesFormGroups[machine.id].get(machine_public_count).setValue(machine.local_disk_storage) + this.machinesFormGroups[machine.id].disable() } addResourceMachine(): void { - this.newResourceMachine.name = this.newResourceMachine.name.trim(); + this.newResourceMachine.name = this.newResourceMachine.name.trim() this.facilityService .addResourceMachine(this.facility_id, this.newResourceMachine) .subscribe((res: ResourceMachine[]): void => { - this.newResourceMachine = new ResourceMachine(null); - this.machinesFormGroups = {}; + this.newResourceMachine = new ResourceMachine(null) + this.machinesFormGroups = {} res.forEach((machine: ResourceMachine): void => { - this.setupFormGroup(machine); - }); - this.resourceMachines = res.map((machine: ResourceMachine): ResourceMachine => new ResourceMachine(machine)); + this.setupFormGroup(machine) + }) + this.resourceMachines = res.map((machine: ResourceMachine): ResourceMachine => new ResourceMachine(machine)) this.resourceMachines.forEach((rf: ResourceMachine): void => { - this.resourceMachineUpdateList[rf.id] = false; - }); - this.factorChanged.emit(); - }); + this.resourceMachineUpdateList[rf.id] = false + }) + this.factorChanged.emit() + }) } updateResourceMachine(rf: ResourceMachine): void { - rf.name = rf.name.trim(); + rf.name = rf.name.trim() this.facilityService.updateResourceMachine(this.facility_id, rf).subscribe((machine: ResourceMachine): void => { - this.resourceMachines[this.resourceMachines.indexOf(rf)] = new ResourceMachine(machine); - this.setupFormGroup(machine); - this.factorChanged.emit(); - }); + this.resourceMachines[this.resourceMachines.indexOf(rf)] = new ResourceMachine(machine) + this.setupFormGroup(machine) + this.factorChanged.emit() + }) } } diff --git a/src/app/facility_manager/resources/resources.component.ts b/src/app/facility_manager/resources/resources.component.ts index 241f591b6c..6f32985719 100644 --- a/src/app/facility_manager/resources/resources.component.ts +++ b/src/app/facility_manager/resources/resources.component.ts @@ -1,17 +1,13 @@ -import { - Component, ElementRef, OnInit, ViewChild, inject, -} from '@angular/core'; -import { - download, mkConfig, generateCsv, CsvOutput, -} from 'export-to-csv'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { Resources } from '../../vo_manager/resources/resources'; -import { FacilityService } from '../../api-connector/facility.service'; -import { ObjectStorageFactor } from './object-storage-factor'; -import { VolumeStorageFactor } from './volume-storage-factor'; -import { GeneralStorageFactor } from './general-storage-factor'; -import { ResourceMachine } from './resource-machine'; -import { GPUSpecification } from './gpu-specification'; +import { Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core' +import { download, mkConfig, generateCsv, CsvOutput } from 'export-to-csv' +import { MatomoTracker } from 'ngx-matomo-client' +import { Resources } from '../../vo_manager/resources/resources' +import { FacilityService } from '../../api-connector/facility.service' +import { ObjectStorageFactor } from './object-storage-factor' +import { VolumeStorageFactor } from './volume-storage-factor' +import { GeneralStorageFactor } from './general-storage-factor' +import { ResourceMachine } from './resource-machine' +import { GPUSpecification } from './gpu-specification' /** * Facility resource component. @@ -20,220 +16,220 @@ import { GPUSpecification } from './gpu-specification'; selector: 'app-resources', templateUrl: './resources.component.html', styleUrls: ['./resources.component.scss'], - providers: [FacilityService], + providers: [FacilityService] }) export class ResourcesComponent implements OnInit { - private readonly tracker = inject(MatomoTracker); - title: string = 'Resource Overview'; - - tableId: string = 'contentToConvert'; - @ViewChild('contentToConvert') pdfTable: ElementRef; - - managerFacilities: [string, number][]; - - ALL_RESOURCES: number = 0; - INTERN_RESOURCES: number = 1; - PUBLIC_RESOURCES: number = 2; - - ALL_ACTIVE: boolean = false; - INTERN_ACTIVE: boolean = false; - PUBLIC_ACTIVE: boolean = true; - - MACHINE_DEFINITION_TAB: number = 0; - STORAGE_TAB: number = 1; - OBJECT_STORAGE_TAB: number = 2; - VOLUME_STORAGE_TAB: number = 3; - GENERAL_STORAGE_TAB: number = 4; - GPU_TAB: number = 5; - - MACHINE_DEFINITION_TAB_ACTIVE: boolean = false; - STORAGE_TAB_ACTIVE: boolean = false; - GENERAL_STORAGE_TAB_ACTIVE: boolean = false; - OBJECT_STORAGE_TAB_ACTIVE: boolean = false; - VOLUME_STORAGE_TAB_ACTIVE: boolean = false; - GPU_TAB_ACTIVE: boolean = false; - - objectStorageFactors: ObjectStorageFactor[] = []; - volumeStorageFactors: VolumeStorageFactor[] = []; - generalStorageFactors: GeneralStorageFactor[] = []; - resourceMachines: ResourceMachine[] = []; - gpuSpecifications: GPUSpecification[] = []; + private readonly tracker = inject(MatomoTracker) + title: string = 'Resource Overview' + + tableId: string = 'contentToConvert' + @ViewChild('contentToConvert') pdfTable: ElementRef + + managerFacilities: [string, number][] + + ALL_RESOURCES: number = 0 + INTERN_RESOURCES: number = 1 + PUBLIC_RESOURCES: number = 2 + + ALL_ACTIVE: boolean = false + INTERN_ACTIVE: boolean = false + PUBLIC_ACTIVE: boolean = true + + MACHINE_DEFINITION_TAB: number = 0 + STORAGE_TAB: number = 1 + OBJECT_STORAGE_TAB: number = 2 + VOLUME_STORAGE_TAB: number = 3 + GENERAL_STORAGE_TAB: number = 4 + GPU_TAB: number = 5 + + MACHINE_DEFINITION_TAB_ACTIVE: boolean = false + STORAGE_TAB_ACTIVE: boolean = false + GENERAL_STORAGE_TAB_ACTIVE: boolean = false + OBJECT_STORAGE_TAB_ACTIVE: boolean = false + VOLUME_STORAGE_TAB_ACTIVE: boolean = false + GPU_TAB_ACTIVE: boolean = false + + objectStorageFactors: ObjectStorageFactor[] = [] + volumeStorageFactors: VolumeStorageFactor[] = [] + generalStorageFactors: GeneralStorageFactor[] = [] + resourceMachines: ResourceMachine[] = [] + gpuSpecifications: GPUSpecification[] = [] /** * Chosen facility. */ - public selectedFacility: [string, number]; + public selectedFacility: [string, number] - isLoaded: boolean = false; - resources: Resources[]; - visible_resources: Resources[]; + isLoaded: boolean = false + resources: Resources[] + visible_resources: Resources[] /** * Id of the table which will be converted to pdf or csv. */ - today: number = Date.now(); + today: number = Date.now() constructor(private facilityService: FacilityService) { - this.facilityService = facilityService; + this.facilityService = facilityService } setAllTabsFalse(): void { - this.MACHINE_DEFINITION_TAB_ACTIVE = false; - this.GENERAL_STORAGE_TAB_ACTIVE = false; - this.OBJECT_STORAGE_TAB_ACTIVE = false; - this.VOLUME_STORAGE_TAB_ACTIVE = false; - this.GPU_TAB_ACTIVE = false; - this.STORAGE_TAB_ACTIVE = false; + this.MACHINE_DEFINITION_TAB_ACTIVE = false + this.GENERAL_STORAGE_TAB_ACTIVE = false + this.OBJECT_STORAGE_TAB_ACTIVE = false + this.VOLUME_STORAGE_TAB_ACTIVE = false + this.GPU_TAB_ACTIVE = false + this.STORAGE_TAB_ACTIVE = false } setAllResourcesFalse(): void { - this.ALL_ACTIVE = false; - this.PUBLIC_ACTIVE = false; - this.INTERN_ACTIVE = false; + this.ALL_ACTIVE = false + this.PUBLIC_ACTIVE = false + this.INTERN_ACTIVE = false } setResources(tab_num: number): void { - this.setAllResourcesFalse(); + this.setAllResourcesFalse() switch (tab_num) { case this.ALL_RESOURCES: - this.ALL_ACTIVE = true; - break; + this.ALL_ACTIVE = true + break case this.INTERN_RESOURCES: - this.INTERN_ACTIVE = true; - break; + this.INTERN_ACTIVE = true + break case this.PUBLIC_RESOURCES: - this.PUBLIC_ACTIVE = true; - break; + this.PUBLIC_ACTIVE = true + break default: - break; + break } - this.setVisibleResources(); + this.setVisibleResources() } setTab(tab_num: number): void { - this.setAllTabsFalse(); + this.setAllTabsFalse() switch (tab_num) { case this.MACHINE_DEFINITION_TAB: - this.MACHINE_DEFINITION_TAB_ACTIVE = true; - break; + this.MACHINE_DEFINITION_TAB_ACTIVE = true + break case this.STORAGE_TAB: - this.STORAGE_TAB_ACTIVE = true; + this.STORAGE_TAB_ACTIVE = true if (this.generalStorageFactors.length > 0) { - this.GENERAL_STORAGE_TAB_ACTIVE = true; + this.GENERAL_STORAGE_TAB_ACTIVE = true } else if (this.volumeStorageFactors.length > 0 || this.objectStorageFactors.length > 0) { - this.OBJECT_STORAGE_TAB_ACTIVE = true; + this.OBJECT_STORAGE_TAB_ACTIVE = true } - break; + break case this.GENERAL_STORAGE_TAB: - this.GENERAL_STORAGE_TAB_ACTIVE = true; - this.STORAGE_TAB_ACTIVE = true; + this.GENERAL_STORAGE_TAB_ACTIVE = true + this.STORAGE_TAB_ACTIVE = true - break; + break case this.OBJECT_STORAGE_TAB: - this.OBJECT_STORAGE_TAB_ACTIVE = true; - this.STORAGE_TAB_ACTIVE = true; + this.OBJECT_STORAGE_TAB_ACTIVE = true + this.STORAGE_TAB_ACTIVE = true - break; + break case this.VOLUME_STORAGE_TAB: - this.VOLUME_STORAGE_TAB_ACTIVE = true; - this.STORAGE_TAB_ACTIVE = true; + this.VOLUME_STORAGE_TAB_ACTIVE = true + this.STORAGE_TAB_ACTIVE = true - break; + break case this.GPU_TAB: - this.GPU_TAB_ACTIVE = true; - break; + this.GPU_TAB_ACTIVE = true + break default: - break; + break } } onChangeSelectedFacility(): void { - this.setAllTabsFalse(); - this.getSelectedFacilityResources(); + this.setAllTabsFalse() + this.getSelectedFacilityResources() } ngOnInit(): void { - this.tracker.trackPageView('Facility Resources'); + this.tracker.trackPageView('Facility Resources') this.facilityService.getManagerFacilities().subscribe((result: [string, number][]): void => { - this.managerFacilities = result; - this.selectedFacility = this.managerFacilities[0]; - this.getSelectedFacilityResources(); - }); + this.managerFacilities = result + this.selectedFacility = this.managerFacilities[0] + this.getSelectedFacilityResources() + }) } setVisibleResources(): void { if (this.PUBLIC_ACTIVE) { this.visible_resources = this.resources.filter( - (res: Resources): boolean => !res.resource_name.includes('Intern') && !res.resource_name.includes('All'), - ); + (res: Resources): boolean => !res.resource_name.includes('Intern') && !res.resource_name.includes('All') + ) } else if (this.INTERN_ACTIVE) { - this.visible_resources = this.resources.filter((res: Resources): boolean => res.resource_name.includes('Intern')); + this.visible_resources = this.resources.filter((res: Resources): boolean => res.resource_name.includes('Intern')) } else if (this.ALL_ACTIVE) { - this.visible_resources = this.resources; + this.visible_resources = this.resources } - this.isLoaded = true; + this.isLoaded = true } public getSelectedFacilityResources(): void { this.facilityService .getObjectStorageFactors(this.selectedFacility['FacilityId']) .subscribe((res: ObjectStorageFactor[]): void => { - this.objectStorageFactors = res; - }); + this.objectStorageFactors = res + }) this.facilityService .getGeneralStorageFactors(this.selectedFacility['FacilityId']) .subscribe((res: GeneralStorageFactor[]): void => { - this.generalStorageFactors = res; - }); + this.generalStorageFactors = res + }) this.facilityService .getResourceMachines(this.selectedFacility['FacilityId']) .subscribe((res: ResourceMachine[]): void => { - this.resourceMachines = res; - }); + this.resourceMachines = res + }) this.facilityService .getVolumeStorageFactors(this.selectedFacility['FacilityId']) .subscribe((res: VolumeStorageFactor[]): void => { - this.volumeStorageFactors = res; - }); + this.volumeStorageFactors = res + }) this.facilityService .getGPUSpecifications(this.selectedFacility['FacilityId']) .subscribe((specs: GPUSpecification[]): void => { - this.gpuSpecifications = specs; - }); + this.gpuSpecifications = specs + }) this.facilityService .getFacilityResources(this.selectedFacility['FacilityId']) .subscribe((res: Resources[]): void => { - res = this.transformGbToTb(res); - this.resources = res; - this.setVisibleResources(); - }); + res = this.transformGbToTb(res) + this.resources = res + this.setVisibleResources() + }) } transformGbToTb(res: Resources[]): Resources[] { res.forEach((resource: Resources) => { if ( - resource['resource_name'] === 'Expired | In-Use' - || resource['resource_name'] === 'Total Used' - || resource['resource_name'] === 'Simple VM' - || resource['resource_name'] === 'Wait for Confirmation: OpenStack' - || resource['resource_name'] === 'Running: OpenStack' + resource['resource_name'] === 'Expired | In-Use' || + resource['resource_name'] === 'Total Used' || + resource['resource_name'] === 'Simple VM' || + resource['resource_name'] === 'Wait for Confirmation: OpenStack' || + resource['resource_name'] === 'Running: OpenStack' ) { - resource['totalObjectStorage'] /= 1024; - resource['totalObjectStorage'] = Math.round((resource['totalObjectStorage'] + Number.EPSILON) * 1000) / 1000; - resource['totalVolumeLimit'] /= 1024; - resource['totalVolumeLimit'] = Math.round((resource['totalVolumeLimit'] + Number.EPSILON) * 1000) / 1000; + resource['totalObjectStorage'] /= 1024 + resource['totalObjectStorage'] = Math.round((resource['totalObjectStorage'] + Number.EPSILON) * 1000) / 1000 + resource['totalVolumeLimit'] /= 1024 + resource['totalVolumeLimit'] = Math.round((resource['totalVolumeLimit'] + Number.EPSILON) * 1000) / 1000 } - }); + }) - return res; + return res } public tableToCSV(): void { - console.log('to csv'); + console.log('to csv') const csvConfig = mkConfig({ fieldSeparator: ',', quoteStrings: true, @@ -242,12 +238,12 @@ export class ResourcesComponent implements OnInit { filename: `${this.selectedFacility['Facility']}_resources.csv`, useTextFile: false, useBom: true, - useKeysAsHeaders: true, - }); + useKeysAsHeaders: true + }) - const converted: any[] = this.visible_resources.map((res: Resources) => Object.assign(res)); - const csv: CsvOutput = generateCsv(csvConfig)(converted); + const converted: any[] = this.visible_resources.map((res: Resources) => Object.assign(res)) + const csv: CsvOutput = generateCsv(csvConfig)(converted) - download(csvConfig)(csv); + download(csvConfig)(csv) } } diff --git a/src/app/facility_manager/resources/volumestoragefactor-overview/volumestoragefactor-overview.component.ts b/src/app/facility_manager/resources/volumestoragefactor-overview/volumestoragefactor-overview.component.ts index f0fb1248f6..671f6834d7 100644 --- a/src/app/facility_manager/resources/volumestoragefactor-overview/volumestoragefactor-overview.component.ts +++ b/src/app/facility_manager/resources/volumestoragefactor-overview/volumestoragefactor-overview.component.ts @@ -1,8 +1,6 @@ -import { - Component, EventEmitter, Input, OnInit, Output, -} from '@angular/core'; -import { FacilityService } from '../../../api-connector/facility.service'; -import { VolumeStorageFactor } from '../volume-storage-factor'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' +import { FacilityService } from '../../../api-connector/facility.service' +import { VolumeStorageFactor } from '../volume-storage-factor' /** * Class for ramfactors. @@ -10,85 +8,83 @@ import { VolumeStorageFactor } from '../volume-storage-factor'; @Component({ selector: 'app-volumestoragefactor-overview', templateUrl: './volumestoragefactor-overview.component.html', - providers: [FacilityService], - + providers: [FacilityService] }) export class VolumestoragefactorOverviewComponent implements OnInit { - volumeStorageFactors: VolumeStorageFactor[]; - @Input() facility_id: number; - @Output() readonly factorChanged: EventEmitter = new EventEmitter(); + volumeStorageFactors: VolumeStorageFactor[] + @Input() facility_id: number + @Output() readonly factorChanged: EventEmitter = new EventEmitter() - newFactor: VolumeStorageFactor; - volumeUpdateList: { [id: string]: boolean } = {}; + newFactor: VolumeStorageFactor + volumeUpdateList: { [id: string]: boolean } = {} constructor(private facilityService: FacilityService) { - this.facilityService = facilityService; + this.facilityService = facilityService } ngOnInit(): void { - this.getVolumeStorageFactors(); - this.newFactor = new VolumeStorageFactor(null); - + this.getVolumeStorageFactors() + this.newFactor = new VolumeStorageFactor(null) } getVolumeStorageFactors(): void { this.facilityService.getVolumeStorageFactors(this.facility_id).subscribe((res: VolumeStorageFactor[]): void => { - this.volumeStorageFactors = res; + this.volumeStorageFactors = res this.volumeStorageFactors.sort((a_factor: VolumeStorageFactor, b_factor: VolumeStorageFactor): number => { if (a_factor.storage > b_factor.storage) { - return 1; + return 1 } else if (a_factor.storage === b_factor.storage) { - return 0; + return 0 } else { - return -1; + return -1 } - - }); + }) this.volumeStorageFactors.forEach((vF: VolumeStorageFactor): void => { - this.volumeUpdateList[vF.id] = false; - }); - }); + this.volumeUpdateList[vF.id] = false + }) + }) } deleteVolumeStorageFactor(id: string | number): void { - this.facilityService.deleteVolumeStorageFactor(this.facility_id, id).subscribe((res: VolumeStorageFactor[]): void => { - this.volumeStorageFactors = res; - this.factorChanged.emit(); - - }); + this.facilityService + .deleteVolumeStorageFactor(this.facility_id, id) + .subscribe((res: VolumeStorageFactor[]): void => { + this.volumeStorageFactors = res + this.factorChanged.emit() + }) } changeVolumeStorageToUpdate(vF: VolumeStorageFactor): void { - this.volumeUpdateList[vF.id] = !this.volumeUpdateList[vF.id]; + this.volumeUpdateList[vF.id] = !this.volumeUpdateList[vF.id] } reloadVolumeStorageFactor(vF: VolumeStorageFactor): void { - this.facilityService.getVolumeStorageFactor(this.facility_id, vF.id).subscribe((volumeFactor: VolumeStorageFactor): void => { - this.volumeStorageFactors[this.volumeStorageFactors.indexOf(vF)] = new VolumeStorageFactor(volumeFactor); - }); + this.facilityService + .getVolumeStorageFactor(this.facility_id, vF.id) + .subscribe((volumeFactor: VolumeStorageFactor): void => { + this.volumeStorageFactors[this.volumeStorageFactors.indexOf(vF)] = new VolumeStorageFactor(volumeFactor) + }) } addVolumeStorageFactor(): void { - - this.facilityService.addVolumeStorageFactor(this.facility_id, this.newFactor).subscribe((res: VolumeStorageFactor[]): void => { - this.newFactor = new VolumeStorageFactor(null); - this.volumeStorageFactors = res; - this.volumeStorageFactors.forEach((vF: VolumeStorageFactor): void => { - this.volumeUpdateList[vF.id] = false; - }); - this.factorChanged.emit(); - }); - + this.facilityService + .addVolumeStorageFactor(this.facility_id, this.newFactor) + .subscribe((res: VolumeStorageFactor[]): void => { + this.newFactor = new VolumeStorageFactor(null) + this.volumeStorageFactors = res + this.volumeStorageFactors.forEach((vF: VolumeStorageFactor): void => { + this.volumeUpdateList[vF.id] = false + }) + this.factorChanged.emit() + }) } updateVolumeStorageFactor(vf: VolumeStorageFactor): void { - - this.facilityService.updateVolumeStorageFactor(this.facility_id, vf).subscribe((volumeFactor: VolumeStorageFactor): void => { - this.volumeStorageFactors[this.volumeStorageFactors.indexOf(vf)] = new VolumeStorageFactor(volumeFactor); - this.factorChanged.emit(); - - }); - + this.facilityService + .updateVolumeStorageFactor(this.facility_id, vf) + .subscribe((volumeFactor: VolumeStorageFactor): void => { + this.volumeStorageFactors[this.volumeStorageFactors.indexOf(vf)] = new VolumeStorageFactor(volumeFactor) + this.factorChanged.emit() + }) } - } diff --git a/src/app/help/help-routing.module.ts b/src/app/help/help-routing.module.ts index bd2827f86f..f6c0f8b9dd 100644 --- a/src/app/help/help-routing.module.ts +++ b/src/app/help/help-routing.module.ts @@ -1,24 +1,22 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { HelpComponent } from './help.component'; +import { NgModule } from '@angular/core' +import { RouterModule, Routes } from '@angular/router' +import { HelpComponent } from './help.component' const routes: Routes = [ { path: '', component: HelpComponent, data: { - title: 'Help', - }, - - }, -]; + title: 'Help' + } + } +] /** * Help module. */ @NgModule({ imports: [RouterModule.forChild(routes)], - exports: [RouterModule], + exports: [RouterModule] }) -export class HelpRoutingModule { -} +export class HelpRoutingModule {} diff --git a/src/app/help/help.component.ts b/src/app/help/help.component.ts index 118ca0535e..ff9158341c 100644 --- a/src/app/help/help.component.ts +++ b/src/app/help/help.component.ts @@ -1,26 +1,24 @@ -import { Component, OnInit, inject } from '@angular/core'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { - WIKI, CLOUD_PORTAL_SUPPORT_MAIL, STATUS_LINK, SUPPORT_LINK, ZAMMAD_HELPDESK_LINK, -} from '../../links/links'; +import { Component, OnInit, inject } from '@angular/core' +import { MatomoTracker } from 'ngx-matomo-client' +import { WIKI, CLOUD_PORTAL_SUPPORT_MAIL, STATUS_LINK, SUPPORT_LINK, ZAMMAD_HELPDESK_LINK } from '../../links/links' /** * Help component. */ @Component({ selector: 'app-help', templateUrl: './help.component.html', - providers: [], + providers: [] }) export class HelpComponent implements OnInit { - private readonly tracker = inject(MatomoTracker); - WIKI: string = WIKI; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - STATUS_LINK: string = STATUS_LINK; - SUPPORT_LINK: string = SUPPORT_LINK; - ZAMMAD_HELPDESK_LINK: string = ZAMMAD_HELPDESK_LINK; - title: string = 'Help'; + private readonly tracker = inject(MatomoTracker) + WIKI: string = WIKI + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + STATUS_LINK: string = STATUS_LINK + SUPPORT_LINK: string = SUPPORT_LINK + ZAMMAD_HELPDESK_LINK: string = ZAMMAD_HELPDESK_LINK + title: string = 'Help' ngOnInit(): void { - this.tracker.trackPageView('Help'); + this.tracker.trackPageView('Help') } } diff --git a/src/app/help/help.module.ts b/src/app/help/help.module.ts index f2c23418f1..6242c5a176 100644 --- a/src/app/help/help.module.ts +++ b/src/app/help/help.module.ts @@ -1,27 +1,18 @@ -import { NgModule } from '@angular/core'; -import { TabsModule } from 'ngx-bootstrap/tabs'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { ModalModule } from 'ngx-bootstrap/modal'; -import { AlertModule } from 'ngx-bootstrap/alert'; -import { HelpRoutingModule } from './help-routing.module'; -import { HelpComponent } from '../help/help.component'; +import { NgModule } from '@angular/core' +import { TabsModule } from 'ngx-bootstrap/tabs' +import { CommonModule } from '@angular/common' +import { FormsModule } from '@angular/forms' +import { ModalModule } from 'ngx-bootstrap/modal' +import { AlertModule } from 'ngx-bootstrap/alert' +import { HelpRoutingModule } from './help-routing.module' +import { HelpComponent } from '../help/help.component' /** * Help module. */ @NgModule({ - imports: [ - HelpRoutingModule, - TabsModule, - CommonModule, - FormsModule, ModalModule.forRoot(), - AlertModule.forRoot(), - ], + imports: [HelpRoutingModule, TabsModule, CommonModule, FormsModule, ModalModule.forRoot(), AlertModule.forRoot()], - declarations: [ - HelpComponent, - ], + declarations: [HelpComponent] }) -export class HelpModule { -} +export class HelpModule {} diff --git a/src/app/layouts/full-layout.component.ts b/src/app/layouts/full-layout.component.ts index f88c45fc64..5d91e8c056 100644 --- a/src/app/layouts/full-layout.component.ts +++ b/src/app/layouts/full-layout.component.ts @@ -1,24 +1,24 @@ -import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; -import moment from 'moment'; -import { Router } from '@angular/router'; -import { ApiSettings } from '../api-connector/api-settings.service'; -import { ClientService } from '../api-connector/client.service'; -import { FacilityService } from '../api-connector/facility.service'; -import { UserService } from '../api-connector/user.service'; -import { GroupService } from '../api-connector/group.service'; -import { VoService } from '../api-connector/vo.service'; -import { IResponseTemplate } from '../api-connector/response-template'; -import { ApplicationBaseClassComponent } from '../shared/shared_modules/baseClass/application-base-class.component'; -import { ApplicationsService } from '../api-connector/applications.service'; -import { ProjectEnumeration } from '../projectmanagement/project-enumeration'; -import { environment } from '../../environments/environment'; -import { is_vo } from '../shared/globalvar'; -import { VirtualmachineService } from '../api-connector/virtualmachine.service'; -import { Application_States } from '../shared/shared_modules/baseClass/abstract-base-class'; -import { WIKI, WIKI_FAQ, STATUS_LINK } from '../../links/links'; -import { MaintenanceTimeFrame } from '../vo_manager/maintenance/maintenanceTimeFrame.model'; -import { MaintenanceService } from '../api-connector/maintenance.service'; -import { UserInfoComponent } from '../userinfo/userinfo.component'; +import { ChangeDetectorRef, Component, OnInit } from '@angular/core' +import moment from 'moment' +import { Router } from '@angular/router' +import { ApiSettings } from '../api-connector/api-settings.service' +import { ClientService } from '../api-connector/client.service' +import { FacilityService } from '../api-connector/facility.service' +import { UserService } from '../api-connector/user.service' +import { GroupService } from '../api-connector/group.service' +import { VoService } from '../api-connector/vo.service' +import { IResponseTemplate } from '../api-connector/response-template' +import { ApplicationBaseClassComponent } from '../shared/shared_modules/baseClass/application-base-class.component' +import { ApplicationsService } from '../api-connector/applications.service' +import { ProjectEnumeration } from '../projectmanagement/project-enumeration' +import { environment } from '../../environments/environment' +import { is_vo } from '../shared/globalvar' +import { VirtualmachineService } from '../api-connector/virtualmachine.service' +import { Application_States } from '../shared/shared_modules/baseClass/abstract-base-class' +import { WIKI, WIKI_FAQ, STATUS_LINK } from '../../links/links' +import { MaintenanceTimeFrame } from '../vo_manager/maintenance/maintenanceTimeFrame.model' +import { MaintenanceService } from '../api-connector/maintenance.service' +import { UserInfoComponent } from '../userinfo/userinfo.component' /** * FullLayout component. @@ -34,49 +34,49 @@ import { UserInfoComponent } from '../userinfo/userinfo.component'; UserService, FacilityService, ClientService, - ApiSettings, - ], + ApiSettings + ] }) export class FullLayoutComponent extends ApplicationBaseClassComponent implements OnInit { - public year: number = new Date().getFullYear(); - public disabled: boolean = false; - public status: { isopen: boolean } = { isopen: false }; - is_vo_admin: boolean = false; - public is_facility_manager: boolean = false; - public is_simple_vm_manager: boolean = false; - public vm_project_member: boolean = false; - public login_name: string = ''; - public production: boolean = environment.production; - show_projects: boolean = false; - navbar_state: string = 'closed'; - overview_state: string = 'closed'; - show_overviews: boolean = false; - brand_logo: string = 'static/webapp/assets/img/denbi-logo-color.svg'; + public year: number = new Date().getFullYear() + public disabled: boolean = false + public status: { isopen: boolean } = { isopen: false } + is_vo_admin: boolean = false + public is_facility_manager: boolean = false + public is_simple_vm_manager: boolean = false + public vm_project_member: boolean = false + public login_name: string = '' + public production: boolean = environment.production + show_projects: boolean = false + navbar_state: string = 'closed' + overview_state: string = 'closed' + show_overviews: boolean = false + brand_logo: string = 'static/webapp/assets/img/denbi-logo-color.svg' // brand_logo_minimized: string = 'static/webapp/assets/img/denbi-logo-minimized.svg'; - simple_vm_logo: string = 'static/webapp/assets/img/simpleVM_Logo.svg'; - openstack_logo: string = 'static/webapp/assets/img/openstack_plain_red.svg'; - kubernetes_logo: string = 'static/webapp/assets/img/kubernetes_logo.svg'; + simple_vm_logo: string = 'static/webapp/assets/img/simpleVM_Logo.svg' + openstack_logo: string = 'static/webapp/assets/img/openstack_plain_red.svg' + kubernetes_logo: string = 'static/webapp/assets/img/kubernetes_logo.svg' - cluster_allowed: boolean = false; - has_workshops: boolean = false; - missing_consents: string[] = []; - maintenanceTimeframes: MaintenanceTimeFrame[] = []; - maintenanceTimeframesLoaded: boolean = false; - checkMaintenanceTimer: ReturnType; - checkMaintenanceTimeout: number = 180000; - numberOfConfirmableTimeframes: number = 0; - confirmedInSession: boolean = false; + cluster_allowed: boolean = false + has_workshops: boolean = false + missing_consents: string[] = [] + maintenanceTimeframes: MaintenanceTimeFrame[] = [] + maintenanceTimeframesLoaded: boolean = false + checkMaintenanceTimer: ReturnType + checkMaintenanceTimeout: number = 180000 + numberOfConfirmableTimeframes: number = 0 + confirmedInSession: boolean = false - TITLE: string = ''; + TITLE: string = '' - project_enumeration: ProjectEnumeration[] = []; + project_enumeration: ProjectEnumeration[] = [] - facilityIds: number[] = []; - Application_States: typeof Application_States = Application_States; + facilityIds: number[] = [] + Application_States: typeof Application_States = Application_States - WIKI: string = WIKI; - WIKI_FAQ: string = WIKI_FAQ; - STATUS_LINK: string = STATUS_LINK; + WIKI: string = WIKI + WIKI_FAQ: string = WIKI_FAQ + STATUS_LINK: string = STATUS_LINK constructor( private voService: VoService, @@ -87,110 +87,110 @@ export class FullLayoutComponent extends ApplicationBaseClassComponent implement applicationsService: ApplicationsService, private virtualMachineService: VirtualmachineService, private cd: ChangeDetectorRef, - private router: Router, + private router: Router ) { - super(userService, applicationsService, facilityService, cd); + super(userService, applicationsService, facilityService, cd) } componentAdded(component: any): void { - this.TITLE = component.title; + this.TITLE = component.title if (component instanceof UserInfoComponent) { - const child: UserInfoComponent = component; + const child: UserInfoComponent = component child.confirmEventEmitter.subscribe(() => { - this.confirmedInSession = true; - }); + this.confirmedInSession = true + }) } - this.maintenanceInformationLoop(); - this.cd.detectChanges(); + this.maintenanceInformationLoop() + this.cd.detectChanges() } public get_is_vo_admin(): boolean { - return this.is_vo_admin; + return this.is_vo_admin } maintenanceInformationLoop(timeout: number = this.checkMaintenanceTimeout): void { - this.stopCheckMaintenanceTimer(); - this.getMaintenanceTimeFrames(); + this.stopCheckMaintenanceTimer() + this.getMaintenanceTimeFrames() this.checkMaintenanceTimer = setTimeout((): void => { - this.maintenanceInformationLoop(); - }, timeout); + this.maintenanceInformationLoop() + }, timeout) } stopCheckMaintenanceTimer(): void { if (this.checkMaintenanceTimer) { - clearTimeout(this.checkMaintenanceTimer); + clearTimeout(this.checkMaintenanceTimer) } } set_cluster_allowed(): void { this.virtualMachineService.getClusterAllowed().subscribe((res: any): void => { - this.cluster_allowed = res['allowed']; - }); + this.cluster_allowed = res['allowed'] + }) } public get_is_facility_manager(): void { this.facilityService.getManagerFacilities().subscribe((result: any): void => { if (result.length > 0) { - this.is_facility_manager = true; - let svm_manager: boolean = false; + this.is_facility_manager = true + let svm_manager: boolean = false for (const facility of result) { if (facility['SimpleVM']) { - svm_manager = true; - break; + svm_manager = true + break } } - this.is_simple_vm_manager = svm_manager; + this.is_simple_vm_manager = svm_manager } - }); + }) } is_vm_project_member(): void { this.groupService.getSimpleVmByUser().subscribe((result: any): void => { if (result.length > 0) { - this.vm_project_member = true; + this.vm_project_member = true } - }); + }) } is_workshop_admin(): void { this.groupService.getSimpleVmByUserWhereWorkshopAndAdmin().subscribe((result: any): void => { if (result.length > 0) { - this.has_workshops = true; + this.has_workshops = true } - }); + }) } getGroupsEnumeration(): void { this.groupService.getGroupsEnumeration().subscribe((res: ProjectEnumeration[]): void => { - this.project_enumeration = res; + this.project_enumeration = res this.project_enumeration.forEach((enumeration: ProjectEnumeration): void => { - this.pushAdditionalStates(enumeration); - }); + this.pushAdditionalStates(enumeration) + }) this.project_enumeration.sort((firstProject: ProjectEnumeration, secondProject: ProjectEnumeration): number => { if (firstProject.is_open_stack && !secondProject.is_open_stack) { - return -1; + return -1 } if (!firstProject.is_open_stack && secondProject.is_open_stack) { - return 1; + return 1 } - return 0; - }); - }); + return 0 + }) + }) } ngOnInit(): void { - this.set_cluster_allowed(); - this.getGroupsEnumeration(); - this.is_vm_project_member(); - this.is_workshop_admin(); - this.get_is_facility_manager(); - this.getLoginName(); - this.getMissingConsents(); - this.getMaintenanceTimeFrames(); - this.maintenanceInformationLoop(); + this.set_cluster_allowed() + this.getGroupsEnumeration() + this.is_vm_project_member() + this.is_workshop_admin() + this.get_is_facility_manager() + this.getLoginName() + this.getMissingConsents() + this.getMaintenanceTimeFrames() + this.maintenanceInformationLoop() - this.is_vo_admin = is_vo; + this.is_vo_admin = is_vo } getMaintenanceTimeFrames(): void { @@ -198,49 +198,49 @@ export class FullLayoutComponent extends ApplicationBaseClassComponent implement next: (mtf: MaintenanceTimeFrame[]) => { this.maintenanceTimeframes = mtf.sort((a, b) => { if (a.start_time < b.start_time) { - return -1; + return -1 } else if (a.start_time > b.start_time) { - return 1; + return 1 } else { - return 0; + return 0 } - }); - this.maintenanceTimeframesLoaded = true; + }) + this.maintenanceTimeframesLoaded = true }, error: () => { - this.maintenanceTimeframesLoaded = false; - }, - }); + this.maintenanceTimeframesLoaded = false + } + }) this.userService.getUserInfo().subscribe( (login: any): void => { this.maintenanceService.getNumberOfUnconfirmedTimeFrames(login['ElixirId']).subscribe((nxt: any) => { - this.numberOfConfirmableTimeframes = nxt['confirmable']; - }); + this.numberOfConfirmableTimeframes = nxt['confirmable'] + }) }, () => { - console.log('An error occurred'); - }, - ); + console.log('An error occurred') + } + ) } getLoginName(): void { this.userService.getLoginElixirName().subscribe((login: IResponseTemplate): void => { - this.login_name = login.value as string; - }); + this.login_name = login.value as string + }) } getMissingConsents(): void { this.userService.getMissingConsents().subscribe((missingConsents: string[]) => { - this.missing_consents = missingConsents; - }); + this.missing_consents = missingConsents + }) } toggleOverviews(): void { - this.show_overviews = !this.show_overviews; + this.show_overviews = !this.show_overviews } toggleProjectsNav(): void { - this.show_projects = !this.show_projects; + this.show_projects = !this.show_projects } /** @@ -249,36 +249,36 @@ export class FullLayoutComponent extends ApplicationBaseClassComponent implement * @param enumeration */ pushAdditionalStates(enumeration: ProjectEnumeration): void { - const days_left: number = this.getDaysLeft(enumeration); - const days_running: number = this.getDaysRunning(enumeration); + const days_left: number = this.getDaysLeft(enumeration) + const days_running: number = this.getDaysRunning(enumeration) if (enumeration.project_application_statuses.includes(Application_States.APPROVED)) { if (days_left < 14 && days_left >= 0) { - enumeration.project_application_statuses.push(Application_States.EXPIRES_SOON); + enumeration.project_application_statuses.push(Application_States.EXPIRES_SOON) } else if (days_left < 0) { - enumeration.project_application_statuses.push(Application_States.EXPIRED); + enumeration.project_application_statuses.push(Application_States.EXPIRED) } if (days_running < 14) { - enumeration.project_application_statuses.push(Application_States.APPROVED_LAST_2_WEEKS); + enumeration.project_application_statuses.push(Application_States.APPROVED_LAST_2_WEEKS) } } } getDaysLeft(projEnum: ProjectEnumeration): number { const expirationDate: string = moment( - moment(projEnum.project_start_date).add(projEnum.project_lifetime, 'months').toDate(), - ).format('DD.MM.YYYY'); + moment(projEnum.project_start_date).add(projEnum.project_lifetime, 'months').toDate() + ).format('DD.MM.YYYY') const lifetimeDays: number = Math.abs( - moment(moment(expirationDate, 'DD.MM.YYYY').toDate()).diff(moment(projEnum.project_start_date), 'days'), - ); + moment(moment(expirationDate, 'DD.MM.YYYY').toDate()).diff(moment(projEnum.project_start_date), 'days') + ) - const daysRunning: number = this.getDaysRunning(projEnum); + const daysRunning: number = this.getDaysRunning(projEnum) - return lifetimeDays - daysRunning; + return lifetimeDays - daysRunning } getDaysRunning(projectEnumeration: ProjectEnumeration): number { return Math.ceil( - Math.abs(Date.now() - new Date(projectEnumeration.project_start_date).getTime()) / (1000 * 3600 * 24), - ); + Math.abs(Date.now() - new Date(projectEnumeration.project_start_date).getTime()) / (1000 * 3600 * 24) + ) } } diff --git a/src/app/logged-in-guard.service.ts b/src/app/logged-in-guard.service.ts index 48846918fd..5132c40d3b 100644 --- a/src/app/logged-in-guard.service.ts +++ b/src/app/logged-in-guard.service.ts @@ -1,13 +1,11 @@ -import { Injectable } from '@angular/core'; -import { - ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree, -} from '@angular/router'; -import { Observable } from 'rxjs'; -import { CookieService } from 'ngx-cookie-service'; -import { HttpClient } from '@angular/common/http'; -import { map } from 'rxjs/operators'; -import { UserService } from './api-connector/user.service'; -import { environment } from '../environments/environment'; +import { Injectable } from '@angular/core' +import { ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree } from '@angular/router' +import { Observable } from 'rxjs' +import { CookieService } from 'ngx-cookie-service' +import { HttpClient } from '@angular/common/http' +import { map } from 'rxjs/operators' +import { UserService } from './api-connector/user.service' +import { environment } from '../environments/environment' /** * Guard which checks if the user is member of the vo. @@ -18,7 +16,7 @@ export class LoggedInGuard { private http: HttpClient, private cookieService: CookieService, private router: Router, - private userService: UserService, + private userService: UserService ) { // constructor for LoggedInGuard } @@ -27,13 +25,13 @@ export class LoggedInGuard { return this.userService.getOnlyLoggedUserWithRedirect(state.url).pipe( map((res: any): boolean => { if ('error' in res) { - window.location.href = environment.login; + window.location.href = environment.login - return false; + return false } - return true; - }), - ); + return true + }) + ) } } diff --git a/src/app/maintenance/maintenance-alert.component.ts b/src/app/maintenance/maintenance-alert.component.ts index 7e0d330916..1bd0a0cf8f 100644 --- a/src/app/maintenance/maintenance-alert.component.ts +++ b/src/app/maintenance/maintenance-alert.component.ts @@ -1,71 +1,69 @@ -import { - Component, OnInit, OnDestroy, EventEmitter, Output, -} from '@angular/core'; -import { Subscription } from 'rxjs'; +import { Component, OnInit, OnDestroy, EventEmitter, Output } from '@angular/core' +import { Subscription } from 'rxjs' -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { MaintenanceTimeFrame } from '../vo_manager/maintenance/maintenanceTimeFrame.model'; -import { MaintenanceService } from '../api-connector/maintenance.service'; -import { UserService } from '../api-connector/user.service'; -import { NotificationModalComponent } from '../shared/modal/notification-modal'; +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { MaintenanceTimeFrame } from '../vo_manager/maintenance/maintenanceTimeFrame.model' +import { MaintenanceService } from '../api-connector/maintenance.service' +import { UserService } from '../api-connector/user.service' +import { NotificationModalComponent } from '../shared/modal/notification-modal' @Component({ selector: 'app-maintenance-alert', templateUrl: './maintenance-alert.component.html', styleUrls: ['./maintenance-alert.component.scss'], - providers: [MaintenanceService], + providers: [MaintenanceService] }) export class MaintenanceAlertComponent implements OnInit, OnDestroy { - subscription: Subscription = new Subscription(); - maintenanceTimeFrames: MaintenanceTimeFrame[]; - numberOfConfirmableTimeframes: number = 0; - frames_loaded: boolean = false; - error_on_loading: boolean = false; - bsModalRef: BsModalRef; - @Output() confirmEventEmitter: EventEmitter = new EventEmitter(); + subscription: Subscription = new Subscription() + maintenanceTimeFrames: MaintenanceTimeFrame[] + numberOfConfirmableTimeframes: number = 0 + frames_loaded: boolean = false + error_on_loading: boolean = false + bsModalRef: BsModalRef + @Output() confirmEventEmitter: EventEmitter = new EventEmitter() constructor( private maintenanceService: MaintenanceService, private userService: UserService, - private modalService: BsModalService, + private modalService: BsModalService ) { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { - this.subscription = new Subscription(); - this.get_timeframes(); + this.subscription = new Subscription() + this.get_timeframes() } ngOnDestroy(): void { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } showNotificationModal( notificationModalTitle: string, notificationModalMessage: string, - notificationModalType: string, + notificationModalType: string ) { - const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage }; + const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage } if (this.bsModalRef) { - this.bsModalRef.hide(); + this.bsModalRef.hide() } - this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); + this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') } getNumberOfConfirmableTimeframes(): void { this.userService.getUserInfo().subscribe( (login: any): void => { this.maintenanceService.getNumberOfUnconfirmedTimeFrames(login['ElixirId']).subscribe((nxt: any) => { - this.numberOfConfirmableTimeframes = nxt['confirmable']; - }); + this.numberOfConfirmableTimeframes = nxt['confirmable'] + }) }, () => { - console.log('An error occurred'); - }, - ); + console.log('An error occurred') + } + ) } confirmTakenNote(): void { @@ -73,20 +71,20 @@ export class MaintenanceAlertComponent implements OnInit, OnDestroy { this.userService.getUserInfo().subscribe( (login: any): void => { this.maintenanceService.confirmNote(login['ElixirId'], this.maintenanceTimeFrames).subscribe(() => { - this.confirmEventEmitter.emit(); - this.getNumberOfConfirmableTimeframes(); + this.confirmEventEmitter.emit() + this.getNumberOfConfirmableTimeframes() this.showNotificationModal( 'Success', 'You have successfully confirmed that you are aware of the maintenance periods.', - 'success', - ); - }); + 'success' + ) + }) }, () => { - this.showNotificationModal('Failed', 'The confirmation of the awareness failed!', 'danger'); - }, - ), - ); + this.showNotificationModal('Failed', 'The confirmation of the awareness failed!', 'danger') + } + ) + ) } get_timeframes(): void { this.subscription.add( @@ -94,22 +92,22 @@ export class MaintenanceAlertComponent implements OnInit, OnDestroy { next: (mtf: MaintenanceTimeFrame[]) => { this.maintenanceTimeFrames = mtf.sort((a, b) => { if (a.start_time < b.start_time) { - return -1; + return -1 } else if (a.start_time > b.start_time) { - return 1; + return 1 } else { - return 0; + return 0 } - }); - this.error_on_loading = false; - this.frames_loaded = true; + }) + this.error_on_loading = false + this.frames_loaded = true }, error: () => { - this.error_on_loading = true; - this.frames_loaded = true; - }, - }), - ); - this.getNumberOfConfirmableTimeframes(); + this.error_on_loading = true + this.frames_loaded = true + } + }) + ) + this.getNumberOfConfirmableTimeframes() } } diff --git a/src/app/member-guard.service.ts b/src/app/member-guard.service.ts index 2e01961d81..7a5c0ddf1d 100644 --- a/src/app/member-guard.service.ts +++ b/src/app/member-guard.service.ts @@ -1,16 +1,14 @@ -import { Injectable } from '@angular/core'; -import { - ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree, -} from '@angular/router'; -import { Observable } from 'rxjs'; -import { CookieService } from 'ngx-cookie-service'; -import { HttpClient } from '@angular/common/http'; -import { map, switchMap } from 'rxjs/operators'; -import { UserService } from './api-connector/user.service'; -import { environment } from '../environments/environment'; -import { IResponseTemplate } from './api-connector/response-template'; -import { VoService } from './api-connector/vo.service'; -import { setElixirId, setVO } from './shared/globalvar'; +import { Injectable } from '@angular/core' +import { ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree } from '@angular/router' +import { Observable } from 'rxjs' +import { CookieService } from 'ngx-cookie-service' +import { HttpClient } from '@angular/common/http' +import { map, switchMap } from 'rxjs/operators' +import { UserService } from './api-connector/user.service' +import { environment } from '../environments/environment' +import { IResponseTemplate } from './api-connector/response-template' +import { VoService } from './api-connector/vo.service' +import { setElixirId, setVO } from './shared/globalvar' /** * Guard which checks if the user is member of the VO. @@ -22,48 +20,48 @@ export class MemberGuardService { private cookieService: CookieService, private router: Router, private userService: UserService, - private voService: VoService, + private voService: VoService ) {} canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { - const redirectUrl = state.url; - const cookieValue = this.cookieService.get('redirect_after_login'); + const redirectUrl = state.url + const cookieValue = this.cookieService.get('redirect_after_login') - this.cookieService.delete('redirect_after_login', '/', environment.domain); - this.cookieService.delete('redirect_after_login', '/portal', environment.domain); + this.cookieService.delete('redirect_after_login', '/', environment.domain) + this.cookieService.delete('redirect_after_login', '/portal', environment.domain) return this.userService.getOnlyLoggedUserWithRedirect(cookieValue || redirectUrl).pipe( switchMap((res: any): Observable => { if (res['error']) { - window.location.href = environment.debugin; + window.location.href = environment.debugin - return new Observable(); + return new Observable() } else { this.voService.isVo().subscribe((result: IResponseTemplate): void => { - setVO(result.value as boolean); - }); + setVO(result.value as boolean) + }) this.userService.getLoggedUserElixirId().subscribe((result: any): void => { - setElixirId(result['elixir_id']); - }); + setElixirId(result['elixir_id']) + }) return this.userService.getIsCurrentUserVoMember().pipe( map((memberInfo: any): boolean | UrlTree => { if (!memberInfo['isMember']) { - return this.router.parseUrl('/registration-info'); + return this.router.parseUrl('/registration-info') } if (cookieValue) { - const val: string = cookieValue.substring(2, cookieValue.length - 1); - this.cookieService.delete('redirect_after_login', '/', environment.domain); - this.cookieService.delete('redirect_after_login', '/portal', environment.domain); + const val: string = cookieValue.substring(2, cookieValue.length - 1) + this.cookieService.delete('redirect_after_login', '/', environment.domain) + this.cookieService.delete('redirect_after_login', '/portal', environment.domain) - return this.router.parseUrl(val); + return this.router.parseUrl(val) } - return true; - }), - ); + return true + }) + ) } - }), - ); + }) + ) } } diff --git a/src/app/news/news-slide/news-slide.component.ts b/src/app/news/news-slide/news-slide.component.ts index 9830397b90..bb55798010 100644 --- a/src/app/news/news-slide/news-slide.component.ts +++ b/src/app/news/news-slide/news-slide.component.ts @@ -1,18 +1,16 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { News } from '../news.model'; +import { Component, Input, OnInit } from '@angular/core' +import { News } from '../news.model' @Component({ selector: 'app-news-slide', templateUrl: './news-slide.component.html', - styleUrls: ['./news-slide.component.scss'], + styleUrls: ['./news-slide.component.scss'] }) export class NewsSlideComponent implements OnInit { - - window_size: number; - @Input() news: News; + window_size: number + @Input() news: News ngOnInit(): void { - this.window_size = window.innerWidth; + this.window_size = window.innerWidth } - } diff --git a/src/app/news/news.component.ts b/src/app/news/news.component.ts index f8cb143f10..dee5097fdc 100644 --- a/src/app/news/news.component.ts +++ b/src/app/news/news.component.ts @@ -1,29 +1,27 @@ -import { - Component, OnInit, OnDestroy, Input, -} from '@angular/core'; -import { Subscription } from 'rxjs'; -import { OwlOptions } from 'ngx-owl-carousel-o'; -import { NewsService } from '../api-connector/news.service'; -import { News } from './news.model'; -import { ProjectEnumeration } from '../projectmanagement/project-enumeration'; -import { GroupService } from '../api-connector/group.service'; +import { Component, OnInit, OnDestroy, Input } from '@angular/core' +import { Subscription } from 'rxjs' +import { OwlOptions } from 'ngx-owl-carousel-o' +import { NewsService } from '../api-connector/news.service' +import { News } from './news.model' +import { ProjectEnumeration } from '../projectmanagement/project-enumeration' +import { GroupService } from '../api-connector/group.service' @Component({ selector: 'app-news', templateUrl: './news.component.html', styleUrls: ['./news.component.scss'], - providers: [NewsService], + providers: [NewsService] }) export class NewsComponent implements OnInit, OnDestroy { - @Input() tags: string[] = []; - facilities: number[] = []; - @Input() cards_per_page: number = 3; - @Input() max_news_amount: number = 6; - subscription: Subscription = new Subscription(); - news: News[] = []; - news_loaded: boolean = false; - error_on_loading: boolean = false; - error_message: string = 'No News to display.'; + @Input() tags: string[] = [] + facilities: number[] = [] + @Input() cards_per_page: number = 3 + @Input() max_news_amount: number = 6 + subscription: Subscription = new Subscription() + news: News[] = [] + news_loaded: boolean = false + error_on_loading: boolean = false + error_message: string = 'No News to display.' custom_options: OwlOptions = { rewind: true, autoplay: true, @@ -40,59 +38,59 @@ export class NewsComponent implements OnInit, OnDestroy { navText: ["", ""], responsive: { 0: { - items: 1, + items: 1 }, 550: { - items: 2, + items: 2 }, 800: { - items: 3, + items: 3 }, 1200: { - items: 4, - }, + items: 4 + } }, - nav: true, - }; + nav: true + } constructor( private news_service: NewsService, - private groupService: GroupService, + private groupService: GroupService ) { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { - this.subscription = new Subscription(); - this.get_news(); + this.subscription = new Subscription() + this.get_news() } ngOnDestroy(): void { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } get_news(): void { - this.facilities = []; + this.facilities = [] this.subscription.add( this.groupService.getGroupsEnumeration().subscribe((res: ProjectEnumeration[]): void => { for (const projectEnumeration of res) { if (!this.facilities.includes(projectEnumeration.facility_id)) { if (projectEnumeration.facility_id !== undefined) { - this.facilities.push(projectEnumeration.facility_id); + this.facilities.push(projectEnumeration.facility_id) } } } this.news_service.getNewsByTags(this.max_news_amount, this.tags, this.facilities).subscribe( (news: News[]) => { - this.news = news; - this.news_loaded = true; + this.news = news + this.news_loaded = true }, () => { - this.news_loaded = true; - this.error_on_loading = true; - }, - ); - }), - ); + this.news_loaded = true + this.error_on_loading = true + } + ) + }) + ) } } diff --git a/src/app/news/news.module.ts b/src/app/news/news.module.ts index 8f6766a062..0d61f95c44 100644 --- a/src/app/news/news.module.ts +++ b/src/app/news/news.module.ts @@ -1,9 +1,9 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { CarouselModule } from 'ngx-owl-carousel-o'; -import { NewsComponent } from './news.component'; -import { NewsSlideComponent } from './news-slide/news-slide.component'; -import { MaintenanceAlertComponent } from '../maintenance/maintenance-alert.component'; +import { NgModule } from '@angular/core' +import { CommonModule } from '@angular/common' +import { CarouselModule } from 'ngx-owl-carousel-o' +import { NewsComponent } from './news.component' +import { NewsSlideComponent } from './news-slide/news-slide.component' +import { MaintenanceAlertComponent } from '../maintenance/maintenance-alert.component' /** * Userinfo module. @@ -12,6 +12,6 @@ import { MaintenanceAlertComponent } from '../maintenance/maintenance-alert.comp imports: [CarouselModule, CommonModule], declarations: [NewsComponent, NewsSlideComponent, MaintenanceAlertComponent], - exports: [NewsComponent, MaintenanceAlertComponent], + exports: [NewsComponent, MaintenanceAlertComponent] }) export class NewsModule {} diff --git a/src/app/pipe-module/pipe-module.module.ts b/src/app/pipe-module/pipe-module.module.ts index 1cf3c30200..188f6fb8b2 100644 --- a/src/app/pipe-module/pipe-module.module.ts +++ b/src/app/pipe-module/pipe-module.module.ts @@ -1,23 +1,23 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FlavorCounterPipe } from './pipes/flavorcounter'; -import { HasstatusinlistPipe } from './pipes/hasstatusinlist.pipe'; -import { InListPipe } from './pipes/in-list.pipe'; -import { HasStatusPipe, StatusInListPipe } from './pipes/has-status.pipe'; -import { IsPiApprovedPipe } from './pipes/is-pi-approved'; -import { FloorIntegerPipe } from './pipes/floor-integer.pipe'; -import { InAllowedPipe } from './pipes/in-allowed.pipe'; -import { NoCoresPipe, NoRamPipe, NoVMsPipe } from './pipes/ressources'; -import { HasUnavailableFlavorsPipe } from './pipes/has-unavailable-flavors.pipe'; -import { ValidTimeFramePipe } from './pipes/validTimeFrame.pipe'; -import { PublicKeyPipe } from './pipes/publicKey.pipe'; -import { IsFutureTimePipe } from './pipes/futureTime.pipe'; -import { IsMigratedProjectIdPipe } from './pipes/migratedList'; -import { HasStatusNotInListPipe } from './pipes/has-status-not-in-list.pipe'; -import { SignificancePipe } from '../shared/shared_modules/components/maintenance-notification/significance-pipe/significance.pipe'; -import { SocialConsentGivenPipe } from './pipes/social-consent-given.pipe'; -import { IsMigratedProjectPipe } from './pipes/isMigratedProject'; -import { HasFlavorTypeOrIsNotCustomPipe } from './pipes/has-flavor-type.pipe'; +import { NgModule } from '@angular/core' +import { CommonModule } from '@angular/common' +import { FlavorCounterPipe } from './pipes/flavorcounter' +import { HasstatusinlistPipe } from './pipes/hasstatusinlist.pipe' +import { InListPipe } from './pipes/in-list.pipe' +import { HasStatusPipe, StatusInListPipe } from './pipes/has-status.pipe' +import { IsPiApprovedPipe } from './pipes/is-pi-approved' +import { FloorIntegerPipe } from './pipes/floor-integer.pipe' +import { InAllowedPipe } from './pipes/in-allowed.pipe' +import { NoCoresPipe, NoRamPipe, NoVMsPipe } from './pipes/ressources' +import { HasUnavailableFlavorsPipe } from './pipes/has-unavailable-flavors.pipe' +import { ValidTimeFramePipe } from './pipes/validTimeFrame.pipe' +import { PublicKeyPipe } from './pipes/publicKey.pipe' +import { IsFutureTimePipe } from './pipes/futureTime.pipe' +import { IsMigratedProjectIdPipe } from './pipes/migratedList' +import { HasStatusNotInListPipe } from './pipes/has-status-not-in-list.pipe' +import { SignificancePipe } from '../shared/shared_modules/components/maintenance-notification/significance-pipe/significance.pipe' +import { SocialConsentGivenPipe } from './pipes/social-consent-given.pipe' +import { IsMigratedProjectPipe } from './pipes/isMigratedProject' +import { HasFlavorTypeOrIsNotCustomPipe } from './pipes/has-flavor-type.pipe' /** * Pipemodule @@ -44,7 +44,7 @@ import { HasFlavorTypeOrIsNotCustomPipe } from './pipes/has-flavor-type.pipe'; SignificancePipe, SocialConsentGivenPipe, IsMigratedProjectPipe, - HasFlavorTypeOrIsNotCustomPipe, + HasFlavorTypeOrIsNotCustomPipe ], exports: [ FlavorCounterPipe, @@ -67,9 +67,9 @@ import { HasFlavorTypeOrIsNotCustomPipe } from './pipes/has-flavor-type.pipe'; SignificancePipe, SocialConsentGivenPipe, IsMigratedProjectPipe, - HasFlavorTypeOrIsNotCustomPipe, + HasFlavorTypeOrIsNotCustomPipe ], imports: [CommonModule], - providers: [], + providers: [] }) export class PipeModuleModule {} diff --git a/src/app/pipe-module/pipes/flavorcounter.ts b/src/app/pipe-module/pipes/flavorcounter.ts index 95a7f39c20..14c785d538 100644 --- a/src/app/pipe-module/pipes/flavorcounter.ts +++ b/src/app/pipe-module/pipes/flavorcounter.ts @@ -1,16 +1,16 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { ApplicationModification } from '../../applications/application_modification.model'; -import { Application } from '../../applications/application.model/application.model'; -import { Flavor } from '../../virtualmachines/virtualmachinemodels/flavor'; +import { Pipe, PipeTransform } from '@angular/core' +import { ApplicationModification } from '../../applications/application_modification.model' +import { Application } from '../../applications/application.model/application.model' +import { Flavor } from '../../virtualmachines/virtualmachinemodels/flavor' /** * Pipe which returns counter of flavors. */ @Pipe({ - name: 'flavorCounter', + name: 'flavorCounter' }) export class FlavorCounterPipe implements PipeTransform { transform(appl: ApplicationModification | Application, flavor: Flavor): number { - return appl.getFlavorCounter(flavor); + return appl.getFlavorCounter(flavor) } } diff --git a/src/app/pipe-module/pipes/floor-integer.pipe.ts b/src/app/pipe-module/pipes/floor-integer.pipe.ts index 40a8e3704e..029e479439 100644 --- a/src/app/pipe-module/pipes/floor-integer.pipe.ts +++ b/src/app/pipe-module/pipes/floor-integer.pipe.ts @@ -1,14 +1,13 @@ -import { Pipe, PipeTransform } from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core' /** * Pipe which checks if status is in list. */ @Pipe({ - name: 'floorInteger', + name: 'floorInteger' }) export class FloorIntegerPipe implements PipeTransform { - transform(integer: number): number { - return Math.floor(integer); + return Math.floor(integer) } } diff --git a/src/app/pipe-module/pipes/futureTime.pipe.ts b/src/app/pipe-module/pipes/futureTime.pipe.ts index 4eb3b7ef34..24239b31b5 100644 --- a/src/app/pipe-module/pipes/futureTime.pipe.ts +++ b/src/app/pipe-module/pipes/futureTime.pipe.ts @@ -1,18 +1,18 @@ -import { Pipe, PipeTransform } from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core' /** * Pipe to check if the date picked is in the future. */ @Pipe({ name: 'isFutureTime', - pure: false, + pure: false }) export class IsFutureTimePipe implements PipeTransform { transform(date: Date): boolean { if (date === null) { - return false; + return false } - return new Date().getTime() <= date.getTime(); + return new Date().getTime() <= date.getTime() } } diff --git a/src/app/pipe-module/pipes/has-flavor-type.pipe.ts b/src/app/pipe-module/pipes/has-flavor-type.pipe.ts index 2d01493353..97b909a667 100644 --- a/src/app/pipe-module/pipes/has-flavor-type.pipe.ts +++ b/src/app/pipe-module/pipes/has-flavor-type.pipe.ts @@ -1,33 +1,33 @@ -// eslint-disable-next-line max-classes-per-file -import { Pipe, PipeTransform } from '@angular/core'; -import { Application } from 'app/applications/application.model/application.model'; -import { FlavorTypeShortcuts } from 'app/shared/shared_modules/baseClass/flavor-type-shortcuts'; -import { Flavor } from 'app/virtualmachines/virtualmachinemodels/flavor'; -import { FlavorType } from 'app/virtualmachines/virtualmachinemodels/flavorType'; + +import { Pipe, PipeTransform } from '@angular/core' +import { Application } from 'app/applications/application.model/application.model' +import { FlavorTypeShortcuts } from 'app/shared/shared_modules/baseClass/flavor-type-shortcuts' +import { Flavor } from 'app/virtualmachines/virtualmachinemodels/flavor' +import { FlavorType } from 'app/virtualmachines/virtualmachinemodels/flavorType' /** * Pipe which compares status. */ @Pipe({ - name: 'hasFlavorTypeOrIsNotCustom', + name: 'hasFlavorTypeOrIsNotCustom' }) export class HasFlavorTypeOrIsNotCustomPipe implements PipeTransform { transform(project: Application, flavorType: FlavorType): boolean { const hasFlavorTypeFlavor: boolean = project.flavors.some( - (flavor: Flavor): boolean => flavor.type.shortcut === flavorType.shortcut, - ); + (flavor: Flavor): boolean => flavor.type.shortcut === flavorType.shortcut + ) - return hasFlavorTypeFlavor || flavorType.shortcut !== FlavorTypeShortcuts.CUSTOM_FLAVOR; + return hasFlavorTypeFlavor || flavorType.shortcut !== FlavorTypeShortcuts.CUSTOM_FLAVOR } } /** * Pipe which checks if status is in a list. */ @Pipe({ - name: 'statusInList', + name: 'statusInList' }) export class StatusInListPipe implements PipeTransform { transform(status: string, status_list_to_compare: string[]): boolean { - return status_list_to_compare.indexOf(status) !== -1; + return status_list_to_compare.indexOf(status) !== -1 } } diff --git a/src/app/pipe-module/pipes/has-status-not-in-list.pipe.ts b/src/app/pipe-module/pipes/has-status-not-in-list.pipe.ts index bb9d697e10..eb5f7791fa 100644 --- a/src/app/pipe-module/pipes/has-status-not-in-list.pipe.ts +++ b/src/app/pipe-module/pipes/has-status-not-in-list.pipe.ts @@ -1,17 +1,17 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { Application } from '../../applications/application.model/application.model'; -import { ProjectEnumeration } from '../../projectmanagement/project-enumeration'; +import { Pipe, PipeTransform } from '@angular/core' +import { Application } from '../../applications/application.model/application.model' +import { ProjectEnumeration } from '../../projectmanagement/project-enumeration' @Pipe({ name: 'hasstatusnotinlist', - pure: false, + pure: false }) export class HasStatusNotInListPipe implements PipeTransform { transform(appl: Application | ProjectEnumeration, status: number): boolean { if (appl === undefined) { - return false; + return false } - return !appl.project_application_statuses.includes(status); + return !appl.project_application_statuses.includes(status) } } diff --git a/src/app/pipe-module/pipes/has-status.pipe.ts b/src/app/pipe-module/pipes/has-status.pipe.ts index 972e614db1..b91becfb09 100644 --- a/src/app/pipe-module/pipes/has-status.pipe.ts +++ b/src/app/pipe-module/pipes/has-status.pipe.ts @@ -1,25 +1,25 @@ -// eslint-disable-next-line max-classes-per-file -import { Pipe, PipeTransform } from '@angular/core'; + +import { Pipe, PipeTransform } from '@angular/core' /** * Pipe which compares status. */ @Pipe({ - name: 'hasStatus', + name: 'hasStatus' }) export class HasStatusPipe implements PipeTransform { transform(status: string | number, status_to_compare: string | number): boolean { - return status === status_to_compare; + return status === status_to_compare } } /** * Pipe which checks if status is in a list. */ @Pipe({ - name: 'statusInList', + name: 'statusInList' }) export class StatusInListPipe implements PipeTransform { transform(status: string, status_list_to_compare: string[]): boolean { - return status_list_to_compare.indexOf(status) !== -1; + return status_list_to_compare.indexOf(status) !== -1 } } diff --git a/src/app/pipe-module/pipes/has-unavailable-flavors.pipe.ts b/src/app/pipe-module/pipes/has-unavailable-flavors.pipe.ts index a26f11e565..ad44d066f6 100644 --- a/src/app/pipe-module/pipes/has-unavailable-flavors.pipe.ts +++ b/src/app/pipe-module/pipes/has-unavailable-flavors.pipe.ts @@ -1,25 +1,25 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { Flavor } from '../../virtualmachines/virtualmachinemodels/flavor'; +import { Pipe, PipeTransform } from '@angular/core' +import { Flavor } from '../../virtualmachines/virtualmachinemodels/flavor' /** * Pipe which checks if any of the flavors in a given list are unavailable. */ @Pipe({ name: 'hasUnavailableFlavors', - pure: false, + pure: false }) export class HasUnavailableFlavorsPipe implements PipeTransform { transform(flavors: Flavor[]): boolean { if (flavors === undefined || flavors.length === 0) { - return false; + return false } else { for (const flavor of flavors) { if (!flavor.available) { - return true; + return true } } - return false; + return false } } } diff --git a/src/app/pipe-module/pipes/hasstatusinlist.pipe.ts b/src/app/pipe-module/pipes/hasstatusinlist.pipe.ts index 73356a600f..a1bd25359c 100644 --- a/src/app/pipe-module/pipes/hasstatusinlist.pipe.ts +++ b/src/app/pipe-module/pipes/hasstatusinlist.pipe.ts @@ -1,20 +1,20 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { Application } from '../../applications/application.model/application.model'; -import { ProjectEnumeration } from '../../projectmanagement/project-enumeration'; +import { Pipe, PipeTransform } from '@angular/core' +import { Application } from '../../applications/application.model/application.model' +import { ProjectEnumeration } from '../../projectmanagement/project-enumeration' /** * Pipe which checks if status is in list. */ @Pipe({ name: 'hasstatusinlist', - pure: false, + pure: false }) export class HasstatusinlistPipe implements PipeTransform { transform(appl: Application | ProjectEnumeration, status: number): boolean { if (appl === undefined) { - return false; + return false } - return appl.project_application_statuses.includes(status); + return appl.project_application_statuses.includes(status) } } diff --git a/src/app/pipe-module/pipes/in-allowed.pipe.ts b/src/app/pipe-module/pipes/in-allowed.pipe.ts index a5c3fd6b23..1e5fc278e0 100644 --- a/src/app/pipe-module/pipes/in-allowed.pipe.ts +++ b/src/app/pipe-module/pipes/in-allowed.pipe.ts @@ -1,21 +1,19 @@ -import { Pipe, PipeTransform } from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core' /** * Generic Pipe to check if element is in list. */ @Pipe({ - name: 'inAllowed', + name: 'inAllowed' }) export class InAllowedPipe implements PipeTransform { - transform(list: [string, number][], value: [string, number]): boolean { if (value) { - const index: number = list.map(elem => elem[1]).indexOf(value[1]); + const index: number = list.map(elem => elem[1]).indexOf(value[1]) - return index !== -1; + return index !== -1 } else { - return false; + return false } } - } diff --git a/src/app/pipe-module/pipes/in-list.pipe.ts b/src/app/pipe-module/pipes/in-list.pipe.ts index 939bef542e..a313a522d3 100644 --- a/src/app/pipe-module/pipes/in-list.pipe.ts +++ b/src/app/pipe-module/pipes/in-list.pipe.ts @@ -1,15 +1,13 @@ -import { Pipe, PipeTransform } from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core' /** * Generic Pipe to check if element is in list. */ @Pipe({ - name: 'inList', + name: 'inList' }) export class InListPipe implements PipeTransform { - transform(list: any[], value: any): boolean { - return list.indexOf(value) !== -1; + return list.indexOf(value) !== -1 } - } diff --git a/src/app/pipe-module/pipes/is-pi-approved.ts b/src/app/pipe-module/pipes/is-pi-approved.ts index 47614ad3bd..c6f21bc595 100644 --- a/src/app/pipe-module/pipes/is-pi-approved.ts +++ b/src/app/pipe-module/pipes/is-pi-approved.ts @@ -1,20 +1,18 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { Application } from '../../applications/application.model/application.model'; +import { Pipe, PipeTransform } from '@angular/core' +import { Application } from '../../applications/application.model/application.model' /** * Pipe which checks if status is in list. */ @Pipe({ - name: 'isPiApproved', + name: 'isPiApproved' }) export class IsPiApprovedPipe implements PipeTransform { - transform(appl: Application): boolean { if (appl === undefined) { - return false; + return false } - return appl.project_application_pi_approved; + return appl.project_application_pi_approved } - } diff --git a/src/app/pipe-module/pipes/isMigratedProject.ts b/src/app/pipe-module/pipes/isMigratedProject.ts index 9b5d2feae7..5aa39be1e0 100644 --- a/src/app/pipe-module/pipes/isMigratedProject.ts +++ b/src/app/pipe-module/pipes/isMigratedProject.ts @@ -1,14 +1,14 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { Application } from 'app/applications/application.model/application.model'; +import { Pipe, PipeTransform } from '@angular/core' +import { Application } from 'app/applications/application.model/application.model' /** * Pipe which returns whether a certain project is migrated or marked for migration to SimpleVM-Platform. */ @Pipe({ - name: 'isMigratedProject', + name: 'isMigratedProject' }) export class IsMigratedProjectPipe implements PipeTransform { transform(projectApplication: Application) { - return projectApplication.isMigrated(); + return projectApplication.isMigrated() } } diff --git a/src/app/pipe-module/pipes/migratedList.ts b/src/app/pipe-module/pipes/migratedList.ts index ad5101081b..25b43f6316 100644 --- a/src/app/pipe-module/pipes/migratedList.ts +++ b/src/app/pipe-module/pipes/migratedList.ts @@ -1,13 +1,13 @@ -import { Pipe, PipeTransform } from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core' /** * Pipe which returns whether a project id belongs to a migrated project or not. */ @Pipe({ - name: 'isMigratedProjectId', + name: 'isMigratedProjectId' }) export class IsMigratedProjectIdPipe implements PipeTransform { transform(pid: string | number, list: string[]) { - return list.includes(pid.toString()); + return list.includes(pid.toString()) } } diff --git a/src/app/pipe-module/pipes/publicKey.pipe.ts b/src/app/pipe-module/pipes/publicKey.pipe.ts index 206dd99bb1..d66c5613aa 100644 --- a/src/app/pipe-module/pipes/publicKey.pipe.ts +++ b/src/app/pipe-module/pipes/publicKey.pipe.ts @@ -1,23 +1,23 @@ -import { Pipe, PipeTransform } from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core' /** * Pipe which checks for validity of ssh-key. */ @Pipe({ - name: 'isValidKeyPipe', + name: 'isValidKeyPipe' }) export class PublicKeyPipe implements PipeTransform { transform(key: string): boolean { if (key === undefined || key === null) { - return false; + return false } - key = key.trim(); - const valid_rsa: boolean = /^ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(key); - const valid_ecdsa_521: boolean = /^ecdsa-sha2-nistp521 AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(key); - const valid_ecdsa_256: boolean = /^ecdsa-sha2-nistp256 AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(key); - const valid_ecdsa_384: boolean = /^ecdsa-sha2-nistp384 AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(key); - const valid_ed25519: boolean = /^ssh-ed25519 AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(key); + key = key.trim() + const valid_rsa: boolean = /^ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(key) + const valid_ecdsa_521: boolean = /^ecdsa-sha2-nistp521 AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(key) + const valid_ecdsa_256: boolean = /^ecdsa-sha2-nistp256 AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(key) + const valid_ecdsa_384: boolean = /^ecdsa-sha2-nistp384 AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(key) + const valid_ed25519: boolean = /^ssh-ed25519 AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(key) - return valid_rsa || valid_ecdsa_256 || valid_ecdsa_384 || valid_ecdsa_521 || valid_ed25519; + return valid_rsa || valid_ecdsa_256 || valid_ecdsa_384 || valid_ecdsa_521 || valid_ed25519 } } diff --git a/src/app/pipe-module/pipes/ressources.ts b/src/app/pipe-module/pipes/ressources.ts index 8e53e5214e..f8c1bfb970 100644 --- a/src/app/pipe-module/pipes/ressources.ts +++ b/src/app/pipe-module/pipes/ressources.ts @@ -1,19 +1,19 @@ -// eslint-disable-next-line max-classes-per-file -import { Pipe, PipeTransform } from '@angular/core'; -import { ApplicationRessourceUsage } from '../../applications/application-ressource-usage/application-ressource-usage'; + +import { Pipe, PipeTransform } from '@angular/core' +import { ApplicationRessourceUsage } from '../../applications/application-ressource-usage/application-ressource-usage' /** * Pipe which compares status. */ @Pipe({ - name: 'noVMsPipe', + name: 'noVMsPipe' }) export class NoVMsPipe implements PipeTransform { transform(ressources: ApplicationRessourceUsage, additional_vms: number = 0): boolean { if (additional_vms > 0) { - return ressources.used_vms + additional_vms > ressources.number_vms; + return ressources.used_vms + additional_vms > ressources.number_vms } else { - return ressources.used_vms >= ressources.number_vms; + return ressources.used_vms >= ressources.number_vms } } } @@ -22,11 +22,11 @@ export class NoVMsPipe implements PipeTransform { * Pipe which compares status. */ @Pipe({ - name: 'noCoresPipe', + name: 'noCoresPipe' }) export class NoCoresPipe implements PipeTransform { transform(ressources: ApplicationRessourceUsage): boolean { - return ressources.cores_used >= ressources.cores_total; + return ressources.cores_used >= ressources.cores_total } } @@ -34,10 +34,10 @@ export class NoCoresPipe implements PipeTransform { * Pipe which compares status. */ @Pipe({ - name: 'noRamPipe', + name: 'noRamPipe' }) export class NoRamPipe implements PipeTransform { transform(ressources: ApplicationRessourceUsage): boolean { - return ressources.ram_used >= ressources.ram_total; + return ressources.ram_used >= ressources.ram_total } } diff --git a/src/app/pipe-module/pipes/social-consent-given.pipe.ts b/src/app/pipe-module/pipes/social-consent-given.pipe.ts index 8a32f75fba..4578b0f264 100644 --- a/src/app/pipe-module/pipes/social-consent-given.pipe.ts +++ b/src/app/pipe-module/pipes/social-consent-given.pipe.ts @@ -1,19 +1,19 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { SocialConsent } from 'app/shared/shared_modules/testimonial-forms/social-consent.model'; +import { Pipe, PipeTransform } from '@angular/core' +import { SocialConsent } from 'app/shared/shared_modules/testimonial-forms/social-consent.model' /** * Generic Pipe to check if element is in list. */ @Pipe({ - name: 'socialConsentGiven', + name: 'socialConsentGiven' }) export class SocialConsentGivenPipe implements PipeTransform { transform(list: SocialConsent[], value: SocialConsent): boolean { - const idx: number = list.findIndex(consent => consent.id === value.id); + const idx: number = list.findIndex(consent => consent.id === value.id) if (idx !== -1) { - return true; + return true } else { - return false; + return false } } } diff --git a/src/app/pipe-module/pipes/validTimeFrame.pipe.ts b/src/app/pipe-module/pipes/validTimeFrame.pipe.ts index 10e42f4237..bfa3076ff4 100644 --- a/src/app/pipe-module/pipes/validTimeFrame.pipe.ts +++ b/src/app/pipe-module/pipes/validTimeFrame.pipe.ts @@ -1,23 +1,23 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { WorkshopTimeFrame } from '../../virtualmachines/workshop/workshopTimeFrame.model'; -import { MaintenanceTimeFrame } from '../../vo_manager/maintenance/maintenanceTimeFrame.model'; +import { Pipe, PipeTransform } from '@angular/core' +import { WorkshopTimeFrame } from '../../virtualmachines/workshop/workshopTimeFrame.model' +import { MaintenanceTimeFrame } from '../../vo_manager/maintenance/maintenanceTimeFrame.model' /** * Pipe to check if the timeframe set is valid, which means that the start-time is before the end time. */ @Pipe({ name: 'isValidTimeFrame', - pure: false, + pure: false }) export class ValidTimeFramePipe implements PipeTransform { transform(timeframe: WorkshopTimeFrame | MaintenanceTimeFrame): boolean { if (timeframe === null || timeframe.start_time === null || timeframe.end_time === null) { - return false; + return false } return ( - new Date().getTime() <= timeframe.start_time.getTime() - && timeframe.start_time.getTime() < timeframe.end_time.getTime() - ); + new Date().getTime() <= timeframe.start_time.getTime() && + timeframe.start_time.getTime() < timeframe.end_time.getTime() + ) } } diff --git a/src/app/projectmanagement/application-progress/application-progress.component.ts b/src/app/projectmanagement/application-progress/application-progress.component.ts index 95320d12a3..25e1488d1d 100644 --- a/src/app/projectmanagement/application-progress/application-progress.component.ts +++ b/src/app/projectmanagement/application-progress/application-progress.component.ts @@ -1,7 +1,7 @@ -import { Component, Input } from '@angular/core'; -import { ApplicationBaseClassComponent } from '../../shared/shared_modules/baseClass/application-base-class.component'; -import { Application } from '../../applications/application.model/application.model'; -import { Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class'; +import { Component, Input } from '@angular/core' +import { ApplicationBaseClassComponent } from '../../shared/shared_modules/baseClass/application-base-class.component' +import { Application } from '../../applications/application.model/application.model' +import { Application_States } from '../../shared/shared_modules/baseClass/abstract-base-class' /** * Components displays progress of given application. @@ -10,11 +10,9 @@ import { Application_States } from '../../shared/shared_modules/baseClass/abstra selector: 'app-application-progress', templateUrl: './application-progress.component.html', styleUrls: ['./application-progress.component.scss'], - providers: [], + providers: [] }) - export class ApplicationProgressComponent extends ApplicationBaseClassComponent { - - @Input() application: Application; - Application_States: typeof Application_States = Application_States; + @Input() application: Application + Application_States: typeof Application_States = Application_States } diff --git a/src/app/projectmanagement/modals/adjust-application/adjust-application.component.ts b/src/app/projectmanagement/modals/adjust-application/adjust-application.component.ts index bd6c98ff84..2c5841deb7 100644 --- a/src/app/projectmanagement/modals/adjust-application/adjust-application.component.ts +++ b/src/app/projectmanagement/modals/adjust-application/adjust-application.component.ts @@ -1,187 +1,185 @@ -import { - Component, EventEmitter, Injectable, OnInit, Output, -} from '@angular/core'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { Application } from '../../../applications/application.model/application.model'; -import { CreditsService } from '../../../api-connector/credits.service'; -import { ApplicationsService } from '../../../api-connector/applications.service'; -import { Flavor } from '../../../virtualmachines/virtualmachinemodels/flavor'; -import { FlavorType } from '../../../virtualmachines/virtualmachinemodels/flavorType'; -import { FlavorService } from '../../../api-connector/flavor.service'; -import { FlavorTypeShortcuts } from '../../../shared/shared_modules/baseClass/flavor-type-shortcuts'; +import { Component, EventEmitter, Injectable, OnInit, Output } from '@angular/core' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { Application } from '../../../applications/application.model/application.model' +import { CreditsService } from '../../../api-connector/credits.service' +import { ApplicationsService } from '../../../api-connector/applications.service' +import { Flavor } from '../../../virtualmachines/virtualmachinemodels/flavor' +import { FlavorType } from '../../../virtualmachines/virtualmachinemodels/flavorType' +import { FlavorService } from '../../../api-connector/flavor.service' +import { FlavorTypeShortcuts } from '../../../shared/shared_modules/baseClass/flavor-type-shortcuts' @Injectable({ providedIn: 'root' }) @Component({ selector: 'app-application', templateUrl: './adjust-application.component.html', - providers: [ApplicationsService], + providers: [ApplicationsService] }) export class AdjustApplicationComponent implements OnInit { - bsModalRef = BsModalRef; - loaded: boolean = false; - loadedFlavorTypes: boolean = false; - loadedFlavors: boolean = false; - modalId: number | string | undefined; - totalNumberOfCores: number = 0; + bsModalRef = BsModalRef + loaded: boolean = false + loadedFlavorTypes: boolean = false + loadedFlavors: boolean = false + modalId: number | string | undefined + totalNumberOfCores: number = 0 newFlavors: { [id: string]: { counter: number flavor: Flavor } - } = {}; - totalRAM: number = 0; - atLeastOneVM: boolean = false; + } = {} + totalRAM: number = 0 + atLeastOneVM: boolean = false - totalGPU: number = 0; - typeList: FlavorType[]; - flavorList: Flavor[] = []; + totalGPU: number = 0 + typeList: FlavorType[] + flavorList: Flavor[] = [] - application: Application; - adjustedApplication: Application; - FlavorTypeShortcuts: typeof FlavorTypeShortcuts = FlavorTypeShortcuts; + application: Application + adjustedApplication: Application + FlavorTypeShortcuts: typeof FlavorTypeShortcuts = FlavorTypeShortcuts - @Output() eventSuccess: EventEmitter = new EventEmitter(); + @Output() eventSuccess: EventEmitter = new EventEmitter() constructor( private modalService: BsModalService, private applicationsService: ApplicationsService, private creditsService: CreditsService, - private flavorService: FlavorService, + private flavorService: FlavorService ) {} ngOnInit() { - this.loaded = false; - this.loadedFlavorTypes = false; - this.loadedFlavors = false; - this.adjustedApplication = new Application(this.application); - this.getAvailableFlavorTypes(); - this.getAvailableFlavors(); + this.loaded = false + this.loadedFlavorTypes = false + this.loadedFlavors = false + this.adjustedApplication = new Application(this.application) + this.getAvailableFlavorTypes() + this.getAvailableFlavors() } getAvailableFlavors() { this.flavorService.getListOfFlavorsAvailable(undefined, undefined, true).subscribe((flavList: Flavor[]): void => { - this.flavorList = flavList; - this.loadedFlavors = true; - this.loaded = this.loadedFlavorTypes && this.loadedFlavors; - }); + this.flavorList = flavList + this.loadedFlavors = true + this.loaded = this.loadedFlavorTypes && this.loadedFlavors + }) } getAvailableFlavorTypes() { this.flavorService.getListOfTypesAvailable().subscribe((availableTypes: FlavorType[]): void => { - this.typeList = availableTypes; - this.loadedFlavorTypes = true; - this.loaded = this.loadedFlavorTypes && this.loadedFlavors; - }); + this.typeList = availableTypes + this.loadedFlavorTypes = true + this.loaded = this.loadedFlavorTypes && this.loadedFlavors + }) } calculateRamCores(): void { - this.totalNumberOfCores = 0; - this.totalRAM = 0; - this.totalGPU = 0; + this.totalNumberOfCores = 0 + this.totalRAM = 0 + this.totalGPU = 0 // tslint:disable-next-line:forin for (const extensionFlavorsKey in this.newFlavors) { - const fl: any = this.newFlavors[extensionFlavorsKey]; - this.totalRAM += fl.flavor.ram_gib * fl.counter; - this.totalNumberOfCores += fl.flavor.vcpus * fl.counter; - this.totalGPU += fl.flavor.gpu * fl.counter; + const fl: any = this.newFlavors[extensionFlavorsKey] + this.totalRAM += fl.flavor.ram_gib * fl.counter + this.totalNumberOfCores += fl.flavor.vcpus * fl.counter + this.totalGPU += fl.flavor.gpu * fl.counter } } checkIfTypeGotSimpleVMFlavorOrIsCustom(type: FlavorType): boolean { for (const flav of this.flavorList) { if ( - (flav.type.shortcut === type.shortcut && flav.simple_vm) - || type.shortcut === FlavorTypeShortcuts.CUSTOM_FLAVOR + (flav.type.shortcut === type.shortcut && flav.simple_vm) || + type.shortcut === FlavorTypeShortcuts.CUSTOM_FLAVOR ) { - return true; + return true } } - return false; + return false } togglePersonalDataType(checked: boolean, data_type: string) { switch (data_type) { case 'person_related': { if (!checked) { - this.adjustedApplication.project_application_no_personal_data = false; - this.adjustedApplication.project_application_nonsensitive_data = false; - this.adjustedApplication.project_application_sensitive_data = false; + this.adjustedApplication.project_application_no_personal_data = false + this.adjustedApplication.project_application_nonsensitive_data = false + this.adjustedApplication.project_application_sensitive_data = false } - break; + break } case 'no_personal_data': { if (checked) { - this.adjustedApplication.project_application_nonsensitive_data = false; - this.adjustedApplication.project_application_sensitive_data = false; + this.adjustedApplication.project_application_nonsensitive_data = false + this.adjustedApplication.project_application_sensitive_data = false } - break; + break } case 'nonsensitive': { if (checked) { - this.adjustedApplication.project_application_no_personal_data = false; + this.adjustedApplication.project_application_no_personal_data = false } - break; + break } case 'sensitive': { if (checked) { - this.adjustedApplication.project_application_no_personal_data = false; + this.adjustedApplication.project_application_no_personal_data = false } - break; + break } default: - break; + break } } hide(): void { - this.modalService.hide(this.modalId); + this.modalService.hide(this.modalId) } checkIfMinimumSelected(): void { - let numberOfVMs: number = 0; + let numberOfVMs: number = 0 for (const fl of this.adjustedApplication.flavors) { - numberOfVMs += this.adjustedApplication.getFlavorCounter(fl); + numberOfVMs += this.adjustedApplication.getFlavorCounter(fl) } - this.atLeastOneVM = numberOfVMs > 0 || this.adjustedApplication.project_application_openstack_project; + this.atLeastOneVM = numberOfVMs > 0 || this.adjustedApplication.project_application_openstack_project } onChangeFlavor(flavor: Flavor, value: number): void { - this.adjustedApplication.setFlavorInFlavors(flavor, value); - this.checkIfMinimumSelected(); + this.adjustedApplication.setFlavorInFlavors(flavor, value) + this.checkIfMinimumSelected() this.creditsService .getCreditsForApplication(this.adjustedApplication.flavors, this.adjustedApplication.project_application_lifetime) .toPromise() .then((credits: number): void => { - this.adjustedApplication.project_application_initial_credits = credits; + this.adjustedApplication.project_application_initial_credits = credits }) - .catch((err: any): void => console.log(err)); + .catch((err: any): void => console.log(err)) } showAdjustApplicationModal(application: Application): EventEmitter { const initialState = { - application, - }; - const bsModalRef: BsModalRef = this.modalService.show(AdjustApplicationComponent, { initialState }); - bsModalRef.setClass('modal-lg'); - this.modalId = bsModalRef.id; + application + } + const bsModalRef: BsModalRef = this.modalService.show(AdjustApplicationComponent, { initialState }) + bsModalRef.setClass('modal-lg') + this.modalId = bsModalRef.id - return bsModalRef.content.eventSuccess; + return bsModalRef.content.eventSuccess } adjustApplication(): void { - this.loaded = false; + this.loaded = false this.applicationsService.adjustApplication(this.adjustedApplication).subscribe( (): void => { - this.hide(); + this.hide() - this.eventSuccess.emit(true); + this.eventSuccess.emit(true) }, (): void => { - this.hide(); + this.hide() - this.eventSuccess.emit(false); - }, - ); + this.eventSuccess.emit(false) + } + ) } } diff --git a/src/app/projectmanagement/modals/adjust-lifetime/adjust-lifetime-request.component.ts b/src/app/projectmanagement/modals/adjust-lifetime/adjust-lifetime-request.component.ts index 4f43e70759..119e08c21c 100644 --- a/src/app/projectmanagement/modals/adjust-lifetime/adjust-lifetime-request.component.ts +++ b/src/app/projectmanagement/modals/adjust-lifetime/adjust-lifetime-request.component.ts @@ -1,64 +1,62 @@ -import { - Component, EventEmitter, Injectable, OnInit, Output, -} from '@angular/core'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { Application } from '../../../applications/application.model/application.model'; -import { ApplicationLifetimeExtension } from '../../../applications/application_extension.model'; +import { Component, EventEmitter, Injectable, OnInit, Output } from '@angular/core' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { Application } from '../../../applications/application.model/application.model' +import { ApplicationLifetimeExtension } from '../../../applications/application_extension.model' -import { ApplicationsService } from '../../../api-connector/applications.service'; +import { ApplicationsService } from '../../../api-connector/applications.service' @Injectable({ providedIn: 'root' }) @Component({ selector: 'app-adjust-lifetime-request', templateUrl: './adjust-lifetime-request.component.html', - providers: [ApplicationsService], + providers: [ApplicationsService] }) export class AdjustLifetimeRequestComponent implements OnInit { - bsModalRef = BsModalRef; - modalId: number | string | undefined; - loaded: boolean = false; + bsModalRef = BsModalRef + modalId: number | string | undefined + loaded: boolean = false - application: Application; - adjustedApplicationLifetimeExtension: ApplicationLifetimeExtension; - @Output() eventSuccess: EventEmitter = new EventEmitter(); + application: Application + adjustedApplicationLifetimeExtension: ApplicationLifetimeExtension + @Output() eventSuccess: EventEmitter = new EventEmitter() constructor( private modalService: BsModalService, - private applicationsService: ApplicationsService, + private applicationsService: ApplicationsService ) {} ngOnInit() { - this.loaded = false; + this.loaded = false this.adjustedApplicationLifetimeExtension = new ApplicationLifetimeExtension( - this.application.project_lifetime_request, - ); - this.loaded = true; + this.application.project_lifetime_request + ) + this.loaded = true } hide(): void { - this.modalService.hide(this.modalId); + this.modalService.hide(this.modalId) } showAdjustLifetimeExtensionModal(application: Application): EventEmitter { const initialState = { - application, - }; - const bsModalRef: BsModalRef = this.modalService.show(AdjustLifetimeRequestComponent, { initialState }); - bsModalRef.setClass('modal-lg'); - this.modalId = bsModalRef.id; + application + } + const bsModalRef: BsModalRef = this.modalService.show(AdjustLifetimeRequestComponent, { initialState }) + bsModalRef.setClass('modal-lg') + this.modalId = bsModalRef.id - return bsModalRef.content.eventSuccess; + return bsModalRef.content.eventSuccess } adjustLifetimeExtension(): void { - this.loaded = false; + this.loaded = false this.applicationsService.adjustLifetimeExtension(this.adjustedApplicationLifetimeExtension).subscribe( (): void => { - this.eventSuccess.emit(true); + this.eventSuccess.emit(true) }, (): void => { - this.eventSuccess.emit(false); - }, - ); + this.eventSuccess.emit(false) + } + ) } } diff --git a/src/app/projectmanagement/modals/credits-request/credits-request.component.ts b/src/app/projectmanagement/modals/credits-request/credits-request.component.ts index 11783b2fb8..3366d379d4 100644 --- a/src/app/projectmanagement/modals/credits-request/credits-request.component.ts +++ b/src/app/projectmanagement/modals/credits-request/credits-request.component.ts @@ -1,112 +1,110 @@ -import { - Component, EventEmitter, OnDestroy, OnInit, -} from '@angular/core'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { Subscription } from 'rxjs'; -import { CreditsService } from '../../../api-connector/credits.service'; -import { Application } from '../../../applications/application.model/application.model'; -import { ApplicationCreditRequest } from '../../../applications/application_credit_request'; -import { ResultComponent } from '../result/result.component'; -import { Flavor } from '../../../virtualmachines/virtualmachinemodels/flavor'; +import { Component, EventEmitter, OnDestroy, OnInit } from '@angular/core' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { Subscription } from 'rxjs' +import { CreditsService } from '../../../api-connector/credits.service' +import { Application } from '../../../applications/application.model/application.model' +import { ApplicationCreditRequest } from '../../../applications/application_credit_request' +import { ResultComponent } from '../result/result.component' +import { Flavor } from '../../../virtualmachines/virtualmachinemodels/flavor' @Component({ selector: 'app-credits-request', templateUrl: './credits-request.component.html', styleUrls: ['./credits-request.component.scss'], - providers: [CreditsService], + providers: [CreditsService] }) export class CreditsRequestComponent implements OnInit, OnDestroy { - project: Application; - temp_credits_extension: ApplicationCreditRequest; + project: Application + temp_credits_extension: ApplicationCreditRequest - smallExamplePossibleHours: number; - largeExamplePossibleHours: number; - smallExamplePossibleDays: string; - largeExamplePossibleDays: string; - smallExampleFlavor: Flavor; - largeExampleFlavor: Flavor; - creditsPerHourSmallExample: number; - creditsPerHourLargeExample: number; - flavorList: Flavor[]; + smallExamplePossibleHours: number + largeExamplePossibleHours: number + smallExamplePossibleDays: string + largeExamplePossibleDays: string + smallExampleFlavor: Flavor + largeExampleFlavor: Flavor + creditsPerHourSmallExample: number + creditsPerHourLargeExample: number + flavorList: Flavor[] - private subscription: Subscription = new Subscription(); - public event: EventEmitter = new EventEmitter(); - submitted: boolean = false; + private subscription: Subscription = new Subscription() + public event: EventEmitter = new EventEmitter() + submitted: boolean = false constructor( public bsModalRef: BsModalRef, private modalService: BsModalService, - private creditsService: CreditsService, + private creditsService: CreditsService ) { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { if (this.project.project_credit_request) { - this.temp_credits_extension = new ApplicationCreditRequest(this.project.project_credit_request); + this.temp_credits_extension = new ApplicationCreditRequest(this.project.project_credit_request) } else { - this.temp_credits_extension = new ApplicationCreditRequest(); - this.temp_credits_extension.setByApp(this.project); + this.temp_credits_extension = new ApplicationCreditRequest() + this.temp_credits_extension.setByApp(this.project) } - this.initExampleFlavors(); + this.initExampleFlavors() } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() if (!this.submitted) { - this.event.emit({ reload: false }); + this.event.emit({ reload: false }) } } updateExampleCredits(numberOfCredits: number): void { - const totalHoursSmall: number = Math.round((numberOfCredits / this.creditsPerHourSmallExample) * 100) / 100; - const totalHoursLarge: number = Math.round((numberOfCredits / this.creditsPerHourLargeExample) * 100) / 100; - this.smallExamplePossibleHours = totalHoursSmall; - this.largeExamplePossibleHours = totalHoursLarge; - this.smallExamplePossibleDays = this.updateCreditsDaysString(totalHoursSmall); - this.largeExamplePossibleDays = this.updateCreditsDaysString(totalHoursLarge); + const totalHoursSmall: number = Math.round((numberOfCredits / this.creditsPerHourSmallExample) * 100) / 100 + const totalHoursLarge: number = Math.round((numberOfCredits / this.creditsPerHourLargeExample) * 100) / 100 + this.smallExamplePossibleHours = totalHoursSmall + this.largeExamplePossibleHours = totalHoursLarge + this.smallExamplePossibleDays = this.updateCreditsDaysString(totalHoursSmall) + this.largeExamplePossibleDays = this.updateCreditsDaysString(totalHoursLarge) } updateCreditsDaysString(hours: number): string { - let days: number = 0; - const minutes: number = Math.floor((hours % 1) * 60); + let days: number = 0 + const minutes: number = Math.floor((hours % 1) * 60) if (hours > 24) { - days = Math.floor(hours / 24); + days = Math.floor(hours / 24) } - hours = Math.floor(hours % 24); + hours = Math.floor(hours % 24) - return `${days} day(s), ${hours} hour(s) and ${minutes} minute(s)`; + return `${days} day(s), ${hours} hour(s) and ${minutes} minute(s)` } initExampleFlavors(): void { const standardFlavors: Flavor[] = this.flavorList // eslint-disable-next-line @typescript-eslint/no-unused-vars - .filter((fl: Flavor, nu: number, arr: Flavor[]): boolean => fl.type.long_name === 'Standard Flavors'); + .filter((fl: Flavor, nu: number, arr: Flavor[]): boolean => fl.type.long_name === 'Standard Flavors') const highMemFlavors: Flavor[] = this.flavorList // eslint-disable-next-line @typescript-eslint/no-unused-vars - .filter((fl: Flavor, nu: number, arr: Flavor[]): boolean => fl.type.long_name === 'High Memory Flavors'); - standardFlavors.sort((fl1: Flavor, fl2: Flavor): number => fl1.vcpus - fl2.vcpus); - highMemFlavors.sort((fl1: Flavor, fl2: Flavor): number => fl1.vcpus - fl2.vcpus); + .filter((fl: Flavor, nu: number, arr: Flavor[]): boolean => fl.type.long_name === 'High Memory Flavors') + standardFlavors.sort((fl1: Flavor, fl2: Flavor): number => fl1.vcpus - fl2.vcpus) + highMemFlavors.sort((fl1: Flavor, fl2: Flavor): number => fl1.vcpus - fl2.vcpus) if (standardFlavors.length !== 0) { - this.smallExampleFlavor = standardFlavors[0]; + this.smallExampleFlavor = standardFlavors[0] this.creditsService .getCreditsPerHour(this.smallExampleFlavor.vcpus, this.smallExampleFlavor.ram_gib) .toPromise() .then((credits: number): void => { - this.creditsPerHourSmallExample = credits * 4; + this.creditsPerHourSmallExample = credits * 4 }) - .catch((err: Error): void => console.log(err.message)); + .catch((err: Error): void => console.log(err.message)) } if (highMemFlavors.length !== 0) { - this.largeExampleFlavor = highMemFlavors[0]; + this.largeExampleFlavor = highMemFlavors[0] this.creditsService .getCreditsPerHour(this.largeExampleFlavor.vcpus, this.largeExampleFlavor.ram_gib) .toPromise() .then((credits: number): void => { - this.creditsPerHourLargeExample = credits; + this.creditsPerHourLargeExample = credits }) - .catch((err: Error): void => console.log(err.message)); + .catch((err: Error): void => console.log(err.message)) } } @@ -114,17 +112,17 @@ export class CreditsRequestComponent implements OnInit, OnDestroy { const initialState = { project: this.project, extension: this.temp_credits_extension, - creditsExtension: true, - }; - this.submitted = true; - this.bsModalRef = this.modalService.show(ResultComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); + creditsExtension: true + } + this.submitted = true + this.bsModalRef = this.modalService.show(ResultComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') this.bsModalRef.content.event.subscribe((result: any) => { if ('reload' in result && result['reload']) { - this.event.emit({ reload: true }); + this.event.emit({ reload: true }) } else { - this.event.emit({ reload: false }); + this.event.emit({ reload: false }) } - }); + }) } } diff --git a/src/app/projectmanagement/modals/lifetime-request/lifetime-request.component.ts b/src/app/projectmanagement/modals/lifetime-request/lifetime-request.component.ts index 25530a9de1..bbac531424 100644 --- a/src/app/projectmanagement/modals/lifetime-request/lifetime-request.component.ts +++ b/src/app/projectmanagement/modals/lifetime-request/lifetime-request.component.ts @@ -1,92 +1,90 @@ -import { - Component, EventEmitter, OnDestroy, OnInit, -} from '@angular/core'; -import { Subscription } from 'rxjs'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { Application } from '../../../applications/application.model/application.model'; -import { ApplicationLifetimeExtension } from '../../../applications/application_extension.model'; -import { CreditsService } from '../../../api-connector/credits.service'; -import { EdamOntologyTerm } from '../../../applications/edam-ontology-term'; -import { ResultComponent } from '../result/result.component'; -import { ApplicationsService } from '../../../api-connector/applications.service'; +import { Component, EventEmitter, OnDestroy, OnInit } from '@angular/core' +import { Subscription } from 'rxjs' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { Application } from '../../../applications/application.model/application.model' +import { ApplicationLifetimeExtension } from '../../../applications/application_extension.model' +import { CreditsService } from '../../../api-connector/credits.service' +import { EdamOntologyTerm } from '../../../applications/edam-ontology-term' +import { ResultComponent } from '../result/result.component' +import { ApplicationsService } from '../../../api-connector/applications.service' @Component({ selector: 'app-lifetime-request', templateUrl: './lifetime-request.component.html', styleUrls: ['./lifetime-request.component.scss'], - providers: [CreditsService, ApplicationsService], + providers: [CreditsService, ApplicationsService] }) export class LifetimeRequestComponent implements OnInit, OnDestroy { - project: Application; - temp_project_extension: ApplicationLifetimeExtension; - initial_number_of_edam_terms: number = 0; + project: Application + temp_project_extension: ApplicationLifetimeExtension + initial_number_of_edam_terms: number = 0 - life_time_string: string; - end_date: Date; - new_end_date: Date | string; - MAX_LIFETIME_DEFAULT: number = 6; - max_lifetime: number = this.MAX_LIFETIME_DEFAULT; - selected_ontology_terms: EdamOntologyTerm[] = []; - edam_ontology_terms: EdamOntologyTerm[]; - ontology_search_keyword: string = 'term'; + life_time_string: string + end_date: Date + new_end_date: Date | string + MAX_LIFETIME_DEFAULT: number = 6 + max_lifetime: number = this.MAX_LIFETIME_DEFAULT + selected_ontology_terms: EdamOntologyTerm[] = [] + edam_ontology_terms: EdamOntologyTerm[] + ontology_search_keyword: string = 'term' - private subscription: Subscription = new Subscription(); - public event: EventEmitter = new EventEmitter(); - submitted: boolean = false; + private subscription: Subscription = new Subscription() + public event: EventEmitter = new EventEmitter() + submitted: boolean = false constructor( public bsModalRef: BsModalRef, private modalService: BsModalService, private creditsService: CreditsService, - private applicationsService: ApplicationsService, // eslint-disable-next-line no-empty-function + private applicationsService: ApplicationsService ) {} ngOnInit(): void { this.applicationsService.getEdamOntologyTerms().subscribe((terms: EdamOntologyTerm[]): void => { - this.edam_ontology_terms = terms; - this.searchTermsInEdamTerms(); - }); + this.edam_ontology_terms = terms + this.searchTermsInEdamTerms() + }) if (this.project.project_application_nfdi?.length > 0) { - this.max_lifetime = 12; + this.max_lifetime = 12 } else { - this.max_lifetime = this.MAX_LIFETIME_DEFAULT; + this.max_lifetime = this.MAX_LIFETIME_DEFAULT } if (this.project.project_lifetime_request) { - this.temp_project_extension = new ApplicationLifetimeExtension(this.project.project_lifetime_request); + this.temp_project_extension = new ApplicationLifetimeExtension(this.project.project_lifetime_request) } else { - this.temp_project_extension = new ApplicationLifetimeExtension(); - this.temp_project_extension.setByApp(this.project); + this.temp_project_extension = new ApplicationLifetimeExtension() + this.temp_project_extension.setByApp(this.project) } - const endDateInfo = this.life_time_string ? this.life_time_string.split(' - ')[1]?.split('.') : []; + const endDateInfo = this.life_time_string ? this.life_time_string.split(' - ')[1]?.split('.') : [] if (endDateInfo.length === 3) { - const [day, month, year] = endDateInfo.map(item => Number(item)); + const [day, month, year] = endDateInfo.map(item => Number(item)) if (!Number.isNaN(day) && !Number.isNaN(month) && !Number.isNaN(year)) { - this.end_date = new Date(year, month - 1, day); + this.end_date = new Date(year, month - 1, day) } } - this.initial_number_of_edam_terms = this.project.project_application_edam_terms.length; + this.initial_number_of_edam_terms = this.project.project_application_edam_terms.length } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() if (!this.submitted) { - this.event.emit({ reload: false }); + this.event.emit({ reload: false }) } } searchTermsInEdamTerms(): void { - const tmp: EdamOntologyTerm[] = []; + const tmp: EdamOntologyTerm[] = [] this.selected_ontology_terms.forEach((ele: any) => { // @ts-ignore - const td = this.edam_ontology_terms.find(term => term.term === ele); - tmp.push(td); - }); - this.selected_ontology_terms = tmp; + const td = this.edam_ontology_terms.find(term => term.term === ele) + tmp.push(td) + }) + this.selected_ontology_terms = tmp } removeEDAMterm(term: EdamOntologyTerm): void { - const indexOf: number = this.selected_ontology_terms.indexOf(term); - this.selected_ontology_terms.splice(indexOf, 1); + const indexOf: number = this.selected_ontology_terms.indexOf(term) + this.selected_ontology_terms.splice(indexOf, 1) } showSubmitModal(): void { @@ -96,67 +94,67 @@ export class LifetimeRequestComponent implements OnInit, OnDestroy { lifetimeExtension: true, expectedTotalCredits: this.project.project_application_initial_credits + this.temp_project_extension.extra_credits, - selected_ontology_terms: this.selected_ontology_terms, - }; - this.submitted = true; - this.bsModalRef = this.modalService.show(ResultComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); + selected_ontology_terms: this.selected_ontology_terms + } + this.submitted = true + this.bsModalRef = this.modalService.show(ResultComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') this.bsModalRef.content.event.subscribe((result: any) => { if ('reload' in result && result['reload']) { if (this.selected_ontology_terms.length > 0) { this.applicationsService .addEdamOntologyTerms(this.project.project_application_id, this.selected_ontology_terms) .subscribe((): void => { - this.event.emit({ reload: true }); - }); + this.event.emit({ reload: true }) + }) } else { - this.event.emit({ reload: true }); + this.event.emit({ reload: true }) } } else { - this.event.emit({ reload: false }); + this.event.emit({ reload: false }) } - }); + }) } isDate(dateToCheck: Date | string) { - return typeof dateToCheck === 'object'; + return typeof dateToCheck === 'object' } calculateNewEndDate() { if (this.end_date < new Date()) { this.new_end_date = `${this.temp_project_extension.extra_lifetime} month${ this.temp_project_extension.extra_lifetime > 1 ? 's' : '' - } after the approval of the extension`; + } after the approval of the extension` } else { - this.new_end_date = new Date(this.end_date); - const month_number: number = this.end_date.getMonth() + this.temp_project_extension.extra_lifetime; - this.new_end_date.setMonth(month_number % 12); + this.new_end_date = new Date(this.end_date) + const month_number: number = this.end_date.getMonth() + this.temp_project_extension.extra_lifetime + this.new_end_date.setMonth(month_number % 12) if (month_number > 11) { - this.new_end_date.setFullYear(this.new_end_date.getFullYear() + 1); + this.new_end_date.setFullYear(this.new_end_date.getFullYear() + 1) } } } calculateCreditsLifetime(): void { if (!this.project.credits_allowed) { - return; + return } if ( - this.temp_project_extension.extra_lifetime <= 0 - || !Number.isInteger(this.temp_project_extension.extra_lifetime) + this.temp_project_extension.extra_lifetime <= 0 || + !Number.isInteger(this.temp_project_extension.extra_lifetime) ) { - this.temp_project_extension.extra_credits = 0; + this.temp_project_extension.extra_credits = 0 - return; + return } this.subscription.add( this.creditsService .getExtraCreditsForLifetimeExtension( this.temp_project_extension.extra_lifetime, - this.project.project_application_id.toString(), + this.project.project_application_id.toString() ) .subscribe((credits: number): void => { - this.temp_project_extension.extra_credits = credits; - }), - ); + this.temp_project_extension.extra_credits = credits + }) + ) } } diff --git a/src/app/projectmanagement/modals/modification-request/modification-request.component.ts b/src/app/projectmanagement/modals/modification-request/modification-request.component.ts index e660635815..093664f274 100644 --- a/src/app/projectmanagement/modals/modification-request/modification-request.component.ts +++ b/src/app/projectmanagement/modals/modification-request/modification-request.component.ts @@ -1,108 +1,106 @@ -import { - ChangeDetectorRef, Component, EventEmitter, OnDestroy, OnInit, -} from '@angular/core'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { Subscription } from 'rxjs'; -import { HasFlavorTypeOrIsNotCustomPipe } from 'app/pipe-module/pipes/has-flavor-type.pipe'; -import { ApplicationModification } from '../../../applications/application_modification.model'; -import { ResultComponent } from '../result/result.component'; -import { Application } from '../../../applications/application.model/application.model'; -import { CLOUD_PORTAL_SUPPORT_MAIL } from '../../../../links/links'; -import { FlavorType } from '../../../virtualmachines/virtualmachinemodels/flavorType'; -import { Flavor } from '../../../virtualmachines/virtualmachinemodels/flavor'; -import { FlavorService } from '../../../api-connector/flavor.service'; -import { CreditsService } from '../../../api-connector/credits.service'; +import { ChangeDetectorRef, Component, EventEmitter, OnDestroy, OnInit } from '@angular/core' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { Subscription } from 'rxjs' +import { HasFlavorTypeOrIsNotCustomPipe } from 'app/pipe-module/pipes/has-flavor-type.pipe' +import { ApplicationModification } from '../../../applications/application_modification.model' +import { ResultComponent } from '../result/result.component' +import { Application } from '../../../applications/application.model/application.model' +import { CLOUD_PORTAL_SUPPORT_MAIL } from '../../../../links/links' +import { FlavorType } from '../../../virtualmachines/virtualmachinemodels/flavorType' +import { Flavor } from '../../../virtualmachines/virtualmachinemodels/flavor' +import { FlavorService } from '../../../api-connector/flavor.service' +import { CreditsService } from '../../../api-connector/credits.service' @Component({ selector: 'app-modification-request', templateUrl: './modification-request.component.html', styleUrls: ['./modification-request.component.scss'], - providers: [FlavorService, CreditsService, HasFlavorTypeOrIsNotCustomPipe], + providers: [FlavorService, CreditsService, HasFlavorTypeOrIsNotCustomPipe] }) export class ModificationRequestComponent implements OnInit, OnDestroy { - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL - project: Application; - temp_project_modification: ApplicationModification; + project: Application + temp_project_modification: ApplicationModification - adjusted_project_modification: ApplicationModification; + adjusted_project_modification: ApplicationModification - expected_total_credits: number = 0; - flavorTypes: FlavorType[] = []; - shown_flavors: { [name: string]: Flavor[] } = {}; - min_vm: boolean = true; + expected_total_credits: number = 0 + flavorTypes: FlavorType[] = [] + shown_flavors: { [name: string]: Flavor[] } = {} + min_vm: boolean = true - min_vm_adjusted: boolean = true; + min_vm_adjusted: boolean = true - adjustment: boolean = false; + adjustment: boolean = false - private subscription: Subscription = new Subscription(); - public event: EventEmitter = new EventEmitter(); - submitted: boolean = false; - extraResourceCommentRequired: boolean = false; - GPU_SHORTCUT = 'GPU'; - HMF_SHORTCUT = 'HMF'; + private subscription: Subscription = new Subscription() + public event: EventEmitter = new EventEmitter() + submitted: boolean = false + extraResourceCommentRequired: boolean = false + GPU_SHORTCUT = 'GPU' + HMF_SHORTCUT = 'HMF' constructor( public bsModalRef: BsModalRef, private modalService: BsModalService, private flavorService: FlavorService, private creditsService: CreditsService, - private cdRef: ChangeDetectorRef, + private cdRef: ChangeDetectorRef ) { // do nothing. } ngOnDestroy(): void { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() if (!this.submitted) { - this.event.emit({ reload: false }); + this.event.emit({ reload: false }) } } ngOnInit(): void { this.subscription.add( this.flavorService.getListOfTypesAvailable().subscribe((result: FlavorType[]) => { - this.flavorTypes = result; + this.flavorTypes = result for (const flavorType of this.flavorTypes) { - this.shown_flavors[flavorType.long_name] = []; + this.shown_flavors[flavorType.long_name] = [] } - this.getFlavors(); - }), - ); + this.getFlavors() + }) + ) if (this.project.project_modification_request) { - this.temp_project_modification = new ApplicationModification(this.project.project_modification_request); - this.temp_project_modification.flavors = []; + this.temp_project_modification = new ApplicationModification(this.project.project_modification_request) + this.temp_project_modification.flavors = [] this.temp_project_modification.flavors = this.project.project_modification_request.flavors.map( - (flavor: Flavor): Flavor => new Flavor(flavor), - ); + (flavor: Flavor): Flavor => new Flavor(flavor) + ) } else { - this.temp_project_modification = new ApplicationModification(); - this.temp_project_modification.setByApp(this.project); + this.temp_project_modification = new ApplicationModification() + this.temp_project_modification.setByApp(this.project) } if (this.adjustment) { - this.adjusted_project_modification = new ApplicationModification(this.project.project_modification_request); - this.adjusted_project_modification.flavors = []; + this.adjusted_project_modification = new ApplicationModification(this.project.project_modification_request) + this.adjusted_project_modification.flavors = [] this.adjusted_project_modification.flavors = this.project.project_modification_request.flavors.map( - (flavor: Flavor): Flavor => new Flavor(flavor), - ); + (flavor: Flavor): Flavor => new Flavor(flavor) + ) } - this.checkExtraResourceCommentRequired(); + this.checkExtraResourceCommentRequired() } checkValidityComment(): boolean { if (this.extraResourceCommentRequired) { if (this.temp_project_modification.comment.length < 50) { - return false; + return false } else { - const regExp = /[a-zA-Z]/g; + const regExp = /[a-zA-Z]/g - return regExp.test(this.temp_project_modification.comment); + return regExp.test(this.temp_project_modification.comment) } } else { - return true; + return true } } @@ -111,67 +109,68 @@ export class ModificationRequestComponent implements OnInit, OnDestroy { this.flavorService .getListOfFlavorsAvailable(this.project.project_application_id.toString(), true) .subscribe((flavors: Flavor[]): void => { - this.temp_project_modification.flavors = []; + this.temp_project_modification.flavors = [] for (const flavor of flavors) { if (this.project.project_application_openstack_project || flavor.simple_vm) { - this.shown_flavors[flavor.type.long_name].push(flavor); + this.shown_flavors[flavor.type.long_name].push(flavor) } } - this.checkFlavorDifferences(); - }), - ); + this.checkFlavorDifferences() + }) + ) } checkFlavorDifferences(): void { for (const flavor of this.project.flavors) { const idx: number = this.shown_flavors[flavor.type.long_name].findIndex( - (fl: Flavor): boolean => fl.name === flavor.name, - ); + (fl: Flavor): boolean => fl.name === flavor.name + ) // not in shown_flavors, so flavor only for project if (idx < 0) { - const disabled_flavor: Flavor = new Flavor(flavor); - disabled_flavor.setDisabled(true); - const mod_flavor: Flavor = new Flavor(flavor); - this.shown_flavors[flavor.type.long_name].push(disabled_flavor); - this.shown_flavors[flavor.type.long_name].push(mod_flavor); - this.temp_project_modification.flavors.push(mod_flavor); + const disabled_flavor: Flavor = new Flavor(flavor) + disabled_flavor.setDisabled(true) + const mod_flavor: Flavor = new Flavor(flavor) + this.shown_flavors[flavor.type.long_name].push(disabled_flavor) + this.shown_flavors[flavor.type.long_name].push(mod_flavor) + this.temp_project_modification.flavors.push(mod_flavor) } else { // else in shown_flavors, may be different than old one - this.shown_flavors[flavor.type.long_name][idx].counter = flavor.counter; - const mod_flavor: Flavor = new Flavor(this.shown_flavors[flavor.type.long_name][idx]); - this.temp_project_modification.flavors.push(mod_flavor); - this.shown_flavors[flavor.type.long_name].splice(idx, 0, flavor); - this.shown_flavors[flavor.type.long_name][idx].setDisabled(true); + this.shown_flavors[flavor.type.long_name][idx].counter = flavor.counter + const mod_flavor: Flavor = new Flavor(this.shown_flavors[flavor.type.long_name][idx]) + this.temp_project_modification.flavors.push(mod_flavor) + this.shown_flavors[flavor.type.long_name].splice(idx, 0, flavor) + this.shown_flavors[flavor.type.long_name][idx].setDisabled(true) } } - this.temp_project_modification.calculateRamCores(); + this.temp_project_modification.calculateRamCores() } checkFlavorPairs(flavor: Flavor, event: any): void { - const amount: number = Number(event.target.value); + const amount: number = Number(event.target.value) const idx: number = this.temp_project_modification.flavors.findIndex( - (fl: Flavor): boolean => fl.name === flavor.name, - ); + (fl: Flavor): boolean => fl.name === flavor.name + ) if (idx >= 0) { - this.temp_project_modification.flavors.splice(idx, 1); + this.temp_project_modification.flavors.splice(idx, 1) if (amount > 0) { - flavor.counter = amount; - this.temp_project_modification.flavors.push(flavor); + flavor.counter = amount + this.temp_project_modification.flavors.push(flavor) } } else if (amount > 0) { - flavor.counter = amount; - this.temp_project_modification.flavors.push(flavor); + flavor.counter = amount + this.temp_project_modification.flavors.push(flavor) } - this.min_vm = this.project.project_application_openstack_project || this.temp_project_modification.flavors.length > 0; - this.temp_project_modification.calculateRamCores(); - this.getExtraCredits(); - this.checkExtraResourceCommentRequired(); + this.min_vm = + this.project.project_application_openstack_project || this.temp_project_modification.flavors.length > 0 + this.temp_project_modification.calculateRamCores() + this.getExtraCredits() + this.checkExtraResourceCommentRequired() } checkExtraResourceCommentRequired(): void { - this.extraResourceCommentRequired = this.compareCriticalResourceValues(); - this.cdRef.detectChanges(); + this.extraResourceCommentRequired = this.compareCriticalResourceValues() + this.cdRef.detectChanges() } /** @@ -185,126 +184,128 @@ export class ModificationRequestComponent implements OnInit, OnDestroy { total_cores: 0, total_ram: 0, total_gpus: 0, - machines: 0, - }; - let correspondingProject: Application | ApplicationModification; + machines: 0 + } + let correspondingProject: Application | ApplicationModification if (current) { - correspondingProject = this.project; + correspondingProject = this.project } else { - correspondingProject = this.temp_project_modification; + correspondingProject = this.temp_project_modification } for (const flavor of correspondingProject.flavors) { if (flavor?.type.shortcut.toUpperCase() === shortcut) { - dict.total_cores += flavor.counter * flavor.vcpus; - dict.total_ram += flavor.counter * flavor.ram_mb; - dict.machines += flavor.counter; + dict.total_cores += flavor.counter * flavor.vcpus + dict.total_ram += flavor.counter * flavor.ram_mb + dict.machines += flavor.counter if (flavor?.type?.shortcut.toUpperCase() === this.GPU_SHORTCUT) { - dict.total_gpus += flavor.counter * flavor.gpu; + dict.total_gpus += flavor.counter * flavor.gpu } } } - return dict; + return dict } /** * checks whether the user tries to apply for more critical resources in the application */ compareCriticalResourceValues(): boolean { - const currentHMF: any = this.calculateResourcesByType(this.HMF_SHORTCUT, true); - const currentGPU: any = this.calculateResourcesByType(this.GPU_SHORTCUT, true); - const requestingHMF: any = this.calculateResourcesByType(this.HMF_SHORTCUT, false); - const requestingGPU: any = this.calculateResourcesByType(this.GPU_SHORTCUT, false); + const currentHMF: any = this.calculateResourcesByType(this.HMF_SHORTCUT, true) + const currentGPU: any = this.calculateResourcesByType(this.GPU_SHORTCUT, true) + const requestingHMF: any = this.calculateResourcesByType(this.HMF_SHORTCUT, false) + const requestingGPU: any = this.calculateResourcesByType(this.GPU_SHORTCUT, false) return ( this.isMoreCriticalResources(currentHMF, requestingHMF) || this.isMoreCriticalResources(currentGPU, requestingGPU) - ); + ) } isMoreCriticalResources(current: any, requesting: any): boolean { for (const key in current) { if (requesting[key] > current[key]) { - return true; + return true } } - return false; + return false } checkFlavorPairsAdjustment(flavor: Flavor, event: any): void { - const amount: number = Number(event.target.value); + const amount: number = Number(event.target.value) const idx: number = this.adjusted_project_modification.flavors.findIndex( - (fl: Flavor): boolean => fl.name === flavor.name, - ); + (fl: Flavor): boolean => fl.name === flavor.name + ) if (idx >= 0) { - this.adjusted_project_modification.flavors.splice(idx, 1); + this.adjusted_project_modification.flavors.splice(idx, 1) if (amount > 0) { - flavor.counter = amount; - this.adjusted_project_modification.flavors.push(flavor); + flavor.counter = amount + this.adjusted_project_modification.flavors.push(flavor) } } else if (amount > 0) { - flavor.counter = amount; - this.adjusted_project_modification.flavors.push(flavor); + flavor.counter = amount + this.adjusted_project_modification.flavors.push(flavor) } - this.min_vm_adjusted = this.project.project_application_openstack_project || this.adjusted_project_modification.flavors.length > 0; - this.adjusted_project_modification.calculateRamCores(); + this.min_vm_adjusted = + this.project.project_application_openstack_project || this.adjusted_project_modification.flavors.length > 0 + this.adjusted_project_modification.calculateRamCores() } getExtraCredits(): void { if (!this.project.credits_allowed) { - return; + return } this.subscription.add( this.creditsService .getExtraCreditsForResourceExtension( this.temp_project_modification.flavors, - this.project.project_application_id.toString(), + this.project.project_application_id.toString() ) .subscribe((credits: number): void => { - this.temp_project_modification.extra_credits = credits; - this.expected_total_credits = this.project.project_application_initial_credits + this.temp_project_modification.extra_credits; + this.temp_project_modification.extra_credits = credits + this.expected_total_credits = + this.project.project_application_initial_credits + this.temp_project_modification.extra_credits if (this.expected_total_credits <= 0) { - this.expected_total_credits = 0; + this.expected_total_credits = 0 } - }), - ); + }) + ) } showSubmitModal(adjustment: boolean): void { - let initialState: object; + let initialState: object if (adjustment) { initialState = { project: this.project, extension: this.temp_project_modification, adjustedModification: this.adjusted_project_modification, modificationExtension: true, - expectedTotalCredits: this.expected_total_credits, - }; + expectedTotalCredits: this.expected_total_credits + } } else { initialState = { project: this.project, extension: this.temp_project_modification, modificationExtension: true, - expectedTotalCredits: this.expected_total_credits, - }; + expectedTotalCredits: this.expected_total_credits + } } - this.submitted = true; + this.submitted = true this.bsModalRef = this.modalService.show(ResultComponent, { initialState, - class: 'modal-lg modal-dialog-scrollable ', - }); + class: 'modal-lg modal-dialog-scrollable ' + }) this.bsModalRef.content.event.subscribe((result: any) => { if ('reload' in result && result['reload']) { if (adjustment) { - this.event.emit({ action: 'adjustedModificationRequest' }); + this.event.emit({ action: 'adjustedModificationRequest' }) } else { - this.event.emit({ reload: true }); + this.event.emit({ reload: true }) } } else { - this.event.emit({ reload: false }); + this.event.emit({ reload: false }) } - }); + }) } } diff --git a/src/app/projectmanagement/modals/result/result.component.ts b/src/app/projectmanagement/modals/result/result.component.ts index 788e6c1b33..959399833c 100644 --- a/src/app/projectmanagement/modals/result/result.component.ts +++ b/src/app/projectmanagement/modals/result/result.component.ts @@ -1,148 +1,148 @@ -import { - Component, EventEmitter, OnDestroy, OnInit, -} from '@angular/core'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { Subscription } from 'rxjs'; -import { Application } from '../../../applications/application.model/application.model'; -import { ApplicationModification } from '../../../applications/application_modification.model'; -import { ApplicationLifetimeExtension } from '../../../applications/application_extension.model'; -import { ApplicationCreditRequest } from '../../../applications/application_credit_request'; -import { ApplicationsService } from '../../../api-connector/applications.service'; -import { EdamOntologyTerm } from '../../../applications/edam-ontology-term'; +import { Component, EventEmitter, OnDestroy, OnInit } from '@angular/core' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { Subscription } from 'rxjs' +import { Application } from '../../../applications/application.model/application.model' +import { ApplicationModification } from '../../../applications/application_modification.model' +import { ApplicationLifetimeExtension } from '../../../applications/application_extension.model' +import { ApplicationCreditRequest } from '../../../applications/application_credit_request' +import { ApplicationsService } from '../../../api-connector/applications.service' +import { EdamOntologyTerm } from '../../../applications/edam-ontology-term' @Component({ selector: 'app-result', templateUrl: './result.component.html', styleUrls: ['./result.component.scss'], - providers: [ApplicationsService, BsModalService], + providers: [ApplicationsService, BsModalService] }) export class ResultComponent implements OnInit, OnDestroy { - subscription: Subscription = new Subscription(); - public event: EventEmitter = new EventEmitter(); - submit: boolean = true; - result: boolean = false; + subscription: Subscription = new Subscription() + public event: EventEmitter = new EventEmitter() + submit: boolean = true + result: boolean = false - project: Application; - extension: ApplicationModification | ApplicationLifetimeExtension | ApplicationCreditRequest; - adjustedModification: ApplicationModification; + project: Application + extension: ApplicationModification | ApplicationLifetimeExtension | ApplicationCreditRequest + adjustedModification: ApplicationModification - lifetimeExtension: boolean = false; - modificationExtension: boolean = false; - creditsExtension: boolean = false; + lifetimeExtension: boolean = false + modificationExtension: boolean = false + creditsExtension: boolean = false - expectedTotalCredits: number = 0; - extensionStatus: number = 0; - selected_ontology_terms: EdamOntologyTerm[]; + expectedTotalCredits: number = 0 + extensionStatus: number = 0 + selected_ontology_terms: EdamOntologyTerm[] - errorMessage: any; + errorMessage: any constructor( public bsModalRef: BsModalRef, private modalService: BsModalService, - private applicationsService: ApplicationsService, + private applicationsService: ApplicationsService ) { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { - this.setToSubmitState(); + this.setToSubmitState() } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() if (!this.result) { - this.event.emit({ reload: false }); + this.event.emit({ reload: false }) } } submitModificationRequest(): void { - this.setToResultState(); + this.setToResultState() this.subscription.add( this.applicationsService.requestModification(this.extension as ApplicationModification).subscribe( (result: { [key: string]: string }): void => { if (result['Error']) { - this.extensionStatus = 2; - this.errorMessage = result['Error']; + this.extensionStatus = 2 + this.errorMessage = result['Error'] } else { - this.extensionStatus = 1; + this.extensionStatus = 1 } - this.event.emit({ reload: true }); + this.event.emit({ reload: true }) }, () => { - this.extensionStatus = 2; - this.errorMessage = 'Submitting the modification request was not successful. Please reload this page and try again!'; - }, - ), - ); + this.extensionStatus = 2 + this.errorMessage = + 'Submitting the modification request was not successful. Please reload this page and try again!' + } + ) + ) } submitModificationAdjustment(): void { - this.setToResultState(); + this.setToResultState() this.subscription.add( this.applicationsService.adjustModification(this.adjustedModification).subscribe( (): void => { - this.extensionStatus = 5; - this.event.emit({ reload: true }); + this.extensionStatus = 5 + this.event.emit({ reload: true }) }, (): void => { - this.extensionStatus = 2; - this.errorMessage = 'An error occurred submitting the modification adjustment.'; - }, - ), - ); + this.extensionStatus = 2 + this.errorMessage = 'An error occurred submitting the modification adjustment.' + } + ) + ) } submitLifetimeExtensionRequest(): void { - this.setToResultState(); + this.setToResultState() this.applicationsService.requestAdditionalLifetime(this.extension as ApplicationLifetimeExtension).subscribe( (result: { [key: string]: string }): void => { if (result['Error']) { - this.extensionStatus = 2; - this.errorMessage = result['Error']; + this.extensionStatus = 2 + this.errorMessage = result['Error'] } else { - this.extensionStatus = 1; + this.extensionStatus = 1 } - this.event.emit({ reload: true }); + this.event.emit({ reload: true }) }, () => { - this.extensionStatus = 2; - this.errorMessage = 'Submitting the extension request was not successful. Please reload this page and try again!'; - }, - ); + this.extensionStatus = 2 + this.errorMessage = + 'Submitting the extension request was not successful. Please reload this page and try again!' + } + ) } submitCreditsModification(): void { - this.setToResultState(); + this.setToResultState() this.subscription.add( this.applicationsService.requestAdditionalCredits(this.extension as ApplicationCreditRequest).subscribe( (result: { [key: string]: string }): void => { if (result['Error']) { - this.extensionStatus = 2; + this.extensionStatus = 2 } else { - this.extensionStatus = 1; + this.extensionStatus = 1 } - this.event.emit({ reload: true }); + this.event.emit({ reload: true }) }, () => { - this.extensionStatus = 2; - this.errorMessage = 'Submitting the credit request was not successful. Please reload this page and try again!'; - }, - ), - ); + this.extensionStatus = 2 + this.errorMessage = 'Submitting the credit request was not successful. Please reload this page and try again!' + } + ) + ) } setToResultState(): void { - this.submit = false; - this.result = true; + this.submit = false + this.result = true } setToSubmitState(): void { - this.submit = true; - this.result = false; + this.submit = true + this.result = false } } diff --git a/src/app/projectmanagement/modals/testimonial/extension-entry.component.ts b/src/app/projectmanagement/modals/testimonial/extension-entry.component.ts index 6f95dcfb09..89adc470cb 100644 --- a/src/app/projectmanagement/modals/testimonial/extension-entry.component.ts +++ b/src/app/projectmanagement/modals/testimonial/extension-entry.component.ts @@ -1,86 +1,89 @@ -import { Component, EventEmitter, OnDestroy } from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Subscription } from 'rxjs'; -import { TESTIMONIAL_PAGE_LINK, WIKI_PUBLICATIONS } from '../../../../links/links'; -import { Doi } from '../../../applications/doi/doi'; -import { GroupService } from '../../../api-connector/group.service'; +import { Component, EventEmitter, OnDestroy } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { Subscription } from 'rxjs' +import { TESTIMONIAL_PAGE_LINK, WIKI_PUBLICATIONS } from '../../../../links/links' +import { Doi } from '../../../applications/doi/doi' +import { GroupService } from '../../../api-connector/group.service' @Component({ selector: 'app-extension-entry', templateUrl: './extension-entry.component.html', styleUrls: ['./extension-entry.component.scss'], - providers: [GroupService], + providers: [GroupService] }) export class ExtensionEntryComponent implements OnDestroy { - private subscription: Subscription = new Subscription(); - public event: EventEmitter = new EventEmitter(); - TESTIMONIAL_PAGE_LINK = TESTIMONIAL_PAGE_LINK; + private subscription: Subscription = new Subscription() + public event: EventEmitter = new EventEmitter() + TESTIMONIAL_PAGE_LINK = TESTIMONIAL_PAGE_LINK - WIKI_PUBLICATIONS: string = WIKI_PUBLICATIONS; + WIKI_PUBLICATIONS: string = WIKI_PUBLICATIONS - newDoi: string; - doiError: string; - dois: Doi[]; - application_id: string | number; - disableInput: boolean = false; + newDoi: string + doiError: string + dois: Doi[] + application_id: string | number + disableInput: boolean = false - constructor(public bsModalRef: BsModalRef, private groupService: GroupService) { - // eslint-disable-next-line no-empty-function + constructor( + public bsModalRef: BsModalRef, + private groupService: GroupService + ) { + } ngOnDestroy(): void { - this.subscription.unsubscribe(); - this.event.emit({ reloadDoi: false, showExtension: true }); + this.subscription.unsubscribe() + this.event.emit({ reloadDoi: false, showExtension: true }) } isNewDoi(): boolean { for (const doi of this.dois) { if (doi.identifier === this.newDoi) { - return false; + return false } } - return true; + return true } toggleDisabledInput(): void { - this.disableInput = !this.disableInput; + this.disableInput = !this.disableInput } addDoi(): void { - this.toggleDisabledInput(); + this.toggleDisabledInput() if (this.isNewDoi()) { this.subscription.add( this.groupService.addGroupDoi(this.application_id, this.newDoi).subscribe( (dois: Doi[]): void => { - this.doiError = null; - this.newDoi = null; - this.dois = dois; - this.event.emit({ reloadDoi: true }); + this.doiError = null + this.newDoi = null + this.dois = dois + this.event.emit({ reloadDoi: true }) }, (): void => { - this.doiError = `DOI ${this.newDoi} was already added by another Project!`; - this.toggleDisabledInput(); + this.doiError = `DOI ${this.newDoi} was already added by another Project!` + this.toggleDisabledInput() }, (): void => { - this.toggleDisabledInput(); - this.newDoi = null; - }, - ), - ); + this.toggleDisabledInput() + this.newDoi = null + } + ) + ) } else { - this.doiError = `DOI ${this.newDoi} was already added by this Project!`; - this.newDoi = null; - this.toggleDisabledInput(); + this.doiError = `DOI ${this.newDoi} was already added by this Project!` + this.newDoi = null + this.toggleDisabledInput() } } deleteDoi(doi: Doi): void { this.subscription.add( this.groupService.deleteGroupDoi(doi.id).subscribe((dois: Doi[]): void => { - this.dois = dois; - this.event.emit({ reloadDoi: true }); - }), - ); + this.dois = dois + this.event.emit({ reloadDoi: true }) + }) + ) } } diff --git a/src/app/projectmanagement/modals/withdraw/withdraw-modal.component.ts b/src/app/projectmanagement/modals/withdraw/withdraw-modal.component.ts index bd8eef3a06..338e58144c 100644 --- a/src/app/projectmanagement/modals/withdraw/withdraw-modal.component.ts +++ b/src/app/projectmanagement/modals/withdraw/withdraw-modal.component.ts @@ -1,7 +1,7 @@ -import { Component, EventEmitter } from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; +import { Component, EventEmitter } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' -import { ApplicationsService } from '../../../api-connector/applications.service'; +import { ApplicationsService } from '../../../api-connector/applications.service' export enum WITHDRAWAL_TYPES { MODIFICATION, @@ -11,38 +11,38 @@ export enum WITHDRAWAL_TYPES { @Component({ selector: 'app-withdrawl-modal', templateUrl: './withdraw-modal.component.html', - providers: [ApplicationsService], + providers: [ApplicationsService] }) export class WithdrawModalComponent { - target_id: string | number; - type: WITHDRAWAL_TYPES; - event: EventEmitter = new EventEmitter(); + target_id: string | number + type: WITHDRAWAL_TYPES + event: EventEmitter = new EventEmitter() constructor( public bsModalRef: BsModalRef, - private projectService: ApplicationsService, + private projectService: ApplicationsService ) { - // eslint-disable-next-line no-empty-function + } withdrawTarget() { switch (this.type) { case WITHDRAWAL_TYPES.EXTENSION: this.projectService.withdrawExtensionRequest(this.target_id).subscribe(() => { - this.bsModalRef.hide(); - this.event.emit(true); - }); - break; + this.bsModalRef.hide() + this.event.emit(true) + }) + break case WITHDRAWAL_TYPES.MODIFICATION: this.projectService.withdrawModificationRequest(this.target_id).subscribe(() => { - this.bsModalRef.hide(); - this.event.emit(true); - }); - break; + this.bsModalRef.hide() + this.event.emit(true) + }) + break default: - this.event.emit(false); + this.event.emit(false) } } - protected readonly WITHDRAWAL_TYPES = WITHDRAWAL_TYPES; + protected readonly WITHDRAWAL_TYPES = WITHDRAWAL_TYPES } diff --git a/src/app/projectmanagement/overview.component.ts b/src/app/projectmanagement/overview.component.ts index b1995bc1a1..f54c962d94 100644 --- a/src/app/projectmanagement/overview.component.ts +++ b/src/app/projectmanagement/overview.component.ts @@ -7,30 +7,30 @@ import { OnInit, Renderer2, ViewChild, - inject, -} from '@angular/core'; -import moment from 'moment'; -import { forkJoin, Observable, Subscription } from 'rxjs'; -import { ActivatedRoute, Router } from '@angular/router'; -import { DOCUMENT } from '@angular/common'; -import { Chart } from 'chart.js'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { environment } from '../../environments/environment'; -import { ProjectMemberApplication } from './project_member_application'; -import { Userinfo } from '../userinfo/userinfo.model'; -import { UserService } from '../api-connector/user.service'; -import { Application } from '../applications/application.model/application.model'; -import { GroupService } from '../api-connector/group.service'; -import { ApplicationBaseClassComponent } from '../shared/shared_modules/baseClass/application-base-class.component'; -import { FacilityService } from '../api-connector/facility.service'; -import { ApplicationsService } from '../api-connector/applications.service'; -import { FullLayoutComponent } from '../layouts/full-layout.component'; -import { Flavor } from '../virtualmachines/virtualmachinemodels/flavor'; -import { FlavorType } from '../virtualmachines/virtualmachinemodels/flavorType'; -import { FlavorService } from '../api-connector/flavor.service'; -import { CreditsService } from '../api-connector/credits.service'; -import { is_vo } from '../shared/globalvar'; + inject +} from '@angular/core' +import moment from 'moment' +import { forkJoin, Observable, Subscription } from 'rxjs' +import { ActivatedRoute, Router } from '@angular/router' +import { DOCUMENT } from '@angular/common' +import { Chart } from 'chart.js' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { MatomoTracker } from 'ngx-matomo-client' +import { environment } from '../../environments/environment' +import { ProjectMemberApplication } from './project_member_application' +import { Userinfo } from '../userinfo/userinfo.model' +import { UserService } from '../api-connector/user.service' +import { Application } from '../applications/application.model/application.model' +import { GroupService } from '../api-connector/group.service' +import { ApplicationBaseClassComponent } from '../shared/shared_modules/baseClass/application-base-class.component' +import { FacilityService } from '../api-connector/facility.service' +import { ApplicationsService } from '../api-connector/applications.service' +import { FullLayoutComponent } from '../layouts/full-layout.component' +import { Flavor } from '../virtualmachines/virtualmachinemodels/flavor' +import { FlavorType } from '../virtualmachines/virtualmachinemodels/flavorType' +import { FlavorService } from '../api-connector/flavor.service' +import { CreditsService } from '../api-connector/credits.service' +import { is_vo } from '../shared/globalvar' import { CLOUD_PORTAL_SUPPORT_MAIL, CREDITS_WIKI, @@ -42,17 +42,17 @@ import { STATUS_LINK, WIKI_MEMBER_MANAGEMENT, WIKI_PUBLICATIONS, - KUBERNETES_LINK, -} from '../../links/links'; -import { Doi } from '../applications/doi/doi'; -import { ApiSettings } from '../api-connector/api-settings.service'; -import { Application_States, ExtensionRequestType } from '../shared/shared_modules/baseClass/abstract-base-class'; -import { ProjectMember } from './project_member.model'; -import { ModificationRequestComponent } from './modals/modification-request/modification-request.component'; -import { LifetimeRequestComponent } from './modals/lifetime-request/lifetime-request.component'; -import { CreditsRequestComponent } from './modals/credits-request/credits-request.component'; -import { ExtensionEntryComponent } from './modals/testimonial/extension-entry.component'; -import { WITHDRAWAL_TYPES, WithdrawModalComponent } from './modals/withdraw/withdraw-modal.component'; + KUBERNETES_LINK +} from '../../links/links' +import { Doi } from '../applications/doi/doi' +import { ApiSettings } from '../api-connector/api-settings.service' +import { Application_States, ExtensionRequestType } from '../shared/shared_modules/baseClass/abstract-base-class' +import { ProjectMember } from './project_member.model' +import { ModificationRequestComponent } from './modals/modification-request/modification-request.component' +import { LifetimeRequestComponent } from './modals/lifetime-request/lifetime-request.component' +import { CreditsRequestComponent } from './modals/credits-request/credits-request.component' +import { ExtensionEntryComponent } from './modals/testimonial/extension-entry.component' +import { WITHDRAWAL_TYPES, WithdrawModalComponent } from './modals/withdraw/withdraw-modal.component' /** * Projectoverview component. */ @@ -66,79 +66,79 @@ import { WITHDRAWAL_TYPES, WithdrawModalComponent } from './modals/withdraw/with UserService, GroupService, ApiSettings, - CreditsService, - ], + CreditsService + ] }) export class OverviewComponent extends ApplicationBaseClassComponent implements OnInit, OnDestroy { - private readonly tracker = inject(MatomoTracker); - bsModalRef: BsModalRef; - modificationRequestDisabled: boolean = false; - lifetimeExtensionDisabled: boolean = false; - creditsExtensionDisabled: boolean = false; - voRegistrationLink: string = environment.voRegistrationLink; - vo_name: string = environment.voName; - WIKI_MEMBER_MANAGEMENT: string = WIKI_MEMBER_MANAGEMENT; - WIKI_PUBLICATIONS: string = WIKI_PUBLICATIONS; - CREDITS_WIKI: string = CREDITS_WIKI; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - PUBLICATIONS_LINK: string = PUBLICATIONS_LINK; - PUBLIC_DOI_ENDPOINT: string = PUBLIC_DOI_ENDPOINT; - SIMPLE_VM_LINK: string = SIMPLE_VM_LINK; - OPENSTACK_LINK: string = OPENSTACK_LINK; - KUBERNETES_LINK: string = KUBERNETES_LINK; - STATUS_LINK: string = STATUS_LINK; - NEW_SVM_PORTAL_LINK: string = NEW_SVM_PORTAL_LINK; - @ViewChild('creditsChart') creditsCanvas: ElementRef; - @ViewChild('publicKeyModal') publicKeyModal: any; - publicKeyToShow: string = ''; - publicKeyMemberName: string = ''; - project_id: string; - application_id: string; - credits: number = 0; - errorMessage: string; - terminate_confirmation_given: boolean = false; - showInformationCollapse: boolean = false; - newDoi: string; - doiError: string; - remove_members_clicked: boolean; - dois: Doi[]; - disabledDoiInput: boolean = false; - invitation_link: string; - project_application: Application; - application_action: string = ''; - application_member_name: string = ''; - application_action_done: boolean = false; - application_action_success: boolean; - application_action_error_message: boolean; - loaded: boolean = true; - userinfo: Userinfo; - allSet: boolean = false; - renderer: Renderer2; - supportMails: string[] = []; - toggleLocked: boolean = false; - resourceDataLoaded: boolean = false; - creditHistoryLoaded: boolean = false; - project_members_loaded: boolean = false; - vmsInUse: number; - maximumVMs: number; - coresInUse: number; - ramInUse: number; - memberApplicationsLoaded: boolean = false; - title: string = 'Project Overview'; - - simple_vm_logo: string = 'static/webapp/assets/img/simpleVM_Logo.svg'; - openstack_logo: string = 'static/webapp/assets/img/openstack_plain_red.svg'; - kubernetes_logo: string = 'static/webapp/assets/img/kubernetes_logo.svg'; - checked_member_list: number[] = []; + private readonly tracker = inject(MatomoTracker) + bsModalRef: BsModalRef + modificationRequestDisabled: boolean = false + lifetimeExtensionDisabled: boolean = false + creditsExtensionDisabled: boolean = false + voRegistrationLink: string = environment.voRegistrationLink + vo_name: string = environment.voName + WIKI_MEMBER_MANAGEMENT: string = WIKI_MEMBER_MANAGEMENT + WIKI_PUBLICATIONS: string = WIKI_PUBLICATIONS + CREDITS_WIKI: string = CREDITS_WIKI + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + PUBLICATIONS_LINK: string = PUBLICATIONS_LINK + PUBLIC_DOI_ENDPOINT: string = PUBLIC_DOI_ENDPOINT + SIMPLE_VM_LINK: string = SIMPLE_VM_LINK + OPENSTACK_LINK: string = OPENSTACK_LINK + KUBERNETES_LINK: string = KUBERNETES_LINK + STATUS_LINK: string = STATUS_LINK + NEW_SVM_PORTAL_LINK: string = NEW_SVM_PORTAL_LINK + @ViewChild('creditsChart') creditsCanvas: ElementRef + @ViewChild('publicKeyModal') publicKeyModal: any + publicKeyToShow: string = '' + publicKeyMemberName: string = '' + project_id: string + application_id: string + credits: number = 0 + errorMessage: string + terminate_confirmation_given: boolean = false + showInformationCollapse: boolean = false + newDoi: string + doiError: string + remove_members_clicked: boolean + dois: Doi[] + disabledDoiInput: boolean = false + invitation_link: string + project_application: Application + application_action: string = '' + application_member_name: string = '' + application_action_done: boolean = false + application_action_success: boolean + application_action_error_message: boolean + loaded: boolean = true + userinfo: Userinfo + allSet: boolean = false + renderer: Renderer2 + supportMails: string[] = [] + toggleLocked: boolean = false + resourceDataLoaded: boolean = false + creditHistoryLoaded: boolean = false + project_members_loaded: boolean = false + vmsInUse: number + maximumVMs: number + coresInUse: number + ramInUse: number + memberApplicationsLoaded: boolean = false + title: string = 'Project Overview' + + simple_vm_logo: string = 'static/webapp/assets/img/simpleVM_Logo.svg' + openstack_logo: string = 'static/webapp/assets/img/openstack_plain_red.svg' + kubernetes_logo: string = 'static/webapp/assets/img/kubernetes_logo.svg' + checked_member_list: number[] = [] // modal variables for User list - public project_members: ProjectMember[] = []; - public isLoaded: boolean = false; - creditsChart: any; - ExtensionRequestType: typeof ExtensionRequestType = ExtensionRequestType; - Application_States: typeof Application_States = Application_States; - private subscription: Subscription = new Subscription(); - private updateCreditsUsedIntervals: ReturnType; - private updateCreditsHistoryIntervals: ReturnType; + public project_members: ProjectMember[] = [] + public isLoaded: boolean = false + creditsChart: any + ExtensionRequestType: typeof ExtensionRequestType = ExtensionRequestType + Application_States: typeof Application_States = Application_States + private subscription: Subscription = new Subscription() + private updateCreditsUsedIntervals: ReturnType + private updateCreditsHistoryIntervals: ReturnType constructor( private flavorService: FlavorService, @@ -152,74 +152,74 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements private router: Router, private creditsService: CreditsService, @Inject(DOCUMENT) private document: Document, - cdrRef: ChangeDetectorRef, + cdrRef: ChangeDetectorRef ) { - super(userService, applicationsService, facilityService, cdrRef); + super(userService, applicationsService, facilityService, cdrRef) } calculateProgressBar(numberToRoundUp: number): string { - return Math.ceil(numberToRoundUp * 100).toString(); + return Math.ceil(numberToRoundUp * 100).toString() } async delay(ms: number): Promise { // tslint:disable-next-line:typedef return new Promise((resolve: any) => { - setTimeout(resolve, ms); - }); + setTimeout(resolve, ms) + }) } ngOnInit(): void { this.activatedRoute.params.subscribe((paramsId: any): void => { try { if (this.updateCreditsUsedIntervals) { - clearInterval(this.updateCreditsUsedIntervals); + clearInterval(this.updateCreditsUsedIntervals) } if (this.updateCreditsHistoryIntervals) { - clearInterval(this.updateCreditsHistoryIntervals); - this.creditHistoryLoaded = false; - this.creditsChart = undefined; + clearInterval(this.updateCreditsHistoryIntervals) + this.creditHistoryLoaded = false + this.creditsChart = undefined } } catch (error: any) { - console.log(error); + console.log(error) } - this.subscription.unsubscribe(); - this.subscription = new Subscription(); - this.modificationRequestDisabled = false; - this.lifetimeExtensionDisabled = false; - this.creditsExtensionDisabled = false; - this.disabledDoiInput = false; - this.resourceDataLoaded = false; - this.creditHistoryLoaded = false; - this.errorMessage = null; - this.isLoaded = false; - this.project_members_loaded = false; - this.errorMessage = null; - this.isLoaded = false; - this.project_application = null; - this.project_members = []; - this.application_id = paramsId.id; - this.tracker.trackPageView(`Project Overview for pid: ${paramsId.id}`); - this.is_vo_admin = is_vo; - - this.getApplication(); - this.getUserinfo(); - this.getListOfFlavors(); - this.getListOfTypes(); - }); + this.subscription.unsubscribe() + this.subscription = new Subscription() + this.modificationRequestDisabled = false + this.lifetimeExtensionDisabled = false + this.creditsExtensionDisabled = false + this.disabledDoiInput = false + this.resourceDataLoaded = false + this.creditHistoryLoaded = false + this.errorMessage = null + this.isLoaded = false + this.project_members_loaded = false + this.errorMessage = null + this.isLoaded = false + this.project_application = null + this.project_members = [] + this.application_id = paramsId.id + this.tracker.trackPageView(`Project Overview for pid: ${paramsId.id}`) + this.is_vo_admin = is_vo + + this.getApplication() + this.getUserinfo() + this.getListOfFlavors() + this.getListOfTypes() + }) } ngOnDestroy(): void { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() try { if (this.updateCreditsUsedIntervals) { - clearInterval(this.updateCreditsUsedIntervals); + clearInterval(this.updateCreditsUsedIntervals) } if (this.updateCreditsHistoryIntervals) { - clearInterval(this.updateCreditsHistoryIntervals); + clearInterval(this.updateCreditsHistoryIntervals) } } catch (error: any) { - console.log(error); + console.log(error) } } @@ -228,54 +228,54 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements this.applicationsService.getFullApplicationByUserPermissions(this.application_id).subscribe( (aj: Application): void => { if (aj.project_application_name === '') { - this.isLoaded = false; - this.errorMessage = 'Not found'; + this.isLoaded = false + this.errorMessage = 'Not found' - return; + return } - this.modificationRequestDisabled = false; - this.lifetimeExtensionDisabled = false; + this.modificationRequestDisabled = false + this.lifetimeExtensionDisabled = false - this.project_application = aj; + this.project_application = aj - this.setSupportMails(this.project_application); + this.setSupportMails(this.project_application) if (this.project_application.project_application_perun_id) { - this.getUsedResources(); + this.getUsedResources() if ( - this.project_application.user_is_admin - || this.project_application.show_member_names - || this.is_vo_admin + this.project_application.user_is_admin || + this.project_application.show_member_names || + this.is_vo_admin ) { - this.getMembersOfTheProject(); + this.getMembersOfTheProject() } if (this.project_application.credits_allowed && !this.project_application.credits_loop_started) { - this.project_application.setCreditsLoopStarted(); - this.startUpdateCreditUsageLoop(); + this.project_application.setCreditsLoopStarted() + this.startUpdateCreditUsageLoop() } } - this.getDois(); - this.getUserProjectApplications(); + this.getDois() + this.getUserProjectApplications() - this.isLoaded = true; + this.isLoaded = true this.activatedRoute.fragment.subscribe(fragment => { if (fragment !== null) { - this.scrollTo(fragment); + this.scrollTo(fragment) } - }); + }) }, (error: any): void => { - this.isLoaded = false; + this.isLoaded = false if (error.status === 403) { - this.errorMessage = 'You are not allowed to view the requested project.'; + this.errorMessage = 'You are not allowed to view the requested project.' } else { - const errorobj: any = error.error; - this.errorMessage = errorobj['error']; + const errorobj: any = error.error + this.errorMessage = errorobj['error'] } - }, - ), - ); + } + ) + ) } scrollTo(element: any): void { @@ -283,17 +283,17 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements document.getElementById(element).scrollIntoView({ behavior: 'smooth', block: 'start', - inline: 'nearest', - }); - }, 1500); + inline: 'nearest' + }) + }, 1500) } getUserinfo(): void { this.subscription.add( this.userService.getUserInfo().subscribe((userinfo: Userinfo): void => { - this.userinfo = userinfo; - }), - ); + this.userinfo = userinfo + }) + ) } /** @@ -302,9 +302,9 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements getListOfFlavors(): void { this.subscription.add( this.flavorService.getListOfFlavorsAvailable().subscribe((flavors: Flavor[]): void => { - this.flavorList = flavors; - }), - ); + this.flavorList = flavors + }) + ) } /** @@ -312,103 +312,103 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements */ getListOfTypes(): void { this.subscription.add( - this.flavorService.getListOfTypesAvailable().subscribe((types: FlavorType[]): void => this.setListOfTypes(types)), - ); + this.flavorService.getListOfTypesAvailable().subscribe((types: FlavorType[]): void => this.setListOfTypes(types)) + ) } getDois(): void { this.subscription.add( this.groupService.getGroupDois(this.application_id).subscribe((dois: Doi[]): void => { - this.dois = dois; - }), - ); + this.dois = dois + }) + ) } showResourceModal(): void { if (this.modificationRequestDisabled) { - return; + return } - this.modificationRequestDisabled = true; + this.modificationRequestDisabled = true const initialState = { - project: this.project_application, - }; - this.bsModalRef = this.modalService.show(ModificationRequestComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeForExtensionResult(this.ExtensionRequestType.MODIFICATION); + project: this.project_application + } + this.bsModalRef = this.modalService.show(ModificationRequestComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeForExtensionResult(this.ExtensionRequestType.MODIFICATION) } showWithDrawExtensionModal(): void { - this.showWithdrawModal(this.project_application.lifetime_extension_request_id, WITHDRAWAL_TYPES.EXTENSION); + this.showWithdrawModal(this.project_application.lifetime_extension_request_id, WITHDRAWAL_TYPES.EXTENSION) } showWithDrawModificationModal(): void { - this.showWithdrawModal(this.project_application.modification_extension_request_id, WITHDRAWAL_TYPES.MODIFICATION); + this.showWithdrawModal(this.project_application.modification_extension_request_id, WITHDRAWAL_TYPES.MODIFICATION) } showWithdrawModal(target_id: string | number, type: WITHDRAWAL_TYPES): void { const initialState = { target_id, - type, - }; - this.bsModalRef = this.modalService.show(WithdrawModalComponent, { initialState, class: 'modal-lg' }); + type + } + this.bsModalRef = this.modalService.show(WithdrawModalComponent, { initialState, class: 'modal-lg' }) this.subscription.add( this.bsModalRef.content.event.subscribe((event: boolean): void => { if (event) { - this.getApplication(); + this.getApplication() } - }), - ); + }) + ) } showExtensionInformationModal(): void { const initialState = { dois: this.dois, - application_id: this.application_id, - }; - this.bsModalRef = this.modalService.show(ExtensionEntryComponent, { initialState, class: 'modal-lg' }); + application_id: this.application_id + } + this.bsModalRef = this.modalService.show(ExtensionEntryComponent, { initialState, class: 'modal-lg' }) this.subscription.add( this.bsModalRef.content.event.subscribe((event: any): void => { if (event.reloadDoi) { - this.getDois(); + this.getDois() } else if (event.showExtension) { - this.showLifetimeExtensionModal(); + this.showLifetimeExtensionModal() } - }), - ); + }) + ) } showLifetimeExtensionModal(): void { if (this.lifetimeExtensionDisabled) { - return; + return } - this.lifetimeExtensionDisabled = true; + this.lifetimeExtensionDisabled = true const initialState = { project: this.project_application, - life_time_string: `${this.project_application.project_application_date_approved} - ${this.project_application.date_end}`, - }; - this.bsModalRef = this.modalService.show(LifetimeRequestComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeForExtensionResult(this.ExtensionRequestType.EXTENSION); + life_time_string: `${this.project_application.project_application_date_approved} - ${this.project_application.date_end}` + } + this.bsModalRef = this.modalService.show(LifetimeRequestComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeForExtensionResult(this.ExtensionRequestType.EXTENSION) } showCreditsExtensionModal(): void { if (this.creditsExtensionDisabled) { - return; + return } - this.creditsExtensionDisabled = true; + this.creditsExtensionDisabled = true const initialState = { project: this.project_application, - flavorList: this.flavorList, - }; - this.bsModalRef = this.modalService.show(CreditsRequestComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeForExtensionResult(this.ExtensionRequestType.CREDIT); + flavorList: this.flavorList + } + this.bsModalRef = this.modalService.show(CreditsRequestComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeForExtensionResult(this.ExtensionRequestType.CREDIT) } subscribeForExtensionResult(type: ExtensionRequestType): void { @@ -416,38 +416,38 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements this.bsModalRef.content.event.subscribe((result: any) => { if ('reload' in result && result['reload']) { if (type === this.ExtensionRequestType.EXTENSION) { - this.lifetimeExtensionDisabled = true; + this.lifetimeExtensionDisabled = true } else if (type === this.ExtensionRequestType.MODIFICATION) { - this.modificationRequestDisabled = true; + this.modificationRequestDisabled = true } else if (type === this.ExtensionRequestType.CREDIT) { - this.creditsExtensionDisabled = true; + this.creditsExtensionDisabled = true } - this.fullLayout.getGroupsEnumeration(); - this.getApplication(); + this.fullLayout.getGroupsEnumeration() + this.getApplication() } else if (type === this.ExtensionRequestType.EXTENSION) { - this.lifetimeExtensionDisabled = false; + this.lifetimeExtensionDisabled = false } else if (type === this.ExtensionRequestType.MODIFICATION) { - this.modificationRequestDisabled = false; + this.modificationRequestDisabled = false } else if (type === this.ExtensionRequestType.CREDIT) { - this.creditsExtensionDisabled = false; + this.creditsExtensionDisabled = false } - }), - ); + }) + ) } fetchCreditHistoryOfProject(): void { - this.creditHistoryLoaded = false; - if (this.project_application != null && this.project_application.credits_allowed) { + this.creditHistoryLoaded = false + if (this.project_application !== null && this.project_application.credits_allowed) { this.subscription.add( this.creditsService .getCreditsUsageHistoryOfProject(Number(this.project_application.project_application_perun_id.toString())) .subscribe((response: any): void => { if (response['data_points'] !== undefined) { - const data_points: number[] = response['data_points']; + const data_points: number[] = response['data_points'] if (this.creditsChart !== undefined) { - this.creditsChart.data.labels = response['time_points']; - this.creditsChart.data.datasets[0].data = data_points; - this.creditsChart.update(); + this.creditsChart.data.labels = response['time_points'] + this.creditsChart.data.datasets[0].data = data_points + this.creditsChart.update() } else { this.creditsChart = new Chart(this.creditsCanvas.nativeElement, { type: 'line', @@ -458,99 +458,99 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements label: 'Credit Usage', data: data_points, borderColor: 'rgba(54, 162, 235, 1)', - backgroundColor: 'rgba(54, 162, 235, 0.2)', - }, - ], + backgroundColor: 'rgba(54, 162, 235, 0.2)' + } + ] }, options: { animation: { - duration: 0, + duration: 0 }, layout: { padding: { left: 25, right: 25, top: 25, - bottom: 50, - }, + bottom: 50 + } }, - responsive: true, - }, - }); + responsive: true + } + }) } } if (!this.creditHistoryLoaded) { - this.creditHistoryLoaded = true; + this.creditHistoryLoaded = true } - }), - ); + }) + ) } } startUpdateCreditUsageLoop(): void { if ( - !this.project_application.credits_allowed - || !this.project_application - || !this.project_application.project_application_perun_id + !this.project_application.credits_allowed || + !this.project_application || + !this.project_application.project_application_perun_id ) { - return; + return } - this.getCurrentCreditsOfProject(); - this.fetchCreditHistoryOfProject(); + this.getCurrentCreditsOfProject() + this.fetchCreditHistoryOfProject() - this.updateCreditsUsedIntervals = setInterval((): any => this.getCurrentCreditsOfProject(), 10000); + this.updateCreditsUsedIntervals = setInterval((): any => this.getCurrentCreditsOfProject(), 10000) - this.updateCreditsHistoryIntervals = setInterval((): any => this.fetchCreditHistoryOfProject(), 30000); + this.updateCreditsHistoryIntervals = setInterval((): any => this.fetchCreditHistoryOfProject(), 30000) } getCurrentCreditsOfProject(): void { if ( - this.project_application - && this.project_application.project_application_perun_id - && this.project_application.credits_allowed + this.project_application && + this.project_application.project_application_perun_id && + this.project_application.credits_allowed ) { this.subscription.add( this.creditsService .getCurrentCreditsOfProject(this.project_application.project_application_perun_id.toString()) .subscribe( (credits: number): void => { - if (this.project_application != null) { - this.project_application.project_application_current_credits = credits; + if (this.project_application !== null) { + this.project_application.project_application_current_credits = credits } }, (err: any): void => { - console.log(err.message); - }, - ), - ); + console.log(err.message) + } + ) + ) } } approveMemberApplication(application: number, membername: string): void { - this.loaded = false; - this.application_action_done = false; + this.loaded = false + this.application_action_done = false this.subscription.add( this.groupService .approveGroupApplication(Number(this.project_application.project_application_perun_id), application) .subscribe((tmp_application: any): void => { if (tmp_application['state'] === 'APPROVED') { - this.application_action_success = true; + this.application_action_success = true } else if (tmp_application['message']) { - this.application_action_success = false; + this.application_action_success = false - this.application_action_error_message = tmp_application['message']; + this.application_action_error_message = tmp_application['message'] } else { - this.application_action_success = false; + this.application_action_success = false } - this.application_action = 'approved'; - this.application_member_name = membername; - this.application_action_done = true; - this.getUserProjectApplications(); - this.getMembersOfTheProject(); - this.loaded = true; - }), - ); + this.application_action = 'approved' + this.application_member_name = membername + this.application_action_done = true + this.getUserProjectApplications() + this.getMembersOfTheProject() + this.loaded = true + }) + ) } /** @@ -561,15 +561,15 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements if (this.resourceDataLoaded) { if (!this.project_application?.project_application_openstack_project) { if ( - this.vmsInUse < this.maximumVMs - && (this.project_application.user_is_admin || this.project_application.allow_machines_starting) + this.vmsInUse < this.maximumVMs && + (this.project_application.user_is_admin || this.project_application.allow_machines_starting) ) { - return true; + return true } } } - return false; + return false } /** @@ -577,23 +577,23 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements * For SimpleVM also the VMs in use are set. */ getUsedResources(): void { - this.resourceDataLoaded = false; + this.resourceDataLoaded = false if (!this.project_application?.project_application_openstack_project) { this.subscription.add( this.groupService .getGroupResources(this.project_application.project_application_perun_id.toString()) .subscribe((res: any): void => { - this.vmsInUse = res['used_vms']; - this.maximumVMs = res['number_vms']; - this.coresInUse = res['cores_used']; - this.ramInUse = res['ram_used']; - this.resourceDataLoaded = true; - }), - ); + this.vmsInUse = res['used_vms'] + this.maximumVMs = res['number_vms'] + this.coresInUse = res['cores_used'] + this.ramInUse = res['ram_used'] + this.resourceDataLoaded = true + }) + ) } else { - this.maximumVMs = this.calculateNumberOfVMs(this.project_application?.flavors); - this.resourceDataLoaded = true; + this.maximumVMs = this.calculateNumberOfVMs(this.project_application?.flavors) + this.resourceDataLoaded = true } } @@ -603,132 +603,132 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements * @param flavors the list of flavors requested in the project */ calculateNumberOfVMs(flavors: Flavor[]): number { - let numberOfVMs: number = 0; + let numberOfVMs: number = 0 flavors.forEach((flavor: any): void => { - numberOfVMs += flavor['counter']; - }); + numberOfVMs += flavor['counter'] + }) - return numberOfVMs; + return numberOfVMs } isNewDoi(): boolean { for (const doi of this.dois) { if (doi.identifier === this.newDoi) { - return false; + return false } } - return true; + return true } deleteDoi(doi: Doi): void { this.subscription.add( this.groupService.deleteGroupDoi(doi.id).subscribe((dois: Doi[]): void => { - this.dois = dois; - }), - ); + this.dois = dois + }) + ) } toggleDoiDisabledInput(): void { - this.disabledDoiInput = !this.disabledDoiInput; + this.disabledDoiInput = !this.disabledDoiInput } toggleMemberNameVisibility(): void { - this.toggleLocked = true; + this.toggleLocked = true this.groupService.toggleVisibility(this.project_application.project_application_perun_id).subscribe( (res: any): void => { - this.project_application.show_member_names = res['show_member_names']; - this.toggleLocked = false; + this.project_application.show_member_names = res['show_member_names'] + this.toggleLocked = false }, () => { - this.toggleLocked = false; - }, - ); + this.toggleLocked = false + } + ) } toggleStartingOfMachines(): void { - this.toggleLocked = true; + this.toggleLocked = true this.groupService.toggleStartingMachines(this.project_application.project_application_perun_id).subscribe( (res: any): void => { - this.project_application.allow_machines_starting = res['allow_machines_starting']; - this.toggleLocked = false; + this.project_application.allow_machines_starting = res['allow_machines_starting'] + this.toggleLocked = false }, () => { - this.toggleLocked = false; - }, - ); + this.toggleLocked = false + } + ) } switchToggleLocked(check: boolean): void { - this.toggleLocked = check; + this.toggleLocked = check } addDoi(): void { - this.toggleDoiDisabledInput(); + this.toggleDoiDisabledInput() if (this.isNewDoi()) { this.subscription.add( this.groupService.addGroupDoi(this.application_id, this.newDoi).subscribe( (dois: Doi[]): void => { - this.doiError = null; - this.newDoi = null; - this.dois = dois; + this.doiError = null + this.newDoi = null + this.dois = dois }, (): void => { - this.doiError = `DOI ${this.newDoi} was already added by another Project!`; - this.toggleDoiDisabledInput(); + this.doiError = `DOI ${this.newDoi} was already added by another Project!` + this.toggleDoiDisabledInput() }, (): void => { - this.toggleDoiDisabledInput(); - this.newDoi = null; - }, - ), - ); + this.toggleDoiDisabledInput() + this.newDoi = null + } + ) + ) } else { - this.doiError = `DOI ${this.newDoi} was already added by this Project!`; - this.newDoi = null; - this.toggleDoiDisabledInput(); + this.doiError = `DOI ${this.newDoi} was already added by this Project!` + this.newDoi = null + this.toggleDoiDisabledInput() } } requestProjectTermination(): void { - this.updateNotificationModal('Waiting', 'Termination request will be submitted...', true, 'info'); + this.updateNotificationModal('Waiting', 'Termination request will be submitted...', true, 'info') this.subscription.add( this.groupService .requestProjectTermination(this.project_application.project_application_perun_id) .subscribe((): void => { - this.fullLayout.getGroupsEnumeration(); - this.getApplication(); - this.updateNotificationModal('Success', 'Termination was requested!', true, 'success'); - }), - ); + this.fullLayout.getGroupsEnumeration() + this.getApplication() + this.updateNotificationModal('Success', 'Termination was requested!', true, 'success') + }) + ) } rejectMemberApplication(application: number, membername: string): void { - this.loaded = false; - this.application_action_done = false; + this.loaded = false + this.application_action_done = false this.subscription.add( this.groupService .rejectGroupApplication(Number(this.project_application.project_application_perun_id), application) .subscribe((tmp_application: any): void => { - this.project_application.project_application_member_applications = []; + this.project_application.project_application_member_applications = [] if (tmp_application['state'] === 'REJECTED') { - this.application_action_success = true; + this.application_action_success = true } else if (tmp_application['message']) { - this.application_action_success = false; + this.application_action_success = false - this.application_action_error_message = tmp_application['message']; + this.application_action_error_message = tmp_application['message'] } else { - this.application_action_success = false; + this.application_action_success = false } - this.application_action = 'rejected'; - this.application_member_name = membername; - this.application_action_done = true; - this.getUserProjectApplications(); - this.loaded = true; - }), - ); + this.application_action = 'rejected' + this.application_member_name = membername + this.application_action_done = true + this.getUserProjectApplications() + this.loaded = true + }) + ) } /** @@ -736,45 +736,45 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements */ getUserProjectApplications(): void { if (this.project_application.isApproved() && this.project_application.project_application_perun_id) { - this.memberApplicationsLoaded = false; + this.memberApplicationsLoaded = false this.subscription.add( this.groupService .getGroupApplications(this.project_application.project_application_perun_id) .subscribe((applications: any): void => { - const newProjectApplications: ProjectMemberApplication[] = []; + const newProjectApplications: ProjectMemberApplication[] = [] if (applications.length === 0) { - this.project_application.project_application_member_applications = []; + this.project_application.project_application_member_applications = [] - this.memberApplicationsLoaded = true; + this.memberApplicationsLoaded = true } for (const application of applications) { - const dateApplicationCreated: moment.Moment = moment(application['createdAt'], 'YYYY-MM-DD HH:mm:ss.SSS'); - const membername: string = application['displayName']; + const dateApplicationCreated: moment.Moment = moment(application['createdAt'], 'YYYY-MM-DD HH:mm:ss.SSS') + const membername: string = application['displayName'] const newMemberApplication: ProjectMemberApplication = new ProjectMemberApplication( application['id'], membername, `${dateApplicationCreated.date()}.${ dateApplicationCreated.month() + 1 - }.${dateApplicationCreated.year()}`, - ); - newProjectApplications.push(newMemberApplication); - this.project_application.project_application_member_applications = newProjectApplications; - this.memberApplicationsLoaded = true; + }.${dateApplicationCreated.year()}` + ) + newProjectApplications.push(newMemberApplication) + this.project_application.project_application_member_applications = newProjectApplications + this.memberApplicationsLoaded = true } - }), - ); + }) + ) } } setSupportMails(project: Application): void { if ( - typeof project.project_application_compute_center?.Support !== 'undefined' - && project.project_application_compute_center?.Support + typeof project.project_application_compute_center?.Support !== 'undefined' && + project.project_application_compute_center?.Support ) { - this.supportMails = project.project_application_compute_center.Support.toString().split(','); + this.supportMails = project.project_application_compute_center.Support.toString().split(',') } else { - this.supportMails = []; + this.supportMails = [] } } @@ -782,112 +782,113 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements * Get all members of a project. */ getMembersOfTheProject(): void { - this.project_members_loaded = false; + this.project_members_loaded = false this.subscription.add( this.groupService .getGroupMembers(this.project_application.project_application_perun_id.toString()) .subscribe((members: ProjectMember[]): void => { - this.project_members = members; + this.project_members = members if (this.project_application.user_is_admin) { if ( - this.project_application - && this.project_application.credits_allowed - && !this.project_application.credits_loop_started + this.project_application && + this.project_application.credits_allowed && + !this.project_application.credits_loop_started ) { - this.project_application.setCreditsLoopStarted(); - this.startUpdateCreditUsageLoop(); + this.project_application.setCreditsLoopStarted() + this.startUpdateCreditUsageLoop() } } - this.project_members_loaded = true; - this.isLoaded = true; - }), - ); + this.project_members_loaded = true + this.isLoaded = true + }) + ) } setAllMembersChecked(): void { if (!this.allSet) { this.project_members.forEach((member: ProjectMember): void => { if ( - !this.isMemberChecked(parseInt(member.memberId.toString(), 10)) - && this.userinfo.MemberId.toString() !== member.memberId.toString() + !this.isMemberChecked(parseInt(member.memberId.toString(), 10)) && + this.userinfo.MemberId.toString() !== member.memberId.toString() ) { - this.checked_member_list.push(parseInt(member.memberId.toString(), 10)); + this.checked_member_list.push(parseInt(member.memberId.toString(), 10)) } - }); - this.allSet = true; + }) + this.allSet = true } else { - this.checked_member_list = []; - this.allSet = false; + this.checked_member_list = [] + this.allSet = false } } isMemberChecked(id: number): boolean { - return this.checked_member_list.indexOf(id) > -1; + return this.checked_member_list.indexOf(id) > -1 } checkIfAllMembersChecked(): void { - let all_set: boolean = true; + let all_set: boolean = true this.project_members.forEach((member: ProjectMember): void => { if ( - !this.isMemberChecked(parseInt(member.memberId.toString(), 10)) - && this.userinfo.MemberId !== member.memberId + !this.isMemberChecked(parseInt(member.memberId.toString(), 10)) && + this.userinfo.MemberId !== member.memberId ) { - all_set = false; + all_set = false } - }); + }) - this.allSet = all_set; + this.allSet = all_set } checkUnCheckMember(id: number): void { - const indexOf: number = this.checked_member_list.indexOf(id); + const indexOf: number = this.checked_member_list.indexOf(id) if (indexOf !== -1) { - this.checked_member_list.splice(indexOf, 1); - this.allSet = false; + this.checked_member_list.splice(indexOf, 1) + this.allSet = false } else { - this.checked_member_list.push(id); - this.checkIfAllMembersChecked(); + this.checked_member_list.push(id) + this.checkIfAllMembersChecked() } } removeCheckedMembers(): void { - this.remove_members_clicked = true; + this.remove_members_clicked = true - const members_in: ProjectMember[] = []; + const members_in: ProjectMember[] = [] const observables: Observable[] = this.checked_member_list.map( - (id: number): Observable => this.groupService.removeMember( - Number(this.project_application.project_application_perun_id), - id, - this.project_application.project_application_compute_center.FacilityId, - ), - ); + (id: number): Observable => + this.groupService.removeMember( + Number(this.project_application.project_application_perun_id), + id, + this.project_application.project_application_compute_center.FacilityId + ) + ) forkJoin(observables).subscribe((): void => { this.project_members.forEach((member: ProjectMember): void => { if (!this.isMemberChecked(parseInt(member.memberId.toString(), 10))) { - members_in.push(member); + members_in.push(member) } - }); - this.project_members = members_in; - this.checked_member_list = []; - this.allSet = false; - this.remove_members_clicked = false; - }); - this.allSet = false; + }) + this.project_members = members_in + this.checked_member_list = [] + this.allSet = false + this.remove_members_clicked = false + }) + this.allSet = false } setAddUserInvitationLink(): void { - const project_reg: string = `https://signup.aai.lifescience-ri.eu/fed/registrar/?vo=${this.vo_name}&group=${this.project_application.project_application_shortname}`; - this.invitation_link = project_reg; + const project_reg: string = `https://signup.aai.lifescience-ri.eu/fed/registrar/?vo=${this.vo_name}&group=${this.project_application.project_application_shortname}` + this.invitation_link = project_reg } copyToClipboard(text: string): void { document.addEventListener('copy', (clipEvent: ClipboardEvent): void => { - clipEvent.clipboardData.setData('text/plain', text); - clipEvent.preventDefault(); - document.removeEventListener('copy', null); - }); - document.execCommand('copy'); + clipEvent.clipboardData.setData('text/plain', text) + clipEvent.preventDefault() + document.removeEventListener('copy', null) + }) + document.execCommand('copy') } public promoteAdmin(userid: number, username: string): void { @@ -895,45 +896,45 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements .addAdmin( this.project_application.project_application_perun_id, userid, - this.project_application.project_application_compute_center.FacilityId, + this.project_application.project_application_compute_center.FacilityId ) .toPromise() .then((result: any): void => { if (result.status === 200) { - this.updateNotificationModal('Success', `${username} promoted to Admin`, true, 'success'); - this.getMembersOfTheProject(); + this.updateNotificationModal('Success', `${username} promoted to Admin`, true, 'success') + this.getMembersOfTheProject() } else { - this.updateNotificationModal('Failed', `${username} could not be promoted to Admin!`, true, 'danger'); + this.updateNotificationModal('Failed', `${username} could not be promoted to Admin!`, true, 'danger') } }) .catch((): void => { - this.updateNotificationModal('Failed', `${username} could not be promoted to Admin!`, true, 'danger'); - }); + this.updateNotificationModal('Failed', `${username} could not be promoted to Admin!`, true, 'danger') + }) } public removeAdmin(userid: number, name: string): void { if (this.userinfo.Id.toString() === userid.toString()) { - return; + return } this.groupService .removeAdmin( this.project_application.project_application_perun_id, userid, - this.project_application.project_application_compute_center.FacilityId, + this.project_application.project_application_compute_center.FacilityId ) .toPromise() .then((result: any): void => { if (result.status === 200) { - this.updateNotificationModal('Success', `${name} was removed as Admin`, true, 'success'); - this.getMembersOfTheProject(); + this.updateNotificationModal('Success', `${name} was removed as Admin`, true, 'success') + this.getMembersOfTheProject() } else { - this.updateNotificationModal('Failed', `${name} could not be removed as Admin!`, true, 'danger'); + this.updateNotificationModal('Failed', `${name} could not be removed as Admin!`, true, 'danger') } }) .catch((): void => { - this.updateNotificationModal('Failed', `${name} could not be removed as Admin!`, true, 'danger'); - }); + this.updateNotificationModal('Failed', `${name} could not be removed as Admin!`, true, 'danger') + }) } /** @@ -944,34 +945,34 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements */ public removeMember(memberid: number, name: string): void { if (this.userinfo.MemberId.toString() === memberid.toString()) { - return; + return } - const indexOf: number = this.checked_member_list.indexOf(memberid); + const indexOf: number = this.checked_member_list.indexOf(memberid) if (indexOf !== -1) { - this.checked_member_list.splice(indexOf, 1); - this.allSet = false; + this.checked_member_list.splice(indexOf, 1) + this.allSet = false } this.subscription.add( this.groupService .removeMember( this.project_application.project_application_perun_id, memberid, - this.project_application.project_application_compute_center.FacilityId, + this.project_application.project_application_compute_center.FacilityId ) .subscribe( (result: any): void => { if (result.status === 200) { - this.updateNotificationModal('Success', `Member ${name} removed from the group`, true, 'success'); - this.getMembersOfTheProject(); + this.updateNotificationModal('Success', `Member ${name} removed from the group`, true, 'success') + this.getMembersOfTheProject() } else { - this.updateNotificationModal('Failed', `Member ${name} could not be removed !`, true, 'danger'); + this.updateNotificationModal('Failed', `Member ${name} could not be removed !`, true, 'danger') } }, (): void => { - this.updateNotificationModal('Failed', `Member ${name} could not be removed !`, true, 'danger'); - }, - ), - ); + this.updateNotificationModal('Failed', `Member ${name} could not be removed !`, true, 'danger') + } + ) + ) } /** @@ -986,15 +987,15 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements 'Denied', `You cannot leave projects as PI. Please contact ${CLOUD_PORTAL_SUPPORT_MAIL} for further steps.`, true, - 'danger', - ); + 'danger' + ) } else { this.subscription.add( this.groupService .leaveGroup( this.project_application.project_application_perun_id, memberid, - this.project_application.project_application_compute_center.FacilityId, + this.project_application.project_application_compute_center.FacilityId ) .subscribe( (result: any): void => { @@ -1003,26 +1004,26 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements 'Success', `You were removed from the project ${projectname}`, true, - 'success', - ); - void this.router.navigate(['/userinfo']); - this.fullLayout.getGroupsEnumeration(); + 'success' + ) + void this.router.navigate(['/userinfo']) + this.fullLayout.getGroupsEnumeration() } else { - this.updateNotificationModal('Failed', `Failed to leave the project ${projectname}!`, true, 'danger'); + this.updateNotificationModal('Failed', `Failed to leave the project ${projectname}!`, true, 'danger') } }, (): void => { - this.updateNotificationModal('Failed', `Failed to leave the project ${projectname}!`, true, 'danger'); - }, - ), - ); + this.updateNotificationModal('Failed', `Failed to leave the project ${projectname}!`, true, 'danger') + } + ) + ) } } showPublicKeyModal(member: ProjectMember): void { - this.publicKeyToShow = member.publicKey; - this.publicKeyMemberName = `${member.firstName} ${member.lastName}`; - this.publicKeyModal.show(); + this.publicKeyToShow = member.publicKey + this.publicKeyMemberName = `${member.firstName} ${member.lastName}` + this.publicKeyModal.show() } /** @@ -1032,15 +1033,15 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements this.subscription.add( this.applicationsService.deleteApplication(this.project_application.project_application_id).subscribe( (): void => { - this.updateNotificationModal('Success', 'The application has been successfully removed', true, 'success'); - this.fullLayout.getGroupsEnumeration(); - // eslint-disable-next-line no-void - void this.router.navigate(['/userinfo']); + this.updateNotificationModal('Success', 'The application has been successfully removed', true, 'success') + this.fullLayout.getGroupsEnumeration() + + void this.router.navigate(['/userinfo']) }, (): void => { - this.updateNotificationModal('Failed', 'Application could not be removed!', true, 'danger'); - }, - ), - ); + this.updateNotificationModal('Failed', 'Application could not be removed!', true, 'danger') + } + ) + ) } } diff --git a/src/app/projectmanagement/project-os-details/project-os-details.component.ts b/src/app/projectmanagement/project-os-details/project-os-details.component.ts index 4f9e77a17a..8d1199148d 100644 --- a/src/app/projectmanagement/project-os-details/project-os-details.component.ts +++ b/src/app/projectmanagement/project-os-details/project-os-details.component.ts @@ -1,11 +1,9 @@ -import { - Component, Input, OnChanges, OnInit, SimpleChanges, -} from '@angular/core'; -import { VirtualMachine } from '../../virtualmachines/virtualmachinemodels/virtualmachine'; -import { Volume } from '../../virtualmachines/volumes/volume'; -import { SnapshotModel } from '../../virtualmachines/snapshots/snapshot.model'; -import { GroupService } from '../../api-connector/group.service'; -import { Application } from '../../applications/application.model/application.model'; +import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' +import { VirtualMachine } from '../../virtualmachines/virtualmachinemodels/virtualmachine' +import { Volume } from '../../virtualmachines/volumes/volume' +import { SnapshotModel } from '../../virtualmachines/snapshots/snapshot.model' +import { GroupService } from '../../api-connector/group.service' +import { Application } from '../../applications/application.model/application.model' /** * Project OpenStack Details Component. @@ -14,41 +12,39 @@ import { Application } from '../../applications/application.model/application.mo selector: 'app-project-os-details', templateUrl: './project-os-details.component.html', styleUrls: ['./project-os-details.component.css'], - providers: [GroupService], + providers: [GroupService] }) export class ProjectOsDetailsComponent implements OnInit, OnChanges { - - @Input() project: Application; - selectedProjectVms: VirtualMachine[] = []; - selectedProjectVolumes: Volume[] = []; - selectedProjectSnapshots: SnapshotModel[] = []; - details_loaded: boolean = false; + @Input() project: Application + selectedProjectVms: VirtualMachine[] = [] + selectedProjectVolumes: Volume[] = [] + selectedProjectSnapshots: SnapshotModel[] = [] + details_loaded: boolean = false constructor(private groupService: GroupService) { - this.groupService = groupService; + this.groupService = groupService } // eslint-disable-next-line @typescript-eslint/no-unused-vars ngOnChanges(changes: SimpleChanges): void { - this.details_loaded = false; - this.getProjectDetails(); + this.details_loaded = false + this.getProjectDetails() } ngOnInit(): void { - this.details_loaded = false; - this.getProjectDetails(); + this.details_loaded = false + this.getProjectDetails() } getProjectDetails(): void { if (!this.project.project_application_perun_id) { - return; + return } this.groupService.getProjectOSDetails(this.project.project_application_perun_id).subscribe((res: any): void => { - this.selectedProjectVms = res['vms']; - this.selectedProjectVolumes = res['volumes']; - this.selectedProjectSnapshots = res['snapshots']; - this.details_loaded = true; - }); + this.selectedProjectVms = res['vms'] + this.selectedProjectVolumes = res['volumes'] + this.selectedProjectSnapshots = res['snapshots'] + this.details_loaded = true + }) } - } diff --git a/src/app/projectmanagement/projectmanagement-routing.module.ts b/src/app/projectmanagement/projectmanagement-routing.module.ts index aaf195fa93..3841b8878e 100644 --- a/src/app/projectmanagement/projectmanagement-routing.module.ts +++ b/src/app/projectmanagement/projectmanagement-routing.module.ts @@ -1,29 +1,27 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { OverviewComponent } from './overview.component'; +import { NgModule } from '@angular/core' +import { RouterModule, Routes } from '@angular/router' +import { OverviewComponent } from './overview.component' const routes: Routes = [ { path: '', redirectTo: '/userinfo', - pathMatch: 'full', + pathMatch: 'full' }, { path: ':id', component: OverviewComponent, data: { - title: 'Project Overview', - }, - }, - -]; + title: 'Project Overview' + } + } +] /** * Projectmanagement routing module. */ @NgModule({ imports: [RouterModule.forChild(routes)], - exports: [RouterModule], + exports: [RouterModule] }) -export class ProjectManagementRoutingModule { -} +export class ProjectManagementRoutingModule {} diff --git a/src/app/projectmanagement/projectmanagement.module.ts b/src/app/projectmanagement/projectmanagement.module.ts index 96bd65b697..7a612831d0 100644 --- a/src/app/projectmanagement/projectmanagement.module.ts +++ b/src/app/projectmanagement/projectmanagement.module.ts @@ -1,31 +1,31 @@ -import { NgModule } from '@angular/core'; -import { TabsModule } from 'ngx-bootstrap/tabs'; -import { CommonModule } from '@angular/common'; -import { ModalModule } from 'ngx-bootstrap/modal'; -import { FormsModule } from '@angular/forms'; -import { AccordionModule } from 'ngx-bootstrap/accordion'; -import { NgChartsModule } from 'ng2-charts'; -import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; -import { AlertModule } from 'ngx-bootstrap/alert'; -import { NgSelectModule } from '@ng-select/ng-select'; -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import { BadgeModule } from '@coreui/angular'; -import { ApplicationsModule } from '../applications/applications.module'; -import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module'; -import { ProjectOsDetailsComponent } from './project-os-details/project-os-details.component'; -import { PipeModuleModule } from '../pipe-module/pipe-module.module'; -import { ProjectManagementRoutingModule } from './projectmanagement-routing.module'; -import { OverviewComponent } from './overview.component'; -import { ApplicationProgressComponent } from './application-progress/application-progress.component'; -import { LifetimeRequestComponent } from './modals/lifetime-request/lifetime-request.component'; -import { ModificationRequestComponent } from './modals/modification-request/modification-request.component'; -import { CreditsRequestComponent } from './modals/credits-request/credits-request.component'; -import { ExtensionEntryComponent } from './modals/testimonial/extension-entry.component'; -import { ResultComponent } from './modals/result/result.component'; -import { SharedModuleModule } from '../shared/shared_modules/shared-module.module'; -import { AdjustLifetimeRequestComponent } from './modals/adjust-lifetime/adjust-lifetime-request.component'; -import { AdjustApplicationComponent } from './modals/adjust-application/adjust-application.component'; -import { WithdrawModalComponent } from './modals/withdraw/withdraw-modal.component'; +import { NgModule } from '@angular/core' +import { TabsModule } from 'ngx-bootstrap/tabs' +import { CommonModule } from '@angular/common' +import { ModalModule } from 'ngx-bootstrap/modal' +import { FormsModule } from '@angular/forms' +import { AccordionModule } from 'ngx-bootstrap/accordion' +import { NgChartsModule } from 'ng2-charts' +import { BsDropdownModule } from 'ngx-bootstrap/dropdown' +import { AlertModule } from 'ngx-bootstrap/alert' +import { NgSelectModule } from '@ng-select/ng-select' +import { NgbModule } from '@ng-bootstrap/ng-bootstrap' +import { BadgeModule } from '@coreui/angular' +import { ApplicationsModule } from '../applications/applications.module' +import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module' +import { ProjectOsDetailsComponent } from './project-os-details/project-os-details.component' +import { PipeModuleModule } from '../pipe-module/pipe-module.module' +import { ProjectManagementRoutingModule } from './projectmanagement-routing.module' +import { OverviewComponent } from './overview.component' +import { ApplicationProgressComponent } from './application-progress/application-progress.component' +import { LifetimeRequestComponent } from './modals/lifetime-request/lifetime-request.component' +import { ModificationRequestComponent } from './modals/modification-request/modification-request.component' +import { CreditsRequestComponent } from './modals/credits-request/credits-request.component' +import { ExtensionEntryComponent } from './modals/testimonial/extension-entry.component' +import { ResultComponent } from './modals/result/result.component' +import { SharedModuleModule } from '../shared/shared_modules/shared-module.module' +import { AdjustLifetimeRequestComponent } from './modals/adjust-lifetime/adjust-lifetime-request.component' +import { AdjustApplicationComponent } from './modals/adjust-application/adjust-application.component' +import { WithdrawModalComponent } from './modals/withdraw/withdraw-modal.component' /** * Projectmanagment module. @@ -47,7 +47,7 @@ import { WithdrawModalComponent } from './modals/withdraw/withdraw-modal.compone NgSelectModule, NgbModule, BadgeModule, - SharedModuleModule, + SharedModuleModule ], declarations: [ OverviewComponent, @@ -60,8 +60,8 @@ import { WithdrawModalComponent } from './modals/withdraw/withdraw-modal.compone ExtensionEntryComponent, AdjustLifetimeRequestComponent, AdjustApplicationComponent, - WithdrawModalComponent, + WithdrawModalComponent ], - exports: [ProjectOsDetailsComponent, ExtensionEntryComponent], + exports: [ProjectOsDetailsComponent, ExtensionEntryComponent] }) export class ProjectManagementModule {} diff --git a/src/app/registration-info.component.ts b/src/app/registration-info.component.ts index 6890375dd0..fc94e4c3ff 100644 --- a/src/app/registration-info.component.ts +++ b/src/app/registration-info.component.ts @@ -1,14 +1,13 @@ -import { Component } from '@angular/core'; -import { environment } from '../environments/environment'; +import { Component } from '@angular/core' +import { environment } from '../environments/environment' /** * Registration info class. */ @Component({ selector: 'app-registration-info', - templateUrl: 'registration-info.component.html', - + templateUrl: 'registration-info.component.html' }) export class RegistrationInfoComponent { - voRegistrationLink: string = environment.voRegistrationLink; + voRegistrationLink: string = environment.voRegistrationLink } diff --git a/src/app/shared/aside.directive.ts b/src/app/shared/aside.directive.ts index e00197e189..8e58ca8f9b 100644 --- a/src/app/shared/aside.directive.ts +++ b/src/app/shared/aside.directive.ts @@ -1,15 +1,14 @@ -import { Directive, HostListener } from '@angular/core'; +import { Directive, HostListener } from '@angular/core' /** * Allows the aside to be toggled via click. */ @Directive({ - selector: '[appAsideMenuToggler]', + selector: '[appAsideMenuToggler]' }) export class AsideToggleDirective { - - @HostListener('click', ['$event']) toggleOpen($event: any) { - $event.preventDefault(); - document.querySelector('body').classList.toggle('aside-menu-hidden'); + @HostListener('click', ['$event']) toggleOpen($event: any) { + $event.preventDefault() + document.querySelector('body').classList.toggle('aside-menu-hidden') } } diff --git a/src/app/shared/breadcrumb.component.ts b/src/app/shared/breadcrumb.component.ts index d1fca443d4..eec21e7398 100644 --- a/src/app/shared/breadcrumb.component.ts +++ b/src/app/shared/breadcrumb.component.ts @@ -1,51 +1,57 @@ -import { Component, OnInit } from '@angular/core'; -import { Router, ActivatedRoute, NavigationEnd } from '@angular/router'; +import { Component, OnInit } from '@angular/core' +import { Router, ActivatedRoute, NavigationEnd } from '@angular/router' -import { filter } from 'rxjs/operators'; +import { filter } from 'rxjs/operators' // tslint:disable @Component({ selector: 'app-breadcrumbs', - template: ` - - - `, + template: ` + + ` }) export class BreadcrumbsComponent implements OnInit { - breadcrumbs: object[]; + breadcrumbs: object[] - constructor(private router: Router, private route: ActivatedRoute) { - this.router = router; - this.route = route; + constructor( + private router: Router, + private route: ActivatedRoute + ) { + this.router = router + this.route = route } ngOnInit(): void { - this.router.events.pipe(filter(event => event instanceof NavigationEnd)) - .subscribe(() => { - this.breadcrumbs = []; - let currentRoute = this.route.root; - let url = ''; - do { - const childrenRoutes = currentRoute.children; - currentRoute = null; - // eslint-disable-next-line no-loop-func - childrenRoutes.forEach(route => { - if (route.outlet === 'primary') { - const routeSnapshot = route.snapshot; - url += `/${routeSnapshot.url.map(segment => segment.path).join('/')}`; - this.breadcrumbs.push({ - label: route.snapshot.data, - url, - }); - currentRoute = route; - } - }); - } while (currentRoute); - }); + this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe(() => { + this.breadcrumbs = [] + let currentRoute = this.route.root + let url = '' + do { + const childrenRoutes = currentRoute.children + currentRoute = null + + childrenRoutes.forEach(route => { + if (route.outlet === 'primary') { + const routeSnapshot = route.snapshot + url += `/${routeSnapshot.url.map(segment => segment.path).join('/')}` + this.breadcrumbs.push({ + label: route.snapshot.data, + url + }) + currentRoute = route + } + }) + } while (currentRoute) + }) } } diff --git a/src/app/shared/datepicking/datepicker.component.ts b/src/app/shared/datepicking/datepicker.component.ts index a924506341..6a6ce76fa3 100644 --- a/src/app/shared/datepicking/datepicker.component.ts +++ b/src/app/shared/datepicking/datepicker.component.ts @@ -1,33 +1,31 @@ -import { - Component, EventEmitter, OnInit, Output, -} from '@angular/core'; -import { NgbDateStruct, NgbCalendar, NgbDatepickerModule } from '@ng-bootstrap/ng-bootstrap'; -import { FormsModule } from '@angular/forms'; -import { JsonPipe } from '@angular/common'; +import { Component, EventEmitter, OnInit, Output } from '@angular/core' +import { NgbDateStruct, NgbCalendar, NgbDatepickerModule } from '@ng-bootstrap/ng-bootstrap' +import { FormsModule } from '@angular/forms' +import { JsonPipe } from '@angular/common' @Component({ selector: 'app-datepicker', standalone: true, imports: [NgbDatepickerModule, FormsModule, JsonPipe], - templateUrl: './datepicker.component.html', + templateUrl: './datepicker.component.html' }) export class DatePickerComponent implements OnInit { - model: NgbDateStruct; - date: { year: number; month: number; day: number }; + model: NgbDateStruct + date: { year: number; month: number; day: number } @Output() readonly dayChange: EventEmitter<{ year: number; month: number; day: number }> = new EventEmitter<{ year: number month: number day: number - }>(); + }>() constructor(private calendar: NgbCalendar) { - this.calendar = calendar; + this.calendar = calendar } ngOnInit(): void { - this.selectToday(); + this.selectToday() } selectToday() { - this.model = this.calendar.getToday(); + this.model = this.calendar.getToday() } } diff --git a/src/app/shared/datepicking/timepicker.component.ts b/src/app/shared/datepicking/timepicker.component.ts index eb2f44337a..3226db7c0c 100644 --- a/src/app/shared/datepicking/timepicker.component.ts +++ b/src/app/shared/datepicking/timepicker.component.ts @@ -1,18 +1,18 @@ -import { Component, EventEmitter, Output } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { JsonPipe } from '@angular/common'; -import { NgbTimepickerModule } from '@ng-bootstrap/ng-bootstrap'; +import { Component, EventEmitter, Output } from '@angular/core' +import { FormsModule } from '@angular/forms' +import { JsonPipe } from '@angular/common' +import { NgbTimepickerModule } from '@ng-bootstrap/ng-bootstrap' @Component({ selector: 'app-timepicker', standalone: true, imports: [NgbTimepickerModule, FormsModule, JsonPipe], - templateUrl: './timepicker.component.html', + templateUrl: './timepicker.component.html' }) export class TimepickerComponent { @Output() readonly timeChange: EventEmitter<{ hour: number; minute: number }> = new EventEmitter<{ hour: number minute: number - }>(); - time = { hour: new Date().getHours(), minute: new Date().getMinutes() }; + }>() + time = { hour: new Date().getHours(), minute: new Date().getMinutes() } } diff --git a/src/app/shared/guards/vo-guard.service.ts b/src/app/shared/guards/vo-guard.service.ts index 01cfdf5207..bb676680b3 100644 --- a/src/app/shared/guards/vo-guard.service.ts +++ b/src/app/shared/guards/vo-guard.service.ts @@ -1,15 +1,13 @@ -import { Injectable } from '@angular/core'; -import { - ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree, -} from '@angular/router'; -import { Observable } from 'rxjs'; -import { is_vo } from '../globalvar'; +import { Injectable } from '@angular/core' +import { ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree } from '@angular/router' +import { Observable } from 'rxjs' +import { is_vo } from '../globalvar' /** * Guard which checks if the user is member of the vo. */ @Injectable({ - providedIn: 'root', + providedIn: 'root' }) export class VoGuardService { constructor(private router: Router) {} @@ -18,14 +16,14 @@ export class VoGuardService { // eslint-disable-next-line @typescript-eslint/no-unused-vars next: ActivatedRouteSnapshot, // eslint-disable-next-line @typescript-eslint/no-unused-vars - state: RouterStateSnapshot, + state: RouterStateSnapshot ): Observable | Promise | boolean | UrlTree { if (is_vo) { - return true; + return true } else { - void this.router.navigate(['/userinfo']); + void this.router.navigate(['/userinfo']) - return false; + return false } } } diff --git a/src/app/shared/modal/confirmation-modal.component.ts b/src/app/shared/modal/confirmation-modal.component.ts index 9432f45f7b..56f79a046d 100644 --- a/src/app/shared/modal/confirmation-modal.component.ts +++ b/src/app/shared/modal/confirmation-modal.component.ts @@ -1,30 +1,28 @@ -import { - Component, EventEmitter, OnDestroy, OnInit, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Application } from '../../applications/application.model/application.model'; -import { ConfirmationTypes } from './confirmation_types'; -import { ConfirmationActions } from './confirmation_actions'; +import { Component, EventEmitter, OnDestroy, OnInit } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { Application } from '../../applications/application.model/application.model' +import { ConfirmationTypes } from './confirmation_types' +import { ConfirmationActions } from './confirmation_actions' @Component({ selector: 'app-confirmation-modal', templateUrl: './confirmation-modal.component.html', - providers: [], + providers: [] }) export class ConfirmationModalComponent implements OnDestroy, OnInit { - protected readonly ConfirmationTypes = ConfirmationTypes; + protected readonly ConfirmationTypes = ConfirmationTypes - application: Application = null; - modalTitle: string = ''; - modalMessage: string = ''; - application_center: string = ''; - action: ConfirmationActions; - type: ConfirmationTypes; - request_failed: boolean = false; - public event: EventEmitter = new EventEmitter(); + application: Application = null + modalTitle: string = '' + modalMessage: string = '' + application_center: string = '' + action: ConfirmationActions + type: ConfirmationTypes + request_failed: boolean = false + public event: EventEmitter = new EventEmitter() constructor(public bsModalRef: BsModalRef) { - // eslint-disable-next-line no-empty-function + } confirmAction(): void { @@ -45,137 +43,137 @@ export class ConfirmationModalComponent implements OnDestroy, OnInit { [ConfirmationActions.APPROVE_CREDITS]: { action: ConfirmationActions.APPROVE_CREDITS }, [ConfirmationActions.APPROVE_APPLICATION]: { action: ConfirmationActions.APPROVE_APPLICATION, - selectedCenter: this.application_center, + selectedCenter: this.application_center }, [ConfirmationActions.DISABLE_APPLICATION]: { action: ConfirmationActions.DISABLE_APPLICATION }, - [ConfirmationActions.ENABLE_APPLICATION]: { action: ConfirmationActions.ENABLE_APPLICATION }, - }; + [ConfirmationActions.ENABLE_APPLICATION]: { action: ConfirmationActions.ENABLE_APPLICATION } + } - const selectedAction = actionsMap[this.action]; + const selectedAction = actionsMap[this.action] if (selectedAction) { this.event.emit({ ...selectedAction, - application: this.application, - }); + application: this.application + }) } else { - this.request_failed = true; + this.request_failed = true } } sendClosed(): void { this.event.emit({ - closed: true, - }); + closed: true + }) } buttonText(): string { switch (this.type) { case ConfirmationTypes.ENABLE: - return 'Enabling'; + return 'Enabling' case ConfirmationTypes.DISABLE: - return 'Disabling'; + return 'Disabling' case ConfirmationTypes.APPROVE: - return 'Approval'; + return 'Approval' case ConfirmationTypes.DELETE: - return 'Deletion'; + return 'Deletion' case ConfirmationTypes.DECLINE: - return 'Declination'; + return 'Declination' case ConfirmationTypes.RESET_PI: - return 'Reset PI'; + return 'Reset PI' default: - break; + break } - return ''; + return '' } ngOnInit() { - this.request_failed = false; + this.request_failed = false const confirmationData = { [ConfirmationActions.DECLINE_MODIFICATION]: { title: 'Confirm decline of modification request', type: ConfirmationTypes.DECLINE, - message: 'Do you really want to decline the modification request', + message: 'Do you really want to decline the modification request' }, [ConfirmationActions.DELETE_APPLICATION]: { title: 'Confirm deletion of application', type: ConfirmationTypes.DECLINE, - message: 'Do you really want to delete the application?', + message: 'Do you really want to delete the application?' }, [ConfirmationActions.DECLINE_APPLICATION]: { title: 'Confirm decline of project application', type: ConfirmationTypes.DECLINE, - message: 'Do you really want to decline the project application', + message: 'Do you really want to decline the project application' }, [ConfirmationActions.DECLINE_EXTENSION]: { title: 'Confirm decline of extension request', type: ConfirmationTypes.DECLINE, - message: 'Do you really want to decline the extension request', + message: 'Do you really want to decline the extension request' }, [ConfirmationActions.DECLINE_CREDITS]: { title: 'Confirm decline of credit request', type: ConfirmationTypes.DECLINE, - message: 'Do you really want to decline the credit request', + message: 'Do you really want to decline the credit request' }, [ConfirmationActions.APPROVE_APPLICATION]: { title: 'Confirm approval of application', type: ConfirmationTypes.APPROVE, - message: 'Do you really want to approve the application', + message: 'Do you really want to approve the application' }, [ConfirmationActions.APPROVE_MODIFICATION]: { title: 'Confirm approval of modification request', type: ConfirmationTypes.APPROVE, - message: 'Do you really want to approve the modification request', + message: 'Do you really want to approve the modification request' }, [ConfirmationActions.APPROVE_EXTENSION]: { title: 'Confirm the approval of the extension request', type: ConfirmationTypes.APPROVE, - message: 'Do you really want to approve the extension request', + message: 'Do you really want to approve the extension request' }, [ConfirmationActions.APPROVE_CREDITS]: { title: 'Confirm approval of credits request', type: ConfirmationTypes.APPROVE, - message: 'Do you really want to decline the credit request', + message: 'Do you really want to decline the credit request' }, [ConfirmationActions.DISABLE_APPLICATION]: { title: 'Confirm disabling of application', type: ConfirmationTypes.DISABLE, - message: 'Do you really want to disable the application', + message: 'Do you really want to disable the application' }, [ConfirmationActions.ENABLE_APPLICATION]: { title: 'Confirm enabling of application', type: ConfirmationTypes.ENABLE, - message: 'Do you really want to enable the application', + message: 'Do you really want to enable the application' }, [ConfirmationActions.RESET_PI]: { title: 'Confirm reset pi', type: ConfirmationTypes.RESET_PI, - message: 'Do you really want to reset the PI', + message: 'Do you really want to reset the PI' }, [ConfirmationActions.APPROVE_TERMINATION]: { title: 'Approve Termination', type: ConfirmationTypes.APPROVE, - message: 'Do you really want to terminate this project', + message: 'Do you really want to terminate this project' }, [ConfirmationActions.DECLINE_TERMINATION]: { title: 'Decline Termination', type: ConfirmationTypes.DECLINE, - message: 'Do you really want to decline the termination of this project', - }, - }; + message: 'Do you really want to decline the termination of this project' + } + } - const data = confirmationData[this.action]; + const data = confirmationData[this.action] if (data) { - this.modalTitle = data.title; - this.type = data.type; - this.modalMessage = data.message; + this.modalTitle = data.title + this.type = data.type + this.modalMessage = data.message } } ngOnDestroy(): void { - this.bsModalRef.hide(); + this.bsModalRef.hide() } } diff --git a/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component.ts b/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component.ts index aa5c04b137..376e5addd5 100644 --- a/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component.ts +++ b/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component.ts @@ -1,71 +1,69 @@ -import { - Component, EventEmitter, OnDestroy, OnInit, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Application } from '../../../../applications/application.model/application.model'; -import { EmailService } from '../../../../api-connector/email.service'; -import { STATUS_LINK } from '../../../../../links/links'; -import { CsvMailTemplateModel } from '../../../classes/csvMailTemplate.model'; -import { NotificationModalComponent } from '../../notification-modal'; +import { Component, EventEmitter, OnDestroy, OnInit } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { Application } from '../../../../applications/application.model/application.model' +import { EmailService } from '../../../../api-connector/email.service' +import { STATUS_LINK } from '../../../../../links/links' +import { CsvMailTemplateModel } from '../../../classes/csvMailTemplate.model' +import { NotificationModalComponent } from '../../notification-modal' @Component({ selector: 'app-project-csv-templated-email-modal', templateUrl: './project-csv-templated-email-modal.component.html', styleUrls: ['./project-csv-templated-email.scss'], - providers: [EmailService], + providers: [EmailService] }) export class ProjectCsvTemplatedEmailModalComponent implements OnInit, OnDestroy { - csvMailTemplate: CsvMailTemplateModel; - csvFile: File; + csvMailTemplate: CsvMailTemplateModel + csvFile: File - emailAdminsOnly: boolean; - emailSubject: string; - emailReply: string; - emailText: string; - templates: string[]; + emailAdminsOnly: boolean + emailSubject: string + emailReply: string + emailText: string + templates: string[] validCSVExample = `Project, VM, LOCATION Proj1, VM_1, Bielefeld -Proj2, VM_2, Giessen`; +Proj2, VM_2, Giessen` - public event: EventEmitter = new EventEmitter(); + public event: EventEmitter = new EventEmitter() constructor( public bsModalRef: BsModalRef, private emailService: EmailService, - private notificationModal: NotificationModalComponent, + private notificationModal: NotificationModalComponent ) { - // eslint-disable-next-line no-empty-function + } ngOnInit() { - this.getMailTemplates(); + this.getMailTemplates() } onCsvFileSelected(event): void { - const inputElement = event.target as HTMLInputElement; - this.csvFile = inputElement.files[0]; + const inputElement = event.target as HTMLInputElement + this.csvFile = inputElement.files[0] if (this.csvFile) { this.emailService.sendCsvTemplate(this.csvFile).subscribe( (csvTemplate: CsvMailTemplateModel) => { - this.csvMailTemplate = csvTemplate; + this.csvMailTemplate = csvTemplate }, (error: CsvMailTemplateModel) => { - this.csvMailTemplate = error; - console.log(error['error']); - }, - ); + this.csvMailTemplate = error + console.log(error['error']) + } + ) } } getMailTemplates(): void { this.emailService.getMailTemplates().subscribe((res: string[]) => { - this.templates = res; - }); + this.templates = res + }) } sentProjectsTemplatedMail(): void { - const project_ids = this.csvMailTemplate.valid_projects.map((pr: Application) => pr.project_application_perun_id); - this.notificationModal.showInfoNotificationModal('Info', 'Sending Mails...'); + const project_ids = this.csvMailTemplate.valid_projects.map((pr: Application) => pr.project_application_perun_id) + this.notificationModal.showInfoNotificationModal('Info', 'Sending Mails...') this.emailService .sendCsvTemplatedMail( @@ -74,21 +72,21 @@ Proj2, VM_2, Giessen`; this.emailSubject, this.emailText, this.emailAdminsOnly, - this.emailReply, + this.emailReply ) .subscribe( () => { - this.notificationModal.showSuccessFullNotificationModal('Success', 'Mails were successfully sent!'); + this.notificationModal.showSuccessFullNotificationModal('Success', 'Mails were successfully sent!') }, () => { - this.notificationModal.showDangerNotificationModal('Failed', 'Failed to send mails!'); - }, - ); + this.notificationModal.showDangerNotificationModal('Failed', 'Failed to send mails!') + } + ) } ngOnDestroy(): void { - this.bsModalRef.hide(); + this.bsModalRef.hide() } - protected readonly STATUS_LINK = STATUS_LINK; + protected readonly STATUS_LINK = STATUS_LINK } diff --git a/src/app/shared/modal/email/project-email-modal/project-email-modal.component.ts b/src/app/shared/modal/email/project-email-modal/project-email-modal.component.ts index aa9e6ce5d6..1d03b9c507 100644 --- a/src/app/shared/modal/email/project-email-modal/project-email-modal.component.ts +++ b/src/app/shared/modal/email/project-email-modal/project-email-modal.component.ts @@ -1,66 +1,64 @@ -import { - Component, EventEmitter, Input, OnDestroy, OnInit, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Application } from '../../../../applications/application.model/application.model'; -import { EmailService } from '../../../../api-connector/email.service'; -import { STATUS_LINK } from '../../../../../links/links'; -import { NotificationModalComponent } from '../../notification-modal'; +import { Component, EventEmitter, Input, OnDestroy, OnInit } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { Application } from '../../../../applications/application.model/application.model' +import { EmailService } from '../../../../api-connector/email.service' +import { STATUS_LINK } from '../../../../../links/links' +import { NotificationModalComponent } from '../../notification-modal' @Component({ selector: 'app-project-email-modal', templateUrl: './project-email-modal.component.html', styleUrls: ['./projext-email-modal.component.scss'], - providers: [EmailService], + providers: [EmailService] }) export class ProjectEmailModalComponent implements OnInit, OnDestroy { - @Input() selectedProjects: Application[]; + @Input() selectedProjects: Application[] - emailAdminsOnly: boolean; - emailSubject: string; - emailReply: string; - emailText: string; - templates: string[]; + emailAdminsOnly: boolean + emailSubject: string + emailReply: string + emailText: string + templates: string[] - public event: EventEmitter = new EventEmitter(); + public event: EventEmitter = new EventEmitter() constructor( public bsModalRef: BsModalRef, private emailService: EmailService, - private notificationModal: NotificationModalComponent, + private notificationModal: NotificationModalComponent ) { - // eslint-disable-next-line no-empty-function + } ngOnInit() { - this.getMailTemplates(); + this.getMailTemplates() } getMailTemplates(): void { this.emailService.getMailTemplates().subscribe((res: string[]) => { - this.templates = res; - }); + this.templates = res + }) } sentProjectsMail(): void { - const project_ids = this.selectedProjects.map((pr: Application) => pr.project_application_perun_id); - this.notificationModal.showInfoNotificationModal('Info', 'Sending Mails...'); + const project_ids = this.selectedProjects.map((pr: Application) => pr.project_application_perun_id) + this.notificationModal.showInfoNotificationModal('Info', 'Sending Mails...') this.emailService .sendMailToProjects(project_ids, this.emailSubject, this.emailText, this.emailAdminsOnly, this.emailReply) .subscribe( () => { - this.notificationModal.showSuccessFullNotificationModal('Success', 'Mails were successfully sent'); + this.notificationModal.showSuccessFullNotificationModal('Success', 'Mails were successfully sent') }, () => { - this.notificationModal.showSuccessFullNotificationModal('Failed', 'Failed to send mails!'); - }, - ); + this.notificationModal.showSuccessFullNotificationModal('Failed', 'Failed to send mails!') + } + ) } ngOnDestroy(): void { - this.bsModalRef.hide(); + this.bsModalRef.hide() } - protected readonly STATUS_LINK = STATUS_LINK; + protected readonly STATUS_LINK = STATUS_LINK } diff --git a/src/app/shared/modal/members/members-list-modal.component.ts b/src/app/shared/modal/members/members-list-modal.component.ts index 7b5caefd03..c6441fea1e 100644 --- a/src/app/shared/modal/members/members-list-modal.component.ts +++ b/src/app/shared/modal/members/members-list-modal.component.ts @@ -1,47 +1,45 @@ -import { - Component, Input, OnDestroy, OnInit, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; +import { Component, Input, OnDestroy, OnInit } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' -import { ProjectMember } from '../../../projectmanagement/project_member.model'; -import { VoService } from '../../../api-connector/vo.service'; -import { is_vo } from '../../globalvar'; -import { FacilityService } from '../../../api-connector/facility.service'; +import { ProjectMember } from '../../../projectmanagement/project_member.model' +import { VoService } from '../../../api-connector/vo.service' +import { is_vo } from '../../globalvar' +import { FacilityService } from '../../../api-connector/facility.service' @Component({ selector: 'app-project-members-list', - templateUrl: './members-list-modal.component.html', + templateUrl: './members-list-modal.component.html' }) export class MembersListModalComponent implements OnDestroy, OnInit { // currently only for vo - members: ProjectMember[] = []; - @Input() projectId: string | number; - @Input() projectName: string; - @Input() facilityId: string | number; + members: ProjectMember[] = [] + @Input() projectId: string | number + @Input() projectName: string + @Input() facilityId: string | number constructor( public bsModalRef: BsModalRef, private voService: VoService, - private facilityService: FacilityService, + private facilityService: FacilityService ) { - // eslint-disable-next-line no-empty-function + } ngOnInit() { if (is_vo) { this.voService.getVoGroupRichMembers(this.projectId).subscribe((members: ProjectMember[]): void => { - this.members = members; - }); + this.members = members + }) } else if (this.facilityId) { this.facilityService .getFacilityGroupRichMembers(this.projectId, this.facilityId) .subscribe((members: ProjectMember[]): void => { - this.members = members; - }); + this.members = members + }) } } ngOnDestroy(): void { - this.bsModalRef.hide(); + this.bsModalRef.hide() } } diff --git a/src/app/shared/modal/notification-modal.ts b/src/app/shared/modal/notification-modal.ts index a9932f23fe..9afee99ce3 100644 --- a/src/app/shared/modal/notification-modal.ts +++ b/src/app/shared/modal/notification-modal.ts @@ -1,82 +1,82 @@ -import { Component, Injectable, OnDestroy } from '@angular/core'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { Router } from '@angular/router'; +import { Component, Injectable, OnDestroy } from '@angular/core' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { Router } from '@angular/router' @Injectable({ providedIn: 'root' }) @Component({ selector: 'app-notification-modal', - templateUrl: './notification-modal.component.html', + templateUrl: './notification-modal.component.html' }) export class NotificationModalComponent implements OnDestroy { - notificationModalTitle: string; - notificationModalType: string; - notificationModalMessage: string; - routerRedirectString: string; - modalId: number | string | undefined; + notificationModalTitle: string + notificationModalType: string + notificationModalMessage: string + routerRedirectString: string + modalId: number | string | undefined hide(): void { - this.modalService.hide(this.modalId); + this.modalService.hide(this.modalId) } constructor( private router: Router, - private modalService: BsModalService, + private modalService: BsModalService ) { - // eslint-disable-next-line no-empty-function + } showNotificationModal( notificationModalTitle: string, notificationModalMessage: string, notificationModalType: string, - routerRedirectString?: string, + routerRedirectString?: string ): void { const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage, - routerRedirectString, - }; - const bsModalRef: BsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); - bsModalRef.setClass('modal-lg'); - this.modalId = bsModalRef.id; + routerRedirectString + } + const bsModalRef: BsModalRef = this.modalService.show(NotificationModalComponent, { initialState }) + bsModalRef.setClass('modal-lg') + this.modalId = bsModalRef.id } showSuccessFullNotificationModal( notificationModalTitle: string, notificationModalMessage: string, - routerRedirectString?: string, + routerRedirectString?: string ): void { - this.showNotificationModal(notificationModalTitle, notificationModalMessage, 'success', routerRedirectString); + this.showNotificationModal(notificationModalTitle, notificationModalMessage, 'success', routerRedirectString) } showDangerNotificationModal( notificationModalTitle: string, notificationModalMessage: string, - routerRedirectString?: string, + routerRedirectString?: string ): void { - this.showNotificationModal(notificationModalTitle, notificationModalMessage, 'danger', routerRedirectString); + this.showNotificationModal(notificationModalTitle, notificationModalMessage, 'danger', routerRedirectString) } showWarningNotificationModal( notificationModalTitle: string, notificationModalMessage: string, - routerRedirectString?: string, + routerRedirectString?: string ): void { - this.showNotificationModal(notificationModalTitle, notificationModalMessage, 'warning', routerRedirectString); + this.showNotificationModal(notificationModalTitle, notificationModalMessage, 'warning', routerRedirectString) } showInfoNotificationModal( notificationModalTitle: string, notificationModalMessage: string, - routerRedirectString?: string, + routerRedirectString?: string ): void { - this.showNotificationModal(notificationModalTitle, notificationModalMessage, 'info', routerRedirectString); + this.showNotificationModal(notificationModalTitle, notificationModalMessage, 'info', routerRedirectString) } ngOnDestroy(): void { if (this.routerRedirectString) { - void this.router.navigateByUrl(this.routerRedirectString); + void this.router.navigateByUrl(this.routerRedirectString) } } } diff --git a/src/app/shared/shared_modules/baseClass/abstract-base-class.ts b/src/app/shared/shared_modules/baseClass/abstract-base-class.ts index e93b68d24d..21cb1a8742 100644 --- a/src/app/shared/shared_modules/baseClass/abstract-base-class.ts +++ b/src/app/shared/shared_modules/baseClass/abstract-base-class.ts @@ -1,4 +1,4 @@ -/* eslint-disable */ + enum Lifetime_States { EXPIRED = 0, @@ -83,8 +83,7 @@ enum Vm_Statuses { RESTARTING = 6, 'NOT FOUND' = 7, } - -/* eslint-enable */ + /** * Abstract class for basic things. @@ -95,50 +94,50 @@ export abstract class AbstractBaseClass { * * @type {boolean} */ - isLoaded: boolean = false; + isLoaded: boolean = false /** * If the user is a vo admin. * * @type {boolean} */ - is_vo_admin: boolean = false; + is_vo_admin: boolean = false - lifetime_states: typeof Lifetime_States = Lifetime_States; - project_states: typeof Project_States = Project_States; - application_states: typeof Application_States = Application_States; - vm_statuses: typeof Vm_Statuses = Vm_Statuses; + lifetime_states: typeof Lifetime_States = Lifetime_States + project_states: typeof Project_States = Project_States + application_states: typeof Application_States = Application_States + vm_statuses: typeof Vm_Statuses = Vm_Statuses - collapse_status: { [id: string]: boolean } = {}; + collapse_status: { [id: string]: boolean } = {} /** * Used in application formular and on instance detail page */ gpuInformationLinks: [string, string][] = [ ['https://developer.nvidia.com/cuda-gpus', 'NVIDIA'], - ['https://en.wikipedia.org/wiki/CUDA', 'Wikipedia'], - ]; + ['https://en.wikipedia.org/wiki/CUDA', 'Wikipedia'] + ] // notification Modal variables - public notificationModalTitle: string = 'Notification'; - public notificationModalMessage: string = 'Please wait...'; - public notificationModalType: string = 'info'; - public notificationModalInfoMessage: string = ''; - public notificationModalIsClosable: boolean = false; - public notificationModalStay: boolean; + public notificationModalTitle: string = 'Notification' + public notificationModalMessage: string = 'Please wait...' + public notificationModalType: string = 'info' + public notificationModalInfoMessage: string = '' + public notificationModalIsClosable: boolean = false + public notificationModalStay: boolean public resetNotificationModal(): void { - this.notificationModalTitle = 'Notification'; - this.notificationModalMessage = 'Please wait...'; - this.notificationModalIsClosable = false; - this.notificationModalType = 'info'; + this.notificationModalTitle = 'Notification' + this.notificationModalMessage = 'Please wait...' + this.notificationModalIsClosable = false + this.notificationModalType = 'info' } public updateNotificationModal(title: string, message: string, closable: true, type: string): void { - this.notificationModalTitle = title; - this.notificationModalMessage = message; - this.notificationModalIsClosable = closable; - this.notificationModalType = type; + this.notificationModalTitle = title + this.notificationModalMessage = message + this.notificationModalIsClosable = closable + this.notificationModalType = type } /** @@ -149,16 +148,16 @@ export abstract class AbstractBaseClass { */ public getCollapseStatus(id: string): boolean { if (id in this.collapse_status) { - return this.collapse_status[id]; + return this.collapse_status[id] } else { - this.collapse_status[id] = true; + this.collapse_status[id] = true - return true; + return true } } public setCollapseStatus(id: string, status: boolean): void { - this.collapse_status[id] = status; + this.collapse_status[id] = status } /** @@ -167,36 +166,36 @@ export abstract class AbstractBaseClass { * @param id */ public switchCollapseStatus(id: string): void { - this.collapse_status[id] = !this.getCollapseStatus(id); + this.collapse_status[id] = !this.getCollapseStatus(id) } lifeTimeReached(lifetimeDays: number, running: number): Lifetime_States { if (!lifetimeDays || !running) { - return null; + return null } if (lifetimeDays - running < 0) { // expired - return this.lifetime_states.EXPIRED; + return this.lifetime_states.EXPIRED } else if (lifetimeDays - running < 21) { // expires soon - return this.lifetime_states.EXPIRES_SOON; + return this.lifetime_states.EXPIRES_SOON } else { // still valid - return this.lifetime_states.VALID_LIFETIME; + return this.lifetime_states.VALID_LIFETIME } } copyToClipboard(text: string): void { document.addEventListener('copy', (clipEvent: ClipboardEvent): void => { - clipEvent.clipboardData.setData('text/plain', text); - clipEvent.preventDefault(); - document.removeEventListener('copy', null); - }); - document.execCommand('copy'); + clipEvent.clipboardData.setData('text/plain', text) + clipEvent.preventDefault() + document.removeEventListener('copy', null) + }) + document.execCommand('copy') } isASCII(testString: string): boolean { // eslint-disable-next-line no-control-regex - return /^[\x00-\x7F]*$/.test(testString); + return /^[\x00-\x7F]*$/.test(testString) } } diff --git a/src/app/shared/shared_modules/baseClass/application-base-class.component.ts b/src/app/shared/shared_modules/baseClass/application-base-class.component.ts index d7d868746c..5d2fb67cfe 100644 --- a/src/app/shared/shared_modules/baseClass/application-base-class.component.ts +++ b/src/app/shared/shared_modules/baseClass/application-base-class.component.ts @@ -1,15 +1,15 @@ -import { ChangeDetectorRef, Component } from '@angular/core'; -import { AbstractBaseClass, Application_States, Application_States_Strings } from './abstract-base-class'; -import { Application } from '../../../applications/application.model/application.model'; -import { Flavor } from '../../../virtualmachines/virtualmachinemodels/flavor'; -import { ApplicationsService } from '../../../api-connector/applications.service'; -import { ComputecenterComponent } from '../../../projectmanagement/computecenter.component'; -import { FlavorType } from '../../../virtualmachines/virtualmachinemodels/flavorType'; -import { FlavorService } from '../../../api-connector/flavor.service'; -import { FacilityService } from '../../../api-connector/facility.service'; -import { UserService } from '../../../api-connector/user.service'; -import { FlavorTypeShortcuts } from './flavor-type-shortcuts'; -import { User } from '../../../applications/application.model/user.model'; +import { ChangeDetectorRef, Component } from '@angular/core' +import { AbstractBaseClass, Application_States, Application_States_Strings } from './abstract-base-class' +import { Application } from '../../../applications/application.model/application.model' +import { Flavor } from '../../../virtualmachines/virtualmachinemodels/flavor' +import { ApplicationsService } from '../../../api-connector/applications.service' +import { ComputecenterComponent } from '../../../projectmanagement/computecenter.component' +import { FlavorType } from '../../../virtualmachines/virtualmachinemodels/flavorType' +import { FlavorService } from '../../../api-connector/flavor.service' +import { FacilityService } from '../../../api-connector/facility.service' +import { UserService } from '../../../api-connector/user.service' +import { FlavorTypeShortcuts } from './flavor-type-shortcuts' +import { User } from '../../../applications/application.model/user.model' /** * Application base component.. @@ -17,7 +17,7 @@ import { User } from '../../../applications/application.model/user.model'; @Component({ selector: 'app-base', template: '', - providers: [FacilityService, ApplicationsService, FlavorService], + providers: [FacilityService, ApplicationsService, FlavorService] }) export class ApplicationBaseClassComponent extends AbstractBaseClass { /** @@ -25,103 +25,103 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * * @type {boolean} */ - isLoaded: boolean = false; - FlavorTypeShortcuts: typeof FlavorTypeShortcuts = FlavorTypeShortcuts; + isLoaded: boolean = false + FlavorTypeShortcuts: typeof FlavorTypeShortcuts = FlavorTypeShortcuts /** * Selected Application. */ - selectedApplication: Application; + selectedApplication: Application /** * All available compute centers. * * @type {Array} */ - computeCenters: ComputecenterComponent[] = []; + computeCenters: ComputecenterComponent[] = [] /** * List of flavor types. */ - typeList: FlavorType[]; + typeList: FlavorType[] /** * Total number of cores. * * @type {number} */ - totalNumberOfCores: number = 0; + totalNumberOfCores: number = 0 /** * Total number of ram. * * @type {number} */ - totalRAM: number = 0; + totalRAM: number = 0 /** * Total number of GPUs */ - totalGPU: number = 0; + totalGPU: number = 0 newFlavors: { [id: string]: { counter: number flavor: Flavor } - } = {}; + } = {} - GPU_SHORTCUT = 'GPU'; - HMF_SHORTCUT = 'HMF'; + GPU_SHORTCUT = 'GPU' + HMF_SHORTCUT = 'HMF' - extension_request: boolean = false; + extension_request: boolean = false /** * If shortname is valid. * * @type {boolean} */ - public wronginput: boolean = false; + public wronginput: boolean = false /** * */ - constantStrings: object; + constantStrings: object /** * List of flavors. */ - flavorList: Flavor[] = []; - extraResourceCommentRequired: boolean = false; + flavorList: Flavor[] = [] + extraResourceCommentRequired: boolean = false /** * If all userApplications are loaded, important for the loader. * * @type {boolean} */ - isLoaded_userApplication: boolean = false; + isLoaded_userApplication: boolean = false - public project_application_pi_approved: boolean = false; + public project_application_pi_approved: boolean = false /** * Name of the project. */ - public projectName: string; + public projectName: string - public project_application_report_allowed: boolean = false; + public project_application_report_allowed: boolean = false /** * Applications of the user viewing the Application overview. * * @type {Array} */ - user_applications: Application[] = []; + user_applications: Application[] = [] constructor( protected userService: UserService, protected applicationsService: ApplicationsService, protected facilityService: FacilityService, - private cdRef: ChangeDetectorRef, + private cdRef: ChangeDetectorRef ) { - super(); + super() } /** @@ -135,88 +135,88 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { cc['compute_center_name'], cc['compute_center_login'], cc['compute_center_support_mail'], - cc['compute_center_client'], - ); - this.computeCenters.push(compute_center); + cc['compute_center_client'] + ) + this.computeCenters.push(compute_center) } - }); + }) } // eslint-disable-next-line @typescript-eslint/no-unused-vars valuesChanged(flavor: Flavor, counter: number, lifetime?: string): void { if (this.newFlavors[flavor.name]) { if (counter === 0 || counter === null) { - delete this.newFlavors[flavor.name]; + delete this.newFlavors[flavor.name] } } if (counter > 0) { - this.newFlavors[flavor.name] = { counter, flavor }; + this.newFlavors[flavor.name] = { counter, flavor } } - this.calculateRamCores(); - this.checkExtraResourceCommentRequired(); + this.calculateRamCores() + this.checkExtraResourceCommentRequired() } checkExtraResourceCommentRequired(): void { for (const extensionFlavorsKey in this.newFlavors) { - const entry: { counter: number; flavor: Flavor } = this.newFlavors[extensionFlavorsKey]; + const entry: { counter: number; flavor: Flavor } = this.newFlavors[extensionFlavorsKey] if ( - (entry?.flavor?.type?.shortcut.toUpperCase() === this.GPU_SHORTCUT - || entry?.flavor?.type?.shortcut.toUpperCase() === this.HMF_SHORTCUT) - && entry.counter > 0 + (entry?.flavor?.type?.shortcut.toUpperCase() === this.GPU_SHORTCUT || + entry?.flavor?.type?.shortcut.toUpperCase() === this.HMF_SHORTCUT) && + entry.counter > 0 ) { - this.extraResourceCommentRequired = true; - this.cdRef.detectChanges(); + this.extraResourceCommentRequired = true + this.cdRef.detectChanges() - return; + return } } - this.extraResourceCommentRequired = false; - this.cdRef.detectChanges(); + this.extraResourceCommentRequired = false + this.cdRef.detectChanges() } getApplicationPi(application: Application) { if (!application.project_application_pi) { this.applicationsService.getApplicationPI(application.project_application_id).subscribe((pi: User) => { - application.project_application_pi = pi; - }); + application.project_application_pi = pi + }) } } getApplicationUser(application: Application) { if (!application.project_application_user) { this.applicationsService.getApplicationUser(application.project_application_id).subscribe((user: User) => { - application.project_application_user = user; - }); + application.project_application_user = user + }) } } getExtensionUser(application: Application) { if (application.project_lifetime_request && !application.project_lifetime_request.user) { this.applicationsService.getLifetimeExtensionUser(application.project_application_id).subscribe((user: User) => { - application.project_lifetime_request.user = user; - }); + application.project_lifetime_request.user = user + }) } } getModificationUser(application: Application) { if (application.project_modification_request && !application.project_modification_request.user) { this.applicationsService.getLifetimeExtensionUser(application.project_application_id).subscribe((user: User) => { - application.project_modification_request.user = user; - }); + application.project_modification_request.user = user + }) } } calculateRamCores(): void { - this.totalNumberOfCores = 0; - this.totalRAM = 0; - this.totalGPU = 0; + this.totalNumberOfCores = 0 + this.totalRAM = 0 + this.totalGPU = 0 // tslint:disable-next-line:forin for (const extensionFlavorsKey in this.newFlavors) { - const fl: any = this.newFlavors[extensionFlavorsKey]; - this.totalRAM += fl.flavor.ram_gib * fl.counter; - this.totalNumberOfCores += fl.flavor.vcpus * fl.counter; - this.totalGPU += fl.flavor.gpu * fl.counter; + const fl: any = this.newFlavors[extensionFlavorsKey] + this.totalRAM += fl.flavor.ram_gib * fl.counter + this.totalNumberOfCores += fl.flavor.vcpus * fl.counter + this.totalGPU += fl.flavor.gpu * fl.counter } } @@ -228,21 +228,21 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { */ public getMemberDetailsByElixirIdIfCollapsed(application: Application, collapse_id: string): void { if (!this.getCollapseStatus(collapse_id)) { - this.getMemberDetailsByElixirId(application); + this.getMemberDetailsByElixirId(application) } } public getMemberDetailsByElixirId(application: Application): void { if (!application.project_application_user) { - return; + return } this.userService .getMemberDetailsByElixirId(application.project_application_user.elixir_id) .subscribe((result: { [key: string]: string }): void => { - application.project_application_user.username = `${result['firstName']} ${result['lastName']}`; + application.project_application_user.username = `${result['firstName']} ${result['lastName']}` - application.project_application_user.email = result['email']; - }); + application.project_application_user.email = result['email'] + }) } /** @@ -252,12 +252,12 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * @returns */ public getStatusById(id: number): string { - const dummy: string = 'Unknown'; + const dummy: string = 'Unknown' if (Application_States_Strings[Application_States[id]]) { - return Application_States_Strings[Application_States[id]]; + return Application_States_Strings[Application_States[id]] } - return dummy; + return dummy } /** @@ -266,7 +266,7 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * @param application */ setSelectedApplication(application: Application): void { - this.selectedApplication = application; + this.selectedApplication = application } /** @@ -276,20 +276,20 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * @param types array of all available FlavorTypes */ setListOfTypes(types: FlavorType[]): void { - let index: number = -1; + let index: number = -1 for (let i: number = 0; i < types.length; i += 1) { if (types[i].shortcut === 'std') { - index = i; - break; + index = i + break } } if (index !== -1) { - const spliced: FlavorType[] = types.splice(index, 1); - types.unshift(spliced[0]); + const spliced: FlavorType[] = types.splice(index, 1) + types.unshift(spliced[0]) } - this.typeList = types; + this.typeList = types } /** @@ -298,41 +298,42 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * @param shortname */ public checkShortname(shortname: string): void { - this.wronginput = !/^[a-zA-Z0-9\s]*$/.test(shortname); + this.wronginput = !/^[a-zA-Z0-9\s]*$/.test(shortname) } /** * Fills the array constantStrings with values dependent of keys which are used to indicate inputs from the application-form */ generateConstants(): void { - this.constantStrings = []; - this.constantStrings['project_application_shortname'] = 'Shortname: '; - this.constantStrings['project_application_description'] = 'Description: '; - this.constantStrings['project_application_comment'] = 'Comment: '; - this.constantStrings['project_application_pi_email'] = 'Principal Investigator Email: '; - this.constantStrings['project_application_bmbf_project'] = 'BMBF Project: '; - - this.constantStrings['project_application_lifetime'] = 'Lifetime of your project: '; - this.constantStrings['project_application_volume_counter'] = 'Number of volumes for additional storage: '; - this.constantStrings['project_application_object_storage'] = 'Object storage: '; - this.constantStrings['project_application_volume_limit'] = 'Volume Storage space for your VMs: '; - this.constantStrings['project_application_comment'] = 'Comment: '; - this.constantStrings['project_application_renewal_comment'] = 'Comment: '; - - this.constantStrings['project_application_renewal_lifetime'] = 'Lifetime of your project: '; - this.constantStrings['project_application_renewal_volume_counter'] = 'Number of volumes for additional storage: '; - this.constantStrings['project_application_renewal_object_storage'] = 'Object storage: '; - this.constantStrings['project_application_renewal_volume_limit'] = 'Volume Storage space for your VMs: '; - this.constantStrings['project_application_institute'] = 'Your institute: '; - this.constantStrings['project_application_workgroup'] = 'Your Workgroup: '; - this.constantStrings['project_application_horizon2020'] = 'Horizon2020: '; - this.constantStrings['project_application_elixir_project'] = 'Elixir Project: '; - - this.constantStrings['project_application_report_allowed'] = 'Dissemination allowed: '; + this.constantStrings = [] + this.constantStrings['project_application_shortname'] = 'Shortname: ' + this.constantStrings['project_application_description'] = 'Description: ' + this.constantStrings['project_application_comment'] = 'Comment: ' + this.constantStrings['project_application_pi_email'] = 'Principal Investigator Email: ' + this.constantStrings['project_application_bmbf_project'] = 'BMBF Project: ' + + this.constantStrings['project_application_lifetime'] = 'Lifetime of your project: ' + this.constantStrings['project_application_volume_counter'] = 'Number of volumes for additional storage: ' + this.constantStrings['project_application_object_storage'] = 'Object storage: ' + this.constantStrings['project_application_volume_limit'] = 'Volume Storage space for your VMs: ' + this.constantStrings['project_application_comment'] = 'Comment: ' + this.constantStrings['project_application_renewal_comment'] = 'Comment: ' + + this.constantStrings['project_application_renewal_lifetime'] = 'Lifetime of your project: ' + this.constantStrings['project_application_renewal_volume_counter'] = 'Number of volumes for additional storage: ' + this.constantStrings['project_application_renewal_object_storage'] = 'Object storage: ' + this.constantStrings['project_application_renewal_volume_limit'] = 'Volume Storage space for your VMs: ' + this.constantStrings['project_application_institute'] = 'Your institute: ' + this.constantStrings['project_application_workgroup'] = 'Your Workgroup: ' + this.constantStrings['project_application_horizon2020'] = 'Horizon2020: ' + this.constantStrings['project_application_elixir_project'] = 'Elixir Project: ' + + this.constantStrings['project_application_report_allowed'] = 'Dissemination allowed: ' for (const key in this.flavorList) { if (key in this.flavorList) { - this.constantStrings[`project_application_${this.flavorList[key].name}`] = `Number of VMs of type ${this.flavorList[key].name}: `; + this.constantStrings[`project_application_${this.flavorList[key].name}`] = + `Number of VMs of type ${this.flavorList[key].name}: ` } } } @@ -349,27 +350,27 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { if (key in this.constantStrings) { switch (key) { case 'project_application_lifetime': { - return `${this.constantStrings[key]}${val} months`; + return `${this.constantStrings[key]}${val} months` } case 'project_application_volume_limit': { - return `${this.constantStrings[key]}${val} GB`; + return `${this.constantStrings[key]}${val} GB` } case 'project_application_object_storage': { - return `${this.constantStrings[key]}${val} GB`; + return `${this.constantStrings[key]}${val} GB` } case 'project_application_report_allowed': { if (val) { - return `${this.constantStrings[key]} Yes`; + return `${this.constantStrings[key]} Yes` } else { - return `${this.constantStrings[key]} No`; + return `${this.constantStrings[key]} No` } } default: { - return `${this.constantStrings[key]}${val}`; + return `${this.constantStrings[key]}${val}` } } } else { - return null; + return null } } } diff --git a/src/app/shared/shared_modules/baseClass/filter-base-class.ts b/src/app/shared/shared_modules/baseClass/filter-base-class.ts index 8afa098963..910dab107b 100644 --- a/src/app/shared/shared_modules/baseClass/filter-base-class.ts +++ b/src/app/shared/shared_modules/baseClass/filter-base-class.ts @@ -1,4 +1,4 @@ -import { AbstractBaseClass, Application_States } from './abstract-base-class'; +import { AbstractBaseClass, Application_States } from './abstract-base-class' /** * Base class for filtering. @@ -11,12 +11,12 @@ export abstract class FilterBaseClass extends AbstractBaseClass { Application_States.EXPIRED, Application_States.WAIT_FOR_CONFIRMATION, Application_States.TERMINATION_REQUESTED, - Application_States.EXPIRES_SOON, - ]; - filterProjectName: string; - filterProjectId: string; - filterProjectLongName: string; - filterFacilityName: string; + Application_States.EXPIRES_SOON + ] + filterProjectName: string + filterProjectId: string + filterProjectLongName: string + filterFacilityName: string abstract applyFilter(): void @@ -24,108 +24,108 @@ export abstract class FilterBaseClass extends AbstractBaseClass { isFilterProjectId(id: string, filter?: string): boolean { if (filter) { - this.filterProjectId = filter; + this.filterProjectId = filter } if (!this.filterProjectId) { - return true; + return true } - return id.includes(this.filterProjectId); + return id.includes(this.filterProjectId) } isFilterFacilityName(name: string): boolean { if (!this.filterFacilityName) { - return true; - } else return name.includes(this.filterFacilityName.toLowerCase()); + return true + } else return name.includes(this.filterFacilityName.toLowerCase()) } isFilterLongProjectName(name: string, filter?: string): boolean { if (filter) { - this.filterProjectLongName = filter; + this.filterProjectLongName = filter } if (!this.filterProjectLongName) { - return true; + return true } - return name != null && name.includes(this.filterProjectLongName); + return name !== null && name.includes(this.filterProjectLongName) } isFilterProjectName(projectName: string, filter?: string): boolean { if (filter) { - this.filterProjectName = filter; + this.filterProjectName = filter } if (!this.filterProjectName) { - return true; + return true } - return projectName != null && projectName.includes(this.filterProjectName); + return projectName !== null && projectName.includes(this.filterProjectName) } isFilterProjectStatus(status_numbers: number[], lifetime_reached: number): boolean { - let status: string; - let lifetime_status: string; + let status: string + let lifetime_status: string if (status_numbers && status_numbers.length > 0) { for (const status_number of status_numbers) { switch (status_number) { case this.project_states.ACTIVE: - status = this.project_states[this.project_states.ACTIVE]; + status = this.project_states[this.project_states.ACTIVE] if (this.filterstatus_list[status]) { - return true; + return true } - break; + break case this.project_states.SUSPENDED: - status = this.project_states[this.project_states.SUSPENDED]; + status = this.project_states[this.project_states.SUSPENDED] if (this.filterstatus_list[status]) { - return true; + return true } - break; + break case this.application_states.WAIT_FOR_CONFIRMATION: - status = this.application_states[this.application_states.WAIT_FOR_CONFIRMATION]; + status = this.application_states[this.application_states.WAIT_FOR_CONFIRMATION] if (this.filterstatus_list[status]) { - return true; + return true } - break; + break case this.application_states.TERMINATION_REQUESTED: - status = this.application_states[this.application_states.TERMINATION_REQUESTED]; + status = this.application_states[this.application_states.TERMINATION_REQUESTED] if (this.filterstatus_list[status]) { - return true; + return true } - break; + break case this.application_states.WAIT_FOR_TERMINATION_FM: - status = this.application_states[this.application_states.WAIT_FOR_TERMINATION_FM]; + status = this.application_states[this.application_states.WAIT_FOR_TERMINATION_FM] if (this.filterstatus_list[status]) { - return true; + return true } - break; + break default: - break; + break } } } switch (lifetime_reached) { case this.lifetime_states.EXPIRED: - lifetime_status = this.lifetime_states[this.lifetime_states.EXPIRED]; + lifetime_status = this.lifetime_states[this.lifetime_states.EXPIRED] if (this.filterstatus_list[lifetime_status]) { - return true; + return true } - break; + break case this.lifetime_states.EXPIRES_SOON: - lifetime_status = this.lifetime_states[this.lifetime_states.EXPIRES_SOON]; + lifetime_status = this.lifetime_states[this.lifetime_states.EXPIRES_SOON] if (this.filterstatus_list[lifetime_status]) { - return true; + return true } - break; + break default: - break; + break } - return false; + return false } changeFilterStatus(status: string): void { - this.filterstatus_list[status] = !this.filterstatus_list[status]; + this.filterstatus_list[status] = !this.filterstatus_list[status] } } diff --git a/src/app/shared/shared_modules/baseClass/shared-modal.ts b/src/app/shared/shared_modules/baseClass/shared-modal.ts index 8a0b76666b..bf0daee0af 100644 --- a/src/app/shared/shared_modules/baseClass/shared-modal.ts +++ b/src/app/shared/shared_modules/baseClass/shared-modal.ts @@ -1,33 +1,32 @@ -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { NotificationModalComponent } from '../../modal/notification-modal'; +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { NotificationModalComponent } from '../../modal/notification-modal' export class SharedModal { - /** * Modal reference to be changed/showed/hidden depending on chosen modal. */ - bsModalRef: BsModalRef; + bsModalRef: BsModalRef constructor(protected modalService: BsModalService) { - // eslint-disable-next-line no-empty-function + } hideCurrentModal() { if (this.bsModalRef) { - this.modalService.hide(this.bsModalRef.id); + this.modalService.hide(this.bsModalRef.id) } } showNotificationModal( notificationModalTitle: string, - notificationModalMessage: string, - notificationModalType: string, + notificationModalMessage: string, + notificationModalType: string ) { - this.hideCurrentModal(); + this.hideCurrentModal() - const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage }; + const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage } - this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); + this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') } } diff --git a/src/app/shared/shared_modules/components/applications/application-badges/application-badges.component.ts b/src/app/shared/shared_modules/components/applications/application-badges/application-badges.component.ts index 6f8853ef13..5d7b4df9ef 100644 --- a/src/app/shared/shared_modules/components/applications/application-badges/application-badges.component.ts +++ b/src/app/shared/shared_modules/components/applications/application-badges/application-badges.component.ts @@ -1,20 +1,20 @@ -import { Component, Input } from '@angular/core'; -import { is_vo } from '../../../../globalvar'; -import { Application } from '../../../../../applications/application.model/application.model'; +import { Component, Input } from '@angular/core' +import { is_vo } from '../../../../globalvar' +import { Application } from '../../../../../applications/application.model/application.model' @Component({ selector: 'app-application-badges', templateUrl: './application-badges.component.html', - styleUrls: ['./application-badges.component.scss'], + styleUrls: ['./application-badges.component.scss'] }) export class ApplicationBadgesComponent { - @Input() application: Application; - is_vo_admin: boolean = false; - simple_vm_logo: string = 'static/webapp/assets/img/simpleVM_Logo.svg'; - openstack_logo: string = 'static/webapp/assets/img/openstack_plain_red.svg'; - kubernetes_logo: string = 'static/webapp/assets/img/kubernetes_logo.svg'; + @Input() application: Application + is_vo_admin: boolean = false + simple_vm_logo: string = 'static/webapp/assets/img/simpleVM_Logo.svg' + openstack_logo: string = 'static/webapp/assets/img/openstack_plain_red.svg' + kubernetes_logo: string = 'static/webapp/assets/img/kubernetes_logo.svg' constructor() { - this.is_vo_admin = is_vo; + this.is_vo_admin = is_vo } } diff --git a/src/app/shared/shared_modules/components/maintenance-notification/maintenance-notification.component.ts b/src/app/shared/shared_modules/components/maintenance-notification/maintenance-notification.component.ts index 75748f4659..762e5e3aea 100644 --- a/src/app/shared/shared_modules/components/maintenance-notification/maintenance-notification.component.ts +++ b/src/app/shared/shared_modules/components/maintenance-notification/maintenance-notification.component.ts @@ -1,17 +1,17 @@ -import { Component, Input, ViewChild } from '@angular/core'; -import { ModalDirective } from 'ngx-bootstrap/modal'; -import { MaintenanceTimeFrame } from '../../../../vo_manager/maintenance/maintenanceTimeFrame.model'; +import { Component, Input, ViewChild } from '@angular/core' +import { ModalDirective } from 'ngx-bootstrap/modal' +import { MaintenanceTimeFrame } from '../../../../vo_manager/maintenance/maintenanceTimeFrame.model' @Component({ selector: 'app-maintenance-notification', templateUrl: './maintenance-notification.component.html', - styleUrls: ['./maintenance-notification.component.scss'], + styleUrls: ['./maintenance-notification.component.scss'] }) export class MaintenanceNotificationComponent { - @Input() maintenanceTimeframes: MaintenanceTimeFrame[] = []; - @ViewChild('maintenanceModal') maintenanceModal: ModalDirective; + @Input() maintenanceTimeframes: MaintenanceTimeFrame[] = [] + @ViewChild('maintenanceModal') maintenanceModal: ModalDirective toggleModal(): void { - this.maintenanceModal.toggle(); + this.maintenanceModal.toggle() } } diff --git a/src/app/shared/shared_modules/components/maintenance-notification/significance-pipe/significance.pipe.ts b/src/app/shared/shared_modules/components/maintenance-notification/significance-pipe/significance.pipe.ts index d70d82df23..a3eb72785d 100644 --- a/src/app/shared/shared_modules/components/maintenance-notification/significance-pipe/significance.pipe.ts +++ b/src/app/shared/shared_modules/components/maintenance-notification/significance-pipe/significance.pipe.ts @@ -1,17 +1,17 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { MaintenanceTimeFrame } from '../../../../../vo_manager/maintenance/maintenanceTimeFrame.model'; +import { Pipe, PipeTransform } from '@angular/core' +import { MaintenanceTimeFrame } from '../../../../../vo_manager/maintenance/maintenanceTimeFrame.model' @Pipe({ - name: 'significanceGiven', + name: 'significanceGiven' }) export class SignificancePipe implements PipeTransform { transform(timeframes: MaintenanceTimeFrame[]): boolean { for (const tf of timeframes) { if (tf.significant) { - return true; + return true } } - return false; + return false } } diff --git a/src/app/shared/shared_modules/directives/nbd-sortable-header.directive.ts b/src/app/shared/shared_modules/directives/nbd-sortable-header.directive.ts index fe9e481727..90a4cb5726 100644 --- a/src/app/shared/shared_modules/directives/nbd-sortable-header.directive.ts +++ b/src/app/shared/shared_modules/directives/nbd-sortable-header.directive.ts @@ -1,11 +1,9 @@ -import { - Directive, EventEmitter, HostBinding, HostListener, Input, Output, -} from '@angular/core'; -import { Application } from '../../../applications/application.model/application.model'; +import { Directive, EventEmitter, HostBinding, HostListener, Input, Output } from '@angular/core' +import { Application } from '../../../applications/application.model/application.model' export type SortColumn = keyof Application | '' export type SortDirection = 'asc' | 'desc' | '' -const rotate: { [key: string]: SortDirection } = { asc: 'desc', desc: '', '': 'asc' }; +const rotate: { [key: string]: SortDirection } = { asc: 'desc', desc: '', '': 'asc' } export interface SortEvent { column: SortColumn @@ -20,26 +18,26 @@ export interface State { sortDirection: SortDirection } -export const compare = (v1: string | number, v2: string | number) => (v1 < v2 ? -1 : v1 > v2 ? 1 : 0); +export const compare = (v1: string | number, v2: string | number) => (v1 < v2 ? -1 : v1 > v2 ? 1 : 0) @Directive({ - selector: 'th[appSortable]', + selector: 'th[appSortable]' }) export class NgbdSortableHeaderDirective { - @Input() appSortable: SortColumn = ''; - @Input() direction: SortDirection = ''; - @Output() sort = new EventEmitter(); + @Input() appSortable: SortColumn = '' + @Input() direction: SortDirection = '' + @Output() sort = new EventEmitter() @HostBinding('class.asc') get asc() { - return this.direction === 'asc'; + return this.direction === 'asc' } @HostBinding('class.desc') get desc() { - return this.direction === 'desc'; + return this.direction === 'desc' } @HostListener('click') rotate() { - this.direction = rotate[this.direction]; - this.sort.emit({ column: this.appSortable, direction: this.direction }); + this.direction = rotate[this.direction] + this.sort.emit({ column: this.appSortable, direction: this.direction }) } } diff --git a/src/app/shared/shared_modules/migration-information/migration-information.component.ts b/src/app/shared/shared_modules/migration-information/migration-information.component.ts index 7f815ea7ab..2ee9089650 100644 --- a/src/app/shared/shared_modules/migration-information/migration-information.component.ts +++ b/src/app/shared/shared_modules/migration-information/migration-information.component.ts @@ -1,42 +1,40 @@ -import { - Component, OnInit, OnDestroy, Input, -} from '@angular/core'; -import { Subscription } from 'rxjs'; -import { CLOUD_PORTAL_SUPPORT_MAIL, NEW_SVM_PORTAL_LINK } from '../../../../links/links'; +import { Component, OnInit, OnDestroy, Input } from '@angular/core' +import { Subscription } from 'rxjs' +import { CLOUD_PORTAL_SUPPORT_MAIL, NEW_SVM_PORTAL_LINK } from '../../../../links/links' @Component({ selector: 'app-migration-information', templateUrl: './migration-information.component.html', - styleUrls: ['./migration-information.component.scss'], + styleUrls: ['./migration-information.component.scss'] }) export class MigrationInformationComponent implements OnInit, OnDestroy { - subscription: Subscription = new Subscription(); + subscription: Subscription = new Subscription() - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - NEW_SVM_PORTAL_LINK: string = NEW_SVM_PORTAL_LINK; + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + NEW_SVM_PORTAL_LINK: string = NEW_SVM_PORTAL_LINK - @Input() isCreationPage: boolean = false; - @Input() affectedProjects: string[] = []; + @Input() isCreationPage: boolean = false + @Input() affectedProjects: string[] = [] - @Input() type: string = ''; + @Input() type: string = '' // eslint-disable-next-line @typescript-eslint/no-useless-constructor constructor() { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { - this.subscription = new Subscription(); - const uniqueProjects = []; + this.subscription = new Subscription() + const uniqueProjects = [] this.affectedProjects.forEach(project => { if (!uniqueProjects.includes(project)) { - uniqueProjects.push(project); + uniqueProjects.push(project) } - }); - this.affectedProjects = uniqueProjects; + }) + this.affectedProjects = uniqueProjects } ngOnDestroy(): void { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } } diff --git a/src/app/shared/shared_modules/public-key/public-key.component.ts b/src/app/shared/shared_modules/public-key/public-key.component.ts index a1a2b7ae4c..0744dbfb41 100644 --- a/src/app/shared/shared_modules/public-key/public-key.component.ts +++ b/src/app/shared/shared_modules/public-key/public-key.component.ts @@ -1,17 +1,15 @@ -import { - Component, EventEmitter, Input, OnInit, Output, -} from '@angular/core'; -import { ClipboardService } from 'ngx-clipboard'; -import { saveAs } from 'file-saver'; -import { BsModalService } from 'ngx-bootstrap/modal'; -import { KeyService } from '../../../api-connector/key.service'; -import { ApiSettings } from '../../../api-connector/api-settings.service'; -import { Userinfo } from '../../../userinfo/userinfo.model'; -import { IResponseTemplate } from '../../../api-connector/response-template'; -import { AbstractBaseClass } from '../baseClass/abstract-base-class'; -import { WIKI_GENERATE_KEYS, CLOUD_PORTAL_SUPPORT_MAIL } from '../../../../links/links'; -import { NotificationModalComponent } from '../../modal/notification-modal'; -import { BlacklistedResponse } from '../../../api-connector/response-interfaces'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' +import { ClipboardService } from 'ngx-clipboard' +import { saveAs } from 'file-saver' +import { BsModalService } from 'ngx-bootstrap/modal' +import { KeyService } from '../../../api-connector/key.service' +import { ApiSettings } from '../../../api-connector/api-settings.service' +import { Userinfo } from '../../../userinfo/userinfo.model' +import { IResponseTemplate } from '../../../api-connector/response-template' +import { AbstractBaseClass } from '../baseClass/abstract-base-class' +import { WIKI_GENERATE_KEYS, CLOUD_PORTAL_SUPPORT_MAIL } from '../../../../links/links' +import { NotificationModalComponent } from '../../modal/notification-modal' +import { BlacklistedResponse } from '../../../api-connector/response-interfaces' /** * Public Key component. @@ -20,107 +18,107 @@ import { BlacklistedResponse } from '../../../api-connector/response-interfaces' selector: '[app-public-key]', templateUrl: './public-key.component.html', styleUrls: ['./public-key.component.scss'], - providers: [ApiSettings, KeyService], + providers: [ApiSettings, KeyService] }) export class PublicKeyComponent extends AbstractBaseClass implements OnInit { - WIKI_GENERATE_KEYS: string = WIKI_GENERATE_KEYS; - public_key: string; - validated_key: boolean = false; - blocked_key: boolean = false; - current_key_blocked: boolean = false; - acknowledgement_given: boolean = false; - @Input() userinfo: Userinfo; - @Output() readonly currentKeyBlockedChanged: EventEmitter = new EventEmitter(); - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; + WIKI_GENERATE_KEYS: string = WIKI_GENERATE_KEYS + public_key: string + validated_key: boolean = false + blocked_key: boolean = false + current_key_blocked: boolean = false + acknowledgement_given: boolean = false + @Input() userinfo: Userinfo + @Output() readonly currentKeyBlockedChanged: EventEmitter = new EventEmitter() + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL constructor( private keyService: KeyService, private clipboardService: ClipboardService, - private modalService: BsModalService, + private modalService: BsModalService ) { - super(); + super() } ngOnInit() { if (this.userinfo?.PublicKey) { - this.isCurrentKeyBlocked(); + this.isCurrentKeyBlocked() } } downloadPem(data: string): void { - const blob: Blob = new Blob([data], { type: 'pem' }); - const url: string = window.URL.createObjectURL(blob); - saveAs(url, `${this.userinfo.UserLogin}_ecdsa`); + const blob: Blob = new Blob([data], { type: 'pem' }) + const url: string = window.URL.createObjectURL(blob) + saveAs(url, `${this.userinfo.UserLogin}_ecdsa`) } generateKey(): void { this.keyService.generateKey().subscribe((res: any): void => { - this.getUserPublicKey(); - this.downloadPem(res['private_key']); - }); + this.getUserPublicKey() + this.downloadPem(res['private_key']) + }) } isKeyBlocked(): void { this.keyService.isBlocked(this.public_key.trim()).subscribe((res: BlacklistedResponse) => { - this.blocked_key = res.blacklisted; - }); + this.blocked_key = res.blacklisted + }) } isCurrentKeyBlocked(): void { this.keyService.isBlocked(this.userinfo.PublicKey).subscribe((res: BlacklistedResponse) => { - this.current_key_blocked = res.blacklisted; - this.currentKeyBlockedChanged.emit(this.current_key_blocked); - }); + this.current_key_blocked = res.blacklisted + this.currentKeyBlockedChanged.emit(this.current_key_blocked) + }) } validateKey(): void { this.keyService.validateKey(this.public_key.trim()).subscribe( (res: any) => { - this.validated_key = res['status'] === 'valid'; + this.validated_key = res['status'] === 'valid' }, () => { - this.validated_key = false; - }, - ); + this.validated_key = false + } + ) } importKey(): void { - const re: RegExp = /\+/gi; + const re: RegExp = /\+/gi this.keyService.postKey(this.public_key.replace(re, '%2B').trim()).subscribe({ next: (): void => { - this.getUserPublicKey(); + this.getUserPublicKey() const initialState = { notificationModalTitle: 'Success', notificationModalType: 'info', - notificationModalMessage: 'The new public key got successfully set', - }; - this.modalService.show(NotificationModalComponent, { initialState }); + notificationModalMessage: 'The new public key got successfully set' + } + this.modalService.show(NotificationModalComponent, { initialState }) }, error: (): any => { const initialState = { notificationModalTitle: 'Error', notificationModalType: 'danger', notificationModalMessage: - 'We were not able successfully set a new public key. Please enter a valid public key!', - }; - this.modalService.show(NotificationModalComponent, { initialState }); - }, - }); + 'We were not able successfully set a new public key. Please enter a valid public key!' + } + this.modalService.show(NotificationModalComponent, { initialState }) + } + }) } copyToClipboard(text: string): void { if (this.clipboardService.isSupported) { - this.clipboardService.copy(text); + this.clipboardService.copy(text) } else { - super.copyToClipboard(text); + super.copyToClipboard(text) } } getUserPublicKey(): void { this.keyService.getKey().subscribe((key: IResponseTemplate): void => { - this.userinfo.PublicKey = key.value as string; - this.isKeyBlocked(); - }); + this.userinfo.PublicKey = key.value as string + this.isKeyBlocked() + }) } } diff --git a/src/app/shared/shared_modules/public-key/public-key.module.ts b/src/app/shared/shared_modules/public-key/public-key.module.ts index 5259210018..1bd631f55b 100644 --- a/src/app/shared/shared_modules/public-key/public-key.module.ts +++ b/src/app/shared/shared_modules/public-key/public-key.module.ts @@ -1,13 +1,13 @@ -import { NgModule } from '@angular/core'; +import { NgModule } from '@angular/core' -import { TabsModule } from 'ngx-bootstrap/tabs'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { ModalModule } from 'ngx-bootstrap/modal'; -import { AlertModule } from 'ngx-bootstrap/alert'; -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import { PublicKeyComponent } from './public-key.component'; -import { PipeModuleModule } from '../../../pipe-module/pipe-module.module'; +import { TabsModule } from 'ngx-bootstrap/tabs' +import { CommonModule } from '@angular/common' +import { FormsModule } from '@angular/forms' +import { ModalModule } from 'ngx-bootstrap/modal' +import { AlertModule } from 'ngx-bootstrap/alert' +import { NgbModule } from '@ng-bootstrap/ng-bootstrap' +import { PublicKeyComponent } from './public-key.component' +import { PipeModuleModule } from '../../../pipe-module/pipe-module.module' /** * Public key module. @@ -20,10 +20,10 @@ import { PipeModuleModule } from '../../../pipe-module/pipe-module.module'; ModalModule.forRoot(), AlertModule.forRoot(), NgbModule, - PipeModuleModule, + PipeModuleModule ], declarations: [PublicKeyComponent], - exports: [PublicKeyComponent, AlertModule, FormsModule, ModalModule, CommonModule, TabsModule], + exports: [PublicKeyComponent, AlertModule, FormsModule, ModalModule, CommonModule, TabsModule] }) export class PublicKeyModule {} diff --git a/src/app/shared/shared_modules/services/project-sort.service.ts b/src/app/shared/shared_modules/services/project-sort.service.ts index f69c4661e3..b542a701c5 100644 --- a/src/app/shared/shared_modules/services/project-sort.service.ts +++ b/src/app/shared/shared_modules/services/project-sort.service.ts @@ -1,13 +1,9 @@ -import { Injectable } from '@angular/core'; -import { - BehaviorSubject, delay, Observable, of, Subject, -} from 'rxjs'; -import { debounceTime, switchMap, tap } from 'rxjs/operators'; -import { Application_States } from '../baseClass/abstract-base-class'; -import { Application } from '../../../applications/application.model/application.model'; -import { - compare, SortColumn, SortDirection, State, -} from '../directives/nbd-sortable-header.directive'; +import { Injectable } from '@angular/core' +import { BehaviorSubject, delay, Observable, of, Subject } from 'rxjs' +import { debounceTime, switchMap, tap } from 'rxjs/operators' +import { Application_States } from '../baseClass/abstract-base-class' +import { Application } from '../../../applications/application.model/application.model' +import { compare, SortColumn, SortDirection, State } from '../directives/nbd-sortable-header.directive' interface SearchResult { sortedApplications: Application[] @@ -15,18 +11,18 @@ interface SearchResult { } @Injectable({ - providedIn: 'root', + providedIn: 'root' }) export class ProjectSortService { - public filterStatusList: number[] = []; - public showSimpleVM: boolean = true; - public showOpenStack: boolean = true; - private _loading$ = new BehaviorSubject(true); - private _search$ = new Subject(); - private _applications$ = new BehaviorSubject([]); - private _total$ = new BehaviorSubject(0); - private _applications: Application[] = []; - public sorted_applications: Application[] = []; + public filterStatusList: number[] = [] + public showSimpleVM: boolean = true + public showOpenStack: boolean = true + private _loading$ = new BehaviorSubject(true) + private _search$ = new Subject() + private _applications$ = new BehaviorSubject([]) + private _total$ = new BehaviorSubject(0) + private _applications: Application[] = [] + public sorted_applications: Application[] = [] _initiateFilterStatusList(): void { this.filterStatusList = [ @@ -37,66 +33,66 @@ export class ProjectSortService { Application_States.WAIT_FOR_CONFIRMATION, Application_States.TERMINATION_REQUESTED, Application_States.EXPIRES_SOON, - Application_States.DISABLED, - ]; + Application_States.DISABLED + ] } get applications$() { - return this._applications$.asObservable(); + return this._applications$.asObservable() } get total$() { - return this._total$.asObservable(); + return this._total$.asObservable() } get loading$() { - return this._loading$.asObservable(); + return this._loading$.asObservable() } set page(page: number) { - this._set({ page }); + this._set({ page }) } get page() { - return this._state.page; + return this._state.page } get pageSize() { - return this._state.pageSize; + return this._state.pageSize } set pageSize(pageSize: number) { - this._set({ pageSize }); + this._set({ pageSize }) } get searchTerm() { - return this._state.searchTerm; + return this._state.searchTerm } set searchTerm(searchTerm: string) { - searchTerm = searchTerm.trim(); - this._set({ searchTerm }); + searchTerm = searchTerm.trim() + this._set({ searchTerm }) } set sortColumn(sortColumn: SortColumn) { - this._set({ sortColumn }); + this._set({ sortColumn }) } set sortDirection(sortDirection: SortDirection) { - this._set({ sortDirection }); + this._set({ sortDirection }) } set applications(applications: Application[]) { - this._applications = applications; - this._search$.next(); + this._applications = applications + this._search$.next() } get applications() { - return this._applications; + return this._applications } initiateSearch(): void { - this._search$.next(); + this._search$.next() } private _state: State = { @@ -104,105 +100,103 @@ export class ProjectSortService { pageSize: 10, searchTerm: '', sortColumn: '', - sortDirection: '', - }; + sortDirection: '' + } private _set(patch: Partial) { - Object.assign(this._state, patch); - this._search$.next(); + Object.assign(this._state, patch) + this._search$.next() } constructor() { - this.applications = []; - this._initiateFilterStatusList(); + this.applications = [] + this._initiateFilterStatusList() this._search$ .pipe( tap(() => this._loading$.next(true)), debounceTime(200), switchMap(() => this._search()), delay(100), - tap(() => this._loading$.next(false)), + tap(() => this._loading$.next(false)) ) .subscribe(result => { - this._applications$.next(result.sortedApplications); - this._total$.next(result.total); - }); + this._applications$.next(result.sortedApplications) + this._total$.next(result.total) + }) - this._search$.next(); + this._search$.next() } addOrRemoveFromFilterStatusList(status: Application_States) { - const idx = this.filterStatusList.indexOf(status); + const idx = this.filterStatusList.indexOf(status) if (idx === -1) { - this.filterStatusList.push(status); + this.filterStatusList.push(status) } else { - this.filterStatusList.splice(idx, 1); + this.filterStatusList.splice(idx, 1) } - this._search$.next(); + this._search$.next() } matches(text: string, project: Application): boolean { - const term = text.toLowerCase(); + const term = text.toLowerCase() if ( - (!this.showSimpleVM && !project.project_application_openstack_project) - || (!this.showOpenStack && project.project_application_openstack_project) + (!this.showSimpleVM && !project.project_application_openstack_project) || + (!this.showOpenStack && project.project_application_openstack_project) ) { - return false; + return false } if (this.filterStatusList) { - const status_match: boolean = project.project_application_statuses.some(r => this.filterStatusList.includes(r)); + const status_match: boolean = project.project_application_statuses.some(r => this.filterStatusList.includes(r)) if (!status_match) { - return false; + return false } } return ( - project.project_application_shortname.toLowerCase().includes(term) - || project.project_application_perun_id.toString().toLowerCase().includes(term) - || project.project_application_current_credits.toString().toLowerCase().includes(term) - || project.project_application_initial_credits.toString().toLowerCase().includes(term) - || project?.project_application_compute_center?.Name.toString().toLowerCase().includes(term) - || project.project_application_total_ram.toString().toLowerCase().includes(term) - || project.project_application_total_cores.toString().toLowerCase().includes(term) - || project.project_application_total_gpu.toString().toLowerCase().includes(term) - || project.project_application_name.toString().toLowerCase().includes(term) - ); + project.project_application_shortname.toLowerCase().includes(term) || + project.project_application_perun_id.toString().toLowerCase().includes(term) || + project.project_application_current_credits.toString().toLowerCase().includes(term) || + project.project_application_initial_credits.toString().toLowerCase().includes(term) || + project?.project_application_compute_center?.Name.toString().toLowerCase().includes(term) || + project.project_application_total_ram.toString().toLowerCase().includes(term) || + project.project_application_total_cores.toString().toLowerCase().includes(term) || + project.project_application_total_gpu.toString().toLowerCase().includes(term) || + project.project_application_name.toString().toLowerCase().includes(term) + ) } sort(applications: Application[], column: SortColumn, direction: string): Application[] { if (direction === '' || column === '') { - return applications; + return applications } else { return [...applications].sort((a, b) => { // if (typeof a[column] == 'string' || typeof a[column] == 'number') { // @ts-ignore - const res = compare(a[column], b[column]); + const res = compare(a[column], b[column]) - return direction === 'asc' ? res : -res; + return direction === 'asc' ? res : -res // } - }); + }) } } private _search(): Observable { - const { - sortColumn, sortDirection, pageSize, page, searchTerm, - } = this._state; + const { sortColumn, sortDirection, pageSize, page, searchTerm } = this._state // 1. sort - let sortedApplications = this.sort(this._applications, sortColumn, sortDirection); + let sortedApplications = this.sort(this._applications, sortColumn, sortDirection) // 2. filter - sortedApplications = sortedApplications.filter(app => this.matches(searchTerm, app)); - this.sorted_applications = sortedApplications; + sortedApplications = sortedApplications.filter(app => this.matches(searchTerm, app)) + this.sorted_applications = sortedApplications - const total = sortedApplications.length; + const total = sortedApplications.length // 3. paginate - sortedApplications = sortedApplications.slice((page - 1) * pageSize, (page - 1) * pageSize + pageSize); + sortedApplications = sortedApplications.slice((page - 1) * pageSize, (page - 1) * pageSize + pageSize) - return of({ sortedApplications, total }); + return of({ sortedApplications, total }) } } diff --git a/src/app/shared/shared_modules/shared-module.module.ts b/src/app/shared/shared_modules/shared-module.module.ts index f55f91f92f..3609f2315e 100644 --- a/src/app/shared/shared_modules/shared-module.module.ts +++ b/src/app/shared/shared_modules/shared-module.module.ts @@ -1,23 +1,23 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { ModalModule } from 'ngx-bootstrap/modal'; -import { ProgressModule, ToastModule } from '@coreui/angular'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { NgSelectModule } from '@ng-select/ng-select'; -import { RouterLink } from '@angular/router'; -import { ApplicationBaseClassComponent } from './baseClass/application-base-class.component'; -import { NotificationModalComponent } from '../modal/notification-modal'; -import { InformationToastComponent } from '../toaster/information-toast.component'; -import { ConfirmationModalComponent } from '../modal/confirmation-modal.component'; -import { MigrationInformationComponent } from './migration-information/migration-information.component'; -import { ApplicationBadgesComponent } from './components/applications/application-badges/application-badges.component'; -import { ProjectEmailModalComponent } from '../modal/email/project-email-modal/project-email-modal.component'; -import { TestimonialFormComponent } from './testimonial-forms/testimonial-form.component'; -import { SharedDirectivesModule } from './shared_directives.module'; -import { MaintenanceNotificationComponent } from './components/maintenance-notification/maintenance-notification.component'; -import { PipeModuleModule } from '../../pipe-module/pipe-module.module'; -import { MembersListModalComponent } from '../modal/members/members-list-modal.component'; -import { ProjectCsvTemplatedEmailModalComponent } from '../modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component'; +import { NgModule } from '@angular/core' +import { CommonModule } from '@angular/common' +import { ModalModule } from 'ngx-bootstrap/modal' +import { ProgressModule, ToastModule } from '@coreui/angular' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { NgSelectModule } from '@ng-select/ng-select' +import { RouterLink } from '@angular/router' +import { ApplicationBaseClassComponent } from './baseClass/application-base-class.component' +import { NotificationModalComponent } from '../modal/notification-modal' +import { InformationToastComponent } from '../toaster/information-toast.component' +import { ConfirmationModalComponent } from '../modal/confirmation-modal.component' +import { MigrationInformationComponent } from './migration-information/migration-information.component' +import { ApplicationBadgesComponent } from './components/applications/application-badges/application-badges.component' +import { ProjectEmailModalComponent } from '../modal/email/project-email-modal/project-email-modal.component' +import { TestimonialFormComponent } from './testimonial-forms/testimonial-form.component' +import { SharedDirectivesModule } from './shared_directives.module' +import { MaintenanceNotificationComponent } from './components/maintenance-notification/maintenance-notification.component' +import { PipeModuleModule } from '../../pipe-module/pipe-module.module' +import { MembersListModalComponent } from '../modal/members/members-list-modal.component' +import { ProjectCsvTemplatedEmailModalComponent } from '../modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component' /** * Shared module. @@ -34,7 +34,7 @@ import { ProjectCsvTemplatedEmailModalComponent } from '../modal/email/project-c ProjectEmailModalComponent, ProjectCsvTemplatedEmailModalComponent, TestimonialFormComponent, - MaintenanceNotificationComponent, + MaintenanceNotificationComponent ], imports: [ CommonModule, @@ -46,7 +46,7 @@ import { ProjectCsvTemplatedEmailModalComponent } from '../modal/email/project-c NgSelectModule, SharedDirectivesModule, ReactiveFormsModule, - RouterLink, + RouterLink ], declarations: [ ApplicationBaseClassComponent, @@ -59,7 +59,7 @@ import { ProjectCsvTemplatedEmailModalComponent } from '../modal/email/project-c ProjectEmailModalComponent, ProjectCsvTemplatedEmailModalComponent, TestimonialFormComponent, - MaintenanceNotificationComponent, - ], + MaintenanceNotificationComponent + ] }) export class SharedModuleModule {} diff --git a/src/app/shared/shared_modules/shared_directives.module.ts b/src/app/shared/shared_modules/shared_directives.module.ts index 4ccffa61dc..c85229ff37 100644 --- a/src/app/shared/shared_modules/shared_directives.module.ts +++ b/src/app/shared/shared_modules/shared_directives.module.ts @@ -1,13 +1,13 @@ -import { NgModule } from '@angular/core'; +import { NgModule } from '@angular/core' import { FloatOrNullValidatorDirective, FloatValidatorDirective, IntegerOrNullValidatorDirective, IntegerValidatorDirective, MaxAmoutValidatorDirective, - MinAmoutValidatorDirective, -} from '../../applications/numberValidations.directive'; -import { NgbdSortableHeaderDirective } from './directives/nbd-sortable-header.directive'; + MinAmoutValidatorDirective +} from '../../applications/numberValidations.directive' +import { NgbdSortableHeaderDirective } from './directives/nbd-sortable-header.directive' /** * Shared directives module. @@ -21,7 +21,7 @@ import { NgbdSortableHeaderDirective } from './directives/nbd-sortable-header.di IntegerOrNullValidatorDirective, FloatOrNullValidatorDirective, FloatValidatorDirective, - NgbdSortableHeaderDirective, + NgbdSortableHeaderDirective ], exports: [ MinAmoutValidatorDirective, @@ -30,7 +30,7 @@ import { NgbdSortableHeaderDirective } from './directives/nbd-sortable-header.di IntegerOrNullValidatorDirective, FloatOrNullValidatorDirective, FloatValidatorDirective, - NgbdSortableHeaderDirective, - ], + NgbdSortableHeaderDirective + ] }) export class SharedDirectivesModule {} diff --git a/src/app/shared/shared_modules/testimonial-forms/testimonial-form.component.ts b/src/app/shared/shared_modules/testimonial-forms/testimonial-form.component.ts index 93e35a7331..39a23fdcbf 100644 --- a/src/app/shared/shared_modules/testimonial-forms/testimonial-form.component.ts +++ b/src/app/shared/shared_modules/testimonial-forms/testimonial-form.component.ts @@ -1,73 +1,71 @@ -import { - Component, OnInit, OnDestroy, Input, ViewChild, -} from '@angular/core'; -import { Subscription } from 'rxjs'; -import { ModalDirective } from 'ngx-bootstrap/modal'; -import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; -import { TESTIMONIAL_PAGE_LINK, CLOUD_PORTAL_SUPPORT_MAIL, SINGLE_TESTIMONIAL_PAGE_LINK } from '../../../../links/links'; -import { NewsService } from '../../../api-connector/news.service'; -import { Application } from '../../../applications/application.model/application.model'; -import { SocialConsent } from './social-consent.model'; +import { Component, OnInit, OnDestroy, Input, ViewChild } from '@angular/core' +import { Subscription } from 'rxjs' +import { ModalDirective } from 'ngx-bootstrap/modal' +import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms' +import { TESTIMONIAL_PAGE_LINK, CLOUD_PORTAL_SUPPORT_MAIL, SINGLE_TESTIMONIAL_PAGE_LINK } from '../../../../links/links' +import { NewsService } from '../../../api-connector/news.service' +import { Application } from '../../../applications/application.model/application.model' +import { SocialConsent } from './social-consent.model' @Component({ selector: 'app-testimonial-form', templateUrl: './testimonial-form.component.html', styleUrls: ['./testimonial-form.component.scss'], - providers: [NewsService], + providers: [NewsService] }) export class TestimonialFormComponent implements OnInit, OnDestroy { - subscription: Subscription = new Subscription(); + subscription: Subscription = new Subscription() - TESTIMONIAL_PAGE_LINK: string = TESTIMONIAL_PAGE_LINK; - SINGLE_TESTIMONIAL_PAGE_LINK: string = SINGLE_TESTIMONIAL_PAGE_LINK; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - @ViewChild('testimonialModal') testimonialModal: ModalDirective; + TESTIMONIAL_PAGE_LINK: string = TESTIMONIAL_PAGE_LINK + SINGLE_TESTIMONIAL_PAGE_LINK: string = SINGLE_TESTIMONIAL_PAGE_LINK + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + @ViewChild('testimonialModal') testimonialModal: ModalDirective - testimonialFormGroup: UntypedFormGroup; - formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); + testimonialFormGroup: UntypedFormGroup + formBuilder: UntypedFormBuilder = new UntypedFormBuilder() - @Input() title: string = ''; - initialTitle: string = ''; - text: string = ''; - initialText: string = ''; - excerpt: string = ''; - initialExcerpt: string = ''; - @Input() contributor: string = ''; - initialContributor: string = ''; - @Input() institution: string = ''; - initialInstitution: string = ''; - @Input() workgroup: string = ''; - initialWorkgroup: string = ''; - @Input() simple_vm: boolean = false; - @Input() project_application: Application; - @Input() testimonialSent: boolean; - initialLoadingSuccessful: boolean = false; - image_url: string = ''; - possibleSocialConsents: SocialConsent[] = []; - selectedSocialConsents: SocialConsent[] = []; - submissionSuccessful: boolean = false; - autosaveTimer: ReturnType; - autosaveTimeout: number = 60000; - userInteractedWithForm: boolean = false; - autoSaveInProgress: boolean = false; - showAutosaveSucess: boolean = false; - showAutosaveFail: boolean = false; - autosaveStatusTimer: ReturnType; - file: File = null; - hideTestimonialForm: boolean = false; + @Input() title: string = '' + initialTitle: string = '' + text: string = '' + initialText: string = '' + excerpt: string = '' + initialExcerpt: string = '' + @Input() contributor: string = '' + initialContributor: string = '' + @Input() institution: string = '' + initialInstitution: string = '' + @Input() workgroup: string = '' + initialWorkgroup: string = '' + @Input() simple_vm: boolean = false + @Input() project_application: Application + @Input() testimonialSent: boolean + initialLoadingSuccessful: boolean = false + image_url: string = '' + possibleSocialConsents: SocialConsent[] = [] + selectedSocialConsents: SocialConsent[] = [] + submissionSuccessful: boolean = false + autosaveTimer: ReturnType + autosaveTimeout: number = 60000 + userInteractedWithForm: boolean = false + autoSaveInProgress: boolean = false + showAutosaveSucess: boolean = false + showAutosaveFail: boolean = false + autosaveStatusTimer: ReturnType + file: File = null + hideTestimonialForm: boolean = false - // eslint-disable-next-line @typescript-eslint/no-useless-constructor + constructor(private newsService: NewsService) { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { - this.setInitialData(); - this.subscription = new Subscription(); - this.getTestimonialData(); + this.setInitialData() + this.subscription = new Subscription() + this.getTestimonialData() this.newsService.getPossibleSocialConsents().subscribe((consents: SocialConsent[]) => { - this.possibleSocialConsents = consents; - }); + this.possibleSocialConsents = consents + }) } createFormGroup(): void { @@ -76,59 +74,59 @@ export class TestimonialFormComponent implements OnInit, OnDestroy { testimonial_text: [this.text, Validators.compose([Validators.required, Validators.minLength(1500)])], testimonial_excerpt: [ this.excerpt, - Validators.compose([Validators.required, Validators.minLength(200), Validators.maxLength(1000)]), + Validators.compose([Validators.required, Validators.minLength(200), Validators.maxLength(1000)]) ], testimonial_contributor: [this.contributor, Validators.required], testimonial_institution: [this.institution, Validators.required], - testimonial_workgroup: [this.workgroup, Validators.required], - }); - this.listenToChanges(); + testimonial_workgroup: [this.workgroup, Validators.required] + }) + this.listenToChanges() } listenToChanges(): void { this.testimonialFormGroup.get('testimonial_title').valueChanges.subscribe((val: string): void => { - this.title = val; - }); + this.title = val + }) this.testimonialFormGroup.get('testimonial_text').valueChanges.subscribe((val: string): void => { - this.text = val; - }); + this.text = val + }) this.testimonialFormGroup.get('testimonial_excerpt').valueChanges.subscribe((val: string): void => { - this.excerpt = val; - }); + this.excerpt = val + }) this.testimonialFormGroup.get('testimonial_contributor').valueChanges.subscribe((val: string): void => { - this.contributor = val; - }); + this.contributor = val + }) this.testimonialFormGroup.get('testimonial_institution').valueChanges.subscribe((val: string): void => { - this.institution = val; - }); + this.institution = val + }) this.testimonialFormGroup.get('testimonial_workgroup').valueChanges.subscribe((val: string): void => { - this.workgroup = val; - }); + this.workgroup = val + }) this.testimonialFormGroup.valueChanges.subscribe((): void => { - this.checkAutosaveNeed(); - }); + this.checkAutosaveNeed() + }) } /** * updateSelectedOptions does not work yet * @param socialConsent the object that got checked/unchecked */ updateSelectedOptions(socialConsent: SocialConsent): void { - const idx: number = this.selectedSocialConsents.findIndex(consent => consent.id === socialConsent.id); + const idx: number = this.selectedSocialConsents.findIndex(consent => consent.id === socialConsent.id) if (idx !== -1) { - this.selectedSocialConsents.splice(idx, 1); + this.selectedSocialConsents.splice(idx, 1) } else { - this.selectedSocialConsents.push(socialConsent); + this.selectedSocialConsents.push(socialConsent) } } setInitialData(): void { - this.initialTitle = this.title; - this.initialText = this.text; - this.initialExcerpt = this.excerpt; - this.initialContributor = this.contributor; - this.initialInstitution = this.institution; - this.initialWorkgroup = this.workgroup; + this.initialTitle = this.title + this.initialText = this.text + this.initialExcerpt = this.excerpt + this.initialContributor = this.contributor + this.initialInstitution = this.institution + this.initialWorkgroup = this.workgroup } checkAutosaveNeed(): void { @@ -138,89 +136,89 @@ export class TestimonialFormComponent implements OnInit, OnDestroy { this.initialExcerpt, this.initialContributor, this.initialInstitution, - this.initialWorkgroup, - ]; - const current: string[] = [this.title, this.text, this.excerpt, this.contributor, this.institution, this.workgroup]; - let setInteractionValue: boolean = false; + this.initialWorkgroup + ] + const current: string[] = [this.title, this.text, this.excerpt, this.contributor, this.institution, this.workgroup] + let setInteractionValue: boolean = false for (let i: number = 0; i < initial.length; i += 1) { if (initial[i] !== current[i]) { - setInteractionValue = true; - break; + setInteractionValue = true + break } } - this.userInteractedWithForm = setInteractionValue; + this.userInteractedWithForm = setInteractionValue if (this.userInteractedWithForm) { - this.setInitialData(); + this.setInitialData() } if (!this.autosaveTimer) { - this.autosaveLoop(); + this.autosaveLoop() } } getTestimonialData(): void { if ( - this.project_application.project_application_testimonial_draft_id - && !this.project_application.project_application_testimonial_submitted + this.project_application.project_application_testimonial_draft_id && + !this.project_application.project_application_testimonial_submitted ) { this.subscription.add( this.newsService.getTestimonial(this.project_application.project_application_id.toString()).subscribe( (result: any): void => { - this.adjustFormWithSavedData(result); - this.createFormGroup(); - this.initialLoadingSuccessful = true; + this.adjustFormWithSavedData(result) + this.createFormGroup() + this.initialLoadingSuccessful = true if (!this.project_application.project_application_testimonial_submitted) { - this.autosaveLoop(); + this.autosaveLoop() } }, (error: any): void => { if (error.error['other_user']) { - this.hideTestimonialForm = true; + this.hideTestimonialForm = true } else { - this.createFormGroup(); + this.createFormGroup() } - }, - ), - ); + } + ) + ) } else { - this.createFormGroup(); + this.createFormGroup() } } adjustFormWithSavedData(result: any): void { - this.title = result['title']; - this.text = result['testimonials_text']; - this.excerpt = result['excerpt']; - this.institution = result['institution']; - this.workgroup = result['workgroup']; - this.contributor = result['contributor']; - this.selectedSocialConsents = result['publication_channels']; + this.title = result['title'] + this.text = result['testimonials_text'] + this.excerpt = result['excerpt'] + this.institution = result['institution'] + this.workgroup = result['workgroup'] + this.contributor = result['contributor'] + this.selectedSocialConsents = result['publication_channels'] } stopAutosaveTimer(): void { if (this.autosaveTimer) { - clearTimeout(this.autosaveTimer); + clearTimeout(this.autosaveTimer) } } stopAutosaveStatusTimer(): void { if (this.autosaveStatusTimer) { - clearTimeout(this.autosaveStatusTimer); + clearTimeout(this.autosaveStatusTimer) } } startDisappearTimer(): void { this.autosaveStatusTimer = setTimeout((): void => { - this.showAutosaveSucess = false; - this.showAutosaveFail = false; - }, 5000); + this.showAutosaveSucess = false + this.showAutosaveFail = false + }, 5000) } autosaveLoop(timeout: number = this.autosaveTimeout): void { - this.stopAutosaveTimer(); + this.stopAutosaveTimer() this.autosaveTimer = setTimeout((): void => { if (this.userInteractedWithForm) { - this.autoSaveInProgress = true; - this.showAutosaveSucess = false; - this.stopAutosaveStatusTimer(); + this.autoSaveInProgress = true + this.showAutosaveSucess = false + this.stopAutosaveStatusTimer() this.subscription.add( this.newsService .autoSaveTestimonialDraft( @@ -232,42 +230,42 @@ export class TestimonialFormComponent implements OnInit, OnDestroy { this.workgroup, this.simple_vm, this.project_application.project_application_id.toString(), - this.selectedSocialConsents, + this.selectedSocialConsents ) .subscribe( (): void => { - this.autoSaveInProgress = false; - this.userInteractedWithForm = false; - this.showAutosaveSucess = true; - this.startDisappearTimer(); + this.autoSaveInProgress = false + this.userInteractedWithForm = false + this.showAutosaveSucess = true + this.startDisappearTimer() }, (error: any): void => { - this.autoSaveInProgress = false; - this.userInteractedWithForm = false; + this.autoSaveInProgress = false + this.userInteractedWithForm = false if (error.error['other_user']) { - this.hideTestimonialForm = true; + this.hideTestimonialForm = true } else { - this.showAutosaveFail = true; - this.startDisappearTimer(); - this.stopAutosaveTimer(); + this.showAutosaveFail = true + this.startDisappearTimer() + this.stopAutosaveTimer() } - }, - ), - ); + } + ) + ) } - this.autosaveLoop(); - }, timeout); + this.autosaveLoop() + }, timeout) } adjustFile(event): void { - const accepted: string[] = ['image/png', 'image/jpeg']; + const accepted: string[] = ['image/png', 'image/jpeg'] if (accepted.includes((event.target.files[0] as File).type)) { - this.file = event.target.files[0]; + this.file = event.target.files[0] } } sendTestimonial(): void { - this.testimonialSent = true; + this.testimonialSent = true this.subscription.add( this.newsService .sendTestimonialDraft( @@ -281,18 +279,18 @@ export class TestimonialFormComponent implements OnInit, OnDestroy { this.image_url, this.project_application.project_application_id.toString(), this.selectedSocialConsents, - this.file, + this.file ) .subscribe((result: any): any => { - this.submissionSuccessful = result['created']; - this.project_application.project_application_testimonial_submitted = true; - this.stopAutosaveTimer(); - this.testimonialModal.show(); - }), - ); + this.submissionSuccessful = result['created'] + this.project_application.project_application_testimonial_submitted = true + this.stopAutosaveTimer() + this.testimonialModal.show() + }) + ) } ngOnDestroy(): void { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } } diff --git a/src/app/shared/sidebar.directive.ts b/src/app/shared/sidebar.directive.ts index 8ad1fa1f02..5416bdab03 100644 --- a/src/app/shared/sidebar.directive.ts +++ b/src/app/shared/sidebar.directive.ts @@ -1,5 +1,5 @@ -// eslint-disable-next-line max-classes-per-file -import { Directive, HostListener } from '@angular/core'; + +import { Directive, HostListener } from '@angular/core' // tslint:disable @@ -7,39 +7,37 @@ import { Directive, HostListener } from '@angular/core'; * Allows the sidebar to be toggled via click. */ @Directive({ - selector: '[appSidebarToggler]', + selector: '[appSidebarToggler]' }) export class SidebarToggleDirective { - - @HostListener('click', ['$event']) toggleOpen($event: any) { - $event.preventDefault(); - document.querySelector('body').classList.toggle('sidebar-hidden'); + @HostListener('click', ['$event']) toggleOpen($event: any) { + $event.preventDefault() + document.querySelector('body').classList.toggle('sidebar-hidden') } } @Directive({ - selector: '[appSidebarMinimizer]', + selector: '[appSidebarMinimizer]' }) export class SidebarMinimizeDirective { - - @HostListener('click', ['$event']) toggleOpen($event: any) { - $event.preventDefault(); - document.querySelector('body').classList.toggle('sidebar-minimized'); + @HostListener('click', ['$event']) toggleOpen($event: any) { + $event.preventDefault() + document.querySelector('body').classList.toggle('sidebar-minimized') } } @Directive({ - selector: '[appMobileSidebarToggler]', + selector: '[appMobileSidebarToggler]' }) export class MobileSidebarToggleDirective { // Check if element has class private hasClass(target: any, elementClassName: string) { - return new RegExp(`(\\s|^)${elementClassName}(\\s|$)`).test(target.className); + return new RegExp(`(\\s|^)${elementClassName}(\\s|$)`).test(target.className) } - @HostListener('click', ['$event']) toggleOpen($event: any) { - $event.preventDefault(); - document.querySelector('body').classList.toggle('sidebar-mobile-show'); + @HostListener('click', ['$event']) toggleOpen($event: any) { + $event.preventDefault() + document.querySelector('body').classList.toggle('sidebar-mobile-show') } } @@ -47,35 +45,34 @@ export class MobileSidebarToggleDirective { * Allows the off-canvas sidebar to be closed via click. */ @Directive({ - selector: '[appSidebarClose]', + selector: '[appSidebarClose]' }) export class SidebarOffCanvasCloseDirective { - // Check if element has class private hasClass(target: any, elementClassName: string) { - return new RegExp(`(\\s|^)${elementClassName}(\\s|$)`).test(target.className); + return new RegExp(`(\\s|^)${elementClassName}(\\s|$)`).test(target.className) } // Toggle element class private toggleClass(elem: any, elementClassName: string) { - let newClass = ` ${elem.className.replace(/[\t\r\n]/g, ' ')} `; + let newClass = ` ${elem.className.replace(/[\t\r\n]/g, ' ')} ` if (this.hasClass(elem, elementClassName)) { while (newClass.indexOf(` ${elementClassName} `) >= 0) { - newClass = newClass.replace(` ${elementClassName} `, ' '); + newClass = newClass.replace(` ${elementClassName} `, ' ') } - // eslint-disable-next-line no-param-reassign - elem.className = newClass.replace(/^\s+|\s+$/g, ''); + + elem.className = newClass.replace(/^\s+|\s+$/g, '') } else { - // eslint-disable-next-line no-param-reassign - elem.className += ` ${elementClassName}`; + + elem.className += ` ${elementClassName}` } } - @HostListener('click', ['$event']) toggleOpen($event: any) { - $event.preventDefault(); + @HostListener('click', ['$event']) toggleOpen($event: any) { + $event.preventDefault() if (this.hasClass(document.querySelector('body'), 'sidebar-off-canvas')) { - this.toggleClass(document.querySelector('body'), 'sidebar-opened'); + this.toggleClass(document.querySelector('body'), 'sidebar-opened') } } } @@ -84,5 +81,5 @@ export const SIDEBAR_TOGGLE_DIRECTIVES = [ SidebarToggleDirective, SidebarMinimizeDirective, SidebarOffCanvasCloseDirective, - MobileSidebarToggleDirective, -]; + MobileSidebarToggleDirective +] diff --git a/src/app/shared/title-headbar.component.ts b/src/app/shared/title-headbar.component.ts index 859da8f3af..91a74f807c 100644 --- a/src/app/shared/title-headbar.component.ts +++ b/src/app/shared/title-headbar.component.ts @@ -1,5 +1,5 @@ -import { Component, Input } from '@angular/core'; -import { UserService } from '../api-connector/user.service'; +import { Component, Input } from '@angular/core' +import { UserService } from '../api-connector/user.service' /** * Title headbar component. @@ -7,21 +7,21 @@ import { UserService } from '../api-connector/user.service'; @Component({ templateUrl: 'title-headbar.component.html', selector: 'app-title-headbar', - providers: [UserService], + providers: [UserService] }) export class TitleHeadbarComponent { - @Input() page_title: string; - @Input() navbar_minimized: boolean; - brand_logo: string = 'static/webapp/assets/img/denbi-logo-color.svg'; - brand_logo_minimized: string = 'static/webapp/assets/img/denbi-logo-minimized.svg'; + @Input() page_title: string + @Input() navbar_minimized: boolean + brand_logo: string = 'static/webapp/assets/img/denbi-logo-color.svg' + brand_logo_minimized: string = 'static/webapp/assets/img/denbi-logo-minimized.svg' constructor(private userService: UserService) { - this.userService = userService; + this.userService = userService } logout(): void { this.userService.logoutUser().subscribe((redirect: any): void => { - window.location.href = redirect['redirect']; - }); + window.location.href = redirect['redirect'] + }) } } diff --git a/src/app/shared/toaster/information-toast.component.ts b/src/app/shared/toaster/information-toast.component.ts index 45aee8d98e..c8d027d9f4 100644 --- a/src/app/shared/toaster/information-toast.component.ts +++ b/src/app/shared/toaster/information-toast.component.ts @@ -1,37 +1,37 @@ -import { Component, Input, OnChanges } from '@angular/core'; +import { Component, Input, OnChanges } from '@angular/core' @Component({ selector: 'app-information-toast', templateUrl: './information-toast.component.html', - styleUrls: ['./information-toast.component.scss'], + styleUrls: ['./information-toast.component.scss'] }) export class InformationToastComponent implements OnChanges { - @Input() message: string = ''; - @Input() title: string = ''; - @Input() type: string = 'info'; + @Input() message: string = '' + @Input() title: string = '' + @Input() type: string = 'info' ngOnChanges() { - this.toggleToast(); + this.toggleToast() } - position = 'top'; - visible = false; - percentage = 0; + position = 'top' + visible = false + percentage = 0 toggleToast() { if (this.message !== '') { - this.visible = true; + this.visible = true } else { - this.visible = false; + this.visible = false } } onVisibleChange($event: boolean) { - this.visible = $event; - this.percentage = !this.visible ? 0 : this.percentage; + this.visible = $event + this.percentage = !this.visible ? 0 : this.percentage } onTimerChange($event: number) { - this.percentage = $event * 25; + this.percentage = $event * 25 } } diff --git a/src/app/userinfo/userinfo-routing.module.ts b/src/app/userinfo/userinfo-routing.module.ts index 25e60b3a49..078528d40f 100644 --- a/src/app/userinfo/userinfo-routing.module.ts +++ b/src/app/userinfo/userinfo-routing.module.ts @@ -1,24 +1,22 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { UserInfoComponent } from './userinfo.component'; +import { NgModule } from '@angular/core' +import { RouterModule, Routes } from '@angular/router' +import { UserInfoComponent } from './userinfo.component' const routes: Routes = [ { path: '', component: UserInfoComponent, data: { - title: 'Profile', - }, - - }, -]; + title: 'Profile' + } + } +] /** * Userinfo routing module. */ @NgModule({ imports: [RouterModule.forChild(routes)], - exports: [RouterModule], + exports: [RouterModule] }) -export class UserInfoRoutingModule { -} +export class UserInfoRoutingModule {} diff --git a/src/app/userinfo/userinfo.component.ts b/src/app/userinfo/userinfo.component.ts index fd98ce2725..d8c6b2c6c8 100644 --- a/src/app/userinfo/userinfo.component.ts +++ b/src/app/userinfo/userinfo.component.ts @@ -1,30 +1,28 @@ -import { - Component, EventEmitter, OnInit, inject, -} from '@angular/core'; -import { forkJoin } from 'rxjs'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { Userinfo } from './userinfo.model'; -import { ApiSettings } from '../api-connector/api-settings.service'; -import { KeyService } from '../api-connector/key.service'; -import { UserService } from '../api-connector/user.service'; -import { GroupService } from '../api-connector/group.service'; -import { IResponseTemplate } from '../api-connector/response-template'; +import { Component, EventEmitter, OnInit, inject } from '@angular/core' +import { forkJoin } from 'rxjs' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { MatomoTracker } from 'ngx-matomo-client' +import { Userinfo } from './userinfo.model' +import { ApiSettings } from '../api-connector/api-settings.service' +import { KeyService } from '../api-connector/key.service' +import { UserService } from '../api-connector/user.service' +import { GroupService } from '../api-connector/group.service' +import { IResponseTemplate } from '../api-connector/response-template' import { LIFESCIENCE_LINKING_ACCOUNTS, WIKI_LINK_ACCOUNTS, CLOUD_PORTAL_SUPPORT_MAIL, - LIFESCIENCE_PROFILE_CONSENT, -} from '../../links/links'; -import { ProjectEnumeration } from '../projectmanagement/project-enumeration'; -import { ApplicationsService } from '../api-connector/applications.service'; -import { VirtualmachineService } from '../api-connector/virtualmachine.service'; -import { VirtualMachine } from '../virtualmachines/virtualmachinemodels/virtualmachine'; -import { VirtualMachineStates } from '../virtualmachines/virtualmachinemodels/virtualmachinestates'; -import { Application } from '../applications/application.model/application.model'; -import { ProjectMember } from '../projectmanagement/project_member.model'; -import { Application_States } from '../shared/shared_modules/baseClass/abstract-base-class'; -import { NotificationModalComponent } from '../shared/modal/notification-modal'; + LIFESCIENCE_PROFILE_CONSENT +} from '../../links/links' +import { ProjectEnumeration } from '../projectmanagement/project-enumeration' +import { ApplicationsService } from '../api-connector/applications.service' +import { VirtualmachineService } from '../api-connector/virtualmachine.service' +import { VirtualMachine } from '../virtualmachines/virtualmachinemodels/virtualmachine' +import { VirtualMachineStates } from '../virtualmachines/virtualmachinemodels/virtualmachinestates' +import { Application } from '../applications/application.model/application.model' +import { ProjectMember } from '../projectmanagement/project_member.model' +import { Application_States } from '../shared/shared_modules/baseClass/abstract-base-class' +import { NotificationModalComponent } from '../shared/modal/notification-modal' /** * UserInformation component. @@ -32,98 +30,99 @@ import { NotificationModalComponent } from '../shared/modal/notification-modal'; @Component({ selector: 'app-userinfo', templateUrl: 'userinfo.component.html', - providers: [GroupService, UserService, ApiSettings, KeyService], + providers: [GroupService, UserService, ApiSettings, KeyService] }) export class UserInfoComponent implements OnInit { - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL /** * Information of the logged-in User */ - userInfo: Userinfo; + userInfo: Userinfo /** * If the user has subscribed to the newsletter. */ - newsletterSubscribed: boolean; + newsletterSubscribed: boolean /** * New requested public key. */ - newPublicKey: string; + newPublicKey: string /** * If every data is loaded. * * @type {boolean} */ - isLoaded: boolean = false; + isLoaded: boolean = false /** * If the data used for a summary of leave-vo-modal is collected * * @type {boolean} */ - summaryLoaded: boolean = false; + summaryLoaded: boolean = false - summaryError: boolean = false; + summaryError: boolean = false - userHasNoGroups: boolean = false; + userHasNoGroups: boolean = false - userIsProjectPi: boolean = false; + userIsProjectPi: boolean = false - userIsLoneAdmin: boolean = false; + userIsLoneAdmin: boolean = false - userIsOpenStackUser: boolean = false; + userIsOpenStackUser: boolean = false - leavingSucceeded: boolean = false; + leavingSucceeded: boolean = false /** * summary of projects the user is member of * * @type {Application[]} */ - userProjects: Application[] = []; + userProjects: Application[] = [] /** * summary of vms the user has * * @type {VirtualMachine[]} */ - userVirtualMachines: VirtualMachine[] = []; + userVirtualMachines: VirtualMachine[] = [] /** * If the user is part of a project. * * @type {boolean} */ - isProjectMember: boolean = true; + isProjectMember: boolean = true /** * If freemium is active. * * @type {boolean} */ - freemiumActive: boolean = false; + freemiumActive: boolean = false /** * Email requested to change. */ - emailChange: string; + emailChange: string - title: string = 'Profile'; + title: string = 'Profile' /** * Text refering to newsletter registration */ - dsgvo_text: string = 'By activating this option, you agree that your preferred e-mail address may be used for the newsletter. ' - + 'You will receive the newsletter until you deactivate the option in the settings again.'; - WIKI_LINK_ACCOUNTS: string = WIKI_LINK_ACCOUNTS; - LIFESCIENCE_LINKING_ACCOUNTS: string = LIFESCIENCE_LINKING_ACCOUNTS; - LIFESCIENCE_PROFILE_CONSENT: string = LIFESCIENCE_PROFILE_CONSENT; + dsgvo_text: string = + 'By activating this option, you agree that your preferred e-mail address may be used for the newsletter. ' + + 'You will receive the newsletter until you deactivate the option in the settings again.' + WIKI_LINK_ACCOUNTS: string = WIKI_LINK_ACCOUNTS + LIFESCIENCE_LINKING_ACCOUNTS: string = LIFESCIENCE_LINKING_ACCOUNTS + LIFESCIENCE_PROFILE_CONSENT: string = LIFESCIENCE_PROFILE_CONSENT - confirmEventEmitter: EventEmitter = new EventEmitter(); + confirmEventEmitter: EventEmitter = new EventEmitter() - private readonly tracker = inject(MatomoTracker); + private readonly tracker = inject(MatomoTracker) constructor( private groupService: GroupService, @@ -131,150 +130,150 @@ export class UserInfoComponent implements OnInit { private keyService: KeyService, private applicationsService: ApplicationsService, private vmService: VirtualmachineService, - private modalService: BsModalService, + private modalService: BsModalService ) { - this.groupService = groupService; - this.userService = userService; - this.keyService = keyService; - this.applicationsService = applicationsService; - this.vmService = vmService; + this.groupService = groupService + this.userService = userService + this.keyService = keyService + this.applicationsService = applicationsService + this.vmService = vmService } emitConfirmation() { - this.confirmEventEmitter.emit(); + this.confirmEventEmitter.emit() } requestChangePreferredMailUser(email: string): void { this.userService.requestChangePreferredMailUser(email).subscribe((): void => { - this.getPendingPreferredMailUser(); - }); + this.getPendingPreferredMailUser() + }) } getPendingPreferredMailUser(): void { this.userService.getPendingPreferredMailUser().subscribe((res: IResponseTemplate): void => { - this.userInfo.PendingEmails = res.value as string[]; - }); + this.userInfo.PendingEmails = res.value as string[] + }) } ngOnInit(): void { - this.tracker.trackPageView('User Info'); - this.getUserinfo(); - this.isFreemiumActive(); - this.isUserSimpleVmMember(); + this.tracker.trackPageView('User Info') + this.getUserinfo() + this.isFreemiumActive() + this.isUserSimpleVmMember() } isFreemiumActive(): void { this.groupService.isFreemiumActive().subscribe((result: IResponseTemplate): void => { - this.freemiumActive = result.value as boolean; - }); + this.freemiumActive = result.value as boolean + }) } importKey(publicKey: string): void { - const re: RegExp = /\+/gi; + const re: RegExp = /\+/gi this.keyService.postKey(publicKey.replace(re, '%2B')).subscribe((): void => { - this.getUserPublicKey(); - }); + this.getUserPublicKey() + }) } getUserPublicKey(): void { this.keyService.getKey().subscribe((key: IResponseTemplate): void => { - this.userInfo.PublicKey = key.value as string; - this.isLoaded = true; - }); + this.userInfo.PublicKey = key.value as string + this.isLoaded = true + }) } getUserinfo(): void { this.userService.getUserInfo().subscribe((userinfo: Userinfo): void => { - this.userInfo = userinfo; - this.title = this.title.concat(': ', this.userInfo.FirstName, ' ', this.userInfo.LastName); + this.userInfo = userinfo + this.title = this.title.concat(': ', this.userInfo.FirstName, ' ', this.userInfo.LastName) forkJoin(this.userService.getNewsletterSubscription(), this.userService.getPendingPreferredMailUser()).subscribe( (res: IResponseTemplate[]): void => { - this.newsletterSubscribed = res[0].value as boolean; - this.userInfo.PendingEmails = res[1].value as string[]; + this.newsletterSubscribed = res[0].value as boolean + this.userInfo.PendingEmails = res[1].value as string[] - this.isLoaded = true; - }, - ); - }); + this.isLoaded = true + } + ) + }) } isUserSimpleVmMember(): void { this.groupService.getSimpleVmByUser().subscribe((result: any): void => { - this.isProjectMember = result.length > 0; - }); + this.isProjectMember = result.length > 0 + }) } setNewsletterSubscription(): void { if (this.newsletterSubscribed) { - this.userService.setNewsletterSubscriptionWhenSubscribed().subscribe(); + this.userService.setNewsletterSubscriptionWhenSubscribed().subscribe() } else { - this.userService.setNewsletterSubscriptionWhenNotSubscribed().subscribe(); + this.userService.setNewsletterSubscriptionWhenNotSubscribed().subscribe() } } validatePublicKey(): boolean { - return /ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(this.newPublicKey); + return /ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(this.newPublicKey) } joinFreemium(): void { - this.groupService.addMemberToFreemium().subscribe(); + this.groupService.addMemberToFreemium().subscribe() } isUserPi(): boolean { - return this.userProjects.some((app: Application) => app.user_is_pi); + return this.userProjects.some((app: Application) => app.user_is_pi) } isUserLoneAdmin(userId: number, userProjectMembers: ProjectMember[][]): boolean { for (const project_members of userProjectMembers) { - const groupAdmins: ProjectMember[] = project_members.filter((singleMember: ProjectMember) => singleMember.isAdmin); + const groupAdmins: ProjectMember[] = project_members.filter((singleMember: ProjectMember) => singleMember.isAdmin) if (groupAdmins.length === 1) { if (groupAdmins[0].userId.toString() === userId.toString()) { - return true; + return true } } } - return false; + return false } isOpenStackUser(): boolean { - return this.userProjects.some((app: Application) => app.project_application_openstack_project); + return this.userProjects.some((app: Application) => app.project_application_openstack_project) } leaveVirtualOrganisation(): void { this.userService.deleteUserFromVO(this.userInfo.MemberId).subscribe({ next: () => { - this.showLeaveResultModal(true); + this.showLeaveResultModal(true) }, error: () => { - this.showLeaveResultModal(false); - }, - }); + this.showLeaveResultModal(false) + } + }) } showLeaveResultModal(success: boolean): void { - // eslint-disable-next-line no-shadow,@typescript-eslint/no-shadow + const initialState = { notificationModalTitle: success ? 'Success' : 'An error occured', notificationModalType: success ? 'info' : 'danger', notificationModalMessage: success ? 'You have successfully ended your membership in the de.NBI VO. Press the button below to logout!' - : 'An error occurred while requesting the end of your VO membership. Please try again or contact our helpdesk!', - }; - const openedModal: BsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); + : 'An error occurred while requesting the end of your VO membership. Please try again or contact our helpdesk!' + } + const openedModal: BsModalRef = this.modalService.show(NotificationModalComponent, { initialState }) openedModal.onHide.subscribe({ next: () => { if (success) { this.userService.logoutUser().subscribe((redirect: any): void => { - window.location.href = redirect['redirect']; - }); + window.location.href = redirect['redirect'] + }) } }, - error: (): any => {}, - }); + error: (): any => {} + }) } /** @@ -282,11 +281,11 @@ export class UserInfoComponent implements OnInit { * @param userProjectMembers */ transformUserResults(userProjectMembers: ProjectMember[][]): void { - this.userIsProjectPi = this.isUserPi(); - this.userIsLoneAdmin = this.isUserLoneAdmin(this.userInfo.Id, userProjectMembers); - this.userIsOpenStackUser = this.isOpenStackUser(); - this.summaryError = false; - this.summaryLoaded = true; + this.userIsProjectPi = this.isUserPi() + this.userIsLoneAdmin = this.isUserLoneAdmin(this.userInfo.Id, userProjectMembers) + this.userIsOpenStackUser = this.isOpenStackUser() + this.summaryError = false + this.summaryLoaded = true } /** @@ -296,48 +295,50 @@ export class UserInfoComponent implements OnInit { if (!this.summaryLoaded) { this.groupService.getGroupsEnumeration().subscribe({ next: (res_enumerations: ProjectEnumeration[]) => { - const application_ids: string[] = res_enumerations.map((pr: ProjectEnumeration) => pr.application_id); + const application_ids: string[] = res_enumerations.map((pr: ProjectEnumeration) => pr.application_id) if (application_ids.length > 0) { forkJoin( - application_ids.map(app_id => this.applicationsService.getFullApplicationByUserPermissions(app_id)), + application_ids.map(app_id => this.applicationsService.getFullApplicationByUserPermissions(app_id)) ).subscribe({ next: (userProjectResult: Application[]) => { - this.userProjects = userProjectResult; + this.userProjects = userProjectResult const group_ids: string[] = this.userProjects - .filter((pr_app: Application) => pr_app.project_application_statuses.includes(Application_States.APPROVED)) - .map((user_application: Application) => user_application.project_application_perun_id.toString()); + .filter((pr_app: Application) => + pr_app.project_application_statuses.includes(Application_States.APPROVED) + ) + .map((user_application: Application) => user_application.project_application_perun_id.toString()) forkJoin(group_ids.map(group_id => this.groupService.getGroupMembers(group_id))).subscribe({ next: (project_members: ProjectMember[][]) => { - this.transformUserResults(project_members); - }, - }); - }, - }); + this.transformUserResults(project_members) + } + }) + } + }) const vmFilter: string[] = [ VirtualMachineStates.ACTIVE, VirtualMachineStates.SHUTOFF, - VirtualMachineStates.CLIENT_OFFLINE, - ]; - VirtualMachineStates.IN_PROCESS_STATES.forEach((state: string) => vmFilter.push(state)); + VirtualMachineStates.CLIENT_OFFLINE + ] + VirtualMachineStates.IN_PROCESS_STATES.forEach((state: string) => vmFilter.push(state)) this.vmService.getVmsFromLoggedInUser(0, 25, '', vmFilter, false, false, true).subscribe({ next: (res: VirtualMachine[]) => { - this.userVirtualMachines = res; - this.summaryError = false; + this.userVirtualMachines = res + this.summaryError = false }, error: () => { - this.summaryError = true; - }, - }); + this.summaryError = true + } + }) } else { - this.userHasNoGroups = true; - this.summaryError = false; - this.summaryLoaded = true; + this.userHasNoGroups = true + this.summaryError = false + this.summaryLoaded = true } }, error: () => { - this.summaryError = true; - }, - }); + this.summaryError = true + } + }) } } } diff --git a/src/app/userinfo/userinfo.module.ts b/src/app/userinfo/userinfo.module.ts index dc95c0ca13..9e77dc7ab9 100644 --- a/src/app/userinfo/userinfo.module.ts +++ b/src/app/userinfo/userinfo.module.ts @@ -1,14 +1,14 @@ -import { NgModule } from '@angular/core'; +import { NgModule } from '@angular/core' -import { TabsModule } from 'ngx-bootstrap/tabs'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { ModalModule } from 'ngx-bootstrap/modal'; -import { AlertModule } from 'ngx-bootstrap/alert'; -import { UserInfoRoutingModule } from './userinfo-routing.module'; -import { UserInfoComponent } from './userinfo.component'; -import { PublicKeyModule } from '../shared/shared_modules/public-key/public-key.module'; -import { NewsModule } from '../news/news.module'; +import { TabsModule } from 'ngx-bootstrap/tabs' +import { CommonModule } from '@angular/common' +import { FormsModule } from '@angular/forms' +import { ModalModule } from 'ngx-bootstrap/modal' +import { AlertModule } from 'ngx-bootstrap/alert' +import { UserInfoRoutingModule } from './userinfo-routing.module' +import { UserInfoComponent } from './userinfo.component' +import { PublicKeyModule } from '../shared/shared_modules/public-key/public-key.module' +import { NewsModule } from '../news/news.module' /** * Userinfo module. @@ -19,14 +19,13 @@ import { NewsModule } from '../news/news.module'; UserInfoRoutingModule, TabsModule, CommonModule, - FormsModule, ModalModule.forRoot(), - AlertModule.forRoot(), NewsModule, + FormsModule, + ModalModule.forRoot(), + AlertModule.forRoot(), + NewsModule ], - declarations: [ - UserInfoComponent, - ], - exports: [UserInfoComponent, UserInfoRoutingModule, TabsModule, CommonModule, FormsModule, ModalModule, AlertModule], + declarations: [UserInfoComponent], + exports: [UserInfoComponent, UserInfoRoutingModule, TabsModule, CommonModule, FormsModule, ModalModule, AlertModule] }) -export class UserinfoModule { -} +export class UserinfoModule {} diff --git a/src/app/validation-application/validation-application.component.ts b/src/app/validation-application/validation-application.component.ts index 1dcfb1f8af..4161399656 100644 --- a/src/app/validation-application/validation-application.component.ts +++ b/src/app/validation-application/validation-application.component.ts @@ -1,12 +1,10 @@ -import { - AfterViewChecked, ChangeDetectorRef, Component, OnInit, inject, -} from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { ApplicationsService } from '../api-connector/applications.service'; -import { Application } from '../applications/application.model/application.model'; -import { ApplicationBaseClassComponent } from '../shared/shared_modules/baseClass/application-base-class.component'; -import { FlavorService } from '../api-connector/flavor.service'; +import { AfterViewChecked, ChangeDetectorRef, Component, OnInit, inject } from '@angular/core' +import { ActivatedRoute } from '@angular/router' +import { MatomoTracker } from 'ngx-matomo-client' +import { ApplicationsService } from '../api-connector/applications.service' +import { Application } from '../applications/application.model/application.model' +import { ApplicationBaseClassComponent } from '../shared/shared_modules/baseClass/application-base-class.component' +import { FlavorService } from '../api-connector/flavor.service' /** * Application validation modal. */ @@ -14,59 +12,59 @@ import { FlavorService } from '../api-connector/flavor.service'; selector: 'app-validation-application', templateUrl: './validation-application.component.html', styleUrls: ['./validation-application.component.scss'], - providers: [ApplicationsService, FlavorService], + providers: [ApplicationsService, FlavorService] }) export class ValidationApplicationComponent extends ApplicationBaseClassComponent implements OnInit, AfterViewChecked { - private readonly tracker = inject(MatomoTracker); - application: Application; - isLoadedApplication: boolean = false; - hash: string; - validated: boolean = false; - title: string; + private readonly tracker = inject(MatomoTracker) + application: Application + isLoadedApplication: boolean = false + hash: string + validated: boolean = false + title: string /** * Total number of cores. * * @type {number} */ - public totalNumberOfCores: number = 0; + public totalNumberOfCores: number = 0 /** * Total number of ram. * * @type {number} */ - public totalRAM: number = 0; + public totalRAM: number = 0 constructor( applicationsService: ApplicationsService, private activatedRoute: ActivatedRoute, - private changeDetector: ChangeDetectorRef, + private changeDetector: ChangeDetectorRef ) { - super(null, applicationsService, null, changeDetector); + super(null, applicationsService, null, changeDetector) } ngAfterViewChecked(): void { - this.changeDetector.detectChanges(); + this.changeDetector.detectChanges() } ngOnInit(): void { this.activatedRoute.params.subscribe((paramsId: any): void => { - this.hash = paramsId.hash; - this.tracker.trackPageView(`Application validation for hash: ${paramsId.hash}`); + this.hash = paramsId.hash + this.tracker.trackPageView(`Application validation for hash: ${paramsId.hash}`) this.applicationsService.getApplicationValidationByHash(this.hash).subscribe( (app: Application): void => { - this.application = new Application(app); + this.application = new Application(app) if (this.application.project_application_openstack_project) { - this.title = 'Cloud Project Application Validation'; + this.title = 'Cloud Project Application Validation' } else { - this.title = 'Simple VM Project Application Validation'; + this.title = 'Simple VM Project Application Validation' } - this.isLoadedApplication = true; + this.isLoadedApplication = true }, (): void => { - this.isLoadedApplication = true; - }, - ); - }); + this.isLoadedApplication = true + } + ) + }) } } diff --git a/src/app/virtualmachines/addvm.component.ts b/src/app/virtualmachines/addvm.component.ts index 9c927ed1bb..ba8646872f 100644 --- a/src/app/virtualmachines/addvm.component.ts +++ b/src/app/virtualmachines/addvm.component.ts @@ -1,42 +1,40 @@ -import { - Component, DoCheck, OnDestroy, OnInit, ViewChild, inject, -} from '@angular/core'; -import { forkJoin, Subscription } from 'rxjs'; -import { Router } from '@angular/router'; +import { Component, DoCheck, OnDestroy, OnInit, ViewChild, inject } from '@angular/core' +import { forkJoin, Subscription } from 'rxjs' +import { Router } from '@angular/router' import { CLOUD_PORTAL_SUPPORT_MAIL, STATUS_LINK, WIKI_EPHEMERAL_LINK, WIKI_MOSH_LINK, WIKI_PERSISTENT_TERMINAL_LINK, - WIKI_VOLUME_OVERVIEW, -} from 'links/links'; -import { KeyValue } from '@angular/common'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { Image } from './virtualmachinemodels/image'; -import { Flavor } from './virtualmachinemodels/flavor'; -import { Userinfo } from '../userinfo/userinfo.model'; -import { environment } from '../../environments/environment'; -import { IResponseTemplate } from '../api-connector/response-template'; -import { Client } from '../vo_manager/clients/client.model'; -import { VirtualMachine } from './virtualmachinemodels/virtualmachine'; -import { BiocondaComponent } from './conda/bioconda.component'; -import { ResEnvComponent } from './conda/res-env.component'; -import { is_vo } from '../shared/globalvar'; -import { RandomNameGenerator } from '../shared/randomNameGenerator'; -import { Volume } from './volumes/volume'; -import { UserService } from '../api-connector/user.service'; -import { GroupService } from '../api-connector/group.service'; -import { KeyService } from '../api-connector/key.service'; -import { FlavorService } from '../api-connector/flavor.service'; -import { BiocondaService } from '../api-connector/bioconda.service'; -import { VirtualmachineService } from '../api-connector/virtualmachine.service'; -import { ApiSettings } from '../api-connector/api-settings.service'; -import { BlockedImageTagResenv } from '../facility_manager/image-tag'; -import { ApplicationRessourceUsage } from '../applications/application-ressource-usage/application-ressource-usage'; -import { ProjectMember } from '../projectmanagement/project_member.model'; -import { ApplicationsService } from '../api-connector/applications.service'; -import { ImageService } from '../api-connector/image.service'; + WIKI_VOLUME_OVERVIEW +} from 'links/links' +import { KeyValue } from '@angular/common' +import { MatomoTracker } from 'ngx-matomo-client' +import { Image } from './virtualmachinemodels/image' +import { Flavor } from './virtualmachinemodels/flavor' +import { Userinfo } from '../userinfo/userinfo.model' +import { environment } from '../../environments/environment' +import { IResponseTemplate } from '../api-connector/response-template' +import { Client } from '../vo_manager/clients/client.model' +import { VirtualMachine } from './virtualmachinemodels/virtualmachine' +import { BiocondaComponent } from './conda/bioconda.component' +import { ResEnvComponent } from './conda/res-env.component' +import { is_vo } from '../shared/globalvar' +import { RandomNameGenerator } from '../shared/randomNameGenerator' +import { Volume } from './volumes/volume' +import { UserService } from '../api-connector/user.service' +import { GroupService } from '../api-connector/group.service' +import { KeyService } from '../api-connector/key.service' +import { FlavorService } from '../api-connector/flavor.service' +import { BiocondaService } from '../api-connector/bioconda.service' +import { VirtualmachineService } from '../api-connector/virtualmachine.service' +import { ApiSettings } from '../api-connector/api-settings.service' +import { BlockedImageTagResenv } from '../facility_manager/image-tag' +import { ApplicationRessourceUsage } from '../applications/application-ressource-usage/application-ressource-usage' +import { ProjectMember } from '../projectmanagement/project_member.model' +import { ApplicationsService } from '../api-connector/applications.service' +import { ImageService } from '../api-connector/image.service' /** * Start virtualmachine component. @@ -53,199 +51,199 @@ import { ImageService } from '../api-connector/image.service'; UserService, ApplicationsService, BiocondaService, - ImageService, - ], + ImageService + ] }) export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { - private readonly tracker = inject(MatomoTracker); - SIXTY_SIX_PERCENT: number = 66; - - SEVENTY_FIVE: number = 75; - ACTIVE: string = 'ACTIVE'; - DELETED: string = 'DELETED'; - PORT_CLOSED: string = 'PORT_CLOSED'; - PREPARE_PLAYBOOK_BUILD: string = 'PREPARE_PLAYBOOK_BUILD'; - CREATING_STATUS: string = 'Creating...'; - CHECKING_PORT_STATUS: string = 'Checking Connection..'; - PREPARE_PLAYBOOK_STATUS: string = 'Prepare Playbook Build...'; - ANIMATED_PROGRESS_BAR: string = 'progress-bar-animated'; - redirectProgress: string = '0'; - newVm: VirtualMachine = null; - members_to_add: ProjectMember[] = []; - progress_bar_status: string = 'Creating..'; - progress_bar_animated: string = 'progress-bar-animated'; - progress_bar_width: number = 0; - http_allowed: boolean = false; - https_allowed: boolean = false; - udp_allowed: boolean = false; - install_mosh: boolean = false; - vm_responsibility: boolean = false; - is_vo: boolean = false; - hasTools: boolean = false; - gaveOkay: boolean = false; - client_checked: boolean = false; - playbook_run: number = 0; - timeout: number = 0; - has_forc: boolean = false; - WIKI_VOLUME_OVERVIEW: string = WIKI_VOLUME_OVERVIEW; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - STATUS_LINK: string = STATUS_LINK; - WIKI_EPHEMERAL_LINK: string = WIKI_EPHEMERAL_LINK; - WIKI_MOSH_LINK: string = WIKI_MOSH_LINK; - WIKI_PERSISTENT_TERMINAL_LINK = WIKI_PERSISTENT_TERMINAL_LINK; - blockedImageTagsResenv: BlockedImageTagResenv[]; - initial_loaded: boolean = false; - - forc_url: string = ''; - client_id: string; - mosh_mode_available: boolean = false; - resenvSelected: boolean = false; - resEnvValid: boolean = true; - resEnvNeedsName: boolean = false; - resEnvNeedsTemplate: boolean = false; - resEnvOkayNeeded: boolean = false; - volumesToMount: Volume[] = []; - volumesToAttach: Volume[] = []; - - title: string = 'New Instance'; - - vm_name: string; - - started_machine: boolean = false; - - conda_img_path: string = 'static/webapp/assets/img/conda_logo.svg'; - - singleProject: boolean = false; - - showAddVol: boolean = false; - - flavors_loaded: boolean = false; - error_starting_machine: boolean = false; - - create_error: IResponseTemplate; - - selectedProjectIsMigrated: boolean = false; + private readonly tracker = inject(MatomoTracker) + SIXTY_SIX_PERCENT: number = 66 + + SEVENTY_FIVE: number = 75 + ACTIVE: string = 'ACTIVE' + DELETED: string = 'DELETED' + PORT_CLOSED: string = 'PORT_CLOSED' + PREPARE_PLAYBOOK_BUILD: string = 'PREPARE_PLAYBOOK_BUILD' + CREATING_STATUS: string = 'Creating...' + CHECKING_PORT_STATUS: string = 'Checking Connection..' + PREPARE_PLAYBOOK_STATUS: string = 'Prepare Playbook Build...' + ANIMATED_PROGRESS_BAR: string = 'progress-bar-animated' + redirectProgress: string = '0' + newVm: VirtualMachine = null + members_to_add: ProjectMember[] = [] + progress_bar_status: string = 'Creating..' + progress_bar_animated: string = 'progress-bar-animated' + progress_bar_width: number = 0 + http_allowed: boolean = false + https_allowed: boolean = false + udp_allowed: boolean = false + install_mosh: boolean = false + vm_responsibility: boolean = false + is_vo: boolean = false + hasTools: boolean = false + gaveOkay: boolean = false + client_checked: boolean = false + playbook_run: number = 0 + timeout: number = 0 + has_forc: boolean = false + WIKI_VOLUME_OVERVIEW: string = WIKI_VOLUME_OVERVIEW + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + STATUS_LINK: string = STATUS_LINK + WIKI_EPHEMERAL_LINK: string = WIKI_EPHEMERAL_LINK + WIKI_MOSH_LINK: string = WIKI_MOSH_LINK + WIKI_PERSISTENT_TERMINAL_LINK = WIKI_PERSISTENT_TERMINAL_LINK + blockedImageTagsResenv: BlockedImageTagResenv[] + initial_loaded: boolean = false + + forc_url: string = '' + client_id: string + mosh_mode_available: boolean = false + resenvSelected: boolean = false + resEnvValid: boolean = true + resEnvNeedsName: boolean = false + resEnvNeedsTemplate: boolean = false + resEnvOkayNeeded: boolean = false + volumesToMount: Volume[] = [] + volumesToAttach: Volume[] = [] + + title: string = 'New Instance' + + vm_name: string + + started_machine: boolean = false + + conda_img_path: string = 'static/webapp/assets/img/conda_logo.svg' + + singleProject: boolean = false + + showAddVol: boolean = false + + flavors_loaded: boolean = false + error_starting_machine: boolean = false + + create_error: IResponseTemplate + + selectedProjectIsMigrated: boolean = false /** * All flavors of a project. */ - flavors: Flavor[] = []; - selected_flavor_types: Flavor[] = []; - selected_flavor_type: string = 'Standard Flavors'; + flavors: Flavor[] = [] + selected_flavor_types: Flavor[] = [] + selected_flavor_type: string = 'Standard Flavors' - flavor_types: { [name: string]: Flavor[] } = {}; + flavor_types: { [name: string]: Flavor[] } = {} /** * Selected Image. */ - selectedImage: Image; + selectedImage: Image /** * Selected Flavor. */ - selectedFlavor: Flavor; + selectedFlavor: Flavor /** * Userinfo from the user. */ - userinfo: Userinfo; + userinfo: Userinfo /** * Selected Project vms client. */ - selectedProjectClient: Client; - - detached_project_volumes: Volume[] = []; - selected_detached_vol: Volume; - undefined_detached_vol: Volume = new Volume(); - newCores: number = 0; - newRam: number = 0; - newVms: number = 0; - newGpus: number = 0; - cluster_allowed: boolean = false; - current_key_blocked: boolean = false; - selectedProjectRessources: ApplicationRessourceUsage; + selectedProjectClient: Client + + detached_project_volumes: Volume[] = [] + selected_detached_vol: Volume + undefined_detached_vol: Volume = new Volume() + newCores: number = 0 + newRam: number = 0 + newVms: number = 0 + newGpus: number = 0 + cluster_allowed: boolean = false + current_key_blocked: boolean = false + selectedProjectRessources: ApplicationRessourceUsage /** * The selected project ['name',id]. */ - selectedProject: [string, number]; + selectedProject: [string, number] /** * If the client for a project is viable. */ - client_available: boolean = false; - showAttachVol: boolean = false; - credits_allowed: boolean = false; + client_available: boolean = false + showAttachVol: boolean = false + credits_allowed: boolean = false /** * Default volume name. * * @type {string} */ - volumeName: string = ''; - volumeMountPath: string; + volumeName: string = '' + volumeMountPath: string /** * Default volumeStorage. * * @type {number} */ - volumeStorage: number = 0; + volumeStorage: number = 0 /** * Indicates whether the projects of the user are loaded or not. * @type {boolean} */ - projects_loaded: boolean; + projects_loaded: boolean /** * Indicates whether the information about the user are loaded or not. * @type {boolean} */ - userinfo_loaded: boolean; + userinfo_loaded: boolean /** * All projects of the user. * * @type {any[]} */ - projects: [string, number][] = []; + projects: [string, number][] = [] /** * All projects in which the user is allowed to start machines. * * @type {any[]} */ - allowedProjects: [string, number][] = []; + allowedProjects: [string, number][] = [] /** * If all project data is loaded. * * @type {boolean} */ - projectDataLoaded: boolean = false; + projectDataLoaded: boolean = false /** * id of the freemium project. * * @type {number} */ - FREEMIUM_ID: number = environment.freemium_project_id; + FREEMIUM_ID: number = environment.freemium_project_id - prod: boolean = environment.production; - subscription: Subscription = new Subscription(); + prod: boolean = environment.production + subscription: Subscription = new Subscription() /** * Time for the check status loop. * * @type {number} */ - private checkStatusTimeout: number = 5000; + private checkStatusTimeout: number = 5000 - @ViewChild('bioconda') biocondaComponent: BiocondaComponent; - @ViewChild('resEnv') resEnvComponent: ResEnvComponent; + @ViewChild('bioconda') biocondaComponent: BiocondaComponent + @ViewChild('resEnv') resEnvComponent: ResEnvComponent constructor( private groupService: GroupService, @@ -256,9 +254,9 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { private userService: UserService, private router: Router, private condaService: BiocondaService, - private applicationsService: ApplicationsService, + private applicationsService: ApplicationsService ) { - // eslint-disable-next-line no-empty-function + } /** @@ -270,30 +268,30 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { this.subscription.add( this.flavorService.getFlavors(project_id).subscribe( (flavors: Flavor[]): void => { - this.flavors = flavors; - this.flavor_types = this.flavorService.sortFlavors(this.flavors); - this.flavors_loaded = true; - this.initial_loaded = true; + this.flavors = flavors + this.flavor_types = this.flavorService.sortFlavors(this.flavors) + this.flavors_loaded = true + this.initial_loaded = true }, (error: any) => { - console.log(error); - this.flavors = []; - this.flavor_types = {}; - this.flavors_loaded = true; - this.initial_loaded = true; - }, - ), - ); + console.log(error) + this.flavors = [] + this.flavor_types = {} + this.flavors_loaded = true + this.initial_loaded = true + } + ) + ) } setCurrentKeyBlocked(value: boolean): void { - this.current_key_blocked = value; + this.current_key_blocked = value } reloadFlavors(): void { - this.flavors_loaded = false; - this.selectedFlavor = undefined; - this.getFlavors(this.selectedProject[1]); + this.flavors_loaded = false + this.selectedFlavor = undefined + this.getFlavors(this.selectedProject[1]) } getDetachedVolumesByProject(): void { @@ -301,29 +299,29 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { this.virtualmachineservice .getDetachedVolumesByProject(this.selectedProject[1]) .subscribe((detached_volumes: Volume[]): void => { - this.detached_project_volumes = detached_volumes; - }), - ); + this.detached_project_volumes = detached_volumes + }) + ) } checkIfMountPathIsUsable(path?: string): boolean { if (path) { for (const vol of this.volumesToMount) { if (vol.volume_path === path) { - return false; + return false } } for (const vol of this.volumesToAttach) { if (vol.volume_path === path) { - return false; + return false } } - return true; + return true } - return false; + return false } /** @@ -332,14 +330,14 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { checkInputVolumeString(text?: string): boolean { if (text) { if (!(text.length > 0)) { - return false; + return false } - // eslint-disable-next-line prefer-regex-literals - return new RegExp('^[\\w]+$', 'i').test(text); + + return new RegExp('^[\\w]+$', 'i').test(text) } - return false; + return false } /** @@ -349,19 +347,19 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { */ checkStorageNumber(): boolean { if (!(this.volumeStorage > 0)) { - return false; - // eslint-disable-next-line max-len + return false + } else { return ( - this.selectedProjectRessources.used_volume_storage + this.getStorageInList() + this.volumeStorage - <= this.selectedProjectRessources.max_volume_storage - ); + this.selectedProjectRessources.used_volume_storage + this.getStorageInList() + this.volumeStorage <= + this.selectedProjectRessources.max_volume_storage + ) } } // eslint-disable-next-line @typescript-eslint/no-unused-vars unsorted(a: KeyValue, b: KeyValue): number { - return 0; + return 0 } /** @@ -370,52 +368,52 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { */ checkVolumeValidity(): boolean { return ( - this.checkStorageNumber() - && this.checkIfMountPathIsUsable(this.volumeMountPath) - && this.checkInputVolumeString(this.volumeMountPath) - && this.checkInputVolumeString(this.volumeName) - ); + this.checkStorageNumber() && + this.checkIfMountPathIsUsable(this.volumeMountPath) && + this.checkInputVolumeString(this.volumeMountPath) && + this.checkInputVolumeString(this.volumeName) + ) } /** * Adds a new volume to the list of volumes which will be mounted to the machine when it gets started. */ addVolumeToList(): void { - const newVol: Volume = new Volume(); - newVol.volume_storage = this.volumeStorage; - newVol.volume_name = this.volumeName; - newVol.volume_path = this.volumeMountPath; - newVol.volume_device = 'test'; - this.volumesToMount.push(newVol); - this.volumeStorage = 0; - this.volumeName = ''; - this.volumeMountPath = ''; + const newVol: Volume = new Volume() + newVol.volume_storage = this.volumeStorage + newVol.volume_name = this.volumeName + newVol.volume_path = this.volumeMountPath + newVol.volume_device = 'test' + this.volumesToMount.push(newVol) + this.volumeStorage = 0 + this.volumeName = '' + this.volumeMountPath = '' } addAttachVolume(vol: Volume): void { - this.selected_detached_vol = this.undefined_detached_vol; - this.volumesToAttach.push(vol); - this.detached_project_volumes = this.detached_project_volumes.filter((volume: Volume): any => vol !== volume); + this.selected_detached_vol = this.undefined_detached_vol + this.volumesToAttach.push(vol) + this.detached_project_volumes = this.detached_project_volumes.filter((volume: Volume): any => vol !== volume) if (this.detached_project_volumes.length === 0) { - this.toggleShowAttachVol(); + this.toggleShowAttachVol() } } removeAttachVolume(vol: Volume): void { - this.selected_detached_vol = null; - const idx: number = this.volumesToAttach.indexOf(vol); - vol.volume_path = null; + this.selected_detached_vol = null + const idx: number = this.volumesToAttach.indexOf(vol) + vol.volume_path = null if (idx !== -1) { - this.volumesToAttach.splice(idx, 1); - this.detached_project_volumes.push(vol); + this.volumesToAttach.splice(idx, 1) + this.detached_project_volumes.push(vol) } } removeVolFromList(vol: Volume): void { - const idx: number = this.volumesToMount.indexOf(vol); - vol.volume_path = null; + const idx: number = this.volumesToMount.indexOf(vol) + vol.volume_path = null if (idx > -1) { - this.volumesToMount.splice(idx, 1); + this.volumesToMount.splice(idx, 1) } } @@ -423,7 +421,7 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { * Validate the public key of the user. */ validatePublicKey(): boolean { - return /ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(this.userinfo.PublicKey); + return /ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(this.userinfo.PublicKey) } /** @@ -431,27 +429,27 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { */ toggleShowAddVol(): void { if (!this.showAddVol) { - this.showAddVol = true; - this.showAttachVol = false; - this.volumeName = ''; - this.volumeMountPath = null; - this.volumeStorage = 0; + this.showAddVol = true + this.showAttachVol = false + this.volumeName = '' + this.volumeMountPath = null + this.volumeStorage = 0 } else { - this.showAddVol = false; - this.volumeName = ''; - this.volumeMountPath = null; - this.volumeStorage = 0; + this.showAddVol = false + this.volumeName = '' + this.volumeMountPath = null + this.volumeStorage = 0 } } toggleShowAttachVol(): void { if (!this.showAttachVol) { - this.showAttachVol = true; - this.showAddVol = false; - this.selected_detached_vol = this.undefined_detached_vol; + this.showAttachVol = true + this.showAddVol = false + this.selected_detached_vol = this.undefined_detached_vol } else { - this.showAttachVol = false; - this.selected_detached_vol = this.undefined_detached_vol; + this.showAttachVol = false + this.selected_detached_vol = this.undefined_detached_vol } } @@ -459,9 +457,9 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { * Reset the progress bar. */ resetProgressBar(): void { - this.progress_bar_status = this.CREATING_STATUS; - this.progress_bar_animated = this.ANIMATED_PROGRESS_BAR; - this.progress_bar_width = 0; + this.progress_bar_status = this.CREATING_STATUS + this.progress_bar_animated = this.ANIMATED_PROGRESS_BAR + this.progress_bar_width = 0 } /** @@ -473,33 +471,33 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { * @param projectid */ startVM(flavor: string, servername: string, project: string, projectid: string | number): void { - this.progress_bar_width = 25; - this.create_error = null; + this.progress_bar_width = 25 + this.create_error = null // tslint:disable-next-line:no-complex-conditionals if (this.selectedImage && flavor && servername && project) { - this.create_error = null; - this.started_machine = true; + this.create_error = null + this.started_machine = true - const re: RegExp = /\+/gi; + const re: RegExp = /\+/gi - const flavor_fixed: string = flavor.replace(re, '%2B'); + const flavor_fixed: string = flavor.replace(re, '%2B') // Playbook and Research-Environment stuff - let play_information: string = this.getPlaybookInformation(); + let play_information: string = this.getPlaybookInformation() if (play_information !== '{}') { - this.playbook_run = 1; + this.playbook_run = 1 } else { - play_information = null; + play_information = null } if (!this.mosh_mode_available) { - this.udp_allowed = false; + this.udp_allowed = false } this.delay(500) .then((): any => { - this.progress_bar_width = 50; + this.progress_bar_width = 50 }) - .catch((): any => {}); - const additional_elixir_ids: string[] = this.members_to_add.map((mem: ProjectMember): string => mem.elixirId); + .catch((): any => {}) + const additional_elixir_ids: string[] = this.members_to_add.map((mem: ProjectMember): string => mem.elixirId) this.subscription.add( this.virtualmachineservice .startVM( @@ -514,49 +512,50 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { this.volumesToMount, this.volumesToAttach, play_information, - additional_elixir_ids, + additional_elixir_ids ) .subscribe( (newVm: VirtualMachine): void => { - this.error_starting_machine = false; - this.newVm = newVm; - this.started_machine = false; + this.error_starting_machine = false + this.newVm = newVm + this.started_machine = false if (newVm.status) { if (newVm['volume_error']) { - this.progress_bar_width = 50; - // eslint-disable-next-line max-len - this.progress_bar_status = 'At least 1 volume could not be created due to invalid naming. This will not stop the machine creation process.'; + this.progress_bar_width = 50 + + this.progress_bar_status = + 'At least 1 volume could not be created due to invalid naming. This will not stop the machine creation process.' setTimeout((): void => { - void this.router.navigate(['/virtualmachines/vmOverview']).then().catch(); - }, 15000); + void this.router.navigate(['/virtualmachines/vmOverview']).then().catch() + }, 15000) } else { - this.progress_bar_width = 75; + this.progress_bar_width = 75 setTimeout((): void => { - void this.router.navigate(['/virtualmachines/vmOverview']).then().catch(); - }, 2000); + void this.router.navigate(['/virtualmachines/vmOverview']).then().catch() + }, 2000) } } else { - this.loadProjectData(); + this.loadProjectData() // eslint-disable-next-line @typescript-eslint/consistent-type-assertions - this.create_error = (newVm); + this.create_error = (newVm) } }, (error): void => { - console.log(error); - this.error_starting_machine = true; - }, - ), - ); + console.log(error) + this.error_starting_machine = true + } + ) + ) } else { - this.progress_bar_status = this.CREATING_STATUS; - this.newVm = null; + this.progress_bar_status = this.CREATING_STATUS + this.newVm = null } } async delay(ms: number): Promise { - // eslint-disable-next-line no-promise-executor-return - await new Promise((resolve: any): any => setTimeout(resolve, ms)); + + await new Promise((resolve: any): any => setTimeout(resolve, ms)) } getPlaybookInformation(): string { @@ -564,31 +563,31 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { [name: string]: { [variable: string]: string } - } = {}; - this.timeout = 300; + } = {} + this.timeout = 300 if (this.biocondaComponent.hasChosenTools()) { playbook_info['conda'] = { - packages: this.biocondaComponent.getChosenTools(), - }; - this.timeout += this.biocondaComponent.getTimeout(); + packages: this.biocondaComponent.getChosenTools() + } + this.timeout += this.biocondaComponent.getTimeout() } if ( - this.resEnvComponent - && this.resEnvComponent.selectedTemplate.template_name !== 'undefined' - && this.resEnvComponent.user_key_url.errors === null + this.resEnvComponent && + this.resEnvComponent.selectedTemplate.template_name !== 'undefined' && + this.resEnvComponent.user_key_url.errors === null ) { playbook_info[this.resEnvComponent.selectedTemplate.template_name] = { - create_only_backend: `${this.resEnvComponent.getCreateOnlyBackend()}`, - }; - playbook_info['user_key_url'] = { user_key_url: this.resEnvComponent.getUserKeyUrl() }; + create_only_backend: `${this.resEnvComponent.getCreateOnlyBackend()}` + } + playbook_info['user_key_url'] = { user_key_url: this.resEnvComponent.getUserKeyUrl() } } if (this.udp_allowed && this.install_mosh) { - playbook_info['optional'] = { mosh: 'install' }; + playbook_info['optional'] = { mosh: 'install' } } - return JSON.stringify(playbook_info); + return JSON.stringify(playbook_info) } /** @@ -596,62 +595,62 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { * If connected get vm,volumes etc. */ getSelectedProjectClient(): void { - this.subscription.unsubscribe(); - this.subscription = new Subscription(); + this.subscription.unsubscribe() + this.subscription = new Subscription() this.subscription.add( this.groupService.getCreditsAllowedByPerunId(this.selectedProject[1]).subscribe((res: any): void => { - this.credits_allowed = res['credits_allowed']; - }), - ); - this.newCores = 0; - this.newGpus = 0; - this.newVms = 0; - this.volumesToAttach = []; - this.volumesToMount = []; - this.client_checked = false; - this.projectDataLoaded = false; + this.credits_allowed = res['credits_allowed'] + }) + ) + this.newCores = 0 + this.newGpus = 0 + this.newVms = 0 + this.volumesToAttach = [] + this.volumesToMount = [] + this.client_checked = false + this.projectDataLoaded = false this.subscription.add( this.groupService.getClient(this.selectedProject[1].toString()).subscribe((client: Client): void => { - this.loadProjectData(); + this.loadProjectData() if (client.status && client.status === 'Connected' && client.activated) { - this.client_available = true; + this.client_available = true - this.client_checked = true; - this.getForc(client.id); + this.client_checked = true + this.getForc(client.id) } else { - this.client_available = false; - this.client_checked = true; + this.client_available = false + this.client_checked = true } - this.selectedProjectClient = client; + this.selectedProjectClient = client this.subscription.add( this.imageService .getBlockedImageTagsResenv(Number(this.selectedProjectClient.id), 'true') .subscribe((tags: BlockedImageTagResenv[]): void => { - this.blockedImageTagsResenv = tags; - }), - ); - }), - ); + this.blockedImageTagsResenv = tags + }) + ) + }) + ) this.subscription.add( this.applicationsService .getApplicationMigratedByGroupId(this.selectedProject[1].toString()) .subscribe((migrated: boolean): void => { - this.selectedProjectIsMigrated = migrated; - }), - ); + this.selectedProjectIsMigrated = migrated + }) + ) } getForc(id: string): void { this.subscription.add( this.groupService.getClientForcUrl(this.selectedProject[1].toString()).subscribe((response: JSON): void => { if (response['forc_url'] !== null) { - this.has_forc = true; - this.forc_url = response['forc_url']; + this.has_forc = true + this.forc_url = response['forc_url'] } - }), - ); - this.client_id = id; + }) + ) + this.client_id = id } /** @@ -659,9 +658,9 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { */ resetData(): void { if (this.newVm === null) { - return; + return } - this.newVm = null; + this.newVm = null } /** @@ -673,65 +672,65 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { forkJoin([ this.groupService.getSimpleVmAllowedByUser(), this.groupService.getSimpleVmByUser(), - this.userService.getUserInfo(), + this.userService.getUserInfo() ]).subscribe((result: any): void => { - this.userinfo = result[2]; - this.userinfo_loaded = true; - this.validatePublicKey(); - const allowedMemberGroups: any = result[0]; - const memberGroups: any = result[1]; + this.userinfo = result[2] + this.userinfo_loaded = true + this.validatePublicKey() + const allowedMemberGroups: any = result[0] + const memberGroups: any = result[1] for (const project of memberGroups) { - this.projects.push(project); + this.projects.push(project) } - this.projects_loaded = true; + this.projects_loaded = true for (const project of allowedMemberGroups) { - this.allowedProjects.push(project); + this.allowedProjects.push(project) } if (this.projects.length === 1) { - this.resetChecks(); - this.selectedProject = this.projects[0]; - this.getSelectedProjectClient(); - this.singleProject = true; + this.resetChecks() + this.selectedProject = this.projects[0] + this.getSelectedProjectClient() + this.singleProject = true } - }), - ); + }) + ) } loadProjectData(): void { - this.projectDataLoaded = false; - this.flavors = []; - this.flavors_loaded = false; - this.selectedImage = undefined; - this.selectedFlavor = undefined; - this.getDetachedVolumesByProject(); + this.projectDataLoaded = false + this.flavors = [] + this.flavors_loaded = false + this.selectedImage = undefined + this.selectedFlavor = undefined + this.getDetachedVolumesByProject() this.subscription.add( this.groupService .getGroupResources(this.selectedProject[1].toString()) .subscribe((res: ApplicationRessourceUsage): void => { - this.selectedProjectRessources = new ApplicationRessourceUsage(res); - this.projectDataLoaded = true; - this.generateRandomName(); - }), - ); - this.getFlavors(this.selectedProject[1]); + this.selectedProjectRessources = new ApplicationRessourceUsage(res) + this.projectDataLoaded = true + this.generateRandomName() + }) + ) + this.getFlavors(this.selectedProject[1]) } generateRandomName(): void { - const rng: RandomNameGenerator = new RandomNameGenerator(); - this.vm_name = rng.randomName(); + const rng: RandomNameGenerator = new RandomNameGenerator() + this.vm_name = rng.randomName() } setSelectedImage(image: Image): void { - this.selectedImage = image; - this.isMoshModeAvailable(); - this.hasImageResenv(); + this.selectedImage = image + this.isMoshModeAvailable() + this.hasImageResenv() } checkImageAgain(): void { if (this.selectedImage !== undefined) { if (this.selectedImage.min_disk > 0) { if (this.selectedFlavor.rootdisk < this.selectedImage.min_disk) { - this.selectedImage = undefined; + this.selectedImage = undefined } } } @@ -740,107 +739,107 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { isMoshModeAvailable(): void { for (const mode of this.selectedImage.modes) { if (mode.name === 'MOSH') { - this.mosh_mode_available = true; + this.mosh_mode_available = true - return; + return } } - this.mosh_mode_available = false; + this.mosh_mode_available = false } hasImageResenv(): void { if (!this.resEnvComponent) { - this.resEnvComponent.unsetOnlyNamespace(); + this.resEnvComponent.unsetOnlyNamespace() - return; + return } for (const mode of this.selectedImage.modes) { for (const template of this.resEnvComponent.templates) { if (template.template_name === mode.name) { - this.resenvSelected = true; - this.resEnvComponent.setOnlyNamespace(template); + this.resenvSelected = true + this.resEnvComponent.setOnlyNamespace(template) if (!this.resEnvComponent.getUserKeyUrl()) { - this.resEnvComponent.setUserKeyUrl(this.vm_name); + this.resEnvComponent.setUserKeyUrl(this.vm_name) } - return; + return } } } - this.resenvSelected = false; + this.resenvSelected = false if (this.resEnvComponent) { - this.resEnvComponent.unsetOnlyNamespace(); + this.resEnvComponent.unsetOnlyNamespace() if (!this.resEnvComponent.getUserKeyUrl()) { - this.resEnvComponent.setUserKeyUrl(this.vm_name); + this.resEnvComponent.setUserKeyUrl(this.vm_name) } } } setSelectedFlavor(flavor: Flavor): void { - this.selectedFlavor = flavor; - this.newCores = this.selectedFlavor.vcpus; - this.newRam = this.selectedFlavor.ram_gib; - this.newGpus = this.selectedFlavor.gpu; - this.checkImageAgain(); + this.selectedFlavor = flavor + this.newCores = this.selectedFlavor.vcpus + this.newRam = this.selectedFlavor.ram_gib + this.newGpus = this.selectedFlavor.gpu + this.checkImageAgain() } ngOnInit(): void { - this.tracker.trackPageView('Create New Instance'); - this.initializeData(); - this.is_vo = is_vo; + this.tracker.trackPageView('Create New Instance') + this.initializeData() + this.is_vo = is_vo } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } ngDoCheck(): void { if (this.resEnvComponent) { - this.resEnvValid = this.resEnvComponent.isValid(); - this.resEnvNeedsName = this.resEnvComponent.needsName(); - this.resEnvNeedsTemplate = this.resEnvComponent.needsTemplate(); - this.resEnvOkayNeeded = this.resEnvComponent.okayNeeded(); + this.resEnvValid = this.resEnvComponent.isValid() + this.resEnvNeedsName = this.resEnvComponent.needsName() + this.resEnvNeedsTemplate = this.resEnvComponent.needsTemplate() + this.resEnvOkayNeeded = this.resEnvComponent.okayNeeded() } } hasChosenTools(hasSomeTools: boolean): void { - this.hasTools = hasSomeTools; + this.hasTools = hasSomeTools } getTimeoutMinutes(): number { - return Math.ceil(this.timeout / 60); + return Math.ceil(this.timeout / 60) } resetChecks(): void { - this.initial_loaded = false; - this.gaveOkay = false; - this.hasTools = false; - this.newVm = null; - this.members_to_add = []; - this.http_allowed = false; - this.https_allowed = false; - this.udp_allowed = false; - this.install_mosh = false; - this.vm_responsibility = false; - this.client_checked = false; - this.playbook_run = 0; - this.has_forc = false; - this.forc_url = ''; - this.mosh_mode_available = false; - this.resenvSelected = false; - this.resEnvValid = true; - this.resEnvNeedsName = false; - this.resEnvNeedsTemplate = false; - this.resEnvOkayNeeded = false; - this.volumesToMount = []; - this.volumesToAttach = []; - this.started_machine = false; - this.showAddVol = false; - this.flavors_loaded = false; - this.flavors = []; - this.selected_flavor_types = []; - this.flavor_types = {}; - this.detached_project_volumes = []; + this.initial_loaded = false + this.gaveOkay = false + this.hasTools = false + this.newVm = null + this.members_to_add = [] + this.http_allowed = false + this.https_allowed = false + this.udp_allowed = false + this.install_mosh = false + this.vm_responsibility = false + this.client_checked = false + this.playbook_run = 0 + this.has_forc = false + this.forc_url = '' + this.mosh_mode_available = false + this.resenvSelected = false + this.resEnvValid = true + this.resEnvNeedsName = false + this.resEnvNeedsTemplate = false + this.resEnvOkayNeeded = false + this.volumesToMount = [] + this.volumesToAttach = [] + this.started_machine = false + this.showAddVol = false + this.flavors_loaded = false + this.flavors = [] + this.selected_flavor_types = [] + this.flavor_types = {} + this.detached_project_volumes = [] } /** @@ -849,15 +848,15 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { */ getStorageInList(): number { if (this.volumesToMount.length === 0) { - return 0; + return 0 } else { - let storageInList: number = 0; + let storageInList: number = 0 this.volumesToMount.forEach((volume: Volume): void => { - storageInList += volume.volume_storage; - }); + storageInList += volume.volume_storage + }) - return storageInList; + return storageInList } } } diff --git a/src/app/virtualmachines/clustercard/clustercard.component.ts b/src/app/virtualmachines/clustercard/clustercard.component.ts index b42f1df8a9..5f68d5d557 100644 --- a/src/app/virtualmachines/clustercard/clustercard.component.ts +++ b/src/app/virtualmachines/clustercard/clustercard.component.ts @@ -1,17 +1,15 @@ -import { - Component, EventEmitter, Input, OnDestroy, OnInit, Output, -} from '@angular/core'; -import { ClipboardService } from 'ngx-clipboard'; -import { Subscription } from 'rxjs'; -import { BsModalService } from 'ngx-bootstrap/modal'; -import { VirtualMachineStates } from '../virtualmachinemodels/virtualmachinestates'; -import { VirtualmachineService } from '../../api-connector/virtualmachine.service'; -import { ImageService } from '../../api-connector/image.service'; -import { Clusterinfo } from '../clusters/clusterinfo'; +import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core' +import { ClipboardService } from 'ngx-clipboard' +import { Subscription } from 'rxjs' +import { BsModalService } from 'ngx-bootstrap/modal' +import { VirtualMachineStates } from '../virtualmachinemodels/virtualmachinestates' +import { VirtualmachineService } from '../../api-connector/virtualmachine.service' +import { ImageService } from '../../api-connector/image.service' +import { Clusterinfo } from '../clusters/clusterinfo' -import { SharedModal } from '../../shared/shared_modules/baseClass/shared-modal'; +import { SharedModal } from '../../shared/shared_modules/baseClass/shared-modal' -import { CLOUD_PORTAL_SUPPORT_MAIL } from '../../../links/links'; +import { CLOUD_PORTAL_SUPPORT_MAIL } from '../../../links/links' /** * Vm card component to be used by vm-overview. Holds information about a virtual machine. @@ -20,47 +18,47 @@ import { CLOUD_PORTAL_SUPPORT_MAIL } from '../../../links/links'; selector: 'app-cluster-card', templateUrl: 'clustercard.component.html', styleUrls: ['./clustercard.component.scss'], - providers: [ImageService], + providers: [ImageService] }) export class ClustercardComponent extends SharedModal implements OnInit, OnDestroy { - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL /** * The virtual machine this card is for. */ - @Input() cluster: Clusterinfo; + @Input() cluster: Clusterinfo /** * Possible virtual machine states. */ - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() /** * Eventemitter when the vm is checked/unchecked. */ - @Output() check_change_event: EventEmitter = new EventEmitter(); + @Output() check_change_event: EventEmitter = new EventEmitter() /** * Elixir id of the user. */ - @Input() user_elixir_id: string = ''; + @Input() user_elixir_id: string = '' /** * If the user is a vo admin. */ - @Input() is_vo_admin: boolean = false; + @Input() is_vo_admin: boolean = false /** * If the user is an admin of the group the cluster belongs to. */ - @Input() is_cluster_admin: boolean = false; + @Input() is_cluster_admin: boolean = false /** * Subscription objcet to listen to different events. */ - subscription: Subscription = new Subscription(); + subscription: Subscription = new Subscription() - statusSubscription: Subscription = new Subscription(); + statusSubscription: Subscription = new Subscription() /** * Modal reference to be changed/showed/hidden depending on chosen modal. @@ -71,42 +69,42 @@ export class ClustercardComponent extends SharedModal implements OnInit, OnDestr * Default wait time between status checks if no other value specified. * @private */ - private checkStatusTimeout: number = 15000; + private checkStatusTimeout: number = 15000 /** * Default time in ms to show an error message if no other value specified. */ - ERROR_TIMER: number = 20000; + ERROR_TIMER: number = 20000 /** * Timeout object to control check status loop (i.e. stopping and starting check status loop). */ - checkStatusTimer: ReturnType; + checkStatusTimer: ReturnType /** * Timeout object to control check status loop (i.e. stopping and starting check status loop). */ - checkWorkerStatusTimer: ReturnType; + checkWorkerStatusTimer: ReturnType - all_worker_loaded: boolean = false; + all_worker_loaded: boolean = false constructor( private clipboardService: ClipboardService, modalService: BsModalService, - private virtualmachineservice: VirtualmachineService, + private virtualmachineservice: VirtualmachineService ) { - super(modalService); + super(modalService) } ngOnInit() { - this.statusSubscription = new Subscription(); + this.statusSubscription = new Subscription() - this.check_status_loop(); + this.check_status_loop() } ngOnDestroy() { - this.subscription.unsubscribe(); - this.statusSubscription.unsubscribe(); - this.stopAllCheckStatusTimer(); + this.subscription.unsubscribe() + this.statusSubscription.unsubscribe() + this.stopAllCheckStatusTimer() } /** @@ -114,10 +112,10 @@ export class ClustercardComponent extends SharedModal implements OnInit, OnDestr */ stopCheckStatusTimer(): void { if (this.checkStatusTimer) { - clearTimeout(this.checkStatusTimer); + clearTimeout(this.checkStatusTimer) } if (this.statusSubscription) { - this.statusSubscription.unsubscribe(); + this.statusSubscription.unsubscribe() } } @@ -126,10 +124,10 @@ export class ClustercardComponent extends SharedModal implements OnInit, OnDestr */ stopCheckWorkerStatusTimer(): void { if (this.checkWorkerStatusTimer) { - clearTimeout(this.checkWorkerStatusTimer); + clearTimeout(this.checkWorkerStatusTimer) } if (this.statusSubscription) { - this.statusSubscription.unsubscribe(); + this.statusSubscription.unsubscribe() } } @@ -137,39 +135,39 @@ export class ClustercardComponent extends SharedModal implements OnInit, OnDestr * Stop and clear all check status loop. */ stopAllCheckStatusTimer(): void { - this.stopCheckStatusTimer(); - this.stopCheckWorkerStatusTimer(); + this.stopCheckStatusTimer() + this.stopCheckWorkerStatusTimer() } get_all_batches_loaded(): boolean { - let worker_amount: number = 0; + let worker_amount: number = 0 for (const worker_batch of this.cluster.worker_batches) { - worker_amount += worker_batch.worker_count; + worker_amount += worker_batch.worker_count } - return this.cluster.worker_instances.length === worker_amount; + return this.cluster.worker_instances.length === worker_amount } check_status_loop(): void { - this.all_worker_loaded = this.get_all_batches_loaded(); + this.all_worker_loaded = this.get_all_batches_loaded() this.checkStatusTimer = setTimeout((): void => { this.statusSubscription.add( this.virtualmachineservice .getClusterInfo(this.cluster.cluster_id) .subscribe((updated_cluster: Clusterinfo): void => { - const password: string = this.cluster.password; - this.cluster = new Clusterinfo(updated_cluster); - this.cluster.password = password; + const password: string = this.cluster.password + this.cluster = new Clusterinfo(updated_cluster) + this.cluster.password = password if ( - this.cluster.status !== VirtualMachineStates.DELETED - && this.cluster.status !== VirtualMachineStates.NOT_FOUND - && this.cluster.status !== VirtualMachineStates.MIGRATED + this.cluster.status !== VirtualMachineStates.DELETED && + this.cluster.status !== VirtualMachineStates.NOT_FOUND && + this.cluster.status !== VirtualMachineStates.MIGRATED ) { - this.check_status_loop(); + this.check_status_loop() } - }), - ); - }, this.checkStatusTimeout); + }) + ) + }, this.checkStatusTimeout) } /** @@ -177,7 +175,7 @@ export class ClustercardComponent extends SharedModal implements OnInit, OnDestr */ copyToClipboard(text: string): void { if (this.clipboardService.isSupported) { - this.clipboardService.copy(text); + this.clipboardService.copy(text) } } @@ -185,11 +183,11 @@ export class ClustercardComponent extends SharedModal implements OnInit, OnDestr * Show message in span that text was copied. */ showCopiedMessage(name: string): void { - const span_id: string = `${name}resenvSpan`; - const { innerHTML } = document.getElementById(span_id); - document.getElementById(span_id).innerHTML = 'Copied URL!'; + const span_id: string = `${name}resenvSpan` + const { innerHTML } = document.getElementById(span_id) + document.getElementById(span_id).innerHTML = 'Copied URL!' setTimeout((): void => { - document.getElementById(span_id).innerHTML = innerHTML; - }, 1000); + document.getElementById(span_id).innerHTML = innerHTML + }, 1000) } } diff --git a/src/app/virtualmachines/clusters/add-cluster/add-cluster.component.ts b/src/app/virtualmachines/clusters/add-cluster/add-cluster.component.ts index ceb296293d..ee07af14aa 100644 --- a/src/app/virtualmachines/clusters/add-cluster/add-cluster.component.ts +++ b/src/app/virtualmachines/clusters/add-cluster/add-cluster.component.ts @@ -1,32 +1,30 @@ -import { - ChangeDetectorRef, Component, OnDestroy, OnInit, ViewChild, inject, -} from '@angular/core'; -import { forkJoin, Subscription } from 'rxjs'; -import { Router } from '@angular/router'; -import { KeyValue } from '@angular/common'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { GroupService } from '../../../api-connector/group.service'; -import { ImageService } from '../../../api-connector/image.service'; -import { KeyService } from '../../../api-connector/key.service'; -import { FlavorService } from '../../../api-connector/flavor.service'; -import { VirtualmachineService } from '../../../api-connector/virtualmachine.service'; -import { ApiSettings } from '../../../api-connector/api-settings.service'; -import { ClientService } from '../../../api-connector/client.service'; -import { UserService } from '../../../api-connector/user.service'; -import { VoService } from '../../../api-connector/vo.service'; -import { Image } from '../../virtualmachinemodels/image'; -import { IResponseTemplate } from '../../../api-connector/response-template'; -import { Flavor } from '../../virtualmachinemodels/flavor'; -import { Userinfo } from '../../../userinfo/userinfo.model'; -import { Client } from '../../../vo_manager/clients/client.model'; -import { BiocondaComponent } from '../../conda/bioconda.component'; -import { ApplicationRessourceUsage } from '../../../applications/application-ressource-usage/application-ressource-usage'; -import { WorkerBatch } from '../clusterinfo'; -import { CLOUD_PORTAL_SUPPORT_MAIL, STATUS_LINK } from '../../../../links/links'; -import { RandomNameGenerator } from '../../../shared/randomNameGenerator'; -import { BiocondaService } from '../../../api-connector/bioconda.service'; -import { ApplicationsService } from '../../../api-connector/applications.service'; -import { ProjectMember } from '../../../projectmanagement/project_member.model'; +import { ChangeDetectorRef, Component, OnDestroy, OnInit, ViewChild, inject } from '@angular/core' +import { forkJoin, Subscription } from 'rxjs' +import { Router } from '@angular/router' +import { KeyValue } from '@angular/common' +import { MatomoTracker } from 'ngx-matomo-client' +import { GroupService } from '../../../api-connector/group.service' +import { ImageService } from '../../../api-connector/image.service' +import { KeyService } from '../../../api-connector/key.service' +import { FlavorService } from '../../../api-connector/flavor.service' +import { VirtualmachineService } from '../../../api-connector/virtualmachine.service' +import { ApiSettings } from '../../../api-connector/api-settings.service' +import { ClientService } from '../../../api-connector/client.service' +import { UserService } from '../../../api-connector/user.service' +import { VoService } from '../../../api-connector/vo.service' +import { Image } from '../../virtualmachinemodels/image' +import { IResponseTemplate } from '../../../api-connector/response-template' +import { Flavor } from '../../virtualmachinemodels/flavor' +import { Userinfo } from '../../../userinfo/userinfo.model' +import { Client } from '../../../vo_manager/clients/client.model' +import { BiocondaComponent } from '../../conda/bioconda.component' +import { ApplicationRessourceUsage } from '../../../applications/application-ressource-usage/application-ressource-usage' +import { WorkerBatch } from '../clusterinfo' +import { CLOUD_PORTAL_SUPPORT_MAIL, STATUS_LINK } from '../../../../links/links' +import { RandomNameGenerator } from '../../../shared/randomNameGenerator' +import { BiocondaService } from '../../../api-connector/bioconda.service' +import { ApplicationsService } from '../../../api-connector/applications.service' +import { ProjectMember } from '../../../projectmanagement/project_member.model' /** * Cluster Component @@ -46,92 +44,92 @@ import { ProjectMember } from '../../../projectmanagement/project_member.model'; ClientService, UserService, VoService, - BiocondaService, - ], + BiocondaService + ] }) export class AddClusterComponent implements OnInit, OnDestroy { - private readonly tracker = inject(MatomoTracker); - is_vo: boolean = false; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - STATUS_LINK: string = STATUS_LINK; + private readonly tracker = inject(MatomoTracker) + is_vo: boolean = false + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + STATUS_LINK: string = STATUS_LINK - client_checked: boolean = false; - timeout: number = 0; - title: string = 'New Cluster'; + client_checked: boolean = false + timeout: number = 0 + title: string = 'New Cluster' - flavors_loaded: boolean = false; + flavors_loaded: boolean = false - projects_loaded: boolean; + projects_loaded: boolean - userinfo_loaded: boolean; + userinfo_loaded: boolean - create_error: IResponseTemplate; - initial_loaded: boolean = false; + create_error: IResponseTemplate + initial_loaded: boolean = false /** * All flavors of a project. */ - flavors: Flavor[] = []; - - flavors_usable: Flavor[] = []; - selected_flavor_types: Flavor[] = []; - selected_flavor_type: string = 'Standard Flavors'; - flavor_types: { [name: string]: Flavor[] } = {}; - vm_limit_reached: boolean = false; - cores_limit_reached: boolean = false; - ram_limit_reached: boolean = false; - - cluster_id: string; - cluster_error: string; - cluster_started: boolean = false; - cluster_responsibility: boolean = false; - resenv_names: string[] = []; + flavors: Flavor[] = [] + + flavors_usable: Flavor[] = [] + selected_flavor_types: Flavor[] = [] + selected_flavor_type: string = 'Standard Flavors' + flavor_types: { [name: string]: Flavor[] } = {} + vm_limit_reached: boolean = false + cores_limit_reached: boolean = false + ram_limit_reached: boolean = false + + cluster_id: string + cluster_error: string + cluster_started: boolean = false + cluster_responsibility: boolean = false + resenv_names: string[] = [] /** * Selected Image. */ - selectedImage: Image; - selectedMasterImage: Image; - selectedWorkerBatches: WorkerBatch[] = [new WorkerBatch(1)]; - selectedBatch: WorkerBatch = this.selectedWorkerBatches[0]; + selectedImage: Image + selectedMasterImage: Image + selectedWorkerBatches: WorkerBatch[] = [new WorkerBatch(1)] + selectedBatch: WorkerBatch = this.selectedWorkerBatches[0] - maxWorkerInstances: number; + maxWorkerInstances: number - singleProject: boolean = false; - cluster_name: string = ''; + singleProject: boolean = false + cluster_name: string = '' /** * Selected Flavor. */ - selectedMasterFlavor: Flavor; - selectedFlavor: Flavor; - selectedWorkerFlavorSet: boolean = false; + selectedMasterFlavor: Flavor + selectedFlavor: Flavor + selectedWorkerFlavorSet: boolean = false - workerInstancesCount: number; + workerInstancesCount: number /** * Userinfo from the user. */ - userinfo: Userinfo; - current_key_blocked: boolean = false; + userinfo: Userinfo + current_key_blocked: boolean = false /** * Selected Project vms client. */ - selectedProjectClient: Client; + selectedProjectClient: Client - selectedProjectRessources: ApplicationRessourceUsage; + selectedProjectRessources: ApplicationRessourceUsage /** * The selected project ['name',id]. */ - selectedProject: [string, number]; - members_to_add: ProjectMember[] = []; + selectedProject: [string, number] + members_to_add: ProjectMember[] = [] /** * If the client for a project is viable. */ - client_available: boolean = false; + client_available: boolean = false /** * If the data for the site is initialized. @@ -144,31 +142,31 @@ export class AddClusterComponent implements OnInit, OnDestroy { * * @type {any[]} */ - projects: [string, number][] = []; + projects: [string, number][] = [] /** * All projects of the user where the user is allowed to start machines. * * @type {any[]} */ - allowedProjects: [string, number][] = []; + allowedProjects: [string, number][] = [] /** * If all project data is loaded. * * @type {boolean} */ - projectDataLoaded: boolean = false; + projectDataLoaded: boolean = false - selectedProjectIsMigrated: boolean = false; + selectedProjectIsMigrated: boolean = false - newCores: number = 0; - newRam: number = 0; - newVms: number = 2; - newGpus: number = 0; - subscription: Subscription = new Subscription(); + newCores: number = 0 + newRam: number = 0 + newVms: number = 2 + newGpus: number = 0 + subscription: Subscription = new Subscription() - @ViewChild('bioconda', { static: true }) biocondaComponent: BiocondaComponent; + @ViewChild('bioconda', { static: true }) biocondaComponent: BiocondaComponent constructor( private groupService: GroupService, @@ -181,47 +179,49 @@ export class AddClusterComponent implements OnInit, OnDestroy { private router: Router, private applicationsService: ApplicationsService, private condaService: BiocondaService, - private cdRef: ChangeDetectorRef, + private cdRef: ChangeDetectorRef ) { - // eslint-disable-next-line no-empty-function + } calcWorkerInstancesCount(): void { - let count: number = 0; + let count: number = 0 this.selectedWorkerBatches.forEach((batch: WorkerBatch): void => { - batch.valid_batch = batch.worker_count <= batch.max_worker_count && batch.worker_count > 0; - count += batch.worker_count; - }); - this.workerInstancesCount = count; - this.newVms = this.workerInstancesCount + 1; + batch.valid_batch = batch.worker_count <= batch.max_worker_count && batch.worker_count > 0 + count += batch.worker_count + }) + this.workerInstancesCount = count + this.newVms = this.workerInstancesCount + 1 } setCurrentKeyBlocked(value: boolean): void { - this.current_key_blocked = value; + this.current_key_blocked = value } changeCount(): void { - this.calcWorkerInstancesCount(); - this.calculateNewValues(); + this.calcWorkerInstancesCount() + this.calculateNewValues() } checkFlavorsUsableForCluster(): void { - const used_flavors: Flavor[] = []; + const used_flavors: Flavor[] = [] // tslint:disable-next-line:no-for-each-push this.selectedWorkerBatches.forEach((batch: WorkerBatch): void => { if (batch !== this.selectedBatch) { - used_flavors.push(batch.flavor); + used_flavors.push(batch.flavor) } - }); + }) const flavors_to_filter: Flavor[] = this.flavors.filter( - (flavor: Flavor): boolean => used_flavors.indexOf(flavor) < 0, - ); - this.flavors_usable = flavors_to_filter.filter((flav: Flavor): boolean => this.selectedProjectRessources.filterFlavorsTest(flav, this.selectedWorkerBatches)); - this.flavor_types = this.flavorService.sortFlavors(this.flavors_usable); - - this.flavors_loaded = true; - this.initial_loaded = true; + (flavor: Flavor): boolean => used_flavors.indexOf(flavor) < 0 + ) + this.flavors_usable = flavors_to_filter.filter((flav: Flavor): boolean => + this.selectedProjectRessources.filterFlavorsTest(flav, this.selectedWorkerBatches) + ) + this.flavor_types = this.flavorService.sortFlavors(this.flavors_usable) + + this.flavors_loaded = true + this.initial_loaded = true } calcMaxWorkerInstancesByFlavor(): void { @@ -229,47 +229,47 @@ export class AddClusterComponent implements OnInit, OnDestroy { this.selectedBatch.max_worker_count = this.selectedProjectRessources.calcMaxWorkerInstancesByFlavor( this.selectedMasterFlavor, this.selectedBatch, - this.selectedWorkerBatches, - ); + this.selectedWorkerBatches + ) } } // eslint-disable-next-line @typescript-eslint/no-unused-vars unsorted(a: KeyValue, b: KeyValue): number { - return 0; + return 0 } setSelectedFlavorType(key: string): void { - this.selected_flavor_type = key; + this.selected_flavor_type = key } calculateNewValues(): void { - let tmp_ram: number = 0; - let tmp_cores: number = 0; - let tmp_gpus: number = 0; + let tmp_ram: number = 0 + let tmp_cores: number = 0 + let tmp_gpus: number = 0 if (this.selectedMasterFlavor) { - tmp_ram += this.selectedMasterFlavor.ram_gib; - tmp_cores += this.selectedMasterFlavor.vcpus; - tmp_gpus += this.selectedMasterFlavor.gpu; + tmp_ram += this.selectedMasterFlavor.ram_gib + tmp_cores += this.selectedMasterFlavor.vcpus + tmp_gpus += this.selectedMasterFlavor.gpu } if (this.selectedWorkerBatches) { this.selectedWorkerBatches.forEach((batch: WorkerBatch): void => { if (batch.worker_count && batch.flavor) { - tmp_ram += batch.flavor.ram_gib * batch.worker_count; - tmp_cores += batch.flavor.vcpus * batch.worker_count; - tmp_gpus += batch.flavor.gpu * batch.worker_count; + tmp_ram += batch.flavor.ram_gib * batch.worker_count + tmp_cores += batch.flavor.vcpus * batch.worker_count + tmp_gpus += batch.flavor.gpu * batch.worker_count } - }); + }) } - this.newRam = tmp_ram; - this.newCores = tmp_cores; - this.newGpus = tmp_gpus; + this.newRam = tmp_ram + this.newCores = tmp_cores + this.newGpus = tmp_gpus } generateRandomName(): void { - const rng: RandomNameGenerator = new RandomNameGenerator(); - this.cluster_name = `${rng.randomName()}Cluster`; + const rng: RandomNameGenerator = new RandomNameGenerator() + this.cluster_name = `${rng.randomName()}Cluster` } /** @@ -281,110 +281,112 @@ export class AddClusterComponent implements OnInit, OnDestroy { this.subscription.add( this.flavorService.getFlavors(project_id).subscribe( (flavors: Flavor[]): void => { - this.flavors = flavors; - this.checkFlavorsUsableForCluster(); + this.flavors = flavors + this.checkFlavorsUsableForCluster() }, (error: any) => { - console.log(error); - this.flavors = []; - this.flavors_usable = []; - this.flavors_loaded = true; - this.initial_loaded = true; - }, - ), - ); + console.log(error) + this.flavors = [] + this.flavors_usable = [] + this.flavors_loaded = true + this.initial_loaded = true + } + ) + ) } reloadFlavors(): void { - this.flavors_loaded = false; - this.selectedMasterFlavor = undefined; - this.selectedFlavor = undefined; - this.getFlavors(this.selectedProject[1]); + this.flavors_loaded = false + this.selectedMasterFlavor = undefined + this.selectedFlavor = undefined + this.getFlavors(this.selectedProject[1]) } /** * Validate the public key of the user. */ validatePublicKey(): boolean { - return /ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(this.userinfo.PublicKey); + return /ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?/.test(this.userinfo.PublicKey) } resetBatches(): void { - this.selectedWorkerBatches = [new WorkerBatch(1)]; - this.selectedBatch = this.selectedWorkerBatches[0]; - this.setBatchUsableFlavors(); + this.selectedWorkerBatches = [new WorkerBatch(1)] + this.selectedBatch = this.selectedWorkerBatches[0] + this.setBatchUsableFlavors() } setBatchUsableFlavors(): void { - const used_flavors: Flavor[] = []; + const used_flavors: Flavor[] = [] // tslint:disable-next-line:no-for-each-push this.selectedWorkerBatches.forEach((existingBatch: WorkerBatch): void => { if (existingBatch !== this.selectedBatch) { - used_flavors.push(existingBatch.flavor); + used_flavors.push(existingBatch.flavor) } - }); + }) const flavors_to_filter: Flavor[] = this.flavors.filter( - (flavor: Flavor): boolean => used_flavors.indexOf(flavor) < 0, - ); - // eslint-disable-next-line max-len - this.selectedBatch.usable_flavors = flavors_to_filter.filter((flav: Flavor): boolean => this.selectedProjectRessources.filterFlavorsTest(flav, this.selectedWorkerBatches, this.selectedMasterFlavor)); + (flavor: Flavor): boolean => used_flavors.indexOf(flavor) < 0 + ) + + this.selectedBatch.usable_flavors = flavors_to_filter.filter((flav: Flavor): boolean => + this.selectedProjectRessources.filterFlavorsTest(flav, this.selectedWorkerBatches, this.selectedMasterFlavor) + ) } setSelectedBatch(batch: WorkerBatch): void { - this.selectedBatch = batch; - this.checkFlavorsUsableForCluster(); - this.setBatchUsableFlavors(); - this.calcWorkerInstancesCount(); - this.calculateNewValues(); - this.calcMaxWorkerInstancesByFlavor(); - this.setBatchUsableFlavors(); + this.selectedBatch = batch + this.checkFlavorsUsableForCluster() + this.setBatchUsableFlavors() + this.calcWorkerInstancesCount() + this.calculateNewValues() + this.calcMaxWorkerInstancesByFlavor() + this.setBatchUsableFlavors() } addBatch(): void { - this.selectedWorkerFlavorSet = false; - this.selectedBatch = null; + this.selectedWorkerFlavorSet = false + this.selectedBatch = null const newBatch: WorkerBatch = new WorkerBatch( - this.selectedWorkerBatches[this.selectedWorkerBatches.length - 1].index + 1, - ); - this.selectedBatch = newBatch; - this.selectedWorkerBatches.push(this.selectedBatch); - this.setBatchUsableFlavors(); - this.selectedBatch.image = this.selectedMasterImage; - this.maxWorkerInstances = null; + this.selectedWorkerBatches[this.selectedWorkerBatches.length - 1].index + 1 + ) + this.selectedBatch = newBatch + this.selectedWorkerBatches.push(this.selectedBatch) + this.setBatchUsableFlavors() + this.selectedBatch.image = this.selectedMasterImage + this.maxWorkerInstances = null } removeBatch(batch: WorkerBatch): void { - const idx: number = this.selectedWorkerBatches.indexOf(batch); + const idx: number = this.selectedWorkerBatches.indexOf(batch) if (batch === this.selectedBatch) { - // eslint-disable-next-line no-plusplus + for (let i = idx; i < this.selectedWorkerBatches.length; i++) { - this.selectedWorkerBatches[i].index -= 1; + this.selectedWorkerBatches[i].index -= 1 } if (idx !== 0) { - this.selectedBatch = this.selectedWorkerBatches[idx - 1]; - this.selectedWorkerFlavorSet = true; + this.selectedBatch = this.selectedWorkerBatches[idx - 1] + this.selectedWorkerFlavorSet = true } else if (idx === 0 && this.selectedWorkerBatches.length > 0) { - this.selectedBatch = this.selectedWorkerBatches[idx + 1]; + this.selectedBatch = this.selectedWorkerBatches[idx + 1] } } - this.selectedWorkerBatches.splice(idx, 1); + this.selectedWorkerBatches.splice(idx, 1) - this.checkFlavorsUsableForCluster(); - this.setBatchUsableFlavors(); - this.calcWorkerInstancesCount(); - this.calculateNewValues(); - this.calcMaxWorkerInstancesByFlavor(); + this.checkFlavorsUsableForCluster() + this.setBatchUsableFlavors() + this.calcWorkerInstancesCount() + this.calculateNewValues() + this.calcMaxWorkerInstancesByFlavor() } startCluster(): void { - this.cluster_error = null; - this.cluster_id = null; + this.cluster_error = null + this.cluster_id = null // not needed anymore when using body directly in POST request // const masterFlavor: string = this.selectedMasterFlavor.name.replace(re, '%2B'); - const additional_elixir_ids: string[] = this.members_to_add.map((mem: ProjectMember): string => mem.elixirId); + const additional_elixir_ids: string[] = this.members_to_add.map((mem: ProjectMember): string => mem.elixirId) this.subscription.add( this.virtualmachineservice @@ -394,36 +396,36 @@ export class AddClusterComponent implements OnInit, OnDestroy { this.selectedWorkerBatches, this.selectedProject[1], this.cluster_name, - additional_elixir_ids, + additional_elixir_ids ) .subscribe( (res: any): void => { if (res['status'] && res['status'] === 'mutex_locked') { setTimeout((): void => { - this.startCluster(); - }, 1000); + this.startCluster() + }, 1000) } else { - this.cluster_id = res['id']; - this.cluster_started = true; + this.cluster_id = res['id'] + this.cluster_started = true setTimeout((): void => { - void this.router.navigate(['/virtualmachines/clusterOverview']).then().catch(); - }, 4000); + void this.router.navigate(['/virtualmachines/clusterOverview']).then().catch() + }, 4000) } }, (error: any): void => { - console.log(error); + console.log(error) if (error['error']['error']) { - this.cluster_error = error['error']['error']; + this.cluster_error = error['error']['error'] } else { - this.cluster_error = error; + this.cluster_error = error } setTimeout((): void => { - void this.router.navigate(['/virtualmachines/clusterOverview']).then().catch(); - }, 4000); - }, - ), - ); + void this.router.navigate(['/virtualmachines/clusterOverview']).then().catch() + }, 4000) + } + ) + ) } /** @@ -431,33 +433,33 @@ export class AddClusterComponent implements OnInit, OnDestroy { * If connected geht vm,volumes etc. */ getSelectedProjectClient(): void { - this.client_checked = false; - this.projectDataLoaded = false; + this.client_checked = false + this.projectDataLoaded = false - this.subscription.unsubscribe(); - this.subscription = new Subscription(); + this.subscription.unsubscribe() + this.subscription = new Subscription() this.subscription.add( this.applicationsService .getApplicationMigratedByGroupId(this.selectedProject[1].toString()) .subscribe((migrated: boolean): void => { - this.selectedProjectIsMigrated = migrated; - }), - ); + this.selectedProjectIsMigrated = migrated + }) + ) this.subscription.add( this.groupService.getClientBibigrid(this.selectedProject[1].toString()).subscribe((client: Client): void => { if (client.status && client.status === 'Connected') { - this.client_available = true; + this.client_available = true - this.loadProjectData(); - this.client_checked = true; + this.loadProjectData() + this.client_checked = true } else { - this.client_available = false; - this.client_checked = true; - this.projectDataLoaded = true; + this.client_available = false + this.client_checked = true + this.projectDataLoaded = true } - this.selectedProjectClient = client; - }), - ); + this.selectedProjectClient = client + }) + ) } /** @@ -469,87 +471,87 @@ export class AddClusterComponent implements OnInit, OnDestroy { forkJoin([ this.groupService.getSimpleVmAllowedByUserWithClusterAllowed(), this.groupService.getSimpleVmByUserWithClusterAllowed(), - this.userService.getUserInfo(), + this.userService.getUserInfo() ]).subscribe((result: any): void => { - this.userinfo = result[2]; - this.userinfo_loaded = true; - this.validatePublicKey(); - const allowedMemberGroups: any = result[0]; - const membergroups: any = result[1]; + this.userinfo = result[2] + this.userinfo_loaded = true + this.validatePublicKey() + const allowedMemberGroups: any = result[0] + const membergroups: any = result[1] for (const project of membergroups) { - this.projects.push(project); + this.projects.push(project) } for (const project of allowedMemberGroups) { - this.allowedProjects.push(project); + this.allowedProjects.push(project) } - this.projects_loaded = true; + this.projects_loaded = true if (this.allowedProjects.length === 1) { - this.selectedProject = this.allowedProjects[0]; - this.singleProject = true; - this.getSelectedProjectClient(); + this.selectedProject = this.allowedProjects[0] + this.singleProject = true + this.getSelectedProjectClient() } - }), - ); + }) + ) } loadProjectData(): void { - this.initial_loaded = false; - this.projectDataLoaded = false; - this.flavors = []; - this.flavors_loaded = false; - this.selectedImage = undefined; - this.selectedFlavor = undefined; + this.initial_loaded = false + this.projectDataLoaded = false + this.flavors = [] + this.flavors_loaded = false + this.selectedImage = undefined + this.selectedFlavor = undefined this.subscription.add( this.groupService .getGroupResources(this.selectedProject[1].toString()) .subscribe((res: ApplicationRessourceUsage): void => { - this.selectedProjectRessources = new ApplicationRessourceUsage(res); - this.getFlavors(this.selectedProject[1]); - this.checkResources(); - this.projectDataLoaded = true; - }), - ); + this.selectedProjectRessources = new ApplicationRessourceUsage(res) + this.getFlavors(this.selectedProject[1]) + this.checkResources() + this.projectDataLoaded = true + }) + ) } checkResources(): void { - this.newCores = 0; - this.newRam = 0; - this.newVms = 2; - this.newGpus = 0; - this.vm_limit_reached = this.selectedProjectRessources.used_vms + 2 > this.selectedProjectRessources.number_vms; - this.cores_limit_reached = this.selectedProjectRessources.cores_used >= this.selectedProjectRessources.cores_total; - this.ram_limit_reached = this.selectedProjectRessources.ram_used >= this.selectedProjectRessources.ram_total; + this.newCores = 0 + this.newRam = 0 + this.newVms = 2 + this.newGpus = 0 + this.vm_limit_reached = this.selectedProjectRessources.used_vms + 2 > this.selectedProjectRessources.number_vms + this.cores_limit_reached = this.selectedProjectRessources.cores_used >= this.selectedProjectRessources.cores_total + this.ram_limit_reached = this.selectedProjectRessources.ram_used >= this.selectedProjectRessources.ram_total } resizeFix(): void { - window.dispatchEvent(new Event('resize')); + window.dispatchEvent(new Event('resize')) } ngOnInit(): void { - this.tracker.trackPageView('Create Cluster'); - this.initializeData(); - this.generateRandomName(); + this.tracker.trackPageView('Create Cluster') + this.initializeData() + this.generateRandomName() this.subscription.add( this.voService.isVo().subscribe((result: IResponseTemplate): void => { - this.is_vo = result.value as boolean; - }), - ); + this.is_vo = result.value as boolean + }) + ) } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } setMasterFlavor(flavor: Flavor): void { - this.selectedMasterFlavor = flavor; - this.checkImageAgain(); + this.selectedMasterFlavor = flavor + this.checkImageAgain() } checkImageAgain(): void { if (this.selectedMasterImage !== undefined) { if (this.selectedMasterImage.min_disk > 0) { if (this.selectedMasterFlavor.rootdisk < this.selectedMasterImage.min_disk) { - this.selectedMasterImage = undefined; + this.selectedMasterImage = undefined } } } diff --git a/src/app/virtualmachines/clusters/cluster-actions/cluster-actions.component.spec.ts b/src/app/virtualmachines/clusters/cluster-actions/cluster-actions.component.spec.ts index 77fe7a065a..5bb16fd082 100644 --- a/src/app/virtualmachines/clusters/cluster-actions/cluster-actions.component.spec.ts +++ b/src/app/virtualmachines/clusters/cluster-actions/cluster-actions.component.spec.ts @@ -1,21 +1,21 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing' -import { ClusterActionsComponent } from './cluster-actions.component'; +import { ClusterActionsComponent } from './cluster-actions.component' describe('ClusterActionsComponent', () => { - let component: ClusterActionsComponent; - let fixture: ComponentFixture; + let component: ClusterActionsComponent + let fixture: ComponentFixture beforeEach(() => { TestBed.configureTestingModule({ - declarations: [ClusterActionsComponent], - }); - fixture = TestBed.createComponent(ClusterActionsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + declarations: [ClusterActionsComponent] + }) + fixture = TestBed.createComponent(ClusterActionsComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) it('should create', () => { - expect(component).toBeTruthy(); - }); -}); + expect(component).toBeTruthy() + }) +}) diff --git a/src/app/virtualmachines/clusters/cluster-actions/cluster-actions.component.ts b/src/app/virtualmachines/clusters/cluster-actions/cluster-actions.component.ts index 4e09071fb7..e9fb47ec71 100644 --- a/src/app/virtualmachines/clusters/cluster-actions/cluster-actions.component.ts +++ b/src/app/virtualmachines/clusters/cluster-actions/cluster-actions.component.ts @@ -1,86 +1,84 @@ -import { - Component, EventEmitter, Input, OnDestroy, Output, -} from '@angular/core'; -import { ClipboardService } from 'ngx-clipboard'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { Subscription } from 'rxjs'; -import { CLOUD_PORTAL_SUPPORT_MAIL, NEW_SVM_PORTAL_LINK } from '../../../../links/links'; -import { Clusterinfo, WorkerBatch } from '../clusterinfo'; -import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates'; -import { ResumeClusterComponent } from '../../modals/resume-cluster/resume-cluster.component'; -import { StopClusterComponent } from '../../modals/stop-cluster/stop-cluster.component'; -import { DeleteClusterComponent } from '../../modals/delete-cluster/delete-cluster.component'; -import { RenameClusterComponent } from '../../modals/rename-cluster/rename-cluster.component'; -import { PasswordClusterComponent } from '../../modals/password-cluster/password-cluster.component'; -import { ScaleClusterComponent } from '../../modals/scale-cluster/scale-cluster.component'; -import { VirtualmachineService } from '../../../api-connector/virtualmachine.service'; -import { NotificationModalComponent } from '../../../shared/modal/notification-modal'; +import { Component, EventEmitter, Input, OnDestroy, Output } from '@angular/core' +import { ClipboardService } from 'ngx-clipboard' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { Subscription } from 'rxjs' +import { CLOUD_PORTAL_SUPPORT_MAIL, NEW_SVM_PORTAL_LINK } from '../../../../links/links' +import { Clusterinfo, WorkerBatch } from '../clusterinfo' +import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates' +import { ResumeClusterComponent } from '../../modals/resume-cluster/resume-cluster.component' +import { StopClusterComponent } from '../../modals/stop-cluster/stop-cluster.component' +import { DeleteClusterComponent } from '../../modals/delete-cluster/delete-cluster.component' +import { RenameClusterComponent } from '../../modals/rename-cluster/rename-cluster.component' +import { PasswordClusterComponent } from '../../modals/password-cluster/password-cluster.component' +import { ScaleClusterComponent } from '../../modals/scale-cluster/scale-cluster.component' +import { VirtualmachineService } from '../../../api-connector/virtualmachine.service' +import { NotificationModalComponent } from '../../../shared/modal/notification-modal' @Component({ selector: 'app-cluster-actions', templateUrl: './cluster-actions.component.html', - styleUrls: ['./cluster-actions.component.scss'], + styleUrls: ['./cluster-actions.component.scss'] }) export class ClusterActionsComponent implements OnDestroy { - @Input() cluster: Clusterinfo; - bsModalRef: BsModalRef; - subscription: Subscription = new Subscription(); - SCALE_UP: string = 'scale_up'; - SCALE_DOWN: string = 'scale_down'; - SCALE_SUCCESS: string = 'scale_success'; - show_connection_info: boolean = false; + @Input() cluster: Clusterinfo + bsModalRef: BsModalRef + subscription: Subscription = new Subscription() + SCALE_UP: string = 'scale_up' + SCALE_DOWN: string = 'scale_down' + SCALE_SUCCESS: string = 'scale_success' + show_connection_info: boolean = false - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); - @Output() readonly stopStatusLoop: EventEmitter = new EventEmitter(); - @Output() readonly startStatusLoop: EventEmitter = new EventEmitter(); + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() + @Output() readonly stopStatusLoop: EventEmitter = new EventEmitter() + @Output() readonly startStatusLoop: EventEmitter = new EventEmitter() - protected readonly CLOUD_PORTAL_SUPPORT_MAIL = CLOUD_PORTAL_SUPPORT_MAIL; + protected readonly CLOUD_PORTAL_SUPPORT_MAIL = CLOUD_PORTAL_SUPPORT_MAIL constructor( private clipboardService: ClipboardService, private modalService: BsModalService, - private virtualmachineservice: VirtualmachineService, + private virtualmachineservice: VirtualmachineService ) {} copyToClipboard(text: string): void { if (this.clipboardService.isSupported) { - this.clipboardService.copy(text); + this.clipboardService.copy(text) } } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() // this.statusSubscription.unsubscribe(); // this.stopAllCheckStatusTimer(); } showResumeModal(): void { - const initialState = { cluster: this.cluster }; + const initialState = { cluster: this.cluster } - this.bsModalRef = this.modalService.show(ResumeClusterComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(ResumeClusterComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } /** * Show Cluster Stop modal */ showStopModal(): void { - const initialState = { cluster: this.cluster }; + const initialState = { cluster: this.cluster } - this.bsModalRef = this.modalService.show(StopClusterComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(StopClusterComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } showDeleteModal(): void { // this.stopAllCheckStatusTimer(); // const all_loaded: boolean = this.get_all_batches_loaded(); - const initialState = { cluster: this.cluster }; + const initialState = { cluster: this.cluster } - this.bsModalRef = this.modalService.show(DeleteClusterComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(DeleteClusterComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } /** @@ -89,177 +87,177 @@ export class ClusterActionsComponent implements OnDestroy { showRenameModal(): void { // this.stopAllCheckStatusTimer(); // const all_loaded: boolean = this.get_all_batches_loaded(); - const initialState = { cluster: this.cluster }; + const initialState = { cluster: this.cluster } - this.bsModalRef = this.modalService.show(RenameClusterComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(RenameClusterComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } showPasswordModal(): void { // this.stopCheckStatusTimer(); - const initialState = { cluster: this.cluster }; + const initialState = { cluster: this.cluster } - this.bsModalRef = this.modalService.show(PasswordClusterComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(PasswordClusterComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } showScaleModal(mode: string, msg?: string): void { - this.hideCurrentModal(); + this.hideCurrentModal() // this.stopCheckStatusTimer(); - const initialState = { cluster: this.cluster, mode, msg }; - this.bsModalRef = this.modalService.show(ScaleClusterComponent, { initialState }); - this.bsModalRef.setClass('modal-xl'); - this.subscribeToBsModalRef(); + const initialState = { cluster: this.cluster, mode, msg } + this.bsModalRef = this.modalService.show(ScaleClusterComponent, { initialState }) + this.bsModalRef.setClass('modal-xl') + this.subscribeToBsModalRef() } hideCurrentModal() { if (this.bsModalRef) { - this.modalService.hide(this.bsModalRef.id); + this.modalService.hide(this.bsModalRef.id) } } stopCluster(): void { - this.stopStatusLoop.emit(); + this.stopStatusLoop.emit() - this.cluster.status = VirtualMachineStates.POWERING_OFF; + this.cluster.status = VirtualMachineStates.POWERING_OFF this.subscription.add( this.virtualmachineservice.stopCluster(this.cluster.cluster_id).subscribe((): void => { - this.cluster.status = VirtualMachineStates.POWERING_OFF; - this.startStatusLoop.emit(); - }), - ); + this.cluster.status = VirtualMachineStates.POWERING_OFF + this.startStatusLoop.emit() + }) + ) } renameCluster(name: string): void { - this.stopStatusLoop.emit(); + this.stopStatusLoop.emit() this.subscription.add( this.virtualmachineservice.renameCluster(this.cluster.cluster_id, name).subscribe((cl: Clusterinfo): void => { - this.cluster.name = cl.name; - this.startStatusLoop.emit(); - }), - ); + this.cluster.name = cl.name + this.startStatusLoop.emit() + }) + ) } deleteCluster(): void { - this.stopStatusLoop.emit(); + this.stopStatusLoop.emit() - this.cluster.status = VirtualMachineStates.DELETING; + this.cluster.status = VirtualMachineStates.DELETING this.subscription.add( this.virtualmachineservice.deleteCluster(this.cluster.cluster_id).subscribe((): void => { - this.cluster.status = VirtualMachineStates.DELETED; - this.startStatusLoop.emit(); - }), - ); + this.cluster.status = VirtualMachineStates.DELETED + this.startStatusLoop.emit() + }) + ) } resumeCluster(): void { - this.stopStatusLoop.emit(); - this.cluster.status = VirtualMachineStates.POWERING_ON; + this.stopStatusLoop.emit() + this.cluster.status = VirtualMachineStates.POWERING_ON this.subscription.add( this.virtualmachineservice.resumeCluster(this.cluster.cluster_id).subscribe((): void => { - this.startStatusLoop.emit(); - }), - ); + this.startStatusLoop.emit() + }) + ) } showNotificationModal( notificationModalTitle: string, notificationModalMessage: string, - notificationModalType: string, + notificationModalType: string ) { - const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage }; + const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage } if (this.bsModalRef) { - this.bsModalRef.hide(); + this.bsModalRef.hide() } - this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); + this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') } scaleDownCluster(cluster: Clusterinfo): void { - this.stopStatusLoop.emit(); + this.stopStatusLoop.emit() - this.cluster = cluster; - let scale_down_count: number = 0; + this.cluster = cluster + let scale_down_count: number = 0 - const scale_down_batches: any = []; + const scale_down_batches: any = [] this.cluster.worker_batches.forEach((batch: WorkerBatch): void => { if (batch.delete_count > 0) { - scale_down_batches.push({ worker_flavor_name: batch.flavor.name, downscale_count: batch.delete_count }); - scale_down_count += batch.delete_count; + scale_down_batches.push({ worker_flavor_name: batch.flavor.name, downscale_count: batch.delete_count }) + scale_down_count += batch.delete_count } - }); - let msg: string = 'Scaling Down Batches: '; + }) + let msg: string = 'Scaling Down Batches: ' for (const batch of scale_down_batches) { - msg += ` \n[Batch with Flavor ${batch.worker_flavor_name} by ${batch.downscale_count} instances ]`; + msg += ` \n[Batch with Flavor ${batch.worker_flavor_name} by ${batch.downscale_count} instances ]` } - this.showNotificationModal('Scaling Down', msg, 'info'); + this.showNotificationModal('Scaling Down', msg, 'info') this.subscription.add( this.virtualmachineservice .scaleDownCluster(this.cluster.cluster_id, scale_down_batches) .subscribe((res: any): void => { - this.cluster.password = res['password']; + this.cluster.password = res['password'] - this.cluster.setScaleDownBatchesCount(); + this.cluster.setScaleDownBatchesCount() - this.cluster.instances_count -= scale_down_count; - this.startStatusLoop.emit(); - this.showScaleModal(this.SCALE_SUCCESS, 'Successfully Scaled Down!'); - }), - ); + this.cluster.instances_count -= scale_down_count + this.startStatusLoop.emit() + this.showScaleModal(this.SCALE_SUCCESS, 'Successfully Scaled Down!') + }) + ) } scaleUpCluster(selectedBatch: WorkerBatch): void { - this.stopStatusLoop.emit(); + this.stopStatusLoop.emit() - const scale_up_count: number = selectedBatch.upscale_count; - this.showNotificationModal('Upscaling Cluster', `Starting ${scale_up_count} additional workers..`, 'info'); + const scale_up_count: number = selectedBatch.upscale_count + this.showNotificationModal('Upscaling Cluster', `Starting ${scale_up_count} additional workers..`, 'info') this.subscription.add( this.virtualmachineservice .scaleCluster( this.cluster.cluster_id, encodeURIComponent(selectedBatch.flavor.name), - selectedBatch.upscale_count, + selectedBatch.upscale_count ) .subscribe((res: any): void => { - selectedBatch.setNewScalingUpWorkerCount(); - this.cluster.password = res['password']; - this.startStatusLoop.emit(); + selectedBatch.setNewScalingUpWorkerCount() + this.cluster.password = res['password'] + this.startStatusLoop.emit() this.showScaleModal( this.SCALE_SUCCESS, - `The start of ${scale_up_count} workers was successfully initiated. Remember to configure your cluster after the machines are active!'`, - ); - }), - ); + `The start of ${scale_up_count} workers was successfully initiated. Remember to configure your cluster after the machines are active!'` + ) + }) + ) } subscribeToBsModalRef(): void { this.subscription.add( this.bsModalRef.content.event.subscribe((result: any) => { if ('new_name' in result) { - this.renameCluster(result['new_name']); + this.renameCluster(result['new_name']) } else if ('deleteCluster' in result) { - this.deleteCluster(); + this.deleteCluster() } else if ('scaleDownCluster' in result) { - this.scaleDownCluster(result['cluster']); + this.scaleDownCluster(result['cluster']) } else if ('scaleUpCluster' in result) { - this.scaleUpCluster(result['selectedBatch']); + this.scaleUpCluster(result['selectedBatch']) } else if ('resumeCluster' in result) { - this.resumeCluster(); + this.resumeCluster() } else if ('stopCluster' in result) { - this.stopCluster(); + this.stopCluster() } else { // this.check_status_loop(); } - }), - ); + }) + ) } - protected readonly NEW_SVM_PORTAL_LINK = NEW_SVM_PORTAL_LINK; + protected readonly NEW_SVM_PORTAL_LINK = NEW_SVM_PORTAL_LINK } diff --git a/src/app/virtualmachines/clusters/clusterdetail/clusterdetail.component.ts b/src/app/virtualmachines/clusters/clusterdetail/clusterdetail.component.ts index 6ae64d9312..bdcbfe3500 100644 --- a/src/app/virtualmachines/clusters/clusterdetail/clusterdetail.component.ts +++ b/src/app/virtualmachines/clusters/clusterdetail/clusterdetail.component.ts @@ -1,24 +1,22 @@ -import { - Component, OnDestroy, OnInit, inject, -} from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { Subscription } from 'rxjs'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { ClipboardService } from 'ngx-clipboard'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { Clusterinfo } from '../clusterinfo'; -import { VirtualmachineService } from '../../../api-connector/virtualmachine.service'; -import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates'; -import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine'; +import { Component, OnDestroy, OnInit, inject } from '@angular/core' +import { ActivatedRoute } from '@angular/router' +import { Subscription } from 'rxjs' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { ClipboardService } from 'ngx-clipboard' +import { MatomoTracker } from 'ngx-matomo-client' +import { Clusterinfo } from '../clusterinfo' +import { VirtualmachineService } from '../../../api-connector/virtualmachine.service' +import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates' +import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine' import { STATUS_LINK, WIKI_GUACAMOLE_LINK, WIKI_RSTUDIO_LINK, WIKI_VOLUME_OVERVIEW, - WIKI_PERSISTENT_TERMINAL_LINK, -} from '../../../../links/links'; -import { DeleteVmComponent } from '../../modals/delete-vm/delete-vm.component'; -import { TemplateNames } from '../../conda/template-names'; + WIKI_PERSISTENT_TERMINAL_LINK +} from '../../../../links/links' +import { DeleteVmComponent } from '../../modals/delete-vm/delete-vm.component' +import { TemplateNames } from '../../conda/template-names' /** * Clusterdetail component. @@ -27,89 +25,89 @@ import { TemplateNames } from '../../conda/template-names'; selector: 'app-clusterdetail', templateUrl: './clusterdetail.component.html', styleUrls: ['./clusterdetail.component.scss'], - providers: [VirtualmachineService], + providers: [VirtualmachineService] }) export class ClusterdetailComponent implements OnInit, OnDestroy { - private readonly tracker = inject(MatomoTracker); - WIKI_RSTUDIO_LINK: string = WIKI_RSTUDIO_LINK; - WIKI_GUACAMOLE_LINK: string = WIKI_GUACAMOLE_LINK; - WIKI_VOLUME_OVERVIEW: string = WIKI_VOLUME_OVERVIEW; + private readonly tracker = inject(MatomoTracker) + WIKI_RSTUDIO_LINK: string = WIKI_RSTUDIO_LINK + WIKI_GUACAMOLE_LINK: string = WIKI_GUACAMOLE_LINK + WIKI_VOLUME_OVERVIEW: string = WIKI_VOLUME_OVERVIEW - WIKI_PERSISTENT_TERMINAL_LINK: string = WIKI_PERSISTENT_TERMINAL_LINK; - virtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); + WIKI_PERSISTENT_TERMINAL_LINK: string = WIKI_PERSISTENT_TERMINAL_LINK + virtualMachineStates: VirtualMachineStates = new VirtualMachineStates() - cluster_id: string; - cluster: Clusterinfo; - isLoaded: boolean = false; - notFoundCluster: boolean = false; - checkStatusTimeout: number = 5000; - subscription: Subscription = new Subscription(); - errorOnLoading = false; - STATUS_LINK: string = STATUS_LINK; - bsModalRef: BsModalRef; - all_worker_loaded: boolean = false; - checkStatusTimer: ReturnType; + cluster_id: string + cluster: Clusterinfo + isLoaded: boolean = false + notFoundCluster: boolean = false + checkStatusTimeout: number = 5000 + subscription: Subscription = new Subscription() + errorOnLoading = false + STATUS_LINK: string = STATUS_LINK + bsModalRef: BsModalRef + all_worker_loaded: boolean = false + checkStatusTimer: ReturnType - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); - statusSubscription: Subscription = new Subscription(); + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() + statusSubscription: Subscription = new Subscription() constructor( private activatedRoute: ActivatedRoute, private virtualmachineService: VirtualmachineService, private modalService: BsModalService, - private clipboardService: ClipboardService, + private clipboardService: ClipboardService ) { - this.activatedRoute = activatedRoute; - this.virtualmachineService = virtualmachineService; + this.activatedRoute = activatedRoute + this.virtualmachineService = virtualmachineService } ngOnInit(): void { this.activatedRoute.params.subscribe((paramsId: any): void => { - this.cluster_id = paramsId.id; - this.tracker.trackPageView(`Cluster Detail Page: ${paramsId.id}`); - this.setClusterById(); - }); + this.cluster_id = paramsId.id + this.tracker.trackPageView(`Cluster Detail Page: ${paramsId.id}`) + this.setClusterById() + }) } resenv_by_play(vm: VirtualMachine): boolean { for (const mode of vm.modes) { if (TemplateNames.ALL_TEMPLATE_NAMES.indexOf(mode.name) !== -1) { - return false; + return false } } - return true; + return true } deleteCluster(): void { this.virtualmachineService.deleteCluster(this.cluster_id).subscribe((): void => { - this.cluster.status = 'Deleted'; - this.cluster.master_instance.status = VirtualMachineStates.DELETED; + this.cluster.status = 'Deleted' + this.cluster.master_instance.status = VirtualMachineStates.DELETED this.cluster.worker_instances.forEach((vm: VirtualMachine): void => { - vm.status = VirtualMachineStates.DELETED; - }); - }); + vm.status = VirtualMachineStates.DELETED + }) + }) } copyToClipboard(text: string): void { if (this.clipboardService.isSupported) { - this.clipboardService.copy(text); + this.clipboardService.copy(text) } } setClusterById(): void { this.virtualmachineService.getClusterInfo(this.cluster_id).subscribe( (cluster_info: Clusterinfo): void => { - this.cluster = new Clusterinfo(cluster_info); - this.isLoaded = true; - this.check_status_loop(); - this.check_status_loop_cluster_vms(); + this.cluster = new Clusterinfo(cluster_info) + this.isLoaded = true + this.check_status_loop() + this.check_status_loop_cluster_vms() }, () => { - this.errorOnLoading = true; - this.isLoaded = true; - }, - ); + this.errorOnLoading = true + this.isLoaded = true + } + ) } check_status_loop_vm(vm: VirtualMachine, final_state: string = VirtualMachineStates.ACTIVE): void { @@ -119,49 +117,49 @@ export class ClusterdetailComponent implements OnInit, OnDestroy { this.virtualmachineService .checkVmStatus(vm.openstackid, vm.name) .subscribe((updated_vm: VirtualMachine): void => { - updated_vm = new VirtualMachine(updated_vm); + updated_vm = new VirtualMachine(updated_vm) // tslint:disable-next-line:triple-equals if (vm !== undefined) { - this.cluster.worker_instances[this.cluster.worker_instances.indexOf(vm)] = updated_vm; + this.cluster.worker_instances[this.cluster.worker_instances.indexOf(vm)] = updated_vm if (VirtualMachineStates.IN_PROCESS_STATES.indexOf(updated_vm.status) !== -1) { - this.check_status_loop_vm(updated_vm, final_state); + this.check_status_loop_vm(updated_vm, final_state) } else if (updated_vm.status === VirtualMachineStates.MIGRATED) { // do nothing } else if (VirtualMachineStates.NOT_IN_PROCESS_STATES.indexOf(updated_vm.status) !== -1) { if (final_state && updated_vm.status !== final_state) { - this.check_status_loop_vm(updated_vm, final_state); + this.check_status_loop_vm(updated_vm, final_state) } else { - this.check_status_loop_vm(updated_vm, final_state); + this.check_status_loop_vm(updated_vm, final_state) } } } - }), - ); + }) + ) }, - this.checkStatusTimeout, - ); + this.checkStatusTimeout + ) } get_all_batches_loaded(): boolean { - let worker_amount: number = 0; + let worker_amount: number = 0 for (const worker_batch of this.cluster.worker_batches) { - worker_amount += worker_batch.worker_count; + worker_amount += worker_batch.worker_count } - return this.cluster.worker_instances.length === worker_amount; + return this.cluster.worker_instances.length === worker_amount } stopAllCheckStatusTimer(): void { - this.stopCheckStatusTimer(); + this.stopCheckStatusTimer() } stopCheckStatusTimer(): void { if (this.checkStatusTimer) { - clearTimeout(this.checkStatusTimer); + clearTimeout(this.checkStatusTimer) } if (this.statusSubscription) { - this.statusSubscription.unsubscribe(); + this.statusSubscription.unsubscribe() } } @@ -170,96 +168,96 @@ export class ClusterdetailComponent implements OnInit, OnDestroy { */ check_status_loop(): void { - this.all_worker_loaded = this.get_all_batches_loaded(); - this.stopAllCheckStatusTimer(); - this.statusSubscription = new Subscription(); + this.all_worker_loaded = this.get_all_batches_loaded() + this.stopAllCheckStatusTimer() + this.statusSubscription = new Subscription() this.checkStatusTimer = setTimeout((): void => { this.statusSubscription.add( this.virtualmachineService .getClusterInfo(this.cluster.cluster_id) .subscribe((updated_cluster: Clusterinfo): void => { - const password: string = this.cluster.password; - this.cluster = new Clusterinfo(updated_cluster); - this.cluster.password = password; + const password: string = this.cluster.password + this.cluster = new Clusterinfo(updated_cluster) + this.cluster.password = password if ( - this.cluster.status !== VirtualMachineStates.DELETED - || this.cluster.status !== VirtualMachineStates.MIGRATED + this.cluster.status !== VirtualMachineStates.DELETED || + this.cluster.status !== VirtualMachineStates.MIGRATED ) { - this.check_status_loop(); - this.check_status_loop_cluster_vms(); + this.check_status_loop() + this.check_status_loop_cluster_vms() } - }), - ); - }, this.checkStatusTimeout); + }) + ) + }, this.checkStatusTimeout) } check_status_loop_cluster_vms(): void { this.cluster.worker_instances.forEach((vm: VirtualMachine): void => { if ( - vm.status !== VirtualMachineStates.ACTIVE - && VirtualMachineStates.NOT_IN_PROCESS_STATES.indexOf(vm.status) === -1 + vm.status !== VirtualMachineStates.ACTIVE && + VirtualMachineStates.NOT_IN_PROCESS_STATES.indexOf(vm.status) === -1 ) { - this.check_status_loop_vm(vm); + this.check_status_loop_vm(vm) } - }); + }) } ngOnDestroy(): void { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } showDeleteModal(worker: VirtualMachine): void { - const initialState = { virtualMachine: worker, clusterWorker: true }; + const initialState = { virtualMachine: worker, clusterWorker: true } - this.bsModalRef = this.modalService.show(DeleteVmComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(DeleteVmComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } subscribeToBsModalRef(): void { this.subscription.add( this.bsModalRef.content.event.subscribe((result: any) => { if ('deleteVM' in result) { - this.deleteVM(result['worker']); + this.deleteVM(result['worker']) } - }), - ); + }) + ) } deleteVM(worker: VirtualMachine): void { - this.setInstanceStatus(worker, VirtualMachineStates.DELETING); + this.setInstanceStatus(worker, VirtualMachineStates.DELETING) this.subscription.add( this.virtualmachineService.deleteVM(worker.openstackid).subscribe((updated_vm: VirtualMachine): void => { if (updated_vm.status !== VirtualMachineStates.DELETED) { setTimeout((): void => { - this.deleteVM(worker); - }, this.checkStatusTimeout); + this.deleteVM(worker) + }, this.checkStatusTimeout) } else { - this.removeInstance(worker); + this.removeInstance(worker) } - }), - ); + }) + ) } removeInstance(worker: VirtualMachine): void { - const worker_instances: VirtualMachine[] = []; + const worker_instances: VirtualMachine[] = [] for (const vm of this.cluster.worker_instances) { if (vm.openstackid === worker.openstackid) { - continue; + continue } - worker_instances.push(vm); + worker_instances.push(vm) } - this.cluster.worker_instances = worker_instances; + this.cluster.worker_instances = worker_instances } setInstanceStatus(worker: VirtualMachine, status: string): void { - const worker_instances: VirtualMachine[] = []; + const worker_instances: VirtualMachine[] = [] for (const vm of this.cluster.worker_instances) { if (vm.openstackid === worker.openstackid) { - vm.status = status; + vm.status = status } - worker_instances.push(vm); + worker_instances.push(vm) } - this.cluster.worker_instances = worker_instances; + this.cluster.worker_instances = worker_instances } } diff --git a/src/app/virtualmachines/clusters/clusterinfo.ts b/src/app/virtualmachines/clusters/clusterinfo.ts index a629b07558..abdf0b9191 100644 --- a/src/app/virtualmachines/clusters/clusterinfo.ts +++ b/src/app/virtualmachines/clusters/clusterinfo.ts @@ -1,40 +1,40 @@ -// eslint-disable-next-line max-classes-per-file -import { VirtualMachine } from '../virtualmachinemodels/virtualmachine'; -import { Client } from '../../vo_manager/clients/client.model'; -import { Flavor } from '../virtualmachinemodels/flavor'; -import { Image } from '../virtualmachinemodels/image'; -import { ApplicationRessourceUsage } from '../../applications/application-ressource-usage/application-ressource-usage'; -import { VirtualMachineStates } from '../virtualmachinemodels/virtualmachinestates'; + +import { VirtualMachine } from '../virtualmachinemodels/virtualmachine' +import { Client } from '../../vo_manager/clients/client.model' +import { Flavor } from '../virtualmachinemodels/flavor' +import { Image } from '../virtualmachinemodels/image' +import { ApplicationRessourceUsage } from '../../applications/application-ressource-usage/application-ressource-usage' +import { VirtualMachineStates } from '../virtualmachinemodels/virtualmachinestates' /** * Cluster Worker Batch */ export class WorkerBatch { - index: number; - flavor: Flavor; - image: Image; - worker_count: number = 0; - running_worker: number = 0; - delete_count: number = 0; - upscale_count: number = 0; - max_scale_up_count: number = 0; - max_worker_count: number; - usable_flavors: Flavor[] = []; - valid_batch: boolean = false; + index: number + flavor: Flavor + image: Image + worker_count: number = 0 + running_worker: number = 0 + delete_count: number = 0 + upscale_count: number = 0 + max_scale_up_count: number = 0 + max_worker_count: number + usable_flavors: Flavor[] = [] + valid_batch: boolean = false constructor(index: number, batch?: Partial) { - this.index = index; - Object.assign(this, batch); + this.index = index + Object.assign(this, batch) if (batch) { if (batch.flavor) { - this.flavor = new Flavor(batch.flavor); + this.flavor = new Flavor(batch.flavor) } if (batch.image) { - this.image = new Image(batch.image); + this.image = new Image(batch.image) } if (batch.usable_flavors) { for (const flavor of batch.usable_flavors) { - this.usable_flavors.push(new Flavor(flavor)); + this.usable_flavors.push(new Flavor(flavor)) } } } @@ -42,19 +42,19 @@ export class WorkerBatch { public setMaxWorkerCount(ressource_usage: ApplicationRessourceUsage): void { if (this.flavor) { - this.max_worker_count = ressource_usage.calcMaxScaleUpWorkerInstancesByFlavor(this.flavor); + this.max_worker_count = ressource_usage.calcMaxScaleUpWorkerInstancesByFlavor(this.flavor) } } public setNewScalingDownWorkerCount(): void { - this.worker_count -= this.delete_count; - this.running_worker -= this.delete_count; - this.delete_count = 0; + this.worker_count -= this.delete_count + this.running_worker -= this.delete_count + this.delete_count = 0 } public setNewScalingUpWorkerCount(): void { - this.worker_count += this.upscale_count; - this.upscale_count = 0; + this.worker_count += this.upscale_count + this.upscale_count = 0 } } @@ -62,78 +62,78 @@ export class WorkerBatch { * Clusterinfo */ export class Clusterinfo { - master_instance: VirtualMachine; - worker_instances: VirtualMachine[]; - worker_batches: WorkerBatch[]; - client: Client; - name: string; - public_ip: string; - cluster_id: string; - group_id: string; - project_id: string; - user: string; - instances_count: number; - launch_date: string; - key_name: string; - status: string; - application_id: string; - project: string; - userlogin: string; - password: string; - master_instance_openstack_id: string; + master_instance: VirtualMachine + worker_instances: VirtualMachine[] + worker_batches: WorkerBatch[] + client: Client + name: string + public_ip: string + cluster_id: string + group_id: string + project_id: string + user: string + instances_count: number + launch_date: string + key_name: string + status: string + application_id: string + project: string + userlogin: string + password: string + master_instance_openstack_id: string - migrate_project_to_simple_vm: boolean = false; + migrate_project_to_simple_vm: boolean = false - project_is_migrated_to_simple_vm: boolean = false; + project_is_migrated_to_simple_vm: boolean = false constructor(cl?: Partial) { - Object.assign(this, cl); + Object.assign(this, cl) if (cl) { if (cl.master_instance) { - this.master_instance = new VirtualMachine(cl.master_instance); + this.master_instance = new VirtualMachine(cl.master_instance) /** * TODO: Remove once cluster status is updated by api */ if (this.master_instance.status === VirtualMachineStates.SHUTOFF) { - this.status = VirtualMachineStates.SHUTOFF; + this.status = VirtualMachineStates.SHUTOFF } } - this.worker_instances = []; + this.worker_instances = [] if (cl.worker_instances) { for (const clWorkerInstance of cl.worker_instances) { - this.worker_instances.push(new VirtualMachine(clWorkerInstance)); + this.worker_instances.push(new VirtualMachine(clWorkerInstance)) } } if (cl.worker_batches) { - this.worker_batches = []; - this.set_worker_batches(cl.worker_batches); + this.worker_batches = [] + this.set_worker_batches(cl.worker_batches) } - this.sortWorkerByStatus(); + this.sortWorkerByStatus() } } public setScaleDownBatchesCount(): void { this.worker_batches.forEach((batch: WorkerBatch): void => { - batch.setNewScalingDownWorkerCount(); + batch.setNewScalingDownWorkerCount() if (batch.worker_count === 0) { - this.worker_batches.splice(this.worker_batches.indexOf(batch)); - this.setScaleDownBatchesCount(); + this.worker_batches.splice(this.worker_batches.indexOf(batch)) + this.setScaleDownBatchesCount() } - }); + }) } public create_new_batch(idx: number): void { - const new_batch: WorkerBatch = new WorkerBatch(idx); - const image: Image = new Image(); - image.name = this.master_instance.image; - new_batch.image = image; - this.worker_batches.push(new_batch); + const new_batch: WorkerBatch = new WorkerBatch(idx) + const image: Image = new Image() + image.name = this.master_instance.image + new_batch.image = image + this.worker_batches.push(new_batch) } public remove_batch(batch: WorkerBatch): void { - const idx: number = this.worker_batches.indexOf(batch); + const idx: number = this.worker_batches.indexOf(batch) if (this.worker_batches.indexOf(batch) !== -1) { - this.worker_batches.splice(idx, 1); + this.worker_batches.splice(idx, 1) } } @@ -142,15 +142,17 @@ export class Clusterinfo { // this.worker_batches.push(new WorkerBatch(worker_batch.index, worker_batch)); // } this.worker_batches = workerBatches.map( - (workerBatch: WorkerBatch): WorkerBatch => new WorkerBatch(workerBatch.index, workerBatch), - ); + (workerBatch: WorkerBatch): WorkerBatch => new WorkerBatch(workerBatch.index, workerBatch) + ) } private get_batches_count(): number { - return this.worker_batches.length; + return this.worker_batches.length } private sortWorkerByStatus(): void { - this.worker_instances.sort((w1: VirtualMachine, w2: VirtualMachine): any => (w1.status > w2.status ? 1 : w2.status > w1.status ? -1 : 0)); + this.worker_instances.sort((w1: VirtualMachine, w2: VirtualMachine): any => + w1.status > w2.status ? 1 : w2.status > w1.status ? -1 : 0 + ) } } diff --git a/src/app/virtualmachines/clusters/clusterinfo/clusterinfo.component.ts b/src/app/virtualmachines/clusters/clusterinfo/clusterinfo.component.ts index a152ca7f47..09cb19c5c7 100644 --- a/src/app/virtualmachines/clusters/clusterinfo/clusterinfo.component.ts +++ b/src/app/virtualmachines/clusters/clusterinfo/clusterinfo.component.ts @@ -1,14 +1,13 @@ -import { Component, Input } from '@angular/core'; -import { Clusterinfo } from '../clusterinfo'; +import { Component, Input } from '@angular/core' +import { Clusterinfo } from '../clusterinfo' /** * Clusterinfo component */ @Component({ selector: 'app-clusterinfo', - templateUrl: './clusterinfo.component.html', + templateUrl: './clusterinfo.component.html' }) export class ClusterinfoComponent { - @Input() cluster: Clusterinfo; - + @Input() cluster: Clusterinfo } diff --git a/src/app/virtualmachines/clusters/clusteroverview/clusterOverview.component.ts b/src/app/virtualmachines/clusters/clusteroverview/clusterOverview.component.ts index a0c66edc07..f93fe328e7 100644 --- a/src/app/virtualmachines/clusters/clusteroverview/clusterOverview.component.ts +++ b/src/app/virtualmachines/clusters/clusteroverview/clusterOverview.component.ts @@ -1,31 +1,29 @@ -/* eslint-disable no-mixed-spaces-and-tabs */ -import { - Component, OnDestroy, OnInit, inject, -} from '@angular/core'; -import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; -import { Subject, Subscription } from 'rxjs'; -import { UntypedFormBuilder } from '@angular/forms'; -import { ClipboardService } from 'ngx-clipboard'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { VirtualmachineService } from '../../../api-connector/virtualmachine.service'; -import { FullLayoutComponent } from '../../../layouts/full-layout.component'; -import { UserService } from '../../../api-connector/user.service'; -import { ImageService } from '../../../api-connector/image.service'; -import { FacilityService } from '../../../api-connector/facility.service'; -import { elixir_id, is_vo } from '../../../shared/globalvar'; -import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates'; -import { GroupService } from '../../../api-connector/group.service'; -import { ClientService } from '../../../api-connector/client.service'; -import { Clusterinfo } from '../clusterinfo'; -import { CLOUD_PORTAL_SUPPORT_MAIL, SCALE_SCRIPT_LINK, STATUS_LINK } from '../../../../links/links'; -import { AbstractBaseClass } from '../../../shared/shared_modules/baseClass/abstract-base-class'; -import { Flavor } from '../../virtualmachinemodels/flavor'; -import { FlavorService } from '../../../api-connector/flavor.service'; -import { ClusterPage } from '../clusterPage.model'; -import { Clusterstates } from '../clusterstatus/clusterstates'; -import { ApplicationsService } from '../../../api-connector/applications.service'; - -export const SCALING_SCRIPT_NAME: string = 'scaling.py'; + +import { Component, OnDestroy, OnInit, inject } from '@angular/core' +import { debounceTime, distinctUntilChanged } from 'rxjs/operators' +import { Subject, Subscription } from 'rxjs' +import { UntypedFormBuilder } from '@angular/forms' +import { ClipboardService } from 'ngx-clipboard' +import { MatomoTracker } from 'ngx-matomo-client' +import { VirtualmachineService } from '../../../api-connector/virtualmachine.service' +import { FullLayoutComponent } from '../../../layouts/full-layout.component' +import { UserService } from '../../../api-connector/user.service' +import { ImageService } from '../../../api-connector/image.service' +import { FacilityService } from '../../../api-connector/facility.service' +import { elixir_id, is_vo } from '../../../shared/globalvar' +import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates' +import { GroupService } from '../../../api-connector/group.service' +import { ClientService } from '../../../api-connector/client.service' +import { Clusterinfo } from '../clusterinfo' +import { CLOUD_PORTAL_SUPPORT_MAIL, SCALE_SCRIPT_LINK, STATUS_LINK } from '../../../../links/links' +import { AbstractBaseClass } from '../../../shared/shared_modules/baseClass/abstract-base-class' +import { Flavor } from '../../virtualmachinemodels/flavor' +import { FlavorService } from '../../../api-connector/flavor.service' +import { ClusterPage } from '../clusterPage.model' +import { Clusterstates } from '../clusterstatus/clusterstates' +import { ApplicationsService } from '../../../api-connector/applications.service' + +export const SCALING_SCRIPT_NAME: string = 'scaling.py' /** * Cluster overview componentn. @@ -43,75 +41,75 @@ export const SCALING_SCRIPT_NAME: string = 'scaling.py'; GroupService, ClientService, GroupService, - FlavorService, - ], + FlavorService + ] }) export class ClusterOverviewComponent extends AbstractBaseClass implements OnInit, OnDestroy { - title: string = 'Cluster Overview'; - private readonly tracker = inject(MatomoTracker); - private subscription: Subscription = new Subscription(); + title: string = 'Cluster Overview' + private readonly tracker = inject(MatomoTracker) + private subscription: Subscription = new Subscription() - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); - ClusterStates: Clusterstates = new Clusterstates(); + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() + ClusterStates: Clusterstates = new Clusterstates() - cluster_page: ClusterPage = new ClusterPage(); - currentPage: number = 1; - DEBOUNCE_TIME: number = 300; - FILTER_DEBOUNCE_TIME: number = 2000; - SCALING_SCRIPT_LINK: string = SCALE_SCRIPT_LINK; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - STATUS_LINK: string = STATUS_LINK; - user_elixir_id: string = elixir_id; + cluster_page: ClusterPage = new ClusterPage() + currentPage: number = 1 + DEBOUNCE_TIME: number = 300 + FILTER_DEBOUNCE_TIME: number = 2000 + SCALING_SCRIPT_LINK: string = SCALE_SCRIPT_LINK + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + STATUS_LINK: string = STATUS_LINK + user_elixir_id: string = elixir_id - isSearching: boolean = true; + isSearching: boolean = true /** * Facilities where the user is manager ['name',id]. */ - public managerFacilities: [string, number][]; + public managerFacilities: [string, number][] /** * Chosen facility. */ - public selectedFacility: [string, number]; + public selectedFacility: [string, number] - filter: string; - cluster_per_site: number = 7; - total_pages: number; - total_items: number; - clusters: Clusterinfo[] = []; + filter: string + cluster_per_site: number = 7 + total_pages: number + total_items: number + clusters: Clusterinfo[] = [] /** * If user is vo admin. */ - items_per_page: number = 7; + items_per_page: number = 7 - is_vo_admin: boolean; - flavors: Flavor[] = []; - flavors_usable: Flavor[] = []; - flavors_loaded: boolean = false; + is_vo_admin: boolean + flavors: Flavor[] = [] + flavors_usable: Flavor[] = [] + flavors_loaded: boolean = false /** * Tab which is shown own|all. * * @type {string} */ - tab: string = 'own'; + tab: string = 'own' - is_facility_manager: boolean = false; + is_facility_manager: boolean = false - clusterPerPageChange: Subject = new Subject(); + clusterPerPageChange: Subject = new Subject() - filterChanged: Subject = new Subject(); + filterChanged: Subject = new Subject() filter_status_list: string[] = [ Clusterstates.RUNNING, Clusterstates.CREATING, Clusterstates.CONFIGURING, Clusterstates.ERROR, - VirtualMachineStates.SHUTOFF, - ]; + VirtualMachineStates.SHUTOFF + ] - migratedProjectIds: string[] = []; - migratedProjectNames: string[] = []; + migratedProjectIds: string[] = [] + migratedProjectNames: string[] = [] constructor( private facilityService: FacilityService, @@ -123,9 +121,9 @@ export class ClusterOverviewComponent extends AbstractBaseClass implements OnIni private clipboardService: ClipboardService, private flavorService: FlavorService, - private applicationsService: ApplicationsService, + private applicationsService: ApplicationsService ) { - super(); + super() } /** @@ -133,18 +131,18 @@ export class ClusterOverviewComponent extends AbstractBaseClass implements OnIni */ applyFilter(): void { if (this.filter) { - this.filter = this.filter.trim(); + this.filter = this.filter.trim() } - this.isSearching = true; + this.isSearching = true if (typeof this.cluster_per_site !== 'number' || this.cluster_per_site <= 0) { - this.cluster_per_site = 7; + this.cluster_per_site = 7 } if (this.tab === 'own') { - this.getClusters(); + this.getClusters() } else if (this.tab === 'all') { - this.getAllClusters(); + this.getAllClusters() } else if (this.tab === 'facility') { - this.getAllCLusterFacilities(); + this.getAllCLusterFacilities() } } @@ -154,12 +152,12 @@ export class ClusterOverviewComponent extends AbstractBaseClass implements OnIni * @param vm Track by vm openstackid. */ trackByCluster(index: number | string, cluster: Clusterinfo): string { - return cluster.cluster_id; + return cluster.cluster_id } copyToClipboard(text: string): void { if (this.clipboardService.isSupported) { - this.clipboardService.copy(text); + this.clipboardService.copy(text) } } @@ -167,10 +165,10 @@ export class ClusterOverviewComponent extends AbstractBaseClass implements OnIni this.subscription.add( this.facilityService.getManagerFacilities().subscribe((result: any): void => { if (result.length > 0) { - this.is_facility_manager = true; + this.is_facility_manager = true } - }), - ); + }) + ) } /** @@ -179,7 +177,7 @@ export class ClusterOverviewComponent extends AbstractBaseClass implements OnIni * @param tabString */ toggleTab(tabString: string): void { - this.tab = tabString; + this.tab = tabString } /** @@ -188,35 +186,35 @@ export class ClusterOverviewComponent extends AbstractBaseClass implements OnIni * @param event */ pageChanged(event: any): void { - this.isSearching = true; + this.isSearching = true - this.currentPage = event.page; + this.currentPage = event.page if (this.tab === 'own') { - this.getClusters(); + this.getClusters() } else if (this.tab === 'all') { - this.getAllClusters(); + this.getAllClusters() } else if (this.tab === 'facility') { - this.getAllCLusterFacilities(); + this.getAllCLusterFacilities() } } generateMigratedProjectIdList(): void { - this.migratedProjectIds = []; + this.migratedProjectIds = [] this.cluster_page.cluster_list.forEach((cluster: Clusterinfo) => { if (cluster.migrate_project_to_simple_vm || cluster.project_is_migrated_to_simple_vm) { - this.migratedProjectIds.push(cluster.project_id.toString()); + this.migratedProjectIds.push(cluster.project_id.toString()) } - const unique = (arr: string[]): string[] => [...new Set(arr)]; - this.migratedProjectIds = unique(this.migratedProjectIds); - }); + const unique = (arr: string[]): string[] => [...new Set(arr)] + this.migratedProjectIds = unique(this.migratedProjectIds) + }) } generateMigratedProjectNamesList(): void { - this.migratedProjectNames = []; + this.migratedProjectNames = [] this.cluster_page.cluster_list.forEach((cluster: Clusterinfo) => { if (cluster.migrate_project_to_simple_vm || cluster.project_is_migrated_to_simple_vm) { - this.migratedProjectNames.push(cluster.project); + this.migratedProjectNames.push(cluster.project) } - }); + }) } /** @@ -227,9 +225,9 @@ export class ClusterOverviewComponent extends AbstractBaseClass implements OnIni this.virtualmachineservice .getClusters(this.currentPage, this.cluster_per_site, this.filter, this.filter_status_list) .subscribe((cluster_page: ClusterPage): void => { - this.prepareClusters(cluster_page); - }), - ); + this.prepareClusters(cluster_page) + }) + ) } getAllCLusterFacilities(): void { @@ -240,33 +238,33 @@ export class ClusterOverviewComponent extends AbstractBaseClass implements OnIni this.currentPage, this.cluster_per_site, this.filter, - this.filter_status_list, + this.filter_status_list ) .subscribe((cluster_page_infos: ClusterPage): void => { - this.prepareClusters(cluster_page_infos); - }), - ); + this.prepareClusters(cluster_page_infos) + }) + ) } prepareClusters(cluster_page_infos: ClusterPage): void { - this.cluster_page = cluster_page_infos; + this.cluster_page = cluster_page_infos // this.clusters = cluster_page_infos['cluster_list'].map((cluster: Clusterinfo): Clusterinfo => new Clusterinfo(cluster)); // this.total_items = cluster_page_infos['total_items']; // this.items_per_page = cluster_page_infos['items_per_page']; // this.total_pages = cluster_page_infos['num_pages']; - this.isSearching = false; - this.generateMigratedProjectIdList(); - this.generateMigratedProjectNamesList(); + this.isSearching = false + this.generateMigratedProjectIdList() + this.generateMigratedProjectNamesList() } changeFilterStatus(status: string): void { - this.currentPage = 1; - const indexOf: number = this.filter_status_list.indexOf(status); + this.currentPage = 1 + const indexOf: number = this.filter_status_list.indexOf(status) if (indexOf === -1) { - this.filter_status_list.push(status); + this.filter_status_list.push(status) } else { - this.filter_status_list.splice(indexOf, 1); + this.filter_status_list.splice(indexOf, 1) } } @@ -275,37 +273,37 @@ export class ClusterOverviewComponent extends AbstractBaseClass implements OnIni this.virtualmachineservice .getAllClusters(this.currentPage, this.cluster_per_site, this.filter, this.filter_status_list) .subscribe((cluster_page_infos: ClusterPage): void => { - this.prepareClusters(cluster_page_infos); - }), - ); + this.prepareClusters(cluster_page_infos) + }) + ) } ngOnInit(): void { - this.tracker.trackPageView('Cluster Overview'); - this.getClusters(); - this.is_vo_admin = is_vo; - this.get_is_facility_manager(); + this.tracker.trackPageView('Cluster Overview') + this.getClusters() + this.is_vo_admin = is_vo + this.get_is_facility_manager() this.subscription.add( this.facilityService.getManagerFacilities().subscribe((result: any): void => { - this.managerFacilities = result; - this.selectedFacility = this.managerFacilities[0]; - }), - ); + this.managerFacilities = result + this.selectedFacility = this.managerFacilities[0] + }) + ) this.subscription.add( this.filterChanged.pipe(debounceTime(this.FILTER_DEBOUNCE_TIME), distinctUntilChanged()).subscribe((): void => { - this.applyFilter(); - }), - ); + this.applyFilter() + }) + ) this.subscription.add( this.clusterPerPageChange.pipe(debounceTime(this.DEBOUNCE_TIME), distinctUntilChanged()).subscribe((): void => { - this.applyFilter(); - }), - ); + this.applyFilter() + }) + ) } ngOnDestroy(): void { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } } diff --git a/src/app/virtualmachines/clusters/clusterstatus/clusterstatus.component.ts b/src/app/virtualmachines/clusters/clusterstatus/clusterstatus.component.ts index b020f89950..905434e52f 100644 --- a/src/app/virtualmachines/clusters/clusterstatus/clusterstatus.component.ts +++ b/src/app/virtualmachines/clusters/clusterstatus/clusterstatus.component.ts @@ -1,18 +1,18 @@ -import { Component, Input } from '@angular/core'; -import { Clusterinfo } from '../clusterinfo'; -import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates'; -import { Clusterstates } from './clusterstates'; +import { Component, Input } from '@angular/core' +import { Clusterinfo } from '../clusterinfo' +import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates' +import { Clusterstates } from './clusterstates' /** * Clusterstatus component. */ @Component({ selector: 'app-clusterstatus', - templateUrl: './clusterstatus.component.html', + templateUrl: './clusterstatus.component.html' }) export class ClusterstatusComponent { - @Input() cluster: Clusterinfo; - @Input() show_text_status: boolean = true; - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); - ClusterStates: Clusterstates = new Clusterstates(); + @Input() cluster: Clusterinfo + @Input() show_text_status: boolean = true + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() + ClusterStates: Clusterstates = new Clusterstates() } diff --git a/src/app/virtualmachines/conda/bioconda.component.ts b/src/app/virtualmachines/conda/bioconda.component.ts index ba2125c2ef..3dc5cbaf31 100644 --- a/src/app/virtualmachines/conda/bioconda.component.ts +++ b/src/app/virtualmachines/conda/bioconda.component.ts @@ -6,14 +6,14 @@ import { HostListener, OnInit, Output, - ViewChild, -} from '@angular/core'; -import { Subject } from 'rxjs'; -import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators'; -import { PaginationComponent } from 'ngx-bootstrap/pagination'; -import { BiocondaService } from '../../api-connector/bioconda.service'; -import { CondaPackageMeta } from './conda-package-meta'; -import { CondaPackage } from './condaPackage.model'; + ViewChild +} from '@angular/core' +import { Subject } from 'rxjs' +import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators' +import { PaginationComponent } from 'ngx-bootstrap/pagination' +import { BiocondaService } from '../../api-connector/bioconda.service' +import { CondaPackageMeta } from './conda-package-meta' +import { CondaPackage } from './condaPackage.model' /** * Bioconda component. @@ -21,204 +21,207 @@ import { CondaPackage } from './condaPackage.model'; @Component({ selector: 'app-bioconda', templateUrl: 'bioconda.component.html', - providers: [BiocondaService], + providers: [BiocondaService] }) export class BiocondaComponent implements OnInit { - FIRST_PAGE: number = 1; - DEBOUNCE_TIME: number = 700; + FIRST_PAGE: number = 1 + DEBOUNCE_TIME: number = 700 - all_tools_meta: CondaPackageMeta[] = []; + all_tools_meta: CondaPackageMeta[] = [] - chosen_tools: CondaPackage[] = []; + chosen_tools: CondaPackage[] = [] - toolsPerPage: number = 10; + toolsPerPage: number = 10 - currentPage: number = this.FIRST_PAGE; + currentPage: number = this.FIRST_PAGE - toolsStart: number = 0; + toolsStart: number = 0 - toolsEnd: number = this.toolsPerPage; + toolsEnd: number = this.toolsPerPage - filterToolName: string = ''; + filterToolName: string = '' - isSearching: boolean; + isSearching: boolean - max_pages: number = 15; - total_pages: number; - window_size: number; - MAX_WINDOW_SIZE: number = 1200; + max_pages: number = 15 + total_pages: number + window_size: number + MAX_WINDOW_SIZE: number = 1200 - filternameChanged: Subject = new Subject(); + filternameChanged: Subject = new Subject() - @Output() readonly hasTools: EventEmitter = new EventEmitter(); - @ViewChild('pagination', { static: true }) pagination: PaginationComponent; - @ViewChild('chosenTable', { static: true }) chosenTable: ElementRef; + @Output() readonly hasTools: EventEmitter = new EventEmitter() + @ViewChild('pagination', { static: true }) pagination: PaginationComponent + @ViewChild('chosenTable', { static: true }) chosenTable: ElementRef // eslint-disable-next-line @typescript-eslint/no-unused-vars @HostListener('window:resize', ['$event']) onResize(event: any): void { - this.window_size = window.innerWidth; + this.window_size = window.innerWidth } - constructor(private condaService: BiocondaService, private cdr: ChangeDetectorRef) { - this.condaService = condaService; - this.cdr = cdr; + constructor( + private condaService: BiocondaService, + private cdr: ChangeDetectorRef + ) { + this.condaService = condaService + this.cdr = cdr } pageChanged(event: any): void { - this.getAllTools(event.page); + this.getAllTools(event.page) } ngOnInit(): void { - this.window_size = window.innerWidth; + this.window_size = window.innerWidth - this.getAllTools(this.FIRST_PAGE); + this.getAllTools(this.FIRST_PAGE) this.filternameChanged .pipe( debounceTime(this.DEBOUNCE_TIME), distinctUntilChanged(), switchMap((filterName: string): any => { - this.isSearching = true; + this.isSearching = true - this.filterToolName = filterName.trim(); + this.filterToolName = filterName.trim() - return this.condaService.getAllTools(1, this.filterToolName); - }), + return this.condaService.getAllTools(1, this.filterToolName) + }) ) .subscribe((res: any): void => { - this.setAllTools(res, 1); - }); + this.setAllTools(res, 1) + }) } // eslint-disable-next-line @typescript-eslint/no-unused-vars onChange(event: any): void { - this.cdr.detectChanges(); + this.cdr.detectChanges() } getAllTools(page: number): void { - this.isSearching = true; + this.isSearching = true this.condaService.getAllTools(page, this.filterToolName).subscribe((metas: any): void => { - this.setAllTools(metas, page); - }); + this.setAllTools(metas, page) + }) } compareVersions(a: string, b: string): number { if (a === b) { - return 0; + return 0 } - const splitA = a.split('.'); - const splitB = b.split('.'); - const length = Math.max(splitA.length, splitB.length); - // eslint-disable-next-line no-plusplus + const splitA = a.split('.') + const splitB = b.split('.') + const length = Math.max(splitA.length, splitB.length) + for (let i = 0; i < length; i++) { if ( - parseInt(splitA[i], 10) > parseInt(splitB[i], 10) - || (splitA[i] === splitB[i] && Number.isNaN(splitB[i + 1])) + parseInt(splitA[i], 10) > parseInt(splitB[i], 10) || + (splitA[i] === splitB[i] && Number.isNaN(splitB[i + 1])) ) { - return 1; + return 1 } if ( - parseInt(splitA[i], 10) < parseInt(splitB[i], 10) - || (splitA[i] === splitB[i] && Number.isNaN(splitA[i + 1])) + parseInt(splitA[i], 10) < parseInt(splitB[i], 10) || + (splitA[i] === splitB[i] && Number.isNaN(splitA[i + 1])) ) { - return -1; + return -1 } } - return 0; + return 0 } adjustToolVersionSort(metaToSort: CondaPackageMeta[]): CondaPackageMeta[] { - const sortedMeta: CondaPackageMeta[] = []; + const sortedMeta: CondaPackageMeta[] = [] metaToSort.forEach((packageMeta: CondaPackageMeta): void => { - packageMeta.versions = packageMeta.versions.sort(this.compareVersions).reverse(); - sortedMeta.push(packageMeta); - }); + packageMeta.versions = packageMeta.versions.sort(this.compareVersions).reverse() + sortedMeta.push(packageMeta) + }) - return sortedMeta; + return sortedMeta } setAllTools(res: any, page: number): void { - this.isSearching = true; + this.isSearching = true - this.all_tools_meta = res['packages']; - this.all_tools_meta = this.adjustToolVersionSort(this.all_tools_meta); - this.total_pages = res['total_items']; - this.toolsStart = 0; - this.toolsPerPage = res['items_per_page']; - this.toolsEnd = this.toolsPerPage; + this.all_tools_meta = res['packages'] + this.all_tools_meta = this.adjustToolVersionSort(this.all_tools_meta) + this.total_pages = res['total_items'] + this.toolsStart = 0 + this.toolsPerPage = res['items_per_page'] + this.toolsEnd = this.toolsPerPage - this.currentPage = page; - this.pagination.selectPage(this.currentPage); - this.cdr.detectChanges(); + this.currentPage = page + this.pagination.selectPage(this.currentPage) + this.cdr.detectChanges() - this.isSearching = false; + this.isSearching = false } changedNameFilter(text: string): void { - this.filternameChanged.next(text); + this.filternameChanged.next(text) } addTool(name: string, version: string): void { - const tool: CondaPackage = new CondaPackage(null, name, version); + const tool: CondaPackage = new CondaPackage(null, name, version) if (!this.is_tool_name_added(tool.name)) { - this.chosen_tools.push(tool); + this.chosen_tools.push(tool) } else { this.chosen_tools.forEach((item: CondaPackage, index: number): void => { if (tool.name === item.name) { - this.chosen_tools.splice(index, 1); + this.chosen_tools.splice(index, 1) } - }); - this.chosen_tools.push(tool); + }) + this.chosen_tools.push(tool) } - this.hasTools.emit(this.hasChosenTools()); + this.hasTools.emit(this.hasChosenTools()) } removeTool(tool: CondaPackage): void { this.chosen_tools.forEach((item: CondaPackage, index: number): void => { if (tool.name === item.name && tool.version === item.version) { - this.chosen_tools.splice(index, 1); - // eslint-disable-next-line @typescript-eslint/no-unused-vars + this.chosen_tools.splice(index, 1) + } - }); + }) - this.hasTools.emit(this.hasChosenTools()); + this.hasTools.emit(this.hasChosenTools()) } is_tool_name_added(name: string): boolean { - let found: boolean = false; + let found: boolean = false this.chosen_tools.forEach((item: CondaPackage): void => { if (name === item.name) { - found = true; + found = true } - }); + }) - return found; + return found } is_added(name: string, version: string): boolean { - const tool: CondaPackage = new CondaPackage(null, name, version); + const tool: CondaPackage = new CondaPackage(null, name, version) - let found: boolean = false; + let found: boolean = false this.chosen_tools.forEach((item: CondaPackage): void => { if (tool.name === item.name && tool.version === item.version) { - found = true; + found = true } - }); + }) - return found; + return found } getChosenTools(): string { - return JSON.stringify(this.chosen_tools); + return JSON.stringify(this.chosen_tools) } getTimeout(): number { - return this.chosen_tools.length * 300 + 840; + return this.chosen_tools.length * 300 + 840 } hasChosenTools(): boolean { - return this.chosen_tools.length > 0; + return this.chosen_tools.length > 0 } } diff --git a/src/app/virtualmachines/conda/res-env.component.ts b/src/app/virtualmachines/conda/res-env.component.ts index 72b2df9863..0deeab293c 100644 --- a/src/app/virtualmachines/conda/res-env.component.ts +++ b/src/app/virtualmachines/conda/res-env.component.ts @@ -1,13 +1,11 @@ -import { - Component, Input, OnChanges, OnDestroy, OnInit, -} from '@angular/core'; -import { UntypedFormControl, Validators } from '@angular/forms'; -import { Subscription } from 'rxjs'; -import { BiocondaService } from '../../api-connector/bioconda.service'; -import { ResearchEnvironment } from '../virtualmachinemodels/res-env'; -import { RandomNameGenerator } from '../../shared/randomNameGenerator'; -import { WIKI_RESENV_LINK, CLOUD_PORTAL_SUPPORT_MAIL } from '../../../links/links'; -import { BlockedImageTagResenv } from '../../facility_manager/image-tag'; +import { Component, Input, OnChanges, OnDestroy, OnInit } from '@angular/core' +import { UntypedFormControl, Validators } from '@angular/forms' +import { Subscription } from 'rxjs' +import { BiocondaService } from '../../api-connector/bioconda.service' +import { ResearchEnvironment } from '../virtualmachinemodels/res-env' +import { RandomNameGenerator } from '../../shared/randomNameGenerator' +import { WIKI_RESENV_LINK, CLOUD_PORTAL_SUPPORT_MAIL } from '../../../links/links' +import { BlockedImageTagResenv } from '../../facility_manager/image-tag' /** * ResEnv. @@ -15,167 +13,167 @@ import { BlockedImageTagResenv } from '../../facility_manager/image-tag'; @Component({ selector: 'app-res-env', templateUrl: 'res-env.component.html', - providers: [BiocondaService], + providers: [BiocondaService] }) export class ResEnvComponent implements OnInit, OnChanges, OnDestroy { - @Input() clientid: string; - @Input() forc_url: string; - @Input() onlyNamespace: boolean = false; - @Input() imageName: string = ''; - @Input() selectedImageTags: string[] = []; - @Input() blockedImageTagsResenv: BlockedImageTagResenv[]; - @Input() workshopMode: boolean = false; + @Input() clientid: string + @Input() forc_url: string + @Input() onlyNamespace: boolean = false + @Input() imageName: string = '' + @Input() selectedImageTags: string[] = [] + @Input() blockedImageTagsResenv: BlockedImageTagResenv[] + @Input() workshopMode: boolean = false - Object: object = Object; + Object: object = Object - templates_to_block: string[] = []; + templates_to_block: string[] = [] user_key_url: UntypedFormControl = new UntypedFormControl('', [ Validators.required, - Validators.pattern('[a-zA-Z]{3,20}'), - ]); + Validators.pattern('[a-zA-Z]{3,20}') + ]) - selectedTemplate: ResearchEnvironment | undefined = undefined; + selectedTemplate: ResearchEnvironment | undefined = undefined - templates: ResearchEnvironment[] = []; + templates: ResearchEnvironment[] = [] - undefinedTemplate: ResearchEnvironment = new ResearchEnvironment(); + undefinedTemplate: ResearchEnvironment = new ResearchEnvironment() - rng: RandomNameGenerator; + rng: RandomNameGenerator - WIKI_RESENV_LINK: string = WIKI_RESENV_LINK; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; + WIKI_RESENV_LINK: string = WIKI_RESENV_LINK + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL - create_only_backend: boolean = false; + create_only_backend: boolean = false - subscription: Subscription = new Subscription(); + subscription: Subscription = new Subscription() constructor(private condaService: BiocondaService) { - this.condaService = condaService; + this.condaService = condaService } setUserKeyUrl(url: string): void { if (this.needsName()) { - this.user_key_url.setValue(url); + this.user_key_url.setValue(url) } } getUserKeyUrl(): string { - return this.user_key_url.value; + return this.user_key_url.value } getCreateOnlyBackend(): boolean { - return this.create_only_backend; + return this.create_only_backend } setSelectedTemplate(template: ResearchEnvironment): void { if (template === null) { - this.selectedTemplate = this.undefinedTemplate; - this.user_key_url.setValue(''); - this.create_only_backend = false; + this.selectedTemplate = this.undefinedTemplate + this.user_key_url.setValue('') + this.create_only_backend = false } else { - this.selectedTemplate = template; + this.selectedTemplate = template if (!this.user_key_url.value) { - this.generateRandomName(); + this.generateRandomName() } } } ngOnInit(): void { - this.undefinedTemplate.template_name = 'undefined'; - this.templates_to_block = []; - this.setSelectedTemplate(null); + this.undefinedTemplate.template_name = 'undefined' + this.templates_to_block = [] + this.setSelectedTemplate(null) this.subscription.add( this.condaService.getForcTemplates(this.clientid).subscribe((templates: ResearchEnvironment[]): void => { - this.templates = templates; - }), - ); - this.rng = new RandomNameGenerator(); - this.generateRandomName(); + this.templates = templates + }) + ) + this.rng = new RandomNameGenerator() + this.generateRandomName() } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } ngOnChanges(): void { - this.checkBlocked(); + this.checkBlocked() } isValid(): boolean { if (this.onlyNamespace) { if (this.workshopMode) { - return true; + return true } else { - return this.user_key_url.errors === null; + return this.user_key_url.errors === null } } else if (this.selectedTemplate.template_name === 'undefined') { if (this.workshopMode) { - return false; + return false } else { - return this.user_key_url.value.length === 0; + return this.user_key_url.value.length === 0 } } else if (this.workshopMode) { - return true; + return true } else { - return this.user_key_url.errors === null; + return this.user_key_url.errors === null } } needsName(): boolean { if (this.onlyNamespace || this.selectedTemplate.template_name !== 'undefined') { - return this.user_key_url.errors !== null; + return this.user_key_url.errors !== null } - return false; + return false } needsTemplate(): boolean { if (this.workshopMode && this.selectedTemplate.template_name === 'undefined') { - return true; + return true } else if (this.user_key_url.value.length !== 0 && !this.onlyNamespace) { - return this.selectedTemplate.template_name === 'undefined'; + return this.selectedTemplate.template_name === 'undefined' } - return false; + return false } okayNeeded(): boolean { - return this.selectedTemplate.template_name !== 'undefined'; + return this.selectedTemplate.template_name !== 'undefined' } setOnlyNamespace(template): void { - this.onlyNamespace = true; - this.create_only_backend = true; - this.setSelectedTemplate(template); + this.onlyNamespace = true + this.create_only_backend = true + this.setSelectedTemplate(template) } unsetOnlyNamespace(): void { - this.onlyNamespace = false; - this.user_key_url.setValue(''); - this.setSelectedTemplate(null); + this.onlyNamespace = false + this.user_key_url.setValue('') + this.setSelectedTemplate(null) } generateRandomName(): void { - this.user_key_url.setValue(this.rng.randomName()); + this.user_key_url.setValue(this.rng.randomName()) } checkBlocked(): void { if (this.selectedImageTags === null || this.selectedImageTags === undefined) { - return; + return } for (const blockedTag of this.blockedImageTagsResenv) { if (this.selectedImageTags.indexOf(blockedTag.tag) !== -1) { - this.templates_to_block = blockedTag.resenvs; + this.templates_to_block = blockedTag.resenvs - return; + return } } - this.templates_to_block = []; + this.templates_to_block = [] } resetData(): void { - this.setSelectedTemplate(null); - this.create_only_backend = false; + this.setSelectedTemplate(null) + this.create_only_backend = false } } diff --git a/src/app/virtualmachines/conda/template-names.ts b/src/app/virtualmachines/conda/template-names.ts index 366cb8e119..6e8a108950 100644 --- a/src/app/virtualmachines/conda/template-names.ts +++ b/src/app/virtualmachines/conda/template-names.ts @@ -2,61 +2,61 @@ * Class containing all FORC Template names */ export class TemplateNames { - private static _RSTUDIO: string = 'rstudio'; - private static _THEIA: string = 'theiaide'; - private static _GUACAMOLE: string = 'guacamole'; - private static _JUPYTERLAB: string = 'jupyterlab'; - private static _VSCODE: string = 'vscode'; + private static _RSTUDIO: string = 'rstudio' + private static _THEIA: string = 'theiaide' + private static _GUACAMOLE: string = 'guacamole' + private static _JUPYTERLAB: string = 'jupyterlab' + private static _VSCODE: string = 'vscode' private static _ALL_TEMPLATES: string[] = [ TemplateNames._RSTUDIO, TemplateNames._THEIA, TemplateNames._GUACAMOLE, TemplateNames._JUPYTERLAB, - TemplateNames._VSCODE, - ]; + TemplateNames._VSCODE + ] static get RSTUDIO(): string { - return this._RSTUDIO; + return this._RSTUDIO } static set RSTUDIO(value: string) { - this._RSTUDIO = value; + this._RSTUDIO = value } static get THEIA(): string { - return this._THEIA; + return this._THEIA } static set THEIA(value: string) { - this._THEIA = value; + this._THEIA = value } static get GUACAMOLE(): string { - return this._GUACAMOLE; + return this._GUACAMOLE } static set GUACAMOLE(value: string) { - this._GUACAMOLE = value; + this._GUACAMOLE = value } static get JUPYTERLAB(): string { - return this._JUPYTERLAB; + return this._JUPYTERLAB } static set JUPYTERLAB(value: string) { - this._JUPYTERLAB = value; + this._JUPYTERLAB = value } static get VSCODE(): string { - return this._VSCODE; + return this._VSCODE } static set VSCODE(value: string) { - this._VSCODE = value; + this._VSCODE = value } static get ALL_TEMPLATE_NAMES(): string[] { - return this._ALL_TEMPLATES; + return this._ALL_TEMPLATES } } diff --git a/src/app/virtualmachines/flavordetail.component.ts b/src/app/virtualmachines/flavordetail.component.ts index 1f59027d8f..4244cc97d7 100644 --- a/src/app/virtualmachines/flavordetail.component.ts +++ b/src/app/virtualmachines/flavordetail.component.ts @@ -1,11 +1,9 @@ -import { - Component, EventEmitter, HostListener, Input, OnChanges, OnInit, Output, -} from '@angular/core'; -import { OwlOptions } from 'ngx-owl-carousel-o'; -import { KeyValue } from '@angular/common'; -import { Flavor } from './virtualmachinemodels/flavor'; -import { FlavorService } from '../api-connector/flavor.service'; -import { Image } from './virtualmachinemodels/image'; +import { Component, EventEmitter, HostListener, Input, OnChanges, OnInit, Output } from '@angular/core' +import { OwlOptions } from 'ngx-owl-carousel-o' +import { KeyValue } from '@angular/common' +import { Flavor } from './virtualmachinemodels/flavor' +import { FlavorService } from '../api-connector/flavor.service' +import { Image } from './virtualmachinemodels/image' /** * Flavor detail component. @@ -13,57 +11,57 @@ import { Image } from './virtualmachinemodels/image'; @Component({ selector: 'app-flavor-detail', templateUrl: 'flavordetail.component.html', - providers: [FlavorService], + providers: [FlavorService] }) export class FlavorDetailComponent implements OnInit, OnChanges { - @Input() selectedFlavor: Flavor; - @Input() selectedImage: Image; - @Input() creditsAllowed: boolean; - @Input() flavors: Flavor[]; - @Input() allowReload: boolean = false; - @Output() readonly selectedFlavorChange: EventEmitter = new EventEmitter(); - @Output() readonly reloadFlavors: EventEmitter = new EventEmitter(); - - regexp_data_test_id: RegExp = /[ ().]/g; - selected_flavor_types: Flavor[] = []; - selected_flavor_type: string = 'Standard Flavors'; - flavor_types: { [name: string]: Flavor[] } = {}; - flavors_per_row: number = 4; - possible_flavors: Flavor[] = []; - filter: string = ''; - filterTimeout = null; - filterDebounceTime: number = 300; - - carousel_activated: boolean = true; - window_size: number; - carousel_window_min_xl_9: number = 1700; - carousel_window_min_xl_8: number = 1380; - carousel_window_min_xl6: number = 1200; + @Input() selectedFlavor: Flavor + @Input() selectedImage: Image + @Input() creditsAllowed: boolean + @Input() flavors: Flavor[] + @Input() allowReload: boolean = false + @Output() readonly selectedFlavorChange: EventEmitter = new EventEmitter() + @Output() readonly reloadFlavors: EventEmitter = new EventEmitter() + + regexp_data_test_id: RegExp = /[ ().]/g + selected_flavor_types: Flavor[] = [] + selected_flavor_type: string = 'Standard Flavors' + flavor_types: { [name: string]: Flavor[] } = {} + flavors_per_row: number = 4 + possible_flavors: Flavor[] = [] + filter: string = '' + filterTimeout = null + filterDebounceTime: number = 300 + + carousel_activated: boolean = true + window_size: number + carousel_window_min_xl_9: number = 1700 + carousel_window_min_xl_8: number = 1380 + carousel_window_min_xl6: number = 1200 filterFlavorsWithDebounce() { - clearTimeout(this.filterTimeout); + clearTimeout(this.filterTimeout) this.filterTimeout = setTimeout(() => { - this.filterFlavors(); - }, this.filterDebounceTime); + this.filterFlavors() + }, this.filterDebounceTime) } filterFlavors(): void { if (this.filter) { - this.possible_flavors = this.flavors.filter(image => image.name.toLowerCase().includes(this.filter.toLowerCase())); + this.possible_flavors = this.flavors.filter(image => image.name.toLowerCase().includes(this.filter.toLowerCase())) } else { - this.possible_flavors = this.flavor_types[this.selected_flavor_type]; + this.possible_flavors = this.flavor_types[this.selected_flavor_type] } } // icons for graphics within flavor cards: - STATIC_IMG_FOLDER: string = 'static/webapp/assets/img/'; + STATIC_IMG_FOLDER: string = 'static/webapp/assets/img/' - CPU_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/cpu_icon.svg`; - RAM_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/ram_icon.svg`; - STORAGE_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/storage_icon.svg`; - GPU_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/gpu_icon.svg`; - CREDITS_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/credits_icon.svg`; + CPU_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/cpu_icon.svg` + RAM_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/ram_icon.svg` + STORAGE_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/storage_icon.svg` + GPU_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/gpu_icon.svg` + CREDITS_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/credits_icon.svg` customOptions: OwlOptions = { loop: false, @@ -72,43 +70,43 @@ export class FlavorDetailComponent implements OnInit, OnChanges { pullDrag: false, dots: true, navSpeed: 700, - navText: ['', ''], + navText: ["", ""], responsive: { 0: { - items: 1, + items: 1 }, 550: { - items: 2, + items: 2 }, 800: { - items: 3, + items: 3 }, 1200: { - items: 4, - }, + items: 4 + } }, - nav: true, - }; + nav: true + } constructor(private flavorService: FlavorService) { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { - this.window_size = window.innerWidth; - this.flavor_types = this.flavorService.sortFlavors(this.flavors); - this.possible_flavors = this.flavor_types[this.selected_flavor_type]; + this.window_size = window.innerWidth + this.flavor_types = this.flavorService.sortFlavors(this.flavors) + this.possible_flavors = this.flavor_types[this.selected_flavor_type] } ngOnChanges() { - this.flavor_types = this.flavorService.sortFlavors(this.flavors); - this.possible_flavors = this.flavor_types[this.selected_flavor_type]; - this.filterFlavors(); + this.flavor_types = this.flavorService.sortFlavors(this.flavors) + this.possible_flavors = this.flavor_types[this.selected_flavor_type] + this.filterFlavors() } // eslint-disable-next-line @typescript-eslint/no-unused-vars @HostListener('window:resize', ['$event']) onResize(event: any): void { - this.window_size = window.innerWidth; + this.window_size = window.innerWidth } /** @@ -118,23 +116,23 @@ export class FlavorDetailComponent implements OnInit, OnChanges { * @param flavor Flavor which will become the selected Flavor. */ setSelectedFlavor(flavor: Flavor): void { - this.selectedFlavor = flavor; - this.selectedFlavorChange.emit(this.selectedFlavor); + this.selectedFlavor = flavor + this.selectedFlavorChange.emit(this.selectedFlavor) } emitFlavorReload(): void { - this.selectedFlavor = undefined; - this.selected_flavor_type = 'Standard Flavors'; - this.reloadFlavors.emit(); + this.selectedFlavor = undefined + this.selected_flavor_type = 'Standard Flavors' + this.reloadFlavors.emit() } setSelectedFlavorType(key: string): void { - this.selected_flavor_type = key; - this.possible_flavors = this.flavor_types[key]; + this.selected_flavor_type = key + this.possible_flavors = this.flavor_types[key] } // eslint-disable-next-line @typescript-eslint/no-unused-vars unsorted(a: KeyValue, b: KeyValue): number { - return 0; + return 0 } } diff --git a/src/app/virtualmachines/imageCarouselSlide.component.ts b/src/app/virtualmachines/imageCarouselSlide.component.ts index 0c927a6bf9..d7d217f755 100644 --- a/src/app/virtualmachines/imageCarouselSlide.component.ts +++ b/src/app/virtualmachines/imageCarouselSlide.component.ts @@ -1,8 +1,6 @@ -import { - Component, EventEmitter, Input, OnInit, Output, -} from '@angular/core'; -import { Image } from './virtualmachinemodels/image'; -import { Flavor } from './virtualmachinemodels/flavor'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' +import { Image } from './virtualmachinemodels/image' +import { Flavor } from './virtualmachinemodels/flavor' /** * Image carousel slide. @@ -10,31 +8,31 @@ import { Flavor } from './virtualmachinemodels/flavor'; @Component({ selector: 'app-image-slide', templateUrl: 'imageCarouselSlide.component.html', - styleUrls: ['./imagedetail.component.scss'], + styleUrls: ['./imagedetail.component.scss'] }) export class ImageCarouselSlideComponent implements OnInit { - @Input() image: Image; - @Input() selectedImage: Image; - @Input() selectedFlavor: Flavor; - @Output() readonly selectedImageChange: EventEmitter = new EventEmitter(); - window_size: number; - img_height: string = '120px!important'; - img_width: string = '210px!important'; - object_fit_scale: string = 'scale'; - image_visible: boolean = true; - regexp_data_test_id: RegExp = /[ ().]/g; - STATIC_IMG_FOLDER: string = 'static/webapp/assets/img/'; + @Input() image: Image + @Input() selectedImage: Image + @Input() selectedFlavor: Flavor + @Output() readonly selectedImageChange: EventEmitter = new EventEmitter() + window_size: number + img_height: string = '120px!important' + img_width: string = '210px!important' + object_fit_scale: string = 'scale' + image_visible: boolean = true + regexp_data_test_id: RegExp = /[ ().]/g + STATIC_IMG_FOLDER: string = 'static/webapp/assets/img/' - RAM_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/ram_icon.svg`; - STORAGE_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/storage_icon.svg`; + RAM_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/ram_icon.svg` + STORAGE_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/storage_icon.svg` ngOnInit(): void { - this.window_size = window.innerWidth; + this.window_size = window.innerWidth } public setImageVisible(): void { if (this.image.logo_url) { - this.image_visible = !this.image_visible; + this.image_visible = !this.image_visible } } } diff --git a/src/app/virtualmachines/imagedetail.component.ts b/src/app/virtualmachines/imagedetail.component.ts index 519f906386..fb4028b324 100644 --- a/src/app/virtualmachines/imagedetail.component.ts +++ b/src/app/virtualmachines/imagedetail.component.ts @@ -1,14 +1,12 @@ -import { - Component, EventEmitter, HostListener, Input, OnDestroy, OnInit, Output, -} from '@angular/core'; -import { OwlOptions } from 'ngx-owl-carousel-o'; -import { forkJoin, Subscription } from 'rxjs'; -import { Image } from './virtualmachinemodels/image'; -import { ImageService } from '../api-connector/image.service'; -import { ImageTypes } from './virtualmachinemodels/imageTypes'; -import { Flavor } from './virtualmachinemodels/flavor'; -import { BiocondaService } from '../api-connector/bioconda.service'; -import { Client } from '../vo_manager/clients/client.model'; +import { Component, EventEmitter, HostListener, Input, OnDestroy, OnInit, Output } from '@angular/core' +import { OwlOptions } from 'ngx-owl-carousel-o' +import { forkJoin, Subscription } from 'rxjs' +import { Image } from './virtualmachinemodels/image' +import { ImageService } from '../api-connector/image.service' +import { ImageTypes } from './virtualmachinemodels/imageTypes' +import { Flavor } from './virtualmachinemodels/flavor' +import { BiocondaService } from '../api-connector/bioconda.service' +import { Client } from '../vo_manager/clients/client.model' /** * Imagedetail component. @@ -17,57 +15,57 @@ import { Client } from '../vo_manager/clients/client.model'; selector: 'app-image-detail[client][project_id]', templateUrl: 'imagedetail.component.html', styleUrls: ['./imagedetail.component.scss'], - providers: [ImageService, BiocondaService], + providers: [ImageService, BiocondaService] }) export class ImageDetailComponent implements OnInit, OnDestroy { - @Input() selectedImage: Image; - @Input() selectedFlavor: Flavor; - @Output() readonly selectedImageChange: EventEmitter = new EventEmitter(); - @Input() isCluster: boolean = false; - @Input() client: Client; - @Input() project_id: number; - images_loaded: boolean = false; - resenv_names: string[] = []; - images: Image[] = []; - filter: string = ''; + @Input() selectedImage: Image + @Input() selectedFlavor: Flavor + @Output() readonly selectedImageChange: EventEmitter = new EventEmitter() + @Input() isCluster: boolean = false + @Input() client: Client + @Input() project_id: number + images_loaded: boolean = false + resenv_names: string[] = [] + images: Image[] = [] + filter: string = '' - subscription: Subscription = new Subscription(); - regexp_data_test_id: RegExp = /[ ().]/g; - carousel_activated: boolean = true; - images_per_row: number = 4; - window_size: number; - carousel_window_min_xl_9: number = 1700; - carousel_window_min_xl_8: number = 1380; - carousel_window_min_xl6: number = 1200; - img_height: string = '120px!important'; - img_width: string = '210px!important'; - image_visible: boolean = true; - selected_image_type: string = ImageTypes.IMAGE; - image_types: { [name: string]: Image[] } = {}; - imageTypes = ImageTypes; - image_selection: Image[]; + subscription: Subscription = new Subscription() + regexp_data_test_id: RegExp = /[ ().]/g + carousel_activated: boolean = true + images_per_row: number = 4 + window_size: number + carousel_window_min_xl_9: number = 1700 + carousel_window_min_xl_8: number = 1380 + carousel_window_min_xl6: number = 1200 + img_height: string = '120px!important' + img_width: string = '210px!important' + image_visible: boolean = true + selected_image_type: string = ImageTypes.IMAGE + image_types: { [name: string]: Image[] } = {} + imageTypes = ImageTypes + image_selection: Image[] - filterTimeout = null; - filterDebounceTime: number = 300; + filterTimeout = null + filterDebounceTime: number = 300 filterImagesWithDebounce() { - clearTimeout(this.filterTimeout); + clearTimeout(this.filterTimeout) this.filterTimeout = setTimeout(() => { - this.filterImages(); - }, this.filterDebounceTime); + this.filterImages() + }, this.filterDebounceTime) } filterImages(): void { if (this.filter) { - this.image_selection = this.images.filter(image => image.name.toLowerCase().includes(this.filter.toLowerCase())); + this.image_selection = this.images.filter(image => image.name.toLowerCase().includes(this.filter.toLowerCase())) } else { - this.image_selection = this.image_types[this.selected_image_type]; + this.image_selection = this.image_types[this.selected_image_type] } } - STATIC_IMG_FOLDER: string = 'static/webapp/assets/img/'; - RAM_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/ram_icon.svg`; - STORAGE_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/storage_icon.svg`; + STATIC_IMG_FOLDER: string = 'static/webapp/assets/img/' + RAM_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/ram_icon.svg` + STORAGE_ICON_PATH: string = `${this.STATIC_IMG_FOLDER}/new_instance/storage_icon.svg` customOptions: OwlOptions = { loop: false, @@ -76,73 +74,76 @@ export class ImageDetailComponent implements OnInit, OnDestroy { pullDrag: false, dots: true, navSpeed: 700, - navText: ['', ''], + navText: ["", ""], responsive: { 0: { - items: 1, + items: 1 }, 550: { - items: 2, + items: 2 }, 800: { - items: 3, + items: 3 }, 1200: { - items: 4, - }, + items: 4 + } }, - nav: true, - }; + nav: true + } - constructor(private imageService: ImageService, private condaService: BiocondaService) { - // eslint-disable-next-line no-empty-function + constructor( + private imageService: ImageService, + private condaService: BiocondaService + ) { + } ngOnInit(): void { - this.window_size = window.innerWidth; - this.prepareImages(); + this.window_size = window.innerWidth + this.prepareImages() } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } prepareImages(): void { - this.images_loaded = false; - this.images = []; - let image_mode = ''; + this.images_loaded = false + this.images = [] + let image_mode = '' if (this.isCluster) { - image_mode = 'cluster'; + image_mode = 'cluster' } forkJoin([ this.condaService.getForcTemplates(this.client.id), - this.imageService.getImages(this.project_id, image_mode), + this.imageService.getImages(this.project_id, image_mode) ]).subscribe(async (res: any) => { - res[0].forEach(resenv => this.resenv_names.push(resenv.template_name)); - this.images = res[1]; - this.image_types = this.imageService.sortImages(this.images, this.resenv_names); + res[0].forEach(resenv => this.resenv_names.push(resenv.template_name)) + this.images = res[1] + this.image_types = this.imageService.sortImages(this.images, this.resenv_names) if (this.isCluster) { - this.selected_image_type = ImageTypes.CLUSTER_IMAGE; + this.selected_image_type = ImageTypes.CLUSTER_IMAGE } else { - this.selected_image_type = ImageTypes.IMAGE; + this.selected_image_type = ImageTypes.IMAGE } - this.image_selection = this.image_types[this.selected_image_type]; - this.images_loaded = true; - }); + this.image_selection = this.image_types[this.selected_image_type] + this.images_loaded = true + }) } setSelectedImageType(key: string): void { - this.selected_image_type = key; - this.image_selection = this.image_types[key]; + this.selected_image_type = key + this.image_selection = this.image_types[key] } public setImageVisible(): void { - this.image_visible = !this.image_visible; + this.image_visible = !this.image_visible } // eslint-disable-next-line @typescript-eslint/no-unused-vars @HostListener('window:resize', ['$event']) onResize(event: any): void { - this.window_size = window.innerWidth; + this.window_size = window.innerWidth } } diff --git a/src/app/virtualmachines/modals/delete-cluster/delete-cluster.component.ts b/src/app/virtualmachines/modals/delete-cluster/delete-cluster.component.ts index be84442d84..d17aad5ec3 100644 --- a/src/app/virtualmachines/modals/delete-cluster/delete-cluster.component.ts +++ b/src/app/virtualmachines/modals/delete-cluster/delete-cluster.component.ts @@ -1,38 +1,36 @@ -import { Component, EventEmitter, OnDestroy } from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Clusterinfo } from '../../clusters/clusterinfo'; -import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates'; +import { Component, EventEmitter, OnDestroy } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { Clusterinfo } from '../../clusters/clusterinfo' +import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates' @Component({ selector: 'app-delete-cluster', - templateUrl: '../delete-cluster/delete-cluster.component.html', + templateUrl: '../delete-cluster/delete-cluster.component.html' }) export class DeleteClusterComponent implements OnDestroy { - /** * Possible virtual machine states. */ - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() - cluster: Clusterinfo; - all_loaded: boolean = true; - public event: EventEmitter = new EventEmitter(); - private submitted: boolean = false; + cluster: Clusterinfo + all_loaded: boolean = true + public event: EventEmitter = new EventEmitter() + private submitted: boolean = false constructor(public bsModalRef: BsModalRef) { - // eslint-disable-next-line no-empty-function + } deleteCluster(): void { - this.submitted = true; - this.event.emit({ deleteCluster: true }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ deleteCluster: true }) + this.bsModalRef.hide() } ngOnDestroy() { if (!this.submitted) { - this.event.emit({ resume: true }); + this.event.emit({ resume: true }) } } - } diff --git a/src/app/virtualmachines/modals/delete-vm/delete-vm.component.ts b/src/app/virtualmachines/modals/delete-vm/delete-vm.component.ts index 8a32676184..1860c104e2 100644 --- a/src/app/virtualmachines/modals/delete-vm/delete-vm.component.ts +++ b/src/app/virtualmachines/modals/delete-vm/delete-vm.component.ts @@ -1,37 +1,37 @@ -import { Component, EventEmitter, OnDestroy } from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine'; -import { elixir_id } from '../../../shared/globalvar'; +import { Component, EventEmitter, OnDestroy } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine' +import { elixir_id } from '../../../shared/globalvar' @Component({ selector: 'app-delete-vm', - templateUrl: './delete-vm.component.html', + templateUrl: './delete-vm.component.html' }) export class DeleteVmComponent implements OnDestroy { - virtualMachine: VirtualMachine; - clusterWorker: boolean = false; - public event: EventEmitter = new EventEmitter(); - private submitted: boolean = false; - user_elixir_id: string = elixir_id; + virtualMachine: VirtualMachine + clusterWorker: boolean = false + public event: EventEmitter = new EventEmitter() + private submitted: boolean = false + user_elixir_id: string = elixir_id /** * To check if the user agreed to deleting someone else's VM */ - delete_foreign_vm_consent: boolean = false; + delete_foreign_vm_consent: boolean = false constructor(public bsModalRef: BsModalRef) { - // eslint-disable-next-line no-empty-function + } deleteVM(): void { - this.submitted = true; - this.event.emit({ deleteVM: true, worker: this.virtualMachine }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ deleteVM: true, worker: this.virtualMachine }) + this.bsModalRef.hide() } ngOnDestroy() { if (!this.submitted) { - this.event.emit({ resume: true }); + this.event.emit({ resume: true }) } } } diff --git a/src/app/virtualmachines/modals/password-cluster/password-cluster.component.ts b/src/app/virtualmachines/modals/password-cluster/password-cluster.component.ts index 9c39734999..abed285721 100644 --- a/src/app/virtualmachines/modals/password-cluster/password-cluster.component.ts +++ b/src/app/virtualmachines/modals/password-cluster/password-cluster.component.ts @@ -1,26 +1,28 @@ -import { Component, EventEmitter, OnInit } from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { ClipboardService } from 'ngx-clipboard'; -import { Clusterinfo } from '../../clusters/clusterinfo'; -import { VirtualmachineService } from '../../../api-connector/virtualmachine.service'; +import { Component, EventEmitter, OnInit } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { ClipboardService } from 'ngx-clipboard' +import { Clusterinfo } from '../../clusters/clusterinfo' +import { VirtualmachineService } from '../../../api-connector/virtualmachine.service' @Component({ - selector: 'app-password-cluster', - templateUrl: '../password-cluster/password-cluster.component.html', - providers: [VirtualmachineService], + selector: 'app-password-cluster', + templateUrl: '../password-cluster/password-cluster.component.html', + providers: [VirtualmachineService] }) export class PasswordClusterComponent implements OnInit { + cluster: Clusterinfo + password: string = null + public event: EventEmitter = new EventEmitter() - cluster: Clusterinfo; - password: string = null; - public event: EventEmitter = new EventEmitter(); - - // eslint-disable-next-line no-empty-function - constructor(public bsModalRef: BsModalRef, private clipboardService: ClipboardService, private virtualmachineservice: VirtualmachineService) { - } + + constructor( + public bsModalRef: BsModalRef, + private clipboardService: ClipboardService, + private virtualmachineservice: VirtualmachineService + ) {} ngOnInit() { - this.generatePassword(); + this.generatePassword() } /** @@ -28,16 +30,14 @@ export class PasswordClusterComponent implements OnInit { */ copyToClipboard(text: string): void { if (this.clipboardService.isSupported) { - this.clipboardService.copy(text); + this.clipboardService.copy(text) } } generatePassword(): void { - this.cluster.password = null; + this.cluster.password = null this.virtualmachineservice.generatePasswordCluster(this.cluster.cluster_id).subscribe((res: any) => { - this.password = res['password']; - - }); + this.password = res['password'] + }) } - } diff --git a/src/app/virtualmachines/modals/reboot-vm/reboot-vm.component.ts b/src/app/virtualmachines/modals/reboot-vm/reboot-vm.component.ts index 253d208339..fd4df531ab 100644 --- a/src/app/virtualmachines/modals/reboot-vm/reboot-vm.component.ts +++ b/src/app/virtualmachines/modals/reboot-vm/reboot-vm.component.ts @@ -1,49 +1,49 @@ -import { Component, EventEmitter, OnDestroy } from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine'; -import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates'; -import { WIKI_MOUNT_VOLUME } from '../../../../links/links'; +import { Component, EventEmitter, OnDestroy } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine' +import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates' +import { WIKI_MOUNT_VOLUME } from '../../../../links/links' @Component({ selector: 'app-reboot-vm', - templateUrl: './reboot-vm.component.html', + templateUrl: './reboot-vm.component.html' }) export class RebootVmComponent implements OnDestroy { - virtualMachine: VirtualMachine; - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); - public event: EventEmitter = new EventEmitter(); - private submitted: boolean = false; - choosingType: boolean = true; - confirm: boolean = false; - reboot_type: string = ''; + virtualMachine: VirtualMachine + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() + public event: EventEmitter = new EventEmitter() + private submitted: boolean = false + choosingType: boolean = true + confirm: boolean = false + reboot_type: string = '' - WIKI_MOUNT_VOLUME: string = WIKI_MOUNT_VOLUME; + WIKI_MOUNT_VOLUME: string = WIKI_MOUNT_VOLUME constructor(public bsModalRef: BsModalRef) { - // eslint-disable-next-line no-empty-function + } rebootVm(): void { - this.submitted = true; - this.event.emit({ reboot_type: this.reboot_type }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ reboot_type: this.reboot_type }) + this.bsModalRef.hide() } softRebootShow(): void { - this.choosingType = false; - this.confirm = true; - this.reboot_type = 'SOFT'; + this.choosingType = false + this.confirm = true + this.reboot_type = 'SOFT' } hardRebootShow(): void { - this.choosingType = false; - this.confirm = true; - this.reboot_type = 'HARD'; + this.choosingType = false + this.confirm = true + this.reboot_type = 'HARD' } ngOnDestroy() { if (!this.submitted) { - this.event.emit({ resume: true }); + this.event.emit({ resume: true }) } } } diff --git a/src/app/virtualmachines/modals/recreate-backend-vm/recreate-backend-vm.component.ts b/src/app/virtualmachines/modals/recreate-backend-vm/recreate-backend-vm.component.ts index 98e99b1a0f..88ca4d2658 100644 --- a/src/app/virtualmachines/modals/recreate-backend-vm/recreate-backend-vm.component.ts +++ b/src/app/virtualmachines/modals/recreate-backend-vm/recreate-backend-vm.component.ts @@ -1,29 +1,29 @@ -import { Component, EventEmitter, OnDestroy } from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine'; +import { Component, EventEmitter, OnDestroy } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine' @Component({ selector: 'app-recreate-backend-vm', - templateUrl: './recreate-backend-vm.component.html', + templateUrl: './recreate-backend-vm.component.html' }) export class RecreateBackendVmComponent implements OnDestroy { - virtualMachine: VirtualMachine; - public event: EventEmitter = new EventEmitter(); - private submitted: boolean = false; + virtualMachine: VirtualMachine + public event: EventEmitter = new EventEmitter() + private submitted: boolean = false constructor(public bsModalRef: BsModalRef) { - // eslint-disable-next-line no-empty-function + } recreateBackendVM(): void { - this.submitted = true; - this.event.emit({ recreateBackendVM: true }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ recreateBackendVM: true }) + this.bsModalRef.hide() } ngOnDestroy() { if (!this.submitted) { - this.event.emit({ resume: true }); + this.event.emit({ resume: true }) } } } diff --git a/src/app/virtualmachines/modals/rename-cluster/rename-cluster.component.ts b/src/app/virtualmachines/modals/rename-cluster/rename-cluster.component.ts index f9f08d8657..3b056490d7 100644 --- a/src/app/virtualmachines/modals/rename-cluster/rename-cluster.component.ts +++ b/src/app/virtualmachines/modals/rename-cluster/rename-cluster.component.ts @@ -1,36 +1,36 @@ -import { Component, EventEmitter, OnDestroy } from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Clusterinfo } from '../../clusters/clusterinfo'; -import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates'; +import { Component, EventEmitter, OnDestroy } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { Clusterinfo } from '../../clusters/clusterinfo' +import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates' @Component({ selector: 'app-rename-cluster', - templateUrl: '../rename-cluster/rename-cluster.component.html', + templateUrl: '../rename-cluster/rename-cluster.component.html' }) export class RenameClusterComponent implements OnDestroy { /** * Possible virtual machine states. */ - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() - cluster: Clusterinfo; - all_loaded: boolean = true; - public event: EventEmitter = new EventEmitter(); - private submitted: boolean = false; + cluster: Clusterinfo + all_loaded: boolean = true + public event: EventEmitter = new EventEmitter() + private submitted: boolean = false constructor(public bsModalRef: BsModalRef) { - // eslint-disable-next-line no-empty-function + } renameCluster(name: string): void { - this.submitted = true; - this.event.emit({ new_name: name }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ new_name: name }) + this.bsModalRef.hide() } ngOnDestroy() { if (!this.submitted) { - this.event.emit({ resume: true }); + this.event.emit({ resume: true }) } } } diff --git a/src/app/virtualmachines/modals/resume-cluster/resume-cluster.component.ts b/src/app/virtualmachines/modals/resume-cluster/resume-cluster.component.ts index 9fc566807a..682d0ee1e1 100644 --- a/src/app/virtualmachines/modals/resume-cluster/resume-cluster.component.ts +++ b/src/app/virtualmachines/modals/resume-cluster/resume-cluster.component.ts @@ -1,33 +1,29 @@ -import { - Component, EventEmitter, OnDestroy, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Clusterinfo } from '../../clusters/clusterinfo'; +import { Component, EventEmitter, OnDestroy } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { Clusterinfo } from '../../clusters/clusterinfo' @Component({ selector: 'app-resume-cluster', - templateUrl: './resume-cluster.component.html', + templateUrl: './resume-cluster.component.html' }) export class ResumeClusterComponent implements OnDestroy { - - cluster: Clusterinfo; - public event: EventEmitter = new EventEmitter(); - private submitted: boolean = false; + cluster: Clusterinfo + public event: EventEmitter = new EventEmitter() + private submitted: boolean = false constructor(public bsModalRef: BsModalRef) { - // eslint-disable-next-line no-empty-function + } resumeCluster(): void { - this.submitted = true; - this.event.emit({ resumeCluster: true }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ resumeCluster: true }) + this.bsModalRef.hide() } ngOnDestroy() { if (!this.submitted) { - this.event.emit({ resume: true }); + this.event.emit({ resume: true }) } } - } diff --git a/src/app/virtualmachines/modals/resume-vm/resume-vm.component.ts b/src/app/virtualmachines/modals/resume-vm/resume-vm.component.ts index 21e7621d52..16f3c7bf64 100644 --- a/src/app/virtualmachines/modals/resume-vm/resume-vm.component.ts +++ b/src/app/virtualmachines/modals/resume-vm/resume-vm.component.ts @@ -1,33 +1,29 @@ -import { - Component, EventEmitter, OnDestroy, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine'; +import { Component, EventEmitter, OnDestroy } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine' @Component({ selector: 'app-resume-vm', - templateUrl: './resume-vm.component.html', + templateUrl: './resume-vm.component.html' }) export class ResumeVmComponent implements OnDestroy { - - virtualMachine: VirtualMachine; - public event: EventEmitter = new EventEmitter(); - private submitted: boolean = false; + virtualMachine: VirtualMachine + public event: EventEmitter = new EventEmitter() + private submitted: boolean = false constructor(public bsModalRef: BsModalRef) { - // eslint-disable-next-line no-empty-function + } resumeVM(): void { - this.submitted = true; - this.event.emit({ resumeVM: true }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ resumeVM: true }) + this.bsModalRef.hide() } ngOnDestroy() { if (!this.submitted) { - this.event.emit({ resume: true }); + this.event.emit({ resume: true }) } } - } diff --git a/src/app/virtualmachines/modals/scale-cluster/scale-cluster.component.ts b/src/app/virtualmachines/modals/scale-cluster/scale-cluster.component.ts index bbed157634..93bca1b967 100644 --- a/src/app/virtualmachines/modals/scale-cluster/scale-cluster.component.ts +++ b/src/app/virtualmachines/modals/scale-cluster/scale-cluster.component.ts @@ -1,72 +1,70 @@ -import { - Component, EventEmitter, OnDestroy, OnInit, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { ClipboardService } from 'ngx-clipboard'; -import { Subscription } from 'rxjs'; -import { Clusterinfo, WorkerBatch } from '../../clusters/clusterinfo'; -import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates'; -import { SCALE_SCRIPT_LINK } from '../../../../links/links'; -import { Flavor } from '../../virtualmachinemodels/flavor'; -import { ApplicationRessourceUsage } from '../../../applications/application-ressource-usage/application-ressource-usage'; -import { FlavorService } from '../../../api-connector/flavor.service'; -import { GroupService } from '../../../api-connector/group.service'; +import { Component, EventEmitter, OnDestroy, OnInit } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { ClipboardService } from 'ngx-clipboard' +import { Subscription } from 'rxjs' +import { Clusterinfo, WorkerBatch } from '../../clusters/clusterinfo' +import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates' +import { SCALE_SCRIPT_LINK } from '../../../../links/links' +import { Flavor } from '../../virtualmachinemodels/flavor' +import { ApplicationRessourceUsage } from '../../../applications/application-ressource-usage/application-ressource-usage' +import { FlavorService } from '../../../api-connector/flavor.service' +import { GroupService } from '../../../api-connector/group.service' @Component({ selector: 'app-scale-cluster', templateUrl: './scale-cluster.component.html', - providers: [FlavorService, GroupService], + providers: [FlavorService, GroupService] }) export class ScaleClusterComponent implements OnDestroy, OnInit { /** * Possible virtual machine states. */ - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); - private subscription: Subscription = new Subscription(); - - scaling_warning_read: boolean = false; - SCALING_SCRIPT_LINK: string = SCALE_SCRIPT_LINK; - SCALING_SCRIPT_NAME: string = 'scaling.py'; - scale_down: boolean = false; - scale_up: boolean = false; - scale_success: boolean = false; - projectDataLoaded: boolean = false; - selectedBatch: WorkerBatch; - scale_down_count: number = 0; - scale_up_worker_count: number; - created_new_batch: boolean = false; - flavors: Flavor[] = []; - flavors_usable: Flavor[] = []; - flavors_loaded: boolean = false; - selectedProjectRessources: ApplicationRessourceUsage; - max_scale_up_count: number = 0; - max_scale_up_count_loaded: boolean = false; - mode: string; - msg: string; - - cluster: Clusterinfo; - old_cluster: Clusterinfo; - public event: EventEmitter = new EventEmitter(); - private submitted: boolean = false; - - // eslint-disable-next-line max-len + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() + private subscription: Subscription = new Subscription() + + scaling_warning_read: boolean = false + SCALING_SCRIPT_LINK: string = SCALE_SCRIPT_LINK + SCALING_SCRIPT_NAME: string = 'scaling.py' + scale_down: boolean = false + scale_up: boolean = false + scale_success: boolean = false + projectDataLoaded: boolean = false + selectedBatch: WorkerBatch + scale_down_count: number = 0 + scale_up_worker_count: number + created_new_batch: boolean = false + flavors: Flavor[] = [] + flavors_usable: Flavor[] = [] + flavors_loaded: boolean = false + selectedProjectRessources: ApplicationRessourceUsage + max_scale_up_count: number = 0 + max_scale_up_count_loaded: boolean = false + mode: string + msg: string + + cluster: Clusterinfo + old_cluster: Clusterinfo + public event: EventEmitter = new EventEmitter() + private submitted: boolean = false + + constructor( public bsModalRef: BsModalRef, private clipboardService: ClipboardService, private flavorService: FlavorService, - private groupService: GroupService, + private groupService: GroupService ) { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { if (this.mode === 'scale_up') { - this.scale_up = true; - this.calcRess(); + this.scale_up = true + this.calcRess() } else if (this.mode === 'scale_down') { - this.scale_down = true; + this.scale_down = true } else if (this.mode === 'scale_success') { - this.scale_success = true; + this.scale_success = true } } @@ -75,183 +73,185 @@ export class ScaleClusterComponent implements OnDestroy, OnInit { */ copyToClipboard(text: string): void { if (this.clipboardService.isSupported) { - this.clipboardService.copy(text); + this.clipboardService.copy(text) } } checkDelCount(batch: WorkerBatch): void { if (batch.delete_count > batch.worker_count) { - batch.delete_count = batch.worker_count; + batch.delete_count = batch.worker_count } - this.scale_down_count = 0; + this.scale_down_count = 0 this.cluster.worker_batches.forEach((bat: WorkerBatch): void => { if (bat.delete_count > 0) { - this.scale_down_count += bat.delete_count; + this.scale_down_count += bat.delete_count } - }); + }) } loadProjectRessource(): void { - this.projectDataLoaded = false; - this.flavors_loaded = false; + this.projectDataLoaded = false + this.flavors_loaded = false - this.flavors = []; + this.flavors = [] this.subscription.add( this.groupService.getGroupResources(this.cluster.project_id).subscribe((res: ApplicationRessourceUsage): void => { - this.selectedProjectRessources = new ApplicationRessourceUsage(res); - this.getFlavors(this.cluster.project_id); - this.projectDataLoaded = true; - }), - ); + this.selectedProjectRessources = new ApplicationRessourceUsage(res) + this.getFlavors(this.cluster.project_id) + this.projectDataLoaded = true + }) + ) } checkUpCount(batch: WorkerBatch): void { if (batch.upscale_count > batch.max_scale_up_count) { - batch.upscale_count = batch.max_scale_up_count; + batch.upscale_count = batch.max_scale_up_count } } calcRess(): void { - this.max_scale_up_count_loaded = false; + this.max_scale_up_count_loaded = false // tslint:disable-next-line:max-line-length this.subscription.add( this.groupService .getGroupResources(this.cluster.master_instance.projectid.toString()) .subscribe((res: ApplicationRessourceUsage): void => { - this.selectedProjectRessources = new ApplicationRessourceUsage(res); + this.selectedProjectRessources = new ApplicationRessourceUsage(res) for (const workerBatch of this.cluster.worker_batches) { workerBatch.max_scale_up_count = this.selectedProjectRessources.calcMaxScaleUpWorkerInstancesByFlavor( - workerBatch.flavor, - ); + workerBatch.flavor + ) } - this.max_scale_up_count_loaded = true; - }), - ); + this.max_scale_up_count_loaded = true + }) + ) } setSelectedBatch(batch: WorkerBatch): void { - this.selectedBatch = batch; + this.selectedBatch = batch } resizeFix(): void { - window.dispatchEvent(new Event('resize')); + window.dispatchEvent(new Event('resize')) } getFlavors(project_id: number | string): void { this.subscription.add( this.flavorService.getFlavors(project_id).subscribe( (flavors: Flavor[]): void => { - this.flavors = flavors; - this.checkFlavorsUsableForCluster(); + this.flavors = flavors + this.checkFlavorsUsableForCluster() }, (error: any) => { - console.log(error); - this.flavors = []; - this.flavors_usable = []; - this.flavors_loaded = true; - }, - ), - ); + console.log(error) + this.flavors = [] + this.flavors_usable = [] + this.flavors_loaded = true + } + ) + ) } calcMaxWorkerInstancesByFlavor(): void { - this.selectedBatch.setMaxWorkerCount(this.selectedProjectRessources); + this.selectedBatch.setMaxWorkerCount(this.selectedProjectRessources) } removeNewBatchSelectedCluster(): void { if (this.created_new_batch && this.selectedBatch) { - this.cluster.remove_batch(this.selectedBatch); - this.created_new_batch = false; - this.selectedBatch = null; + this.cluster.remove_batch(this.selectedBatch) + this.created_new_batch = false + this.selectedBatch = null } } createNewBatchSelectedCluster(): void { - this.created_new_batch = true; - const idx: number = this.getBatchUpscaleIndexNumber(); - this.cluster.create_new_batch(idx); - this.selectedBatch = this.cluster.worker_batches[this.cluster.worker_batches.length - 1]; - this.loadProjectRessource(); + this.created_new_batch = true + const idx: number = this.getBatchUpscaleIndexNumber() + this.cluster.create_new_batch(idx) + this.selectedBatch = this.cluster.worker_batches[this.cluster.worker_batches.length - 1] + this.loadProjectRessource() } getBatchUpscaleIndexNumber(): number { - const indexList: number[] = []; + const indexList: number[] = [] this.cluster.worker_batches.forEach((cwb: WorkerBatch): void => { - indexList.push(cwb.index); - }); - indexList.sort(); - let idx: number = 1; + indexList.push(cwb.index) + }) + indexList.sort() + let idx: number = 1 while (indexList.indexOf(idx) !== -1) { - idx += 1; + idx += 1 } - return idx; + return idx } checkFlavorsUsableForCluster(): void { - this.flavors_usable = []; - const used_flavors: Flavor[] = []; - let flavors_to_filter: Flavor[] = []; + this.flavors_usable = [] + const used_flavors: Flavor[] = [] + let flavors_to_filter: Flavor[] = [] // tslint:disable-next-line:no-for-each-push this.cluster.worker_batches.forEach((batch: WorkerBatch): void => { if (batch.flavor) { - used_flavors.push(batch.flavor); + used_flavors.push(batch.flavor) } - }); + }) if (used_flavors.length > 0) { flavors_to_filter = this.flavors.filter((flavor: Flavor): boolean => { - let not_used: boolean = true; + let not_used: boolean = true used_flavors.forEach((used_flavor: Flavor): void => { if (flavor.name === used_flavor.name) { - not_used = false; + not_used = false } - }); + }) - return not_used; - }); + return not_used + }) } else { - flavors_to_filter = this.flavors; + flavors_to_filter = this.flavors } - this.flavors_usable = flavors_to_filter.filter((flav: Flavor): boolean => this.selectedProjectRessources.filterFlavorsTestUpScaling(flav)); + this.flavors_usable = flavors_to_filter.filter((flav: Flavor): boolean => + this.selectedProjectRessources.filterFlavorsTestUpScaling(flav) + ) - this.flavors_loaded = true; + this.flavors_loaded = true } scaleDownCluster(): void { - this.submitted = true; - this.event.emit({ scaleDownCluster: true, cluster: this.cluster }); + this.submitted = true + this.event.emit({ scaleDownCluster: true, cluster: this.cluster }) - this.bsModalRef.hide(); + this.bsModalRef.hide() } scaleUpCluster(): void { - this.submitted = true; + this.submitted = true this.event.emit({ scaleUpCluster: true, selectedBatch: this.selectedBatch, - created_new_batch: this.created_new_batch, - }); + created_new_batch: this.created_new_batch + }) - this.bsModalRef.hide(); + this.bsModalRef.hide() } resetScalingBatches(): void { for (const workerBatch of this.cluster.worker_batches) { - workerBatch.upscale_count = 0; - workerBatch.delete_count = 0; + workerBatch.upscale_count = 0 + workerBatch.delete_count = 0 } } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() if (!this.submitted) { - this.removeNewBatchSelectedCluster(); - this.resetScalingBatches(); - this.event.emit({ resume: true }); + this.removeNewBatchSelectedCluster() + this.resetScalingBatches() + this.event.emit({ resume: true }) } } } diff --git a/src/app/virtualmachines/modals/snapshot-vm/snapshot-vm.component.ts b/src/app/virtualmachines/modals/snapshot-vm/snapshot-vm.component.ts index 17a1772131..14eaf29e18 100644 --- a/src/app/virtualmachines/modals/snapshot-vm/snapshot-vm.component.ts +++ b/src/app/virtualmachines/modals/snapshot-vm/snapshot-vm.component.ts @@ -1,65 +1,66 @@ -import { - Component, EventEmitter, OnDestroy, OnInit, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Subject, Subscription } from 'rxjs'; -import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; -import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine'; -import { SnapshotModel } from '../../snapshots/snapshot.model'; -import { IResponseTemplate } from '../../../api-connector/response-template'; -import { ImageService } from '../../../api-connector/image.service'; -import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates'; +import { Component, EventEmitter, OnDestroy, OnInit } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { Subject, Subscription } from 'rxjs' +import { debounceTime, distinctUntilChanged } from 'rxjs/operators' +import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine' +import { SnapshotModel } from '../../snapshots/snapshot.model' +import { IResponseTemplate } from '../../../api-connector/response-template' +import { ImageService } from '../../../api-connector/image.service' +import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates' @Component({ selector: 'app-snapshot-vm', templateUrl: './snapshot-vm.component.html', - providers: [ImageService], + providers: [ImageService] }) export class SnapshotVmComponent implements OnDestroy, OnInit { - virtualMachine: VirtualMachine; - public event: EventEmitter = new EventEmitter(); - private submitted: boolean = false; - SNAPSHOT_MAX_RAM: number = SnapshotModel.MAX_RAM; - snapshotSearchTerm: Subject = new Subject(); - subscription: Subscription = new Subscription(); - DEBOUNCE_TIME: number = 300; - validSnapshotNameBool: boolean; - snapshotNameCheckDone: boolean = false; - snapshotName: string = ''; - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); + virtualMachine: VirtualMachine + public event: EventEmitter = new EventEmitter() + private submitted: boolean = false + SNAPSHOT_MAX_RAM: number = SnapshotModel.MAX_RAM + snapshotSearchTerm: Subject = new Subject() + subscription: Subscription = new Subscription() + DEBOUNCE_TIME: number = 300 + validSnapshotNameBool: boolean + snapshotNameCheckDone: boolean = false + snapshotName: string = '' + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() - constructor(public bsModalRef: BsModalRef, private imageService: ImageService) { - // eslint-disable-next-line no-empty-function + constructor( + public bsModalRef: BsModalRef, + private imageService: ImageService + ) { + } snapshotVM(description: any): void { - this.submitted = true; - this.event.emit({ snapshotVM: true, snapshotName: this.snapshotName, description }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ snapshotVM: true, snapshotName: this.snapshotName, description }) + this.bsModalRef.hide() } validSnapshotName(): any { - this.snapshotNameCheckDone = false; + this.snapshotNameCheckDone = false this.imageService .checkSnapshotNameAvailable(this.snapshotName.trim(), this.virtualMachine.client.id) .subscribe((res: IResponseTemplate): void => { - this.validSnapshotNameBool = this.snapshotName.length > 0 && (res.value as boolean); - this.snapshotNameCheckDone = true; - }); + this.validSnapshotNameBool = this.snapshotName.length > 0 && (res.value as boolean) + this.snapshotNameCheckDone = true + }) } ngOnInit() { this.subscription.add( this.snapshotSearchTerm.pipe(debounceTime(this.DEBOUNCE_TIME), distinctUntilChanged()).subscribe((): void => { - this.validSnapshotName(); - }), - ); + this.validSnapshotName() + }) + ) } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() if (!this.submitted) { - this.event.emit({ resume: true }); + this.event.emit({ resume: true }) } } } diff --git a/src/app/virtualmachines/modals/stop-cluster/stop-cluster.component.ts b/src/app/virtualmachines/modals/stop-cluster/stop-cluster.component.ts index 739f192c72..8cfe183215 100644 --- a/src/app/virtualmachines/modals/stop-cluster/stop-cluster.component.ts +++ b/src/app/virtualmachines/modals/stop-cluster/stop-cluster.component.ts @@ -1,27 +1,23 @@ -import { - Component, EventEmitter, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Clusterinfo } from '../../clusters/clusterinfo'; +import { Component, EventEmitter } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { Clusterinfo } from '../../clusters/clusterinfo' @Component({ selector: 'app-cluster-vm', - templateUrl: './stop-cluster.component.html', + templateUrl: './stop-cluster.component.html' }) export class StopClusterComponent { - - cluster: Clusterinfo; - public event: EventEmitter = new EventEmitter(); - private submitted: boolean = false; + cluster: Clusterinfo + public event: EventEmitter = new EventEmitter() + private submitted: boolean = false constructor(public bsModalRef: BsModalRef) { - // eslint-disable-next-line no-empty-function + } stopCluster(): void { - this.submitted = true; - this.event.emit({ stopCluster: true }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ stopCluster: true }) + this.bsModalRef.hide() } - } diff --git a/src/app/virtualmachines/modals/stop-vm/stop-vm.component.ts b/src/app/virtualmachines/modals/stop-vm/stop-vm.component.ts index 1148182fcf..5a94680a90 100644 --- a/src/app/virtualmachines/modals/stop-vm/stop-vm.component.ts +++ b/src/app/virtualmachines/modals/stop-vm/stop-vm.component.ts @@ -1,32 +1,29 @@ -import { - Component, EventEmitter, OnDestroy, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine'; +import { Component, EventEmitter, OnDestroy } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine' @Component({ selector: 'app-stop-vm', - templateUrl: './stop-vm.component.html', + templateUrl: './stop-vm.component.html' }) export class StopVmComponent implements OnDestroy { - - virtualMachine: VirtualMachine; - public event: EventEmitter = new EventEmitter(); - private submitted: boolean = false; + virtualMachine: VirtualMachine + public event: EventEmitter = new EventEmitter() + private submitted: boolean = false constructor(public bsModalRef: BsModalRef) { - // eslint-disable-next-line no-empty-function + } stopVm(): void { - this.submitted = true; - this.event.emit({ stopVM: true }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ stopVM: true }) + this.bsModalRef.hide() } ngOnDestroy() { if (!this.submitted) { - this.event.emit({ resume: true }); + this.event.emit({ resume: true }) } } } diff --git a/src/app/virtualmachines/modals/volume-vm/volume-vm.component.ts b/src/app/virtualmachines/modals/volume-vm/volume-vm.component.ts index 01bae5e4e4..af60c15e43 100644 --- a/src/app/virtualmachines/modals/volume-vm/volume-vm.component.ts +++ b/src/app/virtualmachines/modals/volume-vm/volume-vm.component.ts @@ -1,65 +1,64 @@ -import { - Component, EventEmitter, OnDestroy, OnInit, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Subscription } from 'rxjs'; -import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine'; -import { WIKI_VOLUME_OVERVIEW } from '../../../../links/links'; -import { Volume } from '../../volumes/volume'; -import { VirtualmachineService } from '../../../api-connector/virtualmachine.service'; +import { Component, EventEmitter, OnDestroy, OnInit } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { Subscription } from 'rxjs' +import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine' +import { WIKI_VOLUME_OVERVIEW } from '../../../../links/links' +import { Volume } from '../../volumes/volume' +import { VirtualmachineService } from '../../../api-connector/virtualmachine.service' @Component({ selector: 'app-volume-vm', templateUrl: './volume-vm.component.html', - providers: [VirtualmachineService], + providers: [VirtualmachineService] }) export class VolumeVmComponent implements OnInit, OnDestroy { + virtualMachine: VirtualMachine + selectedVolume: Volume + detached_project_volumes: Volume[] = [] + public event: EventEmitter = new EventEmitter() + private subscription: Subscription = new Subscription() + private submitted: boolean = false + WIKI_VOLUME_OVERVIEW: string = WIKI_VOLUME_OVERVIEW + attach: boolean = false + detach: boolean = false + mode: string = '' - virtualMachine: VirtualMachine; - selectedVolume: Volume; - detached_project_volumes: Volume[] = []; - public event: EventEmitter = new EventEmitter(); - private subscription: Subscription = new Subscription(); - private submitted: boolean = false; - WIKI_VOLUME_OVERVIEW: string = WIKI_VOLUME_OVERVIEW; - attach: boolean = false; - detach: boolean = false; - mode: string = ''; - - constructor(public bsModalRef: BsModalRef, private virtualmachineservice: VirtualmachineService) { - // eslint-disable-next-line no-empty-function + constructor( + public bsModalRef: BsModalRef, + private virtualmachineservice: VirtualmachineService + ) { + } attachVolume(): void { - this.submitted = true; - this.event.emit({ attachVolume: true, volume: this.selectedVolume }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ attachVolume: true, volume: this.selectedVolume }) + this.bsModalRef.hide() } detachVolume(): void { - this.submitted = true; - this.event.emit({ detachVolume: true, volume: this.selectedVolume }); - this.bsModalRef.hide(); + this.submitted = true + this.event.emit({ detachVolume: true, volume: this.selectedVolume }) + this.bsModalRef.hide() } ngOnInit(): void { if (this.mode === 'attach') { this.subscription.add( - this.virtualmachineservice.getDetachedVolumesByProject(this.virtualMachine.projectid).subscribe( - (detached_volumes: Volume[]): void => { - this.detached_project_volumes = detached_volumes; - }, - ), - ); - this.attach = true; - } else if (this.mode === 'detach') this.detach = true; + this.virtualmachineservice + .getDetachedVolumesByProject(this.virtualMachine.projectid) + .subscribe((detached_volumes: Volume[]): void => { + this.detached_project_volumes = detached_volumes + }) + ) + this.attach = true + } else if (this.mode === 'detach') this.detach = true } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() if (!this.submitted) { - this.event.emit({ resume: true }); + this.event.emit({ resume: true }) } } - } diff --git a/src/app/virtualmachines/project-user-list/project-user-list.component.ts b/src/app/virtualmachines/project-user-list/project-user-list.component.ts index 28a0a52c06..a42621284c 100644 --- a/src/app/virtualmachines/project-user-list/project-user-list.component.ts +++ b/src/app/virtualmachines/project-user-list/project-user-list.component.ts @@ -1,9 +1,7 @@ -import { - Component, Input, OnDestroy, OnInit, -} from '@angular/core'; -import { Subscription } from 'rxjs'; -import { ProjectMember } from '../../projectmanagement/project_member.model'; -import { GroupService } from '../../api-connector/group.service'; +import { Component, Input, OnDestroy, OnInit } from '@angular/core' +import { Subscription } from 'rxjs' +import { ProjectMember } from '../../projectmanagement/project_member.model' +import { GroupService } from '../../api-connector/group.service' /** * Project member list selection. @@ -11,45 +9,42 @@ import { GroupService } from '../../api-connector/group.service'; @Component({ selector: 'app-project-user-list', templateUrl: './project-user-list.component.html', - providers: [GroupService], + providers: [GroupService] }) export class ProjectUserListComponent implements OnInit, OnDestroy { - @Input() project_id: string | number; - @Input() user_member_id: number; - project_members: ProjectMember[] = []; - @Input() members_to_add: ProjectMember[] = []; - subscription: Subscription = new Subscription(); + @Input() project_id: string | number + @Input() user_member_id: number + project_members: ProjectMember[] = [] + @Input() members_to_add: ProjectMember[] = [] + subscription: Subscription = new Subscription() constructor(private groupService: GroupService) { - this.groupService = groupService; + this.groupService = groupService } getMembersOfTheProject(): void { this.subscription.add( - this.groupService.getGroupMembers(this.project_id.toString()).subscribe( - (members: ProjectMember[]): void => { - this.project_members = members.filter( - (mem: ProjectMember): boolean => mem.memberId.toString() !== this.user_member_id.toString(), - ); - }, - ), - ); + this.groupService.getGroupMembers(this.project_id.toString()).subscribe((members: ProjectMember[]): void => { + this.project_members = members.filter( + (mem: ProjectMember): boolean => mem.memberId.toString() !== this.user_member_id.toString() + ) + }) + ) } addMember(member: ProjectMember): void { - this.members_to_add.push(member); + this.members_to_add.push(member) } removeMember(member: ProjectMember): void { - this.members_to_add.splice(this.members_to_add.indexOf(member), 1); + this.members_to_add.splice(this.members_to_add.indexOf(member), 1) } ngOnInit(): void { - this.getMembersOfTheProject(); + this.getMembersOfTheProject() } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } - } diff --git a/src/app/virtualmachines/resource-overview/resource-overview.component.ts b/src/app/virtualmachines/resource-overview/resource-overview.component.ts index 42a9b38502..6f6139e43f 100644 --- a/src/app/virtualmachines/resource-overview/resource-overview.component.ts +++ b/src/app/virtualmachines/resource-overview/resource-overview.component.ts @@ -1,7 +1,5 @@ -import { - Component, Input, OnChanges, OnInit, -} from '@angular/core'; -import { ApplicationRessourceUsage } from '../../applications/application-ressource-usage/application-ressource-usage'; +import { Component, Input, OnChanges, OnInit } from '@angular/core' +import { ApplicationRessourceUsage } from '../../applications/application-ressource-usage/application-ressource-usage' /** * Resource Overview Component @@ -9,31 +7,28 @@ import { ApplicationRessourceUsage } from '../../applications/application-ressou @Component({ selector: 'app-resource-overview', templateUrl: './resource-overview.component.html', - styleUrls: ['./resource-overview.component.scss'], + styleUrls: ['./resource-overview.component.scss'] }) export class ResourceOverviewComponent implements OnInit, OnChanges { + @Input() ressourceUsage: ApplicationRessourceUsage + @Input() showAdditionalRes: boolean = false - @Input() ressourceUsage: ApplicationRessourceUsage; - @Input() showAdditionalRes: boolean = false; + @Input() newDiskspace: number = 0 + newVolumes: number = 0 + @Input() newCores: number = 0 + @Input() newRam: number = 0 + @Input() newVms: number = 0 + @Input() newGpus: number = 0 - @Input() newDiskspace: number = 0; - newVolumes: number = 0; - @Input() newCores: number = 0; - @Input() newRam: number = 0; - @Input() newVms: number = 0; - @Input() newGpus: number = 0; - - info_background: string = '#17a2b8'; + info_background: string = '#17a2b8' ngOnChanges(): void { if (this.newDiskspace > 0) { - this.newVolumes = 1; + this.newVolumes = 1 } else { - this.newVolumes = 0; + this.newVolumes = 0 } } - ngOnInit(): void { - - } + ngOnInit(): void {} } diff --git a/src/app/virtualmachines/snapshots/snapshotOverview.component.ts b/src/app/virtualmachines/snapshots/snapshotOverview.component.ts index 2b0eb02927..9ef72d54bc 100644 --- a/src/app/virtualmachines/snapshots/snapshotOverview.component.ts +++ b/src/app/virtualmachines/snapshots/snapshotOverview.component.ts @@ -1,17 +1,17 @@ -import { Component, OnInit, inject } from '@angular/core'; -import { forkJoin, Subject } from 'rxjs'; -import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { ImageService } from '../../api-connector/image.service'; -import { SnapshotModel } from './snapshot.model'; -import { IResponseTemplate } from '../../api-connector/response-template'; -import { FacilityService } from '../../api-connector/facility.service'; -import { CLOUD_PORTAL_SUPPORT_MAIL, WIKI_SNAPSHOTS } from '../../../links/links'; -import { SnapshotPage } from './snapshotPage.model'; -import { ApplicationsService } from '../../api-connector/applications.service'; -import { IsMigratedProjectIdPipe } from '../../pipe-module/pipes/migratedList'; - -// eslint-disable-next-line no-shadow +import { Component, OnInit, inject } from '@angular/core' +import { forkJoin, Subject } from 'rxjs' +import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators' +import { MatomoTracker } from 'ngx-matomo-client' +import { ImageService } from '../../api-connector/image.service' +import { SnapshotModel } from './snapshot.model' +import { IResponseTemplate } from '../../api-connector/response-template' +import { FacilityService } from '../../api-connector/facility.service' +import { CLOUD_PORTAL_SUPPORT_MAIL, WIKI_SNAPSHOTS } from '../../../links/links' +import { SnapshotPage } from './snapshotPage.model' +import { ApplicationsService } from '../../api-connector/applications.service' +import { IsMigratedProjectIdPipe } from '../../pipe-module/pipes/migratedList' + + enum Snapshot_Delete_Statuses { WAITING = 0, SUCCESS = 1, @@ -24,70 +24,70 @@ enum Snapshot_Delete_Statuses { @Component({ selector: 'app-snapshot-overview', templateUrl: 'snapshotOverview.component.html', - providers: [FacilityService, ImageService], + providers: [FacilityService, ImageService] }) export class SnapshotOverviewComponent implements OnInit { - private readonly tracker = inject(MatomoTracker); - snapshot_page: SnapshotPage = new SnapshotPage(); - WIKI_SNAPSHOTS: string = WIKI_SNAPSHOTS; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - checked_snapshots: SnapshotModel[] = []; + private readonly tracker = inject(MatomoTracker) + snapshot_page: SnapshotPage = new SnapshotPage() + WIKI_SNAPSHOTS: string = WIKI_SNAPSHOTS + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + checked_snapshots: SnapshotModel[] = [] - title: string = 'Snapshot Overview'; + title: string = 'Snapshot Overview' - showFacilities: boolean = false; + showFacilities: boolean = false /** * Facilitties where the user is manager ['name',id]. */ - managerFacilities: [string, number][]; + managerFacilities: [string, number][] /** * Chosen facility. */ - selectedFacility: [string, number]; + selectedFacility: [string, number] /** * Selected snapshot. */ - selected_snapshot: SnapshotModel; + selected_snapshot: SnapshotModel /** * Actual delete status. * * @type {Snapshot_Delete_Statuses} */ - delete_status: number = Snapshot_Delete_Statuses.WAITING; - delete_statuses: typeof Snapshot_Delete_Statuses = Snapshot_Delete_Statuses; + delete_status: number = Snapshot_Delete_Statuses.WAITING + delete_statuses: typeof Snapshot_Delete_Statuses = Snapshot_Delete_Statuses /** * If site was initialized. * * @type {boolean} */ - isLoaded: boolean = false; - filterChanged: Subject = new Subject(); - filter: string = ''; - all_snapshots_checked: boolean = false; + isLoaded: boolean = false + filterChanged: Subject = new Subject() + filter: string = '' + all_snapshots_checked: boolean = false - private checkStatusTimeout: number = 5000; + private checkStatusTimeout: number = 5000 - currentPage: number = 1; - snapshotsPerPageChange: Subject = new Subject(); - isSearching: boolean = true; - DEBOUNCE_TIME: number = 300; - migratedProjectIds: string[] = []; - migratedProjectNames: string[] = []; + currentPage: number = 1 + snapshotsPerPageChange: Subject = new Subject() + isSearching: boolean = true + DEBOUNCE_TIME: number = 300 + migratedProjectIds: string[] = [] + migratedProjectNames: string[] = [] constructor( private facilityService: FacilityService, private imageService: ImageService, private applicationsService: ApplicationsService, - private isMigratedPipe: IsMigratedProjectIdPipe, + private isMigratedPipe: IsMigratedProjectIdPipe ) { - this.facilityService = facilityService; - this.imageService = imageService; + this.facilityService = facilityService + this.imageService = imageService } changedFilter(text: string): void { - this.filterChanged.next(text); + this.filterChanged.next(text) } /** @@ -96,95 +96,95 @@ export class SnapshotOverviewComponent implements OnInit { * @param snapshot */ setSelectedSnapshot(snapshot: SnapshotModel): void { - this.selected_snapshot = snapshot; + this.selected_snapshot = snapshot } /** * Get snapshots by user. */ getSnapshots(): void { - this.filter = this.filter.trim(); + this.filter = this.filter.trim() this.imageService .getSnapshotsByUser(this.currentPage, this.snapshot_page.items_per_page, this.filter) .subscribe((snapshot_page: SnapshotPage): void => { - this.snapshot_page = snapshot_page; - this.generateMigratedProjectIdList(); - this.generateMigratedProjectNamesList(); - this.isLoaded = true; - this.checkSnapShotsStatus(); - this.isSearching = false; - }); + this.snapshot_page = snapshot_page + this.generateMigratedProjectIdList() + this.generateMigratedProjectNamesList() + this.isLoaded = true + this.checkSnapShotsStatus() + this.isSearching = false + }) } generateMigratedProjectIdList(): void { - this.migratedProjectIds = []; + this.migratedProjectIds = [] this.snapshot_page.snapshot_list.forEach((snap: SnapshotModel) => { if (snap.migrate_project_to_simple_vm || snap.project_is_migrated_to_simple_vm) { - this.migratedProjectIds.push(snap.snapshot_projectid.toString()); + this.migratedProjectIds.push(snap.snapshot_projectid.toString()) } - const unique = (arr: string[]): string[] => [...new Set(arr)]; - this.migratedProjectIds = unique(this.migratedProjectIds); - }); + const unique = (arr: string[]): string[] => [...new Set(arr)] + this.migratedProjectIds = unique(this.migratedProjectIds) + }) } generateMigratedProjectNamesList(): void { - this.migratedProjectNames = []; + this.migratedProjectNames = [] this.snapshot_page.snapshot_list.forEach((snap: SnapshotModel) => { if (snap.migrate_project_to_simple_vm || snap.project_is_migrated_to_simple_vm) { - this.migratedProjectNames.push(snap.snapshot_project); + this.migratedProjectNames.push(snap.snapshot_project) } - }); + }) } changeCheckAllSnapshots(): void { if (this.all_snapshots_checked) { - this.checked_snapshots = []; - this.all_snapshots_checked = false; + this.checked_snapshots = [] + this.all_snapshots_checked = false - return; + return } this.snapshot_page.snapshot_list.forEach((snap: SnapshotModel): void => { if ( - !this.isSnapChecked(snap) - && !this.isMigratedPipe.transform(snap.snapshot_projectid, this.migratedProjectIds) + !this.isSnapChecked(snap) && + !this.isMigratedPipe.transform(snap.snapshot_projectid, this.migratedProjectIds) ) { - this.checked_snapshots.push(snap); + this.checked_snapshots.push(snap) } - }); - this.all_snapshots_checked = true; + }) + this.all_snapshots_checked = true } checkSnapShotsStatus(): void { - let all_active_or_migrated: boolean = true; + let all_active_or_migrated: boolean = true setTimeout((): void => { - const observables: any = []; + const observables: any = [] for (const snapshot of this.snapshot_page.snapshot_list) { if (snapshot.snapshot_status !== 'active' && snapshot.snapshot_status !== 'MIGRATED') { - observables.push(this.imageService.getSnapshot(snapshot.snapshot_openstackid)); + observables.push(this.imageService.getSnapshot(snapshot.snapshot_openstackid)) } } forkJoin(observables).subscribe((res: any): void => { for (const snap of res) { - this.snapshot_page.snapshot_list[res.indexOf(snap)].snapshot_status = snap['status']; + this.snapshot_page.snapshot_list[res.indexOf(snap)].snapshot_status = snap['status'] if (snap['status'] !== 'active' && snap['status'] !== 'MIGRATED') { - all_active_or_migrated = false; + all_active_or_migrated = false } } if (!all_active_or_migrated) { - this.checkSnapShotsStatus(); + this.checkSnapShotsStatus() } - }); - }, this.checkStatusTimeout); + }) + }, this.checkStatusTimeout) } getFacilitySnapshots(): void { this.facilityService .getFacilitySnapshots(this.selectedFacility['FacilityId'], this.currentPage, this.snapshot_page.items_per_page) .subscribe((snapshot_page: SnapshotPage): void => { - this.snapshot_page = snapshot_page; - this.isSearching = false; - }); + this.snapshot_page = snapshot_page + this.isSearching = false + }) } /** @@ -194,105 +194,105 @@ export class SnapshotOverviewComponent implements OnInit { */ deleteSnapshot(snapshot: SnapshotModel): void { this.imageService.deleteSnapshot(snapshot.snapshot_openstackid).subscribe((result: IResponseTemplate): void => { - this.delete_status = 0; + this.delete_status = 0 if (result.value as boolean) { - this.delete_status = 1; - const idx: number = this.snapshot_page.snapshot_list.indexOf(snapshot); + this.delete_status = 1 + const idx: number = this.snapshot_page.snapshot_list.indexOf(snapshot) - this.snapshot_page.snapshot_list.splice(idx, 1); + this.snapshot_page.snapshot_list.splice(idx, 1) } else if (result.value) { - this.delete_status = 3; - this.getSnapshots(); + this.delete_status = 3 + this.getSnapshots() } else { - this.delete_status = 2; - this.getSnapshots(); + this.delete_status = 2 + this.getSnapshots() } - }); + }) } ngOnInit(): void { - this.tracker.trackPageView('Snapshot Overview'); - this.getSnapshots(); + this.tracker.trackPageView('Snapshot Overview') + this.getSnapshots() this.filterChanged .pipe( debounceTime(this.DEBOUNCE_TIME), distinctUntilChanged(), switchMap((filterName: string): any => { - this.isSearching = true; + this.isSearching = true - this.filter = filterName.trim(); + this.filter = filterName.trim() if (this.showFacilities) { return this.facilityService.getFacilitySnapshots( this.selectedFacility['FacilityId'], this.currentPage, this.snapshot_page.items_per_page, - this.filter, - ); + this.filter + ) } else { return this.imageService.getSnapshotsByUser( this.currentPage, this.snapshot_page.items_per_page, - this.filter, - ); + this.filter + ) } - }), + }) ) .subscribe((snapshot_page: SnapshotPage): void => { - this.snapshot_page = snapshot_page; - this.isLoaded = true; - this.checkSnapShotsStatus(); - this.isSearching = false; - }); + this.snapshot_page = snapshot_page + this.isLoaded = true + this.checkSnapShotsStatus() + this.isSearching = false + }) this.snapshotsPerPageChange.pipe(debounceTime(this.DEBOUNCE_TIME), distinctUntilChanged()).subscribe((): void => { if (this.showFacilities) { - this.getFacilitySnapshots(); + this.getFacilitySnapshots() } else { - this.getSnapshots(); + this.getSnapshots() } - }); + }) this.facilityService.getManagerFacilities().subscribe((result: any): void => { - this.managerFacilities = result; - this.selectedFacility = this.managerFacilities[0]; - }); + this.managerFacilities = result + this.selectedFacility = this.managerFacilities[0] + }) } areAllSnapshotsChecked(): void { - let all_checked: boolean = true; + let all_checked: boolean = true this.snapshot_page.snapshot_list.forEach((snap: SnapshotModel): void => { if (!this.isSnapChecked(snap)) { - all_checked = false; + all_checked = false } - }); + }) - this.all_snapshots_checked = all_checked; + this.all_snapshots_checked = all_checked } changeCheckedSnapshot(snap: SnapshotModel): void { if (!this.isSnapChecked(snap)) { - this.checked_snapshots.push(snap); + this.checked_snapshots.push(snap) } else { - this.checked_snapshots.splice(this.checked_snapshots.indexOf(snap), 1); + this.checked_snapshots.splice(this.checked_snapshots.indexOf(snap), 1) } - this.areAllSnapshotsChecked(); + this.areAllSnapshotsChecked() } isSnapChecked(snap: SnapshotModel): boolean { - return this.checked_snapshots.indexOf(snap) !== -1; + return this.checked_snapshots.indexOf(snap) !== -1 } deleteSelectedSnapshots(): void { this.checked_snapshots.forEach((snap: SnapshotModel): void => { - this.deleteSnapshot(snap); - }); - this.uncheckAll(); + this.deleteSnapshot(snap) + }) + this.uncheckAll() } uncheckAll(): void { - this.checked_snapshots = []; - this.all_snapshots_checked = false; + this.checked_snapshots = [] + this.all_snapshots_checked = false } /** @@ -301,19 +301,19 @@ export class SnapshotOverviewComponent implements OnInit { * @param event */ pageChanged(event: any): void { - this.isSearching = true; + this.isSearching = true - this.currentPage = event.page; + this.currentPage = event.page if (this.showFacilities) { - this.getFacilitySnapshots(); + this.getFacilitySnapshots() } else { - this.getSnapshots(); + this.getSnapshots() } } reset(): void { - this.snapshot_page = new SnapshotPage(); - this.isSearching = true; - this.currentPage = 1; + this.snapshot_page = new SnapshotPage() + this.isSearching = true + this.currentPage = 1 } } diff --git a/src/app/virtualmachines/virtualmachinemodels/virtualmachine.ts b/src/app/virtualmachines/virtualmachinemodels/virtualmachine.ts index a489241fd8..fc8d9979cf 100644 --- a/src/app/virtualmachines/virtualmachinemodels/virtualmachine.ts +++ b/src/app/virtualmachines/virtualmachinemodels/virtualmachine.ts @@ -1,134 +1,134 @@ -import { Flavor } from './flavor'; -import { Client } from '../../vo_manager/clients/client.model'; -import { ImageMode } from '../../facility_manager/image-tag'; -import { Clusterinfo } from '../clusters/clusterinfo'; -import { Volume } from '../volumes/volume'; -import { Backend } from '../conda/backend/backend'; -import { VirtualMachineStates } from './virtualmachinestates'; -import { CondaPackage } from '../conda/condaPackage.model'; +import { Flavor } from './flavor' +import { Client } from '../../vo_manager/clients/client.model' +import { ImageMode } from '../../facility_manager/image-tag' +import { Clusterinfo } from '../clusters/clusterinfo' +import { Volume } from '../volumes/volume' +import { Backend } from '../conda/backend/backend' +import { VirtualMachineStates } from './virtualmachinestates' +import { CondaPackage } from '../conda/condaPackage.model' /** * Virtualmachine class. */ export class VirtualMachine { - flavor: Flavor; - image: string; - project: string; - status: string; - keyname: string; - name: string; - client: Client; - openstackid: string; - created_at_date: string; - deleted_at_date: string; - still_used_confirmation_requested_date: Date; - still_used_confirmed_user_id: string; - stopped_at: string; - elixir_id: string; - fixed_ip: string; - userlogin: string; - floating_ip: string; - ssh_command: string; - udp_command: string; - application_id: string; - cardState: number; - cluster: Clusterinfo; - projectid: number; - playbook_successful: boolean; - playbook_done: boolean; - res_env_url: string; - modes: ImageMode[]; - volumes: Volume[]; - still_used_confirmation_requested: boolean; - error_msg: string; - info_msg: string; - msg: string; - days_running: number; - backend: Backend; - conda_packages: CondaPackage[] = []; - still_used_confirmed_date: Date; + flavor: Flavor + image: string + project: string + status: string + keyname: string + name: string + client: Client + openstackid: string + created_at_date: string + deleted_at_date: string + still_used_confirmation_requested_date: Date + still_used_confirmed_user_id: string + stopped_at: string + elixir_id: string + fixed_ip: string + userlogin: string + floating_ip: string + ssh_command: string + udp_command: string + application_id: string + cardState: number + cluster: Clusterinfo + projectid: number + playbook_successful: boolean + playbook_done: boolean + res_env_url: string + modes: ImageMode[] + volumes: Volume[] + still_used_confirmation_requested: boolean + error_msg: string + info_msg: string + msg: string + days_running: number + backend: Backend + conda_packages: CondaPackage[] = [] + still_used_confirmed_date: Date // still used confirmed date missing in webapp! - migrate_project_to_simple_vm: boolean = false; - project_is_migrated_to_simple_vm: boolean = false; + migrate_project_to_simple_vm: boolean = false + project_is_migrated_to_simple_vm: boolean = false constructor(vm?: Partial) { - Object.assign(this, vm); - this.cardState = 0; + Object.assign(this, vm) + this.cardState = 0 if (vm) { if (vm.flavor) { - this.flavor = new Flavor(vm.flavor); + this.flavor = new Flavor(vm.flavor) } if (vm.client) { - this.client = new Client(vm.client); + this.client = new Client(vm.client) } if (vm.cluster) { - this.cluster = new Clusterinfo(vm.cluster); + this.cluster = new Clusterinfo(vm.cluster) } - this.volumes = []; + this.volumes = [] if (vm.volumes) { for (const volume of vm.volumes) { - this.volumes.push(new Volume(volume)); + this.volumes.push(new Volume(volume)) } } if (vm.backend) { - this.backend = new Backend(vm.backend); + this.backend = new Backend(vm.backend) } - this.conda_packages = []; + this.conda_packages = [] if (vm.conda_packages) { for (const conda_package of vm.conda_packages) { - this.conda_packages.push(new CondaPackage(conda_package)); + this.conda_packages.push(new CondaPackage(conda_package)) } } } - this.getTerminationStartDateString(); - if (this.days_running == null) { - this.days_running = this.calculateDaysRunning(); + this.getTerminationStartDateString() + if (this.days_running === null) { + this.days_running = this.calculateDaysRunning() } } public calculateDaysRunning(): number { - const createdDate: Date = new Date(this.created_at_date); + const createdDate: Date = new Date(this.created_at_date) - return Math.floor((Date.now() - createdDate.getTime()) / 86400000); + return Math.floor((Date.now() - createdDate.getTime()) / 86400000) } public getTerminationStartDateString(): string { if ( - this.still_used_confirmation_requested_date === null - || this.still_used_confirmation_requested_date === undefined + this.still_used_confirmation_requested_date === null || + this.still_used_confirmation_requested_date === undefined ) { - return ''; + return '' } this.still_used_confirmation_requested_date = new Date( - Date.parse(this.still_used_confirmation_requested_date.toString()), - ); - const term_date: Date = new Date(this.still_used_confirmation_requested_date.getTime() + 1000 * 60 * 60 * 24 * 14); + Date.parse(this.still_used_confirmation_requested_date.toString()) + ) + const term_date: Date = new Date(this.still_used_confirmation_requested_date.getTime() + 1000 * 60 * 60 * 24 * 14) - return term_date.toLocaleDateString(); + return term_date.toLocaleDateString() } setErrorMsgWithTimeout(msg: string, timeout: number = 10000): void { - this.error_msg = msg; + this.error_msg = msg setTimeout((): void => { - this.error_msg = null; - }, timeout); + this.error_msg = null + }, timeout) } setMsgWithTimeout(msg: string, timeout: number = 10000): void { - this.msg = msg; + this.msg = msg setTimeout((): void => { - this.msg = null; - }, timeout); + this.msg = null + }, timeout) } updateClusterStatus(): void { if (!this.cluster) { - return; + return } if (this.status === VirtualMachineStates.SHUTOFF) { - this.cluster.status = VirtualMachineStates.SHUTOFF; + this.cluster.status = VirtualMachineStates.SHUTOFF } } } diff --git a/src/app/virtualmachines/virtualmachinemodels/virtualmachinestates.ts b/src/app/virtualmachines/virtualmachinemodels/virtualmachinestates.ts index 2e624c7bc9..b34e65c425 100644 --- a/src/app/virtualmachines/virtualmachinemodels/virtualmachinestates.ts +++ b/src/app/virtualmachines/virtualmachinemodels/virtualmachinestates.ts @@ -1,30 +1,30 @@ -import { GeneralStatusStates } from '../../shared/shared_modules/baseClass/statusstates'; +import { GeneralStatusStates } from '../../shared/shared_modules/baseClass/statusstates' /** * Virtualmachine class. */ export class VirtualMachineStates extends GeneralStatusStates { - private static readonly _ACTIVE: string = 'ACTIVE'; - private static readonly _SHUTOFF: string = 'SHUTOFF'; - private static readonly _BUILD: string = 'BUILD'; - private static readonly _POWERING_OFF: string = 'POWERING_OFF'; - private static readonly _POWERING_ON: string = 'POWERING_ON'; - private static readonly _REBOOTING: string = 'REBOOTING'; - private static readonly _REBOOTING_STARTED: string = 'REBOOT_STARTED'; - private static readonly _REBOOTING_HARD: string = 'REBOOT_STARTED_HARD'; - private static readonly _PREPARE_PLAYBOOK_BUILD: string = 'PREPARE_PLAYBOOK_BUILD'; - private static readonly _BUILD_PLAYBOOK: string = 'BUILD_PLAYBOOK'; - private static readonly _PORT_CLOSED: string = 'PORT_CLOSED'; - private static readonly _CHECKING_CONNECTION: string = 'CHECKING CONNECTION'; - private static readonly _IMAGE_PENDING_UPLOAD: string = 'IMAGE_PENDING_UPLOAD'; - private static readonly _IMAGE_UPLOADING: string = 'IMAGE_UPLOADING'; - private static readonly _SPAWNING: string = 'SPAWNING'; - private static readonly _SCHEDULING: string = 'SCHEDULING'; - private static readonly _PLANNED: string = 'PLANNED'; - private static readonly _CREATION_FAILED: string = 'CREATION_FAILED'; - private static readonly _LOCKED: string = 'LOCKED'; - - private static readonly _DISABLED: string = 'DISABLED'; + private static readonly _ACTIVE: string = 'ACTIVE' + private static readonly _SHUTOFF: string = 'SHUTOFF' + private static readonly _BUILD: string = 'BUILD' + private static readonly _POWERING_OFF: string = 'POWERING_OFF' + private static readonly _POWERING_ON: string = 'POWERING_ON' + private static readonly _REBOOTING: string = 'REBOOTING' + private static readonly _REBOOTING_STARTED: string = 'REBOOT_STARTED' + private static readonly _REBOOTING_HARD: string = 'REBOOT_STARTED_HARD' + private static readonly _PREPARE_PLAYBOOK_BUILD: string = 'PREPARE_PLAYBOOK_BUILD' + private static readonly _BUILD_PLAYBOOK: string = 'BUILD_PLAYBOOK' + private static readonly _PORT_CLOSED: string = 'PORT_CLOSED' + private static readonly _CHECKING_CONNECTION: string = 'CHECKING CONNECTION' + private static readonly _IMAGE_PENDING_UPLOAD: string = 'IMAGE_PENDING_UPLOAD' + private static readonly _IMAGE_UPLOADING: string = 'IMAGE_UPLOADING' + private static readonly _SPAWNING: string = 'SPAWNING' + private static readonly _SCHEDULING: string = 'SCHEDULING' + private static readonly _PLANNED: string = 'PLANNED' + private static readonly _CREATION_FAILED: string = 'CREATION_FAILED' + private static readonly _LOCKED: string = 'LOCKED' + + private static readonly _DISABLED: string = 'DISABLED' private static readonly _IN_PROCESS_STATES: string[] = [ VirtualMachineStates._REBOOTING_STARTED, @@ -47,8 +47,8 @@ export class VirtualMachineStates extends GeneralStatusStates { VirtualMachineStates._GETTING_STATUS, VirtualMachineStates._PLANNED, - null, - ]; + null + ] private static readonly _NOT_IN_PROCESS_STATES: string[] = [ VirtualMachineStates._ACTIVE, @@ -61,8 +61,8 @@ export class VirtualMachineStates extends GeneralStatusStates { VirtualMachineStates._CREATION_FAILED, VirtualMachineStates._MIGRATED, VirtualMachineStates._LOCKED, - VirtualMachineStates._DISABLED, - ]; + VirtualMachineStates._DISABLED + ] private static readonly _DELETABLE_STATES: string[] = [ VirtualMachineStates._ACTIVE, @@ -72,194 +72,194 @@ export class VirtualMachineStates extends GeneralStatusStates { VirtualMachineStates._PLANNED, VirtualMachineStates._PREPARE_PLAYBOOK_BUILD, VirtualMachineStates._CREATION_FAILED, - VirtualMachineStates._LOCKED, - ]; + VirtualMachineStates._LOCKED + ] static get DELETABLE_STATES(): string[] { - return this._DELETABLE_STATES; + return this._DELETABLE_STATES } static get CLIENT_OFFLINE(): string { - return this._CLIENT_OFFLINE; + return this._CLIENT_OFFLINE } static get DISABLED(): string { - return this._DISABLED; + return this._DISABLED } static get LOCKED(): string { - return this._LOCKED; + return this._LOCKED } static get REBOOTING(): string { - return this._REBOOTING; + return this._REBOOTING } static get REBOOTING_STARTED(): string { - return this._REBOOTING_STARTED; + return this._REBOOTING_STARTED } static get PLANNED(): string { - return this._PLANNED; + return this._PLANNED } static get REBOOTING_HARD(): string { - return this._REBOOTING_HARD; + return this._REBOOTING_HARD } static get BUILD(): string { - return this._BUILD; + return this._BUILD } static get IMAGE_PENDING_UPLOAD(): string { - return this._IMAGE_PENDING_UPLOAD; + return this._IMAGE_PENDING_UPLOAD } static get IMAGE_UPLOADING(): string { - return this._IMAGE_UPLOADING; + return this._IMAGE_UPLOADING } static get PREPARE_PLAYBOOK_BUILD(): string { - return this._PREPARE_PLAYBOOK_BUILD; + return this._PREPARE_PLAYBOOK_BUILD } static get BUILD_PLAYBOOK(): string { - return this._BUILD_PLAYBOOK; + return this._BUILD_PLAYBOOK } static get ACTIVE(): string { - return this._ACTIVE; + return this._ACTIVE } static get SHUTOFF(): string { - return this._SHUTOFF; + return this._SHUTOFF } static get SPAWNING(): string { - return this._SPAWNING; + return this._SPAWNING } static get SCHEDULING(): string { - return this._SCHEDULING; + return this._SCHEDULING } static get POWERING_OFF(): string { - return this._POWERING_OFF; + return this._POWERING_OFF } static get POWERING_ON(): string { - return this._POWERING_ON; + return this._POWERING_ON } static get PORT_CLOSED(): string { - return this._PORT_CLOSED; + return this._PORT_CLOSED } static get CHECKING_CONNECTION(): string { - return this._CHECKING_CONNECTION; + return this._CHECKING_CONNECTION } static get IN_PROCESS_STATES(): string[] { - return this._IN_PROCESS_STATES; + return this._IN_PROCESS_STATES } static get NOT_IN_PROCESS_STATES(): string[] { - return this._NOT_IN_PROCESS_STATES; + return this._NOT_IN_PROCESS_STATES } static get CREATION_FAILED(): string { - return this._CREATION_FAILED; + return this._CREATION_FAILED } public get staticPREPARE_PLAYBOOK_BUILD(): string { - return VirtualMachineStates.PREPARE_PLAYBOOK_BUILD; + return VirtualMachineStates.PREPARE_PLAYBOOK_BUILD } public get staticIMAGE_UPLOADING(): string { - return VirtualMachineStates.IMAGE_UPLOADING; + return VirtualMachineStates.IMAGE_UPLOADING } public get staticDISABLED(): string { - return VirtualMachineStates.DISABLED; + return VirtualMachineStates.DISABLED } public get staticIMAGE_PENDING_UPLOAD(): string { - return VirtualMachineStates.IMAGE_PENDING_UPLOAD; + return VirtualMachineStates.IMAGE_PENDING_UPLOAD } public get staticBUILD_PLAYBOOK(): string { - return VirtualMachineStates.BUILD_PLAYBOOK; + return VirtualMachineStates.BUILD_PLAYBOOK } public get staticBUILD(): string { - return VirtualMachineStates.BUILD; + return VirtualMachineStates.BUILD } public get staticPLANNED(): string { - return VirtualMachineStates.PLANNED; + return VirtualMachineStates.PLANNED } public get staticCHECKING_CONNECTION(): string { - return VirtualMachineStates.CHECKING_CONNECTION; + return VirtualMachineStates.CHECKING_CONNECTION } public get staticPORT_CLOSED(): string { - return VirtualMachineStates.PORT_CLOSED; + return VirtualMachineStates.PORT_CLOSED } public get staticACTIVE(): string { - return VirtualMachineStates.ACTIVE; + return VirtualMachineStates.ACTIVE } public get staticSPAWNING(): string { - return VirtualMachineStates.SPAWNING; + return VirtualMachineStates.SPAWNING } public get staticSCHEDULING(): string { - return VirtualMachineStates.SCHEDULING; + return VirtualMachineStates.SCHEDULING } public get staticSHUTOFF(): string { - return VirtualMachineStates.SHUTOFF; + return VirtualMachineStates.SHUTOFF } public get staticPOWERING_OFF(): string { - return VirtualMachineStates.POWERING_OFF; + return VirtualMachineStates.POWERING_OFF } public get staticPOWERING_ON(): string { - return VirtualMachineStates.POWERING_ON; + return VirtualMachineStates.POWERING_ON } public get staticNOT_IN_PROCESS_STATE(): string[] { - return VirtualMachineStates.NOT_IN_PROCESS_STATES; + return VirtualMachineStates.NOT_IN_PROCESS_STATES } public get staticIN_PROCESS_STATE(): string[] { - return VirtualMachineStates.IN_PROCESS_STATES; + return VirtualMachineStates.IN_PROCESS_STATES } public get staticREBOOTING_STARTED(): string { - return VirtualMachineStates.REBOOTING_STARTED; + return VirtualMachineStates.REBOOTING_STARTED } public get staticREBOOTING_HARD(): string { - return VirtualMachineStates.REBOOTING_HARD; + return VirtualMachineStates.REBOOTING_HARD } public get staticREBOOTING(): string { - return VirtualMachineStates.REBOOTING; + return VirtualMachineStates.REBOOTING } public get staticDELETABLE_STATES(): string[] { - return VirtualMachineStates.DELETABLE_STATES; + return VirtualMachineStates.DELETABLE_STATES } public get staticCREATION_FAILED(): string { - return VirtualMachineStates.CREATION_FAILED; + return VirtualMachineStates.CREATION_FAILED } public get staticLOCKED(): string { - return VirtualMachineStates.LOCKED; + return VirtualMachineStates.LOCKED } } diff --git a/src/app/virtualmachines/vm.module.ts b/src/app/virtualmachines/vm.module.ts index fa2a08e7cf..8dcbbc3103 100644 --- a/src/app/virtualmachines/vm.module.ts +++ b/src/app/virtualmachines/vm.module.ts @@ -1,56 +1,56 @@ -import { NgModule } from '@angular/core'; -import { CarouselModule } from 'ngx-owl-carousel-o'; -import { TabsModule } from 'ngx-bootstrap/tabs'; -import { CommonModule } from '@angular/common'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { ModalModule } from 'ngx-bootstrap/modal'; -import { PaginationModule } from 'ngx-bootstrap/pagination'; -import { AccordionModule } from 'ngx-bootstrap/accordion'; -import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import { VmRoutingModule } from './vm_routing.module'; -import { ImageDetailComponent } from './imagedetail.component'; -import { VirtualMachineComponent } from './addvm.component'; -import { FlavorDetailComponent } from './flavordetail.component'; -import { VmOverviewComponent } from './vmOverview.component'; -import { VolumeOverviewComponent } from './volumes/volumeOverview.component'; -import { SnapshotOverviewComponent } from './snapshots/snapshotOverview.component'; -import { PublicKeyModule } from '../shared/shared_modules/public-key/public-key.module'; -import { BiocondaComponent } from './conda/bioconda.component'; -import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module'; -import { ImageCarouselSlideComponent } from './imageCarouselSlide.component'; -import { VmDetailComponent } from './vmdetail/vmdetail.component'; -import { AddClusterComponent } from './clusters/add-cluster/add-cluster.component'; -import { ResourceOverviewComponent } from './resource-overview/resource-overview.component'; -import { ResEnvComponent } from './conda/res-env.component'; -import { ClusterdetailComponent } from './clusters/clusterdetail/clusterdetail.component'; -import { VirtualmachineinfoComponent } from './vmdetail/virtualmachineinfo/virtualmachineinfo.component'; -import { VmstatusComponent } from './vmdetail/vmstatus/vmstatus.component'; -import { ClusterOverviewComponent } from './clusters/clusteroverview/clusterOverview.component'; -import { ClusterinfoComponent } from './clusters/clusterinfo/clusterinfo.component'; -import { ClusterstatusComponent } from './clusters/clusterstatus/clusterstatus.component'; -import { VolumStatusComponent } from './volumes/volum-status/volum-status.component'; -import { PipeModuleModule } from '../pipe-module/pipe-module.module'; -import { ProjectUserListComponent } from './project-user-list/project-user-list.component'; -import { StopVmComponent } from './modals/stop-vm/stop-vm.component'; -import { VmCardComponent } from './vmcard/vmcard.component'; -import { ResumeVmComponent } from './modals/resume-vm/resume-vm.component'; -import { ResumeClusterComponent } from './modals/resume-cluster/resume-cluster.component'; -import { DeleteVmComponent } from './modals/delete-vm/delete-vm.component'; -import { SnapshotVmComponent } from './modals/snapshot-vm/snapshot-vm.component'; -import { VolumeVmComponent } from './modals/volume-vm/volume-vm.component'; -import { RebootVmComponent } from './modals/reboot-vm/reboot-vm.component'; -import { ClustercardComponent } from './clustercard/clustercard.component'; -import { ScaleClusterComponent } from './modals/scale-cluster/scale-cluster.component'; -import { DeleteClusterComponent } from './modals/delete-cluster/delete-cluster.component'; -import { AddWorkshopComponent } from './workshop/add-workshop/add-workshop.component'; -import { WorkshopOverviewComponent } from './workshop/workshop-overview/workshop-overview.component'; -import { NewsModule } from '../news/news.module'; -import { RecreateBackendVmComponent } from './modals/recreate-backend-vm/recreate-backend-vm.component'; -import { DatePickerComponent } from '../shared/datepicking/datepicker.component'; -import { TimepickerComponent } from '../shared/datepicking/timepicker.component'; -import { SharedModuleModule } from '../shared/shared_modules/shared-module.module'; -import { ClusterActionsComponent } from './clusters/cluster-actions/cluster-actions.component'; +import { NgModule } from '@angular/core' +import { CarouselModule } from 'ngx-owl-carousel-o' +import { TabsModule } from 'ngx-bootstrap/tabs' +import { CommonModule } from '@angular/common' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { ModalModule } from 'ngx-bootstrap/modal' +import { PaginationModule } from 'ngx-bootstrap/pagination' +import { AccordionModule } from 'ngx-bootstrap/accordion' +import { BsDropdownModule } from 'ngx-bootstrap/dropdown' +import { NgbModule } from '@ng-bootstrap/ng-bootstrap' +import { VmRoutingModule } from './vm_routing.module' +import { ImageDetailComponent } from './imagedetail.component' +import { VirtualMachineComponent } from './addvm.component' +import { FlavorDetailComponent } from './flavordetail.component' +import { VmOverviewComponent } from './vmOverview.component' +import { VolumeOverviewComponent } from './volumes/volumeOverview.component' +import { SnapshotOverviewComponent } from './snapshots/snapshotOverview.component' +import { PublicKeyModule } from '../shared/shared_modules/public-key/public-key.module' +import { BiocondaComponent } from './conda/bioconda.component' +import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module' +import { ImageCarouselSlideComponent } from './imageCarouselSlide.component' +import { VmDetailComponent } from './vmdetail/vmdetail.component' +import { AddClusterComponent } from './clusters/add-cluster/add-cluster.component' +import { ResourceOverviewComponent } from './resource-overview/resource-overview.component' +import { ResEnvComponent } from './conda/res-env.component' +import { ClusterdetailComponent } from './clusters/clusterdetail/clusterdetail.component' +import { VirtualmachineinfoComponent } from './vmdetail/virtualmachineinfo/virtualmachineinfo.component' +import { VmstatusComponent } from './vmdetail/vmstatus/vmstatus.component' +import { ClusterOverviewComponent } from './clusters/clusteroverview/clusterOverview.component' +import { ClusterinfoComponent } from './clusters/clusterinfo/clusterinfo.component' +import { ClusterstatusComponent } from './clusters/clusterstatus/clusterstatus.component' +import { VolumStatusComponent } from './volumes/volum-status/volum-status.component' +import { PipeModuleModule } from '../pipe-module/pipe-module.module' +import { ProjectUserListComponent } from './project-user-list/project-user-list.component' +import { StopVmComponent } from './modals/stop-vm/stop-vm.component' +import { VmCardComponent } from './vmcard/vmcard.component' +import { ResumeVmComponent } from './modals/resume-vm/resume-vm.component' +import { ResumeClusterComponent } from './modals/resume-cluster/resume-cluster.component' +import { DeleteVmComponent } from './modals/delete-vm/delete-vm.component' +import { SnapshotVmComponent } from './modals/snapshot-vm/snapshot-vm.component' +import { VolumeVmComponent } from './modals/volume-vm/volume-vm.component' +import { RebootVmComponent } from './modals/reboot-vm/reboot-vm.component' +import { ClustercardComponent } from './clustercard/clustercard.component' +import { ScaleClusterComponent } from './modals/scale-cluster/scale-cluster.component' +import { DeleteClusterComponent } from './modals/delete-cluster/delete-cluster.component' +import { AddWorkshopComponent } from './workshop/add-workshop/add-workshop.component' +import { WorkshopOverviewComponent } from './workshop/workshop-overview/workshop-overview.component' +import { NewsModule } from '../news/news.module' +import { RecreateBackendVmComponent } from './modals/recreate-backend-vm/recreate-backend-vm.component' +import { DatePickerComponent } from '../shared/datepicking/datepicker.component' +import { TimepickerComponent } from '../shared/datepicking/timepicker.component' +import { SharedModuleModule } from '../shared/shared_modules/shared-module.module' +import { ClusterActionsComponent } from './clusters/cluster-actions/cluster-actions.component' /** * VM module. @@ -74,7 +74,7 @@ import { ClusterActionsComponent } from './clusters/cluster-actions/cluster-acti NewsModule, DatePickerComponent, TimepickerComponent, - SharedModuleModule, + SharedModuleModule ], declarations: [ ImageCarouselSlideComponent, @@ -111,7 +111,7 @@ import { ClusterActionsComponent } from './clusters/cluster-actions/cluster-acti ScaleClusterComponent, DeleteClusterComponent, AddWorkshopComponent, - WorkshopOverviewComponent, - ], + WorkshopOverviewComponent + ] }) export class VmModule {} diff --git a/src/app/virtualmachines/vmOverview.component.ts b/src/app/virtualmachines/vmOverview.component.ts index 3043950fd9..d33eacb5ba 100644 --- a/src/app/virtualmachines/vmOverview.component.ts +++ b/src/app/virtualmachines/vmOverview.component.ts @@ -1,23 +1,21 @@ -import { - Component, OnDestroy, OnInit, QueryList, ViewChildren, inject, -} from '@angular/core'; -import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; -import { Subject, Subscription } from 'rxjs'; -import { ClipboardService } from 'ngx-clipboard'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { VirtualmachineService } from '../api-connector/virtualmachine.service'; -import { VirtualMachine } from './virtualmachinemodels/virtualmachine'; -import { VirtualMachinePage } from './virtualmachinemodels/virtualMachinePage'; -import { FullLayoutComponent } from '../layouts/full-layout.component'; -import { UserService } from '../api-connector/user.service'; -import { ImageService } from '../api-connector/image.service'; -import { FacilityService } from '../api-connector/facility.service'; -import { is_vo, elixir_id } from '../shared/globalvar'; -import { VirtualMachineStates } from './virtualmachinemodels/virtualmachinestates'; -import { GroupService } from '../api-connector/group.service'; -import { ClientService } from '../api-connector/client.service'; -import { VmCardComponent } from './vmcard/vmcard.component'; -import { ApplicationsService } from '../api-connector/applications.service'; +import { Component, OnDestroy, OnInit, QueryList, ViewChildren, inject } from '@angular/core' +import { debounceTime, distinctUntilChanged } from 'rxjs/operators' +import { Subject, Subscription } from 'rxjs' +import { ClipboardService } from 'ngx-clipboard' +import { MatomoTracker } from 'ngx-matomo-client' +import { VirtualmachineService } from '../api-connector/virtualmachine.service' +import { VirtualMachine } from './virtualmachinemodels/virtualmachine' +import { VirtualMachinePage } from './virtualmachinemodels/virtualMachinePage' +import { FullLayoutComponent } from '../layouts/full-layout.component' +import { UserService } from '../api-connector/user.service' +import { ImageService } from '../api-connector/image.service' +import { FacilityService } from '../api-connector/facility.service' +import { is_vo, elixir_id } from '../shared/globalvar' +import { VirtualMachineStates } from './virtualmachinemodels/virtualmachinestates' +import { GroupService } from '../api-connector/group.service' +import { ClientService } from '../api-connector/client.service' +import { VmCardComponent } from './vmcard/vmcard.component' +import { ApplicationsService } from '../api-connector/applications.service' /** * Vm overview component. @@ -26,145 +24,145 @@ import { ApplicationsService } from '../api-connector/applications.service'; selector: 'app-vm-overview', templateUrl: 'vmOverview.component.html', styleUrls: ['./vmOverview.component.scss'], - providers: [FacilityService, ImageService, UserService, FullLayoutComponent, GroupService, ClientService], + providers: [FacilityService, ImageService, UserService, FullLayoutComponent, GroupService, ClientService] }) export class VmOverviewComponent implements OnInit, OnDestroy { - private readonly tracker = inject(MatomoTracker); + private readonly tracker = inject(MatomoTracker) /** * Title of page */ - title: string = 'Instance Overview'; + title: string = 'Instance Overview' /** * Subscription to events * @private */ - private subscription: Subscription = new Subscription(); + private subscription: Subscription = new Subscription() /** * States a virtual machine can have */ - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() /** * Current page. */ - currentPage: number = 1; + currentPage: number = 1 /** * Pagination object which holds vm objects and pagination information */ - vm_page: VirtualMachinePage = new VirtualMachinePage(); + vm_page: VirtualMachinePage = new VirtualMachinePage() /** * Child vm cards to call their functions and get information. */ - @ViewChildren(VmCardComponent) children: QueryList; + @ViewChildren(VmCardComponent) children: QueryList /** * Debounce time to apply filter if filter was clicked. */ - LONG_DEBOUNCE_TIME: number = 1000; + LONG_DEBOUNCE_TIME: number = 1000 /** * If cluster machines should be shown. */ - filter_cluster: boolean = false; + filter_cluster: boolean = false /** * If machines set for termination should be shown. */ - filter_set_for_termination: boolean = false; + filter_set_for_termination: boolean = false /** * List with statuses to filter vms by. */ - filter_status_list: string[] = [VirtualMachineStates.ACTIVE, VirtualMachineStates.SHUTOFF]; + filter_status_list: string[] = [VirtualMachineStates.ACTIVE, VirtualMachineStates.SHUTOFF] /** * If page is loading/searching backend for vms. */ - isSearching: boolean = true; + isSearching: boolean = true /** * If 'Select all' is clicked. */ - all_checked: boolean = false; + all_checked: boolean = false /** * Facilities where the user is manager ['name',id]. */ - public managerFacilities: [string, number][]; + public managerFacilities: [string, number][] /** * Chosen facility. */ - public selectedFacility: [string, number]; + public selectedFacility: [string, number] /** * Custom string value to filter vms by. */ - filter: string; + filter: string /** * If user is vo admin. */ - is_vo_admin: boolean; + is_vo_admin: boolean /** * Elixir is of user. */ - user_elixir_id: string; + user_elixir_id: string /** * Tab which is shown own|all. * * @type {string} */ - tab: string = 'own'; + tab: string = 'own' /** * If user is manager of a facility. */ - is_facility_manager: boolean = false; + is_facility_manager: boolean = false /** * If user is allowed to see cluster related things. */ - cluster_allowed: boolean = false; + cluster_allowed: boolean = false /** * Subject to listen and react to page changes. */ - vmPerPageChange: Subject = new Subject(); + vmPerPageChange: Subject = new Subject() /** * List for all machines which are checked. */ - selectedMachines: VmCardComponent[] = []; + selectedMachines: VmCardComponent[] = [] /** * List for all not user-owned machines which are checked. */ - otherSelectedMachines: VmCardComponent[] = []; + otherSelectedMachines: VmCardComponent[] = [] /** * To check if the user agreed to deleting someone else's VMs */ - deleteOtherMachines_confirmation: boolean = false; + deleteOtherMachines_confirmation: boolean = false /** * List of groups of which the user is admin. */ - vms_admin: string[] = []; + vms_admin: string[] = [] /** * Perun id of user. */ - user_perun_id: string; + user_perun_id: string - migratedProjectIds: string[] = []; - migratedProjectNames: string[] = []; + migratedProjectIds: string[] = [] + migratedProjectNames: string[] = [] constructor( private facilityService: FacilityService, @@ -174,33 +172,33 @@ export class VmOverviewComponent implements OnInit, OnDestroy { private virtualmachineservice: VirtualmachineService, private groupService: GroupService, - private applicationsService: ApplicationsService, + private applicationsService: ApplicationsService ) { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { - this.tracker.trackPageView('Instance Overview'); - this.set_cluster_allowed(); - this.getVms(); - this.is_vo_admin = is_vo; - this.user_elixir_id = elixir_id; - this.get_is_facility_manager(); + this.tracker.trackPageView('Instance Overview') + this.set_cluster_allowed() + this.getVms() + this.is_vo_admin = is_vo + this.user_elixir_id = elixir_id + this.get_is_facility_manager() this.subscription.add( this.facilityService.getManagerFacilities().subscribe((result: any): void => { - this.managerFacilities = result; - this.selectedFacility = this.managerFacilities[0]; - }), - ); + this.managerFacilities = result + this.selectedFacility = this.managerFacilities[0] + }) + ) this.subscription.add( this.vmPerPageChange.pipe(debounceTime(this.LONG_DEBOUNCE_TIME), distinctUntilChanged()).subscribe((): void => { - this.applyFilter(); - }), - ); + this.applyFilter() + }) + ) } ngOnDestroy(): void { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } /** @@ -208,19 +206,19 @@ export class VmOverviewComponent implements OnInit, OnDestroy { */ applyFilter(): void { if (this.filter) { - this.filter = this.filter.trim(); + this.filter = this.filter.trim() } - this.isSearching = true; + this.isSearching = true if (typeof this.vm_page.items_per_page !== 'number' || this.vm_page.items_per_page <= 0) { - this.vm_page.items_per_page = 7; + this.vm_page.items_per_page = 7 } if (this.tab === 'own') { - this.getVms(); + this.getVms() } else if (this.tab === 'all') { - this.getAllVms(); + this.getAllVms() } else if (this.tab === 'facility') { - this.getAllVmsFacilities(); + this.getAllVmsFacilities() } } @@ -230,7 +228,7 @@ export class VmOverviewComponent implements OnInit, OnDestroy { * @param vm Track by vm openstackid. */ trackByVm(index: number | string, vm: VirtualMachine): string { - return vm.openstackid; + return vm.openstackid } /** @@ -239,9 +237,9 @@ export class VmOverviewComponent implements OnInit, OnDestroy { set_cluster_allowed(): void { this.subscription.add( this.virtualmachineservice.getClusterAllowed().subscribe((res: any): void => { - this.cluster_allowed = res['allowed']; - }), - ); + this.cluster_allowed = res['allowed'] + }) + ) } /** @@ -249,12 +247,12 @@ export class VmOverviewComponent implements OnInit, OnDestroy { * @param status Which status to add/remove from status filter. */ changeFilterStatus(status: string): void { - this.currentPage = 1; - const indexOf: number = this.filter_status_list.indexOf(status); + this.currentPage = 1 + const indexOf: number = this.filter_status_list.indexOf(status) if (indexOf === -1) { - this.filter_status_list.push(status); + this.filter_status_list.push(status) } else { - this.filter_status_list.splice(indexOf, 1); + this.filter_status_list.splice(indexOf, 1) } } @@ -265,10 +263,10 @@ export class VmOverviewComponent implements OnInit, OnDestroy { this.subscription.add( this.facilityService.getManagerFacilities().subscribe((result: any): void => { if (result.length > 0) { - this.is_facility_manager = true; + this.is_facility_manager = true } - }), - ); + }) + ) } /** @@ -277,7 +275,7 @@ export class VmOverviewComponent implements OnInit, OnDestroy { * @param tabString */ toggleTab(tabString: string): void { - this.tab = tabString; + this.tab = tabString } /** @@ -286,15 +284,15 @@ export class VmOverviewComponent implements OnInit, OnDestroy { * @param event */ pageChanged(event: any): void { - this.isSearching = true; + this.isSearching = true - this.currentPage = event.page; + this.currentPage = event.page if (this.tab === 'own') { - this.getVms(); + this.getVms() } else if (this.tab === 'all') { - this.getAllVms(); + this.getAllVms() } else if (this.tab === 'facility') { - this.getAllVmsFacilities(); + this.getAllVmsFacilities() } } @@ -310,34 +308,34 @@ export class VmOverviewComponent implements OnInit, OnDestroy { this.filter, this.filter_status_list, this.filter_cluster, - this.filter_set_for_termination, + this.filter_set_for_termination ) .subscribe((vm_page: VirtualMachinePage): void => { - this.vm_page = vm_page; - this.generateMigratedProjectIdList(); - this.generateMigratedProjectNamesList(); - this.prepareVMS(); - }), - ); + this.vm_page = vm_page + this.generateMigratedProjectIdList() + this.generateMigratedProjectNamesList() + this.prepareVMS() + }) + ) } generateMigratedProjectIdList(): void { - this.migratedProjectIds = []; + this.migratedProjectIds = [] this.vm_page.vm_list.forEach((vm: VirtualMachine) => { if (vm.migrate_project_to_simple_vm || vm.project_is_migrated_to_simple_vm) { - this.migratedProjectIds.push(vm.projectid.toString()); + this.migratedProjectIds.push(vm.projectid.toString()) } - const unique = (arr: string[]): string[] => [...new Set(arr)]; - this.migratedProjectIds = unique(this.migratedProjectIds); - }); + const unique = (arr: string[]): string[] => [...new Set(arr)] + this.migratedProjectIds = unique(this.migratedProjectIds) + }) } generateMigratedProjectNamesList(): void { - this.migratedProjectNames = []; + this.migratedProjectNames = [] this.vm_page.vm_list.forEach((vm: VirtualMachine) => { if (vm.migrate_project_to_simple_vm || vm.project_is_migrated_to_simple_vm) { - this.migratedProjectNames.push(vm.project); + this.migratedProjectNames.push(vm.project) } - }); + }) } /** @@ -353,13 +351,13 @@ export class VmOverviewComponent implements OnInit, OnDestroy { this.filter, this.filter_status_list, this.filter_cluster, - this.filter_set_for_termination, + this.filter_set_for_termination ) .subscribe((vm_page: VirtualMachinePage): void => { - this.vm_page = vm_page; - this.prepareVMS(); - }), - ); + this.vm_page = vm_page + this.prepareVMS() + }) + ) } /** @@ -368,29 +366,29 @@ export class VmOverviewComponent implements OnInit, OnDestroy { checkVMAdminState(): void { this.subscription.add( this.userService.getMemberByUser().subscribe((res: any): void => { - this.user_perun_id = res['userId']; + this.user_perun_id = res['userId'] this.vm_page.vm_list.forEach((vm: VirtualMachine): void => { this.subscription.add( this.groupService.isLoggedUserGroupAdmin(vm.projectid).subscribe((result): any => { if (result['admin']) { - this.vms_admin.push(vm.openstackid); + this.vms_admin.push(vm.openstackid) } - }), - ); - }); - }), - ); + }) + ) + }) + }) + ) } /** * Prepare to show vms. */ prepareVMS(): void { - this.checkVMAdminState(); + this.checkVMAdminState() this.children.forEach((child: VmCardComponent) => { - child.restartAndResumeCheckStatusTimer(); - }); - this.isSearching = false; + child.restartAndResumeCheckStatusTimer() + }) + this.isSearching = false } /** @@ -405,23 +403,23 @@ export class VmOverviewComponent implements OnInit, OnDestroy { this.filter, this.filter_status_list, this.filter_cluster, - this.filter_set_for_termination, + this.filter_set_for_termination ) .subscribe((vm_page: VirtualMachinePage): void => { - this.vm_page = vm_page; - this.prepareVMS(); - }), - ); + this.vm_page = vm_page + this.prepareVMS() + }) + ) } /** * Called if 'Select all' is toggled. Will call a function of every child vm card with value of 'Select all'. */ toggleAllChecked(): void { - this.all_checked = !this.all_checked; + this.all_checked = !this.all_checked this.children.forEach((child: VmCardComponent) => { - child.toggleAllChecked(this.all_checked); - }); + child.toggleAllChecked(this.all_checked) + }) } /** @@ -429,13 +427,13 @@ export class VmOverviewComponent implements OnInit, OnDestroy { * vm cards for their checked values. */ childChecked(): void { - let total: number = 0; - let total_child_checked: number = 0; + let total: number = 0 + let total_child_checked: number = 0 this.children.forEach((child: VmCardComponent) => { - total += child.is_checkable(); - total_child_checked += child.vm_is_checked(); - }); - this.all_checked = total_child_checked === total; + total += child.is_checkable() + total_child_checked += child.vm_is_checked() + }) + this.all_checked = total_child_checked === total } /** @@ -443,23 +441,23 @@ export class VmOverviewComponent implements OnInit, OnDestroy { */ deleteAllCheckedVms(): void { this.selectedMachines.forEach((child: VmCardComponent) => { - child.deleteVM(); - }); + child.deleteVM() + }) } /** * Gather all vms which are checked. */ gatherAllSelectedVMs(): void { - this.selectedMachines = []; - this.otherSelectedMachines = []; + this.selectedMachines = [] + this.otherSelectedMachines = [] this.children.forEach((child: VmCardComponent) => { if (child.is_checked) { if (this.user_elixir_id !== child.vm.elixir_id) { - this.otherSelectedMachines.push(child); + this.otherSelectedMachines.push(child) } - this.selectedMachines.push(child); + this.selectedMachines.push(child) } - }); + }) } } diff --git a/src/app/virtualmachines/vm_routing.module.ts b/src/app/virtualmachines/vm_routing.module.ts index fd4acaa3f9..11423d3c6d 100644 --- a/src/app/virtualmachines/vm_routing.module.ts +++ b/src/app/virtualmachines/vm_routing.module.ts @@ -1,104 +1,94 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { VirtualMachineComponent } from './addvm.component'; -import { VmOverviewComponent } from './vmOverview.component'; -import { VolumeOverviewComponent } from './volumes/volumeOverview.component'; -import { SnapshotOverviewComponent } from './snapshots/snapshotOverview.component'; -import { VmDetailComponent } from './vmdetail/vmdetail.component'; -import { AddClusterComponent } from './clusters/add-cluster/add-cluster.component'; -import { ClusterdetailComponent } from './clusters/clusterdetail/clusterdetail.component'; -import { ClusterOverviewComponent } from './clusters/clusteroverview/clusterOverview.component'; -import { AddWorkshopComponent } from './workshop/add-workshop/add-workshop.component'; -import { WorkshopOverviewComponent } from './workshop/workshop-overview/workshop-overview.component'; +import { NgModule } from '@angular/core' +import { RouterModule, Routes } from '@angular/router' +import { VirtualMachineComponent } from './addvm.component' +import { VmOverviewComponent } from './vmOverview.component' +import { VolumeOverviewComponent } from './volumes/volumeOverview.component' +import { SnapshotOverviewComponent } from './snapshots/snapshotOverview.component' +import { VmDetailComponent } from './vmdetail/vmdetail.component' +import { AddClusterComponent } from './clusters/add-cluster/add-cluster.component' +import { ClusterdetailComponent } from './clusters/clusterdetail/clusterdetail.component' +import { ClusterOverviewComponent } from './clusters/clusteroverview/clusterOverview.component' +import { AddWorkshopComponent } from './workshop/add-workshop/add-workshop.component' +import { WorkshopOverviewComponent } from './workshop/workshop-overview/workshop-overview.component' const routes: Routes = [ { path: 'newVM', component: VirtualMachineComponent, data: { - title: 'New Instance', - }, - + title: 'New Instance' + } }, { path: 'newCluster', component: AddClusterComponent, data: { - title: 'New Cluster', - }, - + title: 'New Cluster' + } }, { path: 'newWorkshop', component: AddWorkshopComponent, data: { - title: 'New Workshop VMs', - }, - + title: 'New Workshop VMs' + } }, { path: 'vmOverview', component: VmOverviewComponent, data: { - title: 'VM Overview', - }, - + title: 'VM Overview' + } }, { path: 'workshopOverview', component: WorkshopOverviewComponent, data: { - title: 'Workshop management', - }, - + title: 'Workshop management' + } }, { path: 'clusterOverview', component: ClusterOverviewComponent, data: { - title: 'Cluster Overview', - }, - + title: 'Cluster Overview' + } }, { path: 'cluster/:id', component: ClusterdetailComponent, data: { - title: 'Cluster Detail', - }, + title: 'Cluster Detail' + } }, { path: 'detail/:id', component: VmDetailComponent, data: { - title: 'VM Detail', - }, - + title: 'VM Detail' + } }, { path: 'volumeOverview', component: VolumeOverviewComponent, data: { - title: 'Volumes Overview', - }, - + title: 'Volumes Overview' + } }, { path: 'snapshotOverview', component: SnapshotOverviewComponent, data: { - title: 'Snapshots Overview', - }, - - }, -]; + title: 'Snapshots Overview' + } + } +] /** * Vm routing module. */ @NgModule({ imports: [RouterModule.forChild(routes)], - exports: [RouterModule], + exports: [RouterModule] }) -export class VmRoutingModule { -} +export class VmRoutingModule {} diff --git a/src/app/virtualmachines/vmcard/vmcard.component.ts b/src/app/virtualmachines/vmcard/vmcard.component.ts index 2a3884fb54..a6b5c2e7c1 100644 --- a/src/app/virtualmachines/vmcard/vmcard.component.ts +++ b/src/app/virtualmachines/vmcard/vmcard.component.ts @@ -1,31 +1,29 @@ -import { - Component, Input, Output, EventEmitter, OnDestroy, OnInit, -} from '@angular/core'; -import { ClipboardService } from 'ngx-clipboard'; -import { Subscription } from 'rxjs'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { VirtualMachine } from '../virtualmachinemodels/virtualmachine'; -import { VirtualMachineStates } from '../virtualmachinemodels/virtualmachinestates'; +import { Component, Input, Output, EventEmitter, OnDestroy, OnInit } from '@angular/core' +import { ClipboardService } from 'ngx-clipboard' +import { Subscription } from 'rxjs' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { VirtualMachine } from '../virtualmachinemodels/virtualmachine' +import { VirtualMachineStates } from '../virtualmachinemodels/virtualmachinestates' import { WIKI_GUACAMOLE_LINK, WIKI_RSTUDIO_LINK, WIKI_PERSISTENT_TERMINAL_LINK, WIKI_JUPYTERLAB_LINK, - NEW_SVM_PORTAL_LINK, -} from '../../../links/links'; -import { TemplateNames } from '../conda/template-names'; -import { StopVmComponent } from '../modals/stop-vm/stop-vm.component'; -import { VirtualmachineService } from '../../api-connector/virtualmachine.service'; -import { ResumeVmComponent } from '../modals/resume-vm/resume-vm.component'; -import { DeleteVmComponent } from '../modals/delete-vm/delete-vm.component'; -import { SnapshotModel } from '../snapshots/snapshot.model'; -import { ImageService } from '../../api-connector/image.service'; -import { SnapshotVmComponent } from '../modals/snapshot-vm/snapshot-vm.component'; -import { VolumeVmComponent } from '../modals/volume-vm/volume-vm.component'; -import { Volume } from '../volumes/volume'; -import { IResponseTemplate } from '../../api-connector/response-template'; -import { RebootVmComponent } from '../modals/reboot-vm/reboot-vm.component'; -import { RecreateBackendVmComponent } from '../modals/recreate-backend-vm/recreate-backend-vm.component'; + NEW_SVM_PORTAL_LINK +} from '../../../links/links' +import { TemplateNames } from '../conda/template-names' +import { StopVmComponent } from '../modals/stop-vm/stop-vm.component' +import { VirtualmachineService } from '../../api-connector/virtualmachine.service' +import { ResumeVmComponent } from '../modals/resume-vm/resume-vm.component' +import { DeleteVmComponent } from '../modals/delete-vm/delete-vm.component' +import { SnapshotModel } from '../snapshots/snapshot.model' +import { ImageService } from '../../api-connector/image.service' +import { SnapshotVmComponent } from '../modals/snapshot-vm/snapshot-vm.component' +import { VolumeVmComponent } from '../modals/volume-vm/volume-vm.component' +import { Volume } from '../volumes/volume' +import { IResponseTemplate } from '../../api-connector/response-template' +import { RebootVmComponent } from '../modals/reboot-vm/reboot-vm.component' +import { RecreateBackendVmComponent } from '../modals/recreate-backend-vm/recreate-backend-vm.component' /** * Vm card component to be used by vm-overview. Holds information about a virtual machine. @@ -34,145 +32,147 @@ import { RecreateBackendVmComponent } from '../modals/recreate-backend-vm/recrea selector: 'app-vm-card', templateUrl: 'vmcard.component.html', styleUrls: ['./vmcard.component.scss'], - providers: [ImageService], + providers: [ImageService] }) export class VmCardComponent implements OnInit, OnDestroy { /** * The virtual machine this card is for. */ - @Input() vm: VirtualMachine; + @Input() vm: VirtualMachine /** * Possible virtual machine states. */ - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() /** * Is the vm checked. */ - is_checked: boolean = false; + is_checked: boolean = false /** * Eventemitter when the vm is checked/unchecked. */ - @Output() check_change_event: EventEmitter = new EventEmitter(); + @Output() check_change_event: EventEmitter = new EventEmitter() /** * Elixir id of the user. */ - @Input() user_elixir_id: string = ''; + @Input() user_elixir_id: string = '' /** * If the user is a vo admin. */ - @Input() is_vo_admin: boolean = false; + @Input() is_vo_admin: boolean = false /** * If the user is an admin of the group the vm belongs to. */ - @Input() is_vm_admin: boolean = false; + @Input() is_vm_admin: boolean = false /** * Link to rstudio wiki */ - WIKI_RSTUDIO_LINK: string = WIKI_RSTUDIO_LINK; - WIKI_JUPYTERLAB_LINK: string = WIKI_JUPYTERLAB_LINK; + WIKI_RSTUDIO_LINK: string = WIKI_RSTUDIO_LINK + WIKI_JUPYTERLAB_LINK: string = WIKI_JUPYTERLAB_LINK /** * Link to guacamole wiki. */ - WIKI_GUACAMOLE_LINK: string = WIKI_GUACAMOLE_LINK; + WIKI_GUACAMOLE_LINK: string = WIKI_GUACAMOLE_LINK /** * Link to persistent terminal sessions tutorial. */ - WIKI_PERSISTENT_TERMINAL_LINK: string = WIKI_PERSISTENT_TERMINAL_LINK; + WIKI_PERSISTENT_TERMINAL_LINK: string = WIKI_PERSISTENT_TERMINAL_LINK /** * Subscription object to listen to different events. */ - subscription: Subscription = new Subscription(); + subscription: Subscription = new Subscription() /** * Modal reference to be changed/showed/hidden depending on chosen modal. */ - bsModalRef: BsModalRef; + bsModalRef: BsModalRef /** * Default wait time between status checks if no other value specified. * @private */ - private checkStatusTimeout: number = 5000; + private checkStatusTimeout: number = 5000 /** * Default time in ms to show an error message if no other value specified. */ - ERROR_TIMER: number = 10000; + ERROR_TIMER: number = 10000 /** * Error message to show if 409 status was returned, typically returned if vm is creating a snapshot. */ - SNAPSHOT_CREATING_ERROR_MSG: string = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; + SNAPSHOT_CREATING_ERROR_MSG: string = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' /** Error message to when reboot failed * */ - REBOOT_ERROR_MSG: string = 'Reboot of machine failed. If the error persists, please contact the support.'; + REBOOT_ERROR_MSG: string = 'Reboot of machine failed. If the error persists, please contact the support.' /** * Timeout object to control check status loop (i.e. stopping and starting check status loop). */ - checkStatusTimer: ReturnType; + checkStatusTimer: ReturnType /** * Constant message for connection issues with client/OpenStack to ensure that the user knows that the information may not be up-to-date. */ - TIMEOUT_ALERT_MESSAGE: string = 'The information available here may not be up-to-date. This is due to connection problems with the compute center. If necessary, try again later.'; + TIMEOUT_ALERT_MESSAGE: string = + 'The information available here may not be up-to-date. This is due to connection problems with the compute center. If necessary, try again later.' /** * String which can be filled with information in case any problems occur or additional information needs to be placed. */ - alertMessage: string = ''; + alertMessage: string = '' /** * Bool which indicates whether the alert with additional information is shown or not. */ - alertVisible: boolean = false; + alertVisible: boolean = false constructor( private clipboardService: ClipboardService, private modalService: BsModalService, private virtualmachineservice: VirtualmachineService, - private imageService: ImageService, + private imageService: ImageService ) { - // eslint-disable-next-line no-empty-function + } ngOnInit() { - this.resumeCheckStatusTimer(); + this.resumeCheckStatusTimer() } ngOnDestroy() { - this.subscription.unsubscribe(); - this.stopCheckStatusTimer(); + this.subscription.unsubscribe() + this.stopCheckStatusTimer() } /** * Start the check status loop without arguments. */ resumeCheckStatusTimer(): void { - this.check_status_loop(); + this.check_status_loop() } /** * Stop and clear the check status loop. Then resume it with a value between 1 second and 3 seconds. */ restartAndResumeCheckStatusTimer(): void { - this.stopCheckStatusTimer(); + this.stopCheckStatusTimer() // so not all requests are at the same time for the vms - const min: number = 1000; - const max: number = 3000; - this.check_status_loop(null, Math.floor(Math.random() * (max - min)) + min); + const min: number = 1000 + const max: number = 3000 + this.check_status_loop(null, Math.floor(Math.random() * (max - min)) + min) } /** @@ -180,7 +180,7 @@ export class VmCardComponent implements OnInit, OnDestroy { */ stopCheckStatusTimer(): void { if (this.checkStatusTimer) { - clearTimeout(this.checkStatusTimer); + clearTimeout(this.checkStatusTimer) } } @@ -188,26 +188,26 @@ export class VmCardComponent implements OnInit, OnDestroy { * Show stop modal. */ showStopModal(): void { - this.stopCheckStatusTimer(); - const initialState = { virtualMachine: this.vm }; + this.stopCheckStatusTimer() + const initialState = { virtualMachine: this.vm } - this.bsModalRef = this.modalService.show(StopVmComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(StopVmComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } recreateBackend(): void { this.subscription.add( this.virtualmachineservice.recreateVmBackend(this.vm.openstackid).subscribe( (updated_vm: VirtualMachine) => { - this.vm.backend = updated_vm.backend; - this.vm.setMsgWithTimeout('Backend was successfully recreated!'); + this.vm.backend = updated_vm.backend + this.vm.setMsgWithTimeout('Backend was successfully recreated!') }, () => { - this.vm.setErrorMsgWithTimeout('Failed to recreate the backend!', this.ERROR_TIMER); - }, - ), - ); + this.vm.setErrorMsgWithTimeout('Failed to recreate the backend!', this.ERROR_TIMER) + } + ) + ) } /** @@ -217,109 +217,109 @@ export class VmCardComponent implements OnInit, OnDestroy { this.subscription.add( this.virtualmachineservice.stopVM(this.vm.openstackid).subscribe( (updated_vm: VirtualMachine): void => { - updated_vm.cardState = 0; - this.vm = updated_vm; + updated_vm.cardState = 0 + this.vm = updated_vm if (this.vm.status === VirtualMachineStates.SHUTOFF) { - this.resumeCheckStatusTimer(); + this.resumeCheckStatusTimer() } else { - this.check_status_loop(VirtualMachineStates.SHUTOFF); + this.check_status_loop(VirtualMachineStates.SHUTOFF) } }, (error1: any): void => { if (error1['error']['error'] === '409') { - this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER); - this.resumeCheckStatusTimer(); + this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER) + this.resumeCheckStatusTimer() } - }, - ), - ); + } + ) + ) } /** * Show attach/detach modal. */ showVolumeModal(mode: string): void { - this.stopCheckStatusTimer(); - const initialState = { virtualMachine: this.vm, mode }; + this.stopCheckStatusTimer() + const initialState = { virtualMachine: this.vm, mode } - this.bsModalRef = this.modalService.show(VolumeVmComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(VolumeVmComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } /** * Show attach/detach modal. */ showRecreateBackendModal(): void { - this.stopCheckStatusTimer(); - const initialState = { virtualMachine: this.vm }; + this.stopCheckStatusTimer() + const initialState = { virtualMachine: this.vm } - this.bsModalRef = this.modalService.show(RecreateBackendVmComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(RecreateBackendVmComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } /** * Run function to attach a volume to a vm. */ attachVolume(volume: Volume): void { - this.vm.status = VirtualMachineStates.GETTING_STATUS; + this.vm.status = VirtualMachineStates.GETTING_STATUS this.subscription.add( this.virtualmachineservice.attachVolumetoServer(volume.volume_openstackid, this.vm.openstackid).subscribe( (result: IResponseTemplate): void => { if (result.value === 'attached') { - this.vm.setMsgWithTimeout('Volume attached'); - this.check_status_loop(null, 1000); + this.vm.setMsgWithTimeout('Volume attached') + this.check_status_loop(null, 1000) } else { - this.vm.setErrorMsgWithTimeout('Volume not attached'); - this.resumeCheckStatusTimer(); + this.vm.setErrorMsgWithTimeout('Volume not attached') + this.resumeCheckStatusTimer() } }, (error1: any): void => { if (error1['error']['error'] === '409') { - this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER); - this.resumeCheckStatusTimer(); + this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER) + this.resumeCheckStatusTimer() } - }, - ), - ); + } + ) + ) } /** * Run function to detach a volume from a vm. */ detachVolume(volume: Volume): void { - this.vm.status = VirtualMachineStates.GETTING_STATUS; + this.vm.status = VirtualMachineStates.GETTING_STATUS this.subscription.add( this.virtualmachineservice.deleteVolumeAttachment(volume.volume_openstackid, this.vm.openstackid).subscribe( (result: any): void => { if (result.value === 'deleted') { - this.vm.setMsgWithTimeout('Volume detached'); - this.check_status_loop(null, 1000); + this.vm.setMsgWithTimeout('Volume detached') + this.check_status_loop(null, 1000) } else { - this.vm.setErrorMsgWithTimeout('Volume not detached'); - this.resumeCheckStatusTimer(); + this.vm.setErrorMsgWithTimeout('Volume not detached') + this.resumeCheckStatusTimer() } }, (error1: any): void => { if (error1['error']['error'] === '409') { - this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER); + this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER) } - }, - ), - ); + } + ) + ) } /** * Show resume/restart modal. */ showRestartModal(): void { - this.stopCheckStatusTimer(); - const initialState = { virtualMachine: this.vm }; + this.stopCheckStatusTimer() + const initialState = { virtualMachine: this.vm } - this.bsModalRef = this.modalService.show(ResumeVmComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(ResumeVmComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } /** @@ -329,144 +329,144 @@ export class VmCardComponent implements OnInit, OnDestroy { this.subscription.add( this.virtualmachineservice.resumeVM(this.vm.openstackid).subscribe( (updated_vm: VirtualMachine): void => { - updated_vm.cardState = 0; - this.vm = updated_vm; + updated_vm.cardState = 0 + this.vm = updated_vm if (this.vm.status === VirtualMachineStates.ACTIVE) { - this.resumeCheckStatusTimer(); + this.resumeCheckStatusTimer() } else { - this.check_status_loop(VirtualMachineStates.ACTIVE); + this.check_status_loop(VirtualMachineStates.ACTIVE) } }, (error1: any): void => { if (error1['error']['error'] === '409') { - this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER); - this.resumeCheckStatusTimer(); + this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER) + this.resumeCheckStatusTimer() } - }, - ), - ); + } + ) + ) } /** * Show hard/soft reboot modal. */ showRebootModal(): void { - this.stopCheckStatusTimer(); - const initialState = { virtualMachine: this.vm }; + this.stopCheckStatusTimer() + const initialState = { virtualMachine: this.vm } - this.bsModalRef = this.modalService.show(RebootVmComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(RebootVmComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } /** * Run function to soft/hard reboot a vm. */ rebootVM(reboot_type: string): void { - this.vm.status = VirtualMachineStates.GETTING_STATUS; + this.vm.status = VirtualMachineStates.GETTING_STATUS this.subscription.add( this.virtualmachineservice.rebootVM(this.vm.openstackid, reboot_type).subscribe( (result: IResponseTemplate): void => { - this.vm.cardState = 0; + this.vm.cardState = 0 if (result.value as boolean) { - this.vm.setMsgWithTimeout('Reboot initiated', 5000); - this.resumeCheckStatusTimer(); + this.vm.setMsgWithTimeout('Reboot initiated', 5000) + this.resumeCheckStatusTimer() } else { - this.check_status_loop(VirtualMachineStates.ACTIVE); + this.check_status_loop(VirtualMachineStates.ACTIVE) } }, (error1: any): void => { if (error1['error']['error'] === '409') { - this.vm.setErrorMsgWithTimeout(this.REBOOT_ERROR_MSG, this.ERROR_TIMER); + this.vm.setErrorMsgWithTimeout(this.REBOOT_ERROR_MSG, this.ERROR_TIMER) } - }, - ), - ); + } + ) + ) } /** * Show snapshot modal. */ showSnapshotModal(): void { - this.stopCheckStatusTimer(); - const initialState = { virtualMachine: this.vm }; + this.stopCheckStatusTimer() + const initialState = { virtualMachine: this.vm } - this.bsModalRef = this.modalService.show(SnapshotVmComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(SnapshotVmComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } /** * Run function to create a snapshot of a vm. */ createSnapshot(snapshot_name: string, description?: string): void { - this.vm.setMsgWithTimeout('Queuing Snapshot...'); - const final_state: string = this.vm.status; - this.vm.status = VirtualMachineStates.IMAGE_PENDING_UPLOAD; + this.vm.setMsgWithTimeout('Queuing Snapshot...') + const final_state: string = this.vm.status + this.vm.status = VirtualMachineStates.IMAGE_PENDING_UPLOAD this.subscription.add( this.imageService.createSnapshot(this.vm.openstackid, snapshot_name.trim(), description).subscribe( (newSnapshot: SnapshotModel): void => { if (!newSnapshot.snapshot_openstackid) { - this.vm.setErrorMsgWithTimeout('Error creating Snapshot', this.ERROR_TIMER); + this.vm.setErrorMsgWithTimeout('Error creating Snapshot', this.ERROR_TIMER) } else { const text: string = `Successfully queued Snapshot.
It might take some minutes till you can use it for starting a new instance at the "New Instance" tab.
You can see the current status in the Snapshot Overview.`; - this.vm.setMsgWithTimeout(text, 30000); + [routerLink]="['/virtualmachines/snapshotOverview']">Snapshot Overview.` + this.vm.setMsgWithTimeout(text, 30000) } - this.check_status_loop(final_state, 15000); + this.check_status_loop(final_state, 15000) }, (error1: any): void => { if (error1['error']['error'] === '409') { - this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER); - this.resumeCheckStatusTimer(); + this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER) + this.resumeCheckStatusTimer() } - }, - ), - ); + } + ) + ) } /** * Show deletion modal */ showDeleteModal(): void { - this.stopCheckStatusTimer(); - const initialState = { virtualMachine: this.vm }; + this.stopCheckStatusTimer() + const initialState = { virtualMachine: this.vm } - this.bsModalRef = this.modalService.show(DeleteVmComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(DeleteVmComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } /** * Run function to delete a vm. */ deleteVM(): void { - this.is_checked = false; - this.vm.status = VirtualMachineStates.DELETING; - this.vm.cardState = 0; + this.is_checked = false + this.vm.status = VirtualMachineStates.DELETING + this.vm.cardState = 0 this.subscription.add( this.virtualmachineservice.deleteVM(this.vm.openstackid).subscribe( (updated_vm: VirtualMachine): void => { - updated_vm.cardState = 0; + updated_vm.cardState = 0 if (updated_vm.status !== VirtualMachineStates.DELETED) { setTimeout((): void => { - this.deleteVM(); - }, this.checkStatusTimeout); + this.deleteVM() + }, this.checkStatusTimeout) } else { - this.stopCheckStatusTimer(); - this.vm = updated_vm; + this.stopCheckStatusTimer() + this.vm = updated_vm } }, (error1: any): void => { if (error1['status'] === 409) { - this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER); + this.vm.setErrorMsgWithTimeout(this.SNAPSHOT_CREATING_ERROR_MSG, this.ERROR_TIMER) } - }, - ), - ); + } + ) + ) } /** @@ -476,95 +476,95 @@ export class VmCardComponent implements OnInit, OnDestroy { this.subscription.add( this.bsModalRef.content.event.subscribe((result: any) => { if ('recreateBackendVM' in result) { - this.recreateBackend(); + this.recreateBackend() } else if ('resume' in result) { - this.resumeCheckStatusTimer(); + this.resumeCheckStatusTimer() } else if ('stopVM' in result) { - this.stopVM(); + this.stopVM() } else if ('resumeVM' in result) { - this.resumeVM(); + this.resumeVM() } else if ('deleteVM' in result) { - this.deleteVM(); + this.deleteVM() } else if ('snapshotVM' in result) { - this.createSnapshot(result['snapshotName'], result['description']); + this.createSnapshot(result['snapshotName'], result['description']) } else if ('attachVolume' in result) { - this.attachVolume(result['volume']); + this.attachVolume(result['volume']) } else if ('detachVolume' in result) { - this.detachVolume(result['volume']); + this.detachVolume(result['volume']) } else if ('reboot_type' in result) { - this.rebootVM(result['reboot_type']); + this.rebootVM(result['reboot_type']) } - }), - ); + }) + ) } showAlert(message: string): void { switch (message) { case 'TIMEOUT': - this.alertMessage = this.TIMEOUT_ALERT_MESSAGE; - break; + this.alertMessage = this.TIMEOUT_ALERT_MESSAGE + break default: - this.alertMessage = ''; + this.alertMessage = '' } - this.alertVisible = true; + this.alertVisible = true } /** * Loop which checks status of a vm depending on its status. Will always stop the timer if it exists first. */ check_status_loop(final_state?: string, timeout: number = this.checkStatusTimeout): void { - this.stopCheckStatusTimer(); + this.stopCheckStatusTimer() this.checkStatusTimer = setTimeout((): void => { this.subscription.add( this.virtualmachineservice .checkVmStatus(this.vm.openstackid, this.vm.name) .subscribe((updated_vm: VirtualMachine): void => { - updated_vm.cardState = this.vm.cardState; + updated_vm.cardState = this.vm.cardState if (this.vm.msg) { - updated_vm.setMsgWithTimeout(this.vm.msg); + updated_vm.setMsgWithTimeout(this.vm.msg) } if (this.vm.error_msg) { - updated_vm.setErrorMsgWithTimeout(this.vm.error_msg); + updated_vm.setErrorMsgWithTimeout(this.vm.error_msg) } - this.vm = updated_vm; + this.vm = updated_vm if (this.vm.status === VirtualMachineStates.ACTIVE) { if (this.vm.volumes?.length > 0) { - const volumeIds: string[] = []; + const volumeIds: string[] = [] for (const vol of this.vm.volumes) { - volumeIds.push(vol.volume_openstackid); + volumeIds.push(vol.volume_openstackid) } this.virtualmachineservice.triggerVolumeUpdate(volumeIds).subscribe( (): void => { - this.alertVisible = false; + this.alertVisible = false }, (error: Response): void => { if (error.status === 408) { // timeout for request - this.showAlert('TIMEOUT'); + this.showAlert('TIMEOUT') } - }, - ); + } + ) } } if (final_state) { if (final_state === this.vm.status) { - this.resumeCheckStatusTimer(); + this.resumeCheckStatusTimer() } else { - this.check_status_loop(final_state); + this.check_status_loop(final_state) } } else if (VirtualMachineStates.IN_PROCESS_STATES.indexOf(this.vm.status) !== -1) { - this.check_status_loop(); + this.check_status_loop() } else if (this.vm.status === VirtualMachineStates.MIGRATED) { - this.stopCheckStatusTimer(); + this.stopCheckStatusTimer() } else if (this.vm.status !== VirtualMachineStates.DELETED) { // so not all requests are at the same time for the vms - const min: number = 20000; - const max: number = 40000; - this.check_status_loop(null, Math.floor(Math.random() * (max - min)) + max); + const min: number = 20000 + const max: number = 40000 + this.check_status_loop(null, Math.floor(Math.random() * (max - min)) + max) } - }), - ); - }, timeout); + }) + ) + }, timeout) } /** @@ -572,12 +572,12 @@ export class VmCardComponent implements OnInit, OnDestroy { */ toggleAllChecked(all_checked: boolean): void { if ( - (this.vm.status === VirtualMachineStates.ACTIVE || this.vm.status === VirtualMachineStates.SHUTOFF) - && !(this.vm.project_is_migrated_to_simple_vm || this.vm.migrate_project_to_simple_vm) + (this.vm.status === VirtualMachineStates.ACTIVE || this.vm.status === VirtualMachineStates.SHUTOFF) && + !(this.vm.project_is_migrated_to_simple_vm || this.vm.migrate_project_to_simple_vm) ) { - this.is_checked = all_checked; + this.is_checked = all_checked } else { - this.is_checked = false; + this.is_checked = false } } @@ -585,11 +585,11 @@ export class VmCardComponent implements OnInit, OnDestroy { * Toggle checked status and notify parent. */ toggleChecked(): void { - this.is_checked = !this.is_checked; + this.is_checked = !this.is_checked if (this.is_checked) { - this.check_change_event.emit(1); + this.check_change_event.emit(1) } else { - this.check_change_event.emit(-1); + this.check_change_event.emit(-1) } } @@ -598,9 +598,9 @@ export class VmCardComponent implements OnInit, OnDestroy { */ is_checkable(): number { if (this.vm.status === VirtualMachineStates.ACTIVE || this.vm.status === VirtualMachineStates.SHUTOFF) { - return 1; + return 1 } else { - return -1; + return -1 } } @@ -609,12 +609,12 @@ export class VmCardComponent implements OnInit, OnDestroy { */ vm_is_checked(): number { if ( - (this.vm.status === VirtualMachineStates.ACTIVE || this.vm.status === VirtualMachineStates.SHUTOFF) - && this.is_checked + (this.vm.status === VirtualMachineStates.ACTIVE || this.vm.status === VirtualMachineStates.SHUTOFF) && + this.is_checked ) { - return 1; + return 1 } else { - return -1; + return -1 } } @@ -623,7 +623,7 @@ export class VmCardComponent implements OnInit, OnDestroy { */ copyToClipboard(text: string): void { if (this.clipboardService.isSupported) { - this.clipboardService.copy(text); + this.clipboardService.copy(text) } } @@ -631,12 +631,12 @@ export class VmCardComponent implements OnInit, OnDestroy { * Show message in span that text was copied. */ showCopiedMessage(name: string): void { - const span_id: string = `${name}resenvSpan`; - const { innerHTML } = document.getElementById(span_id); - document.getElementById(span_id).innerHTML = 'Copied URL!'; + const span_id: string = `${name}resenvSpan` + const { innerHTML } = document.getElementById(span_id) + document.getElementById(span_id).innerHTML = 'Copied URL!' setTimeout((): void => { - document.getElementById(span_id).innerHTML = innerHTML; - }, 1000); + document.getElementById(span_id).innerHTML = innerHTML + }, 1000) } /** @@ -645,12 +645,12 @@ export class VmCardComponent implements OnInit, OnDestroy { resenv_by_play(vm: VirtualMachine): boolean { for (const mode of vm.modes) { if (TemplateNames.ALL_TEMPLATE_NAMES.indexOf(mode.name) !== -1) { - return false; + return false } } - return true; + return true } - protected readonly NEW_SVM_PORTAL_LINK = NEW_SVM_PORTAL_LINK; + protected readonly NEW_SVM_PORTAL_LINK = NEW_SVM_PORTAL_LINK } diff --git a/src/app/virtualmachines/vmdetail/virtualmachineinfo/virtualmachineinfo.component.ts b/src/app/virtualmachines/vmdetail/virtualmachineinfo/virtualmachineinfo.component.ts index 83ff113828..73243b4c43 100644 --- a/src/app/virtualmachines/vmdetail/virtualmachineinfo/virtualmachineinfo.component.ts +++ b/src/app/virtualmachines/vmdetail/virtualmachineinfo/virtualmachineinfo.component.ts @@ -1,9 +1,7 @@ -import { - Component, Input, OnChanges, SimpleChanges, OnInit, ChangeDetectorRef, -} from '@angular/core'; -import { UserService } from 'app/api-connector/user.service'; -import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates'; -import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine'; +import { Component, Input, OnChanges, SimpleChanges, OnInit, ChangeDetectorRef } from '@angular/core' +import { UserService } from 'app/api-connector/user.service' +import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates' +import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine' /** * Virtualmachine info component @@ -13,22 +11,22 @@ import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine'; templateUrl: './virtualmachineinfo.component.html', styleUrls: ['./virtualmachineinfo.component.scss'], - providers: [UserService], + providers: [UserService] }) export class VirtualmachineinfoComponent implements OnChanges, OnInit { - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); - @Input() virtualMachine: VirtualMachine; - @Input() cluster_machine: boolean = false; + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() + @Input() virtualMachine: VirtualMachine + @Input() cluster_machine: boolean = false - userName: string = ''; - userSurname: string = ''; + userName: string = '' + userSurname: string = '' constructor( private userService: UserService, - private changeDetectorRef: ChangeDetectorRef, + private changeDetectorRef: ChangeDetectorRef ) { - this.userService = userService; - this.changeDetectorRef = changeDetectorRef; + this.userService = userService + this.changeDetectorRef = changeDetectorRef } ngOnInit(): void { @@ -37,26 +35,26 @@ export class VirtualmachineinfoComponent implements OnChanges, OnInit { this.userService .getMemberDetailsByElixirId(this.virtualMachine.still_used_confirmed_user_id) .subscribe((result: any) => { - this.userName = result['firstName']; - this.userSurname = result['lastName']; - this.changeDetectorRef.detectChanges(); - }); + this.userName = result['firstName'] + this.userSurname = result['lastName'] + this.changeDetectorRef.detectChanges() + }) } } } ngOnChanges(changes: SimpleChanges): void { - const { changedVM } = changes; - console.log(changedVM); + const { changedVM } = changes + console.log(changedVM) if (changedVM) { if (changedVM['virtualMachine']['currentValue']['still_used_confirmed_user_id']) { this.userService .getMemberDetailsByElixirId(this.virtualMachine.still_used_confirmed_user_id) .subscribe((result: any) => { - this.userName = result['firstName']; - this.userSurname = result['lastName']; - this.changeDetectorRef.detectChanges(); - }); + this.userName = result['firstName'] + this.userSurname = result['lastName'] + this.changeDetectorRef.detectChanges() + }) } } } diff --git a/src/app/virtualmachines/vmdetail/vmdetail.component.ts b/src/app/virtualmachines/vmdetail/vmdetail.component.ts index 627d286a07..8b74f55a79 100644 --- a/src/app/virtualmachines/vmdetail/vmdetail.component.ts +++ b/src/app/virtualmachines/vmdetail/vmdetail.component.ts @@ -1,47 +1,45 @@ -import { - Component, OnInit, ChangeDetectorRef, inject, -} from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { Subject, Subscription } from 'rxjs'; -import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; -import { ClipboardService } from 'ngx-clipboard'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { FlavorService } from '../../api-connector/flavor.service'; -import { ApplicationsService } from '../../api-connector/applications.service'; -import { FacilityService } from '../../api-connector/facility.service'; -import { VoService } from '../../api-connector/vo.service'; -import { UserService } from '../../api-connector/user.service'; -import { GroupService } from '../../api-connector/group.service'; -import { CreditsService } from '../../api-connector/credits.service'; -import { AbstractBaseClass } from '../../shared/shared_modules/baseClass/abstract-base-class'; -import { VirtualMachine } from '../virtualmachinemodels/virtualmachine'; -import { VirtualmachineService } from '../../api-connector/virtualmachine.service'; -import { ImageService } from '../../api-connector/image.service'; -import { Image } from '../virtualmachinemodels/image'; -import { VirtualMachineStates } from '../virtualmachinemodels/virtualmachinestates'; -import { IResponseTemplate } from '../../api-connector/response-template'; -import { SnapshotModel } from '../snapshots/snapshot.model'; -import { PlaybookService } from '../../api-connector/playbook.service'; -import { BiocondaService } from '../../api-connector/bioconda.service'; -import { ResenvTemplate } from '../conda/resenvTemplate.model'; -import { elixir_id, is_vo } from '../../shared/globalvar'; +import { Component, OnInit, ChangeDetectorRef, inject } from '@angular/core' +import { ActivatedRoute, Router } from '@angular/router' +import { Subject, Subscription } from 'rxjs' +import { debounceTime, distinctUntilChanged } from 'rxjs/operators' +import { ClipboardService } from 'ngx-clipboard' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { MatomoTracker } from 'ngx-matomo-client' +import { FlavorService } from '../../api-connector/flavor.service' +import { ApplicationsService } from '../../api-connector/applications.service' +import { FacilityService } from '../../api-connector/facility.service' +import { VoService } from '../../api-connector/vo.service' +import { UserService } from '../../api-connector/user.service' +import { GroupService } from '../../api-connector/group.service' +import { CreditsService } from '../../api-connector/credits.service' +import { AbstractBaseClass } from '../../shared/shared_modules/baseClass/abstract-base-class' +import { VirtualMachine } from '../virtualmachinemodels/virtualmachine' +import { VirtualmachineService } from '../../api-connector/virtualmachine.service' +import { ImageService } from '../../api-connector/image.service' +import { Image } from '../virtualmachinemodels/image' +import { VirtualMachineStates } from '../virtualmachinemodels/virtualmachinestates' +import { IResponseTemplate } from '../../api-connector/response-template' +import { SnapshotModel } from '../snapshots/snapshot.model' +import { PlaybookService } from '../../api-connector/playbook.service' +import { BiocondaService } from '../../api-connector/bioconda.service' +import { ResenvTemplate } from '../conda/resenvTemplate.model' +import { elixir_id, is_vo } from '../../shared/globalvar' import { NEW_SVM_PORTAL_LINK, WIKI_CREATE_SNAPSHOT_LINK, WIKI_GUACAMOLE_LINK, WIKI_PERSISTENT_TERMINAL_LINK, WIKI_RSTUDIO_LINK, - WIKI_VOLUME_OVERVIEW, -} from '../../../links/links'; -import { Volume } from '../volumes/volume'; -import { VolumeStates } from '../volumes/volume_states'; -import { Condalog } from '../conda/condalog'; -import { Backend } from '../conda/backend/backend'; -import { DeleteVmComponent } from '../modals/delete-vm/delete-vm.component'; -import { TemplateNames } from '../conda/template-names'; -import { RebootVmComponent } from '../modals/reboot-vm/reboot-vm.component'; -import { NotificationModalComponent } from '../../shared/modal/notification-modal'; + WIKI_VOLUME_OVERVIEW +} from '../../../links/links' +import { Volume } from '../volumes/volume' +import { VolumeStates } from '../volumes/volume_states' +import { Condalog } from '../conda/condalog' +import { Backend } from '../conda/backend/backend' +import { DeleteVmComponent } from '../modals/delete-vm/delete-vm.component' +import { TemplateNames } from '../conda/template-names' +import { RebootVmComponent } from '../modals/reboot-vm/reboot-vm.component' +import { NotificationModalComponent } from '../../shared/modal/notification-modal' /** * VM Detail page component @@ -62,110 +60,111 @@ import { NotificationModalComponent } from '../../shared/modal/notification-moda VirtualmachineService, ImageService, PlaybookService, - BiocondaService, - ], + BiocondaService + ] }) export class VmDetailComponent extends AbstractBaseClass implements OnInit { - private readonly tracker = inject(MatomoTracker); - vm_id: string; - conda_logs: Condalog; - title: string = 'Instance Detail'; - image: Image; - VolumeStates: VolumeStates = new VolumeStates(); - virtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); - virtualMachine: VirtualMachine; - resenvTemplate: ResenvTemplate; - snapshotSearchTerm: Subject = new Subject(); - errorMessage: boolean = false; - error_msg: string = ''; - filteredMembers: any = null; - backend_users: any = []; - extendDone: boolean = false; + private readonly tracker = inject(MatomoTracker) + vm_id: string + conda_logs: Condalog + title: string = 'Instance Detail' + image: Image + VolumeStates: VolumeStates = new VolumeStates() + virtualMachineStates: VirtualMachineStates = new VirtualMachineStates() + virtualMachine: VirtualMachine + resenvTemplate: ResenvTemplate + snapshotSearchTerm: Subject = new Subject() + errorMessage: boolean = false + error_msg: string = '' + filteredMembers: any = null + backend_users: any = [] + extendDone: boolean = false VOLUME_END_STATES: string[] = [ VolumeStates.AVAILABLE, VolumeStates.NOT_FOUND, VolumeStates.IN_USE, VirtualMachineStates.DELETED, - VirtualMachineStates.DELETING_FAILED, - ]; + VirtualMachineStates.DELETING_FAILED + ] - is_vo_admin: boolean = is_vo; - WIKI_RSTUDIO_LINK: string = WIKI_RSTUDIO_LINK; - WIKI_GUACAMOLE_LINK: string = WIKI_GUACAMOLE_LINK; - WIKI_VOLUME_OVERVIEW: string = WIKI_VOLUME_OVERVIEW; - WIKI_CREATE_SNAPSHOT_LINK: string = WIKI_CREATE_SNAPSHOT_LINK; - WIKI_PERSISTENT_TERMINAL_LINK: string = WIKI_PERSISTENT_TERMINAL_LINK; - SNAPSHOT_MAX_RAM: number = SnapshotModel.MAX_RAM; + is_vo_admin: boolean = is_vo + WIKI_RSTUDIO_LINK: string = WIKI_RSTUDIO_LINK + WIKI_GUACAMOLE_LINK: string = WIKI_GUACAMOLE_LINK + WIKI_VOLUME_OVERVIEW: string = WIKI_VOLUME_OVERVIEW + WIKI_CREATE_SNAPSHOT_LINK: string = WIKI_CREATE_SNAPSHOT_LINK + WIKI_PERSISTENT_TERMINAL_LINK: string = WIKI_PERSISTENT_TERMINAL_LINK + SNAPSHOT_MAX_RAM: number = SnapshotModel.MAX_RAM - REBOOT_ERROR_MSG: string = 'Reboot of machine failed. If the error persists, please contact the support.'; + REBOOT_ERROR_MSG: string = 'Reboot of machine failed. If the error persists, please contact the support.' - DEBOUNCE_TIME: number = 300; + DEBOUNCE_TIME: number = 300 - volume_to_attach: Volume; - detached_project_volumes: Volume[] = []; - user_elixir_id: string = elixir_id; + volume_to_attach: Volume + detached_project_volumes: Volume[] = [] + user_elixir_id: string = elixir_id - is_project_admin: boolean = false; + is_project_admin: boolean = false /** * The changed status. * * @type {number} */ - status_changed: number = 0; + status_changed: number = 0 /** * Timeout for checking vm status. * * @type {number} */ - private checkStatusTimeout: number = 1500; + private checkStatusTimeout: number = 1500 - checkStatusTimer: ReturnType; + checkStatusTimer: ReturnType /** * Type of reboot HARD|SOFT. */ - reboot_type: string; + reboot_type: string /** * If an error appeared when checking vm status. */ - status_check_error: boolean; + status_check_error: boolean /** * IF reboot is done. */ - reboot_done: boolean; + reboot_done: boolean /** * If the snapshot name is valid. */ - validSnapshotNameBool: boolean; + validSnapshotNameBool: boolean /** * String if the snapshot is done. * * @type {string} */ - snapshotNameCheckDone: boolean = false; - snapshotDone: string = 'Waiting'; + snapshotNameCheckDone: boolean = false + snapshotDone: string = 'Waiting' /** * name of the snapshot. */ - snapshotName: string = ''; + snapshotName: string = '' - isMigrated: boolean = false; + isMigrated: boolean = false /** * Modal reference to be changed/showed/hidden depending on chosen modal. */ - bsModalRef: BsModalRef; + bsModalRef: BsModalRef /** * Default time in ms to show an error message if no other value specified. */ - ERROR_TIMER: number = 10000; + ERROR_TIMER: number = 10000 /** * Error message to show if 409 status was returned, typically returned if vm is creating a snapshot. */ - SNAPSHOT_CREATING_ERROR_MSG: string = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; + SNAPSHOT_CREATING_ERROR_MSG: string = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' constructor( private activatedRoute: ActivatedRoute, @@ -181,31 +180,31 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { private biocondaService: BiocondaService, private clipboardService: ClipboardService, private groupService: GroupService, - private cdr: ChangeDetectorRef, + private cdr: ChangeDetectorRef ) { - super(); + super() } getVmCondaLogs(): void { this.virtualmachineService.getCondaLogs(this.vm_id).subscribe((log: Condalog): void => { if (log) { - this.conda_logs = new Condalog(log); + this.conda_logs = new Condalog(log) } - }); + }) } ngOnInit(): void { this.activatedRoute.params.subscribe((paramsId: any): void => { - this.vm_id = paramsId.id; - this.tracker.trackPageView(`Instance Detail Page: ${paramsId.id}`); - this.getVmCondaLogs(); - this.getVmById(); + this.vm_id = paramsId.id + this.tracker.trackPageView(`Instance Detail Page: ${paramsId.id}`) + this.getVmCondaLogs() + this.getVmById() this.snapshotSearchTerm .pipe(debounceTime(this.DEBOUNCE_TIME), distinctUntilChanged()) .subscribe((event: any): void => { - this.validSnapshotName(event); - }); - }); + this.validSnapshotName(event) + }) + }) } /** @@ -215,20 +214,20 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { */ // eslint-disable-next-line @typescript-eslint/no-unused-vars validSnapshotName(event: any): any { - this.snapshotNameCheckDone = false; + this.snapshotNameCheckDone = false this.imageService .checkSnapshotNameAvailable(this.snapshotName.trim(), this.virtualMachine.client.id) .subscribe((res: IResponseTemplate): void => { - this.validSnapshotNameBool = this.snapshotName.length > 0 && (res.value as boolean); - this.snapshotNameCheckDone = true; - }); + this.validSnapshotNameBool = this.snapshotName.length > 0 && (res.value as boolean) + this.snapshotNameCheckDone = true + }) } /** * Reset the snapshotDone to waiting. */ resetSnapshotResult(): void { - this.snapshotDone = 'Waiting'; + this.snapshotDone = 'Waiting' } /** @@ -240,95 +239,95 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { this.virtualmachineService .checkVmStatus(this.virtualMachine.openstackid) .subscribe((updated_vm: VirtualMachine): void => { - this.virtualMachine = updated_vm; - }); + this.virtualMachine = updated_vm + }) } setVmNeeded(): void { this.virtualmachineService.setVmNeeded(this.virtualMachine.openstackid).subscribe((res: any): void => { if (res['still_needed']) { - this.virtualMachine.still_used_confirmation_requested = false; - this.virtualMachine.still_used_confirmed_date = new Date(); - this.cdr.detectChanges(); + this.virtualMachine.still_used_confirmation_requested = false + this.virtualMachine.still_used_confirmed_date = new Date() + this.cdr.detectChanges() } - }); + }) } checkVmVolumesStatus(): void { this.virtualMachine.volumes.forEach((vol: Volume): void => { if ( - vol.volume_status !== VolumeStates.AVAILABLE - && vol.volume_status !== VolumeStates.NOT_FOUND - && vol.volume_status !== VolumeStates.IN_USE - && vol.volume_status !== VolumeStates.MIGRATED + vol.volume_status !== VolumeStates.AVAILABLE && + vol.volume_status !== VolumeStates.NOT_FOUND && + vol.volume_status !== VolumeStates.IN_USE && + vol.volume_status !== VolumeStates.MIGRATED ) { - this.check_status_loop_vol(vol); + this.check_status_loop_vol(vol) } - }); + }) } - // eslint-disable-next-line default-param-last + check_status_loop_vol( volume: Volume, initial_timeout: number = this.checkStatusTimeout, final_state?: string, - expected_storage?: number, + expected_storage?: number ): void { - const created: boolean = volume.volume_created_by_user; + const created: boolean = volume.volume_created_by_user setTimeout((): void => { - const idx: number = this.virtualMachine.volumes.indexOf(volume); + const idx: number = this.virtualMachine.volumes.indexOf(volume) if (volume.volume_openstackid) { - // eslint-disable-next-line consistent-return + this.virtualmachineService.getVolumeById(volume.volume_openstackid).subscribe((vol: Volume): void => { if (expected_storage && vol.volume_storage !== expected_storage) { - return this.check_status_loop_vol(volume, this.checkStatusTimeout, final_state, expected_storage); + return this.check_status_loop_vol(volume, this.checkStatusTimeout, final_state, expected_storage) } else if (expected_storage && vol.volume_storage === expected_storage) { - this.extendDone = true; + this.extendDone = true } if (volume.error_msg !== '' && volume.error_msg !== undefined && volume.error_msg !== null) { - vol.error_msg = volume.error_msg; + vol.error_msg = volume.error_msg setTimeout((): void => { - vol.error_msg = null; - }, 5000); + vol.error_msg = null + }, 5000) } if (idx > -1) { - vol.volume_created_by_user = created; - this.virtualMachine.volumes[idx] = vol; + vol.volume_created_by_user = created + this.virtualMachine.volumes[idx] = vol } // tslint:disable-next-line:max-line-length if (this.VOLUME_END_STATES.indexOf(vol.volume_status) === -1 && final_state !== vol.volume_status) { - this.check_status_loop_vol(this.virtualMachine.volumes[idx], this.checkStatusTimeout, final_state); + this.check_status_loop_vol(this.virtualMachine.volumes[idx], this.checkStatusTimeout, final_state) } - }); + }) } else { // tslint:disable-next-line:max-line-length this.virtualmachineService .getVolumeByNameAndVmName(volume.volume_name, volume.volume_virtualmachine.name) .subscribe((vol: Volume): void => { if (volume.error_msg !== '' && volume.error_msg !== undefined && volume.error_msg !== null) { - vol.error_msg = volume.error_msg; + vol.error_msg = volume.error_msg setTimeout((): void => { - vol.error_msg = null; - }, 5000); + vol.error_msg = null + }, 5000) } if (idx > -1) { - vol.volume_created_by_user = created; - this.virtualMachine.volumes[idx] = vol; + vol.volume_created_by_user = created + this.virtualMachine.volumes[idx] = vol } // tslint:disable-next-line:max-line-length if ( - vol.volume_status !== VolumeStates.AVAILABLE - && vol.volume_status !== VolumeStates.NOT_FOUND - && vol.volume_status !== VolumeStates.IN_USE - && vol.volume_status !== VolumeStates.MIGRATED - && vol.volume_status !== final_state + vol.volume_status !== VolumeStates.AVAILABLE && + vol.volume_status !== VolumeStates.NOT_FOUND && + vol.volume_status !== VolumeStates.IN_USE && + vol.volume_status !== VolumeStates.MIGRATED && + vol.volume_status !== final_state ) { - this.check_status_loop_vol(this.virtualMachine.volumes[idx], this.checkStatusTimeout, final_state); + this.check_status_loop_vol(this.virtualMachine.volumes[idx], this.checkStatusTimeout, final_state) } - }); + }) } - }, initial_timeout); + }, initial_timeout) } /** @@ -337,31 +336,32 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { * @param vm which will be deleted */ deleteVm(): void { - this.virtualMachine.status = VirtualMachineStates.DELETING; + this.virtualMachine.status = VirtualMachineStates.DELETING this.virtualmachineService.deleteVM(this.virtualMachine.openstackid).subscribe( (updated_vm: VirtualMachine): void => { - updated_vm.cardState = 0; - this.virtualMachine = updated_vm; + updated_vm.cardState = 0 + this.virtualMachine = updated_vm if (updated_vm.status === VirtualMachineStates.DELETED) { - this.status_changed = 1; + this.status_changed = 1 } else { - this.status_changed = 2; + this.status_changed = 2 } }, (error1: any): void => { - this.status_changed = 2; + this.status_changed = 2 if (error1['status'] === 409) { - this.error_msg = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; + this.error_msg = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' } - this.getVmById(); - }, - ); + this.getVmById() + } + ) } /** * Subscription object to listen to different events. */ - subscription: Subscription = new Subscription(); + subscription: Subscription = new Subscription() /** * Function to listen to modal results. @@ -370,7 +370,7 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { this.subscription.add( this.bsModalRef.content.event.subscribe((result: any) => { if ('deleteVM' in result) { - this.deleteVm(); + this.deleteVm() /** } else if ('stopVM' in result) { this.stopVM(); } else if ('resumeVM' in result) { @@ -384,93 +384,97 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { } else if ('detachVolume' in result) { this.detachVolume(result['volume']); */ } else if ('reboot_type' in result) { - this.rebootVM(result['reboot_type']); + this.rebootVM(result['reboot_type']) } - }), - ); + }) + ) } /** * Show deletion modal */ showDeleteModal(): void { - const initialState = { virtualMachine: this.virtualMachine }; + const initialState = { virtualMachine: this.virtualMachine } - this.bsModalRef = this.modalService.show(DeleteVmComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(DeleteVmComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } /** * Show reboot modal */ showRebootModal(): void { - const initialState = { virtualMachine: this.virtualMachine }; + const initialState = { virtualMachine: this.virtualMachine } - this.bsModalRef = this.modalService.show(RebootVmComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(RebootVmComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') + this.subscribeToBsModalRef() } getDetachedVolumesByVSelectedMProject(): void { this.virtualmachineService .getDetachedVolumesByProject(this.virtualMachine.projectid) .subscribe((detached_volumes: Volume[]): void => { - this.detached_project_volumes = detached_volumes; - }); + this.detached_project_volumes = detached_volumes + }) } attachVolume(volume: Volume): void { - const volume_status_backup: string = volume.volume_status; - volume.volume_status = VolumeStates.ATTACHING; + const volume_status_backup: string = volume.volume_status + volume.volume_status = VolumeStates.ATTACHING this.virtualmachineService .attachVolumetoServer(volume.volume_openstackid, this.virtualMachine.openstackid) .subscribe( (result: IResponseTemplate): void => { if (result.value === 'attached') { - this.getVmById(); + this.getVmById() } }, (error1: any): void => { - this.status_changed = 2; + this.status_changed = 2 if (error1['error']['error'] === '409') { - this.volume_to_attach.error_msg = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; + this.volume_to_attach.error_msg = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' setTimeout((): void => { - this.volume_to_attach.error_msg = null; - }, 5000); - this.error_msg = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; - volume.volume_status = volume_status_backup; + this.volume_to_attach.error_msg = null + }, 5000) + this.error_msg = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' + volume.volume_status = volume_status_backup } - }, - ); + } + ) } detachVolume(volume: Volume): void { - const volume_status_backup: string = volume.volume_status; - volume.volume_status = VolumeStates.DETACHING; + const volume_status_backup: string = volume.volume_status + volume.volume_status = VolumeStates.DETACHING this.virtualmachineService .deleteVolumeAttachment(volume.volume_openstackid, this.virtualMachine.openstackid) .subscribe( (result: any): void => { if (result.value === 'deleted') { - this.getDetachedVolumesByVSelectedMProject(); - this.getVmById(); + this.getDetachedVolumesByVSelectedMProject() + this.getVmById() } }, (error1: any): void => { - this.status_changed = 2; + this.status_changed = 2 if (error1['error']['error'] === '409') { - volume.error_msg = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; + volume.error_msg = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' setTimeout((): void => { - volume.error_msg = null; - }, 5000); - this.error_msg = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; - volume.volume_status = volume_status_backup; + volume.error_msg = null + }, 5000) + this.error_msg = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' + volume.volume_status = volume_status_backup } - }, - ); + } + ) } /** @@ -480,28 +484,28 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { * @param reboot_type HARD|SOFT */ rebootVM(reboot_type: string): void { - this.stopCheckStatusTimer(); - this.virtualMachine.status = VirtualMachineStates.GETTING_STATUS; + this.stopCheckStatusTimer() + this.virtualMachine.status = VirtualMachineStates.GETTING_STATUS this.subscription.add( this.virtualmachineService.rebootVM(this.virtualMachine.openstackid, reboot_type).subscribe( (result: IResponseTemplate): void => { - this.virtualMachine.cardState = 0; + this.virtualMachine.cardState = 0 if (result.value as boolean) { - this.virtualMachine.setMsgWithTimeout('Reboot initiated', 5000); - this.check_status_loop_when_reboot(); + this.virtualMachine.setMsgWithTimeout('Reboot initiated', 5000) + this.check_status_loop_when_reboot() } else { - this.check_status_loop(VirtualMachineStates.ACTIVE); + this.check_status_loop(VirtualMachineStates.ACTIVE) } }, (error1: any): void => { - this.error_msg = this.REBOOT_ERROR_MSG; + this.error_msg = this.REBOOT_ERROR_MSG if (error1['error']['error'] === '409') { - this.virtualMachine.setErrorMsgWithTimeout(this.REBOOT_ERROR_MSG, this.ERROR_TIMER); + this.virtualMachine.setErrorMsgWithTimeout(this.REBOOT_ERROR_MSG, this.ERROR_TIMER) } - }, - ), - ); + } + ) + ) } /** @@ -517,36 +521,36 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { this.virtualmachineService .checkVmStatus(this.virtualMachine.openstackid) .subscribe((updated_vm: VirtualMachine): void => { - this.virtualMachine = updated_vm; - this.virtualMachine.cardState = 0; + this.virtualMachine = updated_vm + this.virtualMachine.cardState = 0 if (updated_vm.status === final_state || updated_vm.status === VirtualMachineStates.MIGRATED) { - this.virtualMachine = updated_vm; + this.virtualMachine = updated_vm } else { if (this.virtualMachine['error']) { - this.status_check_error = true; + this.status_check_error = true } - this.check_status_loop(final_state, is_selected_vm); + this.check_status_loop(final_state, is_selected_vm) } - }); + }) } else { this.virtualmachineService .checkVmStatus(this.virtualMachine.name) .subscribe((updated_vm: VirtualMachine): void => { - this.virtualMachine = updated_vm; - this.virtualMachine.cardState = 0; + this.virtualMachine = updated_vm + this.virtualMachine.cardState = 0 if (updated_vm.status === final_state) { - this.virtualMachine = updated_vm; + this.virtualMachine = updated_vm } else { if (this.virtualMachine['error']) { - this.status_check_error = true; + this.status_check_error = true } - this.check_status_loop(final_state, is_selected_vm); + this.check_status_loop(final_state, is_selected_vm) } - }); + }) } - }, timeout); + }, timeout) } /** @@ -560,37 +564,37 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { .checkVmStatusWhenReboot(this.virtualMachine.openstackid) .subscribe((updated_vm: VirtualMachine): void => { if (updated_vm.status === VirtualMachineStates.ACTIVE) { - this.reboot_done = true; - this.virtualMachine = updated_vm; - this.showNotificationModal('Success', 'The virtual machine was rebooted successfully!', 'success'); + this.reboot_done = true + this.virtualMachine = updated_vm + this.showNotificationModal('Success', 'The virtual machine was rebooted successfully!', 'success') } else { if (this.virtualMachine['error']) { - this.status_check_error = true; - this.showNotificationModal('Failed', 'The reboot of the virtual machine failed!', 'danger'); + this.status_check_error = true + this.showNotificationModal('Failed', 'The reboot of the virtual machine failed!', 'danger') } - this.check_status_loop_when_reboot(); + this.check_status_loop_when_reboot() } - }); - }, this.checkStatusTimeout); + }) + }, this.checkStatusTimeout) } showNotificationModal( notificationModalTitle: string, notificationModalMessage: string, - notificationModalType: string, + notificationModalType: string ) { - const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage }; + const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage } if (this.bsModalRef) { - this.bsModalRef.hide(); + this.bsModalRef.hide() } - this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); + this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }) + this.bsModalRef.setClass('modal-lg') } stopCheckStatusTimer(): void { if (this.checkStatusTimer) { - clearTimeout(this.checkStatusTimer); + clearTimeout(this.checkStatusTimer) } } @@ -602,67 +606,69 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { stopVm(): void { this.virtualmachineService.stopVM(this.virtualMachine.openstackid).subscribe( (updated_vm: VirtualMachine): void => { - this.status_changed = 0; + this.status_changed = 0 - updated_vm.cardState = 0; - this.virtualMachine = updated_vm; + updated_vm.cardState = 0 + this.virtualMachine = updated_vm switch (updated_vm.status) { case VirtualMachineStates.SHUTOFF: - this.status_changed = 1; - break; + this.status_changed = 1 + break case VirtualMachineStates.POWERING_OFF: - this.check_status_loop(VirtualMachineStates.SHUTOFF, true); - break; + this.check_status_loop(VirtualMachineStates.SHUTOFF, true) + break default: - this.status_changed = 2; - break; + this.status_changed = 2 + break } }, (error1: any): void => { - this.status_changed = 2; + this.status_changed = 2 if (error1['error']['error'] === '409') { - this.error_msg = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; + this.error_msg = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' } - }, - ); + } + ) } checkVmTillActive(): void { if ( - this.virtualMachine.status !== VirtualMachineStates.ACTIVE - && this.virtualMachine.status !== VirtualMachineStates.SHUTOFF - && this.virtualMachine.status !== VirtualMachineStates.DELETED + this.virtualMachine.status !== VirtualMachineStates.ACTIVE && + this.virtualMachine.status !== VirtualMachineStates.SHUTOFF && + this.virtualMachine.status !== VirtualMachineStates.DELETED ) { - this.check_status_loop(VirtualMachineStates.ACTIVE); + this.check_status_loop(VirtualMachineStates.ACTIVE) } } resumeVM(): void { this.virtualmachineService.resumeVM(this.virtualMachine.openstackid).subscribe( (updated_vm: VirtualMachine): void => { - this.status_changed = 0; - updated_vm.cardState = 0; - this.virtualMachine = updated_vm; + this.status_changed = 0 + updated_vm.cardState = 0 + this.virtualMachine = updated_vm switch (updated_vm.status) { case VirtualMachineStates.ACTIVE: - this.status_changed = 1; - break; + this.status_changed = 1 + break case VirtualMachineStates.POWERING_ON: - this.check_status_loop(VirtualMachineStates.ACTIVE, true); - break; + this.check_status_loop(VirtualMachineStates.ACTIVE, true) + break default: - this.status_changed = 2; - break; + this.status_changed = 2 + break } }, (error1: any): void => { - this.status_changed = 2; + this.status_changed = 2 if (error1['error']['error'] === '409') { - this.error_msg = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; + this.error_msg = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' } - }, - ); + } + ) } /** @@ -675,22 +681,23 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { this.imageService.createSnapshot(snapshot_instance, snapshot_name.trim(), description).subscribe( (newSnapshot: SnapshotModel): void => { if (newSnapshot.snapshot_openstackid) { - this.snapshotDone = 'true'; - this.virtualMachine.status = VirtualMachineStates.IMAGE_PENDING_UPLOAD; - this.check_status_loop(VirtualMachineStates.ACTIVE, null, 10000); + this.snapshotDone = 'true' + this.virtualMachine.status = VirtualMachineStates.IMAGE_PENDING_UPLOAD + this.check_status_loop(VirtualMachineStates.ACTIVE, null, 10000) } else { - this.snapshotDone = 'error'; - this.check_status_loop(VirtualMachineStates.ACTIVE); + this.snapshotDone = 'error' + this.check_status_loop(VirtualMachineStates.ACTIVE) } }, (error1: any): void => { - this.snapshotDone = 'error'; - this.status_changed = 2; + this.snapshotDone = 'error' + this.status_changed = 2 if (error1['error']['error'] === '409') { - this.error_msg = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; + this.error_msg = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' } - }, - ); + } + ) } /** @@ -700,7 +707,7 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { */ copyToClipboard(text: string): void { if (this.clipboardService.isSupported) { - this.clipboardService.copy(text); + this.clipboardService.copy(text) } } @@ -711,58 +718,58 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { this.userService.getMemberByUser().subscribe((): void => { this.groupService.isLoggedUserGroupAdmin(this.virtualMachine.projectid).subscribe((result): any => { if (result['admin']) { - this.is_project_admin = true; + this.is_project_admin = true } - }); - }); + }) + }) } getVmById(): void { this.virtualmachineService.getVmById(this.vm_id).subscribe((vm: VirtualMachine): void => { - vm = new VirtualMachine(vm); - this.checkAndGetForcDetails(vm); - this.title = vm['name']; - this.virtualMachine = vm; + vm = new VirtualMachine(vm) + this.checkAndGetForcDetails(vm) + this.title = vm['name'] + this.virtualMachine = vm this.applicationService .getApplicationMigratedByGroupId(this.virtualMachine.projectid.toString()) .subscribe((migrated: boolean): void => { - this.isMigrated = migrated; - }); - this.checkVMAdminState(); + this.isMigrated = migrated + }) + this.checkVMAdminState() this.biocondaService.getTemplateNameByVmName(vm).subscribe((backend: Backend): void => { - if (backend != null) { - const template_name: string = backend.template; + if (backend !== null) { + const template_name: string = backend.template this.biocondaService.getForcTemplates(vm.client.id).subscribe((templates: any): void => { - if (templates != null) { + if (templates !== null) { for (const temp of templates) { if (temp['template_name'] === template_name) { - this.resenvTemplate = temp; - break; + this.resenvTemplate = temp + break } } } - }); + }) } - }); - this.getImageDetails(this.virtualMachine.projectid, this.virtualMachine.image); - this.getDetachedVolumesByVSelectedMProject(); - this.checkVmVolumesStatus(); - this.isLoaded = true; - }); + }) + this.getImageDetails(this.virtualMachine.projectid, this.virtualMachine.image) + this.getDetachedVolumesByVSelectedMProject() + this.checkVmVolumesStatus() + this.isLoaded = true + }) } getImageDetails(project_id: number, name: string): Image { - const newImage: Image = new Image(); + const newImage: Image = new Image() this.imageService.getImageByProjectAndName(project_id, name).subscribe( (image: Image): void => { - this.image = image; + this.image = image }, (): void => { - this.isLoaded = false; - }, - ); + this.isLoaded = false + } + ) - return newImage; + return newImage } // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -773,33 +780,33 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { // } // } - this.getUsersForBackend(); + this.getUsersForBackend() } filterMembers(searchString: string): void { this.groupService .getFilteredMembersByProject(searchString, this.virtualMachine.projectid) .subscribe((result: object): void => { - this.filteredMembers = result; - }); + this.filteredMembers = result + }) } addUserToBackend(userId: any): void { this.biocondaService.addUserToBackend(this.vm_id, userId).subscribe((): void => { - this.getUsersForBackend(); - }); + this.getUsersForBackend() + }) } getUsersForBackend(): void { this.biocondaService.getUsersForBackend(this.vm_id).subscribe((result: any): void => { - this.backend_users = result; - }); + this.backend_users = result + }) } deleteUserFromBackend(userId: any): void { this.biocondaService.deleteUserFromBackend(this.vm_id, userId.toString()).subscribe((): void => { - this.getUsersForBackend(); - }); + this.getUsersForBackend() + }) } /** @@ -808,12 +815,12 @@ export class VmDetailComponent extends AbstractBaseClass implements OnInit { resenv_by_play(vm: VirtualMachine): boolean { for (const mode of vm.modes) { if (TemplateNames.ALL_TEMPLATE_NAMES.indexOf(mode.name) !== -1) { - return false; + return false } } - return true; + return true } - protected readonly NEW_SVM_PORTAL_LINK = NEW_SVM_PORTAL_LINK; + protected readonly NEW_SVM_PORTAL_LINK = NEW_SVM_PORTAL_LINK } diff --git a/src/app/virtualmachines/vmdetail/vmstatus/vmstatus.component.ts b/src/app/virtualmachines/vmdetail/vmstatus/vmstatus.component.ts index 96c9ba2ff4..68c0f48418 100644 --- a/src/app/virtualmachines/vmdetail/vmstatus/vmstatus.component.ts +++ b/src/app/virtualmachines/vmdetail/vmstatus/vmstatus.component.ts @@ -1,7 +1,7 @@ -import { Component, Input } from '@angular/core'; -import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates'; -import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine'; -import { CLOUD_PORTAL_SUPPORT_MAIL } from '../../../../links/links'; +import { Component, Input } from '@angular/core' +import { VirtualMachineStates } from '../../virtualmachinemodels/virtualmachinestates' +import { VirtualMachine } from '../../virtualmachinemodels/virtualmachine' +import { CLOUD_PORTAL_SUPPORT_MAIL } from '../../../../links/links' /** * Vmstatus component. @@ -9,11 +9,11 @@ import { CLOUD_PORTAL_SUPPORT_MAIL } from '../../../../links/links'; @Component({ selector: 'app-vmstatus', templateUrl: './vmstatus.component.html', - styleUrls: ['./vmstatus.component.scss'], + styleUrls: ['./vmstatus.component.scss'] }) export class VmstatusComponent { - VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates(); - @Input() vm: VirtualMachine; - @Input() with_text: boolean = false; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; + VirtualMachineStates: VirtualMachineStates = new VirtualMachineStates() + @Input() vm: VirtualMachine + @Input() with_text: boolean = false + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL } diff --git a/src/app/virtualmachines/volumes/volum-status/volum-status.component.ts b/src/app/virtualmachines/volumes/volum-status/volum-status.component.ts index ec99308c88..da8e91df82 100644 --- a/src/app/virtualmachines/volumes/volum-status/volum-status.component.ts +++ b/src/app/virtualmachines/volumes/volum-status/volum-status.component.ts @@ -1,7 +1,7 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { VolumeStates } from '../volume_states'; -import { Volume } from '../volume'; -import { CLOUD_PORTAL_SUPPORT_MAIL } from '../../../../links/links'; +import { Component, Input, OnInit } from '@angular/core' +import { VolumeStates } from '../volume_states' +import { Volume } from '../volume' +import { CLOUD_PORTAL_SUPPORT_MAIL } from '../../../../links/links' /** * Volume Status component. @@ -9,14 +9,12 @@ import { CLOUD_PORTAL_SUPPORT_MAIL } from '../../../../links/links'; @Component({ selector: 'app-volum-status', templateUrl: './volum-status.component.html', - styleUrls: ['../../vmOverview.component.scss'], + styleUrls: ['../../vmOverview.component.scss'] }) export class VolumStatusComponent implements OnInit { - VolumeStates: VolumeStates = new VolumeStates(); - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - @Input() volume: Volume; - - ngOnInit(): void { - } + VolumeStates: VolumeStates = new VolumeStates() + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + @Input() volume: Volume + ngOnInit(): void {} } diff --git a/src/app/virtualmachines/volumes/volumeOverview.component.ts b/src/app/virtualmachines/volumes/volumeOverview.component.ts index ac89315bf1..14c3d120de 100644 --- a/src/app/virtualmachines/volumes/volumeOverview.component.ts +++ b/src/app/virtualmachines/volumes/volumeOverview.component.ts @@ -1,27 +1,23 @@ -import { - Component, OnDestroy, OnInit, ViewChild, inject, -} from '@angular/core'; -import { - forkJoin, lastValueFrom, Subject, Subscription, -} from 'rxjs'; -import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators'; -import { AbstractControl, UntypedFormControl, ValidatorFn } from '@angular/forms'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { Volume } from './volume'; -import { VirtualmachineService } from '../../api-connector/virtualmachine.service'; -import { VirtualMachine } from '../virtualmachinemodels/virtualmachine'; -import { GroupService } from '../../api-connector/group.service'; -import { AbstractBaseClass } from '../../shared/shared_modules/baseClass/abstract-base-class'; -import { VolumeActionStates } from './volume-action-states.enum'; -import { VolumeRequestStates } from './volume-request-states.enum'; -import { IResponseTemplate } from '../../api-connector/response-template'; -import { FacilityService } from '../../api-connector/facility.service'; -import { WIKI_EXTEND_VOLUME, WIKI_VOLUME_OVERVIEW, CLOUD_PORTAL_SUPPORT_MAIL } from '../../../links/links'; -import { VolumeStates } from './volume_states'; -import { VirtualMachineStates } from '../virtualmachinemodels/virtualmachinestates'; -import { VolumePage } from './volumePage.model'; -import { ApplicationsService } from '../../api-connector/applications.service'; -import { IsMigratedProjectIdPipe } from '../../pipe-module/pipes/migratedList'; +import { Component, OnDestroy, OnInit, ViewChild, inject } from '@angular/core' +import { forkJoin, lastValueFrom, Subject, Subscription } from 'rxjs' +import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators' +import { AbstractControl, UntypedFormControl, ValidatorFn } from '@angular/forms' +import { MatomoTracker } from 'ngx-matomo-client' +import { Volume } from './volume' +import { VirtualmachineService } from '../../api-connector/virtualmachine.service' +import { VirtualMachine } from '../virtualmachinemodels/virtualmachine' +import { GroupService } from '../../api-connector/group.service' +import { AbstractBaseClass } from '../../shared/shared_modules/baseClass/abstract-base-class' +import { VolumeActionStates } from './volume-action-states.enum' +import { VolumeRequestStates } from './volume-request-states.enum' +import { IResponseTemplate } from '../../api-connector/response-template' +import { FacilityService } from '../../api-connector/facility.service' +import { WIKI_EXTEND_VOLUME, WIKI_VOLUME_OVERVIEW, CLOUD_PORTAL_SUPPORT_MAIL } from '../../../links/links' +import { VolumeStates } from './volume_states' +import { VirtualMachineStates } from '../virtualmachinemodels/virtualmachinestates' +import { VolumePage } from './volumePage.model' +import { ApplicationsService } from '../../api-connector/applications.service' +import { IsMigratedProjectIdPipe } from '../../pipe-module/pipes/migratedList' /** * Volume overview component. @@ -30,142 +26,142 @@ import { IsMigratedProjectIdPipe } from '../../pipe-module/pipes/migratedList'; selector: 'app-volume-overview', templateUrl: 'volumeOverview.component.html', providers: [FacilityService, GroupService, VirtualmachineService, IsMigratedProjectIdPipe], - styleUrls: ['../vmOverview.component.scss'], + styleUrls: ['../vmOverview.component.scss'] }) export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit, OnDestroy { - @ViewChild('errorModal') errorModal: any; - private readonly tracker = inject(MatomoTracker); + @ViewChild('errorModal') errorModal: any + private readonly tracker = inject(MatomoTracker) - volume_page: VolumePage = new VolumePage(); + volume_page: VolumePage = new VolumePage() - WIKI_EXTEND_VOLUME: string = WIKI_EXTEND_VOLUME; - WIKI_VOLUME_OVERVIEW: string = WIKI_VOLUME_OVERVIEW; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - title: string = 'Volume Overview'; - selected_volume_data_loaded: boolean = false; - filter: string; - checked_volumes: Volume[] = []; - storageSize: UntypedFormControl = null; + WIKI_EXTEND_VOLUME: string = WIKI_EXTEND_VOLUME + WIKI_VOLUME_OVERVIEW: string = WIKI_VOLUME_OVERVIEW + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + title: string = 'Volume Overview' + selected_volume_data_loaded: boolean = false + filter: string + checked_volumes: Volume[] = [] + storageSize: UntypedFormControl = null /** * Enum of all volume action states. */ - volumeActionStates: typeof VolumeActionStates = VolumeActionStates; - extendError: boolean = false; - extendDone: boolean = false; + volumeActionStates: typeof VolumeActionStates = VolumeActionStates + extendError: boolean = false + extendDone: boolean = false - showFacilities: boolean = false; + showFacilities: boolean = false /** * Enum of all request states. * * @type {VolumeRequestStates} */ - volumeRequestStates: typeof VolumeRequestStates = VolumeRequestStates; + volumeRequestStates: typeof VolumeRequestStates = VolumeRequestStates /** * Facilitties where the user is manager ['name',id]. */ - managerFacilities: [string, number][] = []; + managerFacilities: [string, number][] = [] /** * Chosen facility. */ - selectedFacility: [string, number]; + selectedFacility: [string, number] /** * Array of volumes from the selected Project. */ - project_vms: VirtualMachine[]; + project_vms: VirtualMachine[] /** * Selected vm. */ - selected_vm: VirtualMachine; + selected_vm: VirtualMachine /** * If the site is loaded. * * @type {boolean} */ - isLoaded: boolean = false; + isLoaded: boolean = false /** * Selected volume. */ - selected_volume: Volume; + selected_volume: Volume /** * Diskspace max from selected Project. */ - selectedProjectDiskspaceMax: number; + selectedProjectDiskspaceMax: number /** * Diskspace used from selected Project. */ - selectedProjectDiskspaceUsed: number; + selectedProjectDiskspaceUsed: number /** * Volumes max from selected Project. */ - selectedProjectVolumesMax: number; + selectedProjectVolumesMax: number /** * Volumes used from selected Project. */ - selectedProjectVolumesUsed: number; + selectedProjectVolumesUsed: number /** * Diskspace actual + addition if new volume would be created for selected Project. */ - selectedProjectDiskSpaceSum: number; + selectedProjectDiskSpaceSum: number /** * The selected Project [name,id]. */ - selectedProject: [string, number]; + selectedProject: [string, number] /** * List of all projects from the user. * * @type {any[]} */ - projects: string[] = []; + projects: string[] = [] /** * Default volumeStorage. * * @type {number} */ - diskspace: number = 1; + diskspace: number = 1 /** * Default volumename. * * @type {string} */ - volumeName: string = ''; + volumeName: string = '' /** * Action which is performed with a volume. */ - volume_action_status: number; + volume_action_status: number - extendVolumeStorage: number; + extendVolumeStorage: number - migratedProjectIds: string[] = []; - migratedProjectNames: string[] = []; + migratedProjectIds: string[] = [] + migratedProjectNames: string[] = [] /** * Type of request. */ - request_status: number; - private checkStatusSubscription: Subscription = new Subscription(); - private getVolumesSubscription: Subscription = new Subscription(); - private checkStatusTimeout: number = 5000; - VolumeStates: VolumeStates = new VolumeStates(); - volumePerPageChange: Subject = new Subject(); - filterChanged: Subject = new Subject(); - DEBOUNCE_TIME: number = 1000; - currentPage: number = 1; - isSearching: boolean = true; - all_volumes_checked: boolean = false; - selected_volumes_to_detach: boolean = false; + request_status: number + private checkStatusSubscription: Subscription = new Subscription() + private getVolumesSubscription: Subscription = new Subscription() + private checkStatusTimeout: number = 5000 + VolumeStates: VolumeStates = new VolumeStates() + volumePerPageChange: Subject = new Subject() + filterChanged: Subject = new Subject() + DEBOUNCE_TIME: number = 1000 + currentPage: number = 1 + isSearching: boolean = true + all_volumes_checked: boolean = false + selected_volumes_to_detach: boolean = false VOLUME_END_STATES: string[] = [ VolumeStates.AVAILABLE, VolumeStates.NOT_FOUND, VolumeStates.IN_USE, VirtualMachineStates.DELETED, VirtualMachineStates.DELETING_FAILED, - VolumeStates.ERROR, - ]; - errorState: number = 0; + VolumeStates.ERROR + ] + errorState: number = 0 constructor( private facilityService: FacilityService, @@ -173,162 +169,162 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit private vmService: VirtualmachineService, private applicationsService: ApplicationsService, - private isMigratedPipe: IsMigratedProjectIdPipe, + private isMigratedPipe: IsMigratedProjectIdPipe ) { - super(); + super() } ngOnDestroy(): void { - this.checkStatusSubscription.unsubscribe(); - this.getVolumesSubscription.unsubscribe(); + this.checkStatusSubscription.unsubscribe() + this.getVolumesSubscription.unsubscribe() } changedFilter(text: string): void { - this.filterChanged.next(text); + this.filterChanged.next(text) } isVolChecked(vol: Volume): boolean { - return this.checked_volumes.indexOf(vol) !== -1; + return this.checked_volumes.indexOf(vol) !== -1 } changeCheckedVolume(vol: Volume): void { if (!this.isVolChecked(vol)) { - this.checked_volumes.push(vol); + this.checked_volumes.push(vol) } else { - this.checked_volumes.splice(this.checked_volumes.indexOf(vol), 1); + this.checked_volumes.splice(this.checked_volumes.indexOf(vol), 1) } - this.areAllVolumesChecked(); - this.areSelectedVolumesDetachable(); + this.areAllVolumesChecked() + this.areSelectedVolumesDetachable() } areSelectedVolumesDetachable(): void { - this.selected_volumes_to_detach = false; + this.selected_volumes_to_detach = false this.checked_volumes.forEach((vol: Volume): void => { if (vol.volume_virtualmachine) { - this.selected_volumes_to_detach = true; + this.selected_volumes_to_detach = true } - }); + }) } uncheckAll(): void { - this.checked_volumes = []; - this.all_volumes_checked = false; - this.selected_volumes_to_detach = false; + this.checked_volumes = [] + this.all_volumes_checked = false + this.selected_volumes_to_detach = false } deleteSelectedVolumes(): void { - const delete_vols: Volume[] = this.checked_volumes; + const delete_vols: Volume[] = this.checked_volumes const vol_ids: string[] = this.checked_volumes.map((vol: Volume): string => { - vol.volume_status = VolumeStates.DELETING; + vol.volume_status = VolumeStates.DELETING - return vol.volume_openstackid; - }); + return vol.volume_openstackid + }) this.vmService.deleteVolumes(vol_ids).subscribe((): void => { delete_vols.forEach((vol: Volume): void => { - vol.volume_status = VolumeStates.DELETED; - }); - }); + vol.volume_status = VolumeStates.DELETED + }) + }) - this.uncheckAll(); + this.uncheckAll() } detachSelectedVolumes(): void { - const detach_vols: Volume[] = this.checked_volumes; + const detach_vols: Volume[] = this.checked_volumes const vol_ids: string[] = this.checked_volumes.map((vol: Volume): string => { if (vol.volume_virtualmachine) { - vol.volume_status = VolumeStates.DETACHING; + vol.volume_status = VolumeStates.DETACHING - return vol.volume_openstackid; + return vol.volume_openstackid } else { - return null; + return null } - }); + }) this.vmService.deleteVolumeAttachments(vol_ids).subscribe((): void => { detach_vols.forEach((vol: Volume): void => { - this.check_status_loop(vol, 2000, VolumeStates.AVAILABLE); - }); - }); + this.check_status_loop(vol, 2000, VolumeStates.AVAILABLE) + }) + }) - this.uncheckAll(); + this.uncheckAll() } areAllVolumesChecked(): void { - let all_checked: boolean = true; + let all_checked: boolean = true this.volume_page.volume_list.forEach((vol: Volume): void => { if (!this.isVolChecked(vol)) { - all_checked = false; + all_checked = false } - }); + }) - this.all_volumes_checked = all_checked; + this.all_volumes_checked = all_checked } changeCheckAllVolumes(): void { if (this.all_volumes_checked) { - this.checked_volumes = []; - this.all_volumes_checked = false; + this.checked_volumes = [] + this.all_volumes_checked = false - return; + return } this.volume_page.volume_list.forEach((vol: Volume): void => { if (!this.isVolChecked(vol) && !this.isMigratedPipe.transform(vol.volume_projectid, this.migratedProjectIds)) { - this.checked_volumes.push(vol); + this.checked_volumes.push(vol) } - }); - this.all_volumes_checked = true; - this.areSelectedVolumesDetachable(); + }) + this.all_volumes_checked = true + this.areSelectedVolumesDetachable() } setSelectedProjectByVolume(volume: Volume): void { - this.selectedProject = [volume.volume_project, parseInt(volume.volume_projectid, 10)]; + this.selectedProject = [volume.volume_project, parseInt(volume.volume_projectid, 10)] } ngOnInit(): void { - this.tracker.trackPageView('Volume Overview'); - this.getVolumes(); - this.getUserApprovedProjects(); + this.tracker.trackPageView('Volume Overview') + this.getVolumes() + this.getUserApprovedProjects() this.facilityService.getManagerFacilities().subscribe((result: any): void => { - this.managerFacilities = result; - this.selectedFacility = this.managerFacilities[0]; - }); + this.managerFacilities = result + this.selectedFacility = this.managerFacilities[0] + }) this.filterChanged .pipe( debounceTime(this.DEBOUNCE_TIME), distinctUntilChanged(), switchMap((filter: string): any => { - this.isSearching = true; + this.isSearching = true - this.filter = filter.trim(); + this.filter = filter.trim() - return this.vmService.getVolumesByUser(this.volume_page.items_per_page, this.currentPage, this.filter); - }), + return this.vmService.getVolumesByUser(this.volume_page.items_per_page, this.currentPage, this.filter) + }) ) .subscribe((volume_page: VolumePage): void => { - this.volume_page = volume_page; + this.volume_page = volume_page for (const volume of this.volume_page.volume_list) { - this.setCollapseStatus(volume.volume_openstackid, false); + this.setCollapseStatus(volume.volume_openstackid, false) } - this.isSearching = false; + this.isSearching = false this.volume_page.volume_list.forEach((vol: Volume): void => { if ( - vol.volume_status !== VolumeStates.AVAILABLE - && vol.volume_status !== VolumeStates.NOT_FOUND - && vol.volume_status !== VolumeStates.IN_USE + vol.volume_status !== VolumeStates.AVAILABLE && + vol.volume_status !== VolumeStates.NOT_FOUND && + vol.volume_status !== VolumeStates.IN_USE ) { - this.check_status_loop(vol); + this.check_status_loop(vol) } - }); - }); + }) + }) this.volumePerPageChange.pipe(debounceTime(this.DEBOUNCE_TIME), distinctUntilChanged()).subscribe((): void => { if (this.volume_page.items_per_page && this.volume_page.items_per_page > 0) { if (this.showFacilities) { - this.getFacilityVolumes(); + this.getFacilityVolumes() } else { - this.getVolumes(); + this.getVolumes() } } - }); + }) } /** @@ -339,64 +335,65 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit * @returns */ async attachVolume(volume: Volume, instance_id: string): Promise { - await this.updateVolume(volume); + await this.updateVolume(volume) - volume = this.get_volume_from_list_by_id(volume.volume_openstackid); + volume = this.get_volume_from_list_by_id(volume.volume_openstackid) if (volume.volume_status !== VolumeStates.AVAILABLE) { - volume.error_msg = "Conflict detected. The volume can't be attached, because it is not AVAILABLE"; + volume.error_msg = "Conflict detected. The volume can't be attached, because it is not AVAILABLE" setTimeout((): void => { - volume.error_msg = null; - }, 10000); + volume.error_msg = null + }, 10000) - return; + return } - volume = this.get_volume_from_list_by_id(volume.volume_openstackid); + volume = this.get_volume_from_list_by_id(volume.volume_openstackid) - volume.volume_status = VolumeStates.ATTACHING; + volume.volume_status = VolumeStates.ATTACHING this.vmService.attachVolumetoServer(volume.volume_openstackid, instance_id).subscribe( (result: IResponseTemplate): void => { if (result.value === 'attached') { - this.volume_action_status = this.volumeActionStates.ATTACHING_SUCCESSFULL; + this.volume_action_status = this.volumeActionStates.ATTACHING_SUCCESSFULL } else { - this.volume_action_status = this.volumeActionStates.ERROR; + this.volume_action_status = this.volumeActionStates.ERROR } - this.check_status_loop(volume, 5000, VolumeStates.IN_USE); + this.check_status_loop(volume, 5000, VolumeStates.IN_USE) }, (error: any): void => { if (error['error']['error'] === '409') { - volume.error_msg = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; + volume.error_msg = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' setTimeout((): void => { - volume.error_msg = null; - }, 5000); + volume.error_msg = null + }, 5000) } - this.check_status_loop(volume, 0); - }, - ); + this.check_status_loop(volume, 0) + } + ) } async extendVolume(volume: Volume, new_storage: number): Promise { - await this.updateVolume(volume); + await this.updateVolume(volume) - volume = this.get_volume_from_list_by_id(volume.volume_openstackid); + volume = this.get_volume_from_list_by_id(volume.volume_openstackid) if (volume.volume_status !== VolumeStates.AVAILABLE) { - volume.error_msg = "Conflict detected. The volume can't be extended, because it is not AVAILABLE"; + volume.error_msg = "Conflict detected. The volume can't be extended, because it is not AVAILABLE" setTimeout((): void => { - volume.error_msg = null; - }, 10000); + volume.error_msg = null + }, 10000) - return; + return } - volume.volume_status = VolumeStates.EXTENDING; + volume.volume_status = VolumeStates.EXTENDING this.vmService.extendVolume(volume.volume_openstackid, new_storage.toString()).subscribe((res: any): void => { if (res['status_code'] === 0) { - this.check_status_loop(volume, 0, undefined, new_storage); + this.check_status_loop(volume, 0, undefined, new_storage) } else { - this.extendError = true; - this.check_status_loop(volume, 0); + this.extendError = true + this.check_status_loop(volume, 0) } - }); + }) } /** @@ -405,39 +402,39 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit * @param event */ pageChanged(event: any): void { - this.isSearching = true; + this.isSearching = true - this.currentPage = event.page; + this.currentPage = event.page if (this.showFacilities) { - this.getFacilityVolumes(); + this.getFacilityVolumes() } else { - this.getVolumes(); + this.getVolumes() } } getFacilityVolumes(): void { - this.isSearching = true; - this.getVolumesSubscription.unsubscribe(); - this.getVolumesSubscription = new Subscription(); + this.isSearching = true + this.getVolumesSubscription.unsubscribe() + this.getVolumesSubscription = new Subscription() this.getVolumesSubscription.add( this.facilityService .getFacilityVolumes(this.selectedFacility['FacilityId'], this.volume_page.items_per_page, this.currentPage) .subscribe((volume_page: VolumePage): void => { - this.volume_page = volume_page; + this.volume_page = volume_page for (const volume of this.volume_page.volume_list) { - this.setCollapseStatus(volume.volume_openstackid, false); + this.setCollapseStatus(volume.volume_openstackid, false) } - this.isLoaded = true; - this.isSearching = false; + this.isLoaded = true + this.isSearching = false this.volume_page.volume_list.forEach((vol: Volume): void => { if (vol.volume_status !== VolumeStates.NOT_FOUND) { - this.check_status_loop(vol); + this.check_status_loop(vol) } - }); - }), - ); + }) + }) + ) } /** @@ -449,54 +446,55 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit * @returns */ createAndAttachvolume(volume_name: string, diskspace: number, instance_id: string): void { - this.volume_action_status = 7; + this.volume_action_status = 7 this.vmService.createVolume(volume_name, diskspace.toString(), instance_id).subscribe( async (newVolume: Volume): Promise => { - newVolume.volume_created_by_user = true; + newVolume.volume_created_by_user = true if (newVolume.volume_openstackid) { - newVolume.volume_status = VolumeStates.CREATING; - this.volume_page.volume_list.push(newVolume); - await this.updateVolume(newVolume); - let volume: Volume = this.get_volume_from_list_by_id(newVolume.volume_openstackid); + newVolume.volume_status = VolumeStates.CREATING + this.volume_page.volume_list.push(newVolume) + await this.updateVolume(newVolume) + let volume: Volume = this.get_volume_from_list_by_id(newVolume.volume_openstackid) while (volume.volume_status !== VolumeStates.AVAILABLE) { - // eslint-disable-next-line no-await-in-loop - await this.updateVolume(newVolume); + + await this.updateVolume(newVolume) - volume = this.get_volume_from_list_by_id(newVolume.volume_openstackid); + volume = this.get_volume_from_list_by_id(newVolume.volume_openstackid) } - this.volume_action_status = this.volumeActionStates.ATTACHING; + this.volume_action_status = this.volumeActionStates.ATTACHING this.vmService.attachVolumetoServer(volume.volume_openstackid, instance_id).subscribe( (res: IResponseTemplate): void => { if (res.value === 'attached') { - this.volume_action_status = this.volumeActionStates.SUCCESSFULLY_CREATED_ATTACHED; + this.volume_action_status = this.volumeActionStates.SUCCESSFULLY_CREATED_ATTACHED } else { - this.volume_action_status = this.volumeActionStates.ERROR; + this.volume_action_status = this.volumeActionStates.ERROR } - this.check_status_loop(volume, 0); + this.check_status_loop(volume, 0) }, (error: any): void => { if (error['error']['error'] === '409') { - volume.error_msg = 'Conflict detected. ' - + 'The virtual machine is currently creating a snapshot and must not be altered.'; + volume.error_msg = + 'Conflict detected. ' + + 'The virtual machine is currently creating a snapshot and must not be altered.' setTimeout((): void => { - volume.error_msg = null; - }, 5000); + volume.error_msg = null + }, 5000) } - this.check_status_loop(volume, 0); - }, - ); + this.check_status_loop(volume, 0) + } + ) } else { - this.volume_action_status = this.volumeActionStates.ERROR; + this.volume_action_status = this.volumeActionStates.ERROR } }, (): void => { - this.errorState = 0; - this.errorModal.show(); - }, - ); + this.errorState = 0 + this.errorModal.show() + } + ) } /** @@ -508,29 +506,29 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit * @returns */ createVolume(volume_name: string, diskspace: number, instance_id: string): void { - this.volume_action_status = this.volumeActionStates.WAITING; + this.volume_action_status = this.volumeActionStates.WAITING this.vmService.createVolume(volume_name, diskspace.toString(), instance_id).subscribe((newVolume: Volume): void => { if (newVolume.volume_openstackid) { - this.volume_action_status = this.volumeActionStates.WAIT_CREATION; - this.volume_page.volume_list.push(newVolume); + this.volume_action_status = this.volumeActionStates.WAIT_CREATION + this.volume_page.volume_list.push(newVolume) } else { - this.volume_action_status = this.volumeActionStates.ERROR; + this.volume_action_status = this.volumeActionStates.ERROR } - }); + }) } deleteVolume(volume: Volume): void { - volume.volume_status = VolumeStates.DELETING; + volume.volume_status = VolumeStates.DELETING this.vmService.deleteVolume(volume.volume_openstackid).subscribe( (): void => { - volume.volume_status = VolumeStates.DELETED; + volume.volume_status = VolumeStates.DELETED }, (error: any) => { - console.log(error); - this.errorState = 1; - this.errorModal.show(); - }, - ); + console.log(error) + this.errorState = 1 + this.errorModal.show() + } + ) } /** @@ -541,42 +539,43 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit * @returns */ async detachVolume(volume: Volume, instance_id: string): Promise { - await this.updateVolume(volume); + await this.updateVolume(volume) - volume = this.get_volume_from_list_by_id(volume.volume_openstackid); + volume = this.get_volume_from_list_by_id(volume.volume_openstackid) if (volume.volume_status !== VolumeStates.IN_USE) { - volume.error_msg = "Conflict detected. The volume can't be detached, because it is not IN-USE"; + volume.error_msg = "Conflict detected. The volume can't be detached, because it is not IN-USE" setTimeout((): void => { - volume.error_msg = null; - }, 10000); + volume.error_msg = null + }, 10000) - return; + return } - this.volume_action_status = this.volumeActionStates.DETACHING_VOLUME; - volume.volume_status = VolumeStates.DETACHING; + this.volume_action_status = this.volumeActionStates.DETACHING_VOLUME + volume.volume_status = VolumeStates.DETACHING this.vmService.deleteVolumeAttachment(volume.volume_openstackid, instance_id).subscribe( (result: any): void => { if (result.value === 'deleted') { - this.volume_action_status = this.volumeActionStates.SUCCESSFULLY_DETACHED_VOLUME; + this.volume_action_status = this.volumeActionStates.SUCCESSFULLY_DETACHED_VOLUME } else { - this.volume_action_status = this.volumeActionStates.ERROR; + this.volume_action_status = this.volumeActionStates.ERROR } - this.check_status_loop(volume, 5000, VolumeStates.AVAILABLE); + this.check_status_loop(volume, 5000, VolumeStates.AVAILABLE) }, (error: any): void => { if (error['error']['error'] === '409') { - volume.error_msg = 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.'; + volume.error_msg = + 'Conflict detected. The virtual machine is currently creating a snapshot and must not be altered.' setTimeout((): void => { - volume.error_msg = null; - }, 5000); + volume.error_msg = null + }, 5000) } else { - this.errorState = 2; - this.errorModal.show(); + this.errorState = 2 + this.errorModal.show() } - this.check_status_loop(volume, 0); - }, - ); + this.check_status_loop(volume, 0) + } + ) } /** @@ -587,36 +586,36 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit * @returns */ renameVolume(volume: Volume, new_volume_name: string): void { - this.volume_action_status = this.volumeActionStates.CHANGING_NAME; + this.volume_action_status = this.volumeActionStates.CHANGING_NAME this.vmService .renameVolume(volume.volume_openstackid, new_volume_name) .subscribe((changed_volume: Volume): void => { if (changed_volume.volume_name === new_volume_name) { - this.volume_action_status = this.volumeActionStates.CHANGING_NAME_SUCESSFULL; + this.volume_action_status = this.volumeActionStates.CHANGING_NAME_SUCESSFULL } else { - this.volume_action_status = this.volumeActionStates.ERROR; + this.volume_action_status = this.volumeActionStates.ERROR } - this.volume_page.volume_list[this.volume_page.volume_list.indexOf(volume)] = changed_volume; - }); + this.volume_page.volume_list[this.volume_page.volume_list.indexOf(volume)] = changed_volume + }) } generateMigratedProjectIdList(): void { - this.migratedProjectIds = []; + this.migratedProjectIds = [] this.volume_page.volume_list.forEach((vol: Volume) => { if (vol.migrate_project_to_simple_vm || vol.project_is_migrated_to_simple_vm) { - this.migratedProjectIds.push(vol.volume_projectid.toString()); + this.migratedProjectIds.push(vol.volume_projectid.toString()) } - const unique = (arr: string[]): string[] => [...new Set(arr)]; - this.migratedProjectIds = unique(this.migratedProjectIds); - }); + const unique = (arr: string[]): string[] => [...new Set(arr)] + this.migratedProjectIds = unique(this.migratedProjectIds) + }) } generateMigratedProjectNamesList(): void { - this.migratedProjectNames = []; + this.migratedProjectNames = [] this.volume_page.volume_list.forEach((vol: Volume) => { if (vol.migrate_project_to_simple_vm || vol.project_is_migrated_to_simple_vm) { - this.migratedProjectNames.push(vol.volume_project); + this.migratedProjectNames.push(vol.volume_project) } - }); + }) } /** @@ -625,96 +624,97 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit * @returns */ getVolumes(): void { - this.isSearching = true; - this.getVolumesSubscription.unsubscribe(); - this.getVolumesSubscription = new Subscription(); + this.isSearching = true + this.getVolumesSubscription.unsubscribe() + this.getVolumesSubscription = new Subscription() this.getVolumesSubscription.add( this.vmService .getVolumesByUser(this.volume_page.items_per_page, this.currentPage) .subscribe((volume_page: VolumePage): void => { - this.volume_page = volume_page; - this.generateMigratedProjectIdList(); - this.generateMigratedProjectNamesList(); + this.volume_page = volume_page + this.generateMigratedProjectIdList() + this.generateMigratedProjectNamesList() for (const volume of this.volume_page.volume_list) { - this.setCollapseStatus(volume.volume_openstackid, false); + this.setCollapseStatus(volume.volume_openstackid, false) } - this.isLoaded = true; - this.isSearching = false; + this.isLoaded = true + this.isSearching = false this.volume_page.volume_list.forEach((vol: Volume): void => { if (vol.volume_status !== VolumeStates.NOT_FOUND && vol.volume_status !== VolumeStates.MIGRATED) { - this.check_status_loop(vol); + this.check_status_loop(vol) } - }); - this.storageSize = new UntypedFormControl({ defaultValue: 1 }, this.checkAvailableVolumeSpaceForCreation()); - }), - ); + }) + this.storageSize = new UntypedFormControl({ defaultValue: 1 }, this.checkAvailableVolumeSpaceForCreation()) + }) + ) } checkAvailableVolumeSpaceForCreation(): ValidatorFn { - return (control: AbstractControl): { [key: string]: any } | null => (control.value > 0 && this.selectedProjectDiskSpaceSum <= this.selectedProjectDiskspaceMax - ? null - : { wrongNumber: control.value }); + return (control: AbstractControl): { [key: string]: any } | null => + control.value > 0 && this.selectedProjectDiskSpaceSum <= this.selectedProjectDiskspaceMax + ? null + : { wrongNumber: control.value } } async updateVolume(volume: Volume): Promise { - const created: boolean = volume.volume_created_by_user; + const created: boolean = volume.volume_created_by_user - const vol: Volume = this.get_volume_from_list_by_id(volume.volume_openstackid); - const updated_volume: Volume = await lastValueFrom(this.vmService.getVolumeById(vol.volume_openstackid)); - const idx: number = this.volume_page.volume_list.indexOf(vol); - updated_volume.volume_created_by_user = created; - this.volume_page.volume_list[idx] = updated_volume; + const vol: Volume = this.get_volume_from_list_by_id(volume.volume_openstackid) + const updated_volume: Volume = await lastValueFrom(this.vmService.getVolumeById(vol.volume_openstackid)) + const idx: number = this.volume_page.volume_list.indexOf(vol) + updated_volume.volume_created_by_user = created + this.volume_page.volume_list[idx] = updated_volume } get_volume_from_list_by_id(openstack_id: string): Volume { for (const volume of this.volume_page.volume_list) { if (volume.volume_openstackid === openstack_id) { - return volume; + return volume } } - return null; + return null } - // eslint-disable-next-line default-param-last + check_status_loop( volume: Volume, initial_timeout: number = this.checkStatusTimeout, final_state?: string, - expected_storage?: number, + expected_storage?: number ): void { setTimeout( - // eslint-disable-next-line consistent-return + async (): Promise => { - await this.updateVolume(volume); - const updated_volume: Volume = this.get_volume_from_list_by_id(volume.volume_openstackid); + await this.updateVolume(volume) + const updated_volume: Volume = this.get_volume_from_list_by_id(volume.volume_openstackid) - // eslint-disable-next-line consistent-return + if (expected_storage && updated_volume.volume_storage !== expected_storage) { - return this.check_status_loop(volume, this.checkStatusTimeout, final_state, expected_storage); + return this.check_status_loop(volume, this.checkStatusTimeout, final_state, expected_storage) } else if (expected_storage && updated_volume.volume_storage === expected_storage) { - this.extendDone = true; + this.extendDone = true } if (volume.error_msg !== '' && volume.error_msg !== undefined && volume.error_msg !== null) { - updated_volume.error_msg = volume.error_msg; + updated_volume.error_msg = volume.error_msg setTimeout((): void => { - updated_volume.error_msg = null; - }, 5000); + updated_volume.error_msg = null + }, 5000) } if ( - this.VOLUME_END_STATES.indexOf(updated_volume.volume_status) === -1 - && final_state - && final_state !== updated_volume.volume_status + this.VOLUME_END_STATES.indexOf(updated_volume.volume_status) === -1 && + final_state && + final_state !== updated_volume.volume_status ) { - this.check_status_loop(volume, this.checkStatusTimeout, final_state); + this.check_status_loop(volume, this.checkStatusTimeout, final_state) } }, - initial_timeout, - ); + initial_timeout + ) } /** @@ -725,9 +725,9 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit getUserApprovedProjects(): void { this.groupService.getSimpleVmByUser().subscribe((membergroups: any): void => { for (const project of membergroups) { - this.projects.push(project); + this.projects.push(project) } - }); + }) } /** @@ -737,7 +737,7 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit * @returns */ setRequestStatus(status: number): void { - this.request_status = status; + this.request_status = status } /** @@ -747,35 +747,36 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit * @returns */ setSelectedVolume(volume: Volume): void { - this.selected_volume = volume; + this.selected_volume = volume } /** * Calc volumeStorage sum of selected project volumeStorage and additional volumeStorage of new volume. */ calcDiskSpaceSum(): void { - this.selectedProjectDiskSpaceSum = parseInt(this.diskspace.toString(), 10) + parseInt(this.selectedProjectDiskspaceUsed.toString(), 10); + this.selectedProjectDiskSpaceSum = + parseInt(this.diskspace.toString(), 10) + parseInt(this.selectedProjectDiskspaceUsed.toString(), 10) } getSelectedVolumeStorage(): void { - this.setSelectedProjectByVolume(this.selected_volume); - this.selected_volume_data_loaded = false; + this.setSelectedProjectByVolume(this.selected_volume) + this.selected_volume_data_loaded = false forkJoin( this.groupService.getGroupMaxDiskspace(this.selectedProject[1].toString()), - this.groupService.getGroupUsedDiskspace(this.selectedProject[1].toString()), + this.groupService.getGroupUsedDiskspace(this.selectedProject[1].toString()) ).subscribe((result: any): void => { if (result[0]['value']) { - this.selectedProjectDiskspaceMax = result[0]['value']; + this.selectedProjectDiskspaceMax = result[0]['value'] } else { - this.selectedProjectDiskspaceMax = 0; + this.selectedProjectDiskspaceMax = 0 } if (result[1]['value']) { - this.selectedProjectDiskspaceUsed = result[1]['value']; + this.selectedProjectDiskspaceUsed = result[1]['value'] } else { - this.selectedProjectDiskspaceUsed = 0; + this.selectedProjectDiskspaceUsed = 0 } - this.selected_volume_data_loaded = true; - }); + this.selected_volume_data_loaded = true + }) } /** @@ -788,20 +789,20 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit .getGroupMaxDiskspace(this.selectedProject[1].toString()) .subscribe((result: IResponseTemplate): void => { if (result.value) { - this.selectedProjectDiskspaceMax = result.value as number; + this.selectedProjectDiskspaceMax = result.value as number } else { - this.selectedProjectDiskspaceMax = 0; + this.selectedProjectDiskspaceMax = 0 } - }); + }) this.groupService .getGroupUsedDiskspace(this.selectedProject[1].toString()) .subscribe((result: IResponseTemplate): void => { if (result.value) { - this.selectedProjectDiskspaceUsed = result.value as number; + this.selectedProjectDiskspaceUsed = result.value as number } else { - this.selectedProjectDiskspaceUsed = 0; + this.selectedProjectDiskspaceUsed = 0 } - }); + }) } /** @@ -814,20 +815,20 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit .getVolumeCounter(this.selectedProject[1].toString()) .subscribe((result: IResponseTemplate): void => { if (result.value) { - this.selectedProjectVolumesMax = result.value as number; + this.selectedProjectVolumesMax = result.value as number } else { - this.selectedProjectVolumesMax = 0; + this.selectedProjectVolumesMax = 0 } - }); + }) this.groupService .getVolumesUsed(this.selectedProject[1].toString()) .subscribe((result: IResponseTemplate): void => { if (result.value) { - this.selectedProjectVolumesUsed = result.value as number; + this.selectedProjectVolumesUsed = result.value as number } else { - this.selectedProjectVolumesUsed = 0; + this.selectedProjectVolumesUsed = 0 } - }); + }) } /** @@ -838,7 +839,7 @@ export class VolumeOverviewComponent extends AbstractBaseClass implements OnInit */ getActiveVmsByProject(groupid: number | string): void { this.vmService.getActiveVmsByProject(groupid.toString()).subscribe((result: any): void => { - this.project_vms = result; - }); + this.project_vms = result + }) } } diff --git a/src/app/virtualmachines/volumes/volume_states.ts b/src/app/virtualmachines/volumes/volume_states.ts index 66d6b540f0..25b48f6700 100644 --- a/src/app/virtualmachines/volumes/volume_states.ts +++ b/src/app/virtualmachines/volumes/volume_states.ts @@ -1,24 +1,24 @@ -import { GeneralStatusStates } from '../../shared/shared_modules/baseClass/statusstates'; +import { GeneralStatusStates } from '../../shared/shared_modules/baseClass/statusstates' /** * VolumeStates class. */ export class VolumeStates extends GeneralStatusStates { - private static readonly _IN_USE: string = 'IN-USE'; - private static readonly _RESERVED: string = 'RESERVED'; - private static readonly _AVAILABLE: string = 'AVAILABLE'; - private static readonly _RESERVED_PLANNED_STATUS: string = 'RESERVED_PLANNED'; - private static readonly _RESERVED_ATTACHED: string = 'RESERVED_ATTACHED'; - private static readonly _DETACHING: string = 'DETACHING'; - private static readonly _ATTACHING: string = 'ATTACHING'; - private static readonly _EXTENDING: string = 'EXTENDING'; + private static readonly _IN_USE: string = 'IN-USE' + private static readonly _RESERVED: string = 'RESERVED' + private static readonly _AVAILABLE: string = 'AVAILABLE' + private static readonly _RESERVED_PLANNED_STATUS: string = 'RESERVED_PLANNED' + private static readonly _RESERVED_ATTACHED: string = 'RESERVED_ATTACHED' + private static readonly _DETACHING: string = 'DETACHING' + private static readonly _ATTACHING: string = 'ATTACHING' + private static readonly _EXTENDING: string = 'EXTENDING' private static readonly _IN_PROCESS_STATES: string[] = [ VolumeStates._RESERVED, VolumeStates._DELETING, VolumeStates._DETACHING, - VolumeStates._EXTENDING, - ]; + VolumeStates._EXTENDING + ] private static readonly _NOT_IN_PROCESS_STATES: string[] = [ VolumeStates._IN_USE, @@ -26,8 +26,8 @@ export class VolumeStates extends GeneralStatusStates { VolumeStates._NOT_FOUND, VolumeStates._ERROR, VolumeStates._DELETED, - VolumeStates._MIGRATED, - ]; + VolumeStates._MIGRATED + ] private static readonly _NO_ACTIONS: string[] = [ VolumeStates._DETACHING, @@ -39,90 +39,90 @@ export class VolumeStates extends GeneralStatusStates { VolumeStates._CREATING, VolumeStates._RESERVED_PLANNED_STATUS, VolumeStates._EXTENDING, - VolumeStates._DELETED, - ]; + VolumeStates._DELETED + ] static get RESERVED_PLANNED_STATUS(): string { - return this._RESERVED_PLANNED_STATUS; + return this._RESERVED_PLANNED_STATUS } static get RESERVED_ATTACHED(): string { - return this._RESERVED_ATTACHED; + return this._RESERVED_ATTACHED } static get IN_USE(): string { - return this._IN_USE; + return this._IN_USE } static get RESERVED(): string { - return this._RESERVED; + return this._RESERVED } static get AVAILABLE(): string { - return this._AVAILABLE; + return this._AVAILABLE } static get IN_PROCESS_STATES(): string[] { - return this._IN_PROCESS_STATES; + return this._IN_PROCESS_STATES } static get NOT_IN_PROCESS_STATES(): string[] { - return this._NOT_IN_PROCESS_STATES; + return this._NOT_IN_PROCESS_STATES } static get DETACHING(): string { - return this._DETACHING; + return this._DETACHING } static get ATTACHING(): string { - return this._ATTACHING; + return this._ATTACHING } static get NO_ACTIONS(): string[] { - return this._NO_ACTIONS; + return this._NO_ACTIONS } static get EXTENDING(): string { - return this._EXTENDING; + return this._EXTENDING } public get staticRESERVED_ATTACHED(): string { - return VolumeStates.RESERVED_ATTACHED; + return VolumeStates.RESERVED_ATTACHED } public get staticNO_ACTIONS(): string[] { - return VolumeStates.NO_ACTIONS; + return VolumeStates.NO_ACTIONS } public get staticRESERVED(): string { - return VolumeStates.RESERVED; + return VolumeStates.RESERVED } public get staticDETACHING(): string { - return VolumeStates.DETACHING; + return VolumeStates.DETACHING } public get staticATTACHING(): string { - return VolumeStates.ATTACHING; + return VolumeStates.ATTACHING } public get staticIN_USE(): string { - return VolumeStates.IN_USE; + return VolumeStates.IN_USE } public get staticAVAILABLE(): string { - return VolumeStates.AVAILABLE; + return VolumeStates.AVAILABLE } public get staticNOT_IN_PROCESS_STATE(): string[] { - return VolumeStates.NOT_IN_PROCESS_STATES; + return VolumeStates.NOT_IN_PROCESS_STATES } public get staticRESERVED_PLANNED(): string { - return VolumeStates.RESERVED_PLANNED_STATUS; + return VolumeStates.RESERVED_PLANNED_STATUS } public get staticEXTENDING(): string { - return VolumeStates.EXTENDING; + return VolumeStates.EXTENDING } } diff --git a/src/app/virtualmachines/workshop/add-workshop/add-workshop.component.ts b/src/app/virtualmachines/workshop/add-workshop/add-workshop.component.ts index fa80bf2895..90ba88e0a4 100644 --- a/src/app/virtualmachines/workshop/add-workshop/add-workshop.component.ts +++ b/src/app/virtualmachines/workshop/add-workshop/add-workshop.component.ts @@ -1,30 +1,26 @@ -import { - Component, DoCheck, OnDestroy, OnInit, ViewChild, inject, -} from '@angular/core'; -import { Subscription } from 'rxjs'; -import { KeyValue } from '@angular/common'; -import transliterate from '@sindresorhus/transliterate'; -import { Router } from '@angular/router'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { Workshop } from '../workshop.model'; -import { Userinfo } from '../../../userinfo/userinfo.model'; -import { GroupService } from '../../../api-connector/group.service'; -import { Client } from '../../../vo_manager/clients/client.model'; -import { BlockedImageTagResenv } from '../../../facility_manager/image-tag'; -import { ImageService } from '../../../api-connector/image.service'; -import { ApplicationRessourceUsage } from '../../../applications/application-ressource-usage/application-ressource-usage'; -import { Flavor } from '../../virtualmachinemodels/flavor'; -import { Image } from '../../virtualmachinemodels/image'; -import { FlavorService } from '../../../api-connector/flavor.service'; -import { UserService } from '../../../api-connector/user.service'; -import { ResEnvComponent } from '../../conda/res-env.component'; -import { ProjectMember } from '../../../projectmanagement/project_member.model'; -import { - CLOUD_PORTAL_SUPPORT_MAIL, STATUS_LINK, WIKI_WORKSHOPS, WIKI_EPHEMERAL_LINK, -} from '../../../../links/links'; -import { VirtualmachineService } from '../../../api-connector/virtualmachine.service'; -import { WorkshopService } from '../../../api-connector/workshop.service'; -import { BiocondaService } from '../../../api-connector/bioconda.service'; +import { Component, DoCheck, OnDestroy, OnInit, ViewChild, inject } from '@angular/core' +import { Subscription } from 'rxjs' +import { KeyValue } from '@angular/common' +import transliterate from '@sindresorhus/transliterate' +import { Router } from '@angular/router' +import { MatomoTracker } from 'ngx-matomo-client' +import { Workshop } from '../workshop.model' +import { Userinfo } from '../../../userinfo/userinfo.model' +import { GroupService } from '../../../api-connector/group.service' +import { Client } from '../../../vo_manager/clients/client.model' +import { BlockedImageTagResenv } from '../../../facility_manager/image-tag' +import { ImageService } from '../../../api-connector/image.service' +import { ApplicationRessourceUsage } from '../../../applications/application-ressource-usage/application-ressource-usage' +import { Flavor } from '../../virtualmachinemodels/flavor' +import { Image } from '../../virtualmachinemodels/image' +import { FlavorService } from '../../../api-connector/flavor.service' +import { UserService } from '../../../api-connector/user.service' +import { ResEnvComponent } from '../../conda/res-env.component' +import { ProjectMember } from '../../../projectmanagement/project_member.model' +import { CLOUD_PORTAL_SUPPORT_MAIL, STATUS_LINK, WIKI_WORKSHOPS, WIKI_EPHEMERAL_LINK } from '../../../../links/links' +import { VirtualmachineService } from '../../../api-connector/virtualmachine.service' +import { WorkshopService } from '../../../api-connector/workshop.service' +import { BiocondaService } from '../../../api-connector/bioconda.service' @Component({ selector: 'app-add-workshop', @@ -37,88 +33,88 @@ import { BiocondaService } from '../../../api-connector/bioconda.service'; UserService, VirtualmachineService, WorkshopService, - BiocondaService, - ], + BiocondaService + ] }) export class AddWorkshopComponent implements OnInit, OnDestroy, DoCheck { - private readonly tracker = inject(MatomoTracker); - title: string = 'New workshop VMs'; + private readonly tracker = inject(MatomoTracker) + title: string = 'New workshop VMs' - WIKI_WORKSHOPS: string = WIKI_WORKSHOPS; - STATUS_LINK: string = STATUS_LINK; - WIKI_EPHEMERAL_LINK: string = WIKI_EPHEMERAL_LINK; + WIKI_WORKSHOPS: string = WIKI_WORKSHOPS + STATUS_LINK: string = STATUS_LINK + WIKI_EPHEMERAL_LINK: string = WIKI_EPHEMERAL_LINK /** * The selected workshop. */ - selected_workshop: Workshop; + selected_workshop: Workshop /** * List of all workshops. */ - workshops: Workshop[] = []; + workshops: Workshop[] = [] /** * If all needed data is loaded. */ - is_loaded: boolean = false; + is_loaded: boolean = false /** * Userinfo of the user who wants to start a workshop. */ - userinfo: Userinfo; + userinfo: Userinfo /** * All simplevm application with workshop set to true where user is admin. */ - projects: [string, number][] = []; + projects: [string, number][] = [] /** * Selected Application for workshops. */ - selected_project: [string, number]; + selected_project: [string, number] /** * Subscription object. */ - subscription: Subscription = new Subscription(); + subscription: Subscription = new Subscription() /** * If the client for a project is viable. */ - client_available: boolean = false; + client_available: boolean = false /** * If all project data is loaded. */ - @ViewChild('res_env') res_env_component: ResEnvComponent; - resenv_selected: boolean = false; - res_env_valid: boolean = true; - res_env_needs_template: boolean = false; - res_env_okay_needed: boolean = false; - gave_okay: boolean = false; - project_data_loaded: boolean = false; - credits_allowed: boolean = false; - new_cores: number = 0; - new_ram: number = 0; - new_gpus: number = 0; - new_vms: number = 0; - client_checked: boolean = false; - selected_project_client: Client; - blocked_image_tags_resenv: BlockedImageTagResenv[]; - has_forc: boolean = false; - forc_url: string = ''; - flavors: Flavor[] = []; - selected_flavor: Flavor = undefined; - flavors_loaded: boolean = false; - - selected_image: Image = undefined; - data_loaded: boolean = false; - selected_project_ressources: ApplicationRessourceUsage; - selected_flavor_type: string = 'Standard Flavors'; - flavor_types: { [name: string]: Flavor[] } = {}; - workshop_data_loaded: boolean = false; - members_to_add: ProjectMember[] = []; - project_members: ProjectMember[] = []; - member_data_loaded: boolean = false; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - vm_responsibility: boolean = false; - started_machine: boolean = false; - progress_bar_animated: string = 'progress-bar-animated'; - progress_bar_width: number = 0; - resenv_names: string[] = []; + @ViewChild('res_env') res_env_component: ResEnvComponent + resenv_selected: boolean = false + res_env_valid: boolean = true + res_env_needs_template: boolean = false + res_env_okay_needed: boolean = false + gave_okay: boolean = false + project_data_loaded: boolean = false + credits_allowed: boolean = false + new_cores: number = 0 + new_ram: number = 0 + new_gpus: number = 0 + new_vms: number = 0 + client_checked: boolean = false + selected_project_client: Client + blocked_image_tags_resenv: BlockedImageTagResenv[] + has_forc: boolean = false + forc_url: string = '' + flavors: Flavor[] = [] + selected_flavor: Flavor = undefined + flavors_loaded: boolean = false + + selected_image: Image = undefined + data_loaded: boolean = false + selected_project_ressources: ApplicationRessourceUsage + selected_flavor_type: string = 'Standard Flavors' + flavor_types: { [name: string]: Flavor[] } = {} + workshop_data_loaded: boolean = false + members_to_add: ProjectMember[] = [] + project_members: ProjectMember[] = [] + member_data_loaded: boolean = false + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + vm_responsibility: boolean = false + started_machine: boolean = false + progress_bar_animated: string = 'progress-bar-animated' + progress_bar_width: number = 0 + resenv_names: string[] = [] constructor( private group_service: GroupService, @@ -128,47 +124,47 @@ export class AddWorkshopComponent implements OnInit, OnDestroy, DoCheck { private virtual_machine_service: VirtualmachineService, private workshop_service: WorkshopService, private router: Router, - private condaService: BiocondaService, + private condaService: BiocondaService ) { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { - this.tracker.trackPageView('New Workshop'); - this.get_applications(); - this.get_user_data(); + this.tracker.trackPageView('New Workshop') + this.get_applications() + this.get_user_data() } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } ngDoCheck(): void { if (this.res_env_component) { - this.res_env_valid = this.res_env_component.isValid(); - this.res_env_needs_template = this.res_env_component.needsTemplate(); - this.res_env_okay_needed = this.res_env_component.okayNeeded(); + this.res_env_valid = this.res_env_component.isValid() + this.res_env_needs_template = this.res_env_component.needsTemplate() + this.res_env_okay_needed = this.res_env_component.okayNeeded() } } get_applications(): void { - this.projects = []; + this.projects = [] this.subscription.add( this.group_service.getSimpleVmByUserWhereWorkshopAndAdmin().subscribe((projects: any) => { for (const project of projects) { - this.projects.push(project); + this.projects.push(project) } - this.is_loaded = true; - }), - ); + this.is_loaded = true + }) + ) } get_user_data(): void { this.subscription.add( this.user_service.getUserInfo().subscribe((result: Userinfo) => { - this.userinfo = result; - }), - ); + this.userinfo = result + }) + ) } get_members_of_the_project(): void { @@ -176,56 +172,56 @@ export class AddWorkshopComponent implements OnInit, OnDestroy, DoCheck { this.group_service .getGroupMembers(this.selected_project[1].toString()) .subscribe((members: ProjectMember[]): void => { - this.project_members = members; - this.member_data_loaded = true; - this.check_project_data_loaded(); - }), - ); + this.project_members = members + this.member_data_loaded = true + this.check_project_data_loaded() + }) + ) } get_selected_project_client(): void { this.subscription.add( this.group_service.getCreditsAllowedByPerunId(this.selected_project[1]).subscribe((res: any): void => { - this.credits_allowed = res['credits_allowed']; - }), - ); + this.credits_allowed = res['credits_allowed'] + }) + ) this.subscription.add( this.group_service.getClient(this.selected_project[1].toString()).subscribe((client: Client): void => { - this.load_project_data(); + this.load_project_data() if (client.status && client.status === 'Connected' && client.activated) { - this.client_available = true; - this.client_checked = true; - this.get_forc(); + this.client_available = true + this.client_checked = true + this.get_forc() } else { - this.client_available = false; - this.client_checked = true; + this.client_available = false + this.client_checked = true } - this.selected_project_client = client; + this.selected_project_client = client this.subscription.add( this.image_service .getBlockedImageTagsResenv(Number(this.selected_project_client.id), 'true') .subscribe((tags: BlockedImageTagResenv[]): void => { - this.blocked_image_tags_resenv = tags; - }), - ); - }), - ); + this.blocked_image_tags_resenv = tags + }) + ) + }) + ) } get_workshops_for_application(): void { - this.workshops = []; + this.workshops = [] this.subscription.add( this.workshop_service.getWorkshops(this.selected_project[1]).subscribe((workshops: Workshop[]) => { for (const workshop of workshops) { this.subscription.add( this.workshop_service.loadWorkshopWithVms(workshop.id).subscribe((workshop_with_vms: Workshop) => { - this.workshops.push(workshop_with_vms); - }), - ); + this.workshops.push(workshop_with_vms) + }) + ) } - }), - ); + }) + ) } load_project_data(): void { @@ -233,64 +229,64 @@ export class AddWorkshopComponent implements OnInit, OnDestroy, DoCheck { this.group_service .getGroupResources(this.selected_project[1].toString()) .subscribe((res: ApplicationRessourceUsage): void => { - this.selected_project_ressources = new ApplicationRessourceUsage(res); - this.data_loaded = true; - this.check_project_data_loaded(); - }), - ); - this.get_flavors(this.selected_project[1]); - this.get_members_of_the_project(); + this.selected_project_ressources = new ApplicationRessourceUsage(res) + this.data_loaded = true + this.check_project_data_loaded() + }) + ) + this.get_flavors(this.selected_project[1]) + this.get_members_of_the_project() } get_forc(): void { this.subscription.add( this.group_service.getClientForcUrl(this.selected_project[1].toString()).subscribe((response: JSON): void => { if (response['forc_url'] !== null) { - this.has_forc = true; - this.forc_url = response['forc_url']; + this.has_forc = true + this.forc_url = response['forc_url'] } - }), - ); + }) + ) } get_flavors(id: number): void { this.subscription.add( this.flavor_service.getFlavors(id).subscribe( (flavors: Flavor[]): void => { - this.flavors = flavors; - this.flavor_types = this.flavor_service.sortFlavors(this.flavors); - this.flavors_loaded = true; - this.check_project_data_loaded(); + this.flavors = flavors + this.flavor_types = this.flavor_service.sortFlavors(this.flavors) + this.flavors_loaded = true + this.check_project_data_loaded() }, (error: any) => { - console.log(error); - this.flavors = []; - this.flavor_types = {}; - this.flavors_loaded = true; - this.check_project_data_loaded(); - }, - ), - ); + console.log(error) + this.flavors = [] + this.flavor_types = {} + this.flavors_loaded = true + this.check_project_data_loaded() + } + ) + ) } check_project_data_loaded(): void { if (this.flavors_loaded && this.data_loaded && this.member_data_loaded) { - this.project_data_loaded = true; - this.is_loaded = true; + this.project_data_loaded = true + this.is_loaded = true } } set_selected_workshop(workshop: Workshop): void { - this.selected_workshop = workshop; - this.workshop_data_loaded = true; + this.selected_workshop = workshop + this.workshop_data_loaded = true for (const member of this.project_members) { - member.vm_amount = 0; - member.hasVM = false; + member.vm_amount = 0 + member.hasVM = false for (const workshopvm of this.selected_workshop.vm_list) { if (member.elixirId === workshopvm.elixirid) { - member.hasVM = true; - member.vm_amount += 1; + member.hasVM = true + member.vm_amount += 1 } } } @@ -298,38 +294,38 @@ export class AddWorkshopComponent implements OnInit, OnDestroy, DoCheck { // eslint-disable-next-line @typescript-eslint/no-unused-vars unsorted(a: KeyValue, b: KeyValue): number { - return 0; + return 0 } set_selected_flavor_type(key: string): void { - this.selected_flavor_type = key; + this.selected_flavor_type = key } set_selected_flavor(flavor: Flavor): void { - this.selected_flavor = flavor; - this.new_cores = this.selected_flavor.vcpus; - this.new_ram = this.selected_flavor.ram_gib; - this.new_gpus = this.selected_flavor.gpu; + this.selected_flavor = flavor + this.new_cores = this.selected_flavor.vcpus + this.new_ram = this.selected_flavor.ram_gib + this.new_gpus = this.selected_flavor.gpu } set_selected_image(image: Image): void { - this.selected_image = image; - this.has_image_resenv(); + this.selected_image = image + this.has_image_resenv() } has_image_resenv(): void { for (const mode of this.selected_image.modes) { for (const template of this.res_env_component.templates) { if (template.template_name === mode.name) { - this.resenv_selected = true; - this.res_env_component.setOnlyNamespace(template); + this.resenv_selected = true + this.res_env_component.setOnlyNamespace(template) - return; + return } } } - this.resenv_selected = false; - this.res_env_component.unsetOnlyNamespace(); + this.resenv_selected = false + this.res_env_component.unsetOnlyNamespace() } get_playbook_information(name: string): string { @@ -337,16 +333,16 @@ export class AddWorkshopComponent implements OnInit, OnDestroy, DoCheck { [name: string]: { [variable: string]: string } - } = {}; + } = {} if (this.res_env_component && this.res_env_component.selectedTemplate.template_name !== 'undefined') { playbook_info[this.res_env_component.selectedTemplate.template_name] = { - create_only_backend: `${this.res_env_component.getCreateOnlyBackend()}`, - }; - playbook_info['user_key_url'] = { user_key_url: name }; + create_only_backend: `${this.res_env_component.getCreateOnlyBackend()}` + } + playbook_info['user_key_url'] = { user_key_url: name } } - return JSON.stringify(playbook_info); + return JSON.stringify(playbook_info) } /** @@ -356,36 +352,36 @@ export class AddWorkshopComponent implements OnInit, OnDestroy, DoCheck { * @param user_name Name to append to workshop shortname. */ create_name(user_name: string): string { - let name: string = `${this.selected_workshop.shortname}${user_name}`; - name = transliterate(name); - name = name.replace(/[^a-zA-Z0-9]/g, ''); - name = name.slice(0, 25); + let name: string = `${this.selected_workshop.shortname}${user_name}` + name = transliterate(name) + name = name.replace(/[^a-zA-Z0-9]/g, '') + name = name.slice(0, 25) - return name; + return name } start_vms(): void { - this.started_machine = true; - const servers: { [key: string]: string }[] = []; - const re: RegExp = /\+/gi; - const flavor_fixed: string = this.selected_flavor.name.replace(re, '%2B'); + this.started_machine = true + const servers: { [key: string]: string }[] = [] + const re: RegExp = /\+/gi + const flavor_fixed: string = this.selected_flavor.name.replace(re, '%2B') for (const member of this.members_to_add) { - const name: string = this.create_name(`${member.lastName}${member.firstName}`); + const name: string = this.create_name(`${member.lastName}${member.firstName}`) // Playbook and Research-Environment stuff - const playbook_information: string = this.get_playbook_information(name); + const playbook_information: string = this.get_playbook_information(name) servers.push({ name, playbook_information, elixirId: member.elixirId, - userName: `${member.lastName}${member.firstName}`, - }); + userName: `${member.lastName}${member.firstName}` + }) } this.delay(500) .then((): any => { - this.progress_bar_width = 50; + this.progress_bar_width = 50 }) - .catch((): any => {}); + .catch((): any => {}) this.subscription.add( this.virtual_machine_service .startWorkshopVMs( @@ -394,82 +390,82 @@ export class AddWorkshopComponent implements OnInit, OnDestroy, DoCheck { servers, this.selected_project[0], this.selected_project[1].toString(), - this.selected_workshop.shortname, + this.selected_workshop.shortname ) .subscribe( () => { - this.progress_bar_width = 75; + this.progress_bar_width = 75 setTimeout((): void => { - void this.router.navigate(['/virtualmachines/vmOverview']).then().catch(); - }, 2000); + void this.router.navigate(['/virtualmachines/vmOverview']).then().catch() + }, 2000) }, (error: any) => { - console.log(error); - }, - ), - ); + console.log(error) + } + ) + ) } async delay(ms: number): Promise { - // eslint-disable-next-line no-promise-executor-return - await new Promise((resolve: any): any => setTimeout(resolve, ms)); + + await new Promise((resolve: any): any => setTimeout(resolve, ms)) } add_member(member: ProjectMember): void { - this.members_to_add.push(member); + this.members_to_add.push(member) } remove_member(member: ProjectMember): void { - this.members_to_add.splice(this.members_to_add.indexOf(member), 1); + this.members_to_add.splice(this.members_to_add.indexOf(member), 1) } reset_all_data(): void { - this.selected_project = null; - this.selected_workshop = null; - this.workshops = []; - this.reset_on_project_change(); - this.reset_on_workshop_change(); + this.selected_project = null + this.selected_workshop = null + this.workshops = [] + this.reset_on_project_change() + this.reset_on_workshop_change() } reset_on_project_change(): void { - this.reset_on_workshop_change(); - this.has_forc = false; - this.forc_url = ''; - this.selected_project_client = null; - this.client_checked = false; - this.client_available = false; - this.project_data_loaded = false; - this.flavors = []; - this.data_loaded = false; - this.flavors_loaded = false; - this.selected_workshop = null; - this.credits_allowed = false; - this.project_members = []; - this.member_data_loaded = false; - this.selected_project_ressources = null; - this.flavor_types = {}; + this.reset_on_workshop_change() + this.has_forc = false + this.forc_url = '' + this.selected_project_client = null + this.client_checked = false + this.client_available = false + this.project_data_loaded = false + this.flavors = [] + this.data_loaded = false + this.flavors_loaded = false + this.selected_workshop = null + this.credits_allowed = false + this.project_members = [] + this.member_data_loaded = false + this.selected_project_ressources = null + this.flavor_types = {} } reset_on_workshop_change(): void { - this.new_cores = 0; - this.new_gpus = 0; - this.new_ram = 0; - this.new_vms = 0; - this.workshop_data_loaded = false; - this.selected_image = undefined; - this.selected_flavor = undefined; - this.selected_flavor_type = 'Standard Flavors'; - this.members_to_add = []; - this.vm_responsibility = false; - this.started_machine = false; - this.resenv_selected = false; - this.res_env_valid = true; - this.res_env_needs_template = false; - this.res_env_okay_needed = false; - this.gave_okay = false; - this.progress_bar_width = 0; + this.new_cores = 0 + this.new_gpus = 0 + this.new_ram = 0 + this.new_vms = 0 + this.workshop_data_loaded = false + this.selected_image = undefined + this.selected_flavor = undefined + this.selected_flavor_type = 'Standard Flavors' + this.members_to_add = [] + this.vm_responsibility = false + this.started_machine = false + this.resenv_selected = false + this.res_env_valid = true + this.res_env_needs_template = false + this.res_env_okay_needed = false + this.gave_okay = false + this.progress_bar_width = 0 if (this.res_env_component) { - this.res_env_component.resetData(); + this.res_env_component.resetData() } } } diff --git a/src/app/virtualmachines/workshop/workshop-overview/workshop-overview.component.ts b/src/app/virtualmachines/workshop/workshop-overview/workshop-overview.component.ts index 6f9db57913..58d80657c4 100644 --- a/src/app/virtualmachines/workshop/workshop-overview/workshop-overview.component.ts +++ b/src/app/virtualmachines/workshop/workshop-overview/workshop-overview.component.ts @@ -1,16 +1,14 @@ -import { - Component, OnInit, OnDestroy, ViewChild, inject, -} from '@angular/core'; -import { Subscription } from 'rxjs'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { Workshop } from '../workshop.model'; -import { GroupService } from '../../../api-connector/group.service'; -import { UrlData } from '../workshop-urlinfo.model'; -import { WorkshopService } from '../../../api-connector/workshop.service'; -import { ProjectMember } from '../../../projectmanagement/project_member.model'; -import { WorkshopVM } from '../workshop-vm.model'; -import { WIKI_WORKSHOPS, CLOUD_PORTAL_SUPPORT_MAIL, LIFESCIENCE_HOSTEL_SIGNUP } from '../../../../links/links'; -import { WorkshopTimeFrame } from '../workshopTimeFrame.model'; +import { Component, OnInit, OnDestroy, ViewChild, inject } from '@angular/core' +import { Subscription } from 'rxjs' +import { MatomoTracker } from 'ngx-matomo-client' +import { Workshop } from '../workshop.model' +import { GroupService } from '../../../api-connector/group.service' +import { UrlData } from '../workshop-urlinfo.model' +import { WorkshopService } from '../../../api-connector/workshop.service' +import { ProjectMember } from '../../../projectmanagement/project_member.model' +import { WorkshopVM } from '../workshop-vm.model' +import { WIKI_WORKSHOPS, CLOUD_PORTAL_SUPPORT_MAIL, LIFESCIENCE_HOSTEL_SIGNUP } from '../../../../links/links' +import { WorkshopTimeFrame } from '../workshopTimeFrame.model' interface MemberVm { projectMember: ProjectMember @@ -21,306 +19,306 @@ interface MemberVm { selector: 'app-overview', templateUrl: './workshop-overview.component.html', styleUrls: ['./workshop-overview.component.scss'], - providers: [GroupService, WorkshopService], + providers: [GroupService, WorkshopService] }) export class WorkshopOverviewComponent implements OnInit, OnDestroy { - private readonly tracker = inject(MatomoTracker); - title: string = 'Workshop management'; - - @ViewChild('confirmInterferingSlotModal') confirmInterfereModal: any; - - WIKI_WORKSHOPS: string = WIKI_WORKSHOPS; - LIFESCIENCE_HOSTEL_SIGNUP: string = LIFESCIENCE_HOSTEL_SIGNUP; - CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - subscription: Subscription = new Subscription(); - resend_info: boolean = false; - sending_mails = false; - sending_done = false; - newWorkShopTimeFrame: WorkshopTimeFrame = null; - workshops: Workshop[] = []; - selectedWorkshop: Workshop; - memberVms: MemberVm[] = []; - workshopTimeFramesLoaded: boolean = false; - errorLoadingTimeFrames: boolean = false; - workshopTimeFrames: WorkshopTimeFrame[] = []; - loadedVmsForWorkshop: number[] = []; - projects: [string, number][] = []; - selectedProject: [string, number]; - errorMessage: string = null; - isLoaded: boolean = false; - projectWorkshopsLoading: boolean = false; - projectWorkshopsLoaded: boolean = false; - projectMembersLoading: boolean = false; - projectMembersLoaded: boolean = false; - informationTitle: string = ''; - informationType: string = ''; - informationMessage: string = ''; - deleting: boolean = false; - deleteSuccess: boolean = false; - invalidShortname: boolean = true; - invalidLongname: boolean = true; - newWorkshop: boolean = false; - workshopCreationMessage: { message: string; success: boolean } = { message: '', success: false }; - listOfOverlaps: WorkshopTimeFrame[] = []; - - @ViewChild('creationStatusModal') creationStatusModal: any; + private readonly tracker = inject(MatomoTracker) + title: string = 'Workshop management' + + @ViewChild('confirmInterferingSlotModal') confirmInterfereModal: any + + WIKI_WORKSHOPS: string = WIKI_WORKSHOPS + LIFESCIENCE_HOSTEL_SIGNUP: string = LIFESCIENCE_HOSTEL_SIGNUP + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL + subscription: Subscription = new Subscription() + resend_info: boolean = false + sending_mails = false + sending_done = false + newWorkShopTimeFrame: WorkshopTimeFrame = null + workshops: Workshop[] = [] + selectedWorkshop: Workshop + memberVms: MemberVm[] = [] + workshopTimeFramesLoaded: boolean = false + errorLoadingTimeFrames: boolean = false + workshopTimeFrames: WorkshopTimeFrame[] = [] + loadedVmsForWorkshop: number[] = [] + projects: [string, number][] = [] + selectedProject: [string, number] + errorMessage: string = null + isLoaded: boolean = false + projectWorkshopsLoading: boolean = false + projectWorkshopsLoaded: boolean = false + projectMembersLoading: boolean = false + projectMembersLoaded: boolean = false + informationTitle: string = '' + informationType: string = '' + informationMessage: string = '' + deleting: boolean = false + deleteSuccess: boolean = false + invalidShortname: boolean = true + invalidLongname: boolean = true + newWorkshop: boolean = false + workshopCreationMessage: { message: string; success: boolean } = { message: '', success: false } + listOfOverlaps: WorkshopTimeFrame[] = [] + + @ViewChild('creationStatusModal') creationStatusModal: any constructor( private workshopService: WorkshopService, - private groupService: GroupService, + private groupService: GroupService ) { - // eslint-disable-next-line no-empty-function + } ngOnInit(): void { - this.tracker.trackPageView('Workshop Overview'); + this.tracker.trackPageView('Workshop Overview') this.newWorkShopTimeFrame = new WorkshopTimeFrame({ id: null, end_time: new Date(), start_time: new Date(), workshop: new Workshop(), project: null, - description: '', - }); - this.getProjects(); + description: '' + }) + this.getProjects() } ngOnDestroy(): void { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } getProjects(): void { - this.projects = []; + this.projects = [] this.subscription.add( this.groupService.getSimpleVmByUserWhereWorkshopAndAdmin().subscribe((projects: any) => { for (const project of projects) { - this.projects.push(project); + this.projects.push(project) } - this.isLoaded = true; - }), - ); + this.isLoaded = true + }) + ) } projectChange(): void { - this.resetsOnProjectChange(); - this.getWorkshopsForProject(); - this.getMembersOfTheProject(); - this.loadCalenderForSelectedProject(); + this.resetsOnProjectChange() + this.getWorkshopsForProject() + this.getMembersOfTheProject() + this.loadCalenderForSelectedProject() } dayChanged(date: { year: number; month: number; day: number }): void { - this.newWorkShopTimeFrame.start_time.setDate(date.day); - this.newWorkShopTimeFrame.start_time.setMonth(date.month - 1); - this.newWorkShopTimeFrame.start_time.setFullYear(date.year); + this.newWorkShopTimeFrame.start_time.setDate(date.day) + this.newWorkShopTimeFrame.start_time.setMonth(date.month - 1) + this.newWorkShopTimeFrame.start_time.setFullYear(date.year) - this.newWorkShopTimeFrame.end_time.setDate(date.day); - this.newWorkShopTimeFrame.end_time.setMonth(date.month - 1); - this.newWorkShopTimeFrame.end_time.setFullYear(date.year); + this.newWorkShopTimeFrame.end_time.setDate(date.day) + this.newWorkShopTimeFrame.end_time.setMonth(date.month - 1) + this.newWorkShopTimeFrame.end_time.setFullYear(date.year) } startTimeChanged(time: { hour: number; minute: number }): void { - this.newWorkShopTimeFrame.start_time.setHours(time.hour); - this.newWorkShopTimeFrame.start_time.setMinutes(time.minute); + this.newWorkShopTimeFrame.start_time.setHours(time.hour) + this.newWorkShopTimeFrame.start_time.setMinutes(time.minute) } endTimeChanged(time: { hour: number; minute: number }): void { - this.newWorkShopTimeFrame.end_time.setHours(time.hour); - this.newWorkShopTimeFrame.end_time.setMinutes(time.minute); + this.newWorkShopTimeFrame.end_time.setHours(time.hour) + this.newWorkShopTimeFrame.end_time.setMinutes(time.minute) } createNewTimeFrame(): void { if (this.checkTimeFrameOverlap()) { - this.confirmInterfereModal.show(); + this.confirmInterfereModal.show() } else { - this.processAddAfterConfirm(); + this.processAddAfterConfirm() } } datesOverlap(first_start: number, first_end: number, second_start: number, second_end: number): boolean { return ( - (first_start >= second_start && first_start <= second_end) - || (first_end >= second_start && first_end <= second_end) - || (second_start >= first_start && second_start <= first_end) - || (second_end >= first_start && second_end <= first_end) - ); + (first_start >= second_start && first_start <= second_end) || + (first_end >= second_start && first_end <= second_end) || + (second_start >= first_start && second_start <= first_end) || + (second_end >= first_start && second_end <= first_end) + ) } checkTimeFrameOverlap(): boolean { // eslint-disable-next-line prefer-const - let interferingTimeframes: WorkshopTimeFrame[] = []; + let interferingTimeframes: WorkshopTimeFrame[] = [] this.workshopTimeFrames.forEach((wstf: WorkshopTimeFrame) => { - const start_time: number = new Date(wstf.start_time).getTime(); - const end_time: number = new Date(wstf.end_time).getTime(); + const start_time: number = new Date(wstf.start_time).getTime() + const end_time: number = new Date(wstf.end_time).getTime() if ( this.datesOverlap( start_time, end_time, this.newWorkShopTimeFrame.start_time.getTime(), - this.newWorkShopTimeFrame.end_time.getTime(), + this.newWorkShopTimeFrame.end_time.getTime() ) ) { - interferingTimeframes.push(wstf); + interferingTimeframes.push(wstf) } - }); - this.listOfOverlaps = interferingTimeframes; + }) + this.listOfOverlaps = interferingTimeframes - return interferingTimeframes.length > 0; + return interferingTimeframes.length > 0 } processAddAfterConfirm(): void { this.workshopService.addWorkshopTimeFrame(this.selectedProject[1], this.newWorkShopTimeFrame).subscribe({ next: () => { - this.loadCalenderForSelectedProject(); - this.informationTitle = 'Success'; - this.informationType = 'info'; - this.informationMessage = 'The new timeframe got successfully added to the calender!'; + this.loadCalenderForSelectedProject() + this.informationTitle = 'Success' + this.informationType = 'info' + this.informationMessage = 'The new timeframe got successfully added to the calender!' }, error: () => { - this.informationTitle = 'Error'; - this.informationType = 'danger'; - this.informationMessage = 'An error occured while adding the timeframe to the calender!'; - }, - }); + this.informationTitle = 'Error' + this.informationType = 'danger' + this.informationMessage = 'An error occured while adding the timeframe to the calender!' + } + }) } deleteWorkshopTimeFrame(timeframe: WorkshopTimeFrame): void { this.workshopService.removeWorkshopTimeFrame(this.selectedProject[1], timeframe).subscribe({ next: () => { - this.loadCalenderForSelectedProject(); - this.informationTitle = 'Success'; - this.informationType = 'info'; - this.informationMessage = 'The selected timeframe got successfully removed from the calender!'; + this.loadCalenderForSelectedProject() + this.informationTitle = 'Success' + this.informationType = 'info' + this.informationMessage = 'The selected timeframe got successfully removed from the calender!' }, error: () => { - this.informationTitle = 'Error'; - this.informationType = 'danger'; - this.informationMessage = 'An error occured while removing the timeframe from the calender!'; - }, - }); + this.informationTitle = 'Error' + this.informationType = 'danger' + this.informationMessage = 'An error occured while removing the timeframe from the calender!' + } + }) } getWorkshopsForProject(): void { - this.projectWorkshopsLoading = true; + this.projectWorkshopsLoading = true this.subscription.add( this.workshopService.getWorkshops(this.selectedProject[1]).subscribe((workshops: Workshop[]) => { - this.workshops = workshops; - this.selectedWorkshop = new Workshop(); - this.projectWorkshopsLoading = false; - this.projectWorkshopsLoaded = true; - }), - ); + this.workshops = workshops + this.selectedWorkshop = new Workshop() + this.projectWorkshopsLoading = false + this.projectWorkshopsLoaded = true + }) + ) } getMembersOfTheProject(): void { - this.projectMembersLoading = true; - this.memberVms = []; + this.projectMembersLoading = true + this.memberVms = [] this.subscription.add( this.groupService .getWorkshopMembers(this.selectedProject[1].toString()) .subscribe((members: ProjectMember[]): void => { for (const member of members) { - const workshopVmLink: { [key: number]: WorkshopVM[] } = {}; - const membervm: MemberVm = { projectMember: member, workshopVmLink }; - this.memberVms.push(membervm); - this.projectMembersLoading = false; - this.projectMembersLoaded = true; + const workshopVmLink: { [key: number]: WorkshopVM[] } = {} + const membervm: MemberVm = { projectMember: member, workshopVmLink } + this.memberVms.push(membervm) + this.projectMembersLoading = false + this.projectMembersLoaded = true } - }), - ); + }) + ) } workshopChange(workshop: Workshop): void { - this.selectedWorkshop = workshop; - this.newWorkShopTimeFrame = new WorkshopTimeFrame({ workshop: this.selectedWorkshop, start_time: new Date() }); - this.newWorkshop = false; - this.invalidShortname = true; - this.invalidLongname = true; - this.loadVmsForSelectedProject(); + this.selectedWorkshop = workshop + this.newWorkShopTimeFrame = new WorkshopTimeFrame({ workshop: this.selectedWorkshop, start_time: new Date() }) + this.newWorkshop = false + this.invalidShortname = true + this.invalidLongname = true + this.loadVmsForSelectedProject() } loadCalenderForSelectedProject(): void { - this.workshopTimeFramesLoaded = false; + this.workshopTimeFramesLoaded = false this.subscription.add( this.workshopService.loadWorkshopCalender(this.selectedProject[1]).subscribe({ next: (wsTimeFrames: WorkshopTimeFrame[]) => { this.workshopTimeFrames = wsTimeFrames.sort((a, b) => { if (a.start_time < b.start_time) { - return -1; + return -1 } else if (a.start_time > b.start_time) { - return 1; + return 1 } else { - return 0; + return 0 } - }); - this.workshopTimeFramesLoaded = true; - this.errorLoadingTimeFrames = false; + }) + this.workshopTimeFramesLoaded = true + this.errorLoadingTimeFrames = false }, error: () => { - this.workshopTimeFramesLoaded = true; - this.errorLoadingTimeFrames = true; - }, - }), - ); + this.workshopTimeFramesLoaded = true + this.errorLoadingTimeFrames = true + } + }) + ) } loadVmsForSelectedProject(): void { if (this.loadedVmsForWorkshop.includes(this.selectedWorkshop.id)) { - return; + return } this.subscription.add( this.workshopService.loadWorkshopWithVms(this.selectedWorkshop.id).subscribe((workshopIncoming: Workshop) => { for (let workshop of this.workshops) { if (workshop.id === workshopIncoming.id) { - workshop = workshopIncoming; - this.loadedVmsForWorkshop.push(workshop.id); - this.addVmsToProjectMembers(workshop); - this.getUrlDataForWorkshopVms(workshop); + workshop = workshopIncoming + this.loadedVmsForWorkshop.push(workshop.id) + this.addVmsToProjectMembers(workshop) + this.getUrlDataForWorkshopVms(workshop) } } - }), - ); + }) + ) } addVmsToProjectMembers(workshop: Workshop): void { for (const member of this.memberVms) { if (!(workshop.id in member.workshopVmLink)) { - member.workshopVmLink[workshop.id] = []; + member.workshopVmLink[workshop.id] = [] } for (const vm of workshop.vm_list) { if (member.projectMember.elixirId === vm.elixirid) { - member.workshopVmLink[workshop.id].push(vm); + member.workshopVmLink[workshop.id].push(vm) } } } } resetSendingMails(): void { - this.resend_info = false; - this.sending_mails = false; - this.sending_done = false; + this.resend_info = false + this.sending_mails = false + this.sending_done = false } sendWorkshopVMsEmailInfo(): void { - this.sending_mails = true; - this.sending_done = false; - const vms: WorkshopVM[] = []; + this.sending_mails = true + this.sending_done = false + const vms: WorkshopVM[] = [] for (const memberVm of this.memberVms) { for (const wvm of memberVm.workshopVmLink[this.selectedWorkshop.id]) { if (this.resend_info) { - vms.push(wvm); + vms.push(wvm) } else if (!wvm.email_sent) { - vms.push(wvm); + vms.push(wvm) } } } for (const vm of vms) { - this.sendWorkshopVMEMailInfo(vm); + this.sendWorkshopVMEMailInfo(vm) } - this.sending_done = true; - this.sending_mails = false; + this.sending_done = true + this.sending_mails = false } sendWorkshopVMEMailInfo(workshop_vm: WorkshopVM): void { @@ -330,125 +328,125 @@ export class WorkshopOverviewComponent implements OnInit, OnDestroy { for (const memberVm of this.memberVms) { for (const wvm of memberVm.workshopVmLink[this.selectedWorkshop.id]) { if (wvm === workshop_vm) { - const idx: number = memberVm.workshopVmLink[this.selectedWorkshop.id].indexOf(wvm); - memberVm.workshopVmLink[this.selectedWorkshop.id][idx].email_sent = upd_workshop_vm.email_sent; + const idx: number = memberVm.workshopVmLink[this.selectedWorkshop.id].indexOf(wvm) + memberVm.workshopVmLink[this.selectedWorkshop.id][idx].email_sent = upd_workshop_vm.email_sent } } } }, (error: any) => { if ('error' in error) { - console.log(error); + console.log(error) } - }, - ), - ); + } + ) + ) } getUrlDataForWorkshopVms(workshop: Workshop): void { for (const member of this.memberVms) { if (!(workshop.id in member.workshopVmLink)) { - continue; + continue } for (const vm of member.workshopVmLink[workshop.id]) { if (vm.vm.openstackid && vm.vm.openstackid !== '') { - vm.setLoadingUrlData(true); + vm.setLoadingUrlData(true) this.subscription.add( this.workshopService .getResenvUrlForWorkshopVm(workshop.id, vm.vm.openstackid) .subscribe((urlData: UrlData) => { - vm.setLoadingUrlData(false); - vm.setUrlData(urlData); - }), - ); + vm.setLoadingUrlData(false) + vm.setUrlData(urlData) + }) + ) } } } } cleanupWorkshop(): void { - const selectedId = this.selectedWorkshop.id; - this.selectedWorkshop = new Workshop(); - this.deleting = true; + const selectedId = this.selectedWorkshop.id + this.selectedWorkshop = new Workshop() + this.deleting = true this.subscription.add( this.workshopService.deleteWorkshop(selectedId).subscribe((result: boolean) => { - this.deleting = false; + this.deleting = false if (result) { - this.deleteSuccess = true; + this.deleteSuccess = true for (const workshop of this.workshops) { if (workshop.id === selectedId) { - this.workshops.splice(this.workshops.indexOf(workshop), 1); + this.workshops.splice(this.workshops.indexOf(workshop), 1) } } } else { - this.deleteSuccess = false; + this.deleteSuccess = false } - }), - ); + }) + ) } resetsOnProjectChange(): void { - this.projectWorkshopsLoading = false; - this.projectWorkshopsLoaded = false; + this.projectWorkshopsLoading = false + this.projectWorkshopsLoaded = false - this.projectWorkshopsLoading = false; - this.projectMembersLoaded = false; + this.projectWorkshopsLoading = false + this.projectMembersLoaded = false - this.workshops = []; - this.memberVms = []; - this.loadedVmsForWorkshop = []; + this.workshops = [] + this.memberVms = [] + this.loadedVmsForWorkshop = [] - this.newWorkshop = false; - this.invalidLongname = true; - this.invalidShortname = true; + this.newWorkshop = false + this.invalidLongname = true + this.invalidShortname = true } checkShortname(shortname: string): void { - this.invalidShortname = shortname.length < 3 || shortname.length > 8 || !/^[a-zA-Z0-9\s]*$/.test(shortname); + this.invalidShortname = shortname.length < 3 || shortname.length > 8 || !/^[a-zA-Z0-9\s]*$/.test(shortname) } checkLongname(longname: string): void { - this.invalidLongname = longname.length < 3 || longname.length > 256 || !this.isASCII(longname); + this.invalidLongname = longname.length < 3 || longname.length > 256 || !this.isASCII(longname) } isASCII(testString: string): boolean { // eslint-disable-next-line no-control-regex - return /^[\x00-\x7F]*$/.test(testString); + return /^[\x00-\x7F]*$/.test(testString) } blankWorkshop(): void { - this.newWorkshop = true; - this.selectedWorkshop = new Workshop(); + this.newWorkshop = true + this.selectedWorkshop = new Workshop() } createNewWorkshop(): void { - this.selectedWorkshop.shortname = this.selectedWorkshop.shortname.replace(/\s/g, ''); + this.selectedWorkshop.shortname = this.selectedWorkshop.shortname.replace(/\s/g, '') this.subscription.add( this.workshopService.createWorkshop(this.selectedProject[1], this.selectedWorkshop).subscribe( (workshop: Workshop) => { - this.workshops.push(workshop); - this.workshopChange(workshop); - this.workshopCreationMessage = { message: 'Workshop created successfully!', success: true }; - this.creationStatusModal.show(); + this.workshops.push(workshop) + this.workshopChange(workshop) + this.workshopCreationMessage = { message: 'Workshop created successfully!', success: true } + this.creationStatusModal.show() }, (error: any) => { if ('error' in error) { - this.selectedWorkshop.longname = ''; - this.invalidLongname = true; - this.selectedWorkshop.shortname = ''; - this.invalidShortname = true; + this.selectedWorkshop.longname = '' + this.invalidLongname = true + this.selectedWorkshop.shortname = '' + this.invalidShortname = true if (error['error']['error'] === 'unique_constraint') { this.workshopCreationMessage = { message: 'Workshop name already taken! Please select another name.', - success: false, - }; + success: false + } } else { - this.workshopCreationMessage = { message: 'An error occured. Please try again!', success: false }; + this.workshopCreationMessage = { message: 'An error occured. Please try again!', success: false } } - this.creationStatusModal.show(); + this.creationStatusModal.show() } - }, - ), - ); + } + ) + ) } } diff --git a/src/app/vo_manager/VoManager-routing.module.ts b/src/app/vo_manager/VoManager-routing.module.ts index 9f6ca701f9..52f532c5e3 100644 --- a/src/app/vo_manager/VoManager-routing.module.ts +++ b/src/app/vo_manager/VoManager-routing.module.ts @@ -1,11 +1,11 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { VoOverviewComponent } from './VoOverviewComponent'; -import { VoGuardService } from './vo-guard.service'; -import { ResourcesComponent } from './resources/resources.component'; -import { ClientOverviewComponent } from './clients/clientOverview.component'; -import { NumberChartsComponent } from './number-charts/number-charts.component'; -import { MaintenanceComponent } from './maintenance/maintenance.component'; +import { NgModule } from '@angular/core' +import { RouterModule, Routes } from '@angular/router' +import { VoOverviewComponent } from './VoOverviewComponent' +import { VoGuardService } from './vo-guard.service' +import { ResourcesComponent } from './resources/resources.component' +import { ClientOverviewComponent } from './clients/clientOverview.component' +import { NumberChartsComponent } from './number-charts/number-charts.component' +import { MaintenanceComponent } from './maintenance/maintenance.component' const routes: Routes = [ { @@ -13,24 +13,24 @@ const routes: Routes = [ component: VoOverviewComponent, canActivate: [VoGuardService], data: { - title: 'Vo manager overview', - }, + title: 'Vo manager overview' + } }, { path: 'resources', component: ResourcesComponent, canActivate: [VoGuardService], data: { - title: 'Vo Resources', - }, + title: 'Vo Resources' + } }, { path: 'clientsOverview', component: ClientOverviewComponent, canActivate: [VoGuardService], data: { - title: 'Clients', - }, + title: 'Clients' + } }, { @@ -38,8 +38,8 @@ const routes: Routes = [ component: NumberChartsComponent, canActivate: [VoGuardService], data: { - title: 'Cloud Numbers', - }, + title: 'Cloud Numbers' + } }, { @@ -47,16 +47,16 @@ const routes: Routes = [ component: MaintenanceComponent, canActivate: [VoGuardService], data: { - title: 'Maintenance', - }, - }, -]; + title: 'Maintenance' + } + } +] /** * Vo Manager routing module. */ @NgModule({ imports: [RouterModule.forChild(routes)], - exports: [RouterModule], + exports: [RouterModule] }) export class VoManagerRoutingModule {} diff --git a/src/app/vo_manager/VoManager.module.ts b/src/app/vo_manager/VoManager.module.ts index 36123f5286..988e864d7f 100644 --- a/src/app/vo_manager/VoManager.module.ts +++ b/src/app/vo_manager/VoManager.module.ts @@ -1,27 +1,27 @@ -import { NgModule } from '@angular/core'; +import { NgModule } from '@angular/core' -import { TabsModule } from 'ngx-bootstrap/tabs'; +import { TabsModule } from 'ngx-bootstrap/tabs' -import { CommonModule } from '@angular/common'; -import { ModalModule } from 'ngx-bootstrap/modal'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { NgbPaginationModule, NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap'; -import { BadgeComponent, ButtonDirective, InputGroupComponent } from '@coreui/angular'; -import { VoManagerRoutingModule } from './VoManager-routing.module'; -import { VoOverviewComponent } from './VoOverviewComponent'; -import { VoGuardService } from './vo-guard.service'; -import { VoService } from '../api-connector/vo.service'; -import { ResourcesComponent } from './resources/resources.component'; -import { ProjectManagementModule } from '../projectmanagement/projectmanagement.module'; -import { ClientOverviewComponent } from './clients/clientOverview.component'; -import { PipeModuleModule } from '../pipe-module/pipe-module.module'; -import { NumberChartsComponent } from './number-charts/number-charts.component'; -import { ClientLimitsComponent } from './clients/modals/client-limits..component'; -import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module'; -import { MaintenanceComponent } from './maintenance/maintenance.component'; -import { DatePickerComponent } from '../shared/datepicking/datepicker.component'; -import { TimepickerComponent } from '../shared/datepicking/timepicker.component'; -import { SharedModuleModule } from '../shared/shared_modules/shared-module.module'; +import { CommonModule } from '@angular/common' +import { ModalModule } from 'ngx-bootstrap/modal' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { NgbPaginationModule, NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap' +import { BadgeComponent, ButtonDirective, InputGroupComponent } from '@coreui/angular' +import { VoManagerRoutingModule } from './VoManager-routing.module' +import { VoOverviewComponent } from './VoOverviewComponent' +import { VoGuardService } from './vo-guard.service' +import { VoService } from '../api-connector/vo.service' +import { ResourcesComponent } from './resources/resources.component' +import { ProjectManagementModule } from '../projectmanagement/projectmanagement.module' +import { ClientOverviewComponent } from './clients/clientOverview.component' +import { PipeModuleModule } from '../pipe-module/pipe-module.module' +import { NumberChartsComponent } from './number-charts/number-charts.component' +import { ClientLimitsComponent } from './clients/modals/client-limits..component' +import { SharedDirectivesModule } from '../shared/shared_modules/shared_directives.module' +import { MaintenanceComponent } from './maintenance/maintenance.component' +import { DatePickerComponent } from '../shared/datepicking/datepicker.component' +import { TimepickerComponent } from '../shared/datepicking/timepicker.component' +import { SharedModuleModule } from '../shared/shared_modules/shared-module.module' /** * VO Manager module. @@ -44,7 +44,7 @@ import { SharedModuleModule } from '../shared/shared_modules/shared-module.modul SharedModuleModule, BadgeComponent, InputGroupComponent, - ButtonDirective, + ButtonDirective ], declarations: [ VoOverviewComponent, @@ -52,8 +52,8 @@ import { SharedModuleModule } from '../shared/shared_modules/shared-module.modul ClientOverviewComponent, NumberChartsComponent, ClientLimitsComponent, - MaintenanceComponent, + MaintenanceComponent ], - providers: [VoService, VoGuardService], + providers: [VoService, VoGuardService] }) export class VoManagerModule {} diff --git a/src/app/vo_manager/VoOverviewComponent.ts b/src/app/vo_manager/VoOverviewComponent.ts index af1c573d5e..6eecf277e0 100644 --- a/src/app/vo_manager/VoOverviewComponent.ts +++ b/src/app/vo_manager/VoOverviewComponent.ts @@ -1,30 +1,28 @@ -import { - Component, OnDestroy, OnInit, QueryList, ViewChild, ViewChildren, inject, -} from '@angular/core'; -import { DomSanitizer } from '@angular/platform-browser'; -import { Observable, Subscription, take } from 'rxjs'; -import { BsModalRef, BsModalService, ModalDirective } from 'ngx-bootstrap/modal'; -import * as FileSaver from 'file-saver'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { VoService } from '../api-connector/vo.service'; -import { ProjectMember } from '../projectmanagement/project_member.model'; -import { GroupService } from '../api-connector/group.service'; -import { ComputecenterComponent } from '../projectmanagement/computecenter.component'; -import { IResponseTemplate } from '../api-connector/response-template'; -import { FacilityService } from '../api-connector/facility.service'; -import { FullLayoutComponent } from '../layouts/full-layout.component'; -import { Application } from '../applications/application.model/application.model'; -import { AbstractBaseClass } from '../shared/shared_modules/baseClass/abstract-base-class'; +import { Component, OnDestroy, OnInit, QueryList, ViewChild, ViewChildren, inject } from '@angular/core' +import { DomSanitizer } from '@angular/platform-browser' +import { Observable, Subscription, take } from 'rxjs' +import { BsModalRef, BsModalService, ModalDirective } from 'ngx-bootstrap/modal' +import * as FileSaver from 'file-saver' +import { MatomoTracker } from 'ngx-matomo-client' +import { VoService } from '../api-connector/vo.service' +import { ProjectMember } from '../projectmanagement/project_member.model' +import { GroupService } from '../api-connector/group.service' +import { ComputecenterComponent } from '../projectmanagement/computecenter.component' +import { IResponseTemplate } from '../api-connector/response-template' +import { FacilityService } from '../api-connector/facility.service' +import { FullLayoutComponent } from '../layouts/full-layout.component' +import { Application } from '../applications/application.model/application.model' +import { AbstractBaseClass } from '../shared/shared_modules/baseClass/abstract-base-class' import { NgbdSortableHeaderDirective, - SortEvent, -} from '../shared/shared_modules/directives/nbd-sortable-header.directive'; -import { ProjectSortService } from '../shared/shared_modules/services/project-sort.service'; -import { ConfirmationModalComponent } from '../shared/modal/confirmation-modal.component'; -import { ConfirmationActions } from '../shared/modal/confirmation_actions'; -import { MembersListModalComponent } from '../shared/modal/members/members-list-modal.component'; -import { EmailService } from '../api-connector/email.service'; -import { ProjectCsvTemplatedEmailModalComponent } from '../shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component'; + SortEvent +} from '../shared/shared_modules/directives/nbd-sortable-header.directive' +import { ProjectSortService } from '../shared/shared_modules/services/project-sort.service' +import { ConfirmationModalComponent } from '../shared/modal/confirmation-modal.component' +import { ConfirmationActions } from '../shared/modal/confirmation_actions' +import { MembersListModalComponent } from '../shared/modal/members/members-list-modal.component' +import { EmailService } from '../api-connector/email.service' +import { ProjectCsvTemplatedEmailModalComponent } from '../shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component' /** * Vo Overview component. @@ -32,65 +30,65 @@ import { ProjectCsvTemplatedEmailModalComponent } from '../shared/modal/email/pr @Component({ selector: 'app-vo-overview', templateUrl: 'voOverview.component.html', - providers: [VoService, GroupService, FacilityService, ProjectSortService], + providers: [VoService, GroupService, FacilityService, ProjectSortService] }) export class VoOverviewComponent extends AbstractBaseClass implements OnInit, OnDestroy { - private readonly tracker = inject(MatomoTracker); - title: string = 'VO Overview'; - public emailSubject: string; - public emailReply: string = ''; - public emailText: string; - public emailStatus: number = 0; - - @ViewChild('notificationModal') notificationModal: ModalDirective; - public emailHeader: string; - public emailVerify: string; - public emailType: number; - public emailAdminsOnly: boolean = false; - public expiredTemplated: boolean = false; - - public removalDate: Date = new Date(); - public selectedProject: Application; - selectedEmailProjects: Application[] = []; - computecenters: ComputecenterComponent[] = []; - bsModalRef: BsModalRef; - subscription: Subscription = new Subscription(); - protected readonly ConfirmationActions = ConfirmationActions; - userElixirSearchPI: boolean = true; - userElixirSearchAdmin: boolean = true; - userElixirSearchMember: boolean = true; - projectsLoaded: boolean = false; - show_openstack_projects: boolean = true; - show_simple_vm_projects: boolean = true; - show_simple_vm: boolean = true; - show_openstack: boolean = true; - - validElixirIdFilter: boolean = false; - tsvTaskRunning: boolean = false; - numberOfTsvs: number = 0; - checkTSVTimer: ReturnType; - checkTSVTimeout: number = 10000; - projectsCopy: Application[] = []; - - selectedProjectType: string = 'ALL'; - selectedFacility: string | number = 'ALL'; - userElixirIdFilter: string; - - public newsletterSubscriptionCounter: number; - member_id: number; - projects: Application[] = []; + private readonly tracker = inject(MatomoTracker) + title: string = 'VO Overview' + public emailSubject: string + public emailReply: string = '' + public emailText: string + public emailStatus: number = 0 + + @ViewChild('notificationModal') notificationModal: ModalDirective + public emailHeader: string + public emailVerify: string + public emailType: number + public emailAdminsOnly: boolean = false + public expiredTemplated: boolean = false + + public removalDate: Date = new Date() + public selectedProject: Application + selectedEmailProjects: Application[] = [] + computecenters: ComputecenterComponent[] = [] + bsModalRef: BsModalRef + subscription: Subscription = new Subscription() + protected readonly ConfirmationActions = ConfirmationActions + userElixirSearchPI: boolean = true + userElixirSearchAdmin: boolean = true + userElixirSearchMember: boolean = true + projectsLoaded: boolean = false + show_openstack_projects: boolean = true + show_simple_vm_projects: boolean = true + show_simple_vm: boolean = true + show_openstack: boolean = true + + validElixirIdFilter: boolean = false + tsvTaskRunning: boolean = false + numberOfTsvs: number = 0 + checkTSVTimer: ReturnType + checkTSVTimeout: number = 10000 + projectsCopy: Application[] = [] + + selectedProjectType: string = 'ALL' + selectedFacility: string | number = 'ALL' + userElixirIdFilter: string + + public newsletterSubscriptionCounter: number + member_id: number + projects: Application[] = [] // modal variables for User list - public usersModalProjectMembers: ProjectMember[] = []; - public usersModalProjectID: number; - public usersModalProjectName: string; - public managerFacilities: [string, number][]; + public usersModalProjectMembers: ProjectMember[] = [] + public usersModalProjectID: number + public usersModalProjectName: string + public managerFacilities: [string, number][] - projectMailTemplates: string[] = []; - @ViewChildren(NgbdSortableHeaderDirective) headers: QueryList; + projectMailTemplates: string[] = [] + @ViewChildren(NgbdSortableHeaderDirective) headers: QueryList - applictions$: Observable; - total$: Observable; + applictions$: Observable + total$: Observable // public selectedFacility: [string, number]; @@ -102,110 +100,110 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On private facilityService: FacilityService, public sortProjectService: ProjectSortService, private modalService: BsModalService, - private emailService: EmailService, + private emailService: EmailService ) { - super(); + super() } ngOnInit(): void { - this.tracker.trackPageView('Vo Overview'); - this.getVoProjects(); - this.getComputeCenters(); + this.tracker.trackPageView('Vo Overview') + this.getVoProjects() + this.getComputeCenters() this.voService.getNewsletterSubscriptionCounter().subscribe((result: IResponseTemplate): void => { - this.newsletterSubscriptionCounter = result.value as number; - }); - this.getTSVInformation(); + this.newsletterSubscriptionCounter = result.value as number + }) + this.getTSVInformation() } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } getTSVInformation(timeout: number = this.checkTSVTimeout): void { - this.stopCheckTSVTimer(); + this.stopCheckTSVTimer() this.subscription.add( this.voService.getTsvInformation().subscribe( (result: any): void => { - this.tsvTaskRunning = result[0]; - this.numberOfTsvs = result[1]; + this.tsvTaskRunning = result[0] + this.numberOfTsvs = result[1] if (result[0] !== true) { - this.stopCheckTSVTimer(); + this.stopCheckTSVTimer() } else { this.checkTSVTimer = setTimeout((): void => { - this.getTSVInformation(); - }, timeout); + this.getTSVInformation() + }, timeout) } }, () => { - this.tsvTaskRunning = true; - this.numberOfTsvs = 0; + this.tsvTaskRunning = true + this.numberOfTsvs = 0 this.checkTSVTimer = setTimeout((): void => { - this.getTSVInformation(); - }, timeout); - }, - ), - ); + this.getTSVInformation() + }, timeout) + } + ) + ) } stopCheckTSVTimer(): void { if (this.checkTSVTimer) { - clearTimeout(this.checkTSVTimer); + clearTimeout(this.checkTSVTimer) } } selectAllFilteredProjects(): void { - this.selectedEmailProjects = []; + this.selectedEmailProjects = [] // get all the applications this.applictions$.pipe(take(1)).subscribe(applications => { // set the selected state of all projects to true applications.forEach(application => { - application.is_project_selected = true; - this.toggleSelectedEmailApplication(application, application.is_project_selected); - }); - }); + application.is_project_selected = true + this.toggleSelectedEmailApplication(application, application.is_project_selected) + }) + }) } showConfirmationModal(application: Application, action: ConfirmationActions): void { - const initialState = { application, action }; - console.log(initialState); + const initialState = { application, action } + console.log(initialState) - this.bsModalRef = this.modalService.show(ConfirmationModalComponent, { initialState, class: 'modal-lg' }); - this.subscribeToBsModalRef(); + this.bsModalRef = this.modalService.show(ConfirmationModalComponent, { initialState, class: 'modal-lg' }) + this.subscribeToBsModalRef() } showMembersModal(application: Application): void { const initialState = { projectId: application.project_application_perun_id, - projectName: application.project_application_shortname, - }; + projectName: application.project_application_shortname + } - this.bsModalRef = this.modalService.show(MembersListModalComponent, { initialState, class: 'modal-lg' }); + this.bsModalRef = this.modalService.show(MembersListModalComponent, { initialState, class: 'modal-lg' }) } subscribeToBsModalRef(): void { this.subscription.add( this.bsModalRef.content.event.subscribe((result: any) => { - let action = null; + let action = null if ('action' in result) { - action = result['action']; + action = result['action'] } if (ConfirmationActions.ENABLE_APPLICATION === action) { - this.enableProject(result['application']); + this.enableProject(result['application']) } if (ConfirmationActions.DISABLE_APPLICATION === action) { - this.disableProject(result['application']); + this.disableProject(result['application']) } - }), - ); + }) + ) } unselectAll(): void { this.sortProjectService.applications.forEach((pr: Application) => { - pr.is_project_selected = false; - this.toggleSelectedEmailApplication(pr, pr.is_project_selected); - }); + pr.is_project_selected = false + this.toggleSelectedEmailApplication(pr, pr.is_project_selected) + }) // this.selectedEmailProjects = []; // clear the selectedEmailProjects list } @@ -214,113 +212,113 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On this.applictions$.pipe(take(1)).subscribe(applications => { // set the selected state of all projects to false applications.forEach(application => { - application.is_project_selected = false; - this.toggleSelectedEmailApplication(application, application.is_project_selected); - }); - }); + application.is_project_selected = false + this.toggleSelectedEmailApplication(application, application.is_project_selected) + }) + }) } toggleSelectedEmailApplication(application: Application, isChecked: boolean): void { - const index = this.selectedEmailProjects.indexOf(application); + const index = this.selectedEmailProjects.indexOf(application) if (isChecked) { // checkbox was checked if (index === -1) { // application is not in the list, so add it - this.selectedEmailProjects.push(application); + this.selectedEmailProjects.push(application) } } else { // checkbox was unchecked // application is in the list, so remove it - this.selectedEmailProjects.splice(index, 1); + this.selectedEmailProjects.splice(index, 1) } } openProjectCSVMailModal(): void { - this.bsModalRef = this.modalService.show(ProjectCsvTemplatedEmailModalComponent, { class: 'modal-lg' }); + this.bsModalRef = this.modalService.show(ProjectCsvTemplatedEmailModalComponent, { class: 'modal-lg' }) } disableProject(project: Application): void { this.voService.setDisabledProject(project.project_application_perun_id).subscribe((upd_app: Application) => { - const idx = this.projects.indexOf(project); - this.projects[idx] = upd_app; - this.sortProjectService.applications = this.projects; - }); + const idx = this.projects.indexOf(project) + this.projects[idx] = upd_app + this.sortProjectService.applications = this.projects + }) } checkValidElixirIdFilter(): void { - this.validElixirIdFilter = this.userElixirIdFilter && this.userElixirIdFilter.includes('@elixir-europe.org'); + this.validElixirIdFilter = this.userElixirIdFilter && this.userElixirIdFilter.includes('@elixir-europe.org') if (!this.validElixirIdFilter) { - this.sortProjectService.applications = this.projectsCopy; - this.applictions$ = this.sortProjectService.applications$; - this.total$ = this.sortProjectService.total$; - this.projectsLoaded = true; + this.sortProjectService.applications = this.projectsCopy + this.applictions$ = this.sortProjectService.applications$ + this.total$ = this.sortProjectService.total$ + this.projectsLoaded = true } } getProjectsByMemberElixirId(): void { // tslint:disable-next-line:max-line-length - this.userElixirIdFilter = this.userElixirIdFilter.trim(); + this.userElixirIdFilter = this.userElixirIdFilter.trim() if (this.userElixirIdFilter && this.userElixirIdFilter.includes('@elixir-europe.org')) { - this.projectsLoaded = false; + this.projectsLoaded = false this.voService .getGroupsByMemberElixirId( this.userElixirIdFilter, this.userElixirSearchPI, this.userElixirSearchAdmin, - this.userElixirSearchMember, + this.userElixirSearchMember ) .subscribe((applications: Application[]): void => { - this.projects = applications; + this.projects = applications for (const group of applications) { if (group.project_application_lifetime > 0) { - group.lifetime_reached = this.lifeTimeReached(group.lifetime_days, group.DaysRunning); + group.lifetime_reached = this.lifeTimeReached(group.lifetime_days, group.DaysRunning) } } - this.sortProjectService.applications = this.projects; - this.applictions$ = this.sortProjectService.applications$; - this.total$ = this.sortProjectService.total$; - this.projectsLoaded = true; - }); + this.sortProjectService.applications = this.projects + this.applictions$ = this.sortProjectService.applications$ + this.total$ = this.sortProjectService.total$ + this.projectsLoaded = true + }) } else { - this.sortProjectService.applications = this.projectsCopy; - this.applictions$ = this.sortProjectService.applications$; - this.total$ = this.sortProjectService.total$; - this.projectsLoaded = true; + this.sortProjectService.applications = this.projectsCopy + this.applictions$ = this.sortProjectService.applications$ + this.total$ = this.sortProjectService.total$ + this.projectsLoaded = true } } enableProject(project: Application): void { this.voService.unsetDisabledProject(project.project_application_perun_id).subscribe((upd_app: Application) => { - const idx = this.projects.indexOf(project); - this.projects[idx] = upd_app; - this.sortProjectService.applications = this.projects; - }); + const idx = this.projects.indexOf(project) + this.projects[idx] = upd_app + this.sortProjectService.applications = this.projects + }) } onSort({ column, direction }: SortEvent) { // resetting other headers this.headers.forEach(header => { if (header.appSortable !== column) { - header.direction = ''; + header.direction = '' } - }); + }) - this.sortProjectService.sortColumn = column; - this.sortProjectService.sortDirection = direction; + this.sortProjectService.sortColumn = column + this.sortProjectService.sortDirection = direction } getApplicationInfos(): void { - this.voService.getVoProjectResourcesTimeframes().subscribe(); + this.voService.getVoProjectResourcesTimeframes().subscribe() - this.voService.getVoProjectCounter().subscribe(); - this.voService.getVoProjectDates().subscribe(); + this.voService.getVoProjectCounter().subscribe() + this.voService.getVoProjectDates().subscribe() } sendEmail(subject: string, message: string, reply?: string): void { if (reply) { - reply = reply.trim(); + reply = reply.trim() } switch (this.emailType) { case 0: { @@ -332,20 +330,20 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On this.emailAdminsOnly, this.expiredTemplated, this.removalDate, - reply, - ); - break; + reply + ) + break } case 1: { - this.sendNewsletterToVo(subject, message, this.selectedProjectType, this.emailAdminsOnly, reply); - break; + this.sendNewsletterToVo(subject, message, this.selectedProjectType, this.emailAdminsOnly, reply) + break } default: } } sendTestBug(): void { - this.voService.sendTestError().subscribe(); + this.voService.sendTestError().subscribe() } sendNewsletterToVo( @@ -353,7 +351,7 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On message: string, selectedProjectType: string, adminsOnly: boolean, - reply?: string, + reply?: string ): void { this.voService .sendNewsletterToVo( @@ -361,15 +359,15 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On encodeURIComponent(message), selectedProjectType, adminsOnly, - encodeURIComponent(reply), + encodeURIComponent(reply) ) .subscribe((result: IResponseTemplate): void => { if ((result.value as boolean) === true) { - this.emailStatus = 1; + this.emailStatus = 1 } else { - this.emailStatus = 2; + this.emailStatus = 2 } - }); + }) } sendMailToVo( @@ -380,7 +378,7 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On adminsOnly: boolean, expiredTemplate: boolean, removalDate: Date, - reply?: string, + reply?: string ): void { this.voService .sendMailToVo( @@ -391,50 +389,50 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On adminsOnly, expiredTemplate, removalDate, - encodeURIComponent(reply), + encodeURIComponent(reply) ) .subscribe((result: IResponseTemplate): void => { if ((result.value as boolean) === true) { - this.emailStatus = 1; + this.emailStatus = 1 } else { - this.emailStatus = 2; + this.emailStatus = 2 } - this.selectedProjectType = 'ALL'; - this.selectedFacility = 'ALL'; - }); + this.selectedProjectType = 'ALL' + this.selectedFacility = 'ALL' + }) } dayChanged(date: { year: number; month: number; day: number }): void { - this.removalDate.setDate(date.day); - this.removalDate.setMonth(date.month - 1); - this.removalDate.setFullYear(date.year); + this.removalDate.setDate(date.day) + this.removalDate.setMonth(date.month - 1) + this.removalDate.setFullYear(date.year) } setEmailType(type: number): void { - this.emailType = type; + this.emailType = type switch (this.emailType) { case 0: { - this.emailHeader = 'Send email to selected members of the VO'; - break; + this.emailHeader = 'Send email to selected members of the VO' + break } case 1: { - this.emailHeader = 'Send newsletter to VO'; - break; + this.emailHeader = 'Send newsletter to VO' + break } default: } - this.emailVerify = 'Are you sure you want to send this newsletter to all members of the de.NBI VO?'; + this.emailVerify = 'Are you sure you want to send this newsletter to all members of the de.NBI VO?' } getFacilityName(): string { if (this.selectedFacility === 'ALL') { - return 'of the de.NBI VO'; + return 'of the de.NBI VO' } else { - const temp_cc = this.computecenters.find(cc => cc.FacilityId === this.selectedFacility); + const temp_cc = this.computecenters.find(cc => cc.FacilityId === this.selectedFacility) if (temp_cc === undefined) { - return 'of the de.NBI VO'; + return 'of the de.NBI VO' } else { - return `of the facility "${temp_cc.Name}"`; + return `of the facility "${temp_cc.Name}"` } } } @@ -442,17 +440,17 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On getMailConfinementByProjectType(): string { switch (this.selectedProjectType) { case 'ALL_GM': - return 'of all active projects'; + return 'of all active projects' case 'EXP': - return 'of all expired projects'; + return 'of all expired projects' case 'SVP': - return 'of all SimpleVM projects'; + return 'of all SimpleVM projects' case 'OVP': - return 'of all OpenStack projects'; + return 'of all OpenStack projects' case 'WSH': - return 'of all Workshops'; + return 'of all Workshops' default: - return ''; + return '' } } @@ -461,55 +459,55 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On case 0: { this.emailVerify = `Are you sure you want to send this email to all ${ this.emailAdminsOnly ? ' group administrators' : 'members' - } ${this.getMailConfinementByProjectType()} ${this.getFacilityName()} ?`; - break; + } ${this.getMailConfinementByProjectType()} ${this.getFacilityName()} ?` + break } case 1: { - this.emailVerify = `Are you sure you want to send this newsletter to all members ${this.getMailConfinementByProjectType()} ${this.getFacilityName()} ?`; - break; + this.emailVerify = `Are you sure you want to send this newsletter to all members ${this.getMailConfinementByProjectType()} ${this.getFacilityName()} ?` + break } default: - this.emailVerify = 'Are you sure you want to send this?'; + this.emailVerify = 'Are you sure you want to send this?' } if (this.selectedProjectType !== 'EXP') { - this.expiredTemplated = false; + this.expiredTemplated = false } } getVoProjects(): void { - this.projects = []; + this.projects = [] this.voService.getAllGroupsWithDetails().subscribe((applications: Application[]): void => { for (const application of applications) { if (application.project_application_lifetime > 0) { - application.lifetime_reached = this.lifeTimeReached(application.lifetime_days, application.DaysRunning); + application.lifetime_reached = this.lifeTimeReached(application.lifetime_days, application.DaysRunning) } - this.projects.push(application); + this.projects.push(application) } - this.projectsCopy = this.projects; + this.projectsCopy = this.projects - this.sortProjectService.applications = this.projects; - this.applictions$ = this.sortProjectService.applications$; - this.total$ = this.sortProjectService.total$; - this.projectsLoaded = true; - }); + this.sortProjectService.applications = this.projects + this.applictions$ = this.sortProjectService.applications$ + this.total$ = this.sortProjectService.total$ + this.projectsLoaded = true + }) } resetEmailModal(): void { - this.emailHeader = null; - this.emailSubject = null; - this.emailText = null; - this.emailType = null; - this.emailVerify = null; - this.emailReply = ''; - this.emailStatus = 0; - this.emailAdminsOnly = false; + this.emailHeader = null + this.emailSubject = null + this.emailText = null + this.emailType = null + this.emailVerify = null + this.emailReply = '' + this.emailStatus = 0 + this.emailAdminsOnly = false } public resetNotificationModal(): void { - this.notificationModalTitle = 'Notification'; - this.notificationModalMessage = 'Please wait...'; - this.notificationModalIsClosable = false; - this.notificationModalType = 'info'; + this.notificationModalTitle = 'Notification' + this.notificationModalMessage = 'Please wait...' + this.notificationModalIsClosable = false + this.notificationModalType = 'info' } /** @@ -522,40 +520,40 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On cc['compute_center_facility_id'], cc['compute_center_name'], cc['compute_center_login'], - cc['compute_center_support_mail'], - ); - this.computecenters.push(compute_center); + cc['compute_center_support_mail'] + ) + this.computecenters.push(compute_center) } - }); + }) } /** * Bugfix not scrollable site after closing modal */ removeModalOpen(): void { - document.body.classList.remove('modal-open'); + document.body.classList.remove('modal-open') } public terminateProject(): void { this.voService.terminateProject(this.selectedProject.project_application_perun_id).subscribe( (): void => { - const indexAll: number = this.projects.indexOf(this.selectedProject, 0); + const indexAll: number = this.projects.indexOf(this.selectedProject, 0) if (!this.selectedProject.project_application_openstack_project) { - this.projects.splice(indexAll, 1); - this.sortProjectService.applications = this.projects; + this.projects.splice(indexAll, 1) + this.sortProjectService.applications = this.projects } else { - this.getProjectStatus(this.projects[indexAll]); + this.getProjectStatus(this.projects[indexAll]) } - this.fullLayout.getGroupsEnumeration(); + this.fullLayout.getGroupsEnumeration() if (this.selectedProject.project_application_openstack_project) { this.updateNotificationModal( 'Success', 'The request to terminate the project was forwarded to the facility manager.', true, - 'success', - ); + 'success' + ) } else { - this.updateNotificationModal('Success', 'The project was terminated.', true, 'success'); + this.updateNotificationModal('Success', 'The project was terminated.', true, 'success') } }, (error: any): void => { @@ -564,57 +562,57 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On 'Failed', `The project could not be terminated. Reason: ${error['error']['reason']} for ${error['error']['openstackid']}`, true, - 'danger', - ); + 'danger' + ) } else { - this.updateNotificationModal('Failed', 'The project could not be terminated.', true, 'danger'); + this.updateNotificationModal('Failed', 'The project could not be terminated.', true, 'danger') } - }, - ); + } + ) } getProjectStatus(project: Application): void { this.voService.getProjectStatus(project.project_application_perun_id).subscribe((res: any): void => { - project.project_application_statuses = res['status']; - }); + project.project_application_statuses = res['status'] + }) } suspendProject(project: Application): void { this.voService.removeResourceFromGroup(project.project_application_perun_id).subscribe( (): void => { - this.updateNotificationModal('Success', 'The project got suspended successfully', true, 'success'); - this.getProjectStatus(project); - project.project_application_compute_center = null; + this.updateNotificationModal('Success', 'The project got suspended successfully', true, 'success') + this.getProjectStatus(project) + project.project_application_compute_center = null }, (): void => { - this.updateNotificationModal('Failed', 'The status change was not successful.', true, 'danger'); - }, - ); + this.updateNotificationModal('Failed', 'The status change was not successful.', true, 'danger') + } + ) } resumeProject(project: Application): void { this.voService.resumeProject(project.project_application_perun_id).subscribe( (): void => { - this.updateNotificationModal('Success', 'The project got resumed successfully', true, 'success'); - this.getProjectStatus(project); + this.updateNotificationModal('Success', 'The project got resumed successfully', true, 'success') + this.getProjectStatus(project) }, (): void => { - this.updateNotificationModal('Failed', 'The status change was not successful.', true, 'danger'); - }, - ); + this.updateNotificationModal('Failed', 'The status change was not successful.', true, 'danger') + } + ) } declineTermination(project: Application): void { this.voService.declineTermination(project.project_application_perun_id).subscribe( (): void => { - this.updateNotificationModal('Success', 'The termination was successfully declined', true, 'success'); - const indexAll: number = this.projects.indexOf(project, 0); - this.getProjectStatus(this.projects[indexAll]); + this.updateNotificationModal('Success', 'The termination was successfully declined', true, 'success') + const indexAll: number = this.projects.indexOf(project, 0) + this.getProjectStatus(this.projects[indexAll]) }, (): void => { - this.updateNotificationModal('Failed', 'The status change was not successful.', true, 'danger'); - }, - ); + this.updateNotificationModal('Failed', 'The status change was not successful.', true, 'danger') + } + ) } setProtected(project: Application, set: boolean): void { @@ -626,51 +624,51 @@ export class VoOverviewComponent extends AbstractBaseClass implements OnInit, On ? 'The project was successfully set as protected.' : 'The status "Protected" was removed successfully', true, - 'success', - ); - const indexAll: number = this.projects.indexOf(project, 0); - this.getProjectStatus(this.projects[indexAll]); + 'success' + ) + const indexAll: number = this.projects.indexOf(project, 0) + this.getProjectStatus(this.projects[indexAll]) }, (error: any): void => { if (error['status'] === 500) { - this.updateNotificationModal('Failed', 'The status change was not successful.', true, 'danger'); + this.updateNotificationModal('Failed', 'The status change was not successful.', true, 'danger') } - }, - ); + } + ) } getMembersOfTheProject(projectid: number, projectname: string): void { this.voService.getVoGroupRichMembers(projectid).subscribe((members: ProjectMember[]): void => { - this.usersModalProjectID = projectid; - this.usersModalProjectName = projectname; - this.usersModalProjectMembers = members; - }); + this.usersModalProjectID = projectid + this.usersModalProjectName = projectname + this.usersModalProjectMembers = members + }) } showMembersOfTheProject(projectid: number, projectname: string): void { - this.getMembersOfTheProject(projectid, projectname); + this.getMembersOfTheProject(projectid, projectname) } initiateTsvExport(): void { - this.tsvTaskRunning = true; + this.tsvTaskRunning = true this.voService.getAllProjectsForTsvExport().subscribe((): void => { - this.getTSVInformation(); - }); + this.getTSVInformation() + }) } downloadCurrentTSV(): void { this.voService.downloadProjectsTsv().subscribe( (result): void => { const blobn = new Blob([result], { - type: 'text/tsv', - }); + type: 'text/tsv' + }) - const dateTime = new Date(); - FileSaver.saveAs(blobn, `projects-${dateTime.getDate()}-${dateTime.getMonth()}-${dateTime.getFullYear()}.tsv`); + const dateTime = new Date() + FileSaver.saveAs(blobn, `projects-${dateTime.getDate()}-${dateTime.getMonth()}-${dateTime.getFullYear()}.tsv`) }, (err: any) => { - console.log(`No such file found! - ${err.toString()}`); - }, - ); + console.log(`No such file found! - ${err.toString()}`) + } + ) } } diff --git a/src/app/vo_manager/clients/clientOverview.component.ts b/src/app/vo_manager/clients/clientOverview.component.ts index 78fa1f819a..ab726b2163 100644 --- a/src/app/vo_manager/clients/clientOverview.component.ts +++ b/src/app/vo_manager/clients/clientOverview.component.ts @@ -1,80 +1,78 @@ -import { - Component, OnDestroy, OnInit, inject, -} from '@angular/core'; -import { Subscription } from 'rxjs'; -import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { Client } from './client.model'; -import { ClientService } from '../../api-connector/client.service'; -import { ApiSettings } from '../../api-connector/api-settings.service'; -import { GroupService } from '../../api-connector/group.service'; -import { UserService } from '../../api-connector/user.service'; -import { ComputecenterComponent } from '../../projectmanagement/computecenter.component'; -import { FacilityService } from '../../api-connector/facility.service'; -import { IResponseTemplate } from '../../api-connector/response-template'; -import { is_vo } from '../../shared/globalvar'; -import { ClientLimitsComponent } from './modals/client-limits..component'; +import { Component, OnDestroy, OnInit, inject } from '@angular/core' +import { Subscription } from 'rxjs' +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal' +import { MatomoTracker } from 'ngx-matomo-client' +import { Client } from './client.model' +import { ClientService } from '../../api-connector/client.service' +import { ApiSettings } from '../../api-connector/api-settings.service' +import { GroupService } from '../../api-connector/group.service' +import { UserService } from '../../api-connector/user.service' +import { ComputecenterComponent } from '../../projectmanagement/computecenter.component' +import { FacilityService } from '../../api-connector/facility.service' +import { IResponseTemplate } from '../../api-connector/response-template' +import { is_vo } from '../../shared/globalvar' +import { ClientLimitsComponent } from './modals/client-limits..component' /** * Client component. */ @Component({ selector: 'app-client-overview', templateUrl: 'clientOverview.html', - providers: [FacilityService, UserService, GroupService, ClientService, ApiSettings], + providers: [FacilityService, UserService, GroupService, ClientService, ApiSettings] }) export class ClientOverviewComponent implements OnInit, OnDestroy { - title: string = 'Client Overview'; + title: string = 'Client Overview' /** * All clients. */ - clients: Client[]; - bsModalRef: BsModalRef; + clients: Client[] + bsModalRef: BsModalRef /** * Selected Client; */ - selectedClient: Client; + selectedClient: Client /** * If user is vo. * * @type {boolean} */ - is_vo_admin: boolean = false; + is_vo_admin: boolean = false /** * Default status not added client. * * @type {string} */ - checkStatus: string = 'Not checked'; + checkStatus: string = 'Not checked' /** * All computecenters. * * @type {Array} */ - computeCenters: ComputecenterComponent[] = []; + computeCenters: ComputecenterComponent[] = [] /** * Selected computecenter. */ - selectedComputeCenter: ComputecenterComponent; + selectedComputeCenter: ComputecenterComponent /** * If site is initialized with data. * * @type {boolean} */ - isLoaded: boolean = false; + isLoaded: boolean = false - subscription: Subscription = new Subscription(); - private readonly tracker = inject(MatomoTracker); + subscription: Subscription = new Subscription() + private readonly tracker = inject(MatomoTracker) constructor( private facilityService: FacilityService, private userService: UserService, private clientservice: ClientService, - private modalService: BsModalService, + private modalService: BsModalService ) { - this.facilityService = facilityService; - this.userService = userService; - this.facilityService = facilityService; + this.facilityService = facilityService + this.userService = userService + this.facilityService = facilityService } /** @@ -83,16 +81,16 @@ export class ClientOverviewComponent implements OnInit, OnDestroy { getClientsChecked(): void { this.subscription.add( this.clientservice.getClientsChecked().subscribe((clients: Client[]): void => { - this.clients = clients; - this.isLoaded = true; - }), - ); + this.clients = clients + this.isLoaded = true + }) + ) } showClientsLimitsModal(cl: Client): void { - const initialState = { client: cl }; + const initialState = { client: cl } - this.bsModalRef = this.modalService.show(ClientLimitsComponent, { initialState }); + this.bsModalRef = this.modalService.show(ClientLimitsComponent, { initialState }) // this.bsModalRef.setClass('modal-lg'); // this.subscribeToBsModalRef(); } @@ -108,12 +106,12 @@ export class ClientOverviewComponent implements OnInit, OnDestroy { cc['compute_center_facility_id'], cc['compute_center_name'], cc['compute_center_login'], - cc['compute_center_support_mail'], - ); - this.computeCenters.push(compute_center); + cc['compute_center_support_mail'] + ) + this.computeCenters.push(compute_center) } - }), - ); + }) + ) } /** @@ -127,14 +125,14 @@ export class ClientOverviewComponent implements OnInit, OnDestroy { this.subscription.add( this.clientservice.checkClient(host, port).subscribe((data: IResponseTemplate): void => { if (!data.value) { - this.checkStatus = 'No Connection'; + this.checkStatus = 'No Connection' } else if (data.value) { - this.checkStatus = 'Connected'; + this.checkStatus = 'Connected' } else { - this.checkStatus = 'check failed'; + this.checkStatus = 'check failed' } - }), - ); + }) + ) } } @@ -149,39 +147,39 @@ export class ClientOverviewComponent implements OnInit, OnDestroy { if (host && port && location) { this.subscription.add( this.clientservice.postClient(host, port, location).subscribe((newClient: Client): void => { - this.clients.push(newClient); - }), - ); + this.clients.push(newClient) + }) + ) } } updateClient(host: string, port: string, location: string, id: string): void { this.subscription.add( this.clientservice.updateClient(new Client(null, host, port, location, id)).subscribe((res: Client): void => { - this.clients[this.clients.indexOf(this.selectedClient)] = res; - this.selectedClient = null; - this.getClientsChecked(); - }), - ); + this.clients[this.clients.indexOf(this.selectedClient)] = res + this.selectedClient = null + this.getClientsChecked() + }) + ) } switchActiveClient(id: string): void { this.subscription.add( this.clientservice.switchActive(id).subscribe((client: Client) => { - this.clients[this.clients.indexOf(this.selectedClient)] = client; - this.selectedClient = null; - }), - ); + this.clients[this.clients.indexOf(this.selectedClient)] = client + this.selectedClient = null + }) + ) } ngOnInit(): void { - this.tracker.trackPageView('VO Clients Overview'); - this.is_vo_admin = is_vo; - this.getClientsChecked(); - this.getComputeCenters(); + this.tracker.trackPageView('VO Clients Overview') + this.is_vo_admin = is_vo + this.getClientsChecked() + this.getComputeCenters() } ngOnDestroy() { - this.subscription.unsubscribe(); + this.subscription.unsubscribe() } } diff --git a/src/app/vo_manager/clients/modals/client-limits..component.ts b/src/app/vo_manager/clients/modals/client-limits..component.ts index 7c3922f4c8..d9d0802da3 100644 --- a/src/app/vo_manager/clients/modals/client-limits..component.ts +++ b/src/app/vo_manager/clients/modals/client-limits..component.ts @@ -1,89 +1,87 @@ -import { - Component, EventEmitter, OnDestroy, OnInit, -} from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Client } from '../client.model'; -import { ClientService } from '../../../api-connector/client.service'; -import { Application } from '../../../applications/application.model/application.model'; -import { FacilityService } from '../../../api-connector/facility.service'; -import { ConfirmationActions } from '../../../shared/modal/confirmation_actions'; +import { Component, EventEmitter, OnDestroy, OnInit } from '@angular/core' +import { BsModalRef } from 'ngx-bootstrap/modal' +import { Client } from '../client.model' +import { ClientService } from '../../../api-connector/client.service' +import { Application } from '../../../applications/application.model/application.model' +import { FacilityService } from '../../../api-connector/facility.service' +import { ConfirmationActions } from '../../../shared/modal/confirmation_actions' @Component({ selector: 'app-client-limits', templateUrl: './client-limits.component.html', - providers: [FacilityService, ClientService], + providers: [FacilityService, ClientService] }) export class ClientLimitsComponent implements OnDestroy, OnInit { - client: Client = null; - compute_center_id: string = null; - application: Application = null; - is_modification_request: boolean = false; - approvable: boolean = true; - limits_message: string; - message_type: string; - submitted: boolean = false; - request_failed: boolean = false; - public event: EventEmitter = new EventEmitter(); + client: Client = null + compute_center_id: string = null + application: Application = null + is_modification_request: boolean = false + approvable: boolean = true + limits_message: string + message_type: string + submitted: boolean = false + request_failed: boolean = false + public event: EventEmitter = new EventEmitter() constructor( public bsModalRef: BsModalRef, private clientService: ClientService, - private facilityService: FacilityService, + private facilityService: FacilityService ) { - // eslint-disable-next-line no-empty-function + } getComputeCenterClientLimitsAvailable() { - // eslint-disable-next-line max-len + this.facilityService .getComputeCenterClientLimitsAvailable(this.compute_center_id, this.application.project_application_id.toString()) .subscribe( (cl: any) => { - this.client = new Client(null, null, null, cl['client_name'], null); - this.client.setLimit(cl); + this.client = new Client(null, null, null, cl['client_name'], null) + this.client.setLimit(cl) if (cl['client_available']) { - this.message_type = 'success'; - this.limits_message = `The client [${this.client.location}] has enough resources left!.`; - this.approvable = true; + this.message_type = 'success' + this.limits_message = `The client [${this.client.location}] has enough resources left!.` + this.approvable = true } else { - this.message_type = 'danger'; - this.limits_message = `The client [${this.client.location}] has not the necessary resources left!`; + this.message_type = 'danger' + this.limits_message = `The client [${this.client.location}] has not the necessary resources left!` // this.approvable = false; } }, (error: object): void => { - console.log(error); - this.message_type = 'danger'; - this.limits_message = 'The connection to chosen client cannot be established!'; - this.request_failed = true; - }, - ); + console.log(error) + this.message_type = 'danger' + this.limits_message = 'The connection to chosen client cannot be established!' + this.request_failed = true + } + ) } getClientLimits() { this.clientService.getClientLimits(this.client.id).subscribe( (cl: any) => { - this.client = new Client(null, null, null, cl['client_name'], null); - this.client.setLimit(cl); + this.client = new Client(null, null, null, cl['client_name'], null) + this.client.setLimit(cl) // this.client.newRam = client['new_ram']; }, (error: object): void => { - console.log(error); - this.message_type = 'danger'; - this.limits_message = 'The connection to chosen client cannot be established!'; - this.request_failed = true; - }, - ); + console.log(error) + this.message_type = 'danger' + this.limits_message = 'The connection to chosen client cannot be established!' + this.request_failed = true + } + ) } approve(): void { - this.submitted = true; + this.submitted = true if (this.approvable && !this.is_modification_request) { - this.createSimpleVM(); + this.createSimpleVM() } if (this.approvable && this.is_modification_request) { - this.approveModification(); + this.approveModification() } } @@ -91,40 +89,40 @@ export class ClientLimitsComponent implements OnDestroy, OnInit { this.event.emit({ approveModification: true, application: this.application, - action: ConfirmationActions.APPROVE_MODIFICATION, - }); - this.bsModalRef.hide(); + action: ConfirmationActions.APPROVE_MODIFICATION + }) + this.bsModalRef.hide() } createSimpleVM(): void { this.event.emit({ createSimpleVM: true, compute_center_id: this.compute_center_id, - application: this.application, - }); - this.bsModalRef.hide(); + application: this.application + }) + this.bsModalRef.hide() } ngOnInit() { - this.request_failed = false; + this.request_failed = false if (this.client) { - this.getClientLimits(); + this.getClientLimits() } else if (this.application && !this.compute_center_id) { - this.message_type = 'warning'; - this.limits_message = 'Client will be scheduled via round robin!'; + this.message_type = 'warning' + this.limits_message = 'Client will be scheduled via round robin!' } else if (this.application && !this.is_modification_request) { - this.getComputeCenterClientLimitsAvailable(); + this.getComputeCenterClientLimitsAvailable() } else if (this.application && this.is_modification_request) { - this.getComputeCenterClientLimitsAvailable(); + this.getComputeCenterClientLimitsAvailable() } } ngOnDestroy(): void { if (!this.submitted) { this.event.emit({ - closed: true, - }); + closed: true + }) } - this.bsModalRef.hide(); + this.bsModalRef.hide() } } diff --git a/src/app/vo_manager/maintenance/maintenance.component.ts b/src/app/vo_manager/maintenance/maintenance.component.ts index d2c09bb26f..015f54008c 100644 --- a/src/app/vo_manager/maintenance/maintenance.component.ts +++ b/src/app/vo_manager/maintenance/maintenance.component.ts @@ -1,14 +1,14 @@ -import { Component, OnInit, inject } from '@angular/core'; +import { Component, OnInit, inject } from '@angular/core' -import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; -import { BsModalService } from 'ngx-bootstrap/modal'; -import 'svg2pdf.js'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { WorkshopService } from '../../api-connector/workshop.service'; -import { WorkshopTimeFrame } from '../../virtualmachines/workshop/workshopTimeFrame.model'; -import { VoService } from '../../api-connector/vo.service'; -import { MaintenanceTimeFrame } from './maintenanceTimeFrame.model'; -import { NotificationModalComponent } from '../../shared/modal/notification-modal'; +import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms' +import { BsModalService } from 'ngx-bootstrap/modal' +import 'svg2pdf.js' +import { MatomoTracker } from 'ngx-matomo-client' +import { WorkshopService } from '../../api-connector/workshop.service' +import { WorkshopTimeFrame } from '../../virtualmachines/workshop/workshopTimeFrame.model' +import { VoService } from '../../api-connector/vo.service' +import { MaintenanceTimeFrame } from './maintenanceTimeFrame.model' +import { NotificationModalComponent } from '../../shared/modal/notification-modal' /** * Component to display graphs which illustrate numbers for VO. @@ -17,53 +17,53 @@ import { NotificationModalComponent } from '../../shared/modal/notification-moda selector: 'app-maintenance', templateUrl: './maintenance.component.html', styleUrls: ['./maintenance.component.scss'], - providers: [WorkshopService, VoService], + providers: [WorkshopService, VoService] }) export class MaintenanceComponent implements OnInit { - private readonly tracker = inject(MatomoTracker); - is_vo_admin: boolean = false; - title: string = 'Maintenance'; + private readonly tracker = inject(MatomoTracker) + is_vo_admin: boolean = false + title: string = 'Maintenance' - workshopTimeFramesLoaded: boolean = false; - maintenanceTimeFramesLoaded: boolean = false; - workshopTimeFrames: WorkshopTimeFrame[] = []; - maintenanceTimeFrames: MaintenanceTimeFrame[] = []; - errorWorkshopTimeFrames: boolean = false; - errorMaintenanceTimeFrames: boolean = false; - newMaintenanceTimeFrame: MaintenanceTimeFrame = null; + workshopTimeFramesLoaded: boolean = false + maintenanceTimeFramesLoaded: boolean = false + workshopTimeFrames: WorkshopTimeFrame[] = [] + maintenanceTimeFrames: MaintenanceTimeFrame[] = [] + errorWorkshopTimeFrames: boolean = false + errorMaintenanceTimeFrames: boolean = false + newMaintenanceTimeFrame: MaintenanceTimeFrame = null - timeSpotCritical: boolean = false; - timeSpotsChecked: boolean = false; - criticalTimeSpots: WorkshopTimeFrame[] = []; + timeSpotCritical: boolean = false + timeSpotsChecked: boolean = false + criticalTimeSpots: WorkshopTimeFrame[] = [] - addTimeFrameForm!: UntypedFormGroup; + addTimeFrameForm!: UntypedFormGroup constructor( private workshopService: WorkshopService, private voService: VoService, private fb: UntypedFormBuilder, - private modalService: BsModalService, + private modalService: BsModalService ) {} ngOnInit(): void { - this.tracker.trackPageView('Maintenance'); + this.tracker.trackPageView('Maintenance') this.newMaintenanceTimeFrame = new MaintenanceTimeFrame({ name: '', start_time: new Date(), end_time: new Date(), - message: '', - }); - this.workshopTimeFramesLoaded = false; - this.maintenanceTimeFramesLoaded = false; - this.reloadTimeFrames(); + message: '' + }) + this.workshopTimeFramesLoaded = false + this.maintenanceTimeFramesLoaded = false + this.reloadTimeFrames() this.addTimeFrameForm = this.fb.group({ - name_input_field: ['', [Validators.required, Validators.minLength(5)]], - }); + name_input_field: ['', [Validators.required, Validators.minLength(5)]] + }) } get f() { - return this.addTimeFrameForm.controls; + return this.addTimeFrameForm.controls } dayChanged(date: { year: number; month: number; day: number }): void { @@ -72,16 +72,16 @@ export class MaintenanceComponent implements OnInit { date.month - 1, date.day, this.newMaintenanceTimeFrame.start_time.getHours(), - this.newMaintenanceTimeFrame.start_time.getMinutes(), - ); + this.newMaintenanceTimeFrame.start_time.getMinutes() + ) this.newMaintenanceTimeFrame.end_time = new Date( date.year, date.month - 1, date.day, this.newMaintenanceTimeFrame.end_time.getHours(), - this.newMaintenanceTimeFrame.end_time.getMinutes(), - ); + this.newMaintenanceTimeFrame.end_time.getMinutes() + ) } startTimeChanged(time: { hour: number; minute: number }): void { @@ -90,8 +90,8 @@ export class MaintenanceComponent implements OnInit { this.newMaintenanceTimeFrame.start_time.getMonth(), this.newMaintenanceTimeFrame.start_time.getDate(), time.hour, - time.minute, - ); + time.minute + ) } endTimeChanged(time: { hour: number; minute: number }): void { @@ -100,8 +100,8 @@ export class MaintenanceComponent implements OnInit { this.newMaintenanceTimeFrame.end_time.getMonth(), this.newMaintenanceTimeFrame.end_time.getDate(), time.hour, - time.minute, - ); + time.minute + ) } reloadTimeFrames(): void { @@ -109,127 +109,127 @@ export class MaintenanceComponent implements OnInit { next: (wsTimeFrames: WorkshopTimeFrame[]) => { this.workshopTimeFrames = wsTimeFrames.sort((a, b) => { if (a.start_time < b.start_time) { - return -1; + return -1 } else if (a.start_time > b.start_time) { - return 1; + return 1 } else { - return 0; + return 0 } - }); - this.workshopTimeFramesLoaded = true; - this.errorWorkshopTimeFrames = false; + }) + this.workshopTimeFramesLoaded = true + this.errorWorkshopTimeFrames = false }, error: () => { - this.workshopTimeFramesLoaded = true; - this.errorWorkshopTimeFrames = true; - }, - }); + this.workshopTimeFramesLoaded = true + this.errorWorkshopTimeFrames = true + } + }) this.voService.loadMaintenanceTimeFrames().subscribe({ next: (mtTimeFrames: MaintenanceTimeFrame[]) => { this.maintenanceTimeFrames = mtTimeFrames.sort((a, b) => { if (a.start_time < b.start_time) { - return -1; + return -1 } else if (a.start_time > b.start_time) { - return 1; + return 1 } else { - return 0; + return 0 } - }); - this.maintenanceTimeFramesLoaded = true; - this.errorMaintenanceTimeFrames = false; + }) + this.maintenanceTimeFramesLoaded = true + this.errorMaintenanceTimeFrames = false }, error: () => { - this.maintenanceTimeFramesLoaded = true; - this.errorMaintenanceTimeFrames = true; - }, - }); + this.maintenanceTimeFramesLoaded = true + this.errorMaintenanceTimeFrames = true + } + }) } checkData(): void { - this.timeSpotCritical = false; - this.timeSpotsChecked = false; - this.criticalTimeSpots = []; + this.timeSpotCritical = false + this.timeSpotsChecked = false + this.criticalTimeSpots = [] this.workshopTimeFrames.forEach((wstf: WorkshopTimeFrame) => { - const start_time: number = new Date(wstf.start_time).getTime(); - const end_time: number = new Date(wstf.end_time).getTime(); + const start_time: number = new Date(wstf.start_time).getTime() + const end_time: number = new Date(wstf.end_time).getTime() if ( this.datesOverlap( start_time, end_time, this.newMaintenanceTimeFrame.start_time.getTime(), - this.newMaintenanceTimeFrame.end_time.getTime(), + this.newMaintenanceTimeFrame.end_time.getTime() ) ) { - this.timeSpotCritical = true; - this.criticalTimeSpots.push(wstf); + this.timeSpotCritical = true + this.criticalTimeSpots.push(wstf) } - }); - this.timeSpotsChecked = true; + }) + this.timeSpotsChecked = true } datesOverlap(first_start: number, first_end: number, second_start: number, second_end: number): boolean { return ( - (first_start >= second_start && first_start <= second_end) - || (first_end >= second_start && first_end <= second_end) - || (second_start >= first_start && second_start <= first_end) - || (second_end >= first_start && second_end <= first_end) - ); + (first_start >= second_start && first_start <= second_end) || + (first_end >= second_start && first_end <= second_end) || + (second_start >= first_start && second_start <= first_end) || + (second_end >= first_start && second_end <= first_end) + ) } createNewTimeFrame(): void { this.voService.addMaintenanceTimeFrame(this.newMaintenanceTimeFrame).subscribe({ next: () => { - this.reloadTimeFrames(); + this.reloadTimeFrames() const initialState = { notificationModalTitle: 'Success', notificationModalType: 'info', - notificationModalMessage: 'The new maintenance got successfully added to the calender!', - }; - this.modalService.show(NotificationModalComponent, { initialState }); - this.resetFormValues(); + notificationModalMessage: 'The new maintenance got successfully added to the calender!' + } + this.modalService.show(NotificationModalComponent, { initialState }) + this.resetFormValues() }, error: () => { const initialState = { notificationModalTitle: 'Error', notificationModalType: 'danger', - notificationModalMessage: 'An error occurred while adding the timeframe to the calender!', - }; - this.modalService.show(NotificationModalComponent, { initialState }); - this.resetFormValues(); - }, - }); + notificationModalMessage: 'An error occurred while adding the timeframe to the calender!' + } + this.modalService.show(NotificationModalComponent, { initialState }) + this.resetFormValues() + } + }) } resetFormValues(): void { - this.newMaintenanceTimeFrame.start_time = new Date(); - this.newMaintenanceTimeFrame.end_time = new Date(); - this.newMaintenanceTimeFrame.significant = false; - this.newMaintenanceTimeFrame.name = ''; - this.newMaintenanceTimeFrame.message = ''; - this.newMaintenanceTimeFrame.id = ''; - this.addTimeFrameForm.reset(); + this.newMaintenanceTimeFrame.start_time = new Date() + this.newMaintenanceTimeFrame.end_time = new Date() + this.newMaintenanceTimeFrame.significant = false + this.newMaintenanceTimeFrame.name = '' + this.newMaintenanceTimeFrame.message = '' + this.newMaintenanceTimeFrame.id = '' + this.addTimeFrameForm.reset() } deleteTimeFrame(timeframe: MaintenanceTimeFrame): void { this.voService.deleteMaintenanceTimeFrame(timeframe).subscribe({ next: () => { - this.reloadTimeFrames(); + this.reloadTimeFrames() const initialState = { notificationModalTitle: 'Success', notificationModalType: 'info', - notificationModalMessage: 'The new maintenance got successfully deleted from the calender!', - }; - this.modalService.show(NotificationModalComponent, { initialState }); + notificationModalMessage: 'The new maintenance got successfully deleted from the calender!' + } + this.modalService.show(NotificationModalComponent, { initialState }) }, error: () => { const initialState = { notificationModalTitle: 'Error', notificationModalType: 'danger', - notificationModalMessage: 'An error occurred while deleting the timeframe.', - }; - this.modalService.show(NotificationModalComponent, { initialState }); - }, - }); + notificationModalMessage: 'An error occurred while deleting the timeframe.' + } + this.modalService.show(NotificationModalComponent, { initialState }) + } + }) } /** @@ -237,25 +237,25 @@ export class MaintenanceComponent implements OnInit { * @param timeframe */ switchSignificance(timeframe: MaintenanceTimeFrame): void { - timeframe.significant = !timeframe.significant; + timeframe.significant = !timeframe.significant this.voService.adjustMaintenanceTimeFrame(timeframe).subscribe({ next: () => { - this.reloadTimeFrames(); + this.reloadTimeFrames() const initialState = { notificationModalTitle: 'Success', notificationModalType: 'info', - notificationModalMessage: 'The maintenance got successfully adjusted!', - }; - this.modalService.show(NotificationModalComponent, { initialState }); + notificationModalMessage: 'The maintenance got successfully adjusted!' + } + this.modalService.show(NotificationModalComponent, { initialState }) }, error: () => { const initialState = { notificationModalTitle: 'Error', notificationModalType: 'danger', - notificationModalMessage: 'An error occurred while adjusting the timeframe.', - }; - this.modalService.show(NotificationModalComponent, { initialState }); - }, - }); + notificationModalMessage: 'An error occurred while adjusting the timeframe.' + } + this.modalService.show(NotificationModalComponent, { initialState }) + } + }) } } diff --git a/src/app/vo_manager/number-charts/number-charts.component.ts b/src/app/vo_manager/number-charts/number-charts.component.ts index 52648f88ca..5490f41ca4 100644 --- a/src/app/vo_manager/number-charts/number-charts.component.ts +++ b/src/app/vo_manager/number-charts/number-charts.component.ts @@ -1,12 +1,12 @@ -import { Component, OnInit, inject } from '@angular/core'; -import html2canvas from 'html2canvas'; -import * as saveSVG from 'save-svg-as-png'; -import bb, { areaSpline, bar, Chart } from 'billboard.js'; -import { jsPDF } from 'jspdf'; -import * as d3 from 'd3'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { NumbersService } from '../../api-connector/numbers.service'; -import 'svg2pdf.js'; +import { Component, OnInit, inject } from '@angular/core' +import html2canvas from 'html2canvas' +import * as saveSVG from 'save-svg-as-png' +import bb, { areaSpline, bar, Chart } from 'billboard.js' +import { jsPDF } from 'jspdf' +import * as d3 from 'd3' +import { MatomoTracker } from 'ngx-matomo-client' +import { NumbersService } from '../../api-connector/numbers.service' +import 'svg2pdf.js' /** * Component to display graphs which illustrate numbers for VO. @@ -15,56 +15,56 @@ import 'svg2pdf.js'; selector: 'app-number-charts', templateUrl: './number-charts.component.html', styleUrls: ['./number-charts.component.css'], - providers: [NumbersService], + providers: [NumbersService] }) export class NumberChartsComponent implements OnInit { - private readonly tracker = inject(MatomoTracker); - is_vo_admin: boolean = true; - title: string = 'Cloud Numbers'; + private readonly tracker = inject(MatomoTracker) + is_vo_admin: boolean = true + title: string = 'Cloud Numbers' constructor(private numbersService: NumbersService) { - this.numbersService = numbersService; + this.numbersService = numbersService } /** * Charts */ - public coresAreaChart: Chart; - public coresBarChart: Chart; - public ramAreaChart: Chart; - public ramBarChart: Chart; - public projectNumbersAreaChart: Chart; - public projectNumbersBarChart: Chart; + public coresAreaChart: Chart + public coresBarChart: Chart + public ramAreaChart: Chart + public ramBarChart: Chart + public projectNumbersAreaChart: Chart + public projectNumbersBarChart: Chart - showCoresBarChart: boolean = false; - showCoresAreChart: boolean = true; - showRamBarChart: boolean = false; - showRamAreChart: boolean = true; - showProjectNumbersAreaChart: boolean = true; - showProjectNumbersBarChart: boolean = false; + showCoresBarChart: boolean = false + showCoresAreChart: boolean = true + showRamBarChart: boolean = false + showRamAreChart: boolean = true + showProjectNumbersAreaChart: boolean = true + showProjectNumbersBarChart: boolean = false /** * Lists for numbers of projects per project type and status. */ - private runningOpenstack: any[] = ['OpenStack running']; - private runningSimpleVM: any[] = ['SimpleVM running']; - private terminatedOpenstack: any[] = ['OpenStack terminated']; - private terminatedSimpleVM: any[] = ['SimpleVM terminated']; - private endDatesProjects: any[] = ['x']; + private runningOpenstack: any[] = ['OpenStack running'] + private runningSimpleVM: any[] = ['SimpleVM running'] + private terminatedOpenstack: any[] = ['OpenStack terminated'] + private terminatedSimpleVM: any[] = ['SimpleVM terminated'] + private endDatesProjects: any[] = ['x'] /** * Lists for ram and cores numbers. */ - private simpleVMRam: any[] = ['RAM SimpleVM']; - private simpleVMCores: any[] = ['Cores SimpleVM']; - private openstackRam: any[] = ['RAM OpenStack']; - private openstackCores: any[] = ['Cores Openstack']; - private endDatesResources: any[] = ['x']; + private simpleVMRam: any[] = ['RAM SimpleVM'] + private simpleVMCores: any[] = ['Cores SimpleVM'] + private openstackRam: any[] = ['RAM OpenStack'] + private openstackCores: any[] = ['Cores Openstack'] + private endDatesResources: any[] = ['x'] ngOnInit(): void { - this.tracker.trackPageView('Cloud Numbers'); - this.getData(); + this.tracker.trackPageView('Cloud Numbers') + this.getData() } /** @@ -75,35 +75,35 @@ export class NumberChartsComponent implements OnInit { this.numbersService.getProjectCounterTimeline().subscribe( (result: object[]): void => { result.forEach((valuePack: any): void => { - this.runningOpenstack.push(valuePack['running_openstack']); - this.runningSimpleVM.push(valuePack['running_simple_vm']); - this.terminatedOpenstack.push(valuePack['terminated_openstack']); - this.terminatedSimpleVM.push(valuePack['terminated_simple_vm']); - this.endDatesProjects.push(valuePack['end_date']); - }); - this.drawProjectNumbersChart(); + this.runningOpenstack.push(valuePack['running_openstack']) + this.runningSimpleVM.push(valuePack['running_simple_vm']) + this.terminatedOpenstack.push(valuePack['terminated_openstack']) + this.terminatedSimpleVM.push(valuePack['terminated_simple_vm']) + this.endDatesProjects.push(valuePack['end_date']) + }) + this.drawProjectNumbersChart() }, (err: Error) => { - console.log(err); - }, - ); + console.log(err) + } + ) this.numbersService.getRamCoresTimeline().subscribe( (result: object[]): void => { result.forEach((valuePack: object): void => { - this.openstackCores.push(valuePack['openstack_cores']); - this.openstackRam.push(valuePack['openstack_ram']); - this.simpleVMCores.push(valuePack['simple_vm_cores']); - this.simpleVMRam.push(valuePack['simple_vm_ram']); - this.endDatesResources.push(valuePack['end_date']); - }); - this.drawRamNumbersChart(); - this.drawCoresNumbersChart(); + this.openstackCores.push(valuePack['openstack_cores']) + this.openstackRam.push(valuePack['openstack_ram']) + this.simpleVMCores.push(valuePack['simple_vm_cores']) + this.simpleVMRam.push(valuePack['simple_vm_ram']) + this.endDatesResources.push(valuePack['end_date']) + }) + this.drawRamNumbersChart() + this.drawCoresNumbersChart() }, (err: Error) => { - console.log(err); - }, - ); + console.log(err) + } + ) } /** @@ -113,29 +113,29 @@ export class NumberChartsComponent implements OnInit { html2canvas(document.getElementById(elementId)) .then((canvas: HTMLCanvasElement): void => { // Few necessary setting options - const imgWidth: number = 208; - const imgHeight: number = (canvas.height * imgWidth) / canvas.width; - const contentDataURL: string = canvas.toDataURL('image/png'); - // eslint-disable-next-line new-cap - const pdf: jsPDF = new jsPDF('p', 'mm', 'a4'); // A4 size page of PDF - const position: number = 0; - pdf.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight); - pdf.save(filename.concat('.pdf')); + const imgWidth: number = 208 + const imgHeight: number = (canvas.height * imgWidth) / canvas.width + const contentDataURL: string = canvas.toDataURL('image/png') + + const pdf: jsPDF = new jsPDF('p', 'mm', 'a4') // A4 size page of PDF + const position: number = 0 + pdf.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight) + pdf.save(filename.concat('.pdf')) }) .catch((): void => { - console.log('failed to convert to pdf'); - }); + console.log('failed to convert to pdf') + }) } /** * Downloads the numbers graphic as a png. */ downloadAsPNG(elementId: string, filename: string): void { - const svg = d3.select(`#${elementId} svg`); - svg.attr('id', 'svgToDownload'); + const svg = d3.select(`#${elementId} svg`) + svg.attr('id', 'svgToDownload') - saveSVG.saveSvgAsPng(document.getElementById('svgToDownload'), filename.concat('.png'), {}); - svg.attr('id', null); + saveSVG.saveSvgAsPng(document.getElementById('svgToDownload'), filename.concat('.png'), {}) + svg.attr('id', null) } /** @@ -146,90 +146,90 @@ export class NumberChartsComponent implements OnInit { this.coresAreaChart = bb.generate({ bindto: '#coresAreaChart', size: { - height: 600, + height: 600 }, data: { x: 'x', columns: [this.endDatesResources, this.simpleVMCores, this.openstackCores], type: areaSpline(), groups: [[this.simpleVMCores[0], this.openstackCores[0]]], - order: null, + order: null }, color: { - pattern: ['#00adef', '#ed1944'], + pattern: ['#00adef', '#ed1944'] }, grid: { y: { - show: true, - }, + show: true + } }, axis: { x: { label: { text: 'Date', - position: 'outer-right', + position: 'outer-right' }, type: 'timeseries', tick: { - format: '%Y-%m-%d', - }, + format: '%Y-%m-%d' + } }, y: { label: { text: 'Amount of allocated cores', - position: 'outer-right', - }, - }, + position: 'outer-right' + } + } }, point: { - show: false, - }, - }); + show: false + } + }) this.coresBarChart = bb.generate({ bindto: '#coresBarChart', size: { - height: 600, + height: 600 }, data: { x: 'x', columns: [this.endDatesResources, this.simpleVMCores, this.openstackCores], type: bar(), groups: [[this.simpleVMCores[0], this.openstackCores[0]]], - order: null, + order: null }, color: { - pattern: ['#00adef', '#ed1944'], + pattern: ['#00adef', '#ed1944'] }, grid: { y: { - show: true, - }, + show: true + } }, axis: { x: { label: { text: 'Date', - position: 'outer-right', + position: 'outer-right' }, type: 'timeseries', tick: { - format: '%Y-%m-%d', - }, + format: '%Y-%m-%d' + } }, y: { label: { text: 'Amount of allocated cores', - position: 'outer-right', - }, - }, + position: 'outer-right' + } + } }, point: { - show: false, - }, - }); + show: false + } + }) } /** @@ -240,90 +240,90 @@ export class NumberChartsComponent implements OnInit { this.ramAreaChart = bb.generate({ bindto: '#ramAreaChart', size: { - height: 600, + height: 600 }, data: { x: 'x', columns: [this.endDatesResources, this.simpleVMRam, this.openstackRam], type: areaSpline(), groups: [[this.simpleVMRam[0], this.openstackRam[0]]], - order: null, + order: null }, color: { - pattern: ['#00adef', '#ed1944'], + pattern: ['#00adef', '#ed1944'] }, grid: { y: { - show: true, - }, + show: true + } }, axis: { x: { label: { text: 'Date', - position: 'outer-right', + position: 'outer-right' }, type: 'timeseries', tick: { - format: '%Y-%m-%d', - }, + format: '%Y-%m-%d' + } }, y: { label: { text: 'Amount of allocated VRAM in GB', - position: 'outer-right', - }, - }, + position: 'outer-right' + } + } }, point: { - show: false, - }, - }); + show: false + } + }) this.ramBarChart = bb.generate({ bindto: '#ramBarChart', size: { - height: 600, + height: 600 }, data: { x: 'x', columns: [this.endDatesResources, this.simpleVMRam, this.openstackRam], type: bar(), groups: [[this.simpleVMRam[0], this.openstackRam[0]]], - order: null, + order: null }, color: { - pattern: ['#00adef', '#ed1944'], + pattern: ['#00adef', '#ed1944'] }, grid: { y: { - show: true, - }, + show: true + } }, axis: { x: { label: { text: 'Date', - position: 'outer-right', + position: 'outer-right' }, type: 'timeseries', tick: { - format: '%Y-%m-%d', - }, + format: '%Y-%m-%d' + } }, y: { label: { text: 'Amount of allocated VRAM in GB', - position: 'outer-right', - }, - }, + position: 'outer-right' + } + } }, point: { - show: false, - }, - }); + show: false + } + }) } /** @@ -333,7 +333,7 @@ export class NumberChartsComponent implements OnInit { this.projectNumbersAreaChart = bb.generate({ bindto: '#projectNumbersAreaChart', size: { - height: 600, + height: 600 }, data: { x: 'x', @@ -342,50 +342,50 @@ export class NumberChartsComponent implements OnInit { this.runningSimpleVM, this.terminatedSimpleVM, this.runningOpenstack, - this.terminatedOpenstack, + this.terminatedOpenstack ], type: areaSpline(), groups: [ - [this.runningSimpleVM[0], this.terminatedSimpleVM[0], this.runningOpenstack[0], this.terminatedOpenstack[0]], + [this.runningSimpleVM[0], this.terminatedSimpleVM[0], this.runningOpenstack[0], this.terminatedOpenstack[0]] ], - order: null, + order: null }, color: { - pattern: ['#00adef', '#004b69', '#ed1944', '#590000'], + pattern: ['#00adef', '#004b69', '#ed1944', '#590000'] }, grid: { y: { - show: true, - }, + show: true + } }, axis: { x: { label: { text: 'Date', - position: 'outer-right', + position: 'outer-right' }, type: 'timeseries', tick: { - format: '%Y-%m-%d', - }, + format: '%Y-%m-%d' + } }, y: { label: { text: 'Number of projects', - position: 'outer-right', - }, - }, + position: 'outer-right' + } + } }, point: { - show: false, - }, - }); + show: false + } + }) this.projectNumbersBarChart = bb.generate({ bindto: '#projectNumbersBarChart', size: { - height: 600, + height: 600 }, data: { x: 'x', @@ -394,67 +394,67 @@ export class NumberChartsComponent implements OnInit { this.runningSimpleVM, this.terminatedSimpleVM, this.runningOpenstack, - this.terminatedOpenstack, + this.terminatedOpenstack ], type: bar(), groups: [ - [this.runningSimpleVM[0], this.terminatedSimpleVM[0], this.runningOpenstack[0], this.terminatedOpenstack[0]], + [this.runningSimpleVM[0], this.terminatedSimpleVM[0], this.runningOpenstack[0], this.terminatedOpenstack[0]] ], - order: null, + order: null }, color: { - pattern: ['#00adef', '#004b69', '#ed1944', '#590000'], + pattern: ['#00adef', '#004b69', '#ed1944', '#590000'] }, grid: { y: { - show: true, - }, + show: true + } }, axis: { x: { label: { text: 'Date', - position: 'outer-right', + position: 'outer-right' }, type: 'timeseries', tick: { - format: '%Y-%m-%d', - }, + format: '%Y-%m-%d' + } }, y: { label: { text: 'Number of projects', - position: 'outer-right', - }, - }, + position: 'outer-right' + } + } }, point: { - show: false, - }, - }); + show: false + } + }) } toggleGraph(chart: string): void { switch (chart) { case 'cores': { - this.showCoresBarChart = !this.showCoresBarChart; - this.showCoresAreChart = !this.showCoresAreChart; + this.showCoresBarChart = !this.showCoresBarChart + this.showCoresAreChart = !this.showCoresAreChart - break; + break } case 'ram': { - this.showRamAreChart = !this.showRamAreChart; - this.showRamBarChart = !this.showRamBarChart; - break; + this.showRamAreChart = !this.showRamAreChart + this.showRamBarChart = !this.showRamBarChart + break } case 'projects': { - this.showProjectNumbersBarChart = !this.showProjectNumbersBarChart; - this.showProjectNumbersAreaChart = !this.showProjectNumbersAreaChart; - break; + this.showProjectNumbersBarChart = !this.showProjectNumbersBarChart + this.showProjectNumbersAreaChart = !this.showProjectNumbersAreaChart + break } default: { - break; + break } } } diff --git a/src/app/vo_manager/resources/resources.component.ts b/src/app/vo_manager/resources/resources.component.ts index 4092e7a2bf..a2eb454afe 100644 --- a/src/app/vo_manager/resources/resources.component.ts +++ b/src/app/vo_manager/resources/resources.component.ts @@ -1,13 +1,9 @@ -import { - Component, ElementRef, OnInit, ViewChild, inject, -} from '@angular/core'; +import { Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core' -import { - CsvOutput, download, generateCsv, mkConfig, -} from 'export-to-csv'; -import { MatomoTracker } from 'ngx-matomo-client'; -import { VoService } from '../../api-connector/vo.service'; -import { Resources } from './resources'; +import { CsvOutput, download, generateCsv, mkConfig } from 'export-to-csv' +import { MatomoTracker } from 'ngx-matomo-client' +import { VoService } from '../../api-connector/vo.service' +import { Resources } from './resources' /** * Resource component. @@ -16,28 +12,28 @@ import { Resources } from './resources'; selector: 'app-resources', templateUrl: './resources.component.html', styleUrls: ['./resources.component.scss'], - providers: [VoService], + providers: [VoService] }) export class ResourcesComponent implements OnInit { - private readonly tracker = inject(MatomoTracker); - title: string = 'VO Overview: Resources'; - @ViewChild('resourcesTable') pdfTable: ElementRef; + private readonly tracker = inject(MatomoTracker) + title: string = 'VO Overview: Resources' + @ViewChild('resourcesTable') pdfTable: ElementRef - isLoaded: boolean = false; - voResources: Resources[] = []; - fileName: string = 'VoResources'; - tableId: string = 'resourcesTable'; - today: number = Date.now(); + isLoaded: boolean = false + voResources: Resources[] = [] + fileName: string = 'VoResources' + tableId: string = 'resourcesTable' + today: number = Date.now() constructor(private voservice: VoService) { - this.getVoProjectResources(); + this.getVoProjectResources() } public getVoProjectResources(): void { this.voservice.getVoProjectResources().subscribe((res: Resources[]): void => { - this.voResources = res; - this.isLoaded = true; - }); + this.voResources = res + this.isLoaded = true + }) } public tableToCSV(): void { @@ -50,17 +46,17 @@ export class ResourcesComponent implements OnInit { filename: 'vo_resources.csv', useTextFile: false, useBom: true, - useKeysAsHeaders: true, + useKeysAsHeaders: true // headers: ['Column 1', 'Column 2', etc...] <-- Won't work with useKeysAsHeaders present! - }); + }) - const converted: any[] = this.voResources.map((res: Resources) => Object.assign(res)); - const csv: CsvOutput = generateCsv(csvConfig)(converted); + const converted: any[] = this.voResources.map((res: Resources) => Object.assign(res)) + const csv: CsvOutput = generateCsv(csvConfig)(converted) - download(csvConfig)(csv); + download(csvConfig)(csv) } ngOnInit(): void { - this.tracker.trackPageView('VO Overview Resources'); + this.tracker.trackPageView('VO Overview Resources') } } diff --git a/src/environments/environment.custom.ts b/src/environments/environment.custom.ts index 13631f6f4b..8d95998763 100644 --- a/src/environments/environment.custom.ts +++ b/src/environments/environment.custom.ts @@ -1,8 +1,8 @@ -const API_HOST: string = window['env']['API_HOST'] || 'cloud.denbi.de'; -const VO_NAME: string = window['env']['VO_NAME'] || 'denbi'; -const NEW_SIMPLE_VM: string = window['env']['NEW_SIMPLE_VM'] || 'https://simplevm.denbi.de'; -const MATOMO_SITE_ID = window['env']['MATOMO_SITE_ID'] || 22; -const MATOMO_TRACKING_URL = window['env']['MATOMO_TRACKING_URL'] || 'https://piwik.cebitec.uni-bielefeld.de/'; +const API_HOST: string = window['env']['API_HOST'] || 'cloud.denbi.de' +const VO_NAME: string = window['env']['VO_NAME'] || 'denbi' +const NEW_SIMPLE_VM: string = window['env']['NEW_SIMPLE_VM'] || 'https://simplevm.denbi.de' +const MATOMO_SITE_ID = window['env']['MATOMO_SITE_ID'] || 22 +const MATOMO_TRACKING_URL = window['env']['MATOMO_TRACKING_URL'] || 'https://piwik.cebitec.uni-bielefeld.de/' export const environment: any = { WIKI_PRE: `https://${API_HOST}/wiki/`, @@ -21,5 +21,5 @@ export const environment: any = { login: `https://${API_HOST}/portal/api/v0/loggedUser/`, webapp: `https://${API_HOST}/portal/webapp/`, MATOMO_SITE_ID, - MATOMO_TRACKING_URL, -}; + MATOMO_TRACKING_URL +} diff --git a/src/environments/environment.ts b/src/environments/environment.ts index db5230cd45..3419178d3b 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -3,10 +3,10 @@ // `ng build --env=prod` then `environment.prod.ts` will be used instead. // The list of which env maps to which file can be found in `angular-cli.json`. -const VO_NAME: string = window['env']['VO_NAME'] || 'denbi-dev'; -const NEW_SIMPLE_VM: string = window['env']['NEW_SIMPLE_VM'] || 'https://simplevm.denbi.de'; -const MATOMO_SITE_ID = window['env']['MATOMO_SITE_ID'] || 0; -const MATOMO_TRACKING_URL = window['env']['MATOMO_TRACKING_URL'] || ''; +const VO_NAME: string = window['env']['VO_NAME'] || 'denbi-dev' +const NEW_SIMPLE_VM: string = window['env']['NEW_SIMPLE_VM'] || 'https://simplevm.denbi.de' +const MATOMO_SITE_ID = window['env']['MATOMO_SITE_ID'] || 0 +const MATOMO_TRACKING_URL = window['env']['MATOMO_TRACKING_URL'] || '' export const environment: any = { WIKI_PRE: 'https://portal-dev.denbi.de/wiki/', @@ -27,5 +27,5 @@ export const environment: any = { login: 'http://localhost:8000/api/v0/loggedUser/', webapp: 'http://localhost:8001/', MATOMO_SITE_ID, - MATOMO_TRACKING_URL, -}; + MATOMO_TRACKING_URL +} diff --git a/src/links/links.ts b/src/links/links.ts index feaa7f95fc..8c47430b5b 100644 --- a/src/links/links.ts +++ b/src/links/links.ts @@ -1,63 +1,68 @@ -import { environment } from '../environments/environment'; +import { environment } from '../environments/environment' -export const WIKI_SNAPSHOTS: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/snapshots/`; -export const WIKI: string = `${environment.WIKI_PRE}`; -export const WIKI_GENERATE_KEYS: string = `${environment.WIKI_PRE}quickstart/#generate-ssh-keys`; -export const WIKI_NEWS_MANAGEMENT: string = `${environment.WIKI_PRE}cloud_admin/#news-management`; -export const WIKI_SIMPLEVM_CUSTOMISATION: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/customization/`; -export const WIKI_EXTEND_VOLUME: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/volumes/#extend-a-volume`; -export const WIKI_VOLUME_OVERVIEW: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/volumes/`; -export const WIKI_RESENV_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/customization/#research-environments`; -export const WIKI_RSTUDIO_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/customization/#rstudio`; -export const WIKI_JUPYTERLAB_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/customization/#jupyterlab`; -export const WIKI_GUACAMOLE_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/customization/#apache-guacamole`; -export const WIKI_NEW_INSTANCE_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/Instance/create_instance/`; -export const WIKI_INSTANCE_OVERVIEW_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/Instance/instance_overview/`; -export const WIKI_INSTANCE_DETAIL_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/Instance/instance_detail/`; -export const WIKI_LINK_ACCOUNTS: string = `${environment.WIKI_PRE}portal/user_information/#link-accounts-to-elixir`; -export const WIKI_CLOUD_TERMS_LINK: string = `${environment.WIKI_PRE}portal/allocation/#terms`; -export const LIFESCIENCE_LINKING_ACCOUNTS: string = 'https://profile.aai.lifescience-ri.eu/profile/identities'; -export const LIFESCIENCE_PROFILE_CONSENT: string = 'https://profile.aai.lifescience-ri.eu/profile/consents'; -export const WIKI_PRINCIPAL_INVESTIGATOR: string = 'https://cloud.denbi.de/wiki/portal/allocation/#principal-investigator'; -export const WIKI_LINKING_ACCOUNTS: string = 'https://cloud.denbi.de/wiki/portal/user_information/#link-accounts-to-lifescience-formerly-elixir'; -export const WIKI_PUBLICATIONS: string = `${environment.WIKI_PRE}citation_and_publication/#publications`; -export const WIKI_MEMBER_MANAGEMENT: string = `${environment.WIKI_PRE}portal/project_overview/#member-management`; -export const WIKI_FAQ: string = `${environment.WIKI_PRE}FAQ/`; -export const WIKI_MOTD: string = `${environment.WIKI_PRE}cloud_admin/news_management/#message-of-the-day`; -export const WIKI_WORKSHOPS: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/workshop/`; -export const WIKI_CREATE_SNAPSHOT_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/snapshots/#create-a-snapshot`; -export const SCALE_SCRIPT_LINK: string = 'https://raw.githubusercontent.com/deNBI/user_scripts/master/bibigrid/scaling.py'; -export const WIKI_MOUNT_VOLUME: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/volumes/#mount-a-volume`; -export const WIKI_MOSH_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}Tutorials/Mosh/`; -export const WIKI_EPHEMERAL_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/Instance/create_instance/#about-ephemeral-flavors`; -export const SCALING_UP_WIKI: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/Cluster/cluster_overview/#scale-up-your-cluster`; -export const CREDITS_WIKI: string = `${environment.WIKI_PRE}portal/credits/`; -export const WIKI_PERSONAL_DATA: string = `${environment.WIKI_PRE}portal/personal_data`; -export const SURVEY_LINK: string = 'https://cloud.denbi.de/survey/index.php/252136?lang=en'; -export const CLOUD_PORTAL_SUPPORT_MAIL = 'cloud-helpdesk@denbi.de'; -export const POLICY_LINK: string = 'https://cloud.denbi.de/about/policies/'; -export const SIMPLE_VM_LINK: string = 'https://cloud.denbi.de/about/project-types/simplevm/'; -export const OPENSTACK_LINK: string = 'https://cloud.denbi.de/about/project-types/openstack/'; -export const KUBERNETES_LINK: string = 'https://cloud.denbi.de/about/project-types/kubernetes/'; -export const PROJECT_TYPES_LINK: string = 'https://cloud.denbi.de/about/project-types/'; -export const PUBLICATIONS_LINK: string = 'https://cloud.denbi.de/about/publications/'; -export const PUBLIC_DOI_ENDPOINT: string = `${environment.apiBase}public/statistic/doi/ `; -export const FACILITY_NEWS_LINK: string = 'https://cloud.denbi.de/news/facility-news/'; -export const STATUS_LINK: string = 'https://status.cloud.denbi.de/status'; -export const SUPPORT_LINK: string = 'https://cloud.denbi.de/support/'; -export const ZAMMAD_HELPDESK_LINK = 'https://helpdesk.cloud.denbi.de'; -export const GDPR_LINK = 'https://gdpr.eu/article-9-processing-special-categories-of-personal-data-prohibited/'; -export const LIFESCIENCE_HOSTEL_SIGNUP = 'https://signup.aai.lifescience-ri.eu/non/registrar/?vo=lifescience_hostel&targetnew=https%3A%2F%2Flifescience-ri.eu%2Faai%2Fhow-use&targetexisting=https%3A%2F%2Flifescience-ri.eu%2Faai%2Fhow-use&targetextended=https%3A%2F%2Flifescience-ri.eu%2Faai%2Fhow-use'; -export const WIKI_PERSISTENT_TERMINAL_LINK = `${environment.WIKI_PRE}Tutorials/Persistent_SSH_Sessions/`; -export const WIKI_BACKUP_LINK = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/backup`; +export const WIKI_SNAPSHOTS: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/snapshots/` +export const WIKI: string = `${environment.WIKI_PRE}` +export const WIKI_GENERATE_KEYS: string = `${environment.WIKI_PRE}quickstart/#generate-ssh-keys` +export const WIKI_NEWS_MANAGEMENT: string = `${environment.WIKI_PRE}cloud_admin/#news-management` +export const WIKI_SIMPLEVM_CUSTOMISATION: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/customization/` +export const WIKI_EXTEND_VOLUME: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/volumes/#extend-a-volume` +export const WIKI_VOLUME_OVERVIEW: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/volumes/` +export const WIKI_RESENV_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/customization/#research-environments` +export const WIKI_RSTUDIO_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/customization/#rstudio` +export const WIKI_JUPYTERLAB_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/customization/#jupyterlab` +export const WIKI_GUACAMOLE_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/customization/#apache-guacamole` +export const WIKI_NEW_INSTANCE_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/Instance/create_instance/` +export const WIKI_INSTANCE_OVERVIEW_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/Instance/instance_overview/` +export const WIKI_INSTANCE_DETAIL_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/Instance/instance_detail/` +export const WIKI_LINK_ACCOUNTS: string = `${environment.WIKI_PRE}portal/user_information/#link-accounts-to-elixir` +export const WIKI_CLOUD_TERMS_LINK: string = `${environment.WIKI_PRE}portal/allocation/#terms` +export const LIFESCIENCE_LINKING_ACCOUNTS: string = 'https://profile.aai.lifescience-ri.eu/profile/identities' +export const LIFESCIENCE_PROFILE_CONSENT: string = 'https://profile.aai.lifescience-ri.eu/profile/consents' +export const WIKI_PRINCIPAL_INVESTIGATOR: string = + 'https://cloud.denbi.de/wiki/portal/allocation/#principal-investigator' +export const WIKI_LINKING_ACCOUNTS: string = + 'https://cloud.denbi.de/wiki/portal/user_information/#link-accounts-to-lifescience-formerly-elixir' +export const WIKI_PUBLICATIONS: string = `${environment.WIKI_PRE}citation_and_publication/#publications` +export const WIKI_MEMBER_MANAGEMENT: string = `${environment.WIKI_PRE}portal/project_overview/#member-management` +export const WIKI_FAQ: string = `${environment.WIKI_PRE}FAQ/` +export const WIKI_MOTD: string = `${environment.WIKI_PRE}cloud_admin/news_management/#message-of-the-day` +export const WIKI_WORKSHOPS: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/workshop/` +export const WIKI_CREATE_SNAPSHOT_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/snapshots/#create-a-snapshot` +export const SCALE_SCRIPT_LINK: string = + 'https://raw.githubusercontent.com/deNBI/user_scripts/master/bibigrid/scaling.py' +export const WIKI_MOUNT_VOLUME: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/volumes/#mount-a-volume` +export const WIKI_MOSH_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}Tutorials/Mosh/` +export const WIKI_EPHEMERAL_LINK: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/Instance/create_instance/#about-ephemeral-flavors` +export const SCALING_UP_WIKI: string = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/Cluster/cluster_overview/#scale-up-your-cluster` +export const CREDITS_WIKI: string = `${environment.WIKI_PRE}portal/credits/` +export const WIKI_PERSONAL_DATA: string = `${environment.WIKI_PRE}portal/personal_data` +export const SURVEY_LINK: string = 'https://cloud.denbi.de/survey/index.php/252136?lang=en' +export const CLOUD_PORTAL_SUPPORT_MAIL = 'cloud-helpdesk@denbi.de' +export const POLICY_LINK: string = 'https://cloud.denbi.de/about/policies/' +export const SIMPLE_VM_LINK: string = 'https://cloud.denbi.de/about/project-types/simplevm/' +export const OPENSTACK_LINK: string = 'https://cloud.denbi.de/about/project-types/openstack/' +export const KUBERNETES_LINK: string = 'https://cloud.denbi.de/about/project-types/kubernetes/' +export const PROJECT_TYPES_LINK: string = 'https://cloud.denbi.de/about/project-types/' +export const PUBLICATIONS_LINK: string = 'https://cloud.denbi.de/about/publications/' +export const PUBLIC_DOI_ENDPOINT: string = `${environment.apiBase}public/statistic/doi/ ` +export const FACILITY_NEWS_LINK: string = 'https://cloud.denbi.de/news/facility-news/' +export const STATUS_LINK: string = 'https://status.cloud.denbi.de/status' +export const SUPPORT_LINK: string = 'https://cloud.denbi.de/support/' +export const ZAMMAD_HELPDESK_LINK = 'https://helpdesk.cloud.denbi.de' +export const GDPR_LINK = 'https://gdpr.eu/article-9-processing-special-categories-of-personal-data-prohibited/' +export const LIFESCIENCE_HOSTEL_SIGNUP = + 'https://signup.aai.lifescience-ri.eu/non/registrar/?vo=lifescience_hostel&targetnew=https%3A%2F%2Flifescience-ri.eu%2Faai%2Fhow-use&targetexisting=https%3A%2F%2Flifescience-ri.eu%2Faai%2Fhow-use&targetextended=https%3A%2F%2Flifescience-ri.eu%2Faai%2Fhow-use' +export const WIKI_PERSISTENT_TERMINAL_LINK = `${environment.WIKI_PRE}Tutorials/Persistent_SSH_Sessions/` +export const WIKI_BACKUP_LINK = `${environment.SIMPLEVM_WIKI_PRE}simple_vm/backup` -export const WIKI_SVM_MIGRATION_LINK = `${environment.WIKI_PRE}`; +export const WIKI_SVM_MIGRATION_LINK = `${environment.WIKI_PRE}` -export const NEW_SVM_PORTAL_LINK = `${environment.NEW_SVM_PORTAL_LINK}`; +export const NEW_SVM_PORTAL_LINK = `${environment.NEW_SVM_PORTAL_LINK}` -export const TESTIMONIAL_PAGE_LINK: string = `${environment.wagtailBase}about/testimonials/`; +export const TESTIMONIAL_PAGE_LINK: string = `${environment.wagtailBase}about/testimonials/` -export const SINGLE_TESTIMONIAL_PAGE_LINK: string = 'https://cloud.denbi.de/about/testimonials/denbi-biohackathon-spacehack-project/'; +export const SINGLE_TESTIMONIAL_PAGE_LINK: string = + 'https://cloud.denbi.de/about/testimonials/denbi-biohackathon-spacehack-project/' export const WIKI_LINKS: string[] = [ WIKI_SNAPSHOTS, @@ -84,8 +89,8 @@ export const WIKI_LINKS: string[] = [ WIKI_MOSH_LINK, WIKI_PERSONAL_DATA, WIKI_SVM_MIGRATION_LINK, - WIKI_BACKUP_LINK, -]; + WIKI_BACKUP_LINK +] export const LANDING_PAGE_LINKS: string[] = [ POLICY_LINK, @@ -96,5 +101,5 @@ export const LANDING_PAGE_LINKS: string[] = [ FACILITY_NEWS_LINK, STATUS_LINK, SUPPORT_LINK, - TESTIMONIAL_PAGE_LINK, -]; + TESTIMONIAL_PAGE_LINK +] diff --git a/src/test.ts b/src/test.ts index 7ae5fe21f6..544b0d99b5 100644 --- a/src/test.ts +++ b/src/test.ts @@ -1,25 +1,25 @@ // This file is required by karma.conf.js and loads recursively all the .spec and framework files // tslint:disable -import 'zone.js/dist/long-stack-trace-zone'; -import 'zone.js/dist/proxy.js'; -import 'zone.js/dist/sync-test'; -import 'zone.js/dist/jasmine-patch'; -import 'zone.js/dist/async-test'; -import 'zone.js/dist/fake-async-test'; -import { getTestBed } from '@angular/core/testing'; -import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; +import 'zone.js/dist/long-stack-trace-zone' +import 'zone.js/dist/proxy.js' +import 'zone.js/dist/sync-test' +import 'zone.js/dist/jasmine-patch' +import 'zone.js/dist/async-test' +import 'zone.js/dist/fake-async-test' +import { getTestBed } from '@angular/core/testing' +import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing' // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. -declare let __karma__: any; +declare let __karma__: any // Prevent Karma from running prematurely. -// eslint-disable-next-line func-names -__karma__.loaded = function () {}; + +__karma__.loaded = function () {} // First, initialize the Angular testing environment. getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { - teardown: { destroyAfterEach: false }, -}); + teardown: { destroyAfterEach: false } +}) // Finally, start Karma to run the tests. -__karma__.start(); +__karma__.start()