-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
369 lines (369 loc) · 20.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<!doctype html>
<html lang="en" ng-app="cdbmanager">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title ng-controller="titleCtrl">{{ currentEndpoint.name }} -- CDB Manager</title>
<link rel="stylesheet" href="vendor/bootstrap/bootstrap.min.css">
<link rel="stylesheet" href="vendor/codemirror/codemirror.css" />
<link rel="stylesheet" href="vendor/codemirror/show-hint.css" />
<link href="https://libs.cartocdn.com/mapbox-gl/v0.48.0-carto1/mapbox-gl.css" rel="stylesheet" />
<style>
.CodeMirror {
border-top: 1px solid black;
border-bottom: 1px solid black;
}
.panel-body {
max-height: 400px;
overflow: auto;
font-family: "Courier New", monospace, Monospaced;
}
.panel-body a {
overflow: hidden;
}
.geometry {
max-width: 100px;
overflow: hidden;
}
#map {
height: 300px;
width: 100%;
}
pre {
margin: 0;
border: 0;
padding: 1px 0 0 10px;
background-color: inherit;
}
</style>
<script src="vendor/jquery-1.11.2.min.js"></script>
<script src="vendor/bootstrap/bootstrap.min.js"></script>
<script src="vendor/angularjs/angular.min.js"></script>
<script src="https://libs.cartocdn.com/carto-vl/v0.8.0/carto-vl.min.js"></script>
<script src="https://libs.cartocdn.com/mapbox-gl/v0.48.0-carto1/mapbox-gl.js"></script>
</head>
<body>
<!-- Top bar -->
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">CDB Manager</a>
</div>
</div>
</nav>
<!-- Alert messages -->
<div class="container-fluid">
<div ng-controller="AlertCtrl">
<div ng-repeat="alert in alerts" ng-class="'alert alert-dismissable alert-' + alert.type" role="alert">
<button type="button" class="close" ng-click="closeAlert($index)" aria-label="Close"><span aria-hidden="true">×</span></button>
<alert role="alert">{{ alert.msg }}</alert>
</div>
</div>
</div>
<!-- Main work area -->
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<div class="panel-group" id="accordion" role="tablist">
<!-- Endpoint manager -->
<div class="panel panel-default" ng-controller="endpointsCtrl">
<!-- Endpoint selector -->
<div class="panel-heading" role="tab" id="endpointPanelHeading">
<h4 class="panel-title">
<a ng-show="endpoints.length == 0" data-toggle="collapse" data-parent="#accordion" href="#endpointPanelCollapse" aria-expanded="false" aria-controls="endpointPanelCollapse">Endpoints (start here)</a>
<a ng-show="endpoints.length > 0" data-toggle="collapse" data-parent="#accordion" href="#endpointPanelCollapse" aria-expanded="false" aria-controls="endpointPanelCollapse">Current endpoint:</a>
<select ng-show="endpoints.length > 0" ng-options="endpoint as endpoint.name for endpoint in endpoints" ng-model="current" ng-change="setCurrent()"></select>
</h4>
</div>
<!-- New endpoint selector -->
<div id="endpointPanelCollapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="endpointPanelHeading">
<form name="updatedEndpoint" novalidate>
<div class="panel-body">
<div class="form-group">
<label for="name">Endpoint name (for reference only)</label>
<input type="text" id="name" class="form-control" ng-model="updatedEndpoint.name" ng-disabled="!current">
</div>
<div class="form-group">
<label for="name">Account name</label>
<input type="text" id="account" class="form-control" ng-model="updatedEndpoint.account" ng-disabled="!current">
</div>
<div class="form-group">
<label for="name">API key</label>
<input type="text" id="api_key" class="form-control" ng-model="updatedEndpoint.apiKey" ng-disabled="!current">
</div>
<div class="form-group">
<label for="name">SQL API endpoint URL</label>
<input type="text" id="sql_url" class="form-control" ng-model="updatedEndpoint.sqlURL" ng-disabled="!current">
</div>
<div class="form-group">
<label for="name">Maps API endpoint URL</label>
<input type="text" id="maps_url" class="form-control" ng-model="updatedEndpoint.mapsURL" ng-disabled="!current">
</div>
</div>
<div class="panel-footer">
<button type="button" class="btn btn-default" ng-click="addEndpoint()">New</button>
<div class="pull-right">
<button type="button" class="btn btn-danger" ng-click="removeCurrentEndpoint()" ng-disabled="!current">Remove</button>
<button type="button" class="btn btn-default btn-primary" ng-click="updateCurrentEndpoint(updatedEndpoint)" ng-disabled="!current">Update</button>
</div>
</div>
</form>
</div>
</div>
<!-- SQL console link -->
<div class="panel panel-default" ng-controller="sqlSelectorCtrl">
<div class="panel-heading" role="tab" id="sqlPanel">
<h4 class="panel-title">
<a href ng-click="nav.setCurrentView('sql')">SQL Console</a>
</h4>
</div>
</div>
<!-- Table selector -->
<div class="panel panel-default" ng-controller="tableSelectorCtrl">
<div class="panel-heading" role="tab" id="tablePanelHeading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#tablePanelCollapse" aria-expanded="false" aria-controls="tablePanelCollapse">Tables / Views</a>
<a href ng-show="tables.length > 0" ng-click="nav.setCurrentView('tables')">({{ tables.length }})</a>
</h4>
</div>
<div id="tablePanelCollapse" class="panel-collapse collapse text-truncate text-nowrap" role="tabpanel" aria-labelledby="tablePanelHeading">
<div class="panel-body list-group">
<a href draggable="true" title="{{ table.relname }}" ng-click="showTable(table); nav.setCurrentView('table.columns')" ng-repeat="table in tables" class="list-group-item" ng-class="{active: nav.isCurrentView('table') && table == currentTable}">[{{table.relkind}}] {{ table.relname }}</a>
</div>
<div class="panel-footer">
<button type="button" class="btn btn-default" ng-click="refreshList()">Refresh list</button>
</div>
</div>
</div>
<!-- Function selector -->
<div class="panel panel-default" ng-controller="functionSelectorCtrl">
<div class="panel-heading" role="tab" id="functionPanelHeading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#functionPanelCollapse" aria-expanded="false" aria-controls="functionPanelCollapse">Functions</a>
<a href ng-show="functions.length > 0" ng-click="nav.setCurrentView('functions')">({{ functions.length }})</a>
</h4>
</div>
<div id="functionPanelCollapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="functionPanelHeading">
<div class="panel-body list-group">
<a href title="{{ func.proname }}" ng-click="showFunction(func)" ng-repeat="func in functions" class="list-group-item" ng-class="{active: nav.isCurrentView('function') && func == currentFunction}">{{ func.proname }}</a>
</div>
<div class="panel-footer">
<button type="button" class="btn btn-default" ng-click="refreshList()">Refresh list</button>
</div>
</div>
</div>
<!-- Sequence selector -->
<div class="panel panel-default" ng-controller="sequenceSelectorCtrl">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a href ng-show="sequences.length > 0" ng-click="nav.setCurrentView('sequences')">Sequences ({{ sequences.length }})</a>
<a href ng-hide="sequences.length > 0" ng-click="nav.setCurrentView('sequences')">Sequences</a>
</h4>
</div>
</div>
<!-- Settings -->
<div class="panel panel-default" ng-controller="settingsCtrl">
<div class="panel-heading" role="tab" id="settingsPanelHeading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#settingsPanelCollapse" aria-expanded="false" aria-controls="settingsPanelCollapse">Settings</a>
</h4>
</div>
<div id="settingsPanelCollapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="settingsPanelHeading">
<form novalidate>
<div class="panel-body">
<div class="form-group">
<label for="rowsPerPage">Default # rows in result tables</label>
<input type="number" id="rowsPerPage" class="form-control" ng-model="settings.rowsPerPage">
</div>
<div class="form-group">
<label for="sqlConsoleRowsPerPage">Default # rows in SQL console table</label>
<input type="number" id="sqlConsoleRowsPerPage" class="form-control" ng-model="settings.sqlConsoleRowsPerPage">
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="showAnalysisTables" ng-model="settings.showAnalysisTables"> Show analysis tables
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="showOverviewTables" ng-model="settings.showOverviewTables"> Show overview tables
</label>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- Map -->
<div class="panel panel-default" ng-controller="cartovlCtrl">
<div class="panel-heading" role="tab" id="cartovlPanelHeading">
<h4 class="panel-title">
<a data-toggle="collapse" title="Drag&drop tables or geometries you want to preview" href="#cartovlPanelCollapse" aria-expanded="true" aria-controls="cartovlPanelCollapse">Map preview</a>
<span class="pull-right">
<a ng-if="!reloading" role="button" title="Click to enable map reloading" style="text-decoration: none" class="text-muted" ng-click="toggleReloading()">↻</a>
<a ng-if="reloading" role="button" title="Click to disable map reloading" style="text-decoration: none; color: black" ng-click="toggleReloading()">↻</a>
</span>
</h4>
</div>
<div id="cartovlPanelCollapse" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="cartovlPanelHeading">
<div ng-controller="cartovlCtrl">
<div droppable="true" id="map"></div>
</div>
</div>
</div>
</div>
<!-- Tables view -->
<div class="col-md-9" ng-controller="tablesCtrl" ng-show="nav.isCurrentView('tables')">
<cdb-result-table rows="tables" settings="cdbrt"></cdb-result-table>
</div>
<!-- Single table view -->
<div class="col-md-9" ng-controller="tableCtrl" ng-show="nav.isCurrentView('table')">
<div role="tabpanel">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" ng-class="{active: nav.isCurrentView('table.columns')}"><a href aria-controls="columns" role="tab" ng-click="nav.setCurrentView('table.columns')">Columns</a></li>
<li role="presentation" ng-class="{active: nav.isCurrentView('table.records')}"><a href aria-controls="records" role="tab" ng-click="nav.setCurrentView('table.records')">Records</a></li>
<li role="presentation" ng-class="{active: nav.isCurrentView('table.indexes')}"><a href aria-controls="indexes" role="tab" ng-click="nav.setCurrentView('table.indexes')">Indexes</a></li>
<li role="presentation" ng-class="{active: nav.isCurrentView('table.constraints')}"><a href aria-controls="constraints" role="tab" ng-click="nav.setCurrentView('table.constraints')">Constraints</a></li>
<li role="presentation" ng-class="{active: nav.isCurrentView('table.triggers')}"><a href aria-controls="triggers" role="tab" ng-click="nav.setCurrentView('table.triggers')">Triggers</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" ng-show="nav.isCurrentView('table.columns')">
<cdb-result-table rows="columns" settings="cdbrt4Columns"></cdb-result-table>
</div>
<div role="tabpanel" class="tab-pane active" ng-show="nav.isCurrentView('table.indexes')">
<cdb-result-table rows="indexes" settings="cdbrt4Indexes"></cdb-result-table>
</div>
<div role="tabpanel" class="tab-pane active" ng-show="nav.isCurrentView('table.records')">
<cdb-result-table rows="records" settings="cdbrt4Records"></cdb-result-table>
</div>
<div role="tabpanel" class="tab-pane active" ng-show="nav.isCurrentView('table.constraints')">
<cdb-result-table rows="constraints" settings="cdbrt4Constraints"></cdb-result-table>
</div>
<div role="tabpanel" class="tab-pane active" ng-show="nav.isCurrentView('table.triggers')">
<cdb-result-table rows="triggers" settings="cdbrt4Triggers"></cdb-result-table>
</div>
</div>
</div>
</div>
<!-- Sequence view -->
<div class="col-md-9" ng-controller="sequenceCtrl" ng-show="nav.isCurrentView('sequences')">
<div role="tabpanel">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" ng-class="{active: nav.isCurrentView('sequences')}"><a href aria-controls="details" role="tab" ng-click="nav.setCurrentView('sequences')">Sequences</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" ng-show="nav.isCurrentView('sequences')">
<cdb-result-table rows="sequences" settings="cdbrt"></cdb-result-table>
</div>
</div>
</div>
</div>
<!-- Functions view -->
<div class="col-md-9" ng-controller="functionsCtrl" ng-show="nav.isCurrentView('functions')">
<cdb-result-table rows="functions" settings="cdbrt"></cdb-result-table>
</div>
<!-- Single function view -->
<div class="col-md-9" ng-controller="functionCtrl" ng-show="nav.isCurrentView('function')">
<div class="container-fluid">
<div class="row">
<div class="panel panel-default">
<div class="panel-body">
<div ui-codemirror="{ onLoad: codemirrorLoaded }" ui-codemirror-opts="editorOptions" ng-model="functionInEditor.definition"></div>
<small><i>Use Ctrl-Enter to update function</i></small>
</div>
<div class="panel-footer" style="text-align: right;">
<button type="button" class="btn btn-primary" ng-disabled="functionInEditor.api.running" ng-click="updateFunction(functionInEditor)">Update function</button>
</div>
</div>
</div>
<div class="row">
<div class="alert alert-info" role="alert" ng-show="functionInEditor.api.running">
<alert role="alert">Please wait...</alert>
</div>
<div class="alert alert-success" role="alert" ng-show="!functionInEditor.api.running && functionInEditor.api.valid">
<alert role="alert">Function updated successfully</alert>
</div>
<div class="alert alert-danger" role="alert" ng-show="!functionInEditor.api.running && functionInEditor.api.errorMessage">
<alert role="alert">{{ functionInEditor.api.errorMessage }}</alert>
</div>
</div>
</div>
</div>
<!-- SQL console view -->
<div class="col-md-9" ng-controller="sqlCtrl" ng-show="nav.isCurrentView('sql')">
<div class="container-fluid">
<div class="row">
<div class="panel panel-default">
<div class="panel-heading">
<div class="input-group" ng-class="{'has-error': historyNotFound}">
<input type="text" ng-model="sql.historyNeedle" class="form-control">
<span class="input-group-btn">
<button class="btn btn-default" ng-disabled="!sql.historyNeedle" ng-click="searchHistory(sql.historyNeedle)" type="button">Search history</button>
</span>
</div>
</div>
<div class="panel-body">
<div ui-codemirror="{ onLoad: codemirrorLoaded }" ui-codemirror-opts="editorOptions" ng-model="sql.query"></div>
<small><i>Use Ctrl-Up / Ctrl-Down to browse history, Ctrl-Enter to run query, Ctrl-Space to autocomplete table names</i></small>
</div>
<div class="panel-footer">
<button type="button" class="btn btn-warning" ng-click="cleanHistory()">Clean history</button>
<span class="pull-right">
<button type="button" class="btn btn-default" ng-click="resetConsole()">Reset console</button>
<button type="button" class="btn btn-primary" ng-disabled="sql.result.running" ng-click="execSQL(sql.query)">Execute query (Ctrl-Enter)</button>
</span>
</div>
</div>
</div>
<div class="row">
<div class="alert alert-info" role="alert" ng-show="sql.result.running">
<alert role="alert">Please wait...</alert>
</div>
<div class="alert alert-success" role="alert" ng-show="!sql.result.running && sql.result.items">
<alert role="alert">Total rows: {{ sql.result.raw.data.total_rows }}, server runtime: {{ sql.result.raw.data.time }}s</alert>
</div>
<div class="alert alert-danger" role="alert" ng-show="!sql.result.running && sql.result.errorMessage">
<alert role="alert">{{ sql.result.errorMessage }}</alert>
</div>
</div>
<div class="row" ng-show="sql.result.items">
<cdb-result-table ng-if="!isQueryPlan" rows="sql.result.items" settings="cdbrt"></cdb-result-table>
<query-plan ng-if="isQueryPlan" rows="sql.result.items" settings="cdbrt"></query-plan>
</div>
</div>
</div>
</div>
</div>
<script src="vendor/ngStorage.min.js"></script>
<script src="vendor/codemirror/codemirror.js"></script>
<script src="vendor/codemirror/sql.js"></script>
<script src="vendor/codemirror/show-hint.js"></script>
<script src="vendor/codemirror/sql-hint.js"></script>
<script src="vendor/codemirror/javascript.js"></script>
<script src="vendor/codemirror/ui-codemirror.js"></script>
<script src="vendor/angularutils/dirPagination.js"></script>
<script>
let cdbmanager = angular.module("cdbmanager", ["ngStorage", "api", "ui.codemirror", "angularUtils.directives.dirPagination"]);
cdbmanager.config(function(paginationTemplateProvider) {
paginationTemplateProvider.setPath('vendor/angularutils/dirPagination.tpl.html');
});
</script>
<script src="settings.js"></script>
<script src="ui/results.js"></script>
<script src="nav.js"></script>
<script src="alerts.js"></script>
<script src="map.js"></script>
<script src="endpoints.js"></script>
<script src="api.js"></script>
<script src="records.js"></script>
<script src="tables.js"></script>
<script src="constraints.js"></script>
<script src="sequences.js"></script>
<script src="triggers.js"></script>
<script src="functions.js"></script>
<script src="columns.js"></script>
<script src="indexes.js"></script>
<script src="sql.js"></script>
</body>
</html>