Skip to content

Commit fa5bf03

Browse files
committed
#326 move malewicz from resource files
1 parent 0af579e commit fa5bf03

11 files changed

Lines changed: 30 additions & 92 deletions

File tree

conf/h2/md/database/instance/locks/locks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
````sql
22
/*
3-
{ "name": "locks" }
3+
{ "name": "locks", "title": "Locks" }
44
*/
55
select "@schema"
66
, "@table"

conf/h2/md/database/instance/query/query.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
````sql
22
/*
3-
{ "name": "query" }
3+
{ "name": "query", "title": "Queries" }
44
*/
55
select "@statement" from (
66
select SQL_STATEMENT as "@statement"

conf/h2/md/database/instance/sessions/sessions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
````sql
22
/*
3-
{ "name": "sessions" }
3+
{ "name": "sessions", "title": "Sessions" }
44
*/
55
select "@id" /* { "label": "id", "description": "ID", "visible": true } */
66
, USER_NAME /* { "label": "user", "description": "User name", "visible": true } */

conf/h2/md/database/schema/schema.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
````sql
22
/*
3-
{ "name": "schema" }
3+
{ "name": "schema", "title": "Schema" }
44
*/
55
select "@schema" /* { "label": "schema", "description": "Schema", "visible": true } */
66
, CATALOG_NAME /* { "label": "catalog", "description": "Catalog" } */

conf/h2/md/database/schema/table.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
````sql
22
/*
3-
{ "name": "table" }
3+
{ "name": "table", "title": "Tables" }
44
*/
5-
select "@schema" /* { "label": "owner", "description": "Owner of the table", "visible": true } */
6-
, "@table" /* { "label": "table name", "description": "Name of the table", "visible": true } */
7-
, remarks properties
8-
, last_modification /* { "label": "last modification", "description": "Last modification" } */
9-
, table_type /* { "label": "table type", "description": "Typical types", "visible": true, "values": ['TABLE', 'VIEW', 'SYSTEM TABLE', 'GLOBAL TEMPORARY', 'LOCAL TEMPORARY', 'ALIAS', 'SYNONYM'] } */
5+
select "@schema" /* { "label": "Owner", "description": "Owner of the table", "visible": false } */
6+
, "@table" /* { "label": "Name", "description": "Name of the table", "visible": true } */
7+
, table_type /* { "label": "Type", "description": "Typical types", "visible": true, "values": ['TABLE', 'VIEW', 'SYSTEM TABLE', 'GLOBAL TEMPORARY', 'LOCAL TEMPORARY', 'ALIAS', 'SYNONYM'] } */
8+
, remarks /* { "label": "Comment", "description": "Comments", "visible": true } */
9+
, last_modification /* { "label": "Last modification", "description": "Last modification" } */
1010
from (select t.table_schema as "@schema"
1111
, t.table_name as "@table"
1212
, t.*
@@ -18,7 +18,7 @@ order by "@schema", "@table"
1818

1919
````sql
2020
/*
21-
{ "name": "column" }
21+
{ "name": "column", "title": "Columns" }
2222
*/
2323
select "@schema" /* { "label": "owner", "description": "Owner of the table", "visible": true } */
2424
, "@table" /* { "label": "table name", "description": "Name of the table", "visible": true } */
@@ -36,7 +36,7 @@ select "@schema" /* { "label": "owner", "description": "Owner o
3636

3737
````sql
3838
/*
39-
{ "name": "pk" }
39+
{ "name": "pk", "title": "Primary keys" }
4040
*/
4141
select "@schema" /* { "label": "owner", "description": "Owner of the table", "visible": true } */
4242
, "@table" /* { "label": "table name", "description": "Name of the table", "visible": true } */
@@ -53,7 +53,7 @@ select "@schema" /* { "label": "owner", "description": "Owner o
5353

5454
````sql
5555
/*
56-
{ "name": "index" }
56+
{ "name": "index", "title": "Indexes" }
5757
*/
5858
select "@schema" /* { "label": "owner", "description": "Owner of the table", "visible": true } */
5959
, "@table" /* { "label": "table name", "description": "Name of the table", "visible": true } */

src/main/kotlin/com/github/mgramin/sqlboot/model/resourcetype/impl/SqlResourceType.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ class SqlResourceType(
102102
simpleSelectQuery
103103
.columns()
104104
.map { Metadata(it.key, it.value) } +
105-
Metadata("database", """{"label": "Database", "description": "Database name", "visible": true}""")
105+
Metadata("database", """{"label": "Database", "description": "Database name", "visible": false}""")
106106

107107
override fun toJson(): JsonObject {
108108
val jsonObject = JsonObject()
109109
jsonObject.addProperty("name", name())
110110
jsonObject.addProperty("aliases", aliases().toString())
111111
jsonObject.addProperty("query", simpleSelectQuery.query())
112-
jsonObject.add("query_properties", Gson().toJsonTree(simpleSelectQuery.properties()))
112+
jsonObject.add("properties", Gson().toJsonTree(simpleSelectQuery.properties()))
113113
val jsonArray = JsonArray()
114114
metaData(FakeUri()).forEach { jsonArray.add(it.toJson()) }
115115
jsonObject.add("metadata", jsonArray)

src/main/kotlin/com/github/mgramin/sqlboot/rest/controllers/ApiController.kt

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -84,42 +84,6 @@ class ApiController {
8484

8585
private fun wildcardToRegex(name: String) = name.replace("?", ".?").replace("*", ".*?").toRegex()
8686

87-
@RequestMapping(value = ["/api/meta/{connection}/{type}"], method = [GET, POST])
88-
fun getResourceMetadata(@PathVariable connection: String,
89-
@PathVariable type: String,
90-
request: HttpServletRequest): ResponseEntity<String> {
91-
val jsonArray = JsonArray()
92-
val uri = SqlPlaceholdersWrapper(
93-
DbUri("$connection/$type"))
94-
FsResourceType(listOf(endpointList.getByName(uri.connection())), emptyList())
95-
.resourceTypes()
96-
.asSequence()
97-
.filter { v -> v.name().equals(uri.type(), ignoreCase = true) }
98-
.map { it.metaData(uri) }
99-
.first()
100-
.forEach { jsonArray.add(it.toJson()) }
101-
return ResponseEntity(jsonArray.toString(), HttpStatus.OK)
102-
}
103-
104-
@RequestMapping(value = ["/api/meta/{connection}/{type}/{path}"], method = [GET, POST])
105-
fun getResourceMetadata(@PathVariable connection: String,
106-
@PathVariable type: String,
107-
@PathVariable path: String,
108-
request: HttpServletRequest): ResponseEntity<String> {
109-
val jsonArray = JsonArray()
110-
val uri = SqlPlaceholdersWrapper(
111-
DbUri("$connection/$type/$path"))
112-
FsResourceType(listOf(endpointList.getByName(uri.connection())), emptyList())
113-
.resourceTypes()
114-
.asSequence()
115-
.filter { v -> v.name().equals(uri.type(), ignoreCase = true) }
116-
.map { it.metaData(uri) }
117-
.first()
118-
.forEach { jsonArray.add(it.toJson()) }
119-
return ResponseEntity(jsonArray.toString(), HttpStatus.OK)
120-
}
121-
122-
12387
@RequestMapping(value = ["/api/{connection}/{type}"], method = [GET, POST])
12488
fun getResourcesHeadersJson(@PathVariable connection: String,
12589
@PathVariable type: String,

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

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
22
<div>
3+
<ul class="nav">
4+
<h4>{{meta.properties.title}}</h4>
5+
</ul>
36
<ul class="nav">
47
<li class="nav-item pt-2 pb-2">
58
<nav aria-label="test">
@@ -88,7 +91,7 @@
8891
</tr>
8992
</thead>
9093
<tbody>
91-
<tr v-for="(met, index) in meta">
94+
<tr v-for="(met, index) in meta.metadata">
9295
<th scope="row">{{index + 1}}</th>
9396
<td><input type="checkbox" value="" id="defaultCheck1" v-model="met.properties.visible"></td>
9497
<td>{{met.properties.label}}</td>
@@ -116,29 +119,23 @@ export default {
116119
}
117120
},
118121
created: function () {
119-
this.$http.get(this.$store.getters.preparedMetaUri).then(
122+
this.$http.get(this.$store.getters.preparedTypeUri).then(
120123
response => {
121-
this.meta = response.body
124+
this.meta = response.body[0]
122125
}
123126
)
124127
this.$http.get(this.$store.getters.preparedUri).then(
125128
response => {
126129
this.items = response.body
127-
let field = this.$store.state.orderby.field
128-
/*this.items.sort(function (a, b) {
129-
console.log('sorting field = ' + field)
130-
if (a[field] < b[field]) return 1
131-
else return -1
132-
})*/
133130
}
134131
)
135132
},
136133
computed: {
137134
defaultMeta: function () {
138-
return this.meta.filter(function (v) { return v.properties.visible })
135+
return this.meta.metadata.filter(function (v) { return v.properties.visible })
139136
},
140137
count () {
141-
return this.$store.getters.preparedMetaUri
138+
return this.$store.getters.preparedTypeUri
142139
},
143140
count2 () {
144141
return this.$store.getters.preparedUri
@@ -149,7 +146,7 @@ export default {
149146
this.meta = []
150147
this.$http.get(newValue).then(
151148
response => {
152-
this.meta = response.body
149+
this.meta = response.body[0]
153150
}
154151
)
155152
},
@@ -158,11 +155,6 @@ export default {
158155
this.$http.get(newValue).then(
159156
response => {
160157
this.items = response.body
161-
let field = this.$store.state.orderby.field
162-
/*this.items.sort(function (a, b) {
163-
if (a[field] < b[field]) return 1
164-
else return -1
165-
})*/
166158
}, response => {
167159
this.$notify({
168160
group: 'foo',
@@ -178,9 +170,9 @@ export default {
178170
call () {
179171
this.meta = []
180172
this.items = []
181-
this.$http.get(this.$store.getters.preparedMetaUri).then(
173+
this.$http.get(this.$store.getters.preparedTypeUri).then(
182174
response => {
183-
this.meta = response.body
175+
this.meta = response.body[0]
184176
}
185177
)
186178
this.$http.get(this.$store.getters.preparedUri).then(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab"
99
aria-controls="v-pills-home" aria-selected="true"
1010
v-on:click="setType(type.name)"
11-
><i class="fa fa-table fa-fw" aria-hidden="true"></i>&nbsp; {{type.name}}</a>
11+
><i class="fa fa-table fa-fw" aria-hidden="true"></i>&nbsp; {{ type.properties.title || type.name }}</a>
1212
</div>
1313
</div>
1414
</template>

src/main/malewicz/src/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Vue.config.productionTip = false
3131

3232
const store = new Vuex.Store({
3333
state: {
34-
host: '',
34+
host: 'http://localhost:8007/',
3535
connections: '',
3636
type: 'table',
3737
path: [''],
@@ -44,8 +44,8 @@ const store = new Vuex.Store({
4444
preparedTypesUri: state => {
4545
return state.host + '/api/' + state.connections + '/types'
4646
},
47-
preparedMetaUri: state => {
48-
return state.host + '/api/meta/' + state.connections + '/' + state.type + '/'
47+
preparedTypeUri: state => {
48+
return state.host + '/api/' + state.connections + '/types' + '/' + state.type
4949
},
5050
preparedUri: state => {
5151
return state.host + '/api/' + state.connections + '/' + state.type + '/' + state.path +

0 commit comments

Comments
 (0)