Skip to content

Commit d5fc7f3

Browse files
committed
1 parent 3103e48 commit d5fc7f3

4 files changed

Lines changed: 79 additions & 67 deletions

File tree

src/main/malewicz/src/components/ConnectionsListPanel.vue

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<v-toolbar-title>Connections</v-toolbar-title>
55
</v-toolbar>
66
<v-list>
7-
<v-list-tile v-for="item in connections" :key="item.name">
7+
<v-list-tile v-for="item in $store.getters.getAllConnections" :key="item.name">
88
<v-list-tile-action>
99
<v-checkbox v-model="$store.state.uri.connections" :value="item.name"/>
1010
</v-list-tile-action>
@@ -20,16 +20,7 @@
2020
export default {
2121
name: 'ConnectionsListPanel',
2222
data() {
23-
return {
24-
connections: []
25-
}
26-
},
27-
created: function () {
28-
this.$http.get(this.$store.state.host + '/endpoints').then(
29-
response => {
30-
this.connections = response.body.filter(v => { return v.properties.visible !== false })
31-
}
32-
)
23+
return {}
3324
}
3425
}
3526
</script>

src/main/malewicz/src/components/ObjectsTablePanel.vue

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,6 @@ export default {
154154
completeUri() {
155155
return this.$store.getters.getUri
156156
},
157-
typeUri () {
158-
return this.$store.getters.preparedTypeUri
159-
},
160-
objectUri () {
161-
return this.$store.getters.preparedUri
162-
},
163157
message: {
164158
get () {
165159
return this.$store.getters.getPageNumber
@@ -172,35 +166,40 @@ export default {
172166
watch: {
173167
completeUri: {
174168
handler(newVal, oldVal) {
175-
console.log("RRRRRRRRRRRRRRRRRR")
169+
this.meta = []
170+
// this.meta = this.$store.getters.getTypes.find( v => { return v.name === this.$store.getters.getUri.type } )
171+
172+
this.$http.get(this.$store.getters.preparedTypeUri).then(
173+
response => {
174+
this.meta = response.body[0]
175+
176+
/* if (Object.keys(this.$store.getters.getUri.orderby).length === 0) {
177+
console.log("EMPTY!")
178+
this.pagination.sortBy = 'time'
179+
this.setSort('time')
180+
return
181+
}*/
182+
183+
this.items = []
184+
this.isLoading = true
185+
this.$http.get(this.$store.getters.preparedUri).then(
186+
response => {
187+
this.items = response.body
188+
if (this.items.length >= 15 && this.message === this.getPageCount()) {
189+
this.increasePageCount()
190+
}
191+
this.isLoading = false
192+
}, response => {
193+
this.$notify({ group: 'foo', type: 'error', title: 'Server error', text: response })
194+
this.isLoading = false
195+
}
196+
)
197+
198+
}
199+
)
176200
},
177201
deep: true,
178202
},
179-
typeUri (newValue) {
180-
this.meta = []
181-
this.$http.get(newValue).then(
182-
response => {
183-
this.meta = response.body[0]
184-
// this.setSort('time')
185-
}
186-
)
187-
},
188-
objectUri (newValue) {
189-
this.items = []
190-
this.isLoading = true
191-
this.$http.get(newValue).then(
192-
response => {
193-
this.items = response.body
194-
if (this.items.length >= 15 && this.message === this.getPageCount()) {
195-
this.increasePageCount()
196-
}
197-
this.isLoading = false
198-
}, response => {
199-
this.$notify({ group: 'foo', type: 'error', title: 'Server error', text: response })
200-
this.isLoading = false
201-
}
202-
)
203-
},
204203
getSort(newValue) {
205204
if (newValue.descending === true) {
206205
this.$store.commit('setSort', { "field": newValue.sortBy, "ord": "desc" })

src/main/malewicz/src/components/TypesListPanel.vue

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,23 @@
3737
export default {
3838
name: 'TypesListPanel',
3939
data() {
40-
return {
41-
types: []
42-
}
40+
return {}
4341
},
4442
methods: {
45-
typesByTag(tag) {
46-
return this.types
47-
.filter(el => el === 0 || Boolean(el.properties.tags))
48-
.filter(v => { return v.properties.tags.includes(tag) && v.properties.tags.includes('ui')})
49-
},
5043
allTags() {
51-
return this.types
44+
return this.$store.getters.getTypes
5245
.map(v => { return v.properties.tags } )
5346
.filter(el => el === 0 || Boolean(el))
5447
.map(v => { return v.split(",") } )
5548
.flatMap(v => v)
5649
.filter(this.onlyUnique)
5750
.filter(el => el !== 'ui')
5851
},
52+
typesByTag(tag) {
53+
return this.$store.getters.getTypes
54+
.filter(el => el === 0 || Boolean(el.properties.tags))
55+
.filter(v => { return v.properties.tags.includes(tag) && v.properties.tags.includes('ui')})
56+
},
5957
onlyUnique(value, index, self) {
6058
return self.indexOf(value) === index;
6159
},
@@ -65,20 +63,6 @@
6563
setType(type) {
6664
this.$store.commit('skipObjectUri', type)
6765
}
68-
},
69-
computed: {
70-
getPreparedTypesUri() {
71-
if (this.$store.state.uri.connections.length > 0) {
72-
this.$http.get(this.$store.getters.preparedTypesUri).then(
73-
response => {
74-
this.types = response.body
75-
}
76-
)
77-
}
78-
}
79-
},
80-
watch: {
81-
getPreparedTypesUri(newVal, oldVal) {}
8266
}
8367
}
8468
</script>

src/main/malewicz/src/main.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ const store = new Vuex.Store({
7171
host: '',
7272
// host: 'http://localhost:8007/',
7373
pageCount: 1,
74+
allConnections: [],
75+
types: [],
7476
uri: {
7577
connections: [],
7678
type: 'table',
@@ -80,6 +82,12 @@ const store = new Vuex.Store({
8082
}
8183
},
8284
getters: {
85+
getAllConnections: state => {
86+
return state.allConnections
87+
},
88+
getTypes: state => {
89+
return state.types
90+
},
8391
getUri: state => {
8492
return state.uri
8593
},
@@ -113,11 +121,18 @@ const store = new Vuex.Store({
113121
}
114122
},
115123
mutations: {
124+
setAllConnections (state, connections) {
125+
state.allConnections = connections
126+
},
127+
setTypes (state, types) {
128+
state.types = types
129+
},
116130
setUri (state, uri) {
117131
state.uri = uri
118132
},
119133
skipObjectUri (state, type) {
120134
const c = state.uri.connections
135+
state.pageCount = 1
121136
state.uri = { connections: c, type: type, path: [], orderby: {}, page: { number: 1, size: 15 }}
122137
},
123138
setType (state, typeName) {
@@ -183,5 +198,28 @@ new Vue({
183198
components: { App },
184199
template: '<App/>',
185200
store,
186-
router
201+
router,
202+
created: function() {
203+
this.$http.get(this.$store.state.host + '/endpoints').then(
204+
response => {
205+
this.$store.commit('setAllConnections', response.body)
206+
}
207+
)
208+
},
209+
computed: {
210+
getAllConnections() {
211+
return this.$store.getters.getAllConnections
212+
}
213+
},
214+
watch: {
215+
getAllConnections: {
216+
handler(newVal, oldVal) {
217+
this.$http.get(this.$store.state.host + '/api/' + newVal[0].name + '/types').then(
218+
response => {
219+
this.$store.commit('setTypes', response.body)
220+
}
221+
)
222+
}
223+
}
224+
}
187225
}).$mount('#app')

0 commit comments

Comments
 (0)