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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsDataProviderResource.vue (+30 lines)
Line 0 Link Here
1
<script>
2
import BaseResource from "../BaseResource.vue"
3
import { APIClient } from "../../fetch/api-client.js"
4
5
export default {
6
    extends: BaseResource,
7
    setup(props) {
8
        return {
9
            ...BaseResource.setup({
10
                resource_name: "usage_data_provider",
11
                name_attr: "name",
12
                id_attr: "erm_usage_data_provider_id",
13
                show_component: "UsageStatisticsDataProvidersShow",
14
                list_component: "UsageStatisticsDataProvidersList",
15
                add_component: "UsageStatisticsDataProvidersFormAdd",
16
                edit_component: "UsageStatisticsDataProvidersFormAddEdit",
17
                api_client: APIClient.erm.usage_data_providers,
18
                resource_table_url:
19
                    APIClient.erm._baseURL + "usage_data_providers",
20
                i18n: {
21
                    display_name: __("Data provider"),
22
                },
23
            }),
24
            //UsageStatisticsDataProviderResource specific setup here
25
        }
26
    },
27
    methods: {},
28
    name: "UsageStatisticsDataProviderResource",
29
}
30
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsDataProvidersList.vue (-82 / +24 lines)
Lines 2-29 Link Here
2
    <div v-if="!initialized">{{ $__("Loading") }}</div>
2
    <div v-if="!initialized">{{ $__("Loading") }}</div>
3
    <div v-else id="usage_data_providers_list">
3
    <div v-else id="usage_data_providers_list">
4
        <template class="toolbar_options">
4
        <template class="toolbar_options">
5
            <Toolbar />
5
            <Toolbar>
6
            <div
6
                <ToolbarButton
7
                v-if="usage_data_provider_count > 0"
7
                    action="add"
8
                id="toolbar"
8
                    @go-to-add-resource="goToResourceAdd"
9
                class="btn-toolbar"
9
                    :title="$__('New data provider')"
10
            >
10
                />
11
                <router-link
11
                <ToolbarButton
12
                    v-if="usage_data_provider_count > 0"
12
                    :to="{ name: 'UsageStatisticsDataProvidersSummary' }"
13
                    :to="{ name: 'UsageStatisticsDataProvidersSummary' }"
13
                    class="btn btn-default"
14
                    icon="list"
14
                >
15
                    :title="$__('Data providers summary')"
15
                    <i class="fa fa-list"></i>
16
                />
16
                    {{ $__("Data providers summary") }}</router-link
17
            </Toolbar>
17
                >
18
            </div>
19
        </template>
18
        </template>
20
        <div v-if="usage_data_provider_count > 0" class="page-section">
19
        <div v-if="usage_data_provider_count > 0" class="page-section">
21
            <KohaTable
20
            <KohaTable
22
                ref="table"
21
                ref="table"
23
                v-bind="tableOptions"
22
                v-bind="tableOptions"
24
                @show="show_usage_data_provider"
23
                @show="goToResourceShow"
25
                @edit="edit_usage_data_provider"
24
                @edit="goToResourceEdit"
26
                @delete="delete_usage_data_provider"
25
                @delete="doResourceDelete"
27
                @run_now="run_harvester_now"
26
                @run_now="run_harvester_now"
28
                @test_connection="test_harvester_connection"
27
                @test_connection="test_harvester_connection"
29
            ></KohaTable>
28
            ></KohaTable>
Lines 35-61 Link Here
35
</template>
34
</template>
36
35
37
<script>
36
<script>
38
import Toolbar from "./UsageStatisticsDataProvidersToolbar.vue"
37
import Toolbar from "../Toolbar.vue"
38
import ToolbarButton from "../ToolbarButton.vue"
39
import { inject, ref } from "vue"
39
import { inject, ref } from "vue"
40
import { APIClient } from "../../fetch/api-client.js"
40
import { APIClient } from "../../fetch/api-client.js"
41
import KohaTable from "../KohaTable.vue"
41
import KohaTable from "../KohaTable.vue"
42
import UsageStatisticsDataProviderResource from "./UsageStatisticsDataProviderResource.vue"
42
43
43
export default {
44
export default {
45
    extends: UsageStatisticsDataProviderResource,
44
    setup() {
46
    setup() {
45
        const AVStore = inject("AVStore") // Left in for future permissions fixes
47
        const AVStore = inject("AVStore") // Left in for future permissions fixes
46
        const { get_lib_from_av, map_av_dt_filter } = AVStore
48
        const { get_lib_from_av, map_av_dt_filter } = AVStore
47
49
48
        const { setConfirmationDialog, setMessage, setWarning } =
49
            inject("mainStore")
50
51
        const table = ref()
50
        const table = ref()
52
51
53
        return {
52
        return {
53
            ...UsageStatisticsDataProviderResource.setup(),
54
            get_lib_from_av,
54
            get_lib_from_av,
55
            map_av_dt_filter,
55
            map_av_dt_filter,
56
            setConfirmationDialog,
57
            setMessage,
58
            setWarning,
59
            table,
56
            table,
60
        }
57
        }
61
    },
58
    },
Lines 67-73 export default { Link Here
67
            tableOptions: {
64
            tableOptions: {
68
                columns: this.getTableColumns(),
65
                columns: this.getTableColumns(),
69
                options: {},
66
                options: {},
70
                url: () => this.table_url(),
67
                url: () => this.getResourceTableUrl(),
71
                table_settings: this.usage_data_provider_table_settings,
68
                table_settings: this.usage_data_provider_table_settings,
72
                add_filters: true,
69
                add_filters: true,
73
                actions: {
70
                actions: {
Lines 103-161 export default { Link Here
103
                error => {}
100
                error => {}
104
            )
101
            )
105
        },
102
        },
106
        table_url() {
107
            let url = "/api/v1/erm/usage_data_providers"
108
            return url
109
        },
110
        show_usage_data_provider(usage_data_provider, dt, event) {
111
            event.preventDefault()
112
113
            this.$router.push({
114
                name: "UsageStatisticsDataProvidersShow",
115
                params: {
116
                    usage_data_provider_id:
117
                        usage_data_provider.erm_usage_data_provider_id,
118
                },
119
            })
120
        },
121
        edit_usage_data_provider(usage_data_provider, dt, event) {
122
            this.$router.push({
123
                name: "UsageStatisticsDataProvidersFormAddEdit",
124
                params: {
125
                    usage_data_provider_id:
126
                        usage_data_provider.erm_usage_data_provider_id,
127
                },
128
            })
129
        },
130
        delete_usage_data_provider(usage_data_provider, dt, event) {
131
            this.setConfirmationDialog(
132
                {
133
                    title: this.$__(
134
                        "Are you sure you want to remove this data provider?"
135
                    ),
136
                    message: usage_data_provider.name,
137
                    accept_label: this.$__("Yes, delete"),
138
                    cancel_label: this.$__("No, do not delete"),
139
                },
140
                () => {
141
                    const client = APIClient.erm
142
                    client.usage_data_providers
143
                        .delete(usage_data_provider.erm_usage_data_provider_id)
144
                        .then(
145
                            success => {
146
                                this.setMessage(
147
                                    this.$__("Data provider %s deleted").format(
148
                                        usage_data_provider.name
149
                                    ),
150
                                    true
151
                                )
152
                                dt.draw()
153
                            },
154
                            error => {}
155
                        )
156
                }
157
            )
158
        },
159
        run_harvester_now(usage_data_provider, dt, event) {
103
        run_harvester_now(usage_data_provider, dt, event) {
160
            const { erm_usage_data_provider_id: id, name } = usage_data_provider
104
            const { erm_usage_data_provider_id: id, name } = usage_data_provider
161
105
Lines 307-315 export default { Link Here
307
                    orderable: true,
251
                    orderable: true,
308
                    render: function (data, type, row, meta) {
252
                    render: function (data, type, row, meta) {
309
                        return (
253
                        return (
310
                            '<a href="/cgi-bin/koha/erm/eusage/usage_data_providers/' +
254
                            '<a role="button" class="show">' +
311
                            row.erm_usage_data_provider_id +
312
                            '" class="show">' +
313
                            escape_str(
255
                            escape_str(
314
                                `${row.name} (#${row.erm_usage_data_provider_id})`
256
                                `${row.name} (#${row.erm_usage_data_provider_id})`
315
                            ) +
257
                            ) +
Lines 347-354 export default { Link Here
347
            this.getUsageDataProviderCount()
289
            this.getUsageDataProviderCount()
348
        }
290
        }
349
    },
291
    },
350
    components: { Toolbar, KohaTable },
292
    components: { Toolbar, ToolbarButton, KohaTable },
351
    name: "DataProvidersList",
293
    name: "UsageStatisticsDataProvidersList",
352
}
294
}
353
</script>
295
</script>
354
296
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsDataProvidersShow.vue (-54 / +9 lines)
Lines 3-29 Link Here
3
    <div v-else id="usage_data_providers_show">
3
    <div v-else id="usage_data_providers_show">
4
        <Toolbar>
4
        <Toolbar>
5
            <ToolbarButton
5
            <ToolbarButton
6
                :to="{
6
                action="edit"
7
                    name: 'UsageStatisticsDataProvidersFormAddEdit',
7
                @go-to-edit-resource="goToResourceEdit"
8
                    params: {
8
            />
9
                        usage_data_provider_id:
9
            <ToolbarButton
10
                            usage_data_provider.erm_usage_data_provider_id,
10
                action="delete"
11
                    },
11
                @delete-resource="doResourceDelete"
12
                }"
13
                class="btn btn-default"
14
                icon="pencil"
15
                :title="$__('Edit')"
16
            />
12
            />
17
            <a
18
                @click="
19
                    delete_usage_data_provider(
20
                        usage_data_provider.erm_usage_data_provider_id,
21
                        usage_data_provider.name
22
                    )
23
                "
24
                class="btn btn-default"
25
                ><font-awesome-icon icon="trash" /> {{ $__("Delete") }}</a
26
            >
27
        </Toolbar>
13
        </Toolbar>
28
14
29
        <h2>
15
        <h2>
Lines 126-133 import UsageStatisticsDataProvidersFileImport from "./UsageStatisticsDataProvide Link Here
126
import UsageStatisticsDataProvidersCounterLogs from "./UsageStatisticsDataProvidersCounterLogs.vue"
112
import UsageStatisticsDataProvidersCounterLogs from "./UsageStatisticsDataProvidersCounterLogs.vue"
127
import UsageStatisticsDataProviderDetails from "./UsageStatisticsDataProviderDetails.vue"
113
import UsageStatisticsDataProviderDetails from "./UsageStatisticsDataProviderDetails.vue"
128
import UsageStatisticsProviderDataList from "./UsageStatisticsProviderDataList.vue"
114
import UsageStatisticsProviderDataList from "./UsageStatisticsProviderDataList.vue"
115
import UsageStatisticsDataProviderResource from "./UsageStatisticsDataProviderResource.vue"
129
116
130
export default {
117
export default {
118
    extends: UsageStatisticsDataProviderResource,
131
    setup() {
119
    setup() {
132
        const AVStore = inject("AVStore")
120
        const AVStore = inject("AVStore")
133
        const { get_lib_from_av } = AVStore
121
        const { get_lib_from_av } = AVStore
Lines 135-140 export default { Link Here
135
        const { setConfirmationDialog, setMessage } = inject("mainStore")
123
        const { setConfirmationDialog, setMessage } = inject("mainStore")
136
124
137
        return {
125
        return {
126
            ...UsageStatisticsDataProviderResource.setup(),
138
            get_lib_from_av,
127
            get_lib_from_av,
139
            setConfirmationDialog,
128
            setConfirmationDialog,
140
            setMessage,
129
            setMessage,
Lines 188-227 export default { Link Here
188
        change_tab_content(e) {
177
        change_tab_content(e) {
189
            this.tab_content = e.target.getAttribute("data-content")
178
            this.tab_content = e.target.getAttribute("data-content")
190
        },
179
        },
191
        delete_usage_data_provider: function (
192
            usage_data_provider_id,
193
            usage_data_provider_name
194
        ) {
195
            this.setConfirmationDialog(
196
                {
197
                    title: this.$__(
198
                        "Are you sure you want to remove this data provider?"
199
                    ),
200
                    message: usage_data_provider_name,
201
                    accept_label: this.$__("Yes, delete"),
202
                    cancel_label: this.$__("No, do not delete"),
203
                },
204
                () => {
205
                    const client = APIClient.erm
206
                    client.usage_data_providers
207
                        .delete(usage_data_provider_id)
208
                        .then(
209
                            success => {
210
                                this.setMessage(
211
                                    this.$__(
212
                                        "Usage data provider %s deleted"
213
                                    ).format(usage_data_provider_name),
214
                                    true
215
                                )
216
                                this.$router.push({
217
                                    name: "UsageStatisticsDataProvidersList",
218
                                })
219
                            },
220
                            error => {}
221
                        )
222
                }
223
            )
224
        },
225
    },
180
    },
226
    name: "UsageStatisticsDataProvidersShow",
181
    name: "UsageStatisticsDataProvidersShow",
227
    components: {
182
    components: {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsDataProvidersSummary.vue (-2 / +1 lines)
Lines 24-30 Link Here
24
</template>
24
</template>
25
25
26
<script>
26
<script>
27
import Toolbar from "./UsageStatisticsDataProvidersToolbar.vue"
28
import { inject, ref } from "vue"
27
import { inject, ref } from "vue"
29
import { APIClient } from "../../fetch/api-client.js"
28
import { APIClient } from "../../fetch/api-client.js"
30
import KohaTable from "../KohaTable.vue"
29
import KohaTable from "../KohaTable.vue"
Lines 156-162 export default { Link Here
156
            this.getUsageDataProviders()
155
            this.getUsageDataProviders()
157
        }
156
        }
158
    },
157
    },
159
    components: { Toolbar, KohaTable },
158
    components: { KohaTable },
160
    name: "UsageStatisticsDataProvidersSummary",
159
    name: "UsageStatisticsDataProvidersSummary",
161
}
160
}
162
</script>
161
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsDataProvidersToolbar.vue (-17 lines)
Lines 1-16 Link Here
1
<template>
2
    <div id="toolbar" class="btn-toolbar">
3
        <router-link
4
            :to="{ name: 'UsageStatisticsDataProvidersFormAdd' }"
5
            class="btn btn-default"
6
            ><font-awesome-icon icon="plus" />
7
            {{ $__("New data provider") }}</router-link
8
        >
9
    </div>
10
</template>
11
12
<script>
13
export default {
14
    name: "UsageStatisticsDataProvidersToolbar",
15
}
16
</script>
17
- 

Return to bug 37301