pact_broker 2.52.1 → 2.56.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +80 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/README.md +2 -4
- data/db/migrations/20180828_create_latest_versions.rb +1 -1
- data/lib/pact_broker/api.rb +8 -0
- data/lib/pact_broker/api/contracts/webhook_contract.rb +8 -6
- data/lib/pact_broker/api/decorators/decorator_context.rb +6 -11
- data/lib/pact_broker/api/decorators/reason_decorator.rb +17 -0
- data/lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb +6 -1
- data/lib/pact_broker/api/pact_broker_urls.rb +6 -2
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +14 -14
- data/lib/pact_broker/api/resources/badge.rb +6 -2
- data/lib/pact_broker/api/resources/base_resource.rb +3 -3
- data/lib/pact_broker/api/resources/matrix_badge.rb +5 -0
- data/lib/pact_broker/api/resources/pact.rb +1 -17
- data/lib/pact_broker/api/resources/pacticipant.rb +0 -4
- data/lib/pact_broker/api/resources/pacticipants.rb +3 -2
- data/lib/pact_broker/api/resources/verifications.rb +0 -4
- data/lib/pact_broker/app.rb +13 -4
- data/lib/pact_broker/badges/service.rb +16 -13
- data/lib/pact_broker/db.rb +9 -1
- data/lib/pact_broker/doc/controllers/app.rb +11 -1
- data/lib/pact_broker/doc/views/layouts/main.haml +1 -1
- data/lib/pact_broker/domain/verification.rb +13 -0
- data/lib/pact_broker/hash_refinements.rb +4 -0
- data/lib/pact_broker/integrations/service.rb +2 -2
- data/lib/pact_broker/locale/en.yml +1 -1
- data/lib/pact_broker/logging.rb +3 -1
- data/lib/pact_broker/matrix/deployment_status_summary.rb +23 -1
- data/lib/pact_broker/matrix/reason.rb +9 -0
- data/lib/pact_broker/matrix/unresolved_selector.rb +4 -0
- data/lib/pact_broker/pacticipants/repository.rb +6 -0
- data/lib/pact_broker/pacticipants/service.rb +8 -0
- data/lib/pact_broker/pacts/content.rb +26 -2
- data/lib/pact_broker/pacts/repository.rb +5 -4
- data/lib/pact_broker/tasks/migration_task.rb +20 -1
- data/lib/pact_broker/test/test_data_builder.rb +8 -3
- data/lib/pact_broker/ui/app.rb +1 -0
- data/lib/pact_broker/ui/controllers/base_controller.rb +3 -0
- data/lib/pact_broker/ui/controllers/clusters.rb +2 -2
- data/lib/pact_broker/ui/controllers/groups.rb +3 -2
- data/lib/pact_broker/ui/controllers/index.rb +3 -2
- data/lib/pact_broker/ui/controllers/matrix.rb +19 -3
- data/lib/pact_broker/ui/helpers/url_helper.rb +4 -4
- data/lib/pact_broker/ui/view_models/index_item.rb +16 -11
- data/lib/pact_broker/ui/view_models/index_items.rb +2 -2
- data/lib/pact_broker/ui/view_models/matrix_line.rb +12 -7
- data/lib/pact_broker/ui/view_models/matrix_lines.rb +2 -2
- data/lib/pact_broker/ui/views/groups/show.html.erb +3 -3
- data/lib/pact_broker/ui/views/index/_css_and_js.haml +9 -9
- data/lib/pact_broker/ui/views/index/_navbar.haml +3 -3
- data/lib/pact_broker/ui/views/index/_pagination.haml +1 -1
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +3 -3
- data/lib/pact_broker/ui/views/index/show.haml +3 -3
- data/lib/pact_broker/ui/views/layouts/main.haml +4 -4
- data/lib/pact_broker/ui/views/matrix/show.haml +14 -11
- data/lib/pact_broker/verifications/repository.rb +4 -5
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/webhooks/service.rb +4 -3
- data/lib/pact_broker/webhooks/webhook_event.rb +1 -1
- data/lib/pact_broker/webhooks/webhook_request_logger.rb +8 -8
- data/pact_broker.gemspec +2 -2
- data/public/javascripts/pact.js +7 -6
- data/public/stylesheets/matrix.css +13 -0
- data/script/foo-bar-verification.json +3 -1
- data/script/foo-bar.json +11 -0
- data/script/seed.rb +1 -1
- data/spec/features/create_webhook_spec.rb +1 -1
- data/spec/features/delete_integration_spec.rb +2 -2
- data/spec/features/get_matrix_badge_spec.rb +9 -0
- data/spec/fixtures/webhook_valid.json +1 -1
- data/spec/fixtures/webhook_valid_with_pacticipants.json +1 -1
- data/spec/integration/ui/index_spec.rb +16 -0
- data/spec/integration/ui/matrix_spec.rb +11 -4
- data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +12 -0
- data/spec/lib/pact_broker/api/decorators/pact_version_decorator_spec.rb +1 -1
- data/spec/lib/pact_broker/api/decorators/reason_decorator_spec.rb +18 -1
- data/spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb +1 -1
- data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +8 -0
- data/spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/badge_spec.rb +42 -22
- data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +1 -1
- data/spec/lib/pact_broker/badges/service_spec.rb +15 -3
- data/spec/lib/pact_broker/doc/controllers/app_spec.rb +16 -0
- data/spec/lib/pact_broker/domain/version_spec.rb +7 -7
- data/spec/lib/pact_broker/integrations/service_spec.rb +6 -0
- data/spec/lib/pact_broker/matrix/deployment_status_summary_spec.rb +6 -2
- data/spec/lib/pact_broker/matrix/integration_spec.rb +43 -0
- data/spec/lib/pact_broker/pacts/content_spec.rb +125 -0
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +18 -1
- data/spec/lib/pact_broker/verifications/repository_spec.rb +20 -0
- data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +4 -1
- data/spec/migrations/rollback_spec.rb +6 -0
- data/spec/service_consumers/provider_states_for_pact_broker_client.rb +11 -0
- data/vendor/hal-browser/README.adoc +169 -0
- data/vendor/hal-browser/browser.html +36 -22
- data/vendor/hal-browser/js/hal.js +30 -7
- data/vendor/hal-browser/js/hal/http/client.js +14 -6
- data/vendor/hal-browser/js/hal/resource.js +4 -2
- data/vendor/hal-browser/js/hal/views/documentation.js +1 -1
- data/vendor/hal-browser/js/hal/views/embedded_resource.js +10 -4
- data/vendor/hal-browser/js/hal/views/links.js +3 -2
- data/vendor/hal-browser/js/hal/views/non_safe_request_dialog.js +1 -1
- data/vendor/hal-browser/js/hal/views/properties.js +101 -2
- data/vendor/hal-browser/js/hal/views/query_uri_dialog.js +1 -1
- data/vendor/hal-browser/js/hal/views/request_headers.js +1 -1
- data/vendor/hal-browser/js/hal/views/resource.js +4 -3
- data/vendor/hal-browser/js/hal/views/response_headers.js +12 -1
- data/vendor/hal-browser/login.html +76 -0
- data/vendor/hal-browser/styles.css +3 -1
- data/vendor/hal-browser/vendor/js/URI.min.js +84 -0
- metadata +31 -28
- data/lib/pact_broker/verifications/all_verifications.rb +0 -41
- data/vendor/hal-browser/README.md +0 -41
@@ -1,10 +1,6 @@
|
|
1
1
|
(function() {
|
2
2
|
var urlRegex = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
|
3
3
|
|
4
|
-
function isCurie(string) {
|
5
|
-
return string.split(':').length > 1;
|
6
|
-
};
|
7
|
-
|
8
4
|
var HAL = {
|
9
5
|
Models: {},
|
10
6
|
Views: {},
|
@@ -12,17 +8,43 @@
|
|
12
8
|
currentDocument: {},
|
13
9
|
jsonIndent: 2,
|
14
10
|
isUrl: function(str) {
|
15
|
-
return str.match(urlRegex) || isCurie(str);
|
11
|
+
return str.match(urlRegex) || HAL.isCurie(str);
|
12
|
+
},
|
13
|
+
isCurie: function(string) {
|
14
|
+
var isCurie = false;
|
15
|
+
var curieParts = string.split(':');
|
16
|
+
var curies = HAL.currentDocument._links.curies;
|
17
|
+
|
18
|
+
if(curieParts.length > 1 && curies) {
|
19
|
+
|
20
|
+
for (var i=0; i<curies.length; i++) {
|
21
|
+
if (curies[i].name == curieParts[0]) {
|
22
|
+
isCurie = true;
|
23
|
+
break;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
return isCurie;
|
28
|
+
},
|
29
|
+
isFollowableHeader: function(headerName) {
|
30
|
+
return headerName === 'Location' || headerName === 'Content-Location';
|
16
31
|
},
|
17
32
|
truncateIfUrl: function(str) {
|
18
33
|
var replaceRegex = /(http|https):\/\/([^\/]*)\//;
|
19
34
|
return str.replace(replaceRegex, '.../');
|
20
35
|
},
|
36
|
+
normalizeUrl: function(rel) {
|
37
|
+
var cur = location.hash.slice(1);
|
38
|
+
var uri = new URI(rel)
|
39
|
+
var norm = uri.absoluteTo(cur);
|
40
|
+
|
41
|
+
return norm
|
42
|
+
},
|
21
43
|
buildUrl: function(rel) {
|
22
44
|
if (!HAL.currentDocument._links) {
|
23
45
|
return rel;
|
24
46
|
}
|
25
|
-
if (!rel.match(urlRegex) && isCurie(rel) && HAL.currentDocument._links.curies) {
|
47
|
+
if (!rel.match(urlRegex) && HAL.isCurie(rel) && HAL.currentDocument._links.curies) {
|
26
48
|
var parts = rel.split(':');
|
27
49
|
var curies = HAL.currentDocument._links.curies;
|
28
50
|
for (var i=0; i<curies.length; i++) {
|
@@ -32,7 +54,7 @@
|
|
32
54
|
}
|
33
55
|
}
|
34
56
|
}
|
35
|
-
else if (!rel.match(urlRegex) && isCurie(rel) && HAL.currentDocument._links.curie) {
|
57
|
+
else if (!rel.match(urlRegex) && HAL.isCurie(rel) && HAL.currentDocument._links.curie) {
|
36
58
|
// Backward compatibility with <04 version of spec.
|
37
59
|
var tmpl = uritemplate(HAL.currentDocument._links.curie.href);
|
38
60
|
return tmpl.expand({ rel: rel.split(':')[1] });
|
@@ -54,6 +76,7 @@
|
|
54
76
|
});
|
55
77
|
return headers;
|
56
78
|
},
|
79
|
+
customPostForm: undefined
|
57
80
|
};
|
58
81
|
|
59
82
|
window.HAL = HAL;
|
@@ -1,6 +1,9 @@
|
|
1
1
|
HAL.Http.Client = function(opts) {
|
2
2
|
this.vent = opts.vent;
|
3
|
-
|
3
|
+
this.defaultHeaders = { 'Accept': 'application/hal+json, application/json, */*; q=0.01', 'X-Interface': 'HAL Browser' }; //pact_broker
|
4
|
+
cookie = document.cookie.match('(^|;)\\s*' + 'MyHalBrowserToken' + '\\s*=\\s*([^;]+)');
|
5
|
+
cookie ? this.defaultHeaders.Authorization = 'Bearer ' + cookie.pop() : '';
|
6
|
+
this.headers = this.defaultHeaders;
|
4
7
|
};
|
5
8
|
|
6
9
|
HAL.Http.Client.prototype.get = function(url) {
|
@@ -9,6 +12,10 @@ HAL.Http.Client.prototype.get = function(url) {
|
|
9
12
|
var jqxhr = $.ajax({
|
10
13
|
url: url,
|
11
14
|
dataType: 'json',
|
15
|
+
xhrFields: {
|
16
|
+
withCredentials: false
|
17
|
+
},
|
18
|
+
headers: this.headers,
|
12
19
|
success: function(resource, textStatus, jqXHR) {
|
13
20
|
self.vent.trigger('response', {
|
14
21
|
resource: resource,
|
@@ -24,15 +31,16 @@ HAL.Http.Client.prototype.get = function(url) {
|
|
24
31
|
HAL.Http.Client.prototype.request = function(opts) {
|
25
32
|
var self = this;
|
26
33
|
opts.dataType = 'json';
|
34
|
+
opts.xhrFields = opts.xhrFields || {};
|
35
|
+
opts.xhrFields.withCredentials = opts.xhrFields.withCredentials || false;
|
27
36
|
self.vent.trigger('location-change', { url: opts.url });
|
28
37
|
return jqxhr = $.ajax(opts);
|
29
38
|
};
|
30
39
|
|
31
|
-
HAL.Http.Client.prototype.
|
32
|
-
this.
|
33
|
-
$.ajaxSetup({ headers: headers });
|
40
|
+
HAL.Http.Client.prototype.updateHeaders = function(headers) {
|
41
|
+
this.headers = headers;
|
34
42
|
};
|
35
43
|
|
36
|
-
HAL.Http.Client.prototype.
|
37
|
-
return this.
|
44
|
+
HAL.Http.Client.prototype.getHeaders = function() {
|
45
|
+
return this.headers;
|
38
46
|
};
|
@@ -2,8 +2,8 @@ HAL.Models.Resource = Backbone.Model.extend({
|
|
2
2
|
initialize: function(representation) {
|
3
3
|
representation = representation || {};
|
4
4
|
this.links = representation._links;
|
5
|
-
this.title = this.buildTitle(representation);
|
6
|
-
this.name = this.buildName(representation);
|
5
|
+
this.title = this.buildTitle(representation); // pact_broker
|
6
|
+
this.name = this.buildName(representation); // pact_broker
|
7
7
|
if(representation._embedded !== undefined) {
|
8
8
|
this.embeddedResources = this.buildEmbeddedResources(representation._embedded);
|
9
9
|
}
|
@@ -12,6 +12,7 @@ HAL.Models.Resource = Backbone.Model.extend({
|
|
12
12
|
this.unset('_links', { silent: true });
|
13
13
|
},
|
14
14
|
|
15
|
+
// pact_broker
|
15
16
|
buildName: function(representation) {
|
16
17
|
return representation.name ||
|
17
18
|
(representation._links
|
@@ -19,6 +20,7 @@ HAL.Models.Resource = Backbone.Model.extend({
|
|
19
20
|
&& representation._links.self.name);
|
20
21
|
},
|
21
22
|
|
23
|
+
// pact_broker
|
22
24
|
buildTitle: function(representation) {
|
23
25
|
return representation.title ||
|
24
26
|
(representation._links
|
@@ -22,9 +22,9 @@ HAL.Views.EmbeddedResource = Backbone.View.extend({
|
|
22
22
|
onToggleClick: function(e) {
|
23
23
|
e.preventDefault();
|
24
24
|
this.$accordionBody.collapse('toggle');
|
25
|
+
return false;
|
25
26
|
},
|
26
|
-
|
27
|
-
|
27
|
+
|
28
28
|
onDoxClick: function(e) {
|
29
29
|
e.preventDefault();
|
30
30
|
this.vent.trigger('show-docs', {
|
@@ -36,16 +36,22 @@ HAL.Views.EmbeddedResource = Backbone.View.extend({
|
|
36
36
|
render: function() {
|
37
37
|
this.$el.empty();
|
38
38
|
|
39
|
-
this.linksView.render(this.resource.links);
|
40
39
|
this.propertiesView.render(this.resource.toJSON());
|
40
|
+
this.linksView.render(this.resource.links);
|
41
41
|
|
42
42
|
this.$el.append(this.template({
|
43
43
|
resource: this.resource
|
44
44
|
}));
|
45
45
|
|
46
46
|
var $inner = $('<div class="accordion-inner"></div>');
|
47
|
-
$inner.append(this.linksView.el);
|
48
47
|
$inner.append(this.propertiesView.el);
|
48
|
+
$inner.append(this.linksView.el);
|
49
|
+
|
50
|
+
if (this.resource.embeddedResources) {
|
51
|
+
var embeddedResourcesView = new HAL.Views.EmbeddedResources({ vent: this.vent });
|
52
|
+
embeddedResourcesView.render(this.resource.embeddedResources);
|
53
|
+
$inner.append(embeddedResourcesView.el);
|
54
|
+
}
|
49
55
|
|
50
56
|
this.$accordionBody = $('<div class="accordion-body collapse"></div>');
|
51
57
|
this.$accordionBody.append($inner)
|
@@ -33,10 +33,11 @@ HAL.Views.Links = Backbone.View.extend({
|
|
33
33
|
showNonSafeRequestDialog: function(e) {
|
34
34
|
e.preventDefault();
|
35
35
|
|
36
|
-
var
|
36
|
+
var postForm = (HAL.customPostForm !== undefined) ? HAL.customPostForm : HAL.Views.NonSafeRequestDialog;
|
37
|
+
var d = new postForm({
|
37
38
|
href: $(e.currentTarget).attr('href'),
|
38
39
|
vent: this.vent
|
39
|
-
}).render({})
|
40
|
+
}).render({})
|
40
41
|
},
|
41
42
|
|
42
43
|
showDocs: function(e) {
|
@@ -5,9 +5,108 @@ HAL.Views.Properties = Backbone.View.extend({
|
|
5
5
|
},
|
6
6
|
|
7
7
|
className: 'properties',
|
8
|
-
|
8
|
+
|
9
|
+
_mkIndent: function(indent, space) {
|
10
|
+
var s = "";
|
11
|
+
for(var i=0; i<indent; ++i) {
|
12
|
+
s += space;
|
13
|
+
}
|
14
|
+
return s;
|
15
|
+
},
|
16
|
+
|
17
|
+
_mkSpace : function(spaceChar, cols) {
|
18
|
+
var s = "";
|
19
|
+
for(i=0; i<cols; ++i) {
|
20
|
+
s += spaceChar;
|
21
|
+
}
|
22
|
+
return s;
|
23
|
+
},
|
24
|
+
|
25
|
+
_isHalLink: function(key, value, stack) {
|
26
|
+
if(!(key === "href") || !(typeof value === "string")) {
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
|
30
|
+
var n = 3;
|
31
|
+
if(stack.length < n) {
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
|
35
|
+
var linkParent = stack[stack.length-n];
|
36
|
+
|
37
|
+
if(Array.isArray(linkParent)) {
|
38
|
+
if(stack.length < n+1) {
|
39
|
+
return false;
|
40
|
+
}
|
41
|
+
++n;
|
42
|
+
linkParent = stack[stack.length-n];
|
43
|
+
}
|
44
|
+
|
45
|
+
if(stack.length < n+1) {
|
46
|
+
return false;
|
47
|
+
}
|
48
|
+
++n;
|
49
|
+
var linkParentParent = stack[stack.length-n];
|
50
|
+
|
51
|
+
return linkParentParent["_links"] === linkParent;
|
52
|
+
},
|
53
|
+
|
54
|
+
_stringifyImpl: function(key, value, indent, stack) {
|
55
|
+
var s = "";
|
56
|
+
var space = this._mkSpace(' ', HAL.jsonIndent);
|
57
|
+
stack.push(value);
|
58
|
+
if(key !== null) {
|
59
|
+
s += '"' + key + '": ';
|
60
|
+
}
|
61
|
+
|
62
|
+
var link = this._isHalLink(key, value, stack);
|
63
|
+
if(link) {
|
64
|
+
s += "<a href='#" + value + "'>";
|
65
|
+
}
|
66
|
+
|
67
|
+
if(Array.isArray(value)) {
|
68
|
+
s += '[';
|
69
|
+
++indent;
|
70
|
+
for(var i=0; i<value.length; ++i) {
|
71
|
+
s += this._stringifyImpl(null, value[i], indent, stack);
|
72
|
+
if(i+1<value.length) {
|
73
|
+
s += ", ";
|
74
|
+
}
|
75
|
+
}
|
76
|
+
--indent;
|
77
|
+
s += ']';
|
78
|
+
} else if(typeof value === "object" && value !== null) {
|
79
|
+
// typeof null is resolved as a object, but Object.keys(null) will raise exception
|
80
|
+
s += '{\n';
|
81
|
+
++indent;
|
82
|
+
var keys = Object.keys(value);
|
83
|
+
for(var i=0; i<keys.length; ++i) {
|
84
|
+
var k = keys[i];
|
85
|
+
s += this._mkIndent(indent, space);
|
86
|
+
s += this._stringifyImpl(k, value[k], indent, stack);
|
87
|
+
if(i+1<keys.length) {
|
88
|
+
s += ",";
|
89
|
+
}
|
90
|
+
s += "\n";
|
91
|
+
}
|
92
|
+
--indent;
|
93
|
+
s += this._mkIndent(indent, space) + '}';
|
94
|
+
} else if(typeof value === "boolean" ||
|
95
|
+
typeof value === "number" ||
|
96
|
+
typeof value === "string" ||
|
97
|
+
(typeof value === "object" && value === null)) {
|
98
|
+
s += _.escape(JSON.stringify(value, null, space));
|
99
|
+
}
|
100
|
+
if(link) {
|
101
|
+
s += "</a>";
|
102
|
+
}
|
103
|
+
stack.pop();
|
104
|
+
return s;
|
105
|
+
},
|
106
|
+
|
9
107
|
render: function(props) {
|
10
|
-
this
|
108
|
+
var propsHtml = this._stringifyImpl(null, props, 0, []);
|
109
|
+
this.$el.html(this.template({ properties: propsHtml }));
|
11
110
|
},
|
12
111
|
|
13
112
|
template: _.template($('#properties-template').html())
|
@@ -19,7 +19,7 @@ HAL.Views.RequestHeaders = Backbone.View.extend({
|
|
19
19
|
updateRequestHeaders: function(e) {
|
20
20
|
var inputText = this.$('textarea').val() || '';
|
21
21
|
headers = HAL.parseHeaders(inputText);
|
22
|
-
HAL.client.
|
22
|
+
HAL.client.updateHeaders(_.defaults(headers, HAL.client.defaultHeaders))
|
23
23
|
},
|
24
24
|
|
25
25
|
render: function() {
|
@@ -25,12 +25,13 @@ HAL.Views.Resource = Backbone.View.extend({
|
|
25
25
|
propertiesView = new HAL.Views.Properties({ vent: this.vent }),
|
26
26
|
embeddedResourcesView
|
27
27
|
|
28
|
-
|
28
|
+
|
29
29
|
propertiesView.render(resource.toJSON());
|
30
|
+
linksView.render(resource.links);
|
30
31
|
|
31
32
|
this.$el.empty();
|
32
|
-
this.$el.append(linksView.el);
|
33
|
-
this.$el.append(propertiesView.el);
|
33
|
+
this.$el.append(linksView.el); // pact_broker swap order of links and properties
|
34
|
+
this.$el.append(propertiesView.el); // pact_broker
|
34
35
|
|
35
36
|
if (resource.embeddedResources) {
|
36
37
|
embeddedResourcesView = new HAL.Views.EmbeddedResources({ vent: this.vent });
|
@@ -3,15 +3,26 @@ HAL.Views.ResponseHeaders = Backbone.View.extend({
|
|
3
3
|
this.vent = opts.vent;
|
4
4
|
},
|
5
5
|
|
6
|
+
events: {
|
7
|
+
'click .follow': 'followLink'
|
8
|
+
},
|
9
|
+
|
6
10
|
className: 'response-headers',
|
7
11
|
|
12
|
+
followLink: function(e) {
|
13
|
+
e.preventDefault();
|
14
|
+
var $target = $(e.currentTarget);
|
15
|
+
var uri = $target.attr('href');
|
16
|
+
window.location.hash = uri;
|
17
|
+
},
|
18
|
+
|
8
19
|
render: function(e) {
|
9
20
|
this.$el.html(this.template({
|
10
21
|
status: {
|
11
22
|
code: e.jqxhr.status,
|
12
23
|
text: e.jqxhr.statusText
|
13
24
|
},
|
14
|
-
headers: e.jqxhr.getAllResponseHeaders()
|
25
|
+
headers: HAL.parseHeaders(e.jqxhr.getAllResponseHeaders())
|
15
26
|
}));
|
16
27
|
},
|
17
28
|
|
@@ -0,0 +1,76 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Sign in - HAL Browser</title>
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
|
+
<link href="vendor/css/bootstrap.css" rel="stylesheet">
|
8
|
+
<link href="vendor/css/bootstrap-responsive.css" rel="stylesheet">
|
9
|
+
<style type="text/css">
|
10
|
+
body {
|
11
|
+
padding-top: 40px;
|
12
|
+
padding-bottom: 40px;
|
13
|
+
background-color: #f5f5f5;
|
14
|
+
}
|
15
|
+
.form-signin {
|
16
|
+
max-width: 300px;
|
17
|
+
padding: 19px 29px 29px;
|
18
|
+
margin: 0 auto 20px;
|
19
|
+
background-color: #fff;
|
20
|
+
border: 1px solid #e5e5e5;
|
21
|
+
-webkit-border-radius: 5px;
|
22
|
+
-moz-border-radius: 5px;
|
23
|
+
border-radius: 5px;
|
24
|
+
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
|
25
|
+
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
|
26
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
|
27
|
+
}
|
28
|
+
.form-signin .form-signin-heading {
|
29
|
+
margin-bottom: 10px;
|
30
|
+
}
|
31
|
+
.form-signin input[type="text"], .form-signin input[type="password"] {
|
32
|
+
font-size: 16px;
|
33
|
+
height: auto;
|
34
|
+
margin-bottom: 15px;
|
35
|
+
padding: 7px 9px;
|
36
|
+
}
|
37
|
+
</style>
|
38
|
+
<script src="vendor/js/jquery-1.10.2.min.js"></script>
|
39
|
+
<script src="vendor/js/bootstrap.js"></script>
|
40
|
+
<script>
|
41
|
+
$(document).ready(function() {
|
42
|
+
$('#form-signin').submit(function(event){
|
43
|
+
event.preventDefault();
|
44
|
+
$.ajax({
|
45
|
+
url : '../oauth/token',
|
46
|
+
type : 'POST',
|
47
|
+
async : false,
|
48
|
+
data : 'password='+$("#password").val()+'&username='+$("#username").val()+'&grant_type=password',
|
49
|
+
headers : {
|
50
|
+
Authorization : 'Basic ' + btoa($("#clientid").val() + ':' + $("#clientsecret").val()),
|
51
|
+
"Content-Type" : 'application/x-www-form-urlencoded',
|
52
|
+
"Accept" : 'application/json'
|
53
|
+
},
|
54
|
+
dataType : 'json',
|
55
|
+
success : function(data) {
|
56
|
+
document.cookie = "MyHalBrowserToken=" + data.access_token;
|
57
|
+
window.location.href = 'browser.html'
|
58
|
+
}
|
59
|
+
});
|
60
|
+
});
|
61
|
+
});
|
62
|
+
</script>
|
63
|
+
</head>
|
64
|
+
<body>
|
65
|
+
<div class="container">
|
66
|
+
<form class="form-signin" id="form-signin">
|
67
|
+
<h3 class="form-signin-heading">HAL Browser - OAuth2</h3>
|
68
|
+
<input type="text" class="input-block-level" placeholder="Client ID" id="clientid">
|
69
|
+
<input type="text" class="input-block-level" placeholder="Client Secret" id="clientsecret">
|
70
|
+
<input type="text" class="input-block-level" placeholder="Username" id="username">
|
71
|
+
<input type="password" class="input-block-level" placeholder="Password" id="password">
|
72
|
+
<button type="submit" class="btn btn-large btn-primary" id="login">Sign in</button>
|
73
|
+
</form>
|
74
|
+
</div>
|
75
|
+
</body>
|
76
|
+
</html>
|