Skip to content
Snippets Groups Projects
Verified Commit 41e533f7 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Optimalizace zobrazovani seznamu, popup se zktakou po pridani

parent 64123f28
No related branches found
No related tags found
No related merge requests found
Pipeline #11053 passed
2.2.2 2.3.0
...@@ -72,7 +72,7 @@ sub create ($c) { ...@@ -72,7 +72,7 @@ sub create ($c) {
$c->render( $c->render(
status => 201, status => 201,
openapi => { id => $shortcut->id }, openapi => { $shortcut->get_columns },
); );
} }
...@@ -103,7 +103,7 @@ sub list ($c) { ...@@ -103,7 +103,7 @@ sub list ($c) {
SHORTCUT: SHORTCUT:
foreach my $shortcut ( $c->user->shortcuts( foreach my $shortcut ( $c->user->shortcuts(
{ deleted => undef }, { deleted => undef },
{ order_by => 'shortcut' }, { order_by => {-desc => 'created'} },
) ) { ) ) {
push @shortcuts, $c->spec_filter( push @shortcuts, $c->spec_filter(
{ $shortcut->get_columns }, 'Shortcut' { $shortcut->get_columns }, 'Shortcut'
......
...@@ -27,6 +27,9 @@ components: ...@@ -27,6 +27,9 @@ components:
type: integer type: integer
readOnly: true readOnly: true
maxLength: 8 maxLength: 8
created:
type: string
description: Datum přidání
shortcut: shortcut:
type: string type: string
description: Zkratka description: Zkratka
...@@ -91,6 +94,10 @@ paths: ...@@ -91,6 +94,10 @@ paths:
responses: responses:
201: 201:
description: Shortcut created description: Shortcut created
content:
application/json:
schema:
$ref: '#/components/schemas/Shortcut'
get: get:
tags: tags:
- shortcuts - shortcuts
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
<thead> <thead>
<tr> <tr>
<th class="text-left">Zkratka</th> <th class="text-left">Zkratka</th>
<th class="text-left">Přidano</th>
<th class="text-left">URL</th> <th class="text-left">URL</th>
<th class="text-left">Přesměrování</th> <th class="text-left">Přesměrování</th>
<th class="text-left">Kliky</th> <th class="text-left">Kliky</th>
...@@ -41,6 +42,7 @@ ...@@ -41,6 +42,7 @@
<tbody> <tbody>
<tr v-for="shortcut in shortcuts" > <tr v-for="shortcut in shortcuts" >
<td class="text-bold w-32" @click="showEdit(shortcut)" >{{shortcut.shortcut}}</td> <td class="text-bold w-32" @click="showEdit(shortcut)" >{{shortcut.shortcut}}</td>
<td class="text-bold w-32" @click="showEdit(shortcut)" >{{ formatTimestamp(shortcut.created) }}</td>
<td v-bind:title="shortcut.url" @click="showEdit(shortcut)" >{{ stripURL(shortcut.url) }}</td> <td v-bind:title="shortcut.url" @click="showEdit(shortcut)" >{{ stripURL(shortcut.url) }}</td>
<td class="w-24" @click="showEdit(shortcut)">{{ shortcut.code == 301 ? '301 trvalé' : '302 dočasné'}}</td> <td class="w-24" @click="showEdit(shortcut)">{{ shortcut.code == 301 ? '301 trvalé' : '302 dočasné'}}</td>
<td class="w-16 text-right" @click="showEdit(shortcut)">{{shortcut.counter}}</td> <td class="w-16 text-right" @click="showEdit(shortcut)">{{shortcut.counter}}</td>
...@@ -144,6 +146,7 @@ ...@@ -144,6 +146,7 @@
</div> </div>
<script type="module"> <script type="module">
const MAX_URL_LENGTH = 50;
const BASE_URL = "/api/shortcuts"; const BASE_URL = "/api/shortcuts";
const API_HEADERS = { const API_HEADERS = {
"Content-Type": "application/json", "Content-Type": "application/json",
...@@ -185,8 +188,11 @@ ...@@ -185,8 +188,11 @@
}) })
.then( response => { .then( response => {
if ( response.status == 201 ) { if ( response.status == 201 ) {
this.shortcut = {} this.shortcut = {};
app.fetchData(); app.fetchData();
response.json().then(json => {
this.showInfo(json)
})
} }
else { else {
response.json().then(json => { response.json().then(json => {
...@@ -238,10 +244,15 @@ ...@@ -238,10 +244,15 @@
}, },
stripURL: function(url) { stripURL: function(url) {
const urlObj = new URL(url); if ( url.length > MAX_URL_LENGTH ) {
urlObj.search = ''; url = url.substring(0, MAX_URL_LENGTH) + '...';
urlObj.hash = ''; }
return urlObj.toString(); return url;
},
formatTimestamp: function(timestamp) {
timestamp = new Date(timestamp);
return timestamp.toLocaleDateString('cs-CZ');
}, },
showDelete: function(shortcut) { showDelete: function(shortcut) {
...@@ -250,7 +261,6 @@ ...@@ -250,7 +261,6 @@
}, },
showInfo: function(shortcut) { showInfo: function(shortcut) {
this.selectedShortcut = shortcut;
this.selectedShortcut.full_url = 'https://<%= config->{domain} %>/'+ shortcut.shortcut ; this.selectedShortcut.full_url = 'https://<%= config->{domain} %>/'+ shortcut.shortcut ;
this.shortcutInfoVisible = true; this.shortcutInfoVisible = true;
navigator.clipboard.writeText(this.selectedShortcut.full_url); navigator.clipboard.writeText(this.selectedShortcut.full_url);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment