feat(search-bar): add search bar to tag-list, this will filter tag names

This commit is contained in:
Joxit 2021-04-04 05:59:15 +02:00
parent a2b3c592df
commit b643a44113
No known key found for this signature in database
GPG key ID: F526592B8E012263
3 changed files with 17 additions and 11 deletions

View file

@ -33,7 +33,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<route path="{baseRoute}taglist/(.*)"> <route path="{baseRoute}taglist/(.*)">
<tag-list registry-url="{ state.registryUrl }" registry-name="{ state.name }" pull-url="{ state.pullUrl }" <tag-list registry-url="{ state.registryUrl }" registry-name="{ state.name }" pull-url="{ state.pullUrl }"
image="{ router.getTagListImage() }" show-content-digest="{props.showContentDigest}" image="{ router.getTagListImage() }" show-content-digest="{props.showContentDigest}"
is-image-remove-activated="{props.isImageRemoveActivated}" on-notify="{ notifySnackbar }"></tag-list> is-image-remove-activated="{props.isImageRemoveActivated}" on-notify="{ notifySnackbar }"
filter-results="{ state.filter }"></tag-list>
</route> </route>
<route path="{baseRoute}taghistory/(.*)"> <route path="{baseRoute}taghistory/(.*)">
<tag-history registry-url="{ state.registryUrl }" registry-name="{ state.name }" pull-url="{ state.pullUrl }" <tag-history registry-url="{ state.registryUrl }" registry-name="{ state.name }" pull-url="{ state.pullUrl }"
@ -126,7 +127,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
} }
}, },
onSearch(value) { onSearch(value) {
this.update({ filter: value }) this.update({
filter: value
})
}, },
baseRoute: '([^#]*?)/(\\?[^#]*?)?(#!)?(/?)', baseRoute: '([^#]*?)/(\\?[^#]*?)?(#!)?(/?)',
router, router,

View file

@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<tag-table if="{ state.loadend }" tags="{state.tags}" asc="{state.asc}" page="{ state.page }" <tag-table if="{ state.loadend }" tags="{state.tags}" asc="{state.asc}" page="{ state.page }"
show-content-digest="{props.showContentDigest}" is-image-remove-activated="{props.isImageRemoveActivated}" show-content-digest="{props.showContentDigest}" is-image-remove-activated="{props.isImageRemoveActivated}"
onReverseOrder="{ onReverseOrder }" registry-url="{ props.registryUrl }" pull-url="{ props.pullUrl }" onReverseOrder="{ onReverseOrder }" registry-url="{ props.registryUrl }" pull-url="{ props.pullUrl }"
on-notify="{ props.onNotify }"></tag-table> on-notify="{ props.onNotify }" filter-results="{ props.filterResults }"></tag-table>
<pagination pages="{ getPageLabels(state.page, getNumPages(state.tags)) }" onPageUpdate="{onPageUpdate}"></pagination> <pagination pages="{ getPageLabels(state.page, getNumPages(state.tags)) }" onPageUpdate="{onPageUpdate}"></pagination>
@ -84,15 +84,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
const self = this; const self = this;
const oReq = new Http(); const oReq = new Http();
oReq.addEventListener('load', function () { oReq.addEventListener('load', function () {
state.tags = [];
if (this.status == 200) { if (this.status == 200) {
const tags = JSON.parse(this.responseText).tags || []; const tags = (JSON.parse(this.responseText).tags || [])
state.tags = tags.map(function (tag) { .map(tag => new DockerImage(props.image, tag, null, props.registryUrl, props.onNotify))
return new DockerImage(props.image, tag, null, props.registryUrl, props.onNotify); .sort(compare);
}).sort(compare);
window.requestAnimationFrame(self.onResize); window.requestAnimationFrame(self.onResize);
self.update({ self.update({
page: Math.min(state.page, getNumPages(state.tags)) page: Math.min(state.page, getNumPages(tags)),
tags
}) })
} else if (this.status == 404) { } else if (this.status == 404) {
self.props.onNotify('Server not found', true); self.props.onNotify('Server not found', true);

View file

@ -40,7 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr each="{ image in getPage(props.tags, props.page) }"> <tr each="{ image in getPage(props.tags, props.page) }" if="{ matchSearch(props.filterResults, image.tag) }">
<td class="creation-date"> <td class="creation-date">
<image-date image="{ image }" /> <image-date image="{ image }" />
</td> </td>
@ -85,6 +85,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import RemoveImage, { import RemoveImage, {
deleteImage deleteImage
} from './remove-image.riot'; } from './remove-image.riot';
import {
matchSearch
} from '../search-bar.riot';
export default { export default {
components: { components: {
ImageDate, ImageDate,
@ -135,7 +138,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
toDelete: this.state.toDelete toDelete: this.state.toDelete
}) })
}, },
getPage getPage,
matchSearch
} }
</script> </script>
</tag-table> </tag-table>