aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-11-24 11:44:21 +0100
committerThomas Citharel <tcit@tcit.fr>2017-06-23 09:33:54 +0200
commit46a54f5debe317ccb3a473ec4b54d3755fe6606c (patch)
tree17876e70811c91d1ab45df7827addd6c6fc3c014 /src/Wallabag/CoreBundle
parent29714661b1df78871ceaf0e079f11041a8641d4b (diff)
downloadwallabag-46a54f5debe317ccb3a473ec4b54d3755fe6606c.tar.gz
wallabag-46a54f5debe317ccb3a473ec4b54d3755fe6606c.tar.zst
wallabag-46a54f5debe317ccb3a473ec4b54d3755fe6606c.zip
WIP
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php48
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php33
2 files changed, 81 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index fafa49f1..ba3db806 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -6,7 +6,9 @@ use Pagerfanta\Adapter\DoctrineORMAdapter;
6use Pagerfanta\Exception\OutOfRangeCurrentPageException; 6use Pagerfanta\Exception\OutOfRangeCurrentPageException;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8use Symfony\Bundle\FrameworkBundle\Controller\Controller; 8use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9use Symfony\Component\HttpFoundation\JsonResponse;
9use Symfony\Component\HttpFoundation\Request; 10use Symfony\Component\HttpFoundation\Request;
11use Symfony\Component\HttpFoundation\Response;
10use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 12use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
11use Wallabag\CoreBundle\Entity\Entry; 13use Wallabag\CoreBundle\Entity\Entry;
12use Wallabag\CoreBundle\Form\Type\EntryFilterType; 14use Wallabag\CoreBundle\Form\Type\EntryFilterType;
@@ -604,4 +606,50 @@ class EntryController extends Controller
604 { 606 {
605 return $this->showEntries('untagged', $request, $page); 607 return $this->showEntries('untagged', $request, $page);
606 } 608 }
609
610 /**
611 * Get the progress of an entry.
612 *
613 * @param Entry $entry
614 *
615 * @Route("/progress/{entry}", name="get_progress")
616 *
617 * @return JsonResponse
618 */
619 public function getEntriesProgressAction(Entry $entry)
620 {
621 $this->checkUserAction($entry);
622
623 $json = $this->get('serializer')->serialize($entry->getProgress(), 'json');
624
625 return (new JsonResponse())->setJson($json);
626 }
627
628 /**
629 * Set the progress of an entry.
630 *
631 * @param Entry $entry
632 * @param int $progress
633 *
634 * @Route("/set-progress/{entry}", name="set_progress")
635 *
636 * @return JsonResponse
637 */
638 public function setEntriesProgressAction(Entry $entry, $progress)
639 {
640 $this->checkUserAction($entry);
641 $response = new JsonResponse();
642
643 if (is_null($progress)) {
644 $response->setStatusCode(Response::HTTP_BAD_REQUEST);
645 } else {
646 $progress = (int) $progress;
647 if ($progress >= 0 && $progress <= 100) {
648 $entry->setProgress($progress);
649 $response->setStatusCode(Response::HTTP_OK);
650 }
651 }
652
653 return $response;
654 }
607} 655}
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index a0503c39..639af6aa 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -211,6 +211,15 @@ class Entry
211 private $headers; 211 private $headers;
212 212
213 /** 213 /**
214 * @var int
215 *
216 * @ORM\Column(name="progress", type="integer", nullable=true)
217 *
218 * @Groups({"entries_for_user", "export_all"})
219 */
220 private $progress = 0;
221
222 /**
214 * @Exclude 223 * @Exclude
215 * 224 *
216 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries") 225 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries")
@@ -760,6 +769,20 @@ class Entry
760 } 769 }
761 770
762 /** 771 /**
772 * Set progress.
773 *
774 * @param int $progress
775 *
776 * @return Entry
777 */
778 public function setProgress($progress)
779 {
780 $this->progress = $progress;
781
782 return $this;
783 }
784
785 /**
763 * @return array 786 * @return array
764 */ 787 */
765 public function getHeaders() 788 public function getHeaders()
@@ -778,4 +801,14 @@ class Entry
778 801
779 return $this; 802 return $this;
780 } 803 }
804
805 /**
806 * Get progress.
807 *
808 * @return int
809 */
810 public function getProgress()
811 {
812 return $this->progress;
813 }
781} 814}