grim/port-authority

this should tag care of sorting the tags... although the official node repo is off in weird ways... fixes #4
  • +30 -9
    js/app.js
  • --- a/js/app.js Sun Jan 25 03:13:04 2015 -0600
    +++ b/js/app.js Sun Jan 25 04:33:37 2015 -0600
    @@ -38,11 +38,11 @@
    });
    function ManifestController($scope, manifestREST) {
    - $scope.debug = false;
    + $scope.debug = true;
    $scope.refreshing = false;
    $scope.refreshing_repo = false;
    $scope.registry = "registry.hub.docker.com";
    - $scope.query = "busybox";
    + $scope.query = "node";
    $scope.repos = null;
    $scope.repo = null;
    $scope.error = null;
    @@ -121,28 +121,49 @@
    * and the private registry returns a dictionary of tag
    * names to images. Like:
    * {"latest", "deadb33f"}
    - * This function will normalize them into an object like
    - * {"deadb33f", ["latest"]}
    + * This function will normalize them into a sorted list like
    + * [
    + * ["foo", "latest"]
    + * ["latest"],
    + * ]
    + * Image IDs are thrown away because we don't care about them.
    */
    $scope.ga_tracker.sendEvent("repo", "get tags", "success");
    - $scope.tags = {};
    + $scope.tags = [];
    if(data.constructor === Array) { /* registry.hub.docker.com */
    + var dtags = {};
    for(var ntag in data) {
    var tag = data[ntag];
    - $scope.tags[tag.layer] = $scope.tags[tag.layer] || [];
    + dtags[tag.layer] = dtags[tag.layer] || [];
    +
    + dtags[tag.layer].push(tag.name);
    + }
    - $scope.tags[tag.layer].push(tag.name);
    + var tags = [];
    + for(var tag in dtags) {
    + tags.push(dtags[tag].sort());
    }
    +
    + $scope.tags = tags.sort(function(a, b) { return a[0] - b[0]});
    } else if(data !== null && typeof data === 'object') { /* private registries */
    + var dtags = {};
    +
    for(var tag in data) {
    var layer = data[tag];
    - $scope.tags[layer] = $scope.tags[layer] || [];
    - $scope.tags[layer].push(tag);
    + dtags[layer] = dtags[layer] || [];
    + dtags[layer].push(tag);
    }
    +
    + var tags = [];
    + for(var tag in dtags) {
    + tags.push(dtags[tag].sort());
    + }
    +
    + $scope.tags = tags.sort(function(a, b) { return a[0] - b[0]});
    }
    $scope.refreshing_repo = false;