Sha256: 5fe7010116e77bb93f4bd0916dd2b98e9843fc609229e4e2db24d15fee64295b

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

app.controller("TypeCtrl", function ($scope, $stateParams, Documentation) {
  $scope.typeName = $stateParams.type || $scope.controller.media_type;
  $scope.apiVersion = $stateParams.version;
  $scope.controllers = [];
  $scope.views = [];

  Documentation.getType($stateParams.version, $scope.typeName).then(function(response) {
    $scope.type = response.data;
    $scope.views = _(response.data.views)
      .map(function(view, name) { return _.extend(view, { name: name }); })
      .select(function(view) { return view.name != 'master'; })
      .value();

    _.forEach($scope.type.attributes, function(attribute, name) {
      var example = JSON.stringify($scope.type.example[name], null, 2);
      if (!attribute.options) attribute.options = {};
      if (example) attribute.options.example = example;
      if (attribute.values) attribute.options.values = attribute.values;
      if (attribute.default) attribute.options.default = attribute.default;
    });

    Documentation.getIndex().success(function(response) {
      $scope.controllers = _.select(response[$scope.apiVersion], function(item) { return item.controller && item.media_type == $scope.typeName; });
    });
  }, function() {
    $scope.error = true;
  });
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
praxis-0.11.2 lib/api_browser/app/js/controllers/type.js
praxis-0.11.1 lib/api_browser/app/js/controllers/type.js
praxis-0.11 lib/api_browser/app/js/controllers/type.js
praxis-0.11pre lib/api_browser/app/js/controllers/type.js
praxis-0.10.1 lib/api_browser/app/js/controllers/type.js
praxis-0.10.0 lib/api_browser/app/js/controllers/type.js
praxis-0.9 lib/api_browser/app/js/controllers/type.js