mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-28 00:04:31 +02:00
Merge pull request #212 from mredigonda/remove-jquery
Replaces JQuery ajax requests with Axios requests
This commit is contained in:
commit
d62b50dc23
@ -16,6 +16,7 @@
|
|||||||
"test": "export NODE_PATH=src && mocha src/lib-test/preprocessor.js --compilers js:babel-core/register --recursive src/**/**/__tests__/*-test.js"
|
"test": "export NODE_PATH=src && mocha src/lib-test/preprocessor.js --compilers js:babel-core/register --recursive src/**/**/__tests__/*-test.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"axios-mock-adapter": "^1.15.0",
|
||||||
"babel-core": "^5.8.22",
|
"babel-core": "^5.8.22",
|
||||||
"babel-plugin-transform-class-properties": "^6.11.5",
|
"babel-plugin-transform-class-properties": "^6.11.5",
|
||||||
"babel-register": "^6.7.2",
|
"babel-register": "^6.7.2",
|
||||||
@ -42,7 +43,6 @@
|
|||||||
"gulp-uglify": "^2.1.2",
|
"gulp-uglify": "^2.1.2",
|
||||||
"gulp-util": "^3.0.6",
|
"gulp-util": "^3.0.6",
|
||||||
"humps": "^0.6.0",
|
"humps": "^0.6.0",
|
||||||
"jquery-mockjax": "^2.1.0",
|
|
||||||
"jsdom": "^8.4.1",
|
"jsdom": "^8.4.1",
|
||||||
"morgan": "^1.6.1",
|
"morgan": "^1.6.1",
|
||||||
"proxyquire": "^1.7.4",
|
"proxyquire": "^1.7.4",
|
||||||
@ -55,16 +55,17 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"app-module-path": "^1.0.3",
|
"app-module-path": "^1.0.3",
|
||||||
|
"axios": "^0.18.0",
|
||||||
"chart.js": "^2.4.0",
|
"chart.js": "^2.4.0",
|
||||||
"classnames": "^2.2.5",
|
"classnames": "^2.2.5",
|
||||||
"draft-js": "^0.10.0",
|
"draft-js": "^0.10.0",
|
||||||
"draft-js-export-html": "^0.5.2",
|
"draft-js-export-html": "^0.5.2",
|
||||||
"history": "^3.0.0",
|
"history": "^3.0.0",
|
||||||
"jquery": "^2.1.4",
|
|
||||||
"keycode": "^2.1.4",
|
"keycode": "^2.1.4",
|
||||||
"localStorage": "^1.0.3",
|
"localStorage": "^1.0.3",
|
||||||
"lodash": "^3.10.0",
|
"lodash": "^3.10.0",
|
||||||
"messageformat": "^0.2.2",
|
"messageformat": "^0.2.2",
|
||||||
|
"qs": "^6.5.2",
|
||||||
"react": "^15.4.2",
|
"react": "^15.4.2",
|
||||||
"react-chartjs-2": "^2.0.0",
|
"react-chartjs-2": "^2.0.0",
|
||||||
"react-document-title": "^1.0.2",
|
"react-document-title": "^1.0.2",
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const $ = require('jquery');
|
const axios = require('axios');
|
||||||
const mockjax = require('jquery-mockjax')($, window);
|
const MockAdapter = require('axios-mock-adapter');
|
||||||
|
const qs = require('qs');
|
||||||
|
const mock = new MockAdapter(axios);
|
||||||
|
|
||||||
let fixtures = (function () {
|
let fixtures = (function () {
|
||||||
let fixturesData = [];
|
let fixturesData = [];
|
||||||
@ -23,12 +25,9 @@ fixtures.add(require('data/fixtures/system-fixtures'));
|
|||||||
fixtures.add(require('data/fixtures/article-fixtures'));
|
fixtures.add(require('data/fixtures/article-fixtures'));
|
||||||
|
|
||||||
_.each(fixtures.getAll(), function (fixture) {
|
_.each(fixtures.getAll(), function (fixture) {
|
||||||
mockjax({
|
mock.onAny('http://localhost:3000/api' + fixture.path).reply(function(config) {
|
||||||
contentType: fixture.contentType || 'application/json',
|
return new Promise(function(resolve, reject) {
|
||||||
url: 'http://localhost:3000/api' + fixture.path,
|
setTimeout(() => resolve([200, fixture.response(qs.parse(config.data))]), fixture.time || 500);
|
||||||
responseTime: fixture.time || 500,
|
});
|
||||||
response: function (settings) {
|
|
||||||
this.responseText = fixture.response(settings.data);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const $ = require('jquery');
|
const axios = require('axios');
|
||||||
|
const qs = require('qs');
|
||||||
|
|
||||||
const APIUtils = {
|
const APIUtils = {
|
||||||
|
|
||||||
@ -11,21 +12,14 @@ const APIUtils = {
|
|||||||
data: data
|
data: data
|
||||||
};
|
};
|
||||||
|
|
||||||
if(dataAsForm) {
|
if(!dataAsForm){
|
||||||
options = {
|
options.headers = {'content-type': 'application/x-www-form-urlencoded'};
|
||||||
url: path,
|
options.data = qs.stringify(options.data);
|
||||||
type: method,
|
|
||||||
data: data,
|
|
||||||
processData: false,
|
|
||||||
contentType: false
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax(options)
|
axios(options)
|
||||||
.done(resolve)
|
.then((result) => resolve(result.data))
|
||||||
.fail((jqXHR, textStatus) => {
|
.catch(() => reject());
|
||||||
reject(textStatus);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user