sqlui 0.1.48 → 0.1.49
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/app/args.rb +6 -6
- data/app/database_config.rb +11 -7
- data/client/resources/sqlui.css +3 -5
- data/client/resources/sqlui.js +31 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae60c3a8d2bb051b87f0e10ed67b3c5e5c6360ecd298b5176a17a7a5f66796d8
|
4
|
+
data.tar.gz: 4ee88fae0167dc7dd8958384d7b2492df3944368238453d729244d91232ebf35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b809f370ad688d9b54d50ff1ccf4dd703dea5af4344f61577220da2b3f4d7536265d8b8e03613158b81fdec4d86ca10dde35f89623cb114fde2b345a5df0108b
|
7
|
+
data.tar.gz: 70324412047c434e03c39e3676cd616da4f6a29c0c7767805fe4073d15e59dd1f28d994253921e18457c469154661081a4570cfec63100cfb9dd2d3ae1aec242
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.49
|
data/app/args.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
class Args
|
5
5
|
def self.fetch_non_empty_string(hash, key)
|
6
6
|
value = fetch_non_nil(hash, key, String)
|
7
|
-
raise ArgumentError, "
|
7
|
+
raise ArgumentError, "parameter #{key} empty" if value.strip.empty?
|
8
8
|
|
9
9
|
value
|
10
10
|
end
|
@@ -15,7 +15,7 @@ class Args
|
|
15
15
|
|
16
16
|
def self.fetch_non_empty_hash(hash, key)
|
17
17
|
value = fetch_non_nil(hash, key, Hash)
|
18
|
-
raise ArgumentError, "
|
18
|
+
raise ArgumentError, "parameter #{key} empty" if value.empty?
|
19
19
|
|
20
20
|
value
|
21
21
|
end
|
@@ -29,9 +29,9 @@ class Args
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.fetch_non_nil(hash, key, *classes)
|
32
|
-
raise ArgumentError, "
|
32
|
+
raise ArgumentError, "parameter #{key} missing" unless hash.key?(key)
|
33
33
|
|
34
|
-
raise ArgumentError, "
|
34
|
+
raise ArgumentError, "parameter #{key} null" if hash[key].nil?
|
35
35
|
|
36
36
|
fetch_optional(hash, key, *classes)
|
37
37
|
end
|
@@ -40,12 +40,12 @@ class Args
|
|
40
40
|
value = hash[key]
|
41
41
|
if value && classes.size.positive? && !classes.find { |clazz| value.is_a?(clazz) }
|
42
42
|
if classes.size != 1
|
43
|
-
raise ArgumentError, "
|
43
|
+
raise ArgumentError, "parameter #{key} not #{classes.map(&:to_s).map(&:downcase).join(' or ')}"
|
44
44
|
end
|
45
45
|
|
46
46
|
class_name = classes[0].to_s.downcase
|
47
47
|
class_name = %w[a e i o u].include?(class_name[0]) ? "an #{class_name}" : "a #{class_name}"
|
48
|
-
raise ArgumentError, "
|
48
|
+
raise ArgumentError, "parameter #{key} not #{class_name}"
|
49
49
|
end
|
50
50
|
|
51
51
|
value
|
data/app/database_config.rb
CHANGED
@@ -18,8 +18,10 @@ class DatabaseConfig
|
|
18
18
|
raise ArgumentError, 'url_path should not end with a /' if @url_path.length > 1 && @url_path.end_with?('/')
|
19
19
|
|
20
20
|
@saved_path = Args.fetch_non_empty_string(hash, :saved_path).strip
|
21
|
-
|
22
|
-
|
21
|
+
|
22
|
+
# Make joins an array. It is only a map to allow for YAML extension.
|
23
|
+
@joins = (Args.fetch_optional_hash(hash, :joins) || {}).values
|
24
|
+
@joins.each do |join|
|
23
25
|
next if join.is_a?(Hash) &&
|
24
26
|
join.keys.size == 2 &&
|
25
27
|
join[:label].is_a?(String) && !join[:label].strip.empty? &&
|
@@ -27,6 +29,7 @@ class DatabaseConfig
|
|
27
29
|
|
28
30
|
raise ArgumentError, "invalid join #{join.to_json}"
|
29
31
|
end
|
32
|
+
|
30
33
|
@tables = Args.fetch_optional_hash(hash, :tables) || {}
|
31
34
|
@tables.each do |table, table_config|
|
32
35
|
unless table_config.is_a?(Hash)
|
@@ -43,16 +46,15 @@ class DatabaseConfig
|
|
43
46
|
raise ArgumentError, "invalid table boost for #{table} (#{table_boost}), expected int"
|
44
47
|
end
|
45
48
|
end
|
49
|
+
|
46
50
|
@columns = Args.fetch_optional_hash(hash, :columns) || {}
|
47
51
|
@columns.each do |column, column_config|
|
48
52
|
unless column_config.is_a?(Hash)
|
49
53
|
raise ArgumentError, "invalid column config for #{column} (#{column_config}), expected hash"
|
50
54
|
end
|
51
55
|
|
52
|
-
links = column_config
|
53
|
-
|
54
|
-
|
55
|
-
links.each do |link_config|
|
56
|
+
links = Args.fetch_optional_hash(column_config, :links) || {}
|
57
|
+
links.each_value do |link_config|
|
56
58
|
unless link_config.is_a?(Hash)
|
57
59
|
raise ArgumentError, "invalid link config for #{column} (#{link_config}), expected hash"
|
58
60
|
end
|
@@ -65,9 +67,11 @@ class DatabaseConfig
|
|
65
67
|
raise ArgumentError, "invalid link long_name for #{column} link (#{link_config[:long_name]}), expected string"
|
66
68
|
end
|
67
69
|
unless link_config[:template].is_a?(String)
|
68
|
-
raise ArgumentError, "invalid template for #{column} link (#{link_config[:template]}), expected string"
|
70
|
+
raise ArgumentError, "invalid link template for #{column} link (#{link_config[:template]}), expected string"
|
69
71
|
end
|
70
72
|
end
|
73
|
+
# Make links an array. It is only a map to allow for YAML extension
|
74
|
+
column_config[:links] = links.values
|
71
75
|
end
|
72
76
|
aliases = @tables.map { |_table, table_config| table_config[:alias] }.compact
|
73
77
|
if aliases.to_set.size < aliases.size
|
data/client/resources/sqlui.css
CHANGED
@@ -258,15 +258,13 @@ p {
|
|
258
258
|
}
|
259
259
|
|
260
260
|
#result-table tbody tr td abbr {
|
261
|
-
margin: 0 0 0
|
261
|
+
margin: 0 5px 0 0;
|
262
262
|
text-decoration: none;
|
263
|
-
display: inline-block;
|
264
263
|
position: relative;
|
265
|
-
top: -2px;
|
266
264
|
}
|
267
265
|
|
268
|
-
#result-table tbody tr td abbr:
|
269
|
-
margin: 0
|
266
|
+
#result-table tbody tr td abbr:last-child {
|
267
|
+
margin: 0;
|
270
268
|
}
|
271
269
|
|
272
270
|
.fetch-sql-box {
|
data/client/resources/sqlui.js
CHANGED
@@ -24152,7 +24152,7 @@
|
|
24152
24152
|
return match ? match[1] : identifier
|
24153
24153
|
}
|
24154
24154
|
|
24155
|
-
function createTable (columns, rows, id, cellRenderer) {
|
24155
|
+
function createTable (columns, rows, id, headerRenderer, cellRenderer) {
|
24156
24156
|
const tableElement = document.createElement('table');
|
24157
24157
|
if (id) tableElement.id = id;
|
24158
24158
|
const theadElement = document.createElement('thead');
|
@@ -24163,9 +24163,13 @@
|
|
24163
24163
|
tableElement.appendChild(tbodyElement);
|
24164
24164
|
|
24165
24165
|
columns.forEach(function (columnName) {
|
24166
|
-
|
24167
|
-
|
24168
|
-
|
24166
|
+
if (headerRenderer) {
|
24167
|
+
headerRenderer(headerTrElement, columnName);
|
24168
|
+
} else {
|
24169
|
+
const headerElement = document.createElement('th');
|
24170
|
+
headerElement.innerText = columnName;
|
24171
|
+
headerTrElement.appendChild(headerElement);
|
24172
|
+
}
|
24169
24173
|
});
|
24170
24174
|
if (columns.length > 0) {
|
24171
24175
|
headerTrElement.appendChild(document.createElement('th'));
|
@@ -24179,14 +24183,13 @@
|
|
24179
24183
|
highlight = !highlight;
|
24180
24184
|
tbodyElement.appendChild(rowElement);
|
24181
24185
|
row.forEach(function (value, i) {
|
24182
|
-
let cellElement;
|
24183
24186
|
if (cellRenderer) {
|
24184
|
-
|
24187
|
+
cellRenderer(rowElement, columns[i], value);
|
24185
24188
|
} else {
|
24186
|
-
cellElement = document.createElement('td');
|
24189
|
+
const cellElement = document.createElement('td');
|
24187
24190
|
cellElement.innerText = value;
|
24191
|
+
rowElement.appendChild(cellElement);
|
24188
24192
|
}
|
24189
|
-
rowElement.appendChild(cellElement);
|
24190
24193
|
});
|
24191
24194
|
rowElement.appendChild(document.createElement('td'));
|
24192
24195
|
});
|
@@ -24936,20 +24939,34 @@
|
|
24936
24939
|
|
24937
24940
|
return abbrElement
|
24938
24941
|
};
|
24939
|
-
|
24940
|
-
|
24942
|
+
|
24943
|
+
const headerRenderer = function (rowElement, column) {
|
24944
|
+
const headerElement = document.createElement('th');
|
24945
|
+
headerElement.innerText = column;
|
24946
|
+
if (window.metadata.columns[column]) {
|
24947
|
+
headerElement.colSpan = 2;
|
24948
|
+
}
|
24949
|
+
rowElement.appendChild(headerElement);
|
24950
|
+
};
|
24951
|
+
|
24952
|
+
const cellRenderer = function (rowElement, column, value) {
|
24941
24953
|
if (window.metadata.columns[column]?.links?.length > 0) {
|
24942
|
-
|
24954
|
+
const linksColumnElement = document.createElement('td');
|
24943
24955
|
window.metadata.columns[column].links.forEach((link) => {
|
24944
|
-
|
24956
|
+
linksColumnElement.appendChild(createLink(link, value));
|
24945
24957
|
});
|
24958
|
+
rowElement.appendChild(linksColumnElement);
|
24959
|
+
const textColumnElement = document.createElement('td');
|
24960
|
+
textColumnElement.innerText = value;
|
24961
|
+
rowElement.appendChild(textColumnElement);
|
24946
24962
|
} else {
|
24963
|
+
const cellElement = document.createElement('td');
|
24947
24964
|
cellElement.innerText = value;
|
24965
|
+
rowElement.appendChild(cellElement);
|
24948
24966
|
}
|
24949
|
-
return cellElement
|
24950
24967
|
};
|
24951
24968
|
document.getElementById('result-box')
|
24952
|
-
.appendChild(createTable(fetch.result.columns, fetch.result.rows, 'result-table', cellRenderer));
|
24969
|
+
.appendChild(createTable(fetch.result.columns, fetch.result.rows, 'result-table', headerRenderer, cellRenderer));
|
24953
24970
|
}
|
24954
24971
|
|
24955
24972
|
function disableDownloadButtons () {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.49
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Dower
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|