<?php


namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\AccountSummary\Providers;


use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\di;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ResourceManager;

class AccountSummaryProvider
{
    public function read()
    {
        $resourceManager = new ResourceManager();

        $this->data['bars']    = [
            [
                'name'  => di('lang')->abtr('memory'),
                'value' => $resourceManager->memory()->getPercent(),
                'used'  => $resourceManager->memory()->getUsed(),
                'max'   => $resourceManager->memory()->getTotal(),
                'unit'  => di('lang')->abtr('MB'),
            ],
            [
                'name'  => di('lang')->abtr('vcpu'),
                'value' => $resourceManager->vcpus()->getPercent(),
                'used'  => $resourceManager->vcpus()->getUsed(),
                'max'   => $resourceManager->vcpus()->getTotal(),
                'unit'  => di('lang')->abtr('cores'),
            ],
            [
                'name'  => di('lang')->abtr('disk'),
                'value' => $resourceManager->disk()->getPercent(),
                'used'  => $resourceManager->disk()->getUsed(),
                'max'   => $resourceManager->disk()->getTotal(),
                'unit'  => di('lang')->abtr('GB'),
            ],
            [
                'name'  => di('lang')->abtr('networks'),
                'value' => $resourceManager->virtualNetworks()->getPercent(),
                'used'  => $resourceManager->virtualNetworks()->getUsed(),
                'max'   => $resourceManager->virtualNetworks()->getTotal(),
                'unit'  => ''
            ]
        ];

        return $this->data['bars'];
    }
}
