StatusLabel.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /* * ********************************************************************
  3. * Proxmox Addon product developed. (Jan 9, 2019)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. * ******************************************************************** */
  19. namespace ModulesGarden\ProxmoxAddon\App\UI\Jobs\Others;
  20. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Others\Label;
  21. use function ModulesGarden\ProxmoxAddon\Core\Helper\sl;
  22. /**
  23. * Description of JobLabel
  24. *
  25. * @author Pawel Kopec <pawelk@modulesgardne.com>
  26. */
  27. class StatusLabel extends Label
  28. {
  29. protected $name = 'labelStatus';
  30. protected $id = 'labelStatus';
  31. protected $title = 'labelStatus';
  32. private $status;
  33. public function getStatus()
  34. {
  35. return $this->status;
  36. }
  37. public function setStatus($status)
  38. {
  39. $this->status = $status;
  40. $this->setMessage(sl('lang')->tr($this->status))
  41. ->setTitle(sl('lang')->tr($this->status));
  42. switch ($this->status)
  43. {
  44. case "pending":
  45. $this->setColor('e9fff7')->setBackgroundColor('737980');
  46. break;
  47. case "in_progress":
  48. case "running":
  49. $this->setColor('7b007b')->setBackgroundColor('e9ebf0');
  50. break;
  51. case "completed":
  52. case "finished":
  53. $this->setColor('e5fff4')->setBackgroundColor('5bc758');
  54. break;
  55. case "error":
  56. case "critical":
  57. $this->setColor('fcffff')->setBackgroundColor('ed4040');
  58. break;
  59. default:
  60. //pending
  61. $this->setColor('e9fff7')->setBackgroundColor('737980');
  62. break;
  63. }
  64. return $this;
  65. }
  66. }