mirror of https://github.com/portainer/portainer
Add a button next to the image field when creating a new container, which takes the user to the Docker Hub search page for this image. Version identifiers are trimmed from the image name to ensure that matching images will be found.pull/4889/head
parent
20f8d03366
commit
25c010ec3e
|
@ -28,6 +28,14 @@
|
|||
ng-change="$ctrl.onImageChange()"
|
||||
required
|
||||
/>
|
||||
<span ng-if="$ctrl.displayedRegistryURL() === 'docker.io'" class="input-group-btn">
|
||||
<a href="https://hub.docker.com/search?type=image&q={{$ctrl.model.Image | trimshasum | trimversiontag}}"
|
||||
class="btn btn-default"
|
||||
title="Search image on Docker Hub"
|
||||
target="_blank">
|
||||
<i class="fab fa-docker"></i> Search
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -305,4 +305,21 @@ angular
|
|||
}
|
||||
return _.split(imageName, '@sha256')[0];
|
||||
};
|
||||
})
|
||||
.filter('trimversiontag', function () {
|
||||
'use strict';
|
||||
return function trimversiontag(fullName) {
|
||||
if (!fullName) {
|
||||
return fullName;
|
||||
}
|
||||
var versionIdx = fullName.lastIndexOf(':');
|
||||
if (versionIdx < 0) {
|
||||
return fullName;
|
||||
}
|
||||
var hostIdx = fullName.indexOf('/');
|
||||
if (hostIdx > versionIdx) {
|
||||
return fullName;
|
||||
}
|
||||
return fullName.substring(0, versionIdx);
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue