Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.save = function () {
var body = {};
_.forOwn(mapping, function (fieldMapping, fieldName) {
if (self[fieldName] != null) {
body[fieldName] = (fieldMapping._serialize)
? fieldMapping._serialize(self[fieldName])
: self[fieldName];
}
});
if (self.searchSource) {
body.kibanaSavedObjectMeta = {
searchSourceJSON: angular.toJson(_.omit(self.searchSource.toJSON(), ['sort', 'size']))
};
}
// Slugify the object id
self.id = slugifyId(self.id);
// ensure that the docSource has the current self.id
docSource.id(self.id);
// index the document
return self.saveSource(body);
};
$scope.setOtherNamesForm = function(){
$scope.otherNamesForm.visibility = null;
$.ajax({
url: getBaseUri() + '/my-orcid/otherNamesForms.json',
type: 'POST',
data: angular.toJson($scope.otherNamesForm),
contentType: 'application/json;charset=UTF-8',
dataType: 'json',
success: function(data) {
$scope.otherNamesForm = data;
if(data.errors.length == 0){
$scope.close();
}
$.colorbox.close();
$scope.$apply();
}
}).fail(function() {
// something bad is happening!
console.log("OtherNames.serverValidate() error");
});
};
let queryObj;
if (target.isLogsQuery || queryDef.hasMetricOfType(target, 'logs')) {
target.bucketAggs = [queryDef.defaultBucketAgg()];
target.metrics = [queryDef.defaultMetricAgg()];
// Setting this for metrics queries that are typed as logs
target.isLogsQuery = true;
queryObj = this.queryBuilder.getLogsQuery(target, queryString);
} else {
if (target.alias) {
target.alias = this.templateSrv.replace(target.alias, options.scopedVars, 'lucene');
}
queryObj = this.queryBuilder.build(target, adhocFilters, queryString);
}
const esQuery = angular.toJson(queryObj);
const searchType = queryObj.size === 0 && this.esVersion < 5 ? 'count' : 'query_then_fetch';
const header = this.getQueryHeader(searchType, options.range.from, options.range.to);
payload += header + '\n';
payload += esQuery + '\n';
sentTargets.push(target);
}
if (sentTargets.length === 0) {
return Promise.resolve({ data: [] });
}
payload = payload.replace(/\$timeFrom/g, options.range.from.valueOf().toString());
payload = payload.replace(/\$timeTo/g, options.range.to.valueOf().toString());
$scope.updateTopologyTemplate = function (fieldName, fieldValue) {
var topologyTemplateUpdateRequest = {};
topologyTemplateUpdateRequest[fieldName] = fieldValue;
return topologyTemplateService.put({
topologyTemplateId: $scope.topologyTemplateId
}, angular.toJson(topologyTemplateUpdateRequest), undefined).$promise.then(
function () {}, // Success
function (errorResponse) { // Error
return $translate.instant('ERRORS.' + errorResponse.data.error.code);
}
);
};
// When the 'Ace' of the schema/new is CHANGED (!)
$scope.newSchemaAceChanged = function (_editor) {
$scope.editor = _editor;
updateCurl();
};
// When the 'Ace' of the curl command is loaded
$scope.curlCommandAceLoaded = function (_editor) {
$scope.editor = _editor;
$scope.editor.$blockScrolling = Infinity;
};
$scope.newAvroString =
angular.toJson(
{
"type": "record",
"name": "evolution",
"doc": "This is a sample Avro schema to get you started. Please edit",
"namespace": "com.landoop",
"fields": [{"name": "name", "type": "string"}, {"name": "number1", "type": "int"}, {
"name": "number2",
"type": "float"
}]
}, true);
};
function loadMetaProperties() {
var request = {
'query': '',
'filters': {
target: [$scope.propertiesType]
},
'from': 0,
'size': 5000000 // get all in a single call as we don't have pagination feature here.
};
metapropConfServices.search([], angular.toJson(request), function(result) {
$scope.properties = result.data.data;
});
}
loadMetaProperties();
it('can respond from localStorage', function () {
$window.localStorage
.setItem('convex-' + request.config.url, angular.toJson({
bar: 'baz'
}));
request.config.cache = 'persist';
request.send().then(function (response) {
expect(response).to.deep.equal({bar: 'baz'});
});
$timeout.flush();
});
private openSaveAsDialog(dash: any) {
const blob = new Blob([angular.toJson(dash, true)], {
type: 'application/json;charset=utf-8',
});
saveAs(blob, dash.title + '-' + new Date().getTime() + '.json');
}
getQueryHeader(searchType: any, timeFrom: any, timeTo: any) {
const queryHeader: any = {
search_type: searchType,
ignore_unavailable: true,
index: this.indexPattern.getIndexList(timeFrom, timeTo),
};
if (this.esVersion >= 56 && this.esVersion < 70) {
queryHeader['max_concurrent_shard_requests'] = this.maxConcurrentShardRequests;
}
return angular.toJson(queryHeader);
}