Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
François Prunayre
committed
Aug 14, 2013
1 parent
2c33866
commit 2afec85
Showing
25 changed files
with
3,190 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
web-ui/src/main/resources/catalog/js/admin/LogoSettingsController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
(function() { | ||
goog.provide('gn_logo_settings_controller'); | ||
|
||
|
||
var module = angular.module('gn_logo_settings_controller', | ||
['blueimp.fileupload']); | ||
|
||
|
||
/** | ||
* GnLogoSettingsController provides management interface | ||
* for catalog logo and harvester logo. | ||
* | ||
*/ | ||
module.controller('GnLogoSettingsController', [ | ||
'$scope', '$http', '$rootScope', '$translate', | ||
function($scope, $http, $rootScope, $translate) { | ||
/** | ||
* The list of catalog logos | ||
*/ | ||
$scope.logos = []; | ||
|
||
/** | ||
* Load list of logos | ||
*/ | ||
loadLogo = function() { | ||
$scope.logos = []; | ||
$http.get('admin.logo.list@json?type=icons').success(function(data) { | ||
$scope.logos = data[0]; | ||
}).error(function(data) { | ||
// TODO | ||
}); | ||
}; | ||
|
||
/** | ||
* Callback when error uploading file. | ||
*/ | ||
loadLogoError = function(e, data) { | ||
$rootScope.$broadcast('StatusUpdated', { | ||
title: $translate('logoUploadError'), | ||
error: data.jqXHR.responseJSON, | ||
timeout: 0, | ||
type: 'danger'}); | ||
}; | ||
|
||
/** | ||
* Configure logo uploader | ||
*/ | ||
$scope.logoUploadOptions = { | ||
autoUpload: true, | ||
done: loadLogo, | ||
fail: loadLogoError | ||
}; | ||
|
||
|
||
/** | ||
* Set the catalog logo and optionnaly the favicon | ||
* if favicon parameter is set to true. | ||
*/ | ||
$scope.setCatalogLogo = function(logoName, favicon) { | ||
var setFavicon = favicon ? 1 : 0; | ||
|
||
$http.get('admin.logo.set?fname=' + logoName + | ||
'&favicon=' + favicon) | ||
.success(function(data) { | ||
$rootScope.$broadcast('StatusUpdated', { | ||
msg: $translate('logoUpdated'), | ||
timeout: 2, | ||
type: 'success'}); | ||
}) | ||
.error(function(data) { | ||
$rootScope.$broadcast('StatusUpdated', { | ||
title: $translate('logoUpdateError'), | ||
error: data, | ||
timeout: 0, | ||
type: 'danger'}); | ||
loadLogo(); | ||
}); | ||
}; | ||
|
||
/** | ||
* Remove the logo and refresh the list when done. | ||
*/ | ||
$scope.removeLogo = function(logoName) { | ||
$http.get('admin.logo.remove?fname=' + logoName) | ||
.success(function(data) { | ||
$rootScope.$broadcast('StatusUpdated', { | ||
msg: $translate('logoRemoved'), | ||
timeout: 2, | ||
type: 'success'}); | ||
loadLogo(); | ||
}) | ||
.error(function(data) { | ||
$rootScope.$broadcast('StatusUpdated', { | ||
title: $translate('logoRemoveError'), | ||
error: data, | ||
timeout: 0, | ||
type: 'danger'}); | ||
loadLogo(); | ||
}); | ||
}; | ||
|
||
loadLogo(); | ||
}]); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
web-ui/src/main/resources/catalog/js/admin/SystemSettingsController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
(function() { | ||
goog.provide('gn_system_settings_controller'); | ||
|
||
|
||
var module = angular.module('gn_system_settings_controller', | ||
[]); | ||
|
||
|
||
/** | ||
* GnSystemSettingsController provides management interface | ||
* for catalog settings. | ||
* | ||
* TODO: | ||
* * Add custom forms for some settings (eg. contact for CSW, | ||
* Metadata views > default views, Search only in requested language) | ||
*/ | ||
module.controller('GnSystemSettingsController', [ | ||
'$scope', '$http', '$rootScope', '$translate', 'gnUtilityService', | ||
function($scope, $http, $rootScope, $translate, gnUtilityService) { | ||
|
||
$scope.settings = []; | ||
var sectionsLevel1 = []; | ||
var sectionsLevel2 = []; | ||
$scope.sectionsLevel1 = []; | ||
$scope.sectionsLevel2 = []; | ||
|
||
/** | ||
* Load catalog settings as a flat list and | ||
* extract firs and second level sections. | ||
* | ||
* Form field name is also based on settings | ||
* key replacing "/" by "." (to not create invalid | ||
* element name in XML Jeeves request element). | ||
*/ | ||
function loadSettings() { | ||
$http.get('xml.config.get@json?asTree=false').success(function(data) { | ||
$scope.settings = data; | ||
for (var i = 0; i < $scope.settings.length; i++) { | ||
var tokens = $scope.settings[i]['@name'].split('/'); | ||
$scope.settings[i].formName = | ||
$scope.settings[i]['@name'].replace(/\//g, '.'); | ||
// Extract level 1 and 2 sections | ||
if (tokens) { | ||
if (sectionsLevel1.indexOf(tokens[0]) === -1) { | ||
sectionsLevel1.push(tokens[0]); | ||
$scope.sectionsLevel1.push({ | ||
'name': tokens[0], | ||
'@position': $scope.settings[i]['@position']}); | ||
} | ||
var level2name = tokens[0] + '/' + tokens[1]; | ||
if (sectionsLevel2.indexOf(level2name) === -1) { | ||
sectionsLevel2.push(level2name); | ||
$scope.sectionsLevel2.push({ | ||
'name': level2name, | ||
'@position': $scope.settings[i]['@position']}); | ||
} | ||
} | ||
} | ||
}).error(function(data) { | ||
// TODO | ||
}); | ||
} | ||
|
||
/** | ||
* Filter all settings for a section | ||
*/ | ||
$scope.filterBySection = function(section) { | ||
var settings = []; | ||
|
||
for (var i = 0; i < $scope.settings.length; i++) { | ||
var s = $scope.settings[i]; | ||
if (s['@name'].indexOf(section) !== -1) { | ||
settings.push(s); | ||
} | ||
} | ||
return settings; | ||
}; | ||
|
||
/** | ||
* Order by position | ||
*/ | ||
$scope.getOrderBy = function(s) { | ||
return s['@position']; | ||
}; | ||
|
||
/** | ||
* Save the form containing all settings. When saved, | ||
* broadcast success status and reload catalog info. | ||
*/ | ||
$scope.saveSettings = function(formId) { | ||
$http.get($scope.url + 'admin.config.save?' + $(formId).serialize()) | ||
.success(function(data) { | ||
$rootScope.$broadcast('StatusUpdated', { | ||
msg: $translate('settingsUpdated'), | ||
timeout: 2, | ||
type: 'success'}); | ||
|
||
$scope.loadCatalogInfo(); | ||
}) | ||
.error(function(data) { | ||
$rootScope.$broadcast('StatusUpdated', { | ||
title: $translate('settingsUpdateError'), | ||
error: data, | ||
timeout: 0, | ||
type: 'danger'}); | ||
}); | ||
}; | ||
|
||
/** | ||
* Scroll to an element. | ||
*/ | ||
$scope.scrollTo = gnUtilityService.scrollTo; | ||
|
||
|
||
loadSettings(); | ||
}]); | ||
|
||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.