Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelGauthier committed Jan 23, 2017
1 parent f11dd9a commit 2726f78
Show file tree
Hide file tree
Showing 6 changed files with 358 additions and 146 deletions.
2 changes: 1 addition & 1 deletion rudder-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ along with Rudder. If not, see <http://www.gnu.org/licenses/>.
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>false</enabled></releases>
</repository>
</repositories>
</repositories>

<build>
<plugins>
Expand Down
51 changes: 49 additions & 2 deletions rudder-web/src/main/webapp/javascript/rudder/angular/dataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ app.controller("datasourceCtrl", ['$scope', '$timeout', 'orderByFilter','$http',
$scope.datasources = [];
// Selected data source
$scope.selectedDatasource;

$scope.treeId = "#datasources-tree";
/* Get data sources */
$scope.getDataSources = function(){
return $http.get(contextPath + '/secure/api/latest/datasources').then(function(response){
Expand Down Expand Up @@ -134,6 +134,38 @@ app.controller("datasourceCtrl", ['$scope', '$timeout', 'orderByFilter','$http',
"isNew":true
};
}
$scope.updateKeyName = function(){
if($scope.selectedDatasource.isNew){
if($scope.selectedDatasource.name){
var r=$scope.selectedDatasource.name.toLowerCase();
r = r.replace(new RegExp("\\s", 'g'),"_");
r = r.replace(new RegExp("[àáâãäå]", 'g'),"a");
r = r.replace(new RegExp("æ", 'g'),"ae");
r = r.replace(new RegExp("ç", 'g'),"c");
r = r.replace(new RegExp("[èéêë]", 'g'),"e");
r = r.replace(new RegExp("[ìíîï]", 'g'),"i");
r = r.replace(new RegExp("ñ", 'g'),"n");
r = r.replace(new RegExp("[òóôõö]", 'g'),"o");
r = r.replace(new RegExp("œ", 'g'),"oe");
r = r.replace(new RegExp("[ùúûü]", 'g'),"u");
r = r.replace(new RegExp("[ýÿ]", 'g'),"y");
r = r.replace(new RegExp("\\W", 'g'),"_");
$scope.selectedDatasource.id = r;
}else{
$scope.selectedDatasource.id = "";
}
}
}
$scope.toggleEnabled = function(){
$scope.selectedDatasource.enabled = !$scope.selectedDatasource.enabled;
var temp = jQuery.extend(true, {}, $scope.getDatasource($scope.selectedDatasource.id));
temp.enabled = $scope.selectedDatasource.enabled;
$http.post(contextPath + '/secure/api/latest/datasources/' + temp.id, temp).then(function(response){
var res = response;
var index = $scope.getDatasource($scope.selectedDatasource.id, true);
$scope.datasources[index] = jQuery.extend(true, {}, $scope.selectedDatasource);
});
}
$scope.saveDatasource = function(){
//CONVERT TIMES
$scope.selectedDatasource.runParameters.schedule.duration = minuteConvert($scope.selectedDatasource.modifiedTimes.schedule)
Expand All @@ -158,6 +190,7 @@ app.controller("datasourceCtrl", ['$scope', '$timeout', 'orderByFilter','$http',
$scope.selectDatasource = function(id){
if($scope.forms.datasourceForm){
$scope.forms.datasourceForm.$setPristine();
$('.well').css('display','none');
}
var getDatasource = $scope.getDatasource(id);
if(getDatasource){
Expand All @@ -182,7 +215,11 @@ app.controller("datasourceCtrl", ['$scope', '$timeout', 'orderByFilter','$http',
}
$scope.toggleHeaders = function(idHeader, event){
$('#'+idHeader).toggle(80);
$(event.currentTarget).find('.fa').toggleClass('fa-rotate-180');
$(event.currentTarget).find('.fa').toggleClass('fa-rotate-90');
}
$scope.toggleExample = function(event){
$(event.currentTarget).parent().find('.example-help').toggle();
$(event.currentTarget).toggleClass('show');
}
$scope.addNewHeader = function(datasource){
if(!datasource.type.parameters.headers.hasOwnProperty(datasource.newHeader.key)){
Expand All @@ -196,6 +233,16 @@ app.controller("datasourceCtrl", ['$scope', '$timeout', 'orderByFilter','$http',
$scope.hasHeaders = function(datasource){
return Object.keys(datasource.type.parameters.headers).length;
}

$scope.toggleInfo = function(event, action){
$(event.currentTarget).bsPopover(action);
}
$scope.toggleAdvancedOptions = function(event){
var el = $(event.currentTarget);
el.find('.fa').toggleClass('fa-rotate-90');
el.parent().parent().find('.well').toggle();
}
adjustHeight($scope.treeId, true);
}]);

function timeConvert(time) {
Expand Down
10 changes: 9 additions & 1 deletion rudder-web/src/main/webapp/javascript/rudder/rudder.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,6 @@ function showFileManager(idField){
angular.element(fileManagerApp).injector().invoke(function($compile) {
var $scope = angular.element(fileManagerApp).scope();
fileManagerApp.append($compile(filemanager)($scope));

$scope.directiveId = idField;
// Finally, refresh the watch expressions in the new element
$scope.$apply();
Expand All @@ -648,4 +647,13 @@ function showFileManager(idField){
function hideFileManager(){
$(document).off('keydown.closeWindow');
$("angular-filemanager").remove();
}

//Adjust tree height
function adjustHeight(treeId, height){
var tree = $(treeId);
var offsetTop = tree.offset().top + 12;
var maxHeight = 'calc(100vh - '+ offsetTop + 'px)';
var cssProp = height ? 'height' : 'max-height'
tree.css(cssProp,maxHeight);
}
Loading

0 comments on commit 2726f78

Please sign in to comment.