Repository: ambari Updated Branches: refs/heads/trunk 5fc87355a -> 1f272c278
AMBARI-8493 Admin View: add mock json support. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1f272c27 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1f272c27 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1f272c27 Branch: refs/heads/trunk Commit: 1f272c278107171bea9d08780989ad3332ff3673 Parents: 5fc8735 Author: Andrii Tkach <atk...@hortonworks.com> Authored: Mon Dec 1 19:54:19 2014 +0200 Committer: Andrii Tkach <atk...@hortonworks.com> Committed: Mon Dec 1 19:54:19 2014 +0200 ---------------------------------------------------------------------- ambari-admin/pom.xml | 1 + .../admin-web/app/assets/data/cluster/init.json | 3 + .../app/assets/data/cluster/installed.json | 11 ++ .../app/assets/data/permission/permissions.json | 24 +++ .../admin-web/app/assets/data/stack/stack.json | 104 +++++++++++++ .../app/assets/data/version/version.json | 47 ++++++ .../app/assets/data/version/versions.json | 52 +++++++ .../admin-web/app/assets/data/view/views.json | 9 ++ .../resources/ui/admin-web/app/scripts/app.js | 21 ++- .../app/scripts/controllers/NavbarCtrl.js | 12 +- .../app/scripts/controllers/mainCtrl.js | 6 +- .../stackVersions/StackVersionsEditCtrl.js | 19 +-- .../stackVersions/StackVersionsListCtrl.js | 4 +- .../admin-web/app/scripts/services/Cluster.js | 3 +- .../app/scripts/services/StackVersions.js | 155 +------------------ .../ui/admin-web/app/scripts/services/View.js | 14 +- .../admin-web/app/views/stackVersions/edit.html | 16 +- .../admin-web/app/views/stackVersions/list.html | 8 +- 18 files changed, 319 insertions(+), 190 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-admin/pom.xml b/ambari-admin/pom.xml index 8251860..ebfdc68 100644 --- a/ambari-admin/pom.xml +++ b/ambari-admin/pom.xml @@ -178,6 +178,7 @@ <exclude>src/main/resources/ui/admin-web/bower_components/**</exclude> <exclude>src/main/resources/ui/admin-web/dist/**</exclude> <exclude>src/main/resources/ui/admin-web/node/**</exclude> + <exclude>src/main/resources/ui/admin-web/app/assets/data/**</exclude> <exclude>src/main/resources/ui/admin-web/node_modules/**</exclude> <exclude>src/main/resources/ui/admin-web/app/bower_components/**</exclude> <exclude>src/main/resources/ui/admin-web/test/bower_components/**</exclude> http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/cluster/init.json ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/cluster/init.json b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/cluster/init.json new file mode 100644 index 0000000..75f1443 --- /dev/null +++ b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/cluster/init.json @@ -0,0 +1,3 @@ +{ + "items" : [] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/cluster/installed.json ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/cluster/installed.json b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/cluster/installed.json new file mode 100644 index 0000000..76fbae6 --- /dev/null +++ b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/cluster/installed.json @@ -0,0 +1,11 @@ +{ + "items" : [ + { + "Clusters" : { + "cluster_name" : "c1", + "provisioning_state" : "INSTALLED", + "version" : "HDP-2.2" + } + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/permission/permissions.json ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/permission/permissions.json b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/permission/permissions.json new file mode 100644 index 0000000..e9eaf6a --- /dev/null +++ b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/permission/permissions.json @@ -0,0 +1,24 @@ +{ + "items" : [ + { + "PermissionInfo" : { + "permission_id" : 1 + } + }, + { + "PermissionInfo" : { + "permission_id" : 2 + } + }, + { + "PermissionInfo" : { + "permission_id" : 3 + } + }, + { + "PermissionInfo" : { + "permission_id" : 4 + } + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/stack/stack.json ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/stack/stack.json b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/stack/stack.json new file mode 100644 index 0000000..102992e --- /dev/null +++ b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/stack/stack.json @@ -0,0 +1,104 @@ +{ + "items" : [ + { + "OperatingSystems" : { + "os_type" : "redhat5", + "stack_name" : "HDP", + "stack_version" : "2.2" + }, + "repositories" : [ + { + "Repositories" : { + "os_type" : "redhat5", + "repo_id" : "HDP-2.2", + "stack_name" : "HDP", + "stack_version" : "2.2" + } + }, + { + "Repositories" : { + "os_type" : "redhat5", + "repo_id" : "HDP-UTILS-1.1.0.20", + "stack_name" : "HDP", + "stack_version" : "2.2" + } + } + ] + }, + { + "OperatingSystems" : { + "os_type" : "redhat6", + "stack_name" : "HDP", + "stack_version" : "2.2" + }, + "repositories" : [ + { + "Repositories" : { + "os_type" : "redhat6", + "repo_id" : "HDP-2.2", + "stack_name" : "HDP", + "stack_version" : "2.2" + } + }, + { + "Repositories" : { + "os_type" : "redhat6", + "repo_id" : "HDP-UTILS-1.1.0.20", + "stack_name" : "HDP", + "stack_version" : "2.2" + } + } + ] + }, + { + "OperatingSystems" : { + "os_type" : "suse11", + "stack_name" : "HDP", + "stack_version" : "2.2" + }, + "repositories" : [ + { + "Repositories" : { + "os_type" : "suse11", + "repo_id" : "HDP-2.2", + "stack_name" : "HDP", + "stack_version" : "2.2" + } + }, + { + "Repositories" : { + "os_type" : "suse11", + "repo_id" : "HDP-UTILS-1.1.0.20", + "stack_name" : "HDP", + "stack_version" : "2.2" + } + } + ] + }, + { + "OperatingSystems" : { + "os_type" : "ubuntu12", + "stack_name" : "HDP", + "stack_version" : "2.2" + }, + "repositories" : [ + { + "Repositories" : { + "os_type" : "ubuntu12", + "repo_id" : "HDP-2.2", + "stack_name" : "HDP", + "stack_version" : "2.2" + } + }, + { + "Repositories" : { + "os_type" : "ubuntu12", + "repo_id" : "HDP-UTILS-1.1.0.20", + "stack_name" : "HDP", + "stack_version" : "2.2" + } + } + ] + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/version.json ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/version.json b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/version.json new file mode 100644 index 0000000..0604388 --- /dev/null +++ b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/version.json @@ -0,0 +1,47 @@ +{ + "href": "http://c6401.ambari.apache.org:8080/api/v1/stacks/HDP/versions/2.2/repository_versions/1", + "RepositoryVersions": { + "id": 1, + "repository_version": "2.2.0.1-885", + "display_name": "HDP 2.2.0", + "upgrade_pack": "upgrade-2.2", + "stack": "HDP-2.2", + "operating_systems": [ + { + "OperatingSystems": { + "os_type": "redhat5" + }, + "repositories": [ + { + "Repositories": { + "repo_id": "HDP-2.2", + "stack_name": "HDP", + "base_url": "http://s3.amazonaws.com/dev.hortonworks.com/HDP/centos5/2.x/updates/2.2.0.0" + } + }, + { + "Repositories": { + "repo_id": "HDP-UTILS-1.1.0.20", + "stack_name": "HDP-UTILS", + "base_url": "http://s3.amazonaws.com/dev.hortonworks.com/HDP/centos5/2.x/updates/2.2.0.0" + } + } + ] + } + ], + "deployment_info": [ + { + "cluster": "myCluster", + "status": "CURRENT", + "totalHostCount": 100, + "hosts": ["host1", "host2"] + }, + { + "cluster": "anotherCluster", + "status": "INSTALLED", + "totalHostCount": 100, + "hosts": ["host1", "host2"] + } + ] + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/versions.json ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/versions.json b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/versions.json new file mode 100644 index 0000000..7bfc5f2 --- /dev/null +++ b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/versions.json @@ -0,0 +1,52 @@ +{ + "items": [ + { + "RepositoryVersions": { + "id": 1, + "repository_version": "2.2.0.1-885", + "display_name": "HDP 2.2.0", + "upgrade_pack": "upgrade-2.2", + "current_hosts": ["host1", "host2"], + "status": "CURRENT", + "totalHosts": 100, + "cluster": "myCluster" + } + }, + { + "RepositoryVersions": { + "id": 2, + "repository_version": "2.2.1.1-885", + "display_name": "HDP 2.2.1", + "upgrade_pack": "upgrade-2.2", + "current_hosts": ["host1", "host2"], + "status": "INSTALLED", + "totalHosts": 100, + "cluster": "anotherCluster" + } + }, + { + "RepositoryVersions": { + "id": 3, + "repository_version": "2.2.2.1-885", + "display_name": "HDP 2.2.2", + "upgrade_pack": "upgrade-2.2", + "current_hosts": ["host1", "host2"], + "status": "IN_USE", + "totalHosts": 100, + "cluster": "myCluster" + } + }, + { + "RepositoryVersions": { + "id": 4, + "repository_version": "2.2.3.1-885", + "display_name": "HDP 2.2.3", + "upgrade_pack": "upgrade-2.2", + "current_hosts": [], + "status": "INIT", + "totalHosts": 100, + "cluster": "" + } + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/view/views.json ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/view/views.json b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/view/views.json new file mode 100644 index 0000000..536f7e3 --- /dev/null +++ b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/view/views.json @@ -0,0 +1,9 @@ +{ + "items" : [ + { + "ViewInfo" : { + "view_name" : "ADMIN_VIEW" + } + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/scripts/app.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/app.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/app.js index f1a48f6..cde24e0 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/app.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/app.js @@ -25,8 +25,10 @@ angular.module('ambariAdminConsole', [ 'toggle-switch', 'pascalprecht.translate' ]) -.constant('Settings',{ - baseUrl: '/api/v1' +.constant('Settings', { + baseUrl: '/api/v1', + testMode: (window.location.port == 8000), + mockDataPrefix: 'assets/data/' }) .config(['RestangularProvider', '$httpProvider', '$provide', function(RestangularProvider, $httpProvider, $provide) { // Config Ajax-module @@ -40,6 +42,21 @@ angular.module('ambariAdminConsole', [ $httpProvider.defaults.headers.put['X-Requested-By'] = 'ambari'; $httpProvider.defaults.headers.common['X-Requested-By'] = 'ambari'; + $httpProvider.interceptors.push(['Settings', '$q', function(Settings, $q) { + return { + 'request': function(config) { + if (Settings.testMode) { + if (config.method === 'GET') { + config.url = (config.mock) ? Settings.mockDataPrefix + config.mock : config.url; + } else { + config.method = "GET"; + } + } + return config; + } + }; + }]); + $httpProvider.responseInterceptors.push(['$rootScope', '$q', function (scope, $q) { function success(response) { return response; http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/NavbarCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/NavbarCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/NavbarCtrl.js index d020111..f44a10f 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/NavbarCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/NavbarCtrl.js @@ -25,16 +25,16 @@ angular.module('ambariAdminConsole') editingName : false }; - function loadClusterData(){ - Cluster.getStatus().then(function(cluster) { + function loadClusterData() { + Cluster.getStatus().then(function (cluster) { $scope.cluster = cluster; - if(cluster.Clusters.provisioning_state === 'INIT'){ + if (cluster && cluster.Clusters.provisioning_state === 'INIT') { setTimeout(loadClusterData, 1000); } - }).catch(function(data) { - Alert.error('Cannot load cluster status', data.data.message); + }).catch(function (data) { + Alert.error('Cannot load cluster status', data.statusText); }); - }; + } loadClusterData(); $scope.toggleEditName = function($event) { http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js index 7e0793b..baec0cf 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js @@ -50,13 +50,13 @@ angular.module('ambariAdminConsole') Cluster.getStatus().then(function(cluster) { $scope.cluster = cluster; $scope.isLoaded = true; - if(cluster.Clusters.provisioning_state === 'INIT'){ + if(cluster && cluster.Clusters.provisioning_state === 'INIT'){ setTimeout(loadClusterData, 1000); } }).catch(function(data) { - Alert.error('Cannot load cluster status', data.data.message); + Alert.error('Cannot load cluster status', data.statusText); }); - }; + } loadClusterData(); $scope.viewInstances = []; http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js index 8c1c416..7373bce 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js @@ -20,20 +20,21 @@ angular.module('ambariAdminConsole') .controller('StackVersionsEditCtrl', ['$scope', 'StackVersions', '$routeParams', function($scope, StackVersions, $routeParams) { function loadStackVersionInfo() { - return StackVersions.get($routeParams.id).then(function (stackVersion) { - loadStackRepositories(stackVersion); - $scope.stackVersion = stackVersion; + return StackVersions.get($routeParams.id).then(function (response) { + loadStackRepositories(response.data.RepositoryVersions); + $scope.stackVersion = response.data.RepositoryVersions; }); } function loadStackRepositories(stackVersion) { - return StackVersions.getStackRepositories(stackVersion.stack).then(function (repositories) { + //todo replace "2.2" with actual version + return StackVersions.getStackRepositories('2.2').then(function (response) { var repos = []; - repositories.forEach(function (repo) { + response.data.items.forEach(function (repo) { var installedRepo; - for (var i in stackVersion.repositories) { - if (stackVersion.repositories[i].os === repo.os) { - installedRepo = stackVersion.repositories[i]; + for (var i in stackVersion.operating_systems) { + if (stackVersion.operating_systems[i].OperatingSystems.os_type === repo.OperatingSystems.os_type) { + installedRepo = stackVersion.operating_systems[i]; break; } } @@ -45,7 +46,7 @@ angular.module('ambariAdminConsole') repos.push(repo); } }); - $scope.stackVersion.repositories = repos; + $scope.stackVersion.operatingSystems = repos; }); } http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsListCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsListCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsListCtrl.js index cd93090..698bc6c 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsListCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsListCtrl.js @@ -61,7 +61,9 @@ angular.module('ambariAdminConsole') $scope.getStackVersions = function () { return StackVersions.list($scope.filter).then(function (stacks) { - $scope.stacks = stacks; + $scope.stacks = stacks.data.items.map(function (stack) { + return stack.RepositoryVersions; + }); $scope.tableInfo.total = stacks.length; $scope.tableInfo.showed = stacks.length; }); http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js index 624e773..c474918 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js @@ -23,7 +23,7 @@ angular.module('ambariAdminConsole') getStatus: function() { var deferred = $q.defer(); - $http.get(Settings.baseUrl + '/clusters?fields=Clusters/provisioning_state') + $http.get(Settings.baseUrl + '/clusters?fields=Clusters/provisioning_state', {mock: 'cluster/init.json'}) .then(function(data, status, headers) { deferred.resolve(data.data.items[0]); }) @@ -39,6 +39,7 @@ angular.module('ambariAdminConsole') $http({ method: 'GET', url: Settings.baseUrl + '/permissions', + mock: 'permission/permissions.json', params: { fields: 'PermissionInfo', 'PermissionInfo/resource_name': 'CLUSTER' http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/StackVersions.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/StackVersions.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/StackVersions.js index d5c2803..ae499cc 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/StackVersions.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/StackVersions.js @@ -51,158 +51,15 @@ angular.module('ambariAdminConsole') return { list: function (filter) { - var deferred = $q.defer(); - var mockData = [ - { - name: 'HDP 2.2', - version: 'HDP-2.2.8', - cluster: 'anotherCluster', - status: 'INSTALLED', - totalHosts: 100, - statusHosts: ['host1', 'host2'] - }, - { - name: 'HDP 2.2', - version: 'HDP-2.2.2', - cluster: '', - status: 'INIT' - }, - { - name: 'HDP 2.2', - version: 'HDP-2.2.3', - cluster: 'MyCluster', - status: 'IN_USE', - totalHosts: 100, - statusHosts: ['host1', 'host2'] - }, - { - name: 'HDP 2.2', - version: 'HDP-2.2.4', - cluster: 'MyCluster', - status: 'CURRENT', - totalHosts: 100, - statusHosts: ['host1', 'host2'] - } - ]; - - deferred.resolve(parse(mockData)); - return deferred.promise; + return $http.get(Settings.baseUrl + '/stacks?fields=versions/RepositoryVersions', {mock: 'version/versions.json'}); }, get: function (version) { - var deferred = $q.defer(); - var mockData = { - "RepositoryVersion": { - "id": "1", - "display_name": "HDP 2.2.0.1", - "stack": "HDP-2.2", - "version": "2.2.0.1-885", - "upgrade_pack": "pack1", - "repositories": [ - { - "os": "redhat6", - "baseurls": [ - { - "id": "HDP-2.2.0.1-885", - "type": "HDP", - "baseurl": "http://host1/hdp" - }, - { - "id": "HDP-UTILS-1.0.0.20", - "type": "HDP-UTILS", - "baseurl": "http://host1/hdp-utils" - } - ] - } - ], - "deployment_info": [ - { - "cluster": "myCluster", - "status": "CURRENT", - "totalHostCount": 100, - "hosts": ["host1", "host2"] - }, - { - "cluster": "anotherCluster", - "status": "INSTALLED", - "totalHostCount": 100, - "hosts": ["host1", "host2"] - } - ] - } - }; - - deferred.resolve(mockData.RepositoryVersion); - return deferred.promise; + var url = Settings.baseUrl + '/stacks?versions/RepositoryVersions/repository_version=' + version +'&fields=versions/RepositoryVersions'; + return $http.get(url, {mock: 'version/version.json'}); }, - getStackRepositories: function () { - var deferred = $q.defer(); - var mockData = { - "repositories": [ - { - "os": "redhat5", - "baseurls": [ - { - "id": "HDP-2.2.0.1-885", - "type": "HDP", - "baseurl": "" - }, - { - "id": "HDP-UTILS-1.0.0.20", - "type": "HDP-UTILS", - "baseurl": "" - } - ] - }, - { - "os": "redhat6", - "baseurls": [ - { - "id": "HDP-2.2.0.1-885", - "type": "HDP", - "baseurl": "" - }, - { - "id": "HDP-UTILS-1.0.0.20", - "type": "HDP-UTILS", - "baseurl": "" - } - ] - }, - { - "os": "sles11", - "baseurls": [ - { - "id": "HDP-2.2.0.1-885", - "type": "HDP", - "baseurl": "" - }, - { - "id": "HDP-UTILS-1.0.0.20", - "type": "HDP-UTILS", - "baseurl": "" - } - ] - }, - { - "os": "ubuntu12", - "baseurls": [ - { - "id": "HDP-2.2.0.1-885", - "type": "HDP", - "baseurl": "" - }, - { - "id": "HDP-UTILS-1.0.0.20", - "type": "HDP-UTILS", - "baseurl": "" - } - ] - } - ] - }; - - deferred.resolve(mockData.repositories); - return deferred.promise; + getStackRepositories: function (version) { + var url = Settings.baseUrl + '/stacks/HDP/versions/' + version + '/operating_systems?fields=*'; + return $http.get(url, {mock: 'stack/stack.json'}); } }; }]); http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/View.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/View.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/View.js index 65c5c38..06a9e8f 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/View.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/View.js @@ -22,7 +22,7 @@ angular.module('ambariAdminConsole') function ViewInstance(item){ angular.extend(this, item); - }; + } ViewInstance.find = function(viewName, version, instanceName) { var deferred = $q.defer(); @@ -35,6 +35,7 @@ angular.module('ambariAdminConsole') $http({ method: 'GET', url: Settings.baseUrl + '/views/'+viewName+'/versions/'+version+'/instances/'+instanceName, + mock: 'view/views.json', params:{ 'fields': fields.join(',') } @@ -256,6 +257,7 @@ angular.module('ambariAdminConsole') $http({ method: 'GET', url: Settings.baseUrl + '/views', + mock: 'view/views.json', params:{ 'fields': 'versions/instances/ViewInstanceInfo', 'versions/ViewVersionInfo/system': false, @@ -264,11 +266,13 @@ angular.module('ambariAdminConsole') }).then(function(data) { var instances = []; data.data.items.forEach(function(view) { - view.versions.forEach(function(version) { - version.instances.forEach(function(instance) { - instances.push(instance.ViewInstanceInfo); + if (Array.isArray(view.versions)) { + view.versions.forEach(function(version) { + version.instances.forEach(function(instance) { + instances.push(instance.ViewInstanceInfo); + }); }); - }) + } }); deferred.resolve(instances); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/edit.html ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/edit.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/edit.html index 8aa9415..d3b808d 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/edit.html +++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/edit.html @@ -19,7 +19,7 @@ <div class="clearfix"> <ol class="breadcrumb pull-left"> <li><a href="#/stackVersions">Versions</a></li> - <li class="active">{{stackVersion.version}}</li> + <li class="active">{{stackVersion.repository_version}}</li> </ol> <div class="pull-right top-margin-4" ng-switch="deleteEnabled"> <button ng-switch-when="false" class="btn disabled btn-default" tooltip="Cannot Delete Static Instances">Deregister @@ -45,10 +45,6 @@ <div class="col-sm-9">{{stackVersion.stack}}</div> </div> <div class="form-group"> - <div class="col-sm-3"><label class="control-label">Upgrade Pack</label></div> - <div class="col-sm-9">{{stackVersion.upgrade_pack}}</div> - </div> - <div class="form-group"> <div class="col-sm-3"><label class="control-label">Version Name</label></div> <div class="col-sm-3"><input type="text" class="form-control" placeholder="Version Name" ng-model="stackVersion.display_name" ng-disabled="editVersionDisabled"></div> </div> @@ -85,18 +81,18 @@ <div class="col-sm-3"><h5><label>Name</label></h5></div> <div class="col-sm-6"><h5><label>Base URL</label></h5></div> </div> - <div class="clearfix border-bottom bottom-margin" ng-repeat="repository in stackVersion.repositories"> + <div class="clearfix border-bottom bottom-margin" ng-repeat="os in stackVersion.operatingSystems"> <div class="col-sm-3"> <div class="checkbox"> <label> - <input type="checkbox" ng-model="repository.selected"> {{repository.os}} + <input type="checkbox" ng-model="os.selected"> {{os.OperatingSystems.os_type}} </label> </div> </div> <div class="col-sm-9"> - <div class="form-group" ng-repeat="baseUrl in repository.baseurls"> - <div class="col-sm-4"><label class="control-label">{{baseUrl.type}}</label></div> - <div class="col-sm-8"><input type="text" class="form-control" ng-model="baseUrl.baseurl"></div> + <div class="form-group" ng-repeat="repository in os.repositories"> + <div class="col-sm-4"><label class="control-label">{{repository.Repositories.repo_id}}</label></div> + <div class="col-sm-8"><input type="text" class="form-control" ng-model="repository.Repositories.base_url"></div> </div> </div> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/1f272c27/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/list.html ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/list.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/list.html index 31b1f61..97e67c9 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/list.html +++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/list.html @@ -40,7 +40,7 @@ </select> </th> <th class="col-medium"> - <label for="">Version</label> + <label>Version</label> <input type="text" class="form-control" ng-model="filter.version"> </th> <th class="col-small"> @@ -55,8 +55,8 @@ </thead> <tbody> <tr ng-repeat="stack in stacks"> - <td class="col-small">{{stack.name}}</td> - <td class="col-medium"><a href="#/stackVersions/{{stack.version}}/edit">{{stack.version}}</a></td> + <td class="col-small">{{stack.display_name}}</td> + <td class="col-medium"><a href="#/stackVersions/{{stack.repository_version}}/edit">{{stack.repository_version}}</a></td> <td class="col-small"> <a href ng-show="stack.cluster"> <i class="glyphicon glyphicon-cloud"></i> @@ -66,7 +66,7 @@ </td> <td> <div ng-show="stack.status !== 'INIT'"> - <span class="label" ng-class="stack.statusClass">{{stack.statusLabel}}: {{stack.statusHosts.length}}/{{stack.totalHosts}}</span> + <span class="label" ng-class="stack.statusClass">{{stack.statusLabel}}: {{stack.current_hosts.length}}/{{stack.totalHosts}}</span> </div> </td> </tr>