From 613dfc597d2f7ab2fd528fd767aeec9d56b9ea2d Mon Sep 17 00:00:00 2001 From: pengpengshui Date: Wed, 16 Aug 2017 17:35:36 +0800 Subject: [PATCH 1/7] fix #3046 about delete ID from 'copy Digest ID' --- src/ui_ng/src/i18n/lang/en-us-lang.json | 2 +- src/ui_ng/src/i18n/lang/zh-cn-lang.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui_ng/src/i18n/lang/en-us-lang.json b/src/ui_ng/src/i18n/lang/en-us-lang.json index c5b0d6d802..c49b49830d 100644 --- a/src/ui_ng/src/i18n/lang/en-us-lang.json +++ b/src/ui_ng/src/i18n/lang/en-us-lang.json @@ -312,7 +312,7 @@ "PLACEHOLDER": "We couldn't find any endpoints!" }, "REPOSITORY": { - "COPY_DIGEST_ID": "Copy Digest ID", + "COPY_DIGEST_ID": "Copy Digest", "DELETE": "Delete", "NAME": "Name", "TAGS_COUNT": "Tags", diff --git a/src/ui_ng/src/i18n/lang/zh-cn-lang.json b/src/ui_ng/src/i18n/lang/zh-cn-lang.json index 3488cb40c0..79f49f42ff 100644 --- a/src/ui_ng/src/i18n/lang/zh-cn-lang.json +++ b/src/ui_ng/src/i18n/lang/zh-cn-lang.json @@ -312,7 +312,7 @@ "PLACEHOLDER": "未发现任何复制目标!" }, "REPOSITORY": { - "COPY_DIGEST_ID": "复制摘要ID", + "COPY_DIGEST_ID": "复制摘要", "DELETE": "删除", "NAME": "名称", "TAGS_COUNT": "标签数", From 04929c98f70ea7cb8774311c86ad1c4aee7395e1 Mon Sep 17 00:00:00 2001 From: pengpengshui Date: Thu, 17 Aug 2017 14:29:23 +0800 Subject: [PATCH 2/7] fix issue about back to public project #1918 --- .../project-detail.component.css | 4 +++- .../project-detail.component.html | 2 +- .../project-detail.component.ts | 9 ++++++++- .../src/app/project/project.component.html | 2 +- .../src/app/project/project.component.ts | 19 +++++++++++++++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/ui_ng/src/app/project/project-detail/project-detail.component.css b/src/ui_ng/src/app/project/project-detail/project-detail.component.css index 90f5add5f0..1bf9b2c6e6 100644 --- a/src/ui_ng/src/app/project/project-detail/project-detail.component.css +++ b/src/ui_ng/src/app/project/project-detail/project-detail.component.css @@ -16,4 +16,6 @@ font-size: 14px; font-style: italic; letter-spacing: 0.01em; -} \ No newline at end of file +} +.cursor{ + cursor: pointer;} \ No newline at end of file diff --git a/src/ui_ng/src/app/project/project-detail/project-detail.component.html b/src/ui_ng/src/app/project/project-detail/project-detail.component.html index fcb18e0af1..6f7f3717c1 100644 --- a/src/ui_ng/src/app/project/project-detail/project-detail.component.html +++ b/src/ui_ng/src/app/project/project-detail/project-detail.component.html @@ -1,4 +1,4 @@ -< {{'PROJECT_DETAIL.PROJECTS' | translate}} +< {{'PROJECT_DETAIL.PROJECTS' | translate}} < {{'SEARCH.BACK' | translate}}

{{currentProject.name}} {{roleName | translate}}

diff --git a/src/ui_ng/src/app/project/project-detail/project-detail.component.ts b/src/ui_ng/src/app/project/project-detail/project-detail.component.ts index c0d4a3a4b4..2e2bfd03c2 100644 --- a/src/ui_ng/src/app/project/project-detail/project-detail.component.ts +++ b/src/ui_ng/src/app/project/project-detail/project-detail.component.ts @@ -57,4 +57,11 @@ export class ProjectDetailComponent { return this.sessionService.getCurrentUser() != null; } -} \ No newline at end of file + backToProject(): void { + if (window.sessionStorage) { + window.sessionStorage.setItem('fromDetails', 'true'); + } + this.router.navigate(['/harbor', 'projects']); + } + +} diff --git a/src/ui_ng/src/app/project/project.component.html b/src/ui_ng/src/app/project/project.component.html index d1d6f09e13..d55f959304 100644 --- a/src/ui_ng/src/app/project/project.component.html +++ b/src/ui_ng/src/app/project/project.component.html @@ -13,7 +13,7 @@
- diff --git a/src/ui_ng/src/app/project/project.component.ts b/src/ui_ng/src/app/project/project.component.ts index 8242ed4980..0a0e1504ad 100644 --- a/src/ui_ng/src/app/project/project.component.ts +++ b/src/ui_ng/src/app/project/project.component.ts @@ -47,6 +47,7 @@ import { StatisticHandler } from '../shared/statictics/statistic-handler.service changeDetection: ChangeDetectionStrategy.OnPush }) export class ProjectComponent implements OnInit, OnDestroy { + selecteType:number = 0; changedProjects: Project[]; projectTypes = ProjectTypes; @@ -121,6 +122,16 @@ export class ProjectComponent implements OnInit, OnDestroy { retrieve(state?: State): void { this.projectName = ""; + + if (window.sessionStorage && window.sessionStorage['projectTypeValue'] && window.sessionStorage['fromDetails']) { + this.currentFilteredType = +window.sessionStorage['projectTypeValue']; + this.selecteType = this.currentFilteredType; + window.sessionStorage.removeItem('fromDetails'); + } + if (this.currentFilteredType !== 0) { + this.getProjects('', this.currentFilteredType - 1); + return; + } this.getProjects(); } @@ -175,6 +186,9 @@ export class ProjectComponent implements OnInit, OnDestroy { } else { this.getProjects("", this.currentFilteredType - 1); } + if (window.sessionStorage) { + window.sessionStorage['projectTypeValue'] = this.currentFilteredType; + } } } @@ -192,6 +206,11 @@ export class ProjectComponent implements OnInit, OnDestroy { } else { this.getProjects("", this.currentFilteredType - 1); } + + this.selecteType = this.currentFilteredType; + if (window.sessionStorage) { + window.sessionStorage['projectTypeValue'] = this.currentFilteredType; + } }, error => this.messageHandlerService.handleError(error) ); From 78e1f8c8cec753b5ff3a97b3ee0259719abbdab6 Mon Sep 17 00:00:00 2001 From: pengpengshui Date: Thu, 17 Aug 2017 14:42:36 +0800 Subject: [PATCH 3/7] fix issues about image have no data an scan complete time in image detail ,3054,3023 --- src/ui_ng/lib/src/tag/tag-detail.component.css.ts | 4 ++++ src/ui_ng/lib/src/tag/tag-detail.component.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ui_ng/lib/src/tag/tag-detail.component.css.ts b/src/ui_ng/lib/src/tag/tag-detail.component.css.ts index 7c3f062df9..2bfb781d8c 100644 --- a/src/ui_ng/lib/src/tag/tag-detail.component.css.ts +++ b/src/ui_ng/lib/src/tag/tag-detail.component.css.ts @@ -112,4 +112,8 @@ export const TAG_DETAIL_STYLES: string = ` .tip-icon-low{ color:yellow; } +.second-column div, .fourth-column div, .image-detail-value div{ +height: 24px; +} + `; \ No newline at end of file diff --git a/src/ui_ng/lib/src/tag/tag-detail.component.ts b/src/ui_ng/lib/src/tag/tag-detail.component.ts index 5572742e56..cfcf3281a6 100644 --- a/src/ui_ng/lib/src/tag/tag-detail.component.ts +++ b/src/ui_ng/lib/src/tag/tag-detail.component.ts @@ -101,7 +101,7 @@ export class TagDetailComponent implements OnInit { public get scanCompletedDatetime(): Date { return this.tagDetails && this.tagDetails.scan_overview ? - this.tagDetails.scan_overview.update_time : new Date(); + this.tagDetails.scan_overview.update_time : null; } public get suffixForHigh(): string { From 160593a86a5a1ab4cb6f8611eeee86a216c9a091 Mon Sep 17 00:00:00 2001 From: pengpengshui Date: Thu, 17 Aug 2017 14:45:13 +0800 Subject: [PATCH 4/7] fix issue about no warn when deleting repository which contains signed tags, 3022 --- .../repository-stackview.component.html.ts | 2 +- .../repository-stackview.component.ts | 99 ++++++++++++++++--- src/ui_ng/lib/src/tag/tag.component.ts | 20 ++-- src/ui_ng/src/i18n/lang/en-us-lang.json | 2 + src/ui_ng/src/i18n/lang/es-es-lang.json | 2 + src/ui_ng/src/i18n/lang/zh-cn-lang.json | 2 + 6 files changed, 104 insertions(+), 23 deletions(-) diff --git a/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.html.ts b/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.html.ts index 4be3af9c03..86746dc654 100644 --- a/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.html.ts +++ b/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.html.ts @@ -23,7 +23,7 @@ export const REPOSITORY_STACKVIEW_TEMPLATE: string = ` {{r.name}} {{r.tags_count}} {{r.pull_count}} - + diff --git a/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.ts b/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.ts index 3d02c30003..c8cb663748 100644 --- a/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.ts +++ b/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.ts @@ -6,7 +6,7 @@ import { ViewChild, ChangeDetectionStrategy, ChangeDetectorRef, - EventEmitter + EventEmitter, OnChanges, SimpleChanges } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { Comparator } from 'clarity-angular'; @@ -41,6 +41,7 @@ import { doFiltering, doSorting } from '../utils'; +import {TagService} from '../service/index'; @Component({ selector: 'hbr-repository-stackview', @@ -48,7 +49,8 @@ import { styles: [REPOSITORY_STACKVIEW_STYLES], changeDetection: ChangeDetectionStrategy.OnPush }) -export class RepositoryStackviewComponent implements OnInit { +export class RepositoryStackviewComponent implements OnChanges, OnInit { + signedCon: {[key: string]: any | string[]} = {}; @Input() projectId: number; @Input() projectName: string = "unknown"; @@ -80,6 +82,8 @@ export class RepositoryStackviewComponent implements OnInit { private translateService: TranslateService, private repositoryService: RepositoryService, private systemInfoService: SystemInfoService, + private translate: TranslateService, + private tagService: TagService, private ref: ChangeDetectorRef) { } public get registryUrl(): string { @@ -122,15 +126,24 @@ export class RepositoryStackviewComponent implements OnInit { } this.translateService.get('REPOSITORY.DELETED_REPO_SUCCESS') .subscribe(res => this.errorHandler.info(res)); - }).catch(error => this.errorHandler.error(error)); + }).catch(error => { + if (error.status === "412"){ + this.translateService.get('REPOSITORY.TAGS_SIGNED') + .subscribe(res => this.errorHandler.info(res)); + return; + } + this.errorHandler.error(error); + }); + } + } + + ngOnChanges(changes: SimpleChanges): void { + if (changes['projectId']) { + this.refresh(); } } ngOnInit(): void { - if (!this.projectId) { - this.errorHandler.error('Project ID cannot be unset.'); - return; - } //Get system info for tag views toPromise(this.systemInfoService.getSystemInfo()) .then(systemInfo => this.systemInfo = systemInfo) @@ -153,15 +166,67 @@ export class RepositoryStackviewComponent implements OnInit { this.clrLoad(st); } + saveSignatures(event: {[key: string]: string[]}): void { + Object.assign(this.signedCon, event); + } + deleteRepo(repoName: string) { - let message = new ConfirmationMessage( - 'REPOSITORY.DELETION_TITLE_REPO', - 'REPOSITORY.DELETION_SUMMARY_REPO', - repoName, - repoName, - ConfirmationTargets.REPOSITORY, - ConfirmationButtons.DELETE_CANCEL); - this.confirmationDialog.open(message); + // get children tags data + + let signature: string = ''; + if (this.signedCon[repoName]) { + if (this.signedCon[repoName].length === 0) { + this.confirmationDialogSet('DELETION_TITLE_REPO', signature, repoName, 'REPOSITORY.DELETION_SUMMARY_REPO', ConfirmationButtons.DELETE_CANCEL); + return; + } + signature = this.signedCon[repoName].join(','); + this.confirmationDialogSet('DELETION_TITLE_REPO_SIGNED', signature, repoName, 'REPOSITORY.DELETION_SUMMARY_REPO_SIGNED', ConfirmationButtons.CLOSE); + } else { + this.getTagInfo(repoName).then(() => { + if (this.signedCon[repoName].length) { + signature = this.signedCon[repoName].join(','); + this.confirmationDialogSet('DELETION_TITLE_REPO_SIGNED', signature, repoName, 'REPOSITORY.DELETION_SUMMARY_REPO_SIGNED', ConfirmationButtons.CLOSE); + } else { + this.confirmationDialogSet('DELETION_TITLE_REPO', signature, repoName, 'REPOSITORY.DELETION_SUMMARY_REPO', ConfirmationButtons.DELETE_CANCEL); + } + }); + } + } + getTagInfo(repoName: string): Promise { + // this.signedNameArr = []; + this.signedCon[repoName] = []; + return toPromise(this.tagService + .getTags(repoName)) + .then(items => { + items.forEach((t: Tag) => { + if (t.signature !== null) { + this.signedCon[repoName].push(t.name); + } + }); + }) + .catch(error => this.errorHandler.error(error)); + } + + confirmationDialogSet(summaryTitle: string, signature: string, repoName: string, summaryKey: string, button: ConfirmationButtons): void { + this.translate.get(summaryKey, + { + repoName: repoName, + signedImages: signature, + }) + .subscribe((res: string) => { + summaryKey = res; + let message = new ConfirmationMessage( + summaryTitle, + summaryKey, + repoName, + repoName, + ConfirmationTargets.REPOSITORY, + button); + this.confirmationDialog.open(message); + + let hnd = setInterval(() => this.ref.markForCheck(), 100); + setTimeout(() => clearInterval(hnd), 5000); + }); } refresh() { @@ -194,6 +259,7 @@ export class RepositoryStackviewComponent implements OnInit { this.totalCount = repo.metadata.xTotalCount; this.repositories = repo.data; + this.signedCon = {}; //Do filtering and sorting this.repositories = doFiltering(this.repositories, state); this.repositories = doSorting(this.repositories, state); @@ -231,4 +297,5 @@ export class RepositoryStackviewComponent implements OnInit { return st; } -} \ No newline at end of file +} + diff --git a/src/ui_ng/lib/src/tag/tag.component.ts b/src/ui_ng/lib/src/tag/tag.component.ts index caf46bf3ff..a056e67598 100644 --- a/src/ui_ng/lib/src/tag/tag.component.ts +++ b/src/ui_ng/lib/src/tag/tag.component.ts @@ -71,10 +71,11 @@ export class TagComponent implements OnInit { @Output() refreshRepo = new EventEmitter(); @Output() tagClickEvent = new EventEmitter(); + @Output() signatureOutput = new EventEmitter(); + tags: Tag[]; - showTagManifestOpened: boolean; manifestInfoTitle: string; digestId: string; @@ -136,6 +137,7 @@ export class TagComponent implements OnInit { retrieve() { this.tags = []; + let signatures: string[] = [] ; this.loading = true; toPromise(this.tagService @@ -151,11 +153,17 @@ export class TagComponent implements OnInit { components: { total: 0, summary: [] - } - }; - } - }); - this.tags = items; + } + }; + } + if (t.signature !== null) { + signatures.push(t.name); + } + }); + this.tags = items; + let signedName: {[key: string]: string[]} = {}; + signedName[this.repoName] = signatures; + this.signatureOutput.emit(signedName); this.loading = false; if (this.tags && this.tags.length === 0) { this.refreshRepo.emit(true); diff --git a/src/ui_ng/src/i18n/lang/en-us-lang.json b/src/ui_ng/src/i18n/lang/en-us-lang.json index c49b49830d..4386ecaf54 100644 --- a/src/ui_ng/src/i18n/lang/en-us-lang.json +++ b/src/ui_ng/src/i18n/lang/en-us-lang.json @@ -321,6 +321,8 @@ "MY_REPOSITORY": "My Repository", "PUBLIC_REPOSITORY": "Public Repository", "DELETION_TITLE_REPO": "Confirm Repository Deletion", + "DELETION_TITLE_REPO_SIGNED": "Repository cannot be deleted", + "DELETION_SUMMARY_REPO_SIGNED": "Repository '{{repoName}}' cannot be deleted because the following signed images existing.\n{{signedImages}} \nYou should unsign all the signed images before deleting the repository!", "DELETION_SUMMARY_REPO": "Do you want to delete repository {{param}}?", "DELETION_TITLE_TAG": "Confirm Tag Deletion", "DELETION_SUMMARY_TAG": "Do you want to delete tag {{param}}?", diff --git a/src/ui_ng/src/i18n/lang/es-es-lang.json b/src/ui_ng/src/i18n/lang/es-es-lang.json index 9ccdd061c6..a88d5e2a12 100644 --- a/src/ui_ng/src/i18n/lang/es-es-lang.json +++ b/src/ui_ng/src/i18n/lang/es-es-lang.json @@ -322,6 +322,8 @@ "MY_REPOSITORY": "Mi Repositorio", "PUBLIC_REPOSITORY": "Repositorio Público", "DELETION_TITLE_REPO": "Confirmar Eliminación de Repositorio", + "DELETION_TITLE_REPO_SIGNED": "Repository cannot be deleted", + "DELETION_SUMMARY_REPO_SIGNED": "Repository '{{repoName}}' cannot be deleted because the following signed images existing.\n{{signedImages}} \nYou should unsign all the signed images before deleting the repository!", "DELETION_SUMMARY_REPO": "¿Quiere eliminar el repositorio {{param}}?", "DELETION_TITLE_TAG": "Confirmación de Eliminación de Etiqueta", "DELETION_SUMMARY_TAG": "¿Quiere eliminar la etiqueta {{param}}?", diff --git a/src/ui_ng/src/i18n/lang/zh-cn-lang.json b/src/ui_ng/src/i18n/lang/zh-cn-lang.json index 79f49f42ff..7bad738cdd 100644 --- a/src/ui_ng/src/i18n/lang/zh-cn-lang.json +++ b/src/ui_ng/src/i18n/lang/zh-cn-lang.json @@ -321,6 +321,8 @@ "MY_REPOSITORY": "我的仓库", "PUBLIC_REPOSITORY": "公共仓库", "DELETION_TITLE_REPO": "删除镜像仓库确认", + "DELETION_TITLE_REPO_SIGNED": "仓库不能被删除", + "DELETION_SUMMARY_REPO_SIGNED": "镜像仓库 '{{repoName}}' 不能被删除,因为存在以下签名镜像.\n{{signedImages}} \n在删除镜像仓库前需先删除所有的签名镜像", "DELETION_SUMMARY_REPO": "确认删除镜像仓库 {{param}}?", "DELETION_TITLE_TAG": "删除镜像标签确认", "DELETION_SUMMARY_TAG": "确认删除镜像标签 {{param}}?", From b362e4d36a197f9f8c4618953542b27774e0e886 Mon Sep 17 00:00:00 2001 From: pengpengshui Date: Thu, 17 Aug 2017 14:59:25 +0800 Subject: [PATCH 5/7] fix issue about cannot click add replication button , 3071 --- src/ui_ng/lib/src/replication/replication.component.css.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ui_ng/lib/src/replication/replication.component.css.ts b/src/ui_ng/lib/src/replication/replication.component.css.ts index a85801e1b2..473cfc00e4 100644 --- a/src/ui_ng/lib/src/replication/replication.component.css.ts +++ b/src/ui_ng/lib/src/replication/replication.component.css.ts @@ -9,7 +9,6 @@ export const REPLICATION_STYLE: string = ` .option-left { padding-left: 16px; - margin-top: 18px; } .option-right { padding-right: 16px; From 7393843bd09a6a9c9f991bf124222f22076630f3 Mon Sep 17 00:00:00 2001 From: "Fuhui Peng (c)" Date: Fri, 18 Aug 2017 17:41:03 +0800 Subject: [PATCH 6/7] '3022' --- .../repository-stackview.component.ts | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.ts b/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.ts index c8cb663748..1b8c892228 100644 --- a/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.ts +++ b/src/ui_ng/lib/src/repository-stackview/repository-stackview.component.ts @@ -138,7 +138,7 @@ export class RepositoryStackviewComponent implements OnChanges, OnInit { } ngOnChanges(changes: SimpleChanges): void { - if (changes['projectId']) { + if (changes['projectId'] && changes['projectId'].currentValue) { this.refresh(); } } @@ -171,24 +171,11 @@ export class RepositoryStackviewComponent implements OnChanges, OnInit { } deleteRepo(repoName: string) { - // get children tags data - - let signature: string = ''; if (this.signedCon[repoName]) { - if (this.signedCon[repoName].length === 0) { - this.confirmationDialogSet('DELETION_TITLE_REPO', signature, repoName, 'REPOSITORY.DELETION_SUMMARY_REPO', ConfirmationButtons.DELETE_CANCEL); - return; - } - signature = this.signedCon[repoName].join(','); - this.confirmationDialogSet('DELETION_TITLE_REPO_SIGNED', signature, repoName, 'REPOSITORY.DELETION_SUMMARY_REPO_SIGNED', ConfirmationButtons.CLOSE); - } else { + this.signedDataSet(repoName); + } else { this.getTagInfo(repoName).then(() => { - if (this.signedCon[repoName].length) { - signature = this.signedCon[repoName].join(','); - this.confirmationDialogSet('DELETION_TITLE_REPO_SIGNED', signature, repoName, 'REPOSITORY.DELETION_SUMMARY_REPO_SIGNED', ConfirmationButtons.CLOSE); - } else { - this.confirmationDialogSet('DELETION_TITLE_REPO', signature, repoName, 'REPOSITORY.DELETION_SUMMARY_REPO', ConfirmationButtons.DELETE_CANCEL); - } + this.signedDataSet(repoName); }); } } @@ -207,6 +194,16 @@ export class RepositoryStackviewComponent implements OnChanges, OnInit { .catch(error => this.errorHandler.error(error)); } + signedDataSet(repoName: string): void { + let signature: string = ''; + if (this.signedCon[repoName].length === 0) { + this.confirmationDialogSet('DELETION_TITLE_REPO', signature, repoName, 'REPOSITORY.DELETION_SUMMARY_REPO', ConfirmationButtons.DELETE_CANCEL); + return; + } + signature = this.signedCon[repoName].join(','); + this.confirmationDialogSet('DELETION_TITLE_REPO_SIGNED', signature, repoName, 'REPOSITORY.DELETION_SUMMARY_REPO_SIGNED', ConfirmationButtons.CLOSE); + } + confirmationDialogSet(summaryTitle: string, signature: string, repoName: string, summaryKey: string, button: ConfirmationButtons): void { this.translate.get(summaryKey, { From 45c47964867cb70facd704c4c0718808a8559b97 Mon Sep 17 00:00:00 2001 From: "Fuhui Peng (c)" Date: Fri, 18 Aug 2017 17:42:50 +0800 Subject: [PATCH 7/7] '1918' --- .../src/app/project/project.component.ts | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/ui_ng/src/app/project/project.component.ts b/src/ui_ng/src/app/project/project.component.ts index 0a0e1504ad..f81017403a 100644 --- a/src/ui_ng/src/app/project/project.component.ts +++ b/src/ui_ng/src/app/project/project.component.ts @@ -47,7 +47,6 @@ import { StatisticHandler } from '../shared/statictics/statistic-handler.service changeDetection: ChangeDetectionStrategy.OnPush }) export class ProjectComponent implements OnInit, OnDestroy { - selecteType:number = 0; changedProjects: Project[]; projectTypes = ProjectTypes; @@ -64,6 +63,15 @@ export class ProjectComponent implements OnInit, OnDestroy { subscription: Subscription; loading: boolean = true; + get selecteType (): number { + return this.currentFilteredType; + } + set selecteType(_project: number) { + if (window.sessionStorage) { + window.sessionStorage['projectTypeValue'] = _project; + } + } + constructor( private projectService: ProjectService, private messageHandlerService: MessageHandlerService, @@ -99,6 +107,10 @@ export class ProjectComponent implements OnInit, OnDestroy { } ngOnInit(): void { + if (window.sessionStorage && window.sessionStorage['projectTypeValue'] && window.sessionStorage['fromDetails']) { + this.currentFilteredType = +window.sessionStorage['projectTypeValue']; + window.sessionStorage.removeItem('fromDetails'); + } } ngOnDestroy(): void { @@ -122,12 +134,6 @@ export class ProjectComponent implements OnInit, OnDestroy { retrieve(state?: State): void { this.projectName = ""; - - if (window.sessionStorage && window.sessionStorage['projectTypeValue'] && window.sessionStorage['fromDetails']) { - this.currentFilteredType = +window.sessionStorage['projectTypeValue']; - this.selecteType = this.currentFilteredType; - window.sessionStorage.removeItem('fromDetails'); - } if (this.currentFilteredType !== 0) { this.getProjects('', this.currentFilteredType - 1); return; @@ -186,9 +192,6 @@ export class ProjectComponent implements OnInit, OnDestroy { } else { this.getProjects("", this.currentFilteredType - 1); } - if (window.sessionStorage) { - window.sessionStorage['projectTypeValue'] = this.currentFilteredType; - } } } @@ -206,11 +209,6 @@ export class ProjectComponent implements OnInit, OnDestroy { } else { this.getProjects("", this.currentFilteredType - 1); } - - this.selecteType = this.currentFilteredType; - if (window.sessionStorage) { - window.sessionStorage['projectTypeValue'] = this.currentFilteredType; - } }, error => this.messageHandlerService.handleError(error) );