Commit cdb3c0bb by Suma Shivaprasad

ATLAS-318 Config file conatining API endpoint + all api calls to be centralized…

ATLAS-318 Config file conatining API endpoint + all api calls to be centralized (sanjayp via sumasai)
parent 64bda5a4
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
"unused": true, // Warn unused variables. "unused": true, // Warn unused variables.
"globals": { // Globals variables. "globals": { // Globals variables.
"angular": true, "angular": true,
"$": false "$": false,
"baseUrl":true
}, },
"predef": [ // Extra globals. "predef": [ // Extra globals.
"define", "define",
......
...@@ -95,6 +95,7 @@ module.exports = function(grunt) { ...@@ -95,6 +95,7 @@ module.exports = function(grunt) {
dist: distPath + '/js/app.min.js', dist: distPath + '/js/app.min.js',
modules: grunt.file.expand( modules: grunt.file.expand(
modulesPath + 'js/app.js', modulesPath + 'js/app.js',
modulesPath + 'js/config.js',
modulesPath + 'js/routes.js', modulesPath + 'js/routes.js',
modulesPath + 'modules/**/*Module.js', modulesPath + 'modules/**/*Module.js',
modulesPath + 'modules/**/*.js', modulesPath + 'modules/**/*.js',
......
...@@ -52,7 +52,7 @@ angular.module('dgc').factory('lodash', ['$window', ...@@ -52,7 +52,7 @@ angular.module('dgc').factory('lodash', ['$window',
]).factory('HttpInterceptor', ['Global', function(Global) { ]).factory('HttpInterceptor', ['Global', function(Global) {
return { return {
'request': function(config) { 'request': function(config) {
if (config.url && (config.url.indexOf('api/atlas/') === 0 || config.url.indexOf('/api/atlas/') === 0)) { if (config.url && (config.url.indexOf(baseUrl) === 0 || config.url.indexOf(baseUrl) === 0)) {
config.params = config.params || {}; config.params = config.params || {};
config.params['user.name'] = Global.user; config.params['user.name'] = Global.user;
} }
......
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
var host = '',
port = '',
baseUrl = '/api/atlas/',
apiHost = (host!=='') ? host + ':' + port + baseUrl : baseUrl ;
angular.module('dgc').constant('AtlasConfig', {
API_ENDPOINTS: {
ABOUT: apiHost + 'admin/version',
GET_ENTITY: apiHost + 'entities',
ATTACH_DETACH_TRAITS: 'traits',
SCHEMA_LINEAGE_PREPEND: apiHost + 'lineage/hive/table',
SCHEMA_APPEND: 'schema',
GRAPH: 'graph',
TRAITS_LIST: apiHost + 'types?type=TRAIT',
SEARCH: apiHost + 'discovery/search/',
CREATE_TRAIT: apiHost + 'types'
}
});
\ No newline at end of file
...@@ -18,6 +18,6 @@ ...@@ -18,6 +18,6 @@
'use strict'; 'use strict';
angular.module('dgc.about').factory('AboutResource', ['$resource', function($resource) { angular.module('dgc.about').factory('AboutResource', ['$resource', 'AtlasConfig', function($resource, AtlasConfig) {
return $resource('/api/atlas/admin/version', {}); return $resource(AtlasConfig.API_ENDPOINTS.ABOUT, {});
}]); }]);
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
'use strict'; 'use strict';
angular.module('dgc.details').factory('DetailsResource', ['$resource', function($resource) { angular.module('dgc.details').factory('DetailsResource', ['$resource', 'AtlasConfig', function($resource, AtlasConfig) {
return $resource('/api/atlas/entities/:id', {}, { return $resource(AtlasConfig.API_ENDPOINTS.GET_ENTITY +'/:id', {}, {
get: { get: {
method: 'GET', method: 'GET',
transformResponse: function(data) { transformResponse: function(data) {
...@@ -31,16 +31,16 @@ angular.module('dgc.details').factory('DetailsResource', ['$resource', function( ...@@ -31,16 +31,16 @@ angular.module('dgc.details').factory('DetailsResource', ['$resource', function(
}, },
saveTag: { saveTag: {
method: 'POST', method: 'POST',
url: '/api/atlas/entities/:id/traits' url : AtlasConfig.API_ENDPOINTS.GET_ENTITY + '/:id/' + AtlasConfig.API_ENDPOINTS.ATTACH_DETACH_TRAITS
}, },
detachTag : { detachTag : {
method: 'DELETE', method: 'DELETE',
url: '/api/atlas/entities/:id/traits/:tagName' url : AtlasConfig.API_ENDPOINTS.GET_ENTITY + '/:id/' + AtlasConfig.API_ENDPOINTS.ATTACH_DETACH_TRAITS + '/:tagName'
} }
}); });
}]).factory('SchemaResource', ['$resource', function($resource) { }]).factory('SchemaResource', ['$resource','AtlasConfig', function($resource, AtlasConfig) {
return $resource('/api/atlas/lineage/hive/table/:tableName/schema', {}, { return $resource(AtlasConfig.API_ENDPOINTS.SCHEMA_LINEAGE_PREPEND + '/:tableName/' + AtlasConfig.API_ENDPOINTS.SCHEMA_APPEND, {}, {
get: { get: {
method: 'GET', method: 'GET',
transformResponse: function(data) { transformResponse: function(data) {
......
...@@ -18,6 +18,6 @@ ...@@ -18,6 +18,6 @@
'use strict'; 'use strict';
angular.module('dgc.lineage').factory('LineageResource', ['$resource', function($resource) { angular.module('dgc.lineage').factory('LineageResource', ['$resource','AtlasConfig', function($resource, AtlasConfig) {
return $resource('/api/atlas/lineage/hive/table/:tableName/:type/graph', {}); return $resource(AtlasConfig.API_ENDPOINTS.SCHEMA_LINEAGE_PREPEND+'/:tableName/:type/'+AtlasConfig.API_ENDPOINTS.GRAPH, {});
}]); }]);
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
*/ */
'use strict'; 'use strict';
angular.module('dgc.navigation').controller('NavigationController', ['$scope', 'NavigationResource', '$cacheFactory', angular.module('dgc.navigation').controller('NavigationController', ['$scope', 'NavigationResource', '$cacheFactory','AtlasConfig',
function($scope, NavigationResource, $cacheFactory) { function($scope, NavigationResource, $cacheFactory,AtlasConfig) {
$scope.updateVar = function(event) { $scope.updateVar = function(event) {
$scope.$$prevSibling.query = angular.element(event.target).text(); $scope.$$prevSibling.query = angular.element(event.target).text();
...@@ -31,12 +31,12 @@ angular.module('dgc.navigation').controller('NavigationController', ['$scope', ' ...@@ -31,12 +31,12 @@ angular.module('dgc.navigation').controller('NavigationController', ['$scope', '
setTimeout(function() { setTimeout(function() {
var httpDefaultCache = $cacheFactory.get('$http'); var httpDefaultCache = $cacheFactory.get('$http');
httpDefaultCache.remove('/api/atlas/types?type=TRAIT'); httpDefaultCache.remove(AtlasConfig.API_ENDPOINTS.TRAITS_LIST);
}, 3600000); }, 3600000);
$scope.refreshTags = function(){ $scope.refreshTags = function(){
var httpDefaultCache = $cacheFactory.get('$http'); var httpDefaultCache = $cacheFactory.get('$http');
httpDefaultCache.remove('/api/atlas/types?type=TRAIT'); httpDefaultCache.remove(AtlasConfig.API_ENDPOINTS.TRAITS_LIST);
$scope.leftnav = NavigationResource.get(); $scope.leftnav = NavigationResource.get();
}; };
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
'use strict'; 'use strict';
angular.module('dgc.navigation').factory('NavigationResource', ['$resource', function($resource) { angular.module('dgc.navigation').factory('NavigationResource', ['$resource','AtlasConfig', function($resource, AtlasConfig) {
return $resource('/api/atlas/types?type=TRAIT', {}, { return $resource(AtlasConfig.API_ENDPOINTS.TRAITS_LIST, {}, {
get: { get: {
'method': 'GET', 'method': 'GET',
'responseType': 'json', 'responseType': 'json',
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
'use strict'; 'use strict';
angular.module('dgc.search').factory('SearchResource', ['$resource', function($resource) { angular.module('dgc.search').factory('SearchResource', ['$resource', 'AtlasConfig', function($resource, AtlasConfig) {
return $resource('/api/atlas/discovery/search/', {}, { return $resource(AtlasConfig.API_ENDPOINTS.SEARCH, {}, {
search: { search: {
'method': 'GET', 'method': 'GET',
'responseType': 'json', 'responseType': 'json',
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
*/ */
'use strict'; 'use strict';
angular.module('dgc.tags.definition').controller('DefinitionTagsController', ['$scope', '$resource', '$state', '$stateParams', 'lodash', 'AttributeDefinition', 'TagClasses', 'TagsResource', 'NotificationService', 'NavigationResource', '$cacheFactory', angular.module('dgc.tags.definition').controller('DefinitionTagsController', ['$scope', '$resource', '$state', '$stateParams', 'lodash', 'AttributeDefinition', 'TagClasses', 'TagsResource', 'NotificationService', 'NavigationResource', '$cacheFactory','AtlasConfig',
function($scope, $resource, $state, $stateParams, _, AttributeDefinition, Categories, TagsResource, NotificationService, NavigationResource, $cacheFactory) { function($scope, $resource, $state, $stateParams, _, AttributeDefinition, Categories, TagsResource, NotificationService, NavigationResource, $cacheFactory,AtlasConfig) {
$scope.categoryList = Categories; $scope.categoryList = Categories;
$scope.category = 'TRAIT'; $scope.category = 'TRAIT';
$scope.tagModel = { $scope.tagModel = {
...@@ -47,7 +47,7 @@ angular.module('dgc.tags.definition').controller('DefinitionTagsController', ['$ ...@@ -47,7 +47,7 @@ angular.module('dgc.tags.definition').controller('DefinitionTagsController', ['$
$scope.refreshTags = function(){ $scope.refreshTags = function(){
var httpDefaultCache = $cacheFactory.get('$http'); var httpDefaultCache = $cacheFactory.get('$http');
httpDefaultCache.remove('/api/atlas/types?type=TRAIT'); httpDefaultCache.remove(AtlasConfig.API_ENDPOINTS.TRAITS_LIST);
$scope.typesList = NavigationResource.get(); $scope.typesList = NavigationResource.get();
}; };
...@@ -65,7 +65,7 @@ angular.module('dgc.tags.definition').controller('DefinitionTagsController', ['$ ...@@ -65,7 +65,7 @@ angular.module('dgc.tags.definition').controller('DefinitionTagsController', ['$
.then(function TagCreateSuccess() { .then(function TagCreateSuccess() {
NotificationService.info('"' + $scope.tagModel.typeName + '" has been created', false); NotificationService.info('"' + $scope.tagModel.typeName + '" has been created', false);
var httpDefaultCache = $cacheFactory.get('$http'); var httpDefaultCache = $cacheFactory.get('$http');
httpDefaultCache.remove('/api/atlas/types?type=TRAIT'); httpDefaultCache.remove(AtlasConfig.API_ENDPOINTS.TRAITS_LIST);
$scope.typesList = NavigationResource.get(); $scope.typesList = NavigationResource.get();
$scope.reset(); $scope.reset();
}).catch(function TagCreateFailed(error) { }).catch(function TagCreateFailed(error) {
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
'use strict'; 'use strict';
angular.module('dgc.tags').factory('TagsResource', ['$resource', function($resource) { angular.module('dgc.tags').factory('TagsResource', ['$resource', 'AtlasConfig', function($resource, AtlasConfig) {
return $resource('/api/atlas/types/:id', {}, { return $resource(AtlasConfig.API_ENDPOINTS.CREATE_TRAIT + '/:id', {}, {
query: { query: {
method: 'GET', method: 'GET',
transformResponse: function(data) { transformResponse: function(data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment