From 98cdc94e2bc568560f3510330d5c58dee55bc051 Mon Sep 17 00:00:00 2001 From: OldHawk Date: Fri, 3 Nov 2017 16:53:09 +0800 Subject: [PATCH] feat(torrents): show seed or leech progress stats in home torrent list --- .../torrent-progress.client.directive.js | 55 +++++++++++++++++-- .../core/client/views/home.client.view.html | 19 ++++++- .../views/list-torrents.client.view.html | 1 + 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/modules/core/client/directives/torrent-progress.client.directive.js b/modules/core/client/directives/torrent-progress.client.directive.js index 04586ec9..3ad1f20c 100644 --- a/modules/core/client/directives/torrent-progress.client.directive.js +++ b/modules/core/client/directives/torrent-progress.client.directive.js @@ -22,12 +22,12 @@ scope.$watch(attrs.torrentProgress, function (p) { if (p && p.length > 0) { var pt = p[0]; - mtDebug.info(pt); + //mtDebug.info(pt); var t_progressbar = ngProgressFactory.createInstance(); t_progressbar.setParent(element[0]); t_progressbar.setAbsolute(); - t_progressbar.setHeight('3px'); + t_progressbar.setHeight('2px'); if(pt.peer_status === PEERSTATE_SEEDER){ t_progressbar.set(100); t_progressbar.setColor('#ff6600'); @@ -36,12 +36,59 @@ t_progressbar.setColor('#5cb85c'); } t_progressbar.progressbarEl.css('background-color', '#dedede'); - t_progressbar.progressbarEl.css('top', '-6px'); + t_progressbar.progressbarEl.css('top', '-5px'); t_progressbar.progressbarEl.css('left', '8px'); t_progressbar.progressbarEl.css('right', '8px'); //element.css('margin-bottom', '8px'); - console.log(t_progressbar); + //console.log(t_progressbar); + } + }); + } + } + + + angular.module('core') + .directive('cardProgress', cardProgress); + + cardProgress.$inject = ['$compile', 'DebugConsoleService', 'ngProgressFactory']; + + function cardProgress($compile, mtDebug, ngProgressFactory) { + const PEERSTATE_SEEDER = 'seeder'; + const PEERSTATE_LEECHER = 'leecher'; + + var directive = { + restrict: 'A', + replace: true, + link: link + }; + + return directive; + + function link(scope, element, attrs) { + scope.$watch(attrs.cardProgress, function (p) { + if (p && p.length > 0) { + var pt = p[0]; + //mtDebug.info(pt); + + var t_progressbar = ngProgressFactory.createInstance(); + t_progressbar.setParent(element[0]); + t_progressbar.setAbsolute(); + t_progressbar.setHeight('2px'); + if(pt.peer_status === PEERSTATE_SEEDER){ + t_progressbar.set(100); + t_progressbar.setColor('#ff6600'); + }else { + t_progressbar.set(pt.peer_percent); + t_progressbar.setColor('#5cb85c'); + } + t_progressbar.progressbarEl.css('background-color', '#dedede'); + t_progressbar.progressbarEl.css('top', '0'); + //t_progressbar.progressbarEl.css('left', '8px'); + //t_progressbar.progressbarEl.css('right', '8px'); + + //element.css('margin-bottom', '8px'); + //console.log(t_progressbar); } }); } diff --git a/modules/core/client/views/home.client.view.html b/modules/core/client/views/home.client.view.html index 865ab38c..cf3763fb 100644 --- a/modules/core/client/views/home.client.view.html +++ b/modules/core/client/views/home.client.view.html @@ -133,8 +133,8 @@ -
+
+
{{$index + 1}}. {{nt.resource_detail_info.title}}
@@ -355,6 +356,7 @@
+
+
{{$index + 1}}. {{nt.resource_detail_info.name}} S{{nt.torrent_seasons}}E{{nt.torrent_episodes}} @@ -525,6 +528,7 @@
+
  • +
    {{$index + 1}}. {{nm.resource_detail_info.title}}
    @@ -700,6 +705,7 @@
    +
    • +
      {{$index + 1}}. {{nm.resource_detail_info.title}}
      @@ -868,6 +875,7 @@
      +
      • +
        {{$index + 1}}. {{nm.resource_detail_info.title}}
        @@ -1036,6 +1045,7 @@
        +
        • +
          {{$index + 1}}. {{nm.resource_detail_info.title}}
          @@ -1204,6 +1215,7 @@
          +
          • +
            {{$index + 1}}. {{nm.resource_detail_info.title}}
            @@ -1372,6 +1385,7 @@
            +
            • +
              {{$index + 1}}. {{nm.resource_detail_info.title}}
              @@ -1540,6 +1555,7 @@
              +
              • +
                {{$index + 1}}. {{nm.resource_detail_info.title}}
                diff --git a/modules/torrents/client/views/list-torrents.client.view.html b/modules/torrents/client/views/list-torrents.client.view.html index 2105557b..d3387a17 100644 --- a/modules/torrents/client/views/list-torrents.client.view.html +++ b/modules/torrents/client/views/list-torrents.client.view.html @@ -33,6 +33,7 @@
                +