Skip to content

Commit

Permalink
feat: render "active time" in torrent info tab (#537) @invakid404
Browse files Browse the repository at this point in the history
  • Loading branch information
invakid404 committed Nov 14, 2022
1 parent 470384d commit d3cf4d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/components/TorrentDetail/Tabs/Info.vue
Expand Up @@ -44,6 +44,15 @@
{{ torrent.size | getDataUnit(1) }}
</td>
</tr>
<tr>
<td :class="commonStyle">
{{ $t("torrent.timeActive") | titleCase }}
</td>
<td>
{{ torrent.time_active }}
<span v-if="torrent.seeding_time">{{ `(${$t("torrent.seededFor")} ${torrent.seeding_time})` }}</span>
</td>
</tr>
<tr>
<td :class="commonStyle">
{{ $t('torrent.downloaded') | titleCase }}
Expand Down
4 changes: 3 additions & 1 deletion src/lang/en.js
Expand Up @@ -57,7 +57,9 @@ const locale = {
created: 'created by',
comments: 'comments',
uploadedSession: 'Uploaded Session',
torrentTitle: 'Torrent Title'
torrentTitle: 'Torrent Title',
timeActive: 'Time Active',
seededFor: 'seeded for'
},
/** Navbar */
navbar: {
Expand Down
7 changes: 7 additions & 0 deletions src/models/Torrent.js
@@ -1,3 +1,8 @@
import dayjs from 'dayjs'
import duration from 'dayjs/plugin/duration'

dayjs.extend(duration)

export default class Torrent {
constructor(data) {
this.name = data.name
Expand Down Expand Up @@ -32,6 +37,8 @@ export default class Torrent {
this.availability = Math.round(data.availability * 100) / 100
this.forced = data.state.includes('forced')
this.magnet = data.magnet_uri
this.time_active = dayjs.duration(data.time_active, 'seconds').format('D[d] H[h] m[m] s[s]')
this.seeding_time = data.seeding_time > 0 ? dayjs.duration(data.seeding_time, 'seconds').format('D[d] H[h] m[m] s[s]') : null

Object.freeze(this)
}
Expand Down

0 comments on commit d3cf4d5

Please sign in to comment.