use code-mirror directive for host facts

This commit is contained in:
Keith Grant 2019-03-19 15:07:10 -04:00
parent 5583af2a58
commit b6d8f9c6f6
3 changed files with 20 additions and 17 deletions

View File

@ -77,6 +77,14 @@ function atCodeMirrorController (
return true;
}
if (typeof str !== 'string') {
const yamlStr = jsyaml.safeDump(str);
// jsyaml.safeDump doesn't process an empty object correctly
if (yamlStr === '{}\n') {
return '---';
}
return yamlStr;
}
if (str === '' || str === '{}') {
return '---';
} else if (IsJsonString(str)) {

View File

@ -4,25 +4,17 @@
* All Rights Reserved
*************************************************/
function AnsibleFacts($scope, Facts, ParseTypeChange, ParseVariableString) {
function AnsibleFacts($scope, Facts) {
function init() {
$scope.facts = ParseVariableString(Facts);
$scope.facts = Facts;
let rows = (_.isEmpty(Facts)) ? 6 : 20;
$("#host_facts").attr("rows", rows);
$scope.parseType = 'yaml';
ParseTypeChange({
scope: $scope,
variable: 'facts',
parse_variable: 'parseType',
field_id: 'host_facts',
readOnly: true
});
}
init();
}
export default ['$scope', 'Facts', 'ParseTypeChange', 'ParseVariableString', AnsibleFacts
];
export default ['$scope', 'Facts', AnsibleFacts];

View File

@ -1,10 +1,13 @@
<form class="Form ng-pristine ng-valid ng-valid-required" name="host_form" id="host_form" autocomplete="off" novalidate="">
<div class="form-group Form-formGroup Form-formGroup--fullWidth">
<label class="Form-inputLabelContainer " for="facts">
<span class="Form-inputLabel" translate>FACTS</span>
</label>
<div>
<textarea rows="6" ng-model="facts" name="facts" class="form-control Form-textArea Form-formGroup--fullWidth" id="host_facts"></textarea>
</div>
<at-code-mirror
id="host_facts"
name="facts"
class="Form-textArea Form-formGroup--fullWidth"
label="facts"
variables="facts"
tooltip=""
disabled="true"
></at-code-mirror>
</div>
</form>