This repository has been archived by the owner on Jul 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leonardo Chaia
committed
Oct 26, 2018
1 parent
18100a6
commit 514ae08
Showing
35 changed files
with
642 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ImageSource, ImageListFilter, ImageListItemData, ImageSourceDeletion } from '../docker-images/image-source.model'; | ||
import { Observable } from 'rxjs'; | ||
import { Injectable } from '@angular/core'; | ||
import { map, switchMap } from 'rxjs/operators'; | ||
import { DockerImageService } from './docker-image.service'; | ||
import { DockerEventsService } from './docker-events.service'; | ||
|
||
@Injectable() | ||
export class DockerDaemonImageSource | ||
extends ImageSource | ||
implements ImageSourceDeletion { | ||
|
||
public priority = 0; | ||
public readonly name = 'Docker Daemon'; | ||
|
||
constructor( | ||
private readonly dockerEvents: DockerEventsService, | ||
private readonly dockerImage: DockerImageService) { | ||
super(); | ||
} | ||
|
||
public loadList(filter?: ImageListFilter): Observable<ImageListItemData[]> { | ||
return this.dockerEvents.bindAll(['delete', 'import', 'load', 'pull', 'tag', 'untag'], 'image') | ||
.pipe( | ||
switchMap(() => this.getImages(filter)) | ||
); | ||
} | ||
|
||
public deleteImage(image: ImageListItemData): Observable<void> { | ||
return this.dockerImage.removeImage(image.id); | ||
} | ||
|
||
protected getImages(filter?: ImageListFilter) { | ||
let dockerFilter: any; | ||
if (filter && filter.term) { | ||
dockerFilter = { reference: { [`*${filter.term}*`]: true } }; | ||
} | ||
return this.dockerImage.imageList({ | ||
all: filter ? filter.displayDanglingImages : false, | ||
filters: dockerFilter, | ||
}).pipe( | ||
map(r => r.map(i => ({ | ||
name: i.RepoTags ? i.RepoTags.join(', ') : i.Id, | ||
id: i.Id, | ||
size: i.Size | ||
} as ImageListItemData))) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
...p/docker-hub/docker-hub-repo-list-container/docker-hub-repo-list-container.component.html
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...app/docker-hub/docker-hub-repo-list-container/docker-hub-repo-list-container.component.ts
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
src/app/docker-hub/docker-hub-repo-list/docker-hub-repo-list.component.html
This file was deleted.
Oops, something went wrong.
69 changes: 0 additions & 69 deletions
69
src/app/docker-hub/docker-hub-repo-list/docker-hub-repo-list.component.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ImageSource, ImageListFilter, ImageListItemData } from '../docker-images/image-source.model'; | ||
import { Observable, throwError } from 'rxjs'; | ||
import { Injectable } from '@angular/core'; | ||
import { DockerHubService } from './docker-hub.service'; | ||
import { map, switchMap } from 'rxjs/operators'; | ||
import { SettingsService } from '../settings/settings.service'; | ||
|
||
@Injectable() | ||
export class DockerHubImageSource extends ImageSource { | ||
public priority = 1; | ||
public readonly name = 'Docker Hub'; | ||
|
||
constructor( | ||
private readonly settings: SettingsService, | ||
private readonly dockerHub: DockerHubService) { | ||
super(); | ||
} | ||
|
||
public loadList(filter?: ImageListFilter): Observable<ImageListItemData[]> { | ||
filter = filter || {}; | ||
return this.settings.getDockerIOSettings() | ||
.pipe( | ||
switchMap(settings => { | ||
if (settings && settings.username && settings.password) { | ||
return this.dockerHub.getReposForUser(null) | ||
.pipe( | ||
map(r => r.results | ||
.map(i => ({ | ||
name: `${i.namespace}/${i.name}` | ||
} as ImageListItemData)) | ||
.filter(item => !filter.term || item.name.includes(filter.term)) | ||
), | ||
); | ||
} else { | ||
return throwError('Docker Hub is not configured'); | ||
} | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.