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

(-)a/Koha/REST/V1/ERM.pm (+37 lines)
Lines 20-25 use Modern::Perl; Link Here
20
use Mojo::Base 'Mojolicious::Controller';
20
use Mojo::Base 'Mojolicious::Controller';
21
21
22
use Koha::Patrons;
22
use Koha::Patrons;
23
use Koha::ERM::Agreements;
24
use Koha::ERM::Licenses;
25
use Koha::ERM::Documents;
26
use Koha::ERM::EHoldings::Titles;
27
use Koha::ERM::EHoldings::Packages;
28
use Koha::ERM::EUsage::UsageDataProviders;
23
29
24
use Try::Tiny qw( catch try );
30
use Try::Tiny qw( catch try );
25
31
Lines 52-57 sub config { Link Here
52
    );
58
    );
53
}
59
}
54
60
61
=head3 counts
62
63
Return the ERM resources counts
64
65
=cut
66
67
sub counts {
68
    my $c = shift->openapi->valid_input or return;
69
70
    my $agreements_count           = Koha::ERM::Agreements->search->count;
71
    my $documents_count            = Koha::ERM::Documents->search->count;
72
    my $eholdings_packages_count   = Koha::ERM::EHoldings::Packages->search->count;
73
    my $eholdings_titles_count     = Koha::ERM::EHoldings::Titles->search->count;
74
    my $licenses_count             = Koha::ERM::Licenses->search->count;
75
    my $usage_data_providers_count = Koha::ERM::EUsage::UsageDataProviders->search->count;
76
77
    return $c->render(
78
        status  => 200,
79
        openapi => {
80
            counts => {
81
                agreements_count           => $agreements_count,
82
                documents_count            => $documents_count,
83
                eholdings_packages_count   => $eholdings_packages_count,
84
                eholdings_titles_count     => $eholdings_titles_count,
85
                licenses_count             => $licenses_count,
86
                usage_data_providers_count => $usage_data_providers_count,
87
            }
88
        },
89
    );
90
}
91
55
=head3 list_users
92
=head3 list_users
56
93
57
Return the list of possible ERM users
94
Return the list of possible ERM users
(-)a/api/v1/swagger/definitions/erm_counts.yaml (+7 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  counts:
5
    type: object
6
    description: List of ERM resources counts
7
additionalProperties: false
(-)a/api/v1/swagger/paths/erm_counts.yaml (+38 lines)
Line 0 Link Here
1
---
2
/erm/counts:
3
  get:
4
    x-mojo-to: ERM#counts
5
    operationId: getERMcounts
6
    description: This resource returns a list of ERM resources counts
7
    summary: get the ERM counts
8
    tags:
9
      - erm_counts
10
    produces:
11
      - application/json
12
    responses:
13
      200:
14
        description: The ERM counts
15
        schema:
16
          $ref: "../swagger.yaml#/definitions/erm_counts"
17
      400:
18
        description: Bad request
19
        schema:
20
          $ref: "../swagger.yaml#/definitions/error"
21
      403:
22
        description: Access forbidden
23
        schema:
24
          $ref: "../swagger.yaml#/definitions/error"
25
      500:
26
        description: |
27
          Internal server error. Possible `error_code` attribute values:
28
29
          * `internal_server_error`
30
        schema:
31
          $ref: "../swagger.yaml#/definitions/error"
32
      503:
33
        description: Under maintenance
34
        schema:
35
          $ref: "../swagger.yaml#/definitions/error"
36
    x-koha-authorization:
37
      permissions:
38
        erm: 1
(-)a/api/v1/swagger/swagger.yaml (+7 lines)
Lines 50-55 definitions: Link Here
50
    $ref: ./definitions/desk.yaml
50
    $ref: ./definitions/desk.yaml
51
  edifact_file:
51
  edifact_file:
52
    $ref: ./definitions/edifact_file.yaml
52
    $ref: ./definitions/edifact_file.yaml
53
  erm_counts:
54
    $ref: ./definitions/erm_counts.yaml
53
  erm_config:
55
  erm_config:
54
    $ref: ./definitions/erm_config.yaml
56
    $ref: ./definitions/erm_config.yaml
55
  erm_agreement:
57
  erm_agreement:
Lines 335-340 paths: Link Here
335
    $ref: "./paths/deleted_biblios.yaml#/~1deleted~1biblios~1{biblio_id}"
337
    $ref: "./paths/deleted_biblios.yaml#/~1deleted~1biblios~1{biblio_id}"
336
  /erm/config:
338
  /erm/config:
337
    $ref: ./paths/erm_config.yaml#/~1erm~1config
339
    $ref: ./paths/erm_config.yaml#/~1erm~1config
340
  /erm/counts:
341
    $ref: ./paths/erm_counts.yaml#/~1erm~1counts
338
  /erm/agreements:
342
  /erm/agreements:
339
    $ref: ./paths/erm_agreements.yaml#/~1erm~1agreements
343
    $ref: ./paths/erm_agreements.yaml#/~1erm~1agreements
340
  "/erm/agreements/{agreement_id}":
344
  "/erm/agreements/{agreement_id}":
Lines 1204-1209 tags: Link Here
1204
  - description: "Manage ERM configuration\n"
1208
  - description: "Manage ERM configuration\n"
1205
    name: erm_config
1209
    name: erm_config
1206
    x-displayName: ERM configuration
1210
    x-displayName: ERM configuration
1211
  - description: "Get ERM resources counts\n"
1212
    name: erm_counts
1213
    x-displayName: ERM counts
1207
  - description: "Manage ERM counter files\n"
1214
  - description: "Manage ERM counter files\n"
1208
    name: erm_counter_files
1215
    name: erm_counter_files
1209
    x-displayName: ERM counter files
1216
    x-displayName: ERM counter files
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/erm-api-client.js (-1 / +9 lines)
Lines 447-452 export class ERMAPIClient { Link Here
447
                }),
447
                }),
448
        };
448
        };
449
    }
449
    }
450
451
    get counts() {
452
        return {
453
            get: () =>
454
                this.httpClient.get({
455
                    endpoint: "counts",
456
                }),
457
        };
458
    }
450
}
459
}
451
460
452
export default ERMAPIClient;
461
export default ERMAPIClient;
453
- 

Return to bug 39320