mirror of
https://github.com/mmumshad/ansible-playable.git
synced 2025-03-09 23:38:54 +00:00
Initial Commit
This commit is contained in:
commit
c92f737237
273 changed files with 16964 additions and 0 deletions
60
client/app/directives/complexVar/complexVar.controller.js
Normal file
60
client/app/directives/complexVar/complexVar.controller.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
'use strict';
|
||||
const angular = require('angular');
|
||||
|
||||
/*@ngInject*/
|
||||
export function complexVarController($scope,$filter) {
|
||||
'ngInject';
|
||||
var loadMembers = function(){
|
||||
$scope.membersCopy = angular.copy($scope.members);
|
||||
//var membersArray = $filter('addDotInKey')($filter('dictToKeyValueArray')($scope.membersCopy));
|
||||
var membersArray = ($filter('dictToKeyValueArraySimple')($scope.membersCopy));
|
||||
|
||||
$scope.tabgroup = $scope.tabgroup || 0;
|
||||
|
||||
if(membersArray.length)
|
||||
$scope.membersCopy = membersArray;
|
||||
else
|
||||
$scope.membersCopy = [{key:"",value:""}];
|
||||
|
||||
$scope.path = $scope.path || "";
|
||||
|
||||
angular.forEach($scope.membersCopy,function(member){
|
||||
if(Object.prototype.toString.call(member.value) === '[object Object]'){
|
||||
member.type = 'object';
|
||||
}else if(Object.prototype.toString.call(member.value) === '[object Array]'){
|
||||
member.type = 'array';
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
loadMembers();
|
||||
|
||||
$scope.setMemberType = function(member,type){
|
||||
if(type === 'object'){
|
||||
member.value = {};
|
||||
member.type = 'object';
|
||||
}else if(type === 'array'){
|
||||
member.value = {};
|
||||
member.type = 'array';
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$on('membersUpdated',function(){
|
||||
console.log('On Members Updated');
|
||||
console.log($scope.members);
|
||||
loadMembers();
|
||||
});
|
||||
|
||||
$scope.$watch('membersCopy',function(){
|
||||
if($scope.type === 'object')
|
||||
$scope.members = $filter('removeDotInKey')($filter('keyValueArrayToDict')($scope.membersCopy));
|
||||
else if($scope.type === 'array')
|
||||
$scope.members = $filter('keyValueArrayToArray')($scope.membersCopy);
|
||||
},true)
|
||||
}
|
||||
|
||||
export default angular.module('webAppApp.complexVarCtrl', [])
|
||||
.controller('ComplexVarController', complexVarController)
|
||||
.name;
|
|
@ -0,0 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
describe('Controller: ComplexVarCtrl', function() {
|
||||
// load the controller's module
|
||||
beforeEach(module('webAppApp.complexVar'));
|
||||
|
||||
var ComplexVarCtrl;
|
||||
|
||||
// Initialize the controller and a mock scope
|
||||
beforeEach(inject(function($controller) {
|
||||
ComplexVarCtrl = $controller('ComplexVarCtrl', {});
|
||||
}));
|
||||
|
||||
it('should ...', function() {
|
||||
expect(1).to.equal(1);
|
||||
});
|
||||
});
|
8
client/app/directives/complexVar/complexVar.css
Normal file
8
client/app/directives/complexVar/complexVar.css
Normal file
|
@ -0,0 +1,8 @@
|
|||
.complex-var-input {
|
||||
line-height: 1;
|
||||
padding-right: 5px;
|
||||
padding-left: 5px;
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
height: 25px;
|
||||
}
|
20
client/app/directives/complexVar/complexVar.directive.js
Normal file
20
client/app/directives/complexVar/complexVar.directive.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
const angular = require('angular');
|
||||
|
||||
export default angular.module('webAppApp.complexVar', [])
|
||||
.directive('complexVar', function() {
|
||||
return {
|
||||
template: require('./complexVar.html'),
|
||||
restrict: 'EA',
|
||||
scope: {
|
||||
members: '=',
|
||||
path: '=',
|
||||
type: '=',
|
||||
inputWidth: '=',
|
||||
tabgroup: '=?bind',
|
||||
hostVars: '='
|
||||
},
|
||||
controller: 'ComplexVarController'
|
||||
};
|
||||
})
|
||||
.name;
|
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
|
||||
describe('Directive: complexVar', function() {
|
||||
// load the directive's module and view
|
||||
beforeEach(module('webAppApp.complexVar'));
|
||||
beforeEach(module('app/directives/complexVar/complexVar.html'));
|
||||
|
||||
var element, scope;
|
||||
|
||||
beforeEach(inject(function($rootScope) {
|
||||
scope = $rootScope.$new();
|
||||
}));
|
||||
|
||||
it('should make hidden element visible', inject(function($compile) {
|
||||
element = angular.element('<complex-var></complex-var>');
|
||||
element = $compile(element)(scope);
|
||||
scope.$apply();
|
||||
expect(element.text()).to.equal('this is the complexVar directive');
|
||||
}));
|
||||
});
|
38
client/app/directives/complexVar/complexVar.html
Normal file
38
client/app/directives/complexVar/complexVar.html
Normal file
|
@ -0,0 +1,38 @@
|
|||
<div>
|
||||
<div class="row">
|
||||
<div class="col-md-5" style="text-align: center" ng-if="type != 'array'">
|
||||
<h5>Key</h5>
|
||||
</div>
|
||||
<div class="col-md-5" style="text-align: center">
|
||||
<h5>Value</h5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-repeat="member in membersCopy">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5" style="padding:2px;" ng-if="type != 'array'">
|
||||
<input type="text" ng-model="member.key" class="form-control complex-var-input" tabindex="{{tabgroup + ($index * 10) + 1}}" >
|
||||
</div>
|
||||
<div class="col-md-5" style="padding:2px;">
|
||||
<!--<input type="text" ng-model="member.value">-->
|
||||
<input type="text" ng-model="member.value" uib-typeahead="('\{\{' + var.key + '\}\}') as (var.key + ' = ' + var.value) for var in hostVars | filter: $viewValue" class="form-control complex-var-input" tabindex="{{tabgroup + ($index * 10) + 2}}">
|
||||
</div>
|
||||
<div class="col-md-2" style="padding:2px;">
|
||||
<div class="btn-group" style="top: -7px;">
|
||||
<label ng-click="membersCopy.splice($index+1,0,{})" style="cursor: pointer;font-weight: bold;font-size: 20px; color:green" tabindex="{{tabgroup + ($index * 10) + 3}}" ng-keydown="($event.which === 13 || $event.which === 32) && membersCopy.splice($index+1,0,{})" >+</label>
|
||||
<label ng-click="membersCopy.splice($index,1)" style="cursor: pointer;font-weight: bold;font-size: 25px; color:red" tabindex="{{tabgroup + ($index * 10) + 4}}">-</label>
|
||||
<label ng-click="setMemberType(member,'object')" style="cursor: pointer;font-weight: bold;font-size: 12px;" tabindex="{{tabgroup + ($index * 10) + 5}}">{ }</label>
|
||||
<label ng-click="setMemberType(member,'array')" style="cursor: pointer;font-weight: bold;font-size: 12px;" tabindex="{{tabgroup + ($index * 10) + 6}}">[ ]</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-left:30px;">
|
||||
<complex-var ng-if="member.type == 'object' || member.type == 'array'" host-vars="hostVars" tabgroup="tabgroup + 100" type="member.type" members="member.value" path="member.key">
|
||||
</complex-var>
|
||||
</div>
|
||||
|
||||
<!--<input type="text" ng-model="member.value" uib-typeahead="('"\{\{' + var.name + '\}\}"') as (var.name + ' = ' + var.value) for var in hostvars | filter: $viewValue" class="form-control">-->
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue