Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<template>
<b-container fluid>
<b-row>
<button @click="fetchRepoData">Fetch!</button>
</b-row>
<b-tabs>
<b-tab title="Processors">
<ocrd-processor-list
:processors="processors"
:steps="steps"
:step_filter="step_filter"
:categories="categories"
:category_filter="category_filter"
></ocrd-processor-list>
</b-tab>
<b-tab title="Projects">
<ocrd-project-list
:repos="repos"
></ocrd-project-list>
</b-tab>
</b-tabs>
</b-container>
</template>
<script>
import OcrdProcessorList from './OcrdProcessorList.vue'
import OcrdProjectList from './OcrdProjectList.vue'
export default {
components: {
OcrdProcessorList,
OcrdProjectList
},
data() {
return {
repos_raw: [],
category_filter: [],
step_filter: [],
}
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
},
steps() {
return this.all_processors.reduce((all, processor) => {
all.push(...processor.steps.filter(step => all.indexOf(step) == -1))
return all
}, [])
},
categories() {
return this.all_processors.reduce((all, processor) => {
all.push(...processor.categories.filter(category => all.indexOf(category) == -1))
return all
}, [])
},
all_processors() {
return this.repos_raw.reduce((all, repo) => {
if (repo.ocrd_tool)
all.push(...Object.values(repo.ocrd_tool.tools).map(tool => {
tool.part_of = repo.org_plus_name
return tool
}))
return all
}, [])
},
processors() {
return this.all_processors.filter(tool => {
for (let step_filter of this.step_filter) {
if (tool.steps.indexOf(step_filter) == -1)
return false
}
for (let category_filter of this.category_filter) {
if (tool.categories.indexOf(category_filter) == -1)
return false
}
return true
})
fetch('repos.json').then(resp => resp.json()).then(repos => {
this.repos_raw.splice(0, this.repos_raw.length)
this.repos_raw.push(...repos)
}
)
toggleStepFilter(v) {
if (v in this.step_filter) {
this.step_filter = this.step_filter.splice(this.step_filter.indexOf(v), 1)
} else {
this.step_filter.push(v)
}
}