pact_broker 0.0.10 → 1.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +0 -3
- data/README.md +28 -1
- data/Rakefile +4 -2
- data/assets/d3.v3.js +9263 -0
- data/assets/force.csv +29 -0
- data/assets/index.html +186 -0
- data/assets/index2.html +224 -0
- data/assets/relationships +4 -0
- data/assets/stylesheets/github.css +387 -0
- data/bethtest.rb +67 -0
- data/config.ru +10 -4
- data/config/boot.rb +4 -0
- data/example/Gemfile +5 -0
- data/example/config.ru +18 -0
- data/lib/db.rb +52 -0
- data/lib/pact_broker.rb +2 -0
- data/lib/pact_broker/api.rb +2 -0
- data/lib/pact_broker/api/decorators/pact_collection_decorator.rb +1 -1
- data/lib/pact_broker/api/decorators/pacticipant_collection_decorator.rb +1 -1
- data/lib/pact_broker/api/decorators/relationships_csv_decorator.rb +32 -0
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +43 -0
- data/lib/pact_broker/api/resources/latest_pact.rb +7 -1
- data/lib/pact_broker/api/resources/relationships.rb +29 -0
- data/lib/pact_broker/app.rb +82 -0
- data/lib/pact_broker/configuration.rb +47 -0
- data/lib/pact_broker/db.rb +7 -39
- data/lib/pact_broker/models/relationship.rb +27 -0
- data/lib/pact_broker/project_root.rb +7 -0
- data/lib/pact_broker/services/pacticipant_service.rb +6 -0
- data/lib/pact_broker/ui/controllers/base_controller.rb +15 -0
- data/lib/pact_broker/ui/controllers/clusters.rb +28 -0
- data/lib/pact_broker/ui/controllers/relationships.rb +21 -0
- data/lib/pact_broker/ui/view_models/clusters.rb +0 -0
- data/lib/pact_broker/ui/view_models/relationship.rb +35 -0
- data/lib/pact_broker/ui/view_models/relationships.rb +21 -0
- data/lib/pact_broker/ui/views/clusters/show.haml +2 -0
- data/lib/pact_broker/ui/views/layouts/main.haml +2 -0
- data/lib/pact_broker/ui/views/relationships/show.haml +44 -0
- data/lib/pact_broker/version.rb +1 -1
- data/lib/rack/hal_browser.rb +1 -0
- data/lib/rack/hal_browser/redirect.rb +45 -0
- data/pact_broker.gemspec +10 -8
- data/public/bootstrap.zip +0 -0
- data/public/config.json +412 -0
- data/public/css/bootstrap-theme.css +346 -0
- data/public/css/bootstrap-theme.min.css +7 -0
- data/public/css/bootstrap.css +5780 -0
- data/public/css/bootstrap.min.css +7 -0
- data/public/fonts/glyphicons-halflings-regular.eot +0 -0
- data/public/fonts/glyphicons-halflings-regular.svg +229 -0
- data/public/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/public/fonts/glyphicons-halflings-regular.woff +0 -0
- data/public/javascripts/jquery-2.1.1.min.js +4 -0
- data/public/javascripts/jquery.tablesorter.js +1765 -0
- data/public/javascripts/jquery.tablesorter.min.js +5 -0
- data/public/js/bootstrap.js +1943 -0
- data/public/js/bootstrap.min.js +7 -0
- data/public/stylesheets/github.css +387 -0
- data/public/stylesheets/relationships.css +18 -0
- data/script/update-hal-browser +6 -0
- data/spec/fixtures/renderer_pact.json +34 -0
- data/spec/lib/pact_broker/api/decorators/relationships_csv_decorator_spec.rb +30 -0
- data/spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb +29 -0
- data/spec/lib/pact_broker/api/resources/latest_pact_spec.rb +57 -0
- data/spec/lib/pact_broker/configuration_spec.rb +21 -0
- data/spec/lib/pact_broker/services/pacticipant_service_spec.rb +30 -0
- data/spec/lib/pact_broker/ui/controllers/clusters_spec.rb +27 -0
- data/spec/lib/pact_broker/ui/controllers/relationships_spec.rb +37 -0
- data/spec/lib/pact_broker/ui/view_models/relationship_spec.rb +29 -0
- data/spec/lib/rack/hal_browser/redirect_spec.rb +63 -0
- data/spec/service_consumers/pact_helper.rb +1 -1
- data/spec/spec_helper.rb +10 -3
- data/tasks/database.rb +57 -0
- data/tasks/db.rake +57 -12
- data/tasks/pact.rake +1 -1
- data/tasks/rspec.rake +1 -9
- data/vendor/hal-browser/.gitignore +1 -0
- data/vendor/hal-browser/MIT-LICENSE.txt +20 -0
- data/vendor/hal-browser/README.md +35 -0
- data/vendor/hal-browser/browser.html +246 -0
- data/vendor/hal-browser/js/hal.js +57 -0
- data/vendor/hal-browser/js/hal/browser.js +60 -0
- data/vendor/hal-browser/js/hal/http/client.js +38 -0
- data/vendor/hal-browser/js/hal/resource.js +34 -0
- data/vendor/hal-browser/js/hal/views/browser.js +29 -0
- data/vendor/hal-browser/js/hal/views/documentation.js +7 -0
- data/vendor/hal-browser/js/hal/views/embedded_resource.js +56 -0
- data/vendor/hal-browser/js/hal/views/embedded_resources.js +41 -0
- data/vendor/hal-browser/js/hal/views/explorer.js +23 -0
- data/vendor/hal-browser/js/hal/views/inspector.js +39 -0
- data/vendor/hal-browser/js/hal/views/links.js +54 -0
- data/vendor/hal-browser/js/hal/views/location_bar.js +40 -0
- data/vendor/hal-browser/js/hal/views/navigation.js +19 -0
- data/vendor/hal-browser/js/hal/views/non_safe_request_dialog.js +53 -0
- data/vendor/hal-browser/js/hal/views/properties.js +14 -0
- data/vendor/hal-browser/js/hal/views/query_uri_dialog.js +69 -0
- data/vendor/hal-browser/js/hal/views/request_headers.js +30 -0
- data/vendor/hal-browser/js/hal/views/resource.js +38 -0
- data/vendor/hal-browser/js/hal/views/response.js +24 -0
- data/vendor/hal-browser/js/hal/views/response_body.js +40 -0
- data/vendor/hal-browser/js/hal/views/response_headers.js +19 -0
- data/vendor/hal-browser/styles.css +67 -0
- data/vendor/hal-browser/vendor/css/bootstrap-responsive.css +1109 -0
- data/vendor/hal-browser/vendor/css/bootstrap.css +6158 -0
- data/vendor/hal-browser/vendor/img/ajax-loader.gif +0 -0
- data/vendor/hal-browser/vendor/img/glyphicons-halflings-white.png +0 -0
- data/vendor/hal-browser/vendor/img/glyphicons-halflings.png +0 -0
- data/vendor/hal-browser/vendor/js/backbone.js +1487 -0
- data/vendor/hal-browser/vendor/js/bootstrap.js +2276 -0
- data/vendor/hal-browser/vendor/js/jquery-1.9.1.js +9597 -0
- data/vendor/hal-browser/vendor/js/underscore.js +1227 -0
- data/vendor/hal-browser/vendor/js/uritemplates.js +438 -0
- metadata +162 -47
- data/Gemfile.lock +0 -110
@@ -0,0 +1,38 @@
|
|
1
|
+
HAL.Http.Client = function(opts) {
|
2
|
+
this.vent = opts.vent;
|
3
|
+
$.ajaxSetup({ headers: { 'Accept': 'application/hal+json, application/json, */*; q=0.01' } });
|
4
|
+
};
|
5
|
+
|
6
|
+
HAL.Http.Client.prototype.get = function(url) {
|
7
|
+
var self = this;
|
8
|
+
this.vent.trigger('location-change', { url: url });
|
9
|
+
var jqxhr = $.ajax({
|
10
|
+
url: url,
|
11
|
+
dataType: 'json',
|
12
|
+
success: function(resource, textStatus, jqXHR) {
|
13
|
+
self.vent.trigger('response', {
|
14
|
+
resource: resource,
|
15
|
+
jqxhr: jqXHR,
|
16
|
+
headers: jqXHR.getAllResponseHeaders()
|
17
|
+
});
|
18
|
+
}
|
19
|
+
}).error(function() {
|
20
|
+
self.vent.trigger('fail-response', { jqxhr: jqxhr });
|
21
|
+
});
|
22
|
+
};
|
23
|
+
|
24
|
+
HAL.Http.Client.prototype.request = function(opts) {
|
25
|
+
var self = this;
|
26
|
+
opts.dataType = 'json';
|
27
|
+
self.vent.trigger('location-change', { url: opts.url });
|
28
|
+
return jqxhr = $.ajax(opts);
|
29
|
+
};
|
30
|
+
|
31
|
+
HAL.Http.Client.prototype.updateDefaultHeaders = function(headers) {
|
32
|
+
this.defaultHeaders = headers;
|
33
|
+
$.ajaxSetup({ headers: headers });
|
34
|
+
};
|
35
|
+
|
36
|
+
HAL.Http.Client.prototype.getDefaultHeaders = function() {
|
37
|
+
return this.defaultHeaders;
|
38
|
+
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
HAL.Models.Resource = Backbone.Model.extend({
|
2
|
+
initialize: function(representation) {
|
3
|
+
representation = representation || {};
|
4
|
+
this.links = representation._links;
|
5
|
+
if(representation._embedded !== undefined) {
|
6
|
+
this.embeddedResources = this.buildEmbeddedResources(representation._embedded);
|
7
|
+
}
|
8
|
+
this.set(representation);
|
9
|
+
this.unset('_embedded', { silent: true });
|
10
|
+
this.unset('_links', { silent: true });
|
11
|
+
},
|
12
|
+
|
13
|
+
buildEmbeddedResources: function(embeddedResources) {
|
14
|
+
var result = {};
|
15
|
+
_.each(embeddedResources, function(obj, rel) {
|
16
|
+
if($.isArray(obj)) {
|
17
|
+
var arr = [];
|
18
|
+
_.each(obj, function(resource, i) {
|
19
|
+
var newResource = new HAL.Models.Resource(resource);
|
20
|
+
newResource.identifier = rel + '[' + i + ']';
|
21
|
+
newResource.embed_rel = rel;
|
22
|
+
arr.push(newResource);
|
23
|
+
});
|
24
|
+
result[rel] = arr;
|
25
|
+
} else {
|
26
|
+
var newResource = new HAL.Models.Resource(obj);
|
27
|
+
newResource.identifier = rel;
|
28
|
+
newResource.embed_rel = rel;
|
29
|
+
result[rel] = newResource;
|
30
|
+
}
|
31
|
+
});
|
32
|
+
return result;
|
33
|
+
}
|
34
|
+
});
|
@@ -0,0 +1,29 @@
|
|
1
|
+
HAL.Views.Browser = Backbone.View.extend({
|
2
|
+
initialize: function(opts) {
|
3
|
+
var self = this;
|
4
|
+
this.vent = opts.vent;
|
5
|
+
this.entryPoint = opts.entryPoint;
|
6
|
+
this.explorerView = new HAL.Views.Explorer({ vent: this.vent });
|
7
|
+
this.inspectorView = new HAL.Views.Inspector({ vent: this.vent });
|
8
|
+
},
|
9
|
+
|
10
|
+
className: 'hal-browser row-fluid',
|
11
|
+
|
12
|
+
render: function() {
|
13
|
+
this.$el.empty();
|
14
|
+
|
15
|
+
this.inspectorView.render();
|
16
|
+
this.explorerView.render();
|
17
|
+
|
18
|
+
this.$el.html(this.explorerView.el);
|
19
|
+
this.$el.append(this.inspectorView.el);
|
20
|
+
|
21
|
+
var entryPoint = this.entryPoint;
|
22
|
+
|
23
|
+
$("#entryPointLink").click(function(event) {
|
24
|
+
event.preventDefault();
|
25
|
+
window.location.hash = entryPoint;
|
26
|
+
});
|
27
|
+
return this;
|
28
|
+
}
|
29
|
+
});
|
@@ -0,0 +1,56 @@
|
|
1
|
+
HAL.Views.EmbeddedResource = Backbone.View.extend({
|
2
|
+
initialize: function(opts) {
|
3
|
+
this.vent = opts.vent;
|
4
|
+
this.resource = opts.resource;
|
5
|
+
|
6
|
+
this.propertiesView = new HAL.Views.Properties({});
|
7
|
+
this.linksView = new HAL.Views.Links({
|
8
|
+
vent: this.vent
|
9
|
+
});
|
10
|
+
|
11
|
+
_.bindAll(this, 'onToggleClick');
|
12
|
+
_.bindAll(this, 'onDoxClick');
|
13
|
+
},
|
14
|
+
|
15
|
+
events: {
|
16
|
+
'click a.accordion-toggle': 'onToggleClick',
|
17
|
+
'click span.dox': 'onDoxClick'
|
18
|
+
},
|
19
|
+
|
20
|
+
className: 'embedded-resource accordion-group',
|
21
|
+
|
22
|
+
onToggleClick: function(e) {
|
23
|
+
e.preventDefault();
|
24
|
+
this.$accordionBody.collapse('toggle');
|
25
|
+
},
|
26
|
+
|
27
|
+
onDoxClick: function(e) {
|
28
|
+
e.preventDefault();
|
29
|
+
this.vent.trigger('show-docs', {
|
30
|
+
url: $(e.currentTarget).data('href')
|
31
|
+
});
|
32
|
+
return false;
|
33
|
+
},
|
34
|
+
|
35
|
+
render: function() {
|
36
|
+
this.$el.empty();
|
37
|
+
|
38
|
+
this.propertiesView.render(this.resource.toJSON());
|
39
|
+
this.linksView.render(this.resource.links);
|
40
|
+
|
41
|
+
this.$el.append(this.template({
|
42
|
+
resource: this.resource
|
43
|
+
}));
|
44
|
+
|
45
|
+
var $inner = $('<div class="accordion-inner"></div>');
|
46
|
+
$inner.append(this.propertiesView.el);
|
47
|
+
$inner.append(this.linksView.el);
|
48
|
+
|
49
|
+
this.$accordionBody = $('<div class="accordion-body collapse"></div>');
|
50
|
+
this.$accordionBody.append($inner)
|
51
|
+
|
52
|
+
this.$el.append(this.$accordionBody);
|
53
|
+
},
|
54
|
+
|
55
|
+
template: _.template($('#embedded-resource-template').html())
|
56
|
+
});
|
@@ -0,0 +1,41 @@
|
|
1
|
+
HAL.Views.EmbeddedResources = Backbone.View.extend({
|
2
|
+
initialize: function(opts) {
|
3
|
+
this.vent = opts.vent;
|
4
|
+
_.bindAll(this, 'render');
|
5
|
+
},
|
6
|
+
|
7
|
+
className: 'embedded-resources accordion',
|
8
|
+
|
9
|
+
render: function(resources) {
|
10
|
+
var self = this,
|
11
|
+
resourceViews = [],
|
12
|
+
buildView = function(resource) {
|
13
|
+
return new HAL.Views.EmbeddedResource({
|
14
|
+
resource: resource,
|
15
|
+
vent: self.vent
|
16
|
+
});
|
17
|
+
};
|
18
|
+
|
19
|
+
_.each(resources, function(prop) {
|
20
|
+
if ($.isArray(prop)) {
|
21
|
+
_.each(prop, function(resource) {
|
22
|
+
resourceViews.push(buildView(resource));
|
23
|
+
});
|
24
|
+
} else {
|
25
|
+
resourceViews.push(buildView(prop));
|
26
|
+
}
|
27
|
+
});
|
28
|
+
|
29
|
+
this.$el.html(this.template());
|
30
|
+
|
31
|
+
_.each(resourceViews, function(view) {
|
32
|
+
view.render();
|
33
|
+
self.$el.append(view.el);
|
34
|
+
});
|
35
|
+
|
36
|
+
|
37
|
+
return this;
|
38
|
+
},
|
39
|
+
|
40
|
+
template: _.template($('#embedded-resources-template').html())
|
41
|
+
});
|
@@ -0,0 +1,23 @@
|
|
1
|
+
HAL.Views.Explorer = Backbone.View.extend({
|
2
|
+
initialize: function(opts) {
|
3
|
+
var self = this;
|
4
|
+
this.vent = opts.vent;
|
5
|
+
this.navigationView = new HAL.Views.Navigation({ vent: this.vent });
|
6
|
+
this.resourceView = new HAL.Views.Resource({ vent: this.vent });
|
7
|
+
},
|
8
|
+
|
9
|
+
className: 'explorer span6',
|
10
|
+
|
11
|
+
render: function() {
|
12
|
+
this.navigationView.render();
|
13
|
+
|
14
|
+
this.$el.html(this.template());
|
15
|
+
|
16
|
+
this.$el.append(this.navigationView.el);
|
17
|
+
this.$el.append(this.resourceView.el);
|
18
|
+
},
|
19
|
+
|
20
|
+
template: function() {
|
21
|
+
return '<h1>Explorer</h1>';
|
22
|
+
}
|
23
|
+
});
|
@@ -0,0 +1,39 @@
|
|
1
|
+
HAL.Views.Inspector = Backbone.View.extend({
|
2
|
+
initialize: function(opts) {
|
3
|
+
this.vent = opts.vent;
|
4
|
+
|
5
|
+
_.bindAll(this, 'renderDocumentation');
|
6
|
+
_.bindAll(this, 'renderResponse');
|
7
|
+
|
8
|
+
this.vent.bind('show-docs', this.renderDocumentation);
|
9
|
+
this.vent.bind('response', this.renderResponse);
|
10
|
+
},
|
11
|
+
|
12
|
+
className: 'inspector span6',
|
13
|
+
|
14
|
+
render: function() {
|
15
|
+
this.$el.html(this.template());
|
16
|
+
},
|
17
|
+
|
18
|
+
renderResponse: function(response) {
|
19
|
+
var responseView = new HAL.Views.Response({ vent: this.vent });
|
20
|
+
|
21
|
+
this.render();
|
22
|
+
responseView.render(response);
|
23
|
+
|
24
|
+
this.$el.append(responseView.el);
|
25
|
+
},
|
26
|
+
|
27
|
+
renderDocumentation: function(e) {
|
28
|
+
var docView = new HAL.Views.Documenation({ vent: this.vent });
|
29
|
+
|
30
|
+
this.render();
|
31
|
+
docView.render(e.url);
|
32
|
+
|
33
|
+
this.$el.append(docView.el);
|
34
|
+
},
|
35
|
+
|
36
|
+
template: function() {
|
37
|
+
return '<h1>Inspector</h1>';
|
38
|
+
}
|
39
|
+
});
|
@@ -0,0 +1,54 @@
|
|
1
|
+
HAL.Views.Links = Backbone.View.extend({
|
2
|
+
initialize: function(opts) {
|
3
|
+
this.vent = opts.vent;
|
4
|
+
},
|
5
|
+
|
6
|
+
events: {
|
7
|
+
'click .follow': 'followLink',
|
8
|
+
'click .non-get': 'showNonSafeRequestDialog',
|
9
|
+
'click .query': 'showUriQueryDialog',
|
10
|
+
'click .dox': 'showDocs'
|
11
|
+
},
|
12
|
+
|
13
|
+
className: 'links',
|
14
|
+
|
15
|
+
followLink: function(e) {
|
16
|
+
e.preventDefault();
|
17
|
+
var $target = $(e.currentTarget);
|
18
|
+
var uri = $target.attr('href');
|
19
|
+
window.location.hash = uri;
|
20
|
+
},
|
21
|
+
|
22
|
+
showUriQueryDialog: function(e) {
|
23
|
+
e.preventDefault();
|
24
|
+
|
25
|
+
var $target = $(e.currentTarget);
|
26
|
+
var uri = $target.attr('href');
|
27
|
+
|
28
|
+
new HAL.Views.QueryUriDialog({
|
29
|
+
href: uri
|
30
|
+
}).render({});
|
31
|
+
},
|
32
|
+
|
33
|
+
showNonSafeRequestDialog: function(e) {
|
34
|
+
e.preventDefault();
|
35
|
+
|
36
|
+
var d = new HAL.Views.NonSafeRequestDialog({
|
37
|
+
href: $(e.currentTarget).attr('href'),
|
38
|
+
vent: this.vent
|
39
|
+
}).render({});
|
40
|
+
},
|
41
|
+
|
42
|
+
showDocs: function(e) {
|
43
|
+
e.preventDefault();
|
44
|
+
var $target = $(e.target);
|
45
|
+
var uri = $target.attr('href') || $target.parent().attr('href');
|
46
|
+
this.vent.trigger('show-docs', { url: uri });
|
47
|
+
},
|
48
|
+
|
49
|
+
template: _.template($('#links-template').html()),
|
50
|
+
|
51
|
+
render: function(links) {
|
52
|
+
this.$el.html(this.template({ links: links }));
|
53
|
+
}
|
54
|
+
});
|
@@ -0,0 +1,40 @@
|
|
1
|
+
HAL.Views.LocationBar = Backbone.View.extend({
|
2
|
+
initialize: function(opts) {
|
3
|
+
this.vent = opts.vent;
|
4
|
+
_.bindAll(this, 'render');
|
5
|
+
_.bindAll(this, 'onButtonClick');
|
6
|
+
this.vent.bind('location-change', this.render);
|
7
|
+
this.vent.bind('location-change', _.bind(this.showSpinner, this));
|
8
|
+
this.vent.bind('response', _.bind(this.hideSpinner, this));
|
9
|
+
},
|
10
|
+
|
11
|
+
events: {
|
12
|
+
'submit form': 'onButtonClick'
|
13
|
+
},
|
14
|
+
|
15
|
+
className: 'address',
|
16
|
+
|
17
|
+
render: function(e) {
|
18
|
+
e = e || { url: '' };
|
19
|
+
this.$el.html(this.template(e));
|
20
|
+
},
|
21
|
+
|
22
|
+
onButtonClick: function(e) {
|
23
|
+
e.preventDefault();
|
24
|
+
this.vent.trigger('location-go', this.getLocation());
|
25
|
+
},
|
26
|
+
|
27
|
+
getLocation: function() {
|
28
|
+
return this.$el.find('input').val();
|
29
|
+
},
|
30
|
+
|
31
|
+
showSpinner: function() {
|
32
|
+
this.$el.find('.ajax-loader').addClass('visible');
|
33
|
+
},
|
34
|
+
|
35
|
+
hideSpinner: function() {
|
36
|
+
this.$el.find('.ajax-loader').removeClass('visible');
|
37
|
+
},
|
38
|
+
|
39
|
+
template: _.template($('#location-bar-template').html())
|
40
|
+
});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
HAL.Views.Navigation = Backbone.View.extend({
|
2
|
+
initialize: function(opts) {
|
3
|
+
this.vent = opts.vent;
|
4
|
+
this.locationBar = new HAL.Views.LocationBar({ vent: this.vent });
|
5
|
+
this.requestHeadersView = new HAL.Views.RequestHeaders({ vent: this.vent });
|
6
|
+
},
|
7
|
+
|
8
|
+
className: 'navigation',
|
9
|
+
|
10
|
+
render: function() {
|
11
|
+
this.$el.empty();
|
12
|
+
|
13
|
+
this.locationBar.render();
|
14
|
+
this.requestHeadersView.render();
|
15
|
+
|
16
|
+
this.$el.append(this.locationBar.el);
|
17
|
+
this.$el.append(this.requestHeadersView.el);
|
18
|
+
}
|
19
|
+
});
|
@@ -0,0 +1,53 @@
|
|
1
|
+
HAL.Views.NonSafeRequestDialog = Backbone.View.extend({
|
2
|
+
initialize: function(opts) {
|
3
|
+
this.href = opts.href;
|
4
|
+
this.vent = opts.vent;
|
5
|
+
this.uriTemplate = uritemplate(this.href);
|
6
|
+
_.bindAll(this, 'submitQuery');
|
7
|
+
},
|
8
|
+
|
9
|
+
events: {
|
10
|
+
'submit form': 'submitQuery'
|
11
|
+
},
|
12
|
+
|
13
|
+
className: 'modal fade',
|
14
|
+
|
15
|
+
submitQuery: function(e) {
|
16
|
+
e.preventDefault();
|
17
|
+
|
18
|
+
var self = this,
|
19
|
+
opts = {
|
20
|
+
url: this.$('.url').val(),
|
21
|
+
headers: HAL.parseHeaders(this.$('.headers').val()),
|
22
|
+
method: this.$('.method').val(),
|
23
|
+
data: this.$('.body').val()
|
24
|
+
};
|
25
|
+
|
26
|
+
var request = HAL.client.request(opts);
|
27
|
+
request.done(function(response) {
|
28
|
+
self.vent.trigger('response', { resource: response, jqxhr: jqxhr });
|
29
|
+
}).fail(function(response) {
|
30
|
+
self.vent.trigger('fail-response', { jqxhr: jqxhr });
|
31
|
+
}).always(function() {
|
32
|
+
self.vent.trigger('response-headers', { jqxhr: jqxhr });
|
33
|
+
window.location.hash = 'NON-GET:' + opts.url;
|
34
|
+
});
|
35
|
+
|
36
|
+
this.$el.modal('hide');
|
37
|
+
},
|
38
|
+
|
39
|
+
render: function(opts) {
|
40
|
+
var headers = HAL.client.getDefaultHeaders(),
|
41
|
+
headersString = '';
|
42
|
+
|
43
|
+
_.each(headers, function(value, name) {
|
44
|
+
headersString += name + ': ' + value + '\n';
|
45
|
+
});
|
46
|
+
|
47
|
+
this.$el.html(this.template({ href: this.href, user_defined_headers: headersString }));
|
48
|
+
this.$el.modal();
|
49
|
+
return this;
|
50
|
+
},
|
51
|
+
|
52
|
+
template: _.template($('#non-safe-request-template').html())
|
53
|
+
});
|