|
|
|
@ -53,36 +53,14 @@ export default function ExtensionFormHttpDirective($compile, $templateCache, $tr |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
if(scope.isAdd) { |
|
|
|
scope.converterConfigs = []; |
|
|
|
scope.config.converterConfigurations = scope.converterConfigs; |
|
|
|
} else { |
|
|
|
scope.converterConfigs = scope.config.converterConfigurations; |
|
|
|
} |
|
|
|
|
|
|
|
scope.updateValidity = function() { |
|
|
|
var valid = scope.converterConfigs && scope.converterConfigs.length > 0; |
|
|
|
scope.theForm.$setValidity('converterConfigs', valid); |
|
|
|
if(scope.converterConfigs.length) { |
|
|
|
for(let i=0;i<scope.converterConfigs.length;i++) { |
|
|
|
if(!scope.converterConfigs[i].converters.length) { |
|
|
|
scope.theForm.$setValidity('converters', false); |
|
|
|
break; |
|
|
|
} else { |
|
|
|
scope.theForm.$setValidity('converters', true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
scope.$watch('converterConfigs', function() { |
|
|
|
scope.updateValidity(); |
|
|
|
}, true); |
|
|
|
|
|
|
|
scope.addConverterConfig = function() { |
|
|
|
var newConverterConfig = {converterId:"", converters:[]}; |
|
|
|
scope.converterConfigs.push(newConverterConfig); |
|
|
|
} |
|
|
|
|
|
|
|
scope.converterConfigs[scope.converterConfigs.length - 1].converters = []; |
|
|
|
scope.addConverter(scope.converterConfigs[scope.converterConfigs.length - 1].converters); |
|
|
|
}; |
|
|
|
|
|
|
|
scope.removeConverterConfig = function(config) { |
|
|
|
var index = scope.converterConfigs.indexOf(config); |
|
|
|
@ -90,12 +68,17 @@ export default function ExtensionFormHttpDirective($compile, $templateCache, $tr |
|
|
|
scope.converterConfigs.splice(index, 1); |
|
|
|
} |
|
|
|
scope.theForm.$setDirty(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
scope.addConverter = function(converters) { |
|
|
|
var newConverter = {deviceNameJsonExpression:"", deviceTypeJsonExpression:"", attributes:[], timeseries:[]}; |
|
|
|
var newConverter = { |
|
|
|
deviceNameJsonExpression:"", |
|
|
|
deviceTypeJsonExpression:"", |
|
|
|
attributes:[], |
|
|
|
timeseries:[] |
|
|
|
}; |
|
|
|
converters.push(newConverter); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
scope.removeConverter = function(converter, converters) { |
|
|
|
var index = converters.indexOf(converter); |
|
|
|
@ -103,12 +86,12 @@ export default function ExtensionFormHttpDirective($compile, $templateCache, $tr |
|
|
|
converters.splice(index, 1); |
|
|
|
} |
|
|
|
scope.theForm.$setDirty(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
scope.addAttribute = function(attributes) { |
|
|
|
var newAttribute = {type:"", key:"", value:""}; |
|
|
|
attributes.push(newAttribute); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
scope.removeAttribute = function(attribute, attributes) { |
|
|
|
var index = attributes.indexOf(attribute); |
|
|
|
@ -116,11 +99,44 @@ export default function ExtensionFormHttpDirective($compile, $templateCache, $tr |
|
|
|
attributes.splice(index, 1); |
|
|
|
} |
|
|
|
scope.theForm.$setDirty(); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(scope.isAdd) { |
|
|
|
scope.converterConfigs = scope.config.converterConfigurations; |
|
|
|
scope.addConverterConfig(); |
|
|
|
} else { |
|
|
|
scope.converterConfigs = scope.config.converterConfigurations; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scope.updateValidity = function() { |
|
|
|
let valid = scope.converterConfigs && scope.converterConfigs.length > 0; |
|
|
|
scope.theForm.$setValidity('converterConfigs', valid); |
|
|
|
if(scope.converterConfigs.length) { |
|
|
|
for(let i=0; i<scope.converterConfigs.length; i++) { |
|
|
|
if(!scope.converterConfigs[i].converters.length) { |
|
|
|
scope.theForm.$setValidity('converters', false); |
|
|
|
break; |
|
|
|
} else { |
|
|
|
scope.theForm.$setValidity('converters', true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
scope.$watch('converterConfigs', function() { |
|
|
|
scope.updateValidity(); |
|
|
|
}, true); |
|
|
|
|
|
|
|
|
|
|
|
scope.transformerTypeChange = function(attribute) { |
|
|
|
attribute.transformer = ""; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
scope.validateTransformer = function (model, editorName) { |
|
|
|
if(model && model.length) { |
|
|
|
@ -131,10 +147,10 @@ export default function ExtensionFormHttpDirective($compile, $templateCache, $tr |
|
|
|
scope.theForm[editorName].$setValidity('transformerJSON', false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
$compile(element.contents())(scope); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
return { |
|
|
|
restrict: "A", |
|
|
|
|