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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ModuleDashboard/Widgets/ERMCounts.vue (-7 / +33 lines)
Lines 104-116 export default { Link Here
104
104
105
        async function getCounts() {
105
        async function getCounts() {
106
            try {
106
            try {
107
                const response = await APIClient.erm.counts.get();
107
                const endpoints = [
108
                    {
109
                        name: "agreements_count",
110
                        endpoint: APIClient.erm.agreements.count(),
111
                    },
112
                    {
113
                        name: "licenses_count",
114
                        endpoint: APIClient.erm.licenses.count(),
115
                    },
116
                    {
117
                        name: "eholdings_packages_count",
118
                        endpoint: APIClient.erm.localPackages.count(),
119
                    },
120
                    {
121
                        name: "eholdings_titles_count",
122
                        endpoint: APIClient.erm.localTitles.count(),
123
                    },
124
                    {
125
                        name: "usage_data_providers_count",
126
                        endpoint: APIClient.erm.usage_data_providers.count(),
127
                    },
128
                ];
108
129
109
                Object.keys(response.counts).forEach(key => {
130
                endpoints.forEach(({ name, endpoint }) => {
110
                    const item = countDefinitions.find(i => i.name === key);
131
                    endpoint
111
                    if (item) {
132
                        .then(response => {
112
                        item.count = response.counts[key];
133
                            const definition = countDefinitions.find(i => i.name === name);
113
                    }
134
                            if (definition) {
135
                                definition.count = response;
136
                            }
137
                        })
138
                        .catch(error => {
139
                            console.error(`Error fetching ${name}:`, error);
140
                        });
114
                });
141
                });
115
142
116
                baseWidget.loading.value = false;
143
                baseWidget.loading.value = false;
117
- 

Return to bug 39320