How to use the angular.toJson function in angular

To help you get started, we’ve selected a few angular examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenSOC / opensoc-ui / src / kibana / components / courier / saved_object / saved_object.js View on Github external
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);
      };
github ORCID / ORCID-Source / orcid-web / src / main / webapp / static / javascript / ng1Orcid / app / controllers / OtherNamesCtrl.ts View on Github external
$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");
                });
            };
github grafana / grafana / public / app / plugins / datasource / elasticsearch / datasource.ts View on Github external
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());
github alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / topologytemplates / controllers / topology_template.js View on Github external
$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);
                }
            );
          };
github lensesio / schema-registry-ui / src / schema-registry / new / new.controller.js View on Github external
// 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);

};
github alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / meta-props / controllers / meta_props_edit.js View on Github external
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();
github bendrucker / convex / test / unit / request.js View on Github external
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();
    });
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / features / dashboard / components / DashExportModal / DashExportCtrl.ts View on Github external
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');
  }
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / plugins / datasource / elasticsearch / datasource.ts View on Github external
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);
  }