mirror of
https://github.com/Joxit/docker-registry-ui.git
synced 2025-04-28 16:09:54 +03:00
feat(taglist-order): add new option taglist-order
This commit is contained in:
parent
fbab517a17
commit
8bbfc5c390
4 changed files with 11 additions and 30 deletions
|
@ -55,6 +55,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
filter-results="{ state.filter }"
|
filter-results="{ state.filter }"
|
||||||
on-authentication="{ onAuthentication }"
|
on-authentication="{ onAuthentication }"
|
||||||
use-control-cache-header="{ truthy(props.useControlCacheHeader) }"
|
use-control-cache-header="{ truthy(props.useControlCacheHeader) }"
|
||||||
|
taglist-order="{ taglistOrderParser(props.taglistOrder) }"
|
||||||
></tag-list>
|
></tag-list>
|
||||||
</route>
|
</route>
|
||||||
<route path="{baseRoute}taghistory/(.*)">
|
<route path="{baseRoute}taghistory/(.*)">
|
||||||
|
@ -129,6 +130,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
import { stripHttps, getRegistryServers, setRegistryServers, truthy, stringToArray } from '../scripts/utils';
|
import { stripHttps, getRegistryServers, setRegistryServers, truthy, stringToArray } from '../scripts/utils';
|
||||||
import router from '../scripts/router';
|
import router from '../scripts/router';
|
||||||
import { loadTheme } from '../scripts/theme';
|
import { loadTheme } from '../scripts/theme';
|
||||||
|
import { taglistOrderParser } from '../scripts/taglist-order';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
@ -241,6 +243,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
version,
|
version,
|
||||||
truthy,
|
truthy,
|
||||||
stringToArray,
|
stringToArray,
|
||||||
|
taglistOrderParser,
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -61,11 +61,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Http } from '../../scripts/http';
|
import { Http } from '../../scripts/http';
|
||||||
import { DockerImage, compare } from '../../scripts/docker-image';
|
import { DockerImage } from '../../scripts/docker-image';
|
||||||
import { getNumPages, getPageLabels } from '../../scripts/utils';
|
import { getNumPages, getPageLabels } from '../../scripts/utils';
|
||||||
import Pagination from './pagination.riot';
|
import Pagination from './pagination.riot';
|
||||||
import TagTable from './tag-table.riot';
|
import TagTable from './tag-table.riot';
|
||||||
import router from '../../scripts/router';
|
import router from '../../scripts/router';
|
||||||
|
import { getTagComparator } from '../../scripts/taglist-order';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Pagination,
|
Pagination,
|
||||||
|
@ -86,6 +88,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// this may be run before the final document size is available, so schedule
|
// this may be run before the final document size is available, so schedule
|
||||||
// a correction once everything is set up.
|
// a correction once everything is set up.
|
||||||
window.requestAnimationFrame(this.onResize);
|
window.requestAnimationFrame(this.onResize);
|
||||||
|
this.tagComparator = getTagComparator(props.taglistOrder);
|
||||||
},
|
},
|
||||||
display(props, state) {
|
display(props, state) {
|
||||||
state.tags = [];
|
state.tags = [];
|
||||||
|
@ -106,7 +109,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
useControlCacheHeader: props.useControlCacheHeader,
|
useControlCacheHeader: props.useControlCacheHeader,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.sort(compare);
|
.sort(self.tagComparator);
|
||||||
window.requestAnimationFrame(self.onResize);
|
window.requestAnimationFrame(self.onResize);
|
||||||
self.update({
|
self.update({
|
||||||
page: Math.min(state.page, getNumPages(tags)),
|
page: Math.min(state.page, getNumPages(tags)),
|
||||||
|
@ -168,7 +171,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
this.state.tags.reverse();
|
this.state.tags.reverse();
|
||||||
this.state.asc = false;
|
this.state.asc = false;
|
||||||
} else {
|
} else {
|
||||||
this.state.tags.sort(compare);
|
this.state.tags.sort(this.tagComparator);
|
||||||
this.state.asc = true;
|
this.state.asc = true;
|
||||||
}
|
}
|
||||||
this.update();
|
this.update();
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
show-catalog-nb-tags="${SHOW_CATALOG_NB_TAGS}"
|
show-catalog-nb-tags="${SHOW_CATALOG_NB_TAGS}"
|
||||||
history-custom-labels="${HISTORY_CUSTOM_LABELS}"
|
history-custom-labels="${HISTORY_CUSTOM_LABELS}"
|
||||||
use-control-cache-header="${USE_CONTROL_CACHE_HEADER}"
|
use-control-cache-header="${USE_CONTROL_CACHE_HEADER}"
|
||||||
|
taglist-order="${TAGLIST_ORDER}
|
||||||
theme="${THEME}"
|
theme="${THEME}"
|
||||||
theme-primary-text="${THEME_PRIMARY_TEXT}"
|
theme-primary-text="${THEME_PRIMARY_TEXT}"
|
||||||
theme-neutral-text="${THEME_NEUTRAL_TEXT}"
|
theme-neutral-text="${THEME_NEUTRAL_TEXT}"
|
||||||
|
@ -73,6 +74,7 @@
|
||||||
show-catalog-nb-tags="true"
|
show-catalog-nb-tags="true"
|
||||||
history-custom-labels="first_custom_labels,second_custom_labels"
|
history-custom-labels="first_custom_labels,second_custom_labels"
|
||||||
use-control-cache-header="false"
|
use-control-cache-header="false"
|
||||||
|
taglist-order="alpha-asc;num-desc"
|
||||||
theme="auto"
|
theme="auto"
|
||||||
theme-primary-text=""
|
theme-primary-text=""
|
||||||
theme-neutral-text=""
|
theme-neutral-text=""
|
||||||
|
|
|
@ -18,33 +18,6 @@ import { Http } from './http';
|
||||||
import { isDigit, eventTransfer, ERROR_CAN_NOT_READ_CONTENT_DIGEST } from './utils';
|
import { isDigit, eventTransfer, ERROR_CAN_NOT_READ_CONTENT_DIGEST } from './utils';
|
||||||
import observable from '@riotjs/observable';
|
import observable from '@riotjs/observable';
|
||||||
|
|
||||||
const tagReduce = (acc, e) => {
|
|
||||||
if (acc.length > 0 && isDigit(acc[acc.length - 1].charAt(0)) == isDigit(e)) {
|
|
||||||
acc[acc.length - 1] += e;
|
|
||||||
} else {
|
|
||||||
acc.push(e);
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function compare(e1, e2) {
|
|
||||||
const tag1 = e1.tag.match(/./g).reduce(tagReduce, []);
|
|
||||||
const tag2 = e2.tag.match(/./g).reduce(tagReduce, []);
|
|
||||||
|
|
||||||
for (var i = 0; i < tag1.length && i < tag2.length; i++) {
|
|
||||||
const compare = tag1[i].localeCompare(tag2[i]);
|
|
||||||
if (isDigit(tag1[i].charAt(0)) && isDigit(tag2[i].charAt(0))) {
|
|
||||||
const diff = tag1[i] - tag2[i];
|
|
||||||
if (diff != 0) {
|
|
||||||
return diff;
|
|
||||||
}
|
|
||||||
} else if (compare != 0) {
|
|
||||||
return compare;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return e1.tag.length - e2.tag.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class DockerImage {
|
export class DockerImage {
|
||||||
constructor(name, tag, { list, registryUrl, onNotify, onAuthentication, useControlCacheHeader }) {
|
constructor(name, tag, { list, registryUrl, onNotify, onAuthentication, useControlCacheHeader }) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue