Compare commits
1 Commits
master
...
use-v3-for
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8240169016 |
|
@ -22,6 +22,7 @@ if (Config.useV3API) {
|
|||
|
||||
Build.reopen({
|
||||
ajax: Ember.inject.service(),
|
||||
v3Ajax: Ember.inject.service(),
|
||||
state: attr(),
|
||||
number: attr('number'),
|
||||
message: attr('string'),
|
||||
|
@ -125,11 +126,11 @@ Build.reopen({
|
|||
canRestart: Ember.computed.alias('isFinished'),
|
||||
|
||||
cancel() {
|
||||
return this.get('ajax').post("/builds/" + (this.get('id')) + "/cancel");
|
||||
return this.get('v3Ajax').post("/build/" + (this.get('id')) + "/cancel");
|
||||
},
|
||||
|
||||
restart() {
|
||||
return this.get('ajax').post("/builds/" + (this.get('id')) + "/restart");
|
||||
return this.get('v3Ajax').post("/build/" + (this.get('id')) + "/restart");
|
||||
},
|
||||
|
||||
formattedFinishedAt: function() {
|
||||
|
|
|
@ -9,6 +9,7 @@ import { hasMany, belongsTo } from 'ember-data/relationships';
|
|||
|
||||
export default Model.extend(DurationCalculations, {
|
||||
ajax: Ember.inject.service(),
|
||||
v3Ajax: Ember.inject.service(),
|
||||
logId: attr(),
|
||||
queue: attr(),
|
||||
state: attr(),
|
||||
|
@ -111,7 +112,7 @@ export default Model.extend(DurationCalculations, {
|
|||
canRestart: Ember.computed.alias('isFinished'),
|
||||
|
||||
cancel() {
|
||||
return this.get('ajax').post("/jobs/" + (this.get('id')) + "/cancel");
|
||||
return this.get('v3Ajax').post("/job/" + (this.get('id')) + "/cancel");
|
||||
},
|
||||
|
||||
removeLog() {
|
||||
|
@ -126,7 +127,7 @@ export default Model.extend(DurationCalculations, {
|
|||
},
|
||||
|
||||
restart() {
|
||||
return this.get('ajax').post("/jobs/" + (this.get('id')) + "/restart");
|
||||
return this.get('v3Ajax').post("/job/" + (this.get('id')) + "/restart");
|
||||
},
|
||||
|
||||
appendLog(part) {
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
import Ember from 'ember';
|
||||
import config from 'travis/config/environment';
|
||||
var default_options;
|
||||
|
||||
jQuery.support.cors = true;
|
||||
|
||||
default_options = {
|
||||
accepts: {
|
||||
json: 'application/json; version=2'
|
||||
}
|
||||
};
|
||||
|
||||
export default Ember.Service.extend({
|
||||
auth: Ember.inject.service(),
|
||||
|
||||
default_options: {
|
||||
accepts: {
|
||||
json: 'application/json; version=2'
|
||||
}
|
||||
},
|
||||
|
||||
get(url, callback, errorCallback) {
|
||||
return this.ajax(url, 'get', {
|
||||
success: callback,
|
||||
|
@ -38,11 +37,15 @@ export default Ember.Service.extend({
|
|||
return true;
|
||||
},
|
||||
|
||||
getEndpoint() {
|
||||
return config.apiEndpoint || '';
|
||||
},
|
||||
|
||||
ajax(url, method, options) {
|
||||
var accepts, base, data, delimeter, endpoint, error, key, name, params, promise, ref, ref1, ref2, reject, resolve, success, token, value, xhr;
|
||||
method = method || "GET";
|
||||
method = method.toUpperCase();
|
||||
endpoint = config.apiEndpoint || '';
|
||||
endpoint = this.getEndpoint();
|
||||
options = options || {};
|
||||
token = Ember.get(this, 'auth').token();
|
||||
if (token && (this.needsAuth(method, url) || options.forceAuth)) {
|
||||
|
@ -83,7 +86,7 @@ export default Ember.Service.extend({
|
|||
return error.call(this, data, status, xhr);
|
||||
};
|
||||
|
||||
options = $.extend(options, default_options);
|
||||
options = $.extend(options, this.default_options);
|
||||
|
||||
if (options.data && (method === "GET" || method === "HEAD")) {
|
||||
params = jQuery.param(options.data);
|
||||
|
|
17
app/services/v3-ajax.js
Normal file
17
app/services/v3-ajax.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import Ember from 'ember';
|
||||
import config from 'travis/config/environment';
|
||||
import Ajax from 'travis/services/ajax';
|
||||
|
||||
jQuery.support.cors = true;
|
||||
|
||||
export default Ajax.extend({
|
||||
default_options: {
|
||||
accepts: {
|
||||
json: 'application/json'
|
||||
}
|
||||
},
|
||||
|
||||
getEndpoint() {
|
||||
return config.apiEndpoint + '/v3';
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user