datatable-axios 0.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +51 -0
- package/.github/workflows/sonar.yml +28 -0
- package/.prettierignore +4 -0
- package/.prettierrc.json +8 -0
- package/.releaserc.json +16 -0
- package/CHANGELOG.md +78 -0
- package/LICENSE +20 -20
- package/Readme.md +176 -137
- package/dist/datatable-axios.cjs.js +77 -83
- package/dist/datatable-axios.esm.js +77 -83
- package/dist/datatable-axios.umd.js +86 -90
- package/eslint.config.js +29 -0
- package/package.json +78 -59
- package/sonar-project.properties +6 -0
- package/test/datatable.test.js +108 -0
- package/dist/datatable-axios.js +0 -30
- package/dist/datatable-axios.umd.cjs +0 -1
|
@@ -1,90 +1,84 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A datatable-axios class
|
|
5
|
+
* @class
|
|
6
|
+
*/
|
|
7
|
+
class datatable {
|
|
8
|
+
constructor() {}
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Method to perform a GET request
|
|
12
|
+
* @param {string} url - The url of API endpoint
|
|
13
|
+
* @returns {Promise<object>} Server response from API endpoint
|
|
14
|
+
*/
|
|
15
|
+
async get(url) {
|
|
16
|
+
// Parse the search parameters from the URL
|
|
17
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
9
18
|
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// Return a Promise that resolves when the request completes
|
|
74
|
-
return new Promise(async (resolve) => {
|
|
75
|
-
if (!page && !paginate && !search) {
|
|
76
|
-
// If no search parameters, make a regular PUT request
|
|
77
|
-
await window.axios.put(url).then(response => {
|
|
78
|
-
resolve(response); // Resolve the Promise with the response
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
// If search parameters exist, append them to the URL
|
|
82
|
-
await window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
|
|
83
|
-
resolve(response); // Resolve the Promise with the response
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
})
|
|
87
|
-
}
|
|
19
|
+
// Retrieve values from search parameters
|
|
20
|
+
let page = searchParams.get("page");
|
|
21
|
+
let paginate = searchParams.get("paginate");
|
|
22
|
+
let search = searchParams.get("search");
|
|
23
|
+
|
|
24
|
+
// If no search parameters, make a regular GET request
|
|
25
|
+
if (!page && !paginate && !search) {
|
|
26
|
+
return window.axios.get(url);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// If search parameters exist, append them to the URL
|
|
30
|
+
return window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Method to perform a POST request
|
|
35
|
+
*
|
|
36
|
+
* @async
|
|
37
|
+
* @param {string} url - The url of API endpoint
|
|
38
|
+
* @returns {Promise<object>} Server response from API endpoint
|
|
39
|
+
*/
|
|
40
|
+
async post(url) {
|
|
41
|
+
// Parse the search parameters from the URL
|
|
42
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
43
|
+
|
|
44
|
+
// Retrieve values from search parameters
|
|
45
|
+
let page = searchParams.get("page");
|
|
46
|
+
let paginate = searchParams.get("paginate");
|
|
47
|
+
let search = searchParams.get("search");
|
|
48
|
+
|
|
49
|
+
// If no search parameters, make a regular POST request
|
|
50
|
+
if (!page && !paginate && !search) {
|
|
51
|
+
return window.axios.post(url);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// If search parameters exist, append them to the URL
|
|
55
|
+
return window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Method to perform a PUT request
|
|
60
|
+
*
|
|
61
|
+
* @async
|
|
62
|
+
* @param {string} url - The url of API endpoint
|
|
63
|
+
* @returns {Promise<object>} Server response from API endpoint
|
|
64
|
+
*/
|
|
65
|
+
async put(url) {
|
|
66
|
+
// Parse the search parameters from the URL
|
|
67
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
68
|
+
|
|
69
|
+
// Retrieve values from search parameters
|
|
70
|
+
let page = searchParams.get("page");
|
|
71
|
+
let paginate = searchParams.get("paginate");
|
|
72
|
+
let search = searchParams.get("search");
|
|
73
|
+
|
|
74
|
+
// If no search parameters, make a regular PUT request
|
|
75
|
+
if (!page && !paginate && !search) {
|
|
76
|
+
return window.axios.put(url);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// If search parameters exist, append them to the URL
|
|
80
|
+
return window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
|
|
81
|
+
}
|
|
88
82
|
}
|
|
89
83
|
|
|
90
84
|
// Import the "datatable" class from the local file "./datatable"
|
|
@@ -1,88 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A datatable-axios class
|
|
3
|
+
* @class
|
|
4
|
+
*/
|
|
5
|
+
class datatable {
|
|
6
|
+
constructor() {}
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Method to perform a GET request
|
|
10
|
+
* @param {string} url - The url of API endpoint
|
|
11
|
+
* @returns {Promise<object>} Server response from API endpoint
|
|
12
|
+
*/
|
|
13
|
+
async get(url) {
|
|
14
|
+
// Parse the search parameters from the URL
|
|
15
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
7
16
|
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// Return a Promise that resolves when the request completes
|
|
72
|
-
return new Promise(async (resolve) => {
|
|
73
|
-
if (!page && !paginate && !search) {
|
|
74
|
-
// If no search parameters, make a regular PUT request
|
|
75
|
-
await window.axios.put(url).then(response => {
|
|
76
|
-
resolve(response); // Resolve the Promise with the response
|
|
77
|
-
});
|
|
78
|
-
} else {
|
|
79
|
-
// If search parameters exist, append them to the URL
|
|
80
|
-
await window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`).then(response => {
|
|
81
|
-
resolve(response); // Resolve the Promise with the response
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
}
|
|
17
|
+
// Retrieve values from search parameters
|
|
18
|
+
let page = searchParams.get("page");
|
|
19
|
+
let paginate = searchParams.get("paginate");
|
|
20
|
+
let search = searchParams.get("search");
|
|
21
|
+
|
|
22
|
+
// If no search parameters, make a regular GET request
|
|
23
|
+
if (!page && !paginate && !search) {
|
|
24
|
+
return window.axios.get(url);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// If search parameters exist, append them to the URL
|
|
28
|
+
return window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Method to perform a POST request
|
|
33
|
+
*
|
|
34
|
+
* @async
|
|
35
|
+
* @param {string} url - The url of API endpoint
|
|
36
|
+
* @returns {Promise<object>} Server response from API endpoint
|
|
37
|
+
*/
|
|
38
|
+
async post(url) {
|
|
39
|
+
// Parse the search parameters from the URL
|
|
40
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
41
|
+
|
|
42
|
+
// Retrieve values from search parameters
|
|
43
|
+
let page = searchParams.get("page");
|
|
44
|
+
let paginate = searchParams.get("paginate");
|
|
45
|
+
let search = searchParams.get("search");
|
|
46
|
+
|
|
47
|
+
// If no search parameters, make a regular POST request
|
|
48
|
+
if (!page && !paginate && !search) {
|
|
49
|
+
return window.axios.post(url);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// If search parameters exist, append them to the URL
|
|
53
|
+
return window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Method to perform a PUT request
|
|
58
|
+
*
|
|
59
|
+
* @async
|
|
60
|
+
* @param {string} url - The url of API endpoint
|
|
61
|
+
* @returns {Promise<object>} Server response from API endpoint
|
|
62
|
+
*/
|
|
63
|
+
async put(url) {
|
|
64
|
+
// Parse the search parameters from the URL
|
|
65
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
66
|
+
|
|
67
|
+
// Retrieve values from search parameters
|
|
68
|
+
let page = searchParams.get("page");
|
|
69
|
+
let paginate = searchParams.get("paginate");
|
|
70
|
+
let search = searchParams.get("search");
|
|
71
|
+
|
|
72
|
+
// If no search parameters, make a regular PUT request
|
|
73
|
+
if (!page && !paginate && !search) {
|
|
74
|
+
return window.axios.put(url);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// If search parameters exist, append them to the URL
|
|
78
|
+
return window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
|
|
79
|
+
}
|
|
86
80
|
}
|
|
87
81
|
|
|
88
82
|
// Import the "datatable" class from the local file "./datatable"
|
|
@@ -1,96 +1,92 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})(this, (function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
resolve(response); // Resolve the Promise with the response
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
})
|
|
89
|
-
}
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["datatable-axios"] = factory());
|
|
5
|
+
})(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A datatable-axios class
|
|
9
|
+
* @class
|
|
10
|
+
*/
|
|
11
|
+
class datatable {
|
|
12
|
+
constructor() {}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Method to perform a GET request
|
|
16
|
+
* @param {string} url - The url of API endpoint
|
|
17
|
+
* @returns {Promise<object>} Server response from API endpoint
|
|
18
|
+
*/
|
|
19
|
+
async get(url) {
|
|
20
|
+
// Parse the search parameters from the URL
|
|
21
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
22
|
+
|
|
23
|
+
// Retrieve values from search parameters
|
|
24
|
+
let page = searchParams.get("page");
|
|
25
|
+
let paginate = searchParams.get("paginate");
|
|
26
|
+
let search = searchParams.get("search");
|
|
27
|
+
|
|
28
|
+
// If no search parameters, make a regular GET request
|
|
29
|
+
if (!page && !paginate && !search) {
|
|
30
|
+
return window.axios.get(url);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// If search parameters exist, append them to the URL
|
|
34
|
+
return window.axios.get(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Method to perform a POST request
|
|
39
|
+
*
|
|
40
|
+
* @async
|
|
41
|
+
* @param {string} url - The url of API endpoint
|
|
42
|
+
* @returns {Promise<object>} Server response from API endpoint
|
|
43
|
+
*/
|
|
44
|
+
async post(url) {
|
|
45
|
+
// Parse the search parameters from the URL
|
|
46
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
47
|
+
|
|
48
|
+
// Retrieve values from search parameters
|
|
49
|
+
let page = searchParams.get("page");
|
|
50
|
+
let paginate = searchParams.get("paginate");
|
|
51
|
+
let search = searchParams.get("search");
|
|
52
|
+
|
|
53
|
+
// If no search parameters, make a regular POST request
|
|
54
|
+
if (!page && !paginate && !search) {
|
|
55
|
+
return window.axios.post(url);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// If search parameters exist, append them to the URL
|
|
59
|
+
return window.axios.post(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Method to perform a PUT request
|
|
64
|
+
*
|
|
65
|
+
* @async
|
|
66
|
+
* @param {string} url - The url of API endpoint
|
|
67
|
+
* @returns {Promise<object>} Server response from API endpoint
|
|
68
|
+
*/
|
|
69
|
+
async put(url) {
|
|
70
|
+
// Parse the search parameters from the URL
|
|
71
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
72
|
+
|
|
73
|
+
// Retrieve values from search parameters
|
|
74
|
+
let page = searchParams.get("page");
|
|
75
|
+
let paginate = searchParams.get("paginate");
|
|
76
|
+
let search = searchParams.get("search");
|
|
77
|
+
|
|
78
|
+
// If no search parameters, make a regular PUT request
|
|
79
|
+
if (!page && !paginate && !search) {
|
|
80
|
+
return window.axios.put(url);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// If search parameters exist, append them to the URL
|
|
84
|
+
return window.axios.put(`${url}?page=${page}&paginate=${paginate}&search=${search}`);
|
|
90
85
|
}
|
|
86
|
+
}
|
|
91
87
|
|
|
92
|
-
|
|
88
|
+
// Import the "datatable" class from the local file "./datatable"
|
|
93
89
|
|
|
94
|
-
|
|
90
|
+
return datatable;
|
|
95
91
|
|
|
96
92
|
}));
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import prettier from "eslint-plugin-prettier";
|
|
4
|
+
import prettierConfig from "eslint-config-prettier";
|
|
5
|
+
|
|
6
|
+
export default [
|
|
7
|
+
js.configs.recommended,
|
|
8
|
+
{
|
|
9
|
+
files: ["**/*.js"],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
ecmaVersion: "latest",
|
|
12
|
+
sourceType: "module",
|
|
13
|
+
globals: {
|
|
14
|
+
...globals.browser,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
plugins: {
|
|
18
|
+
prettier,
|
|
19
|
+
},
|
|
20
|
+
rules: {
|
|
21
|
+
"prettier/prettier": "error",
|
|
22
|
+
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
prettierConfig,
|
|
26
|
+
{
|
|
27
|
+
ignores: ["node_modules/", "coverage/", "dist/"],
|
|
28
|
+
},
|
|
29
|
+
];
|