View | Details | Raw Unified | Return to bug 38993
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/didyoumean.tt (-1 / +1 lines)
Lines 116-122 Link Here
116
116
117
        function yesimeant() {
117
        function yesimeant() {
118
            var OPACdidyoumean = serialize_plugins('opac');
118
            var OPACdidyoumean = serialize_plugins('opac');
119
            const client = APIClient.syspref;
119
            const client = APIClient.sysprefs;
120
            client.sysprefs.update('OPACdidyoumean', OPACdidyoumean).then(
120
            client.sysprefs.update('OPACdidyoumean', OPACdidyoumean).then(
121
                success => {
121
                success => {
122
                    alert(_("Successfully saved configuration"));
122
                    alert(_("Successfully saved configuration"));
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js (-7 / +6 lines)
Lines 1-16 Link Here
1
import HttpClient from "./http-client";
1
export class AcquisitionAPIClient {
2
2
    constructor(HttpClient) {
3
export class AcquisitionAPIClient extends HttpClient {
3
        this.httpClient = new HttpClient({
4
    constructor() {
4
            baseURL:  "/api/v1/acquisitions/",
5
        super({
6
            baseURL: "/api/v1/acquisitions/",
7
        });
5
        });
6
8
    }
7
    }
9
8
10
    get vendors() {
9
    get vendors() {
11
        return {
10
        return {
12
            getAll: (query, params) =>
11
            getAll: (query, params) =>
13
                this.getAll({
12
                this.httpClient.getAll({
14
                    endpoint: "vendors",
13
                    endpoint: "vendors",
15
                    query,
14
                    query,
16
                    params,
15
                    params,
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/additional-fields-api-client.js (-7 / +5 lines)
Lines 1-16 Link Here
1
import HttpClient from "./http-client";
1
export class AdditionalFieldsAPIClient {
2
2
    constructor(HttpClient) {
3
export class AdditionalFieldsAPIClient extends HttpClient {
3
        this.httpClient = new HttpClient({
4
    constructor() {
4
            baseURL:  "/api/v1/extended_attribute_types",
5
        super({
6
            baseURL: "/api/v1/extended_attribute_types",
7
        });
5
        });
8
    }
6
    }
9
7
10
    get additional_fields() {
8
    get additional_fields() {
11
        return {
9
        return {
12
            getAll: resource_type =>
10
            getAll: resource_type =>
13
                this.get({
11
                this.httpClient.get({
14
                    endpoint: "?resource_type=" + resource_type,
12
                    endpoint: "?resource_type=" + resource_type,
15
                }),
13
                }),
16
        };
14
        };
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js (-12 / +14 lines)
Lines 1-6 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
import HttpClient from "./http-client.js";
3
2
import ArticleRequestAPIClient from "./article-request-api-client.js";
4
import ArticleRequestAPIClient from "./article-request-api-client.js";
3
import AVAPIClient from "./authorised-value-api-client.js";
5
import AVAPIClient from "./authorised-values-api-client.js";
4
import CataloguingAPIClient from "./cataloguing-api-client.js";
6
import CataloguingAPIClient from "./cataloguing-api-client.js";
5
import CirculationAPIClient from "./circulation-api-client.js";
7
import CirculationAPIClient from "./circulation-api-client.js";
6
import ClubAPIClient from "./club-api-client.js";
8
import ClubAPIClient from "./club-api-client.js";
Lines 12-26 import SysprefAPIClient from "./system-preferences-api-client.js"; Link Here
12
import TicketAPIClient from "./ticket-api-client.js";
14
import TicketAPIClient from "./ticket-api-client.js";
13
15
14
export const APIClient = {
16
export const APIClient = {
15
    article_request: new ArticleRequestAPIClient(),
17
    article_request: new ArticleRequestAPIClient(HttpClient),
16
    authorised_value: new AVAPIClient(),
18
    authorised_values: new AVAPIClient(HttpClient),
17
    cataloguing: new CataloguingAPIClient(),
19
    cataloguing: new CataloguingAPIClient(HttpClient),
18
    circulation: new CirculationAPIClient(),
20
    circulation: new CirculationAPIClient(HttpClient),
19
    club: new ClubAPIClient(),
21
    club: new ClubAPIClient(HttpClient),
20
    cover_image: new CoverImageAPIClient(),
22
    cover_image: new CoverImageAPIClient(HttpClient),
21
    localization: new LocalizationAPIClient(),
23
    localization: new LocalizationAPIClient(HttpClient),
22
    patron: new PatronAPIClient(),
24
    patron: new PatronAPIClient(HttpClient),
23
    recall: new RecallAPIClient(),
25
    recall: new RecallAPIClient(HttpClient),
24
    syspref: new SysprefAPIClient(),
26
    sysprefs: new SysprefAPIClient(HttpClient),
25
    ticket: new TicketAPIClient(),
27
    ticket: new TicketAPIClient(HttpClient),
26
};
28
};
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/article-request-api-client.js (-11 / +9 lines)
Lines 1-11 Link Here
1
/* keep tidy */
1
export class ArticleRequestAPIClient {
2
import HttpClient from "./http-client.js";
2
    constructor(HttpClient) {
3
        this.httpClient = new HttpClient({
3
4
4
export class ArticleRequestAPIClient extends HttpClient {
5
    constructor() {
6
        super({
7
            baseURL: "/cgi-bin/koha/svc/article_request",
5
            baseURL: "/cgi-bin/koha/svc/article_request",
8
            headers: {
6
        headers: {
9
                "Content-Type":
7
                "Content-Type":
10
                    "application/x-www-form-urlencoded;charset=utf-8",
8
                    "application/x-www-form-urlencoded;charset=utf-8",
11
            },
9
            },
Lines 15-36 export class ArticleRequestAPIClient extends HttpClient { Link Here
15
    get articleRequests() {
13
    get articleRequests() {
16
        return {
14
        return {
17
            process: id =>
15
            process: id =>
18
                this.post({
16
                this.httpClient.post({
19
                    endpoint: "",
17
                    endpoint: "",
20
                    body: "id=%s&op=%s".format(id, "cud-process"),
18
                    body: "id=%s&op=%s".format(id, "cud-process"),
21
                }),
19
                }),
22
            complete: id =>
20
            complete: id =>
23
                this.post({
21
                this.httpClient.post({
24
                    endpoint: "",
22
                    endpoint: "",
25
                    body: "id=%s&op=%s".format(id, "cud-complete"),
23
                    body: "id=%s&op=%s".format(id, "cud-complete"),
26
                }),
24
                }),
27
            pending: id =>
25
            pending: id =>
28
                this.post({
26
                this.httpClient.post({
29
                    endpoint: "",
27
                    endpoint: "",
30
                    body: "id=%s&op=%s".format(id, "cud-pending"),
28
                    body: "id=%s&op=%s".format(id, "cud-pending"),
31
                }),
29
                }),
32
            update_urls: (id, urls) =>
30
            update_urls: (id, urls) =>
33
                this.post({
31
                this.httpClient.post({
34
                    endpoint: "",
32
                    endpoint: "",
35
                    body: "id=%s&urls=%s&op=%s".format(
33
                    body: "id=%s&urls=%s&op=%s".format(
36
                        id,
34
                        id,
Lines 39-45 export class ArticleRequestAPIClient extends HttpClient { Link Here
39
                    ),
37
                    ),
40
                }),
38
                }),
41
            update_library_id: (id, library_id) =>
39
            update_library_id: (id, library_id) =>
42
                this.post({
40
                this.httpClient.post({
43
                    endpoint: "",
41
                    endpoint: "",
44
                    body: "id=%s&library_id=%s&op=%s".format(
42
                    body: "id=%s&library_id=%s&op=%s".format(
45
                        id,
43
                        id,
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/authorised-value-api-client.js (-31 lines)
Lines 1-31 Link Here
1
/* keep tidy */
2
import HttpClient from "./http-client.js";
3
4
export class AVAPIClient extends HttpClient {
5
    constructor() {
6
        super({
7
            baseURL: "/cgi-bin/koha/svc/authorised_values",
8
            headers: {
9
                "Content-Type":
10
                    "application/x-www-form-urlencoded;charset=utf-8",
11
            },
12
        });
13
    }
14
15
    get values() {
16
        return {
17
            create: value =>
18
                this.post({
19
                    endpoint: "",
20
                    body: "category=%s&value=%s&description=%s&opac_description=%s".format(
21
                        encodeURIComponent(value.category),
22
                        encodeURIComponent(value.value),
23
                        encodeURIComponent(value.description),
24
                        encodeURIComponent(value.opac_description)
25
                    ),
26
                }),
27
        };
28
    }
29
}
30
31
export default AVAPIClient;
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/authorised-values-api-client.js (+43 lines)
Line 0 Link Here
1
export class AVAPIClient {
2
    constructor(HttpClient) {
3
        this.httpClient = new HttpClient({
4
            baseURL: "",
5
        });
6
    }
7
8
    get values() {
9
        return {
10
            get: category =>
11
                this.httpClient.get({
12
                    endpoint: `/api/v1/authorised_value_categories/${category}/authorised_values`,
13
                }),
14
            getCategoriesWithValues: cat_array =>
15
                this.httpClient.get({
16
                    endpoint:
17
                        '/api/v1/authorised_value_categories' +
18
                        '?q={"me.category_name":[' +
19
                        cat_array.join(", ") +
20
                        "]}",
21
                    headers: {
22
                        "x-koha-embed": "authorised_values",
23
                    },
24
                }),
25
            create: value =>
26
                this.httpClient.post({
27
                    endpoint: "/cgi-bin/koha/svc/authorised_values",
28
                    body: "category=%s&value=%s&description=%s&opac_description=%s".format(
29
                        encodeURIComponent(value.category),
30
                        encodeURIComponent(value.value),
31
                        encodeURIComponent(value.description),
32
                        encodeURIComponent(value.opac_description)
33
                    ),
34
                    headers: {
35
                        "Content-Type":
36
                            "application/x-www-form-urlencoded;charset=utf-8",
37
                    },
38
                }),
39
        };
40
    }
41
}
42
43
export default AVAPIClient;
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/cataloguing-api-client.js (-7 / +5 lines)
Lines 1-9 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
import HttpClient from "./http-client.js";
2
export class CataloguingAPIClient {
3
3
    constructor(HttpClient) {
4
export class CataloguingAPIClient extends HttpClient {
4
        this.httpClient = new HttpClient({
5
    constructor() {
6
        super({
7
            baseURL: "/cgi-bin/koha/svc/",
5
            baseURL: "/cgi-bin/koha/svc/",
8
        });
6
        });
9
    }
7
    }
Lines 11-17 export class CataloguingAPIClient extends HttpClient { Link Here
11
    get catalog_bib() {
9
    get catalog_bib() {
12
        return {
10
        return {
13
            create: bib_info =>
11
            create: bib_info =>
14
                this.post({
12
                this.httpClient.post({
15
                    endpoint: "new_bib/?frameworkcode=%s".format(
13
                    endpoint: "new_bib/?frameworkcode=%s".format(
16
                        bib_info.frameworkcode
14
                        bib_info.frameworkcode
17
                    ),
15
                    ),
Lines 21-27 export class CataloguingAPIClient extends HttpClient { Link Here
21
                    },
19
                    },
22
                }),
20
                }),
23
            update: bib_info =>
21
            update: bib_info =>
24
                this.post({
22
                this.httpClient.post({
25
                    endpoint: "bib/%s?frameworkcode=%s".format(
23
                    endpoint: "bib/%s?frameworkcode=%s".format(
26
                        bib_info.id,
24
                        bib_info.id,
27
                        bib_info.frameworkcode
25
                        bib_info.frameworkcode
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/circulation-api-client.js (-9 / +7 lines)
Lines 1-9 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
import HttpClient from "./http-client.js";
2
export class CirculationAPIClient {
3
3
    constructor(HttpClient) {
4
export class CirculationAPIClient extends HttpClient {
4
        this.httpClient = new HttpClient({
5
    constructor() {
6
        super({
7
            baseURL: "/cgi-bin/koha/svc/",
5
            baseURL: "/cgi-bin/koha/svc/",
8
        });
6
        });
9
    }
7
    }
Lines 11-17 export class CirculationAPIClient extends HttpClient { Link Here
11
    get checkins() {
9
    get checkins() {
12
        return {
10
        return {
13
            create: checkin =>
11
            create: checkin =>
14
                this.post({
12
                this.httpClient.post({
15
                    endpoint: "checkin",
13
                    endpoint: "checkin",
16
                    body: "itemnumber=%s&borrowernumber=%s&branchcode=%s&exempt_fine=%s&op=%s".format(
14
                    body: "itemnumber=%s&borrowernumber=%s&branchcode=%s&exempt_fine=%s&op=%s".format(
17
                        checkin.item_id,
15
                        checkin.item_id,
Lines 31-37 export class CirculationAPIClient extends HttpClient { Link Here
31
    get checkouts() {
29
    get checkouts() {
32
        return {
30
        return {
33
            renew: checkout =>
31
            renew: checkout =>
34
                this.post({
32
                this.httpClient.post({
35
                    endpoint: "renew",
33
                    endpoint: "renew",
36
                    body:
34
                    body:
37
                        "itemnumber=%s&borrowernumber=%s&branchcode=%s&override_limit=%s".format(
35
                        "itemnumber=%s&borrowernumber=%s&branchcode=%s&override_limit=%s".format(
Lines 52-58 export class CirculationAPIClient extends HttpClient { Link Here
52
                    },
50
                    },
53
                }),
51
                }),
54
            mark_as_seen: checkout_id =>
52
            mark_as_seen: checkout_id =>
55
                this.post({
53
                this.httpClient.post({
56
                    endpoint: "checkout_notes",
54
                    endpoint: "checkout_notes",
57
                    body: "issue_id=%s&op=%s".format(checkout_id, "cud-seen"),
55
                    body: "issue_id=%s&op=%s".format(checkout_id, "cud-seen"),
58
                    headers: {
56
                    headers: {
Lines 61-67 export class CirculationAPIClient extends HttpClient { Link Here
61
                    },
59
                    },
62
                }),
60
                }),
63
            mark_as_not_seen: checkout_id =>
61
            mark_as_not_seen: checkout_id =>
64
                this.post({
62
                this.httpClient.post({
65
                    endpoint: "checkout_notes",
63
                    endpoint: "checkout_notes",
66
                    body: "issue_id=%s&op=%s".format(
64
                    body: "issue_id=%s&op=%s".format(
67
                        checkout_id,
65
                        checkout_id,
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/club-api-client.js (-9 / +7 lines)
Lines 1-9 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
import HttpClient from "./http-client.js";
2
export class ClubAPIClient {
3
3
    constructor(HttpClient) {
4
export class ClubAPIClient extends HttpClient {
4
        this.httpClient = new HttpClient({
5
    constructor() {
6
        super({
7
            baseURL: "/cgi-bin/koha/svc/club/",
5
            baseURL: "/cgi-bin/koha/svc/club/",
8
        });
6
        });
9
    }
7
    }
Lines 11-17 export class ClubAPIClient extends HttpClient { Link Here
11
    get templates() {
9
    get templates() {
12
        return {
10
        return {
13
            delete: template_id =>
11
            delete: template_id =>
14
                this.post({
12
                this.httpClient.post({
15
                    endpoint: "template/delete",
13
                    endpoint: "template/delete",
16
                    body: "id=%s&op=%s".format(template_id, "cud-delete"),
14
                    body: "id=%s&op=%s".format(template_id, "cud-delete"),
17
                    headers: {
15
                    headers: {
Lines 25-31 export class ClubAPIClient extends HttpClient { Link Here
25
    get clubs() {
23
    get clubs() {
26
        return {
24
        return {
27
            delete: club_id =>
25
            delete: club_id =>
28
                this.post({
26
                this.httpClient.post({
29
                    endpoint: "delete",
27
                    endpoint: "delete",
30
                    body: "id=%s&op=%s".format(club_id, "cud-delete"),
28
                    body: "id=%s&op=%s".format(club_id, "cud-delete"),
31
                    headers: {
29
                    headers: {
Lines 39-45 export class ClubAPIClient extends HttpClient { Link Here
39
    get enrollments() {
37
    get enrollments() {
40
        return {
38
        return {
41
            cancel: enrollment_id =>
39
            cancel: enrollment_id =>
42
                this.post({
40
                this.httpClient.post({
43
                    endpoint: "cancel_enrollment",
41
                    endpoint: "cancel_enrollment",
44
                    body: "id=%s&op=%s".format(enrollment_id, "cud-delete"),
42
                    body: "id=%s&op=%s".format(enrollment_id, "cud-delete"),
45
                    headers: {
43
                    headers: {
Lines 49-55 export class ClubAPIClient extends HttpClient { Link Here
49
                }),
47
                }),
50
48
51
            enroll: data =>
49
            enroll: data =>
52
                this.post({
50
                this.httpClient.post({
53
                    endpoint: "enroll",
51
                    endpoint: "enroll",
54
                    body: "%s&op=%s".format(
52
                    body: "%s&op=%s".format(
55
                        data, // Could do better, but too much work for now!
53
                        data, // Could do better, but too much work for now!
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/cover-image-api-client.js (-6 / +4 lines)
Lines 1-9 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
import HttpClient from "./http-client.js";
2
export class CoverImageAPIClient {
3
3
    constructor(HttpClient) {
4
export class CoverImageAPIClient extends HttpClient {
4
        this.httpClient = new HttpClient({
5
    constructor() {
6
        super({
7
            baseURL: "/cgi-bin/koha/svc/cover_images",
5
            baseURL: "/cgi-bin/koha/svc/cover_images",
8
        });
6
        });
9
    }
7
    }
Lines 11-17 export class CoverImageAPIClient extends HttpClient { Link Here
11
    get cover_images() {
9
    get cover_images() {
12
        return {
10
        return {
13
            delete: image_id =>
11
            delete: image_id =>
14
                this.post({
12
                this.httpClient.post({
15
                    endpoint: "",
13
                    endpoint: "",
16
                    body: "imagenumber=%s&op=%s".format(image_id, "cud-delete"),
14
                    body: "imagenumber=%s&op=%s".format(image_id, "cud-delete"),
17
                    headers: {
15
                    headers: {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js (-61 / +59 lines)
Lines 1-8 Link Here
1
import HttpClient from "./http-client";
1
export class ERMAPIClient {
2
2
    constructor(HttpClient) {
3
export class ERMAPIClient extends HttpClient {
3
        this.httpClient = new HttpClient({
4
    constructor() {
5
        super({
6
            baseURL: "/api/v1/erm/",
4
            baseURL: "/api/v1/erm/",
7
        });
5
        });
8
    }
6
    }
Lines 10-16 export class ERMAPIClient extends HttpClient { Link Here
10
    get config() {
8
    get config() {
11
        return {
9
        return {
12
            get: () =>
10
            get: () =>
13
                this.get({
11
                this.httpClient.get({
14
                    endpoint: "config",
12
                    endpoint: "config",
15
                }),
13
                }),
16
        };
14
        };
Lines 19-25 export class ERMAPIClient extends HttpClient { Link Here
19
    get agreements() {
17
    get agreements() {
20
        return {
18
        return {
21
            get: id =>
19
            get: id =>
22
                this.get({
20
                this.httpClient.get({
23
                    endpoint: "agreements/" + id,
21
                    endpoint: "agreements/" + id,
24
                    headers: {
22
                    headers: {
25
                        "x-koha-embed":
23
                        "x-koha-embed":
Lines 27-53 export class ERMAPIClient extends HttpClient { Link Here
27
                    },
25
                    },
28
                }),
26
                }),
29
            getAll: (query, params) =>
27
            getAll: (query, params) =>
30
                this.getAll({
28
                this.httpClient.getAll({
31
                    endpoint: "agreements",
29
                    endpoint: "agreements",
32
                    query,
30
                    query,
33
                    params,
31
                    params,
34
                }),
32
                }),
35
            delete: id =>
33
            delete: id =>
36
                this.delete({
34
                this.httpClient.delete({
37
                    endpoint: "agreements/" + id,
35
                    endpoint: "agreements/" + id,
38
                }),
36
                }),
39
            create: agreement =>
37
            create: agreement =>
40
                this.post({
38
                this.httpClient.post({
41
                    endpoint: "agreements",
39
                    endpoint: "agreements",
42
                    body: agreement,
40
                    body: agreement,
43
                }),
41
                }),
44
            update: (agreement, id) =>
42
            update: (agreement, id) =>
45
                this.put({
43
                this.httpClient.put({
46
                    endpoint: "agreements/" + id,
44
                    endpoint: "agreements/" + id,
47
                    body: agreement,
45
                    body: agreement,
48
                }),
46
                }),
49
            count: (query = {}) =>
47
            count: (query = {}) =>
50
                this.count({
48
                this.httpClient.count({
51
                    endpoint:
49
                    endpoint:
52
                        "agreements?" +
50
                        "agreements?" +
53
                        new URLSearchParams({
51
                        new URLSearchParams({
Lines 62-68 export class ERMAPIClient extends HttpClient { Link Here
62
    get licenses() {
60
    get licenses() {
63
        return {
61
        return {
64
            get: id =>
62
            get: id =>
65
                this.get({
63
                this.httpClient.get({
66
                    endpoint: "licenses/" + id,
64
                    endpoint: "licenses/" + id,
67
                    headers: {
65
                    headers: {
68
                        "x-koha-embed":
66
                        "x-koha-embed":
Lines 70-76 export class ERMAPIClient extends HttpClient { Link Here
70
                    },
68
                    },
71
                }),
69
                }),
72
            getAll: (query, params) =>
70
            getAll: (query, params) =>
73
                this.getAll({
71
                this.httpClient.getAll({
74
                    endpoint: "licenses",
72
                    endpoint: "licenses",
75
                    query,
73
                    query,
76
                    params,
74
                    params,
Lines 79-99 export class ERMAPIClient extends HttpClient { Link Here
79
                    },
77
                    },
80
                }),
78
                }),
81
            delete: id =>
79
            delete: id =>
82
                this.delete({
80
                this.httpClient.delete({
83
                    endpoint: "licenses/" + id,
81
                    endpoint: "licenses/" + id,
84
                }),
82
                }),
85
            create: license =>
83
            create: license =>
86
                this.post({
84
                this.httpClient.post({
87
                    endpoint: "licenses",
85
                    endpoint: "licenses",
88
                    body: license,
86
                    body: license,
89
                }),
87
                }),
90
            update: (license, id) =>
88
            update: (license, id) =>
91
                this.put({
89
                this.httpClient.put({
92
                    endpoint: "licenses/" + id,
90
                    endpoint: "licenses/" + id,
93
                    body: license,
91
                    body: license,
94
                }),
92
                }),
95
            count: (query = {}) =>
93
            count: (query = {}) =>
96
                this.count({
94
                this.httpClient.count({
97
                    endpoint:
95
                    endpoint:
98
                        "licenses?" +
96
                        "licenses?" +
99
                        new URLSearchParams({
97
                        new URLSearchParams({
Lines 108-114 export class ERMAPIClient extends HttpClient { Link Here
108
    get localPackages() {
106
    get localPackages() {
109
        return {
107
        return {
110
            get: id =>
108
            get: id =>
111
                this.get({
109
                this.httpClient.get({
112
                    endpoint: "eholdings/local/packages/" + id,
110
                    endpoint: "eholdings/local/packages/" + id,
113
                    headers: {
111
                    headers: {
114
                        "x-koha-embed":
112
                        "x-koha-embed":
Lines 116-122 export class ERMAPIClient extends HttpClient { Link Here
116
                    },
114
                    },
117
                }),
115
                }),
118
            getAll: (query, params) =>
116
            getAll: (query, params) =>
119
                this.getAll({
117
                this.httpClient.getAll({
120
                    endpoint: "eholdings/local/packages",
118
                    endpoint: "eholdings/local/packages",
121
                    query,
119
                    query,
122
                    params,
120
                    params,
Lines 125-145 export class ERMAPIClient extends HttpClient { Link Here
125
                    },
123
                    },
126
                }),
124
                }),
127
            delete: id =>
125
            delete: id =>
128
                this.delete({
126
                this.httpClient.delete({
129
                    endpoint: "eholdings/local/packages/" + id,
127
                    endpoint: "eholdings/local/packages/" + id,
130
                }),
128
                }),
131
            create: local_package =>
129
            create: local_package =>
132
                this.post({
130
                this.httpClient.post({
133
                    endpoint: "eholdings/local/packages",
131
                    endpoint: "eholdings/local/packages",
134
                    body: local_package,
132
                    body: local_package,
135
                }),
133
                }),
136
            update: (local_package, id) =>
134
            update: (local_package, id) =>
137
                this.put({
135
                this.httpClient.put({
138
                    endpoint: "eholdings/local/packages/" + id,
136
                    endpoint: "eholdings/local/packages/" + id,
139
                    body: local_package,
137
                    body: local_package,
140
                }),
138
                }),
141
            count: (query = {}) =>
139
            count: (query = {}) =>
142
                this.count({
140
                this.httpClient.count({
143
                    endpoint:
141
                    endpoint:
144
                        "eholdings/local/packages?" +
142
                        "eholdings/local/packages?" +
145
                        new URLSearchParams({
143
                        new URLSearchParams({
Lines 154-181 export class ERMAPIClient extends HttpClient { Link Here
154
    get localTitles() {
152
    get localTitles() {
155
        return {
153
        return {
156
            get: id =>
154
            get: id =>
157
                this.get({
155
                this.httpClient.get({
158
                    endpoint: "eholdings/local/titles/" + id,
156
                    endpoint: "eholdings/local/titles/" + id,
159
                    headers: {
157
                    headers: {
160
                        "x-koha-embed": "resources,resources.package",
158
                        "x-koha-embed": "resources,resources.package",
161
                    },
159
                    },
162
                }),
160
                }),
163
            delete: id =>
161
            delete: id =>
164
                this.delete({
162
                this.httpClient.delete({
165
                    endpoint: "eholdings/local/titles/" + id,
163
                    endpoint: "eholdings/local/titles/" + id,
166
                }),
164
                }),
167
            create: local_package =>
165
            create: local_package =>
168
                this.post({
166
                this.httpClient.post({
169
                    endpoint: "eholdings/local/titles",
167
                    endpoint: "eholdings/local/titles",
170
                    body: local_package,
168
                    body: local_package,
171
                }),
169
                }),
172
            update: (local_package, id) =>
170
            update: (local_package, id) =>
173
                this.put({
171
                this.httpClient.put({
174
                    endpoint: "eholdings/local/titles/" + id,
172
                    endpoint: "eholdings/local/titles/" + id,
175
                    body: local_package,
173
                    body: local_package,
176
                }),
174
                }),
177
            count: (query = {}) =>
175
            count: (query = {}) =>
178
                this.count({
176
                this.httpClient.count({
179
                    endpoint:
177
                    endpoint:
180
                        "eholdings/local/titles?" +
178
                        "eholdings/local/titles?" +
181
                        new URLSearchParams({
179
                        new URLSearchParams({
Lines 185-196 export class ERMAPIClient extends HttpClient { Link Here
185
                        }),
183
                        }),
186
                }),
184
                }),
187
            import: body =>
185
            import: body =>
188
                this.post({
186
                this.httpClient.post({
189
                    endpoint: "eholdings/local/titles/import",
187
                    endpoint: "eholdings/local/titles/import",
190
                    body,
188
                    body,
191
                }),
189
                }),
192
            import_kbart: body =>
190
            import_kbart: body =>
193
                this.post({
191
                this.httpClient.post({
194
                    endpoint: "eholdings/local/titles/import_kbart",
192
                    endpoint: "eholdings/local/titles/import_kbart",
195
                    body,
193
                    body,
196
                }),
194
                }),
Lines 200-206 export class ERMAPIClient extends HttpClient { Link Here
200
    get localResources() {
198
    get localResources() {
201
        return {
199
        return {
202
            get: id =>
200
            get: id =>
203
                this.get({
201
                this.httpClient.get({
204
                    endpoint: "eholdings/local/resources/" + id,
202
                    endpoint: "eholdings/local/resources/" + id,
205
                    headers: {
203
                    headers: {
206
                        "x-koha-embed": "title,package,vendor",
204
                        "x-koha-embed": "title,package,vendor",
Lines 212-218 export class ERMAPIClient extends HttpClient { Link Here
212
    get EBSCOPackages() {
210
    get EBSCOPackages() {
213
        return {
211
        return {
214
            get: id =>
212
            get: id =>
215
                this.get({
213
                this.httpClient.get({
216
                    endpoint: "eholdings/ebsco/packages/" + id,
214
                    endpoint: "eholdings/ebsco/packages/" + id,
217
                    headers: {
215
                    headers: {
218
                        "x-koha-embed":
216
                        "x-koha-embed":
Lines 220-226 export class ERMAPIClient extends HttpClient { Link Here
220
                    },
218
                    },
221
                }),
219
                }),
222
            patch: (id, body) =>
220
            patch: (id, body) =>
223
                this.patch({
221
                this.httpClient.patch({
224
                    endpoint: "eholdings/ebsco/packages/" + id,
222
                    endpoint: "eholdings/ebsco/packages/" + id,
225
                    body,
223
                    body,
226
                }),
224
                }),
Lines 230-236 export class ERMAPIClient extends HttpClient { Link Here
230
    get EBSCOTitles() {
228
    get EBSCOTitles() {
231
        return {
229
        return {
232
            get: id =>
230
            get: id =>
233
                this.get({
231
                this.httpClient.get({
234
                    endpoint: "eholdings/ebsco/titles/" + id,
232
                    endpoint: "eholdings/ebsco/titles/" + id,
235
                    headers: {
233
                    headers: {
236
                        "x-koha-embed": "resources,resources.package",
234
                        "x-koha-embed": "resources,resources.package",
Lines 242-255 export class ERMAPIClient extends HttpClient { Link Here
242
    get EBSCOResources() {
240
    get EBSCOResources() {
243
        return {
241
        return {
244
            get: id =>
242
            get: id =>
245
                this.get({
243
                this.httpClient.get({
246
                    endpoint: "eholdings/ebsco/resources/" + id,
244
                    endpoint: "eholdings/ebsco/resources/" + id,
247
                    headers: {
245
                    headers: {
248
                        "x-koha-embed": "title,package,vendor",
246
                        "x-koha-embed": "title,package,vendor",
249
                    },
247
                    },
250
                }),
248
                }),
251
            patch: (id, body) =>
249
            patch: (id, body) =>
252
                this.patch({
250
                this.httpClient.patch({
253
                    endpoint: "eholdings/ebsco/resources/" + id,
251
                    endpoint: "eholdings/ebsco/resources/" + id,
254
                    body,
252
                    body,
255
                }),
253
                }),
Lines 259-289 export class ERMAPIClient extends HttpClient { Link Here
259
    get usage_data_providers() {
257
    get usage_data_providers() {
260
        return {
258
        return {
261
            get: id =>
259
            get: id =>
262
                this.get({
260
                this.httpClient.get({
263
                    endpoint: "usage_data_providers/" + id,
261
                    endpoint: "usage_data_providers/" + id,
264
                }),
262
                }),
265
            getAll: query =>
263
            getAll: query =>
266
                this.getAll({
264
                this.httpClient.getAll({
267
                    endpoint: "usage_data_providers",
265
                    endpoint: "usage_data_providers",
268
                    query,
266
                    query,
269
                    query,
267
                    query,
270
                }),
268
                }),
271
            delete: id =>
269
            delete: id =>
272
                this.delete({
270
                this.httpClient.delete({
273
                    endpoint: "usage_data_providers/" + id,
271
                    endpoint: "usage_data_providers/" + id,
274
                }),
272
                }),
275
            create: usage_data_provider =>
273
            create: usage_data_provider =>
276
                this.post({
274
                this.httpClient.post({
277
                    endpoint: "usage_data_providers",
275
                    endpoint: "usage_data_providers",
278
                    body: usage_data_provider,
276
                    body: usage_data_provider,
279
                }),
277
                }),
280
            update: (usage_data_provider, id) =>
278
            update: (usage_data_provider, id) =>
281
                this.put({
279
                this.httpClient.put({
282
                    endpoint: "usage_data_providers/" + id,
280
                    endpoint: "usage_data_providers/" + id,
283
                    body: usage_data_provider,
281
                    body: usage_data_provider,
284
                }),
282
                }),
285
            process_SUSHI_response: (id, body) =>
283
            process_SUSHI_response: (id, body) =>
286
                this.post({
284
                this.httpClient.post({
287
                    endpoint:
285
                    endpoint:
288
                        "usage_data_providers/" +
286
                        "usage_data_providers/" +
289
                        id +
287
                        id +
Lines 291-307 export class ERMAPIClient extends HttpClient { Link Here
291
                    body: body,
289
                    body: body,
292
                }),
290
                }),
293
            process_COUNTER_file: (id, body) =>
291
            process_COUNTER_file: (id, body) =>
294
                this.post({
292
                this.httpClient.post({
295
                    endpoint:
293
                    endpoint:
296
                        "usage_data_providers/" + id + "/process_COUNTER_file",
294
                        "usage_data_providers/" + id + "/process_COUNTER_file",
297
                    body: body,
295
                    body: body,
298
                }),
296
                }),
299
            test: id =>
297
            test: id =>
300
                this.get({
298
                this.httpClient.get({
301
                    endpoint: "usage_data_providers/" + id + "/test_connection",
299
                    endpoint: "usage_data_providers/" + id + "/test_connection",
302
                }),
300
                }),
303
            count: (query = {}) =>
301
            count: (query = {}) =>
304
                this.count({
302
                this.httpClient.count({
305
                    endpoint:
303
                    endpoint:
306
                        "usage_data_providers?" +
304
                        "usage_data_providers?" +
307
                        new URLSearchParams({
305
                        new URLSearchParams({
Lines 316-326 export class ERMAPIClient extends HttpClient { Link Here
316
    get counter_files() {
314
    get counter_files() {
317
        return {
315
        return {
318
            delete: id =>
316
            delete: id =>
319
                this.delete({
317
                this.httpClient.delete({
320
                    endpoint: "counter_files/" + id,
318
                    endpoint: "counter_files/" + id,
321
                }),
319
                }),
322
            count: (query = {}) =>
320
            count: (query = {}) =>
323
                this.count({
321
                this.httpClient.count({
324
                    endpoint:
322
                    endpoint:
325
                        "counter_files?" +
323
                        "counter_files?" +
326
                        new URLSearchParams({
324
                        new URLSearchParams({
Lines 335-351 export class ERMAPIClient extends HttpClient { Link Here
335
    get default_usage_reports() {
333
    get default_usage_reports() {
336
        return {
334
        return {
337
            getAll: query =>
335
            getAll: query =>
338
                this.get({
336
                this.httpClient.get({
339
                    endpoint: "default_usage_reports",
337
                    endpoint: "default_usage_reports",
340
                    query,
338
                    query,
341
                }),
339
                }),
342
            create: default_usage_report =>
340
            create: default_usage_report =>
343
                this.post({
341
                this.httpClient.post({
344
                    endpoint: "default_usage_reports",
342
                    endpoint: "default_usage_reports",
345
                    body: default_usage_report,
343
                    body: default_usage_report,
346
                }),
344
                }),
347
            delete: id =>
345
            delete: id =>
348
                this.delete({
346
                this.httpClient.delete({
349
                    endpoint: "default_usage_reports/" + id,
347
                    endpoint: "default_usage_reports/" + id,
350
                }),
348
                }),
351
        };
349
        };
Lines 354-365 export class ERMAPIClient extends HttpClient { Link Here
354
    get usage_platforms() {
352
    get usage_platforms() {
355
        return {
353
        return {
356
            getAll: query =>
354
            getAll: query =>
357
                this.getAll({
355
                this.httpClient.getAll({
358
                    endpoint: "usage_platforms",
356
                    endpoint: "usage_platforms",
359
                    query: query,
357
                    query: query,
360
                }),
358
                }),
361
            count: (query = {}) =>
359
            count: (query = {}) =>
362
                this.count({
360
                this.httpClient.count({
363
                    endpoint:
361
                    endpoint:
364
                        "usage_platforms?" +
362
                        "usage_platforms?" +
365
                        new URLSearchParams({
363
                        new URLSearchParams({
Lines 374-385 export class ERMAPIClient extends HttpClient { Link Here
374
    get usage_items() {
372
    get usage_items() {
375
        return {
373
        return {
376
            getAll: query =>
374
            getAll: query =>
377
                this.getAll({
375
                this.httpClient.getAll({
378
                    endpoint: "usage_items",
376
                    endpoint: "usage_items",
379
                    query: query,
377
                    query: query,
380
                }),
378
                }),
381
            count: (query = {}) =>
379
            count: (query = {}) =>
382
                this.count({
380
                this.httpClient.count({
383
                    endpoint:
381
                    endpoint:
384
                        "usage_items?" +
382
                        "usage_items?" +
385
                        new URLSearchParams({
383
                        new URLSearchParams({
Lines 394-405 export class ERMAPIClient extends HttpClient { Link Here
394
    get usage_databases() {
392
    get usage_databases() {
395
        return {
393
        return {
396
            getAll: query =>
394
            getAll: query =>
397
                this.getAll({
395
                this.httpClient.getAll({
398
                    endpoint: "usage_databases",
396
                    endpoint: "usage_databases",
399
                    query: query,
397
                    query: query,
400
                }),
398
                }),
401
            count: (query = {}) =>
399
            count: (query = {}) =>
402
                this.count({
400
                this.httpClient.count({
403
                    endpoint:
401
                    endpoint:
404
                        "usage_databases?" +
402
                        "usage_databases?" +
405
                        new URLSearchParams({
403
                        new URLSearchParams({
Lines 414-425 export class ERMAPIClient extends HttpClient { Link Here
414
    get usage_titles() {
412
    get usage_titles() {
415
        return {
413
        return {
416
            getAll: query =>
414
            getAll: query =>
417
                this.getAll({
415
                this.httpClient.getAll({
418
                    endpoint: "usage_titles",
416
                    endpoint: "usage_titles",
419
                    query: query,
417
                    query: query,
420
                }),
418
                }),
421
            count: (query = {}) =>
419
            count: (query = {}) =>
422
                this.count({
420
                this.httpClient.count({
423
                    endpoint:
421
                    endpoint:
424
                        "usage_titles?" +
422
                        "usage_titles?" +
425
                        new URLSearchParams({
423
                        new URLSearchParams({
Lines 434-440 export class ERMAPIClient extends HttpClient { Link Here
434
    get counter_registry() {
432
    get counter_registry() {
435
        return {
433
        return {
436
            getAll: query =>
434
            getAll: query =>
437
                this.getAll({
435
                this.httpClient.getAll({
438
                    endpoint: "counter_registry",
436
                    endpoint: "counter_registry",
439
                    query,
437
                    query,
440
                }),
438
                }),
Lines 443-449 export class ERMAPIClient extends HttpClient { Link Here
443
    get sushi_service() {
441
    get sushi_service() {
444
        return {
442
        return {
445
            getAll: query =>
443
            getAll: query =>
446
                this.getAll({
444
                this.httpClient.getAll({
447
                    endpoint: "sushi_service",
445
                    endpoint: "sushi_service",
448
                    query,
446
                    query,
449
                }),
447
                }),
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/item-api-client.js (-6 / +4 lines)
Lines 1-8 Link Here
1
import HttpClient from "./http-client";
1
export class ItemAPIClient {
2
2
    constructor(HttpClient) {
3
export class ItemAPIClient extends HttpClient {
3
        this.httpClient = new HttpClient({
4
    constructor() {
5
        super({
6
            baseURL: "/api/v1/",
4
            baseURL: "/api/v1/",
7
        });
5
        });
8
    }
6
    }
Lines 10-16 export class ItemAPIClient extends HttpClient { Link Here
10
    get items() {
8
    get items() {
11
        return {
9
        return {
12
            getAll: (query, params, headers) =>
10
            getAll: (query, params, headers) =>
13
                this.getAll({
11
                this.httpClient.getAll({
14
                    endpoint: "items",
12
                    endpoint: "items",
15
                    query,
13
                    query,
16
                    params,
14
                    params,
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/localization-api-client.js (-8 / +6 lines)
Lines 1-9 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
import HttpClient from "./http-client.js";
2
export class LocalizationAPIClient {
3
3
    constructor(HttpClient) {
4
export class LocalizationAPIClient extends HttpClient {
4
        this.httpClient = new HttpClient({
5
    constructor() {
6
        super({
7
            baseURL: "/cgi-bin/koha/svc/localization",
5
            baseURL: "/cgi-bin/koha/svc/localization",
8
        });
6
        });
9
    }
7
    }
Lines 11-17 export class LocalizationAPIClient extends HttpClient { Link Here
11
    get localizations() {
9
    get localizations() {
12
        return {
10
        return {
13
            create: localization =>
11
            create: localization =>
14
                this.post({
12
                this.httpClient.post({
15
                    endpoint: "",
13
                    endpoint: "",
16
                    body: "entity=%s&code=%s&lang=%s&translation=%s".format(
14
                    body: "entity=%s&code=%s&lang=%s&translation=%s".format(
17
                        encodeURIComponent(localization.entity),
15
                        encodeURIComponent(localization.entity),
Lines 25-31 export class LocalizationAPIClient extends HttpClient { Link Here
25
                    },
23
                    },
26
                }),
24
                }),
27
            update: localization =>
25
            update: localization =>
28
                this.put({
26
                this.httpClient.put({
29
                    endpoint: "",
27
                    endpoint: "",
30
                    body: "id=%s&lang=%s&translation=%s".format(
28
                    body: "id=%s&lang=%s&translation=%s".format(
31
                        encodeURIComponent(localization.id),
29
                        encodeURIComponent(localization.id),
Lines 38-44 export class LocalizationAPIClient extends HttpClient { Link Here
38
                    },
36
                    },
39
                }),
37
                }),
40
            delete: id =>
38
            delete: id =>
41
                this.delete({
39
                this.httpClient.delete({
42
                    endpoint: "/?id=%s".format(id),
40
                    endpoint: "/?id=%s".format(id),
43
                    headers: {
41
                    headers: {
44
                        "Content-Type":
42
                        "Content-Type":
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js (-22 / +8 lines)
Lines 1-29 Link Here
1
/* keep tidy */
1
export class PatronAPIClient {
2
import HttpClient from "./http-client.js";
2
    constructor(HttpClient) {
3
3
        this.httpClient = new HttpClient({
4
export class PatronAPIClient extends HttpClient {
4
            baseURL: "/api/v1/",
5
    constructor() {
6
        super({
7
            baseURL: "/cgi-bin/koha/svc/",
8
        });
5
        });
9
    }
6
    }
10
7
11
    get lists() {
8
    get patrons() {
12
        return {
9
        return {
13
            add_patrons: ({ patron_ids, list_id, new_list_name }) =>
10
            get: id =>
14
                this.post({
11
                this.httpClient.get({
15
                    endpoint: "members/add_to_list",
12
                    endpoint: "patrons/" + id,
16
                    body: "add_to_patron_list=%s&new_patron_list=%s&%s".format(
17
                        list_id,
18
                        new_list_name,
19
                        patron_ids
20
                            .map(id => "borrowernumber=%s".format(id))
21
                            .join("&")
22
                    ),
23
                    headers: {
24
                        "Content-Type":
25
                            "application/x-www-form-urlencoded;charset=utf-8",
26
                    },
27
                }),
13
                }),
28
        };
14
        };
29
    }
15
    }
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/preservation-api-client.js (-29 / +27 lines)
Lines 1-8 Link Here
1
import HttpClient from "./http-client";
1
export class PreservationAPIClient {
2
2
    constructor(HttpClient) {
3
export class PreservationAPIClient extends HttpClient {
3
        this.httpClient = new HttpClient({
4
    constructor() {
5
        super({
6
            baseURL: "/api/v1/preservation/",
4
            baseURL: "/api/v1/preservation/",
7
        });
5
        });
8
    }
6
    }
Lines 10-16 export class PreservationAPIClient extends HttpClient { Link Here
10
    get config() {
8
    get config() {
11
        return {
9
        return {
12
            get: () =>
10
            get: () =>
13
                this.get({
11
                this.httpClient.get({
14
                    endpoint: "config",
12
                    endpoint: "config",
15
                }),
13
                }),
16
        };
14
        };
Lines 19-25 export class PreservationAPIClient extends HttpClient { Link Here
19
    get trains() {
17
    get trains() {
20
        return {
18
        return {
21
            get: id =>
19
            get: id =>
22
                this.get({
20
                this.httpClient.get({
23
                    endpoint: "trains/" + id,
21
                    endpoint: "trains/" + id,
24
                    headers: {
22
                    headers: {
25
                        "x-koha-embed":
23
                        "x-koha-embed":
Lines 27-33 export class PreservationAPIClient extends HttpClient { Link Here
27
                    },
25
                    },
28
                }),
26
                }),
29
            getAll: (query = {}) =>
27
            getAll: (query = {}) =>
30
                this.get({
28
                this.httpClient.get({
31
                    endpoint:
29
                    endpoint:
32
                        "trains?" +
30
                        "trains?" +
33
                        new URLSearchParams({
31
                        new URLSearchParams({
Lines 36-56 export class PreservationAPIClient extends HttpClient { Link Here
36
                        }),
34
                        }),
37
                }),
35
                }),
38
            delete: id =>
36
            delete: id =>
39
                this.delete({
37
                this.httpClient.delete({
40
                    endpoint: "trains/" + id,
38
                    endpoint: "trains/" + id,
41
                }),
39
                }),
42
            create: train =>
40
            create: train =>
43
                this.post({
41
                this.httpClient.post({
44
                    endpoint: "trains",
42
                    endpoint: "trains",
45
                    body: train,
43
                    body: train,
46
                }),
44
                }),
47
            update: (train, id) =>
45
            update: (train, id) =>
48
                this.put({
46
                this.httpClient.put({
49
                    endpoint: "trains/" + id,
47
                    endpoint: "trains/" + id,
50
                    body: train,
48
                    body: train,
51
                }),
49
                }),
52
            count: (query = {}) =>
50
            count: (query = {}) =>
53
                this.count({
51
                this.httpClient.count({
54
                    endpoint:
52
                    endpoint:
55
                        "trains?" +
53
                        "trains?" +
56
                        new URLSearchParams({
54
                        new URLSearchParams({
Lines 65-78 export class PreservationAPIClient extends HttpClient { Link Here
65
    get processings() {
63
    get processings() {
66
        return {
64
        return {
67
            get: id =>
65
            get: id =>
68
                this.get({
66
                this.httpClient.get({
69
                    endpoint: "processings/" + id,
67
                    endpoint: "processings/" + id,
70
                    headers: {
68
                    headers: {
71
                        "x-koha-embed": "attributes",
69
                        "x-koha-embed": "attributes",
72
                    },
70
                    },
73
                }),
71
                }),
74
            getAll: query =>
72
            getAll: query =>
75
                this.get({
73
                this.httpClient.get({
76
                    endpoint:
74
                    endpoint:
77
                        "processings?" +
75
                        "processings?" +
78
                        new URLSearchParams({
76
                        new URLSearchParams({
Lines 82-102 export class PreservationAPIClient extends HttpClient { Link Here
82
                }),
80
                }),
83
81
84
            delete: id =>
82
            delete: id =>
85
                this.delete({
83
                this.httpClient.delete({
86
                    endpoint: "processings/" + id,
84
                    endpoint: "processings/" + id,
87
                }),
85
                }),
88
            create: processing =>
86
            create: processing =>
89
                this.post({
87
                this.httpClient.post({
90
                    endpoint: "processings",
88
                    endpoint: "processings",
91
                    body: processing,
89
                    body: processing,
92
                }),
90
                }),
93
            update: (processing, id) =>
91
            update: (processing, id) =>
94
                this.put({
92
                this.httpClient.put({
95
                    endpoint: "processings/" + id,
93
                    endpoint: "processings/" + id,
96
                    body: processing,
94
                    body: processing,
97
                }),
95
                }),
98
            count: (query = {}) =>
96
            count: (query = {}) =>
99
                this.count({
97
                this.httpClient.count({
100
                    endpoint:
98
                    endpoint:
101
                        "processings?" +
99
                        "processings?" +
102
                        new URLSearchParams({
100
                        new URLSearchParams({
Lines 111-117 export class PreservationAPIClient extends HttpClient { Link Here
111
    get train_items() {
109
    get train_items() {
112
        return {
110
        return {
113
            get: (train_id, id) =>
111
            get: (train_id, id) =>
114
                this.get({
112
                this.httpClient.get({
115
                    endpoint: "trains/" + train_id + "/items/" + id,
113
                    endpoint: "trains/" + train_id + "/items/" + id,
116
                    headers: {
114
                    headers: {
117
                        "x-koha-embed":
115
                        "x-koha-embed":
Lines 119-149 export class PreservationAPIClient extends HttpClient { Link Here
119
                    },
117
                    },
120
                }),
118
                }),
121
            delete: (train_id, id) =>
119
            delete: (train_id, id) =>
122
                this.delete({
120
                this.httpClient.delete({
123
                    endpoint: "trains/" + train_id + "/items/" + id,
121
                    endpoint: "trains/" + train_id + "/items/" + id,
124
                }),
122
                }),
125
            create: (train_item, train_id) =>
123
            create: (train_item, train_id) =>
126
                this.post({
124
                this.httpClient.post({
127
                    endpoint: "trains/" + train_id + "/items",
125
                    endpoint: "trains/" + train_id + "/items",
128
                    body: train_item,
126
                    body: train_item,
129
                }),
127
                }),
130
            createAll: (train_items, train_id) =>
128
            createAll: (train_items, train_id) =>
131
                this.post({
129
                this.httpClient.post({
132
                    endpoint: "trains/" + train_id + "/items/batch",
130
                    endpoint: "trains/" + train_id + "/items/batch",
133
                    body: train_items,
131
                    body: train_items,
134
                }),
132
                }),
135
            copy: (new_train_id, train_id, id) =>
133
            copy: (new_train_id, train_id, id) =>
136
                this.post({
134
                this.httpClient.post({
137
                    endpoint: "trains/" + train_id + "/items/" + id + "/copy",
135
                    endpoint: "trains/" + train_id + "/items/" + id + "/copy",
138
                    body: { train_id: new_train_id },
136
                    body: { train_id: new_train_id },
139
                }),
137
                }),
140
            update: (train_item, train_id, id) =>
138
            update: (train_item, train_id, id) =>
141
                this.put({
139
                this.httpClient.put({
142
                    endpoint: "trains/" + train_id + "/items/" + id,
140
                    endpoint: "trains/" + train_id + "/items/" + id,
143
                    body: train_item,
141
                    body: train_item,
144
                }),
142
                }),
145
            count: (train_id, query = {}) =>
143
            count: (train_id, query = {}) =>
146
                this.count({
144
                this.httpClient.count({
147
                    endpoint:
145
                    endpoint:
148
                        "trains/" +
146
                        "trains/" +
149
                        train_id +
147
                        train_id +
Lines 169-175 export class PreservationAPIClient extends HttpClient { Link Here
169
                    _per_page: 1,
167
                    _per_page: 1,
170
                    q: JSON.stringify(q),
168
                    q: JSON.stringify(q),
171
                };
169
                };
172
                return this.get({
170
                return this.httpClient.get({
173
                    endpoint:
171
                    endpoint:
174
                        "waiting-list/items?" + new URLSearchParams(params),
172
                        "waiting-list/items?" + new URLSearchParams(params),
175
                    headers: {
173
                    headers: {
Lines 180-195 export class PreservationAPIClient extends HttpClient { Link Here
180
                });
178
                });
181
            },
179
            },
182
            delete: id =>
180
            delete: id =>
183
                this.delete({
181
                this.httpClient.delete({
184
                    endpoint: "waiting-list/items/" + id,
182
                    endpoint: "waiting-list/items/" + id,
185
                }),
183
                }),
186
            createAll: items =>
184
            createAll: items =>
187
                this.post({
185
                this.httpClient.post({
188
                    endpoint: "waiting-list/items",
186
                    endpoint: "waiting-list/items",
189
                    body: items,
187
                    body: items,
190
                }),
188
                }),
191
            count: (query = {}) =>
189
            count: (query = {}) =>
192
                this.count({
190
                this.httpClient.count({
193
                    endpoint:
191
                    endpoint:
194
                        "waiting-list/items?" +
192
                        "waiting-list/items?" +
195
                        new URLSearchParams({
193
                        new URLSearchParams({
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/recall-api-client.js (-10 / +8 lines)
Lines 1-9 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
import HttpClient from "./http-client.js";
2
export class RecallAPIClient {
3
3
    constructor(HttpClient) {
4
export class RecallAPIClient extends HttpClient {
4
        this.httpClient = new HttpClient({
5
    constructor() {
6
        super({
7
            baseURL: "/cgi-bin/koha/svc/recall",
5
            baseURL: "/cgi-bin/koha/svc/recall",
8
        });
6
        });
9
    }
7
    }
Lines 11-17 export class RecallAPIClient extends HttpClient { Link Here
11
    get recalls() {
9
    get recalls() {
12
        return {
10
        return {
13
            cancel: recall_id =>
11
            cancel: recall_id =>
14
                this.post({
12
                this.httpClient.post({
15
                    endpoint: "",
13
                    endpoint: "",
16
                    body: "recall_id=%s&op=%s".format(recall_id, "cud-cancel"),
14
                    body: "recall_id=%s&op=%s".format(recall_id, "cud-cancel"),
17
                    headers: {
15
                    headers: {
Lines 20-26 export class RecallAPIClient extends HttpClient { Link Here
20
                    },
18
                    },
21
                }),
19
                }),
22
            expire: recall_id =>
20
            expire: recall_id =>
23
                this.post({
21
                this.httpClient.post({
24
                    endpoint: "",
22
                    endpoint: "",
25
                    body: "recall_id=%s&op=%s".format(recall_id, "cud-expire"),
23
                    body: "recall_id=%s&op=%s".format(recall_id, "cud-expire"),
26
                    headers: {
24
                    headers: {
Lines 30-36 export class RecallAPIClient extends HttpClient { Link Here
30
                }),
28
                }),
31
29
32
            revert: recall_id =>
30
            revert: recall_id =>
33
                this.post({
31
                this.httpClient.post({
34
                    endpoint: "",
32
                    endpoint: "",
35
                    body: "recall_id=%s&op=%s".format(recall_id, "cud-revert"),
33
                    body: "recall_id=%s&op=%s".format(recall_id, "cud-revert"),
36
                    headers: {
34
                    headers: {
Lines 40-46 export class RecallAPIClient extends HttpClient { Link Here
40
                }),
38
                }),
41
39
42
            overdue: recall_id =>
40
            overdue: recall_id =>
43
                this.post({
41
                this.httpClient.post({
44
                    endpoint: "",
42
                    endpoint: "",
45
                    body: "recall_id=%s&op=%s".format(recall_id, "cud-overdue"),
43
                    body: "recall_id=%s&op=%s".format(recall_id, "cud-overdue"),
46
                    headers: {
44
                    headers: {
Lines 50-56 export class RecallAPIClient extends HttpClient { Link Here
50
                }),
48
                }),
51
49
52
            transit: recall_id =>
50
            transit: recall_id =>
53
                this.post({
51
                this.httpClient.post({
54
                    endpoint: "",
52
                    endpoint: "",
55
                    body: "recall_id=%s&op=%s".format(recall_id, "cud-transit"),
53
                    body: "recall_id=%s&op=%s".format(recall_id, "cud-transit"),
56
                    headers: {
54
                    headers: {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/record-sources-api-client.js (-11 / +9 lines)
Lines 1-8 Link Here
1
import HttpClient from "./http-client";
1
export class RecordSourcesAPIClient {
2
2
    constructor(HttpClient) {
3
export class RecordSourcesAPIClient extends HttpClient {
3
        this.httpClient = new HttpClient({
4
    constructor() {
5
        super({
6
            baseURL: "/api/v1/record_sources",
4
            baseURL: "/api/v1/record_sources",
7
        });
5
        });
8
    }
6
    }
Lines 10-41 export class RecordSourcesAPIClient extends HttpClient { Link Here
10
    get record_sources() {
8
    get record_sources() {
11
        return {
9
        return {
12
            create: record_source =>
10
            create: record_source =>
13
                this.post({
11
                this.httpClient.post({
14
                    endpoint: "",
12
                    endpoint: "",
15
                    body: record_source,
13
                    body: record_source,
16
                }),
14
                }),
17
            delete: id =>
15
            delete: id =>
18
                this.delete({
16
                this.httpClient.delete({
19
                    endpoint: "/" + id,
17
                    endpoint: "/" + id,
20
                }),
18
                }),
21
            update: (record_source, id) =>
19
            update: (record_source, id) =>
22
                this.put({
20
                this.httpClient.put({
23
                    endpoint: "/" + id,
21
                    endpoint: "/" + id,
24
                    body: record_source,
22
                    body: record_source,
25
                }),
23
                }),
26
            get: id =>
24
            get: id =>
27
                this.get({
25
                this.httpClient.get({
28
                    endpoint: "/" + id,
26
                    endpoint: "/" + id,
29
                }),
27
                }),
30
            getAll: (query, params) =>
28
            getAll: (query, params) =>
31
                this.getAll({
29
                this.httpClient.getAll({
32
                    endpoint: "/",
30
                    endpoint: "/",
33
                    query,
31
                    query,
34
                    params,
32
                    params,
35
                    headers: {},
33
                    headers: {},
36
                }),
34
                }),
37
            count: (query = {}) =>
35
            count: (query = {}) =>
38
                this.count({
36
                this.httpClient.count({
39
                    endpoint:
37
                    endpoint:
40
                        "?" +
38
                        "?" +
41
                        new URLSearchParams({
39
                        new URLSearchParams({
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js (-10 / +9 lines)
Lines 1-9 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
import HttpClient from "./http-client.js";
2
export class SysprefAPIClient {
3
3
    constructor(HttpClient) {
4
export class SysprefAPIClient extends HttpClient {
4
        this.httpClient = new HttpClient({
5
    constructor() {
6
        super({
7
            baseURL: "/cgi-bin/koha/svc/config/systempreferences",
5
            baseURL: "/cgi-bin/koha/svc/config/systempreferences",
8
        });
6
        });
9
    }
7
    }
Lines 11-25 export class SysprefAPIClient extends HttpClient { Link Here
11
    get sysprefs() {
9
    get sysprefs() {
12
        return {
10
        return {
13
            get: variable =>
11
            get: variable =>
14
                this.get({
12
                this.httpClient.get({
15
                    endpoint: "/?pref=" + variable,
13
                    endpoint: "/?pref=" + variable,
16
                }),
14
                }),
17
            update: (variable, value) =>
15
            update: (variable, value) =>
18
                this.post({
16
                this.httpClient.post({
19
                    endpoint: "",
17
                    endpoint: "",
20
                    body: "pref_%s=%s".format(
18
                    body: "pref_%s=%s&csrf_token=%s".format(
21
                        encodeURIComponent(variable),
19
                        encodeURIComponent(variable),
22
                        encodeURIComponent(value)
20
                        encodeURIComponent(value),
21
                        csrf_token
23
                    ),
22
                    ),
24
                    headers: {
23
                    headers: {
25
                        "Content-Type":
24
                        "Content-Type":
Lines 27-33 export class SysprefAPIClient extends HttpClient { Link Here
27
                    },
26
                    },
28
                }),
27
                }),
29
            update_all: sysprefs =>
28
            update_all: sysprefs =>
30
                this.post({
29
                this.httpClient.post({
31
                    endpoint: "",
30
                    endpoint: "",
32
                    body: Object.keys(sysprefs)
31
                    body: Object.keys(sysprefs)
33
                        .map(variable =>
32
                        .map(variable =>
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/ticket-api-client.js (-8 / +6 lines)
Lines 1-9 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
import HttpClient from "./http-client.js";
2
export class TicketAPIClient {
3
3
    constructor(HttpClient) {
4
export class TicketAPIClient extends HttpClient {
4
        this.httpClient = new HttpClient({
5
    constructor() {
6
        super({
7
            baseURL: "/cgi-bin/koha/svc/",
5
            baseURL: "/cgi-bin/koha/svc/",
8
        });
6
        });
9
    }
7
    }
Lines 11-17 export class TicketAPIClient extends HttpClient { Link Here
11
    get tickets() {
9
    get tickets() {
12
        return {
10
        return {
13
            mark_as_viewed: ticket_id =>
11
            mark_as_viewed: ticket_id =>
14
                this.post({
12
                this.httpClient.post({
15
                    endpoint: "problem_reports",
13
                    endpoint: "problem_reports",
16
                    body: "report_id=%s&op=%s".format(ticket_id, "cud-viewed"),
14
                    body: "report_id=%s&op=%s".format(ticket_id, "cud-viewed"),
17
                    headers: {
15
                    headers: {
Lines 20-26 export class TicketAPIClient extends HttpClient { Link Here
20
                    },
18
                    },
21
                }),
19
                }),
22
            mark_as_closed: ticket_id =>
20
            mark_as_closed: ticket_id =>
23
                this.post({
21
                this.httpClient.post({
24
                    endpoint: "problem_reports",
22
                    endpoint: "problem_reports",
25
                    body: "report_id=%s&op=%s".format(ticket_id, "cud-closed"),
23
                    body: "report_id=%s&op=%s".format(ticket_id, "cud-closed"),
26
                    headers: {
24
                    headers: {
Lines 29-35 export class TicketAPIClient extends HttpClient { Link Here
29
                    },
27
                    },
30
                }),
28
                }),
31
            mark_as_new: ticket_id =>
29
            mark_as_new: ticket_id =>
32
                this.post({
30
                this.httpClient.post({
33
                    endpoint: "problem_reports",
31
                    endpoint: "problem_reports",
34
                    body: "report_id=%s&op=%s".format(ticket_id, "cud-new"),
32
                    body: "report_id=%s&op=%s".format(ticket_id, "cud-new"),
35
                    headers: {
33
                    headers: {
(-)a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js (-1 / +1 lines)
Lines 49-55 KOHA.Preferences = { Link Here
49
            return;
49
            return;
50
        }
50
        }
51
        KOHA.AJAX.MarkRunning($(form).find(".save-all"), __("Saving..."));
51
        KOHA.AJAX.MarkRunning($(form).find(".save-all"), __("Saving..."));
52
        const client = APIClient.syspref;
52
        const client = APIClient.sysprefs;
53
        client.sysprefs
53
        client.sysprefs
54
            .update_all(sysprefs)
54
            .update_all(sysprefs)
55
            .then(
55
            .then(
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js (-18 / +20 lines)
Lines 1-21 Link Here
1
import ERMAPIClient from "./erm-api-client";
1
import HttpClient from "./http-client";
2
import PatronAPIClient from "./patron-api-client";
2
3
import AcquisitionAPIClient from "./acquisition-api-client";
3
import ERMAPIClient from "./../../fetch/erm-api-client";
4
import AdditionalFieldsAPIClient from "./additional-fields-api-client";
4
import PatronAPIClient from "./../../fetch/patron-api-client";
5
import AVAPIClient from "./authorised-values-api-client";
5
import AcquisitionAPIClient from "./../../fetch/acquisition-api-client";
6
import ItemAPIClient from "./item-api-client";
6
import AdditionalFieldsAPIClient from "./../../fetch/additional-fields-api-client";
7
import RecordSourcesAPIClient from "./record-sources-api-client";
7
import AVAPIClient from "./../../fetch/authorised-values-api-client";
8
import SysprefAPIClient from "./system-preferences-api-client";
8
import ItemAPIClient from "./../../fetch/item-api-client";
9
import PreservationAPIClient from "./preservation-api-client";
9
import RecordSourcesAPIClient from "./../../fetch/record-sources-api-client";
10
import SysprefAPIClient from "./../../fetch/system-preferences-api-client";
11
import PreservationAPIClient from "./../../fetch/preservation-api-client";
10
12
11
export const APIClient = {
13
export const APIClient = {
12
    erm: new ERMAPIClient(),
14
    erm: new ERMAPIClient(HttpClient),
13
    patron: new PatronAPIClient(),
15
    patron: new PatronAPIClient(HttpClient),
14
    acquisition: new AcquisitionAPIClient(),
16
    acquisition: new AcquisitionAPIClient(HttpClient),
15
    additional_fields: new AdditionalFieldsAPIClient(),
17
    additional_fields: new AdditionalFieldsAPIClient(HttpClient),
16
    authorised_values: new AVAPIClient(),
18
    authorised_values: new AVAPIClient(HttpClient),
17
    item: new ItemAPIClient(),
19
    item: new ItemAPIClient(HttpClient),
18
    sysprefs: new SysprefAPIClient(),
20
    sysprefs: new SysprefAPIClient(HttpClient),
19
    preservation: new PreservationAPIClient(),
21
    preservation: new PreservationAPIClient(HttpClient),
20
    record_sources: new RecordSourcesAPIClient(),
22
    record_sources: new RecordSourcesAPIClient(HttpClient),
21
};
23
};
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/authorised-values-api-client.js (-30 lines)
Lines 1-30 Link Here
1
import HttpClient from "./http-client";
2
3
export class AVAPIClient extends HttpClient {
4
    constructor() {
5
        super({
6
            baseURL: "/api/v1/authorised_value_categories",
7
        });
8
    }
9
10
    get values() {
11
        return {
12
            get: category =>
13
                this.get({
14
                    endpoint: `/${category}/authorised_values`,
15
                }),
16
            getCategoriesWithValues: cat_array =>
17
                this.get({
18
                    endpoint:
19
                        '?q={"me.category_name":[' +
20
                        cat_array.join(", ") +
21
                        "]}",
22
                    headers: {
23
                        "x-koha-embed": "authorised_values",
24
                    },
25
                }),
26
        };
27
    }
28
}
29
30
export default AVAPIClient;
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js (-20 lines)
Lines 1-20 Link Here
1
import HttpClient from "./http-client";
2
3
export class PatronAPIClient extends HttpClient {
4
    constructor() {
5
        super({
6
            baseURL: "/api/v1/",
7
        });
8
    }
9
10
    get patrons() {
11
        return {
12
            get: id =>
13
                this.get({
14
                    endpoint: "patrons/" + id,
15
                }),
16
        };
17
    }
18
}
19
20
export default PatronAPIClient;
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js (-34 lines)
Lines 1-33 Link Here
1
import HttpClient from "./http-client";
2
3
export class SysprefAPIClient extends HttpClient {
4
    constructor() {
5
        super({
6
            baseURL: "/cgi-bin/koha/svc/config/systempreferences",
7
        });
8
    }
9
10
    get sysprefs() {
11
        return {
12
            get: variable =>
13
                this.get({
14
                    endpoint: "/?pref=" + variable,
15
                }),
16
            update: (variable, value) =>
17
                this.post({
18
                    endpoint: "",
19
                    body: "pref_%s=%s&csrf_token=%s".format(
20
                        variable,
21
                        value,
22
                        csrf_token
23
                    ),
24
                    headers: {
25
                        "Content-Type":
26
                            "application/x-www-form-urlencoded;charset=utf-8",
27
                    },
28
                }),
29
        };
30
    }
31
}
32
33
export default SysprefAPIClient;
34
- 

Return to bug 38993