Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
sorted files and tasks by added time
Browse files Browse the repository at this point in the history
  • Loading branch information
boypt committed Aug 29, 2019
1 parent 6b540e4 commit 8797ed3
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 17 deletions.
5 changes: 4 additions & 1 deletion engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ func (e *Engine) upsertTorrent(tt *torrent.Torrent) *Torrent {
ih := tt.InfoHash().HexString()
torrent, ok := e.ts[ih]
if !ok {
torrent = &Torrent{InfoHash: ih}
torrent = &Torrent{
InfoHash: ih,
AddedAt: time.Now(),
}
e.ts[ih] = torrent
}
//update torrent fields using underlying torrent
Expand Down
1 change: 1 addition & 0 deletions engine/torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Torrent struct {
DownloadRate float32
UploadRate float32
SeedRatio float32
AddedAt time.Time
Stats torrent.TorrentStats
t *torrent.Torrent
updatedAt time.Time
Expand Down
11 changes: 0 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,20 @@ go 1.12

require (
github.com/NYTimes/gziphandler v1.1.1
github.com/PuerkitoBio/goquery v1.5.0 // indirect
github.com/anacrolix/torrent v1.5.2
github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 // indirect
github.com/boypt/scraper v0.0.0-20190812010241-70ab02dcd31b
github.com/elazarl/go-bindata-assetfs v1.0.0
github.com/elithrar/simple-scrypt v1.3.0 // indirect
github.com/gorilla/websocket v1.4.0 // indirect
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/jpillora/ansi v0.0.0-20170202005112-f496b27cd669 // indirect
github.com/jpillora/archive v0.0.0-20160301031048-e0b3681851f1
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7
github.com/jpillora/cloud-torrent v0.0.0-00010101000000-000000000000
github.com/jpillora/cookieauth v0.0.0-20190219222732-2ae29b2a9c76
github.com/jpillora/eventsource v0.0.0-20170920003432-7ed8c999e167 // indirect
github.com/jpillora/opts v1.0.5
github.com/jpillora/requestlog v0.0.0-20181015073026-df8817be5f82
github.com/jpillora/scraper v0.0.0-20171020112404-0b5e5ce320ff
github.com/jpillora/sizestr v0.0.0-20160130011556-e2ea2fa42fb9 // indirect
github.com/jpillora/velox v0.0.0-20180825063758-42845d323220
github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
github.com/radovskyb/watcher v1.0.6
github.com/shirou/gopsutil v2.18.12+incompatible
github.com/skratchdot/open-golang v0.0.0-20190402232053-79abb63cd66e
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ github.com/gopherjs/gopherjs v0.0.0-20190309154008-847fc94819f9 h1:Z0f701LpR4dqO
github.com/gopherjs/gopherjs v0.0.0-20190309154008-847fc94819f9/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gosuri/uilive v0.0.0-20170323041506-ac356e6e42cd/go.mod h1:qkLSc0A5EXSP6B04TrN4oQoxqFI7A8XvoXSlJi8cwk8=
github.com/gosuri/uilive v0.0.3/go.mod h1:qkLSc0A5EXSP6B04TrN4oQoxqFI7A8XvoXSlJi8cwk8=
github.com/gosuri/uiprogress v0.0.0-20170224063937-d0567a9d84a1/go.mod h1:C1RTYn4Sc7iEyf6j8ft5dyoZ4212h8G1ol9QQluh5+0=
Expand Down
7 changes: 7 additions & 0 deletions server/server_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"os"
"path/filepath"
"sort"
"strings"
"time"

Expand Down Expand Up @@ -110,5 +111,11 @@ func list(path string, info os.FileInfo, node *fsNode, n *int) error {
node.Size += c.Size
node.Children = append(node.Children, c)
}

// sort by modified time
sort.Slice(node.Children, func(i, j int) bool {
return node.Children[i].Modified.Before(node.Children[j].Modified)
})

return nil
}
8 changes: 4 additions & 4 deletions static/files.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions static/files/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ app.filter("round", function() {
};
});

app.filter('dictValuesArray', function () {
return function (obj) {
if (!(obj instanceof Object)) return obj;

var arr = [];
for (var key in obj) {
arr.push(obj[key]);
}
return arr;
}
})

app.directive("ngEnter", function() {
return function(scope, element, attrs) {
element.bind("keydown keypress", function(event) {
Expand Down
2 changes: 1 addition & 1 deletion static/files/template/torrents.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h5 class="right">
<p>Add torrents above</p>
</div>

<div ng-repeat="(hash, t) in state.Torrents" ng-class="{open: t.open}" class="ui torrent segment">
<div ng-repeat="t in state.Torrents | dictValuesArray | orderBy:'AddedAt'" ng-class="{open: t.open}" class="ui torrent segment">

<div ng-if="!t.Loaded" class="ui active inverted dimmer">
<div class="ui text loader">Loading</div>
Expand Down

0 comments on commit 8797ed3

Please sign in to comment.