<?php

namespace ModulesGarden\Servers\ProxmoxCloudVps\App\Helpers;

/*
File:   UrlServiceHelper.php
Date:   15.06.2020
Author: Tomasz Bielecki (tomasz.bi@modulesgarden.com)
Class UrlServiceHelper
*/

use ModulesGarden\ProxmoxAddon\App\Services\UrlService;


/**
 * Class UrlServiceHelper
 * @package ModulesGarden\Servers\ProxmoxCloudVps\App\Helpers
 */
class UrlServiceHelper
{

    /**
     * @var \ModulesGarden\ProxmoxAddon\App\Services\UrlService
     */
    protected $urlService;

    /**
     * UrlServiceHelper constructor.
     */
    public function __construct()
    {
        $this->urlService = new UrlService();
    }

    /**
     * @return string
     */
    public function getXTermConsoleUrl()
    {
        $id = \ModulesGarden\ProxmoxAddon\Core\Helper\sl('Vm')->getVmModel()->id;
        return BuildUrl::isClientArea() ? $this->urlService->getUrl('console', 'xtermjs',['vm'=> $id]) : BuildUrl::getSelfUrl().'&mg-action=xtermjs&vm='.$id;
    }

    /**
     * @return string
     */
    public function getNoVncConsoleUrl()
    {
        $id = \ModulesGarden\ProxmoxAddon\Core\Helper\sl('Vm')->getVmModel()->id;
        return BuildUrl::isClientArea() ? $this->urlService->getUrl('console', 'novnc', ['vm'=> $id]) : BuildUrl::getSelfUrl().'&mg-action=novncs&vm='.$id;
    }

    /**
     * @return mixed
     */
    public function getSpiceConsoleUrl()
    {
        $id = \ModulesGarden\ProxmoxAddon\Core\Helper\sl('Vm')->getVmModel()->id;
        return $this->urlService->getUrl('console', 'spice',['vm'=> $id]);
    }

    public function home()
    {
        return $this->urlService->getUrl();
    }

}