Browse Source

Add date field to bookmarks

master
Alfred 9 months ago
parent
commit
79867b3c41
5 changed files with 15 additions and 2 deletions
  1. 1
    0
      package.json
  2. 1
    1
      pgsql/schema.pgsql
  3. 11
    1
      src/components/BookmarkControl.vue
  4. 1
    0
      src/models/Bookmark.js
  5. 1
    0
      src/scss/main.scss

+ 1
- 0
package.json View File

@@ -17,6 +17,7 @@
17 17
     "axios": "^0.18.0",
18 18
     "bulma": "^0.7.1",
19 19
     "lodash": "^4.17.10",
20
+    "moment": "^2.22.2",
20 21
     "querystring": "^0.2.0",
21 22
     "vue": "^2.5.2",
22 23
     "vue-router": "^3.0.1"

+ 1
- 1
pgsql/schema.pgsql View File

@@ -13,7 +13,7 @@ create table macarrodes.t_bookmarks (
13 13
   url text not null,
14 14
   favicon text,
15 15
   main_image text,
16
-  date_add date default current_date,
16
+  date_add timestamp default current_date,
17 17
   len integer,
18 18
   lan text,
19 19
   nclicks integer default 0,

+ 11
- 1
src/components/BookmarkControl.vue View File

@@ -2,7 +2,7 @@
2 2
 <div id="bookmark-control">
3 3
     <div class="row">
4 4
       <span class="text">[ {{ bookmark.nclicks }} ]</span>
5
-      <span class="text">bookmark.date</span>
5
+      <span class="text" :alt="bookmark.date">{{ strDate }}</span>
6 6
       <span class="text">|</span>
7 7
       <span class="text"><a :href="'https://' + bookmark.site" v-text="bookmark.site"></a></span>
8 8
       <span class="text">|</span>
@@ -16,11 +16,21 @@
16 16
 <script>
17 17
 import TagControl from './TagControl'
18 18
 import axios from 'axios'
19
+import moment from 'moment'
19 20
 
20 21
 export default {
21 22
   components: {
22 23
     tagControl: TagControl
23 24
   },
25
+  data () {
26
+    return {
27
+    }
28
+  },
29
+  computed: {
30
+    strDate () {
31
+      return moment(this.bookmark.date).fromNow()
32
+    }
33
+  },
24 34
   props: {
25 35
     bookmark: null
26 36
   },

+ 1
- 0
src/models/Bookmark.js View File

@@ -12,6 +12,7 @@ export default class Bookmark {
12 12
     this.tags = (data) ? _.map(data.tags, (e) => { return new Tag(e) }) : []
13 13
     this.language = (data) ? data.language : ''
14 14
     this.isNew = this.id === undefined
15
+    this.date = (data) ? data.date_add : undefined
15 16
   }
16 17
 
17 18
   dto () {

+ 1
- 0
src/scss/main.scss View File

@@ -41,6 +41,7 @@ a {
41 41
 .tabs {
42 42
     a {
43 43
         color: white;
44
+        border: none;
44 45
 
45 46
         &:hover {
46 47
             color: $secondary-color;

Loading…
Cancel
Save