admindb 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +325 -0
- package/dist/app.d.ts +36 -0
- package/dist/app.js +186 -0
- package/dist/app.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +61 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +23 -0
- package/dist/config.js.map +1 -0
- package/dist/csv.d.ts +15 -0
- package/dist/csv.js +80 -0
- package/dist/csv.js.map +1 -0
- package/dist/db/database.d.ts +225 -0
- package/dist/db/database.js +497 -0
- package/dist/db/database.js.map +1 -0
- package/dist/db/export.d.ts +12 -0
- package/dist/db/export.js +37 -0
- package/dist/db/export.js.map +1 -0
- package/dist/db/manager.d.ts +62 -0
- package/dist/db/manager.js +206 -0
- package/dist/db/manager.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +10 -0
- package/dist/logger.js +25 -0
- package/dist/logger.js.map +1 -0
- package/dist/public/css/app.css +1 -0
- package/dist/public/css/input.css +179 -0
- package/dist/public/js/api.js +47 -0
- package/dist/public/js/app.js +120 -0
- package/dist/public/js/browse.js +123 -0
- package/dist/public/js/databases.js +45 -0
- package/dist/public/js/designer.js +205 -0
- package/dist/public/js/forms.js +244 -0
- package/dist/public/js/query.js +232 -0
- package/dist/public/js/schema.js +314 -0
- package/dist/public/js/triggers.js +155 -0
- package/dist/public/js/views.js +176 -0
- package/dist/routes/api.d.ts +9 -0
- package/dist/routes/api.js +622 -0
- package/dist/routes/api.js.map +1 -0
- package/dist/routes/databases.d.ts +19 -0
- package/dist/routes/databases.js +99 -0
- package/dist/routes/databases.js.map +1 -0
- package/dist/routes/pages.d.ts +9 -0
- package/dist/routes/pages.js +253 -0
- package/dist/routes/pages.js.map +1 -0
- package/dist/sql/classifier.d.ts +19 -0
- package/dist/sql/classifier.js +37 -0
- package/dist/sql/classifier.js.map +1 -0
- package/dist/sql/generator.d.ts +99 -0
- package/dist/sql/generator.js +259 -0
- package/dist/sql/generator.js.map +1 -0
- package/dist/test/classifier.test.d.ts +1 -0
- package/dist/test/classifier.test.js +44 -0
- package/dist/test/classifier.test.js.map +1 -0
- package/dist/test/csv.test.d.ts +1 -0
- package/dist/test/csv.test.js +64 -0
- package/dist/test/csv.test.js.map +1 -0
- package/dist/test/database.test.d.ts +1 -0
- package/dist/test/database.test.js +224 -0
- package/dist/test/database.test.js.map +1 -0
- package/dist/test/generator.test.d.ts +1 -0
- package/dist/test/generator.test.js +164 -0
- package/dist/test/generator.test.js.map +1 -0
- package/dist/test/manager.test.d.ts +1 -0
- package/dist/test/manager.test.js +146 -0
- package/dist/test/manager.test.js.map +1 -0
- package/dist/util.d.ts +29 -0
- package/dist/util.js +127 -0
- package/dist/util.js.map +1 -0
- package/dist/views/layouts/main.hbs +49 -0
- package/dist/views/pages/databases.hbs +102 -0
- package/dist/views/pages/designer.hbs +81 -0
- package/dist/views/pages/error.hbs +12 -0
- package/dist/views/pages/form.hbs +62 -0
- package/dist/views/pages/home.hbs +123 -0
- package/dist/views/pages/query.hbs +94 -0
- package/dist/views/pages/schema.hbs +290 -0
- package/dist/views/pages/table.hbs +203 -0
- package/dist/views/pages/triggers.hbs +162 -0
- package/dist/views/pages/views.hbs +134 -0
- package/dist/views/partials/navbar.hbs +50 -0
- package/dist/views/partials/sidebar.hbs +128 -0
- package/package.json +62 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<div class="space-y-6">
|
|
2
|
+
<!-- Header -->
|
|
3
|
+
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
4
|
+
<div>
|
|
5
|
+
<p class="text-sm font-semibold uppercase tracking-wider text-primary">Workspace</p>
|
|
6
|
+
<h1 class="mt-1 text-3xl font-extrabold tracking-tight">Query editor</h1>
|
|
7
|
+
<p class="mt-1.5 text-sm text-base-content/55">Run arbitrary SQL — SELECT results render as a table, COUNT gives a summary, and write statements execute.</p>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="flex flex-wrap gap-2">
|
|
10
|
+
{{#unless readonly}}
|
|
11
|
+
<button id="save-query" type="button" class="btn btn-outline btn-sm gap-1.5">
|
|
12
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4" /></svg>
|
|
13
|
+
Save query
|
|
14
|
+
</button>
|
|
15
|
+
{{/unless}}
|
|
16
|
+
<button id="run-query" type="button" class="btn btn-primary btn-sm gap-1.5">
|
|
17
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z" /><path stroke-linecap="round" stroke-linejoin="round" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
|
|
18
|
+
Run
|
|
19
|
+
</button>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<!-- Saved queries row -->
|
|
24
|
+
<div class="flex flex-wrap items-end gap-3">
|
|
25
|
+
<div class="form-control w-full max-w-xs">
|
|
26
|
+
<label class="field-label" for="saved-query-select">Saved queries</label>
|
|
27
|
+
<select id="saved-query-select" class="field-select">
|
|
28
|
+
<option value="">— select a saved query —</option>
|
|
29
|
+
{{#each savedQueries}}
|
|
30
|
+
<option value="{{this.id}}">{{this.name}}</option>
|
|
31
|
+
{{/each}}
|
|
32
|
+
</select>
|
|
33
|
+
</div>
|
|
34
|
+
{{#unless readonly}}
|
|
35
|
+
<button id="delete-query" type="button" class="btn btn-ghost btn-sm mb-0.5 text-error" disabled>Delete saved</button>
|
|
36
|
+
<div class="form-control w-full max-w-xs">
|
|
37
|
+
<label class="field-label" for="save-query-name">Save current SQL as</label>
|
|
38
|
+
<div class="join w-full">
|
|
39
|
+
<input id="save-query-name" type="text" class="field-input join-item !rounded-r-none" placeholder="query name" autocomplete="off" />
|
|
40
|
+
<button id="save-query-inline" type="button" class="btn btn-outline join-item">Save</button>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
{{/unless}}
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<!-- Editor -->
|
|
47
|
+
<div class="app-card overflow-hidden">
|
|
48
|
+
<div class="flex items-center justify-between border-b border-base-200 bg-base-200/40 px-4 py-2.5">
|
|
49
|
+
<span class="flex items-center gap-2 text-sm font-semibold text-base-content/60">
|
|
50
|
+
<span class="grid h-5 w-5 place-items-center rounded-md bg-primary/10 text-primary">
|
|
51
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" /></svg>
|
|
52
|
+
</span>
|
|
53
|
+
query.sql
|
|
54
|
+
</span>
|
|
55
|
+
<span class="text-[11px] text-base-content/40">Ctrl/⌘ + Enter to run</span>
|
|
56
|
+
</div>
|
|
57
|
+
<div class="p-3">
|
|
58
|
+
<div class="sql-editor-wrap">
|
|
59
|
+
<pre id="query-gutter" class="sql-gutter" aria-hidden="true">1</pre>
|
|
60
|
+
<textarea id="query-sql" class="sql-input" rows="10" placeholder="SELECT * FROM users WHERE …" spellcheck="false"></textarea>
|
|
61
|
+
</div>
|
|
62
|
+
<div id="query-message" class="mt-3"></div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<!-- Results -->
|
|
67
|
+
<div id="query-result" class="hidden">
|
|
68
|
+
<div class="app-card overflow-hidden">
|
|
69
|
+
<div class="flex items-center gap-2 border-b border-base-200 px-4 py-3">
|
|
70
|
+
<span id="result-kind" class="grid h-6 w-6 place-items-center rounded-md bg-success/10 text-success">
|
|
71
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" /></svg>
|
|
72
|
+
</span>
|
|
73
|
+
<span id="result-summary" class="text-sm font-medium text-base-content/60"></span>
|
|
74
|
+
<div class="ml-auto flex items-center gap-1.5">
|
|
75
|
+
<button id="export-csv" type="button" class="btn btn-ghost btn-xs gap-1 text-base-content/70 hover:text-primary" disabled>
|
|
76
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" /></svg>
|
|
77
|
+
CSV
|
|
78
|
+
</button>
|
|
79
|
+
<button id="export-json" type="button" class="btn btn-ghost btn-xs gap-1 text-base-content/70 hover:text-primary" disabled>
|
|
80
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" /></svg>
|
|
81
|
+
JSON
|
|
82
|
+
</button>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
<div class="overflow-x-auto">
|
|
86
|
+
<table class="table table-sm table-pin-rows">
|
|
87
|
+
<thead id="query-result-head" class="bg-base-200/70 text-xs uppercase tracking-wide text-base-content/50"></thead>
|
|
88
|
+
<tbody id="query-result-body"></tbody>
|
|
89
|
+
</table>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<script src="{{basePath}}/js/query.js" defer></script>
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
<div class="space-y-6">
|
|
2
|
+
<!-- Header -->
|
|
3
|
+
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
4
|
+
<div class="flex items-center gap-3.5">
|
|
5
|
+
<a href="{{basePath}}/tables/{{table}}" class="btn btn-circle btn-ghost btn-sm" aria-label="Back to table">
|
|
6
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M10 19l-7-7m0 0l7-7m-7 7h18" /></svg>
|
|
7
|
+
</a>
|
|
8
|
+
<div>
|
|
9
|
+
<p class="text-sm font-semibold uppercase tracking-wider text-primary">Schema editor</p>
|
|
10
|
+
<h1 class="font-mono text-2xl font-bold tracking-tight">{{table}}</h1>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="flex flex-wrap gap-2">
|
|
14
|
+
<a href="{{basePath}}/tables/{{table}}" class="btn btn-ghost btn-sm gap-1.5">
|
|
15
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 10h18M3 14h18m-9-4v8m-7 0h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>
|
|
16
|
+
View data
|
|
17
|
+
</a>
|
|
18
|
+
<a href="{{basePath}}/query" class="btn btn-outline btn-sm gap-1.5">
|
|
19
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" /></svg>
|
|
20
|
+
Query
|
|
21
|
+
</a>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<!-- Rename table -->
|
|
26
|
+
<div class="app-card p-5">
|
|
27
|
+
<div class="flex flex-wrap items-end gap-3">
|
|
28
|
+
<div class="w-full max-w-sm">
|
|
29
|
+
<label class="field-label" for="table-rename-input">Table name</label>
|
|
30
|
+
<input id="table-rename-input" class="field-input font-mono" value="{{table}}" spellcheck="false" autocomplete="off" {{#if isInternal}}disabled{{/if}} {{#if readonly}}disabled{{/if}} />
|
|
31
|
+
</div>
|
|
32
|
+
<button id="rename-table" type="button" class="btn btn-primary btn-sm mb-0.5" {{#if isInternal}}disabled{{/if}} {{#if readonly}}disabled{{/if}}>
|
|
33
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" /></svg>
|
|
34
|
+
Rename table
|
|
35
|
+
</button>
|
|
36
|
+
{{#if isInternal}}<span class="mb-1 text-xs text-base-content/45">Internal tables cannot be renamed.</span>{{/if}}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<!-- Columns -->
|
|
41
|
+
<div class="app-card overflow-hidden">
|
|
42
|
+
<div class="flex flex-wrap items-center justify-between gap-2 border-b border-base-200 px-5 py-4">
|
|
43
|
+
<h2 class="text-sm font-semibold uppercase tracking-wide text-base-content/45">
|
|
44
|
+
Columns
|
|
45
|
+
<span class="ml-1 rounded-md bg-base-200 px-1.5 py-0.5 text-[10px] text-base-content/50">{{schema.columns.length}}</span>
|
|
46
|
+
</h2>
|
|
47
|
+
<button id="add-column" type="button" class="btn btn-outline btn-sm gap-1.5" {{#if readonly}}disabled{{/if}}>
|
|
48
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4" /></svg>
|
|
49
|
+
Add column
|
|
50
|
+
</button>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<div id="add-column-panel" class="hidden border-b border-base-200 p-4">
|
|
54
|
+
<div id="add-column-form" class="grid grid-cols-2 items-end gap-2.5 sm:grid-cols-12"></div>
|
|
55
|
+
<div id="add-column-error" class="hidden mt-3"></div>
|
|
56
|
+
<div class="mt-3 flex gap-2">
|
|
57
|
+
<button id="add-column-submit" type="button" class="btn btn-primary btn-sm">Add column</button>
|
|
58
|
+
<button id="add-column-cancel" type="button" class="btn btn-ghost btn-sm">Cancel</button>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div class="overflow-x-auto">
|
|
63
|
+
<table class="table table-sm">
|
|
64
|
+
<thead>
|
|
65
|
+
<tr class="bg-base-200/70 text-xs uppercase tracking-wide text-base-content/50">
|
|
66
|
+
<th class="font-semibold">Name</th>
|
|
67
|
+
<th class="font-semibold">Type</th>
|
|
68
|
+
<th class="font-semibold">Constraints</th>
|
|
69
|
+
<th class="font-semibold">Default</th>
|
|
70
|
+
<th class="text-right font-semibold">Actions</th>
|
|
71
|
+
</tr>
|
|
72
|
+
</thead>
|
|
73
|
+
<tbody>
|
|
74
|
+
{{#each schema.columns}}
|
|
75
|
+
<tr class="hover:bg-primary/[0.04]">
|
|
76
|
+
<td class="col-name-cell align-middle" data-column="{{this.name}}">
|
|
77
|
+
<span class="name-display font-mono text-[13px] font-semibold">{{this.name}}</span>
|
|
78
|
+
</td>
|
|
79
|
+
<td class="align-middle"><span class="chip chip-type">{{this.type}}</span></td>
|
|
80
|
+
<td class="align-middle">
|
|
81
|
+
<div class="flex flex-wrap gap-1">
|
|
82
|
+
{{#if (gt this.pk 0)}}<span class="chip chip-pk">PK</span>{{/if}}
|
|
83
|
+
{{#if this.notnull}}<span class="chip chip-type">NOT NULL</span>{{/if}}
|
|
84
|
+
{{#if this.unique}}{{#unless (gt this.pk 0)}}<span class="chip chip-type">UNIQUE</span>{{/unless}}{{/if}}
|
|
85
|
+
{{#if this.fk}}<span class="chip chip-type">FK → {{this.fk.table}}.{{this.fk.to}}</span>{{/if}}
|
|
86
|
+
{{#if this.indexed}}<span class="chip chip-type">INDEX</span>{{/if}}
|
|
87
|
+
{{#if this.referencedBy.length}}<span class="chip chip-null" title="Referenced by {{this.referencedBy.length}} table(s)">REF × {{this.referencedBy.length}}</span>{{/if}}
|
|
88
|
+
</div>
|
|
89
|
+
</td>
|
|
90
|
+
<td class="align-middle font-mono text-[13px] text-base-content/60">
|
|
91
|
+
{{#if this.dflt_value}}{{this.dflt_value}}{{else}}<span class="text-base-content/25">—</span>{{/if}}
|
|
92
|
+
</td>
|
|
93
|
+
<td class="whitespace-nowrap text-right align-middle">
|
|
94
|
+
<div class="flex items-center justify-end gap-1">
|
|
95
|
+
<button type="button" class="btn btn-ghost btn-xs gap-1 text-base-content/70 hover:text-primary col-rename" {{#if ../readonly}}disabled{{/if}}>
|
|
96
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" /></svg>
|
|
97
|
+
Rename
|
|
98
|
+
</button>
|
|
99
|
+
<button type="button" class="btn btn-ghost btn-xs gap-1 text-error col-drop" {{#if ../readonly}}disabled{{/if}} {{#unless this.canDrop}}disabled title="{{join this.dropBlockers "; "}}"{{/unless}}>
|
|
100
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" /></svg>
|
|
101
|
+
Delete
|
|
102
|
+
</button>
|
|
103
|
+
</div>
|
|
104
|
+
</td>
|
|
105
|
+
</tr>
|
|
106
|
+
{{/each}}
|
|
107
|
+
</tbody>
|
|
108
|
+
</table>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
<!-- Foreign keys -->
|
|
113
|
+
{{#if schema.foreignKeys.length}}
|
|
114
|
+
<div class="app-card overflow-hidden">
|
|
115
|
+
<div class="border-b border-base-200 px-5 py-4">
|
|
116
|
+
<h2 class="text-sm font-semibold uppercase tracking-wide text-base-content/45">Foreign keys</h2>
|
|
117
|
+
</div>
|
|
118
|
+
<div class="overflow-x-auto">
|
|
119
|
+
<table class="table table-sm">
|
|
120
|
+
<thead>
|
|
121
|
+
<tr class="bg-base-200/70 text-xs uppercase tracking-wide text-base-content/50">
|
|
122
|
+
<th class="font-semibold">Column</th>
|
|
123
|
+
<th class="font-semibold">References</th>
|
|
124
|
+
<th class="font-semibold">On delete</th>
|
|
125
|
+
<th class="font-semibold">On update</th>
|
|
126
|
+
</tr>
|
|
127
|
+
</thead>
|
|
128
|
+
<tbody>
|
|
129
|
+
{{#each schema.foreignKeys}}
|
|
130
|
+
<tr class="hover:bg-primary/[0.04]">
|
|
131
|
+
<td class="align-middle font-mono text-[13px]">{{this.from}}</td>
|
|
132
|
+
<td class="align-middle font-mono text-[13px] text-primary">{{this.table}}.{{this.to}}</td>
|
|
133
|
+
<td class="align-middle text-[13px] text-base-content/60">{{this.on_delete}}</td>
|
|
134
|
+
<td class="align-middle text-[13px] text-base-content/60">{{this.on_update}}</td>
|
|
135
|
+
</tr>
|
|
136
|
+
{{/each}}
|
|
137
|
+
</tbody>
|
|
138
|
+
</table>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
{{/if}}
|
|
142
|
+
|
|
143
|
+
<!-- Indexes -->
|
|
144
|
+
<div class="app-card overflow-hidden">
|
|
145
|
+
<div class="flex flex-wrap items-center justify-between gap-2 border-b border-base-200 px-5 py-4">
|
|
146
|
+
<h2 class="text-sm font-semibold uppercase tracking-wide text-base-content/45">
|
|
147
|
+
Indexes
|
|
148
|
+
<span class="ml-1 rounded-md bg-base-200 px-1.5 py-0.5 text-[10px] text-base-content/50">{{schema.indexes.length}}</span>
|
|
149
|
+
</h2>
|
|
150
|
+
<button id="add-index" type="button" class="btn btn-outline btn-sm gap-1.5" {{#if readonly}}disabled{{/if}}>
|
|
151
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4" /></svg>
|
|
152
|
+
Add index
|
|
153
|
+
</button>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div id="add-index-panel" class="hidden border-b border-base-200 p-4">
|
|
157
|
+
<div class="grid grid-cols-1 gap-3 sm:grid-cols-3">
|
|
158
|
+
<div>
|
|
159
|
+
<label class="field-label" for="index-name">Index name <span class="text-base-content/40">(optional)</span></label>
|
|
160
|
+
<input id="index-name" class="field-input font-mono" placeholder="idx_users_email" spellcheck="false" autocomplete="off" />
|
|
161
|
+
</div>
|
|
162
|
+
<div class="flex items-end pb-1">
|
|
163
|
+
<label class="flex cursor-pointer items-center gap-2">
|
|
164
|
+
<input id="index-unique" type="checkbox" class="checkbox checkbox-primary checkbox-sm" />
|
|
165
|
+
<span class="text-sm font-medium text-base-content/70">Unique index</span>
|
|
166
|
+
</label>
|
|
167
|
+
</div>
|
|
168
|
+
<div class="sm:col-span-3">
|
|
169
|
+
<label class="field-label">Columns <span class="text-base-content/40">— click in the order they should appear</span></label>
|
|
170
|
+
<div id="index-columns" class="flex flex-wrap gap-2">
|
|
171
|
+
{{#each schema.columns}}
|
|
172
|
+
<button type="button" class="index-col-btn rounded-lg border border-base-300 px-2.5 py-1.5 text-[13px] font-mono hover:border-primary/50" data-column="{{this.name}}">
|
|
173
|
+
<span class="index-col-num mr-1 hidden rounded bg-primary/15 px-1 text-[10px] font-bold text-primary">1</span>{{this.name}}
|
|
174
|
+
</button>
|
|
175
|
+
{{/each}}
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
<div id="index-preview" class="mt-3 hidden">
|
|
180
|
+
<div class="rounded-xl bg-base-200/60 p-3">
|
|
181
|
+
<div class="mb-1 text-[10px] font-semibold uppercase tracking-wider text-base-content/40">Generated SQL</div>
|
|
182
|
+
<pre class="code-panel !m-0"><code id="index-preview-code"></code></pre>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
<div id="add-index-error" class="mt-3 hidden"></div>
|
|
186
|
+
<div class="mt-3 flex gap-2">
|
|
187
|
+
<button id="add-index-submit" type="button" class="btn btn-primary btn-sm">Create index</button>
|
|
188
|
+
<button id="add-index-cancel" type="button" class="btn btn-ghost btn-sm">Cancel</button>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<div class="overflow-x-auto">
|
|
193
|
+
{{#if schema.indexes.length}}
|
|
194
|
+
<table class="table table-sm">
|
|
195
|
+
<thead>
|
|
196
|
+
<tr class="bg-base-200/70 text-xs uppercase tracking-wide text-base-content/50">
|
|
197
|
+
<th class="font-semibold">Name</th>
|
|
198
|
+
<th class="font-semibold">Columns</th>
|
|
199
|
+
<th class="font-semibold">Kind</th>
|
|
200
|
+
<th class="font-semibold">SQL</th>
|
|
201
|
+
<th class="text-right font-semibold">Actions</th>
|
|
202
|
+
</tr>
|
|
203
|
+
</thead>
|
|
204
|
+
<tbody>
|
|
205
|
+
{{#each schema.indexes}}
|
|
206
|
+
<tr class="hover:bg-primary/[0.04]">
|
|
207
|
+
<td class="align-middle font-mono text-[13px]">{{this.name}}</td>
|
|
208
|
+
<td class="align-middle font-mono text-[13px] text-base-content/70">{{join this.columns ", "}}</td>
|
|
209
|
+
<td class="align-middle">
|
|
210
|
+
<div class="flex flex-wrap gap-1">
|
|
211
|
+
{{#if this.unique}}<span class="chip chip-type">UNIQUE</span>{{else}}<span class="chip chip-type">INDEX</span>{{/if}}
|
|
212
|
+
{{#unless (eq this.origin 'c')}}<span class="chip chip-null" title="Automatic index (created by SQLite)">AUTO</span>{{/unless}}
|
|
213
|
+
</div>
|
|
214
|
+
</td>
|
|
215
|
+
<td class="align-middle">
|
|
216
|
+
{{#if this.sql}}
|
|
217
|
+
<details class="group">
|
|
218
|
+
<summary class="cursor-pointer text-xs font-medium text-primary/80 hover:text-primary">View SQL</summary>
|
|
219
|
+
<pre class="mt-1 max-w-[26rem] overflow-x-auto rounded-lg bg-base-200/70 p-2 font-mono text-[11px] leading-relaxed text-base-content/70">{{this.sql}}</pre>
|
|
220
|
+
</details>
|
|
221
|
+
{{else}}
|
|
222
|
+
<span class="text-base-content/30">—</span>
|
|
223
|
+
{{/if}}
|
|
224
|
+
</td>
|
|
225
|
+
<td class="whitespace-nowrap text-right align-middle">
|
|
226
|
+
<button type="button" class="btn btn-ghost btn-xs gap-1 text-error index-drop"
|
|
227
|
+
data-index="{{this.name}}" {{#if ../readonly}}disabled{{/if}} {{#unless (eq this.origin 'c')}}disabled title="Automatic index — cannot be dropped"{{/unless}}>
|
|
228
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" /></svg>
|
|
229
|
+
Drop
|
|
230
|
+
</button>
|
|
231
|
+
</td>
|
|
232
|
+
</tr>
|
|
233
|
+
{{/each}}
|
|
234
|
+
</tbody>
|
|
235
|
+
</table>
|
|
236
|
+
{{else}}
|
|
237
|
+
<div class="px-5 py-8 text-center text-sm text-base-content/45">No indexes on this table yet.</div>
|
|
238
|
+
{{/if}}
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
<!-- Referenced by -->
|
|
243
|
+
{{#if schema.references.length}}
|
|
244
|
+
<div class="app-card overflow-hidden">
|
|
245
|
+
<div class="border-b border-base-200 px-5 py-4">
|
|
246
|
+
<h2 class="text-sm font-semibold uppercase tracking-wide text-base-content/45">Referenced by</h2>
|
|
247
|
+
</div>
|
|
248
|
+
<div class="overflow-x-auto">
|
|
249
|
+
<table class="table table-sm">
|
|
250
|
+
<thead>
|
|
251
|
+
<tr class="bg-base-200/70 text-xs uppercase tracking-wide text-base-content/50">
|
|
252
|
+
<th class="font-semibold">Table</th>
|
|
253
|
+
<th class="font-semibold">Via</th>
|
|
254
|
+
</tr>
|
|
255
|
+
</thead>
|
|
256
|
+
<tbody>
|
|
257
|
+
{{#each schema.references}}
|
|
258
|
+
<tr class="hover:bg-primary/[0.04]">
|
|
259
|
+
<td class="align-middle font-mono text-[13px]">{{this.table}}</td>
|
|
260
|
+
<td class="align-middle font-mono text-[13px] text-base-content/70">{{this.from}} → {{this.to}}</td>
|
|
261
|
+
</tr>
|
|
262
|
+
{{/each}}
|
|
263
|
+
</tbody>
|
|
264
|
+
</table>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
{{/if}}
|
|
268
|
+
|
|
269
|
+
<!-- Danger zone -->
|
|
270
|
+
{{#unless isInternal}}
|
|
271
|
+
<div class="rounded-2xl border border-error/25 bg-error/[0.03] p-5">
|
|
272
|
+
<h2 class="flex items-center gap-2 text-sm font-semibold uppercase tracking-wide text-error">
|
|
273
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>
|
|
274
|
+
Danger zone
|
|
275
|
+
</h2>
|
|
276
|
+
<p class="mt-1 text-sm text-base-content/55">Dropping this table permanently removes its schema and all of its data.</p>
|
|
277
|
+
<div class="mt-3 flex flex-wrap items-center gap-3">
|
|
278
|
+
<button id="drop-table" type="button" class="btn btn-error btn-sm" {{#if readonly}}disabled{{/if}} {{#if schema.references.length}}disabled title="Referenced by {{schema.references.length}} table(s)"{{/if}}>
|
|
279
|
+
Drop table
|
|
280
|
+
</button>
|
|
281
|
+
{{#if readonly}}<span class="text-xs text-base-content/50">Read-only — table changes are disabled.</span>{{/if}}
|
|
282
|
+
{{#if schema.references.length}}
|
|
283
|
+
<span class="text-xs text-base-content/50">Cannot drop — referenced by {{schema.references.length}} table(s).</span>
|
|
284
|
+
{{/if}}
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
{{/unless}}
|
|
288
|
+
</div>
|
|
289
|
+
<script id="schema-config" type="application/json">{{{json config}}}</script>
|
|
290
|
+
<script src="{{basePath}}/js/schema.js" defer></script>
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
<div class="space-y-5">
|
|
2
|
+
<!-- Header -->
|
|
3
|
+
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
4
|
+
<div class="flex items-center gap-3.5">
|
|
5
|
+
<span class="grid h-12 w-12 place-items-center rounded-xl bg-primary/10 text-primary">
|
|
6
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 10h18M3 14h18m-9-4v8m-7 0h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>
|
|
7
|
+
</span>
|
|
8
|
+
<div>
|
|
9
|
+
<h1 class="font-mono text-2xl font-bold tracking-tight">{{table}}</h1>
|
|
10
|
+
<p class="text-sm text-base-content/55">
|
|
11
|
+
{{count}} row(s) · {{info.columns.length}} column(s)
|
|
12
|
+
{{#if pkCols.length}}· PK <span class="font-mono">{{join pkCols ", "}}</span>{{/if}}
|
|
13
|
+
</p>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="flex flex-wrap gap-2">
|
|
17
|
+
<a href="{{basePath}}/tables/{{table}}/schema" class="btn btn-ghost btn-sm gap-1.5">
|
|
18
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /></svg>
|
|
19
|
+
Edit schema
|
|
20
|
+
</a>
|
|
21
|
+
<a href="{{basePath}}/export" class="btn btn-ghost btn-sm gap-1.5">
|
|
22
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" /></svg>
|
|
23
|
+
SQL dump
|
|
24
|
+
</a>
|
|
25
|
+
<div class="dropdown dropdown-end">
|
|
26
|
+
<div tabindex="0" role="button" class="btn btn-outline btn-sm gap-1.5">
|
|
27
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" /></svg>
|
|
28
|
+
Export
|
|
29
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7" /></svg>
|
|
30
|
+
</div>
|
|
31
|
+
<ul tabindex="0" class="dropdown-content menu z-50 w-40 rounded-xl border border-base-300 bg-base-100 p-1.5 shadow-lift">
|
|
32
|
+
<li><a href="{{basePath}}/api/tables/{{table}}/export?format=csv">CSV</a></li>
|
|
33
|
+
<li><a href="{{basePath}}/api/tables/{{table}}/export?format=json">JSON</a></li>
|
|
34
|
+
</ul>
|
|
35
|
+
</div>
|
|
36
|
+
{{#unless readonly}}
|
|
37
|
+
<button id="import-csv" type="button" class="btn btn-outline btn-sm gap-1.5">
|
|
38
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" /></svg>
|
|
39
|
+
Import CSV
|
|
40
|
+
</button>
|
|
41
|
+
{{/unless}}
|
|
42
|
+
<a href="{{basePath}}/query" class="btn btn-outline btn-sm gap-1.5">
|
|
43
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" /></svg>
|
|
44
|
+
Query
|
|
45
|
+
</a>
|
|
46
|
+
{{#unless readonly}}
|
|
47
|
+
<a href="{{basePath}}/tables/{{table}}/rows/new" class="btn btn-primary btn-sm gap-1.5">
|
|
48
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4" /></svg>
|
|
49
|
+
New row
|
|
50
|
+
</a>
|
|
51
|
+
{{/unless}}
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<!-- Row filters -->
|
|
56
|
+
<form id="filter-form" class="app-card p-4">
|
|
57
|
+
<div class="mb-3 flex flex-wrap items-center justify-between gap-2">
|
|
58
|
+
<span class="flex items-center gap-2 text-sm font-semibold uppercase tracking-wide text-base-content/45">
|
|
59
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414A1 1 0 0014 15.414V20a1 1 0 01-1 1h-2a1 1 0 01-1-1v-4.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z" /></svg>
|
|
60
|
+
Filter rows
|
|
61
|
+
</span>
|
|
62
|
+
<span class="text-xs text-base-content/40">Tip: <code>=exact</code> · <code>>5</code> · <code><=10</code> · <code>pre*</code> starts with · plain text = contains</span>
|
|
63
|
+
</div>
|
|
64
|
+
<div class="grid grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4">
|
|
65
|
+
{{#each colNames}}
|
|
66
|
+
<label class="block">
|
|
67
|
+
<span class="field-label !mb-1 font-mono">{{this}}</span>
|
|
68
|
+
<input type="text" class="field-input filter-input !py-1.5 !text-[13px]" name="{{this}}" value="{{lookup ../filters this}}" placeholder="filter…" autocomplete="off" spellcheck="false" />
|
|
69
|
+
</label>
|
|
70
|
+
{{/each}}
|
|
71
|
+
</div>
|
|
72
|
+
<div class="mt-3 flex flex-wrap items-center gap-2">
|
|
73
|
+
<button type="submit" class="btn btn-primary btn-sm gap-1.5">
|
|
74
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /></svg>
|
|
75
|
+
Apply filter
|
|
76
|
+
</button>
|
|
77
|
+
<button type="button" id="clear-filter" class="btn btn-ghost btn-sm">Clear</button>
|
|
78
|
+
{{#if filterQS}}
|
|
79
|
+
<span class="text-xs text-base-content/50">Filtering <b class="tabular-nums">{{count}}</b> row(s).</span>
|
|
80
|
+
{{/if}}
|
|
81
|
+
</div>
|
|
82
|
+
</form>
|
|
83
|
+
|
|
84
|
+
<!-- CSV import -->
|
|
85
|
+
<div id="import-panel" class="app-card hidden p-4">
|
|
86
|
+
<div class="mb-3 flex items-center justify-between">
|
|
87
|
+
<h2 class="text-sm font-semibold uppercase tracking-wide text-base-content/45">Import CSV into <span class="font-mono normal-case">{{table}}</span></h2>
|
|
88
|
+
<button id="import-csv-close" type="button" class="btn btn-ghost btn-xs" aria-label="Close">×</button>
|
|
89
|
+
</div>
|
|
90
|
+
<div class="space-y-3">
|
|
91
|
+
<textarea id="import-csv-text" rows="6" class="field-input w-full font-mono text-[13px]" placeholder="id,name,email 1,Ada,ada@example.com 2,Bob,bob@example.com" spellcheck="false"></textarea>
|
|
92
|
+
<div class="flex flex-wrap items-center gap-3">
|
|
93
|
+
<input type="file" id="import-csv-file" class="file-input file-input-sm w-full max-w-xs" accept=".csv,text/csv" />
|
|
94
|
+
<button id="import-csv-submit" type="button" class="btn btn-primary btn-sm gap-1.5">
|
|
95
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" /></svg>
|
|
96
|
+
Import
|
|
97
|
+
</button>
|
|
98
|
+
</div>
|
|
99
|
+
<p class="text-xs text-base-content/45">The first row must be column names matching this table. Empty cells are treated as “not set” so database defaults apply. The import is transactional — a failed row rolls back everything.</p>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
{{#if rows.length}}
|
|
104
|
+
<div class="app-card overflow-hidden">
|
|
105
|
+
<!-- Toolbar -->
|
|
106
|
+
<div class="flex flex-wrap items-center justify-between gap-2 border-b border-base-200 px-4 py-3">
|
|
107
|
+
<span class="text-sm text-base-content/55">Showing <b class="tabular-nums">{{firstRow}}</b>–<b class="tabular-nums">{{lastRow}}</b> of <b class="tabular-nums">{{count}}</b> rows</span>
|
|
108
|
+
<label class="flex items-center gap-2 text-sm text-base-content/55">
|
|
109
|
+
Rows per page
|
|
110
|
+
<select id="page-size" class="field-select !w-auto !py-1.5 !text-[13px]" data-table="{{table}}" data-orderby="{{orderBy}}" data-orderdir="{{orderDir}}" data-filters="{{filterQS}}">
|
|
111
|
+
{{#each sizes}}<option value="{{this}}" {{#if (eq this ../pageSize)}}selected{{/if}}>{{this}}</option>{{/each}}
|
|
112
|
+
</select>
|
|
113
|
+
</label>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<div class="overflow-x-auto">
|
|
117
|
+
<table class="table table-sm table-pin-rows">
|
|
118
|
+
<thead>
|
|
119
|
+
<tr class="bg-base-200/70 text-xs uppercase tracking-wide text-base-content/50">
|
|
120
|
+
{{#each colHeaders}}
|
|
121
|
+
<th class="whitespace-nowrap font-semibold">
|
|
122
|
+
<a href="{{this.href}}" class="sort-link {{#if this.active}}active{{/if}}" title="Sort by {{this.name}}">
|
|
123
|
+
<span class="font-mono normal-case">{{this.name}}</span>
|
|
124
|
+
{{#if this.pk}}<span class="chip chip-pk">PK</span>{{/if}}
|
|
125
|
+
<span class="sort-arrow">{{#if (eq this.dir 'desc')}}↓{{else}}↑{{/if}}</span>
|
|
126
|
+
</a>
|
|
127
|
+
</th>
|
|
128
|
+
{{/each}}
|
|
129
|
+
<th class="text-right font-semibold">Actions</th>
|
|
130
|
+
</tr>
|
|
131
|
+
</thead>
|
|
132
|
+
<tbody>
|
|
133
|
+
{{#each rows}}
|
|
134
|
+
<tr class="group hover:bg-primary/[0.04]">
|
|
135
|
+
{{#each this.cells}}
|
|
136
|
+
<td class="max-w-xs align-middle">
|
|
137
|
+
{{#if this.isNull}}
|
|
138
|
+
<span class="chip chip-null">NULL</span>
|
|
139
|
+
{{else}}
|
|
140
|
+
<span class="block max-w-xs truncate font-mono text-[13px]" title="{{this.display}}">{{truncate this.display 120}}</span>
|
|
141
|
+
{{/if}}
|
|
142
|
+
</td>
|
|
143
|
+
{{/each}}
|
|
144
|
+
<td class="whitespace-nowrap text-right align-middle">
|
|
145
|
+
{{#unless ../readonly}}
|
|
146
|
+
{{#if this.pkEncoded}}
|
|
147
|
+
<div class="row-actions">
|
|
148
|
+
<a href="{{../basePath}}/tables/{{../table}}/rows/{{this.pkEncoded}}/edit" class="btn btn-ghost btn-xs gap-1 text-base-content/70 hover:text-primary">
|
|
149
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" /></svg>
|
|
150
|
+
Edit
|
|
151
|
+
</a>
|
|
152
|
+
<button type="button" class="btn btn-ghost btn-xs gap-1 text-error js-delete-row"
|
|
153
|
+
data-table="{{../table}}" data-pk="{{this.pkEncoded}}">
|
|
154
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" /></svg>
|
|
155
|
+
Delete
|
|
156
|
+
</button>
|
|
157
|
+
</div>
|
|
158
|
+
{{else}}
|
|
159
|
+
<span class="text-xs text-base-content/35">No PK</span>
|
|
160
|
+
{{/if}}
|
|
161
|
+
{{/unless}}
|
|
162
|
+
</td>
|
|
163
|
+
</tr>
|
|
164
|
+
{{/each}}
|
|
165
|
+
</tbody>
|
|
166
|
+
</table>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<!-- Pagination -->
|
|
170
|
+
{{#if (gt pages 1)}}
|
|
171
|
+
<div class="flex flex-wrap items-center justify-between gap-2 border-t border-base-200 px-4 py-3">
|
|
172
|
+
<span class="text-sm text-base-content/50">Page {{page}} of {{pages}}</span>
|
|
173
|
+
<div class="flex gap-1.5">
|
|
174
|
+
<a href="{{basePath}}/tables/{{table}}?page={{sub page 1}}&size={{pageSize}}&orderBy={{orderBy}}&orderDir={{orderDir}}{{#if filterQS}}&{{filterQS}}{{/if}}"
|
|
175
|
+
class="btn btn-outline btn-sm {{#unless (gt page 1)}}btn-disabled{{/unless}}" aria-disabled="{{#if (gt page 1)}}false{{else}}true{{/if}}">
|
|
176
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" /></svg>
|
|
177
|
+
Prev
|
|
178
|
+
</a>
|
|
179
|
+
<a href="{{basePath}}/tables/{{table}}?page={{add page 1}}&size={{pageSize}}&orderBy={{orderBy}}&orderDir={{orderDir}}{{#if filterQS}}&{{filterQS}}{{/if}}"
|
|
180
|
+
class="btn btn-outline btn-sm {{#unless (lt page pages)}}btn-disabled{{/unless}}" aria-disabled="{{#if (lt page pages)}}false{{else}}true{{/if}}">
|
|
181
|
+
Next
|
|
182
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" /></svg>
|
|
183
|
+
</a>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
{{/if}}
|
|
187
|
+
</div>
|
|
188
|
+
{{else}}
|
|
189
|
+
<div class="empty-state">
|
|
190
|
+
<span class="empty-icon">
|
|
191
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-7 w-7" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" /></svg>
|
|
192
|
+
</span>
|
|
193
|
+
<p class="text-sm font-medium text-base-content/70">No rows in <span class="font-mono">{{table}}</span></p>
|
|
194
|
+
<div class="mt-2 flex gap-2">
|
|
195
|
+
{{#unless readonly}}
|
|
196
|
+
<a href="{{basePath}}/tables/{{table}}/rows/new" class="btn btn-primary btn-sm">Insert a row</a>
|
|
197
|
+
{{/unless}}
|
|
198
|
+
<a href="{{basePath}}/query" class="btn btn-outline btn-sm">Run a query</a>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
{{/if}}
|
|
202
|
+
</div>
|
|
203
|
+
<script src="{{basePath}}/js/browse.js" defer></script>
|