Skip to content

Commit 0e4fcfa

Browse files
committed
1 parent 22cf7cc commit 0e4fcfa

4 files changed

Lines changed: 68 additions & 67 deletions

File tree

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<v-list>
77
<v-list-tile v-for="item in connections" :key="item.name">
88
<v-list-tile-action>
9-
<v-checkbox v-model="$store.state.newConnections" :value="item.name"/>
9+
<v-checkbox v-model="$store.state.uri.newConnections" :value="item.name"/>
1010
</v-list-tile-action>
1111
<v-list-tile-content>
1212
<v-list-tile-title>{{ item.name }}</v-list-tile-title>
@@ -25,12 +25,11 @@
2525
}
2626
},
2727
created: function () {
28-
this.$http.get(this.$store.state.host + '/endpoints').then(
28+
this.$http.get(this.$store.state.uri.host + '/endpoints').then(
2929
response => {
3030
this.connections = response.body.filter(v => {
3131
return v.properties.visible !== false
3232
})
33-
this.$store.commit('setAllConnection', response.body)
3433
}
3534
)
3635
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default {
114114
}
115115
},
116116
created: function () {
117-
// if (this.$store.state.allConnections.length > 0) {
117+
if (this.$store.state.uri.newConnections.length > 0) {
118118
this.isLoading = true
119119
this.$http.get(this.$store.getters.preparedTypeUri).then(
120120
response => {
@@ -130,7 +130,7 @@ export default {
130130
this.isLoading = false
131131
}
132132
)
133-
// }
133+
}
134134
},
135135
computed: {
136136
getSort () {
@@ -219,7 +219,7 @@ export default {
219219
return this.$store.commit('pageNumber', number)
220220
},
221221
isActivePage (number) {
222-
return number === this.$store.state.page.number
222+
return number === this.$store.state.uri.page.number
223223
},
224224
setSort (field) {
225225
this.$store.commit('setSort', {field: field, ord: 'desc'})

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
return self.indexOf(value) === index;
6161
},
6262
isActive(type) {
63-
return this.$store.state.type === type.name
63+
return this.$store.state.uri.type === type.name
6464
},
6565
setType(type) {
6666
this.$store.commit('setType', type)
@@ -72,12 +72,13 @@
7272
},
7373
computed: {
7474
getPreparedTypesUri() {
75-
this.$http.get(this.$store.getters.preparedTypesUri).then(
76-
response => {
77-
this.types = response.body
78-
}
79-
)
80-
return this.$store.getters.preparedTypesUri
75+
if (this.$store.state.uri.newConnections.length > 0) {
76+
this.$http.get(this.$store.getters.preparedTypesUri).then(
77+
response => {
78+
this.types = response.body
79+
}
80+
)
81+
}
8182
}
8283
},
8384
watch: {

src/main/malewicz/src/main.js

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -70,103 +70,104 @@ Vue.filter('formatDate', function(value) {
7070

7171
const store = new Vuex.Store({
7272
state: {
73-
host: '',
74-
// host: 'http://localhost:8007/',
75-
newConnections: [],
76-
allConnections: [],
77-
type: 'table',
78-
path: [],
79-
page: { 'number': 1, 'size': 15, 'count': 1 },
80-
orderby: {},
81-
where: '',
82-
cache: false
73+
uri: {
74+
host: '',
75+
// host: 'http://localhost:8007/',
76+
newConnections: [],
77+
type: 'table',
78+
path: [],
79+
page: { 'number': 1, 'size': 15, 'count': 1 },
80+
orderby: {},
81+
where: '',
82+
cache: false,
83+
}
8384
},
8485
getters: {
8586
preparedTypesUri: state => {
86-
return state.host + '/api/' + state.newConnections[0] + '/types'
87+
return state.uri.host + '/api/' + state.uri.newConnections[0] + '/types'
8788
},
8889
preparedTypeUri: state => {
89-
return state.host + '/api/' + state.newConnections[0] + '/types' + '/' + state.type
90+
return state.uri.host + '/api/' + state.uri.newConnections[0] + '/types' + '/' + state.uri.type
9091
},
9192
preparedUri: state => {
92-
return state.host + '/api/' + state.newConnections.join('|') + '/' + state.type + '/' + state.path +
93-
'?page=' + state.page.number + ',' + state.page.size +
94-
(state.orderby.field ? ('&orderby=' + state.orderby.field + '-' + state.orderby.ord) : '')
93+
return state.uri.host + '/api/' + state.uri.newConnections.join('|') + '/' + state.uri.type + '/' + state.uri.path +
94+
'?page=' + state.uri.page.number + ',' + state.uri.page.size +
95+
(state.uri.orderby.field ? ('&orderby=' + state.uri.orderby.field + '-' + state.uri.orderby.ord) : '')
9596
},
9697
getSimpleUri: state => {
97-
return state.newConnections.join('|') + '/' + state.type + '/' + (state.path ? state.path : '') +
98-
'?page=' + state.page.number + ',' + state.page.size +
99-
(state.orderby.field ? ('&orderby=' + state.orderby.field + '-' + state.orderby.ord) : '')
98+
return state.uri.newConnections.join('|') + '/' + state.uri.type + '/' + (state.uri.path ? state.uri.path : '') +
99+
'?page=' + state.uri.page.number + ',' + state.uri.page.size +
100+
(state.uri.orderby.field ? ('&orderby=' + state.uri.orderby.field + '-' + state.uri.orderby.ord) : '')
100101
},
101102
getPage: state => {
102-
return state.page
103+
return state.uri.page
103104
},
104105
getPageCount: state => {
105-
return state.page.count
106+
return state.uri.page.count
106107
},
107108
getPageNumber: state => {
108-
return state.page.number
109+
return state.uri.page.number
109110
},
110111
getConnections: state => {
111-
return state.newConnections
112+
return state.uri.newConnections
112113
}
113114
},
114115
mutations: {
115116
setNewConnection (state, connectionName) {
116-
state.newConnections = connectionName
117-
},
118-
setAllConnection (state, connectionName) {
119-
state.allConnections = connectionName
117+
state.uri.newConnections = connectionName
120118
},
121119
setType (state, typeName) {
122-
state.type = typeName
120+
state.uri.type = typeName
123121
},
124122
setPath (state, path) {
125-
state.path = path
123+
state.uri.path = path
126124
},
127125
setSort (state, sort) {
128-
state.orderby = sort
126+
state.uri.orderby = sort
129127
},
130128
nextPage (state) {
131-
state.page.number++
129+
state.uri.page.number++
132130
},
133131
prevPage (state) {
134-
state.page.number--
132+
state.uri.page.number--
135133
},
136134
pageNumber (state, number) {
137-
state.page.number = number
135+
state.uri.page.number = number
138136
},
139137
setPage (state, val) {
140-
state.page.number = parseInt(val.split(',')[0])
141-
state.page.size = parseInt(val.split(',')[1])
138+
state.uri.page.number = parseInt(val.split(',')[0])
139+
state.uri.page.size = parseInt(val.split(',')[1])
142140
},
143141
setPageCount (state, count) {
144-
state.page.count = count
142+
state.uri.page.count = count
145143
},
146144
increasePageCount (state) {
147-
state.page.count++
145+
state.uri.page.count++
148146
},
149147
changeUri (state, uriString) {
150148
const parse = require('url-parse')
151149
const url = parse(uriString, true)
152-
var path = url.pathname.split('/').filter(v => v)
153-
state.newConnections = path[0].split('|')
154-
state.type = path[1]
155-
if (path[2]) {
156-
state.path = path[2]
157-
} else {
158-
state.path = ""
159-
}
160-
if (url.query.page) {
161-
state.page.number = parseInt(url.query.page.split(',')[0])
162-
state.page.size = parseInt(url.query.page.split(',')[1])
163-
}
164-
if (url.query.orderby) {
165-
let field = url.query.orderby.split('-')[0]
166-
let ord = url.query.orderby.split('-')[1]
167-
state.orderby = {field: field, ord: ord }
168-
} else {
169-
state.orderby = {}
150+
const path = url.pathname.split('/').filter(v => v);
151+
const rawConnections = path[0]
152+
if (rawConnections) {
153+
state.uri.newConnections = path[0].split('|')
154+
state.uri.type = path[1]
155+
if (path[2]) {
156+
state.uri.path = path[2]
157+
} else {
158+
state.uri.path = ""
159+
}
160+
if (url.query.page) {
161+
state.uri.page.number = parseInt(url.query.page.split(',')[0])
162+
state.uri.page.size = parseInt(url.query.page.split(',')[1])
163+
}
164+
if (url.query.orderby) {
165+
let field = url.query.orderby.split('-')[0]
166+
let ord = url.query.orderby.split('-')[1]
167+
state.uri.orderby = {field: field, ord: ord}
168+
} else {
169+
state.uri.orderby = {}
170+
}
170171
}
171172
}
172173
}

0 commit comments

Comments
 (0)