diff --git a/src/ui_ng/src/app/repository/repository.service.ts b/src/ui_ng/src/app/repository/repository.service.ts index 7d2de726a..03dcfe9bd 100644 --- a/src/ui_ng/src/app/repository/repository.service.ts +++ b/src/ui_ng/src/app/repository/repository.service.ts @@ -28,10 +28,11 @@ export class RepositoryService { constructor(private http: Http){} listRepositories(projectId: number, repoName: string, page?: number, pageSize?: number): Observable { - console.log('List repositories with project ID:' + projectId); let params = new URLSearchParams(); - params.set('page', page + ''); - params.set('page_size', pageSize + ''); + if(page && pageSize) { + params.set('page', page + ''); + params.set('page_size', pageSize + ''); + } return this.http .get(`/api/repositories?project_id=${projectId}&q=${repoName}&detail=1`, {search: params}) .map(response=>response) @@ -60,7 +61,7 @@ export class RepositoryService { tags.forEach(t=>{ for(let i = 0; i < signatures.length; i++) { if(signatures[i].tag === t.tag) { - t.signed = true; + t.signed = 1; break; } } @@ -68,14 +69,13 @@ export class RepositoryService { return tags; }) .catch(error=>{ - return tags; + return Observable.of(tags); }) }) .catch(error=>Observable.throw(error)); } deleteRepository(repoName: string): Observable { - console.log('Delete repository with repo name:' + repoName); return this.http .delete(`/api/repositories/${repoName}/tags`) .map(response=>response.status) @@ -83,7 +83,6 @@ export class RepositoryService { } deleteRepoByTag(repoName: string, tag: string): Observable { - console.log('Delete repository with repo name:' + repoName + ', tag:' + tag); return this.http .delete(`/api/repositories/${repoName}/tags/${tag}`) .map(response=>response.status) diff --git a/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.html b/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.html index c0e1acf8f..4d38410c7 100644 --- a/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.html +++ b/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.html @@ -24,23 +24,27 @@ {{'REPOSITORY.DOCKER_VERSION' | translate}} {{'REPOSITORY.ARCHITECTURE' | translate}} {{'REPOSITORY.OS' | translate}} - - - - - - - {{t.tag}} - {{t.pullCommand}} - - - - - {{t.author}} - {{t.created | date: 'short'}} - {{t.dockerVersion}} - {{t.architecture}} - {{t.os}} + + + + + + + {{t.tag}} + {{t.pullCommand}} + + + + + + {{'REPOSITORY.NOTARY_IS_UNDETERMINED' | translate}} + + + {{t.author}} + {{t.created | date: 'short'}} + {{t.dockerVersion}} + {{t.architecture}} + {{t.os}} {{tags ? tags.length : 0}} {{'REPOSITORY.ITEMS' | translate}} \ No newline at end of file diff --git a/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.ts b/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.ts index 017d3de0f..2a19de475 100644 --- a/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.ts +++ b/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.ts @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -import { Component, OnInit, OnDestroy } from '@angular/core'; +import { Component, OnInit, OnDestroy, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { RepositoryService } from '../repository.service'; @@ -35,7 +35,8 @@ import { Project } from '../../project/project'; @Component({ selector: 'tag-repository', templateUrl: 'tag-repository.component.html', - styleUrls: ['./tag-repository.component.css'] + styleUrls: ['./tag-repository.component.css'], + changeDetection: ChangeDetectionStrategy.OnPush }) export class TagRepositoryComponent implements OnInit, OnDestroy { @@ -66,7 +67,8 @@ export class TagRepositoryComponent implements OnInit, OnDestroy { private deletionDialogService: ConfirmationDialogService, private repositoryService: RepositoryService, private appConfigService: AppConfigService, - private session: SessionService){ + private session: SessionService, + private ref: ChangeDetectorRef){ this.subscription = this.deletionDialogService.confirmationConfirm$.subscribe( message => { @@ -117,19 +119,31 @@ export class TagRepositoryComponent implements OnInit, OnDestroy { retrieve() { this.tags = []; + this.repositoryService + .listTags(this.repoName) + .subscribe( + items => this.listTags(items), + error => this.messageHandlerService.handleError(error)); + if(this.withNotary) { this.repositoryService - .listTagsWithVerifiedSignatures(this.repoName) + .listNotarySignatures(this.repoName) .subscribe( - items => this.listTags(items), - error => this.messageHandlerService.handleError(error)); - } else { - this.repositoryService - .listTags(this.repoName) - .subscribe( - items => this.listTags(items), - error => this.messageHandlerService.handleError(error)); - } + signatures => { + this.tags.forEach((t, n)=>{ + let signed = false; + for(let i = 0; i < signatures.length; i++) { + if (signatures[i].tag === t.tag) { + signed = true; + break; + } + } + this.tags[n].signed = (signed) ? 1 : 0; + this.ref.markForCheck(); + }); + }, + error => console.error('Cannot determine the signature of this tag.')); + } } private listTags(tags: Tag[]): void { @@ -148,6 +162,8 @@ export class TagRepositoryComponent implements OnInit, OnDestroy { tag.parent = data['parent']; this.tags.push(tag); }); + let hnd = setInterval(()=>this.ref.markForCheck(), 100); + setTimeout(()=>clearInterval(hnd), 1000); } deleteTag(tag: TagView) { diff --git a/src/ui_ng/src/app/repository/tag-view.ts b/src/ui_ng/src/app/repository/tag-view.ts index 63d5523b0..9c164be09 100644 --- a/src/ui_ng/src/app/repository/tag-view.ts +++ b/src/ui_ng/src/app/repository/tag-view.ts @@ -14,7 +14,7 @@ export class TagView { tag: string; pullCommand: string; - signed: boolean; + signed: number = -1; author: string; created: Date; dockerVersion: string; diff --git a/src/ui_ng/src/app/repository/tag.ts b/src/ui_ng/src/app/repository/tag.ts index 5a7b70979..9c9087ed0 100644 --- a/src/ui_ng/src/app/repository/tag.ts +++ b/src/ui_ng/src/app/repository/tag.ts @@ -36,5 +36,5 @@ export class Tag { } ]; }; - signed: boolean; + signed: number; } \ No newline at end of file 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 bbcddafd7..ccfa36de2 100644 --- a/src/ui_ng/src/i18n/lang/en-us-lang.json +++ b/src/ui_ng/src/i18n/lang/en-us-lang.json @@ -325,7 +325,8 @@ "POP_REPOS": "Popular Repositories", "DELETED_REPO_SUCCESS": "Deleted repository successfully.", "DELETED_TAG_SUCCESS": "Deleted tag successfully.", - "COPY": "Copy" + "COPY": "Copy", + "NOTARY_IS_UNDETERMINED": "Cannot determine the signature of this tag." }, "ALERT": { "FORM_CHANGE_CONFIRMATION": "Some changes are not saved yet. Do you want to cancel?" 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 70298c9ef..0351163a3 100644 --- a/src/ui_ng/src/i18n/lang/zh-cn-lang.json +++ b/src/ui_ng/src/i18n/lang/zh-cn-lang.json @@ -325,7 +325,8 @@ "POP_REPOS": "受欢迎的镜像仓库", "DELETED_REPO_SUCCESS": "成功删除镜像仓库。", "DELETED_TAG_SUCCESS": "成功删除镜像标签。", - "COPY": "复制" + "COPY": "复制", + "NOTARY_IS_UNDETERMINED": "无法确定镜像标签签名。" }, "ALERT": { "FORM_CHANGE_CONFIRMATION": "表单内容改变,确认是否取消?"