Skip to content

Commit

Permalink
Merge pull request OmniDB#748 from rafaelthca/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rafaelthca authored Oct 23, 2018
2 parents 5f09cb1 + 329e647 commit d605469
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 252 deletions.
54 changes: 0 additions & 54 deletions OmniDB/OmniDB_app/include/OmniDatabase/PostgreSQL.py
Original file line number Diff line number Diff line change
Expand Up @@ -7461,60 +7461,6 @@ def GetAutocompleteValues(self, p_columns, p_filter):
UNION ALL
select type,
sequence,
num_dots,
result,
result_complete,
select_value,
quote_ident(schema_name) || '.' || quote_ident(table_name) || ' - <b>' || complement || '</b>' as complement,
'<b>' || complement || '</b>' as complement_complete
from (
select 'column' as type,
7 as sequence,
2 as num_dots,
quote_ident(a.attname) as result,
quote_ident(n.nspname) as schema_name,
quote_ident(c.relname) as table_name,
quote_ident(n.nspname) || '.' || quote_ident(c.relname) || '.' || quote_ident(a.attname) as result_complete,
quote_ident(n.nspname) || '.' || quote_ident(c.relname) || '.' || quote_ident(a.attname) as select_value,
(case when t.typtype = 'd'::"char"
then case when bt.typelem <> 0::oid and bt.typlen = '-1'::integer
then 'ARRAY'::text
when nbt.nspname = 'pg_catalog'::name
then format_type(t.typbasetype, NULL::integer)
else 'USER-DEFINED'::text
end
else case when t.typelem <> 0::oid and t.typlen = '-1'::integer
then 'ARRAY'::text
when nt.nspname = 'pg_catalog'::name
then format_type(a.atttypid, NULL::integer)
else 'USER-DEFINED'::text
end
end) as complement
from pg_attribute a
inner join pg_class c
on c.oid = a.attrelid
inner join pg_namespace n
on n.oid = c.relnamespace
inner join (
pg_type t
inner join pg_namespace nt
on t.typnamespace = nt.oid
) on a.atttypid = t.oid
left join (
pg_type bt
inner join pg_namespace nbt
on bt.typnamespace = nbt.oid
) on t.typtype = 'd'::"char" and t.typbasetype = bt.oid
where a.attnum > 0
and not a.attisdropped
and c.relkind in ('r', 'f', 'p', 'v')) x
UNION ALL
select 'function' as type,
8 as sequence,
1 as num_dots,
Expand Down
126 changes: 0 additions & 126 deletions OmniDB/OmniDB_app/include/Spartacus/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import openpyxl
from collections import OrderedDict
import tempfile
import formulas

import OmniDB_app.include.Spartacus as Spartacus

Expand Down Expand Up @@ -64,131 +63,6 @@ def Decrypt(self, p_cyphertext):
except Exception as exc:
raise Spartacus.Utils.Exception(str(exc))

class DataFileReader(object):
def __init__(self, p_filename, p_fieldnames=None, p_encoding='utf-8', p_delimiter=None, p_resolveFormulas=False):
v_tmp = p_filename.split('.')
if len(v_tmp) > 1:
self.v_extension = v_tmp[-1].lower()
else:
self.v_extension = 'csv'
if self.v_extension == 'txt' or self.v_extension == 'out':
self.v_extension = 'csv'
self.v_filename = p_filename
self.v_file = None
self.v_header = p_fieldnames
self.v_encoding = p_encoding
self.v_delimiter = p_delimiter
self.v_resolveFormulas = p_resolveFormulas
self.v_open = False
def Open(self):
try:
if not os.path.isfile(self.v_filename):
raise Spartacus.Utils.Exception('File {0} does not exist or is not a file.'.format(self.v_filename))
if self.v_extension == 'csv':
self.v_file = open(self.v_filename, encoding=self.v_encoding)
v_sample = self.v_file.read(1024)
self.v_file.seek(0)
v_sniffer = csv.Sniffer()
if not v_sniffer.has_header(v_sample):
raise Spartacus.Utils.Exception('CSV file {0} does not have a header.'.format(self.v_filename))
v_dialect = v_sniffer.sniff(v_sample)
if self.v_delimiter is not None:
v_dialect.delimiter = self.v_delimiter
self.v_object = csv.DictReader(self.v_file, self.v_header, None, None, v_dialect)
self.v_open = True
elif self.v_extension == 'xlsx':
if self.v_resolveFormulas:
v_tempFile = tempfile.NamedTemporaryFile(suffix=".xlsx")
v_tempFile.file.close()
v_excelModel = formulas.ExcelModel().loads(self.v_filename).finish()
v_excelModel.calculate()
v_written = v_excelModel.write()
v_written = v_written[list(v_written.keys())[0]]
v_written[list(v_written.keys())[0]].save(v_tempFile.name)
self.v_object = openpyxl.load_workbook(v_tempFile.name, read_only=True)
else:
self.v_object = openpyxl.load_workbook(self.v_filename, read_only=True)

self.v_open = True
else:
raise Spartacus.Utils.Exception('File extension "{0}" not supported.'.format(self.v_extension))
except Spartacus.Utils.Exception as exc:
raise exc
except Exception as exc:
raise Spartacus.Utils.Exception(str(exc))
def Read(self, p_blocksize=None, p_sheetname=None):
try:
if not self.v_open:
raise Spartacus.Utils.Exception('You need to call Open() first.')
if self.v_extension == 'csv':
v_table = Spartacus.Database.DataTable(None, p_alltypesstr=True)
v_first = True
x = 0
for v_row in self.v_object:
if v_first:
if self.v_header:
v_table.Columns = self.v_header
else:
for k in v_row.keys():
v_table.Columns.append(k)
v_first = False
v_table.Rows.append(v_row)
x = x + 1
if x == p_blocksize:
yield v_table
x = 0
v_table.Rows = []
self.v_file.close()
if len(v_table.Rows) > 0:
yield v_table
else:
if p_sheetname:
v_worksheet = self.v_object[p_sheetname]
v_table = Spartacus.Database.DataTable(p_sheetname)
else:
v_worksheet = self.v_object.active
v_table = Spartacus.Database.DataTable()
v_worksheet.max_row = v_worksheet.max_column = None
v_first = True
x = 0
for v_row in v_worksheet.rows:
if v_first:
if self.v_header:
v_table.Columns = self.v_header
else:
v_table.Columns = [a.value for a in v_row]
v_first = False
else:
v_tmp = [a.value for a in v_row]
if len(v_tmp) < len(v_table.Columns):
for i in range(0, len(v_table.Columns) - len(v_tmp)):
v_tmp.append(None)
elif len(v_tmp) > len(v_table.Columns):
for i in range(0, len(v_tmp) - len(v_table.Columns)):
v_tmp.pop()
v_table.Rows.append(OrderedDict(zip(v_table.Columns, v_tmp)))
x = x + 1
if x == p_blocksize:
yield v_table
x = 0
v_table.Rows = []
if len(v_table.Rows) > 0:
yield v_table
except Spartacus.Utils.Exception as exc:
raise exc
except Exception as exc:
raise Spartacus.Utils.Exception(str(exc))
def Sheets(self):
try:
if self.v_extension == 'xlsx' and self.v_object:
return self.v_object.get_sheet_names()
else:
return []
except Spartacus.Utils.Exception as exc:
raise exc
except Exception as exc:
raise Spartacus.Utils.Exception(str(exc))

class DataFileWriter(object):
def __init__(self, p_filename, p_fieldnames=None, p_encoding='utf-8', p_delimiter=';', p_lineterminator='\n'):
v_tmp = p_filename.split('.')
Expand Down
4 changes: 2 additions & 2 deletions OmniDB/OmniDB_app/static/OmniDB_app/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ button {
font-family: Arial;
color: #333;
font-size: 12px;
height: 30px;
height: 28px;
line-height: 0px;
padding-left: 12px;
padding-right: 12px;
Expand Down Expand Up @@ -593,7 +593,7 @@ button:hover {
border-radius: 3px;
font-family: Arial;
color: #FFF;
font-size: 13px;
font-size: 11px;
padding: 6px 12px 6px 12px;
border: solid #ff6262 1px;
text-decoration: none;
Expand Down
3 changes: 2 additions & 1 deletion OmniDB/OmniDB_app/static/OmniDB_app/js/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ function autocomplete_get_results(p_sql,p_value,p_pos) {
}
},
'box',
true);
true,
true);

}

Expand Down
52 changes: 26 additions & 26 deletions OmniDB/OmniDB_app/templates/OmniDB_app/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<title>OmniDB</title>
<link rel="shortcut icon" type="image/x-icon" href="/static/OmniDB_app/images/favicon.ico"/>

<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/css/style.css?v2.12.0.4" />
<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/css/style.css?v2.12.0.5" />

<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/css/modern-style.css?v1.0.0.0" />

<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/css/handsontable.full.css?v2.12.0.4"/>
<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/css/msdropdown/dd.css?v2.12.0.4" />
<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/lib/tabs/css/tabs.css?v2.12.0.4" />
<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/css/popper.css?v2.12.0.4" />
<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/css/handsontable.full.css?v2.12.0.5"/>
<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/css/msdropdown/dd.css?v2.12.0.5" />
<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/lib/tabs/css/tabs.css?v2.12.0.5" />
<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/css/popper.css?v2.12.0.5" />

<link rel="stylesheet" href="/static/OmniDB_app/css/explain/bootstrap.css">
<link rel="stylesheet" href="/static/OmniDB_app/css/explain/main.css">
Expand Down Expand Up @@ -578,27 +578,27 @@ <h2>Primary Supporter:</h2>

<div class="div_loading"><button id="bt_cancel_ajax" onclick="cancelAjax()">Cancel</button></div>

<script type="text/javascript" src="/static/OmniDB_app/js/explain/react.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/explain/react-dom.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/explain/d3.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/explain/pgplan.js?v2.12.0.4" ></script>

<script type="text/javascript" src="/static/OmniDB_app/js/jquery-1.11.2.min.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/popper.min.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/tooltip.min.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/jquery.dd.min.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/lib/ace/ace.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/lib/ace/mode-sql.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/lib/ace/ext-language_tools.js?v2.12.0.4"></script>
<script type="text/javascript" src="/static/OmniDB_app/lib/tabs/lib/tabs.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/handsontable.full.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/NotificationControl.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/AjaxControl.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/WebSocketControl.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/Renderers.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/HeaderActions.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/Passwords.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/Users.js?v2.12.0.4" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/explain/react.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/explain/react-dom.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/explain/d3.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/explain/pgplan.js?v2.12.0.5" ></script>

<script type="text/javascript" src="/static/OmniDB_app/js/jquery-1.11.2.min.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/popper.min.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/tooltip.min.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/jquery.dd.min.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/lib/ace/ace.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/lib/ace/mode-sql.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/lib/ace/ext-language_tools.js?v2.12.0.5"></script>
<script type="text/javascript" src="/static/OmniDB_app/lib/tabs/lib/tabs.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/handsontable.full.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/NotificationControl.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/AjaxControl.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/WebSocketControl.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/Renderers.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/HeaderActions.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/Passwords.js?v2.12.0.5" ></script>
<script type="text/javascript" src="/static/OmniDB_app/js/Users.js?v2.12.0.5" ></script>

<script type="text/javascript">

Expand Down
2 changes: 1 addition & 1 deletion OmniDB/OmniDB_app/templates/OmniDB_app/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<link rel="shortcut icon" type="image/x-icon" href="/static/OmniDB_app/images/favicon.ico" />

<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/css/login.css?v2.12.0.4"/>
<link rel="stylesheet" type="text/css" href="/static/OmniDB_app/css/login.css?v2.12.0.5"/>
</head>
<body>
<div id="div_form">
Expand Down
Loading

0 comments on commit d605469

Please sign in to comment.