From 3da88147872b71a59f19e2aa3bf307e06cd0187e Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 28 Dec 2015 16:29:17 -0500 Subject: [PATCH] Create a common repo-list-view control and use it everywhere This allows users to choose grid view or table view in all repo lists Fixes #732 --- static/css/directives/ui/repo-list-view.css | 4 +++ static/directives/repo-list-grid.html | 2 +- static/directives/repo-list-table.html | 3 +- static/directives/repo-list-view.html | 38 +++++++++++++++++++++ static/js/directives/ui/repo-list-grid.js | 3 +- static/js/directives/ui/repo-list-table.js | 5 +-- static/js/directives/ui/repo-list-view.js | 38 +++++++++++++++++++++ static/js/pages/org-view.js | 7 ++-- static/js/pages/repo-list.js | 8 +---- static/js/pages/user-view.js | 7 ++-- static/partials/org-view.html | 15 ++------ static/partials/repo-list.html | 30 ++-------------- static/partials/user-view.html | 32 ++++++----------- 13 files changed, 115 insertions(+), 77 deletions(-) create mode 100644 static/css/directives/ui/repo-list-view.css create mode 100644 static/directives/repo-list-view.html create mode 100644 static/js/directives/ui/repo-list-view.js diff --git a/static/css/directives/ui/repo-list-view.css b/static/css/directives/ui/repo-list-view.css new file mode 100644 index 000000000..321feb64a --- /dev/null +++ b/static/css/directives/ui/repo-list-view.css @@ -0,0 +1,4 @@ +.repo-list-view .btn-group { + float: right; + margin-bottom: 10px; +} diff --git a/static/directives/repo-list-grid.html b/static/directives/repo-list-grid.html index e1e4018d5..e225b21bc 100644 --- a/static/directives/repo-list-grid.html +++ b/static/directives/repo-list-grid.html @@ -29,7 +29,7 @@ - {{ repository.namespace }}/{{ repository.name }} + {{ repository.namespace }}/{{ repository.name }}
diff --git a/static/directives/repo-list-table.html b/static/directives/repo-list-table.html index 8b4d266fc..7a16c4537 100644 --- a/static/directives/repo-list-table.html +++ b/static/directives/repo-list-table.html @@ -1,7 +1,8 @@
-
You do not have any viewable repositories.
+
You do not have any viewable repositories.
+
This namespace doesn't have any viewable repositories.
Either no repositories exist yet or you may not have permission to view any. If you have permission, try creating a new repository.
diff --git a/static/directives/repo-list-view.html b/static/directives/repo-list-view.html new file mode 100644 index 000000000..efb944901 --- /dev/null +++ b/static/directives/repo-list-view.html @@ -0,0 +1,38 @@ +
+ +
+ + +
+ +
+ + +
+
+
+
+ + +
+ +
+
+ + +
+
+
+
+
+
\ No newline at end of file diff --git a/static/js/directives/ui/repo-list-grid.js b/static/js/directives/ui/repo-list-grid.js index a01aec827..5f554f015 100644 --- a/static/js/directives/ui/repo-list-grid.js +++ b/static/js/directives/ui/repo-list-grid.js @@ -13,7 +13,8 @@ angular.module('quay').directive('repoListGrid', function () { starred: '=starred', namespace: '=namespace', starToggled: '&starToggled', - hideTitle: '=hideTitle' + hideTitle: '=hideTitle', + hideNamespaces: '=hideNamespaces' }, controller: function($scope, $element, UserService) { $scope.isOrganization = function(namespace) { diff --git a/static/js/directives/ui/repo-list-table.js b/static/js/directives/ui/repo-list-table.js index c19a22371..7a5e98e53 100644 --- a/static/js/directives/ui/repo-list-table.js +++ b/static/js/directives/ui/repo-list-table.js @@ -10,7 +10,8 @@ angular.module('quay').directive('repoListTable', function () { restrict: 'C', scope: { 'repositoriesResources': '=repositoriesResources', - 'namespaces': '=namespaces' + 'namespaces': '=namespaces', + 'starToggled': '&starToggled' }, controller: function($scope, $element, $filter) { var orderBy = $filter('orderBy'); @@ -59,7 +60,7 @@ angular.module('quay').directive('repoListTable', function () { $scope.getAvatarData = function(namespace) { var found = {}; $scope.namespaces.forEach(function(current) { - if (current.name == namespace) { + if (current.name == namespace || current.username == namespace) { found = current.avatar; } }); diff --git a/static/js/directives/ui/repo-list-view.js b/static/js/directives/ui/repo-list-view.js new file mode 100644 index 000000000..a578e9413 --- /dev/null +++ b/static/js/directives/ui/repo-list-view.js @@ -0,0 +1,38 @@ +/** + * An element that displays a list (grid or table) of repositories. + */ +angular.module('quay').directive('repoListView', function () { + var directiveDefinitionObject = { + priority: 0, + templateUrl: '/static/directives/repo-list-view.html', + replace: false, + transclude: true, + restrict: 'C', + scope: { + namespaces: '=namespaces', + starredRepositories: '=starredRepositories', + starToggled: '&starToggled', + }, + controller: function($scope, $element, CookieService) { + $scope.resources = []; + $scope.showAsList = CookieService.get('quay.repoview') == 'list'; + + $scope.$watch('namespaces', function(namespaces) { + if (!namespaces) { return; } + + $scope.resources = []; + namespaces.forEach(function(namespace) { + if (namespace && namespace.repositories) { + $scope.resources.push(namespace.repositories); + } + }); + }, true); + + $scope.setShowAsList = function(value) { + $scope.showAsList = value; + CookieService.putPermanent('quay.repoview', value ? 'list' : 'grid'); + }; + } + }; + return directiveDefinitionObject; +}); \ No newline at end of file diff --git a/static/js/pages/org-view.js b/static/js/pages/org-view.js index 15867e109..45c6405a0 100644 --- a/static/js/pages/org-view.js +++ b/static/js/pages/org-view.js @@ -13,6 +13,7 @@ function OrgViewCtrl($scope, $routeParams, $timeout, ApiService, UIService, AvatarService) { var orgname = $routeParams.orgname; + $scope.namespace = orgname; $scope.showLogsCounter = 0; $scope.showApplicationsCounter = 0; $scope.showInvoicesCounter = 0; @@ -31,10 +32,12 @@ var loadRepositories = function() { var options = { 'namespace': orgname, - 'public': true + 'public': true, + 'last_modified': true, + 'popularity': true }; - $scope.repositoriesResource = ApiService.listReposAsResource().withOptions(options).get(function(resp) { + $scope.organization.repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) { return resp.repositories; }); }; diff --git a/static/js/pages/repo-list.js b/static/js/pages/repo-list.js index 85885aaeb..30e889bbb 100644 --- a/static/js/pages/repo-list.js +++ b/static/js/pages/repo-list.js @@ -11,14 +11,13 @@ }]); - function RepoListCtrl($scope, $sanitize, $q, Restangular, UserService, ApiService, CookieService, Features) { + function RepoListCtrl($scope, $sanitize, $q, Restangular, UserService, ApiService, Features) { $scope.namespace = null; $scope.page = 1; $scope.publicPageCount = null; $scope.allRepositories = {}; $scope.loading = true; $scope.resources = []; - $scope.showAsList = CookieService.get('quay.repoview') == 'list'; $scope.Features = Features; // When loading the UserService, if the user is logged in, create a list of @@ -46,11 +45,6 @@ } }); - $scope.setShowAsList = function(value) { - $scope.showAsList = value; - CookieService.putPermanent('quay.repoview', value ? 'list' : 'grid'); - }; - $scope.isOrganization = function(namespace) { return !!UserService.getOrganization(namespace); }; diff --git a/static/js/pages/user-view.js b/static/js/pages/user-view.js index d6d55fa7c..60aa9218b 100644 --- a/static/js/pages/user-view.js +++ b/static/js/pages/user-view.js @@ -19,6 +19,7 @@ $scope.changeEmailInfo = {}; $scope.changePasswordInfo = {}; $scope.hasSingleSignin = ExternalLoginService.hasSingleSignin(); + $scope.context = {}; UserService.updateUserIn($scope); @@ -26,16 +27,18 @@ var options = { 'public': true, 'namespace': username, + 'last_modified': true, + 'popularity': true }; - $scope.repositoriesResource = ApiService.listReposAsResource().withOptions(options).get(function(resp) { + $scope.context.viewuser.repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) { return resp.repositories; }); }; var loadUser = function() { $scope.userResource = ApiService.getUserInformationAsResource({'username': username}).get(function(user) { - $scope.viewuser = user; + $scope.context.viewuser = user; // Load the repositories. $timeout(function() { diff --git a/static/partials/org-view.html b/static/partials/org-view.html index b824cf382..0628d0798 100644 --- a/static/partials/org-view.html +++ b/static/partials/org-view.html @@ -17,12 +17,7 @@
-
-
+
@@ -65,13 +60,7 @@
-

Repositories

-
-
+

Repositories

diff --git a/static/partials/repo-list.html b/static/partials/repo-list.html index 57f0da865..8041ffdb2 100644 --- a/static/partials/repo-list.html +++ b/static/partials/repo-list.html @@ -59,33 +59,9 @@
-
- - -
- - -
-
-
- - -
- -
-
- - -
-
-
-
+
diff --git a/static/partials/user-view.html b/static/partials/user-view.html index d274cd8c5..08c1e1ec6 100644 --- a/static/partials/user-view.html +++ b/static/partials/user-view.html @@ -5,27 +5,23 @@
- - {{ viewuser.username }} + + {{ context.viewuser.username }} - - + + Create New Repository
-
-
+
+
-
-
+
+
@@ -56,13 +52,7 @@
-

Repositories

-
-
+

Repositories

@@ -119,7 +109,7 @@ - + @@ -133,7 +123,7 @@
Current E-mail Address:{{ viewuser.email }}{{ context.viewuser.email }}
New E-mail Address: