diff --git a/src/Cacic/CommonBundle/Controller/AgenteController.php b/src/Cacic/CommonBundle/Controller/AgenteController.php index fa843d6..882a5a9 100644 --- a/src/Cacic/CommonBundle/Controller/AgenteController.php +++ b/src/Cacic/CommonBundle/Controller/AgenteController.php @@ -22,6 +22,7 @@ use ZipArchive; class AgenteController extends Controller { public function indexAction(Request $request) { + $em = $this->getDoctrine()->getManager(); $logger = $this->get('logger'); // Cria diretório dos agentes se não existir $rootDir = $this->container->get('kernel')->getRootDir(); @@ -36,132 +37,62 @@ class AgenteController extends Controller { mkdir($cacicDir); } - $linuxDir = $cacicDir . "linux/"; - if (!is_dir($linuxDir)) { - mkdir($linuxDir); - } - - $windowsDir = $cacicDir . "windows/"; - if (!is_dir($windowsDir)) { - mkdir($windowsDir); - } + #$linuxDir = $cacicDir . "linux/"; + #if (!is_dir($linuxDir)) { + # mkdir($linuxDir); + #} + # + #$windowsDir = $cacicDir . "windows/"; + #if (!is_dir($windowsDir)) { + # mkdir($windowsDir); + #} $outrosDir = $downloadsDir . "outros/"; if (!is_dir($outrosDir)) { mkdir($outrosDir); } + // Carrega a lista de Agentes por plataforma + $tipo_so = $em->getRepository('CacicCommonBundle:TipoSo')->findAll(); - $form = $this->createForm( new AgenteType() ); + $form = $this->createForm( new AgenteType(), null, array( + 'tipo_so' => $tipo_so + )); $locale = $request->getLocale(); - // Constrói array de arquivos e hashes - $finder = new Finder(); - $saida = array(); - $base_url = $request->getBaseUrl(); - $base_url = preg_replace('/\/app.*.php/', "/", $base_url); - - // Primeiro tratamos agentes Linux - // A regra é que o agente mais atual estará na pasta current - $finder->directories()->in($linuxDir); - $saida['linux']['versions'] = array(); - foreach($finder as $version) { - $agentes = new Finder(); - if ($version->getFileName() == 'current') { - continue; - } - $saida['linux']['versions'][$version->getFileName()] = array(); - $agentes->files()->in($version->getRealPath()); - foreach ($agentes as $file) { - array_push($saida['linux']['versions'][$version->getFileName()], array( - 'name' => $file->getFileName(), - 'download_url' => $base_url . 'downloads/cacic/linux/' . $version->getFileName() . '/' . $file->getFileName(), - 'hash' => md5_file($file->getRealPath()), - 'size' => $file->getSize(), - 'filename' => 'cacic/linux/' . $version->getFileName() . '/' . $file->getFileName() - )); - - } - } - // Get latest version - $current = @basename(@readlink($linuxDir."current")); - $saida['linux']['live_version'] = $current; - - // Aí tratamos Windows - $finder->directories()->in($windowsDir); - $saida['windows']['versions'] = array(); - foreach($finder as $version) { - $agentes = new Finder(); - if ($version->getFileName() == 'current') { - continue; - } - $saida['windows']['versions'][$version->getFileName()] = array(); - $agentes->files()->in($version->getRealPath()); - //$logger->debug("1111111111111111111111111111111111111111111 ".$version->getRealPath()); - foreach ($agentes as $file) { - //$logger->debug("77777777777777777777777777777777777777777 $file"); - array_push($saida['windows']['versions'][$version->getFileName()], array( - 'name' => $file->getFileName(), - 'download_url' => $base_url . 'downloads/cacic/windows/' . $version->getFileName() . '/' . $file->getFileName(), - 'hash' => md5_file($file->getRealPath()), - 'size' => $file->getSize(), - 'filename' => 'cacic/windows/' . $version->getFileName() . '/' . $file->getFileName() - )); - - } - } - // Get latest version - $current = @basename(@readlink($windowsDir."current")); - $saida['windows']['live_version'] = $current; - //$logger->debug("4444444444444444444444444444444444 ".print_r($saida, true)); if ( $request->isMethod('POST') ) { // Aqui vamos fazer o tratamento dos agentes $data = $form->getData(); - $data['windows_version'] = $request->get('agentes')['windows_version']; - $data['linux_version'] = $request->get('agentes')['linux_version']; + $data['version'] = $request->get('agentes')['version']; $files = $request->files->get('agentes'); //$logger->debug("99999999999999999999999999999999999 ".print_r($data, true)); - if (!empty($files['windows'])) { + if (!empty($files)) { //$logger->debug("88888888888888888888888888888888888888 ".print_r($files['windows'], true)); - if (empty($data['windows_version'])) { + if (empty($data['version'])) { $logger->error("O parâmetro versão é obrigatório"); $this->get('session')->getFlashBag()->add('error', 'O parâmetro versão é obrigatório'); } else { - $versionDir = $windowsDir . $data['windows_version']; - $result = $this->uploadPackage($files['windows'], $versionDir); - if (!$result) { - $logger->error("Erro na atualização dos Agentes Windows"); - $this->get('session')->getFlashBag()->add('error', 'Erro na atualização dos agentes Windows'); - } else { - // Make this version current - $logger->debug("Agentes atualizados com sucesso. Ajustando para versão $versionDir"); - @unlink("$windowsDir"."current"); - symlink($versionDir, "$windowsDir"."current"); - $this->get('session')->getFlashBag()->add('success', 'Agentes atualizados com sucesso!'); + // Carrega as versões dos sistemas operacionais + $versionDir = $cacicDir . $data['version']; + $result = false; + foreach($tipo_so as $so) { + $tipoDir = $versionDir . "/" . $so->getTipo(); + $result = $this->uploadPackage($files[$so->getTipo()], $tipoDir); } - } - } - if (!empty($files['linux'])) { - if (empty($data['linux_version'])) { - $logger->error("O parâmetro versão é obrigatório"); - $this->get('session')->getFlashBag()->add('error', 'O parâmetro versão é obrigatório'); - } else { - $versionDir = $linuxDir . $data['linux_version']; - $result = $this->uploadPackage($files['linux'], $versionDir); if (!$result) { - $logger->error("Erro na atualização dos Agentes Linux"); - $this->get('session')->getFlashBag()->add('error', 'Erro na atualização dos agentes Linux'); + $logger->error("Erro na atualização dos Agentes"); + $this->get('session')->getFlashBag()->add('error', 'Erro na atualização dos agentes'); } else { // Make this version current $logger->debug("Agentes atualizados com sucesso. Ajustando para versão $versionDir"); - @unlink("$linuxDir"."current"); - symlink($versionDir, $linuxDir."current"); + @unlink("$cacicDir"."current"); + symlink($versionDir, "$cacicDir"."current"); $this->get('session')->getFlashBag()->add('success', 'Agentes atualizados com sucesso!'); } } @@ -169,6 +100,52 @@ class AgenteController extends Controller { } + // Constrói array de arquivos e hashes + $finder = new Finder(); + $saida = array(); + $base_url = $request->getBaseUrl(); + $base_url = preg_replace('/\/app.*.php/', "", $base_url); + + // Varre diretório do Cacic + $finder->depth('== 0'); + $finder->directories()->in($cacicDir); + + // Agora busca diretórios de versão + $saida['tipo_so'] = array(); + foreach($finder as $version) { + //$logger->debug("1111111111111111111111111111111 ".$version->getFileName()); + if ($version->getFileName() == 'current') { + continue; + } + + // Agora busca um diretório pra cada tipo de SO + foreach($tipo_so as $so) { + $saida['tipo_so'][$so->getTipo()][$version->getFileName()] = array(); + $agentes_path = $version->getRealPath() . "/" . $so->getTipo(); + + // Cria diretório se não existir + if (!is_dir($agentes_path)) { + mkdir($agentes_path); + } + $agentes = new Finder(); + $agentes->files()->in($agentes_path); + foreach($agentes as $file) { + array_push($saida['tipo_so'][$so->getTipo()][$version->getFileName()], array( + 'name' => $file->getFileName(), + 'download_url' => $base_url . '/downloads/cacic/' . $version->getFileName() . '/' . $so->getTipo() . "/" . $file->getFileName(), + 'hash' => md5_file($file->getRealPath()), + 'size' => $file->getSize(), + 'filename' => 'cacic/' . $version->getFileName() . '/' . $so->getTipo() . "/" . $file->getFileName() + )); + } + } + } + + + // Get latest version + $current = @basename(@readlink($cacicDir."current")); + $saida['live_version'] = $current; + return $this->render( 'CacicCommonBundle:Agente:index.html.twig', array( 'local'=>$locale, @@ -322,7 +299,7 @@ class AgenteController extends Controller { } - $logger->debug("3333333333333333333333333333333333333333 ".print_r($saida, true)); + //$logger->debug("3333333333333333333333333333333333333333 ".print_r($saida, true)); return $this->render( 'CacicCommonBundle:Agente:deploy.html.twig', array( diff --git a/src/Cacic/CommonBundle/Controller/RedeController.php b/src/Cacic/CommonBundle/Controller/RedeController.php index 6901146..89bdfb7 100644 --- a/src/Cacic/CommonBundle/Controller/RedeController.php +++ b/src/Cacic/CommonBundle/Controller/RedeController.php @@ -734,40 +734,39 @@ class RedeController extends Controller // Varro todas as subredes para cada módulo $subredes = array(); - $windows = array(); - $linux = array(); + $saida = array(); foreach ($subredesOrig as $redeItem) { - // Busca o módulo em cada uma das redes + // Busca o tipo de SO $codigos = array(); - foreach ($modulos as $key => $value) { - $idRede = $redeItem['idRede']; - // Verifico se o módulo existe na subrede - $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:RedeVersaoModulo')->subrede($idRede, $key); - - if (empty($rede)) { - // O módulo não foi encontrado. Adiciona o código 1 - array_push($codigos, 0); - //$rede = $redeItem[0]; - } else { - if ($value['hash'] == $rede[0]['teHash']) { - // Se o hash for igual, adiciona o código 2 - array_push($codigos, 2); - + foreach($modulos as $tipo_so => $file) { + // Busca o módulo em cada uma das redes + foreach ($file as $key => $value) { + $idRede = $redeItem['idRede']; + // Verifico se o módulo existe na subrede + $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:RedeVersaoModulo')->subredeFilePath($idRede, $value['filename']); + + if (empty($rede)) { + // O módulo não foi encontrado. Adiciona o código 1 + array_push($codigos, 0); + //$rede = $redeItem[0]; } else { - // Se o hash for diferente, adiciona o código 1 - array_push($codigos, 1); + if ($value['hash'] == $rede[0]['teHash']) { + // Se o hash for igual, adiciona o código 2 + array_push($codigos, 2); + + } else { + // Se o hash for diferente, adiciona o código 1 + array_push($codigos, 1); + } } - } - // Cria um array para Windows e outro para Linux - if ($value['tipoSo'] == 'windows') { - $windows[$key] = $value; - } else { - $linux[$key] = $value; - } + // Array de saída + $saida[$tipo_so][$value['name']] = $value; + } } + // Define o elemento HTML para os módulos if (in_array(0, $codigos)) { // Se o código 0 for encontrato, marcamos o módulo como inexistente @@ -799,10 +798,11 @@ class RedeController extends Controller } } + //$logger->debug("111111111111111111111111111111111111111 \n".print_r($saida, true)); + return $this->render( 'CacicCommonBundle:Rede:manutencaoNeo.html.twig', array( - 'windows'=> $windows, - 'linux' => $linux, + 'saida'=> $saida, 'subredes' => $subredes ) ); @@ -839,78 +839,50 @@ class RedeController extends Controller // Constrói array de arquivos e hashes $saida = array(); $base_url = $request->getBaseUrl(); - $base_url = preg_replace('/\/app.*.php/', "/", $base_url); + $base_url = preg_replace('/\/app.*.php/', "", $base_url); // Primeiro tratamos agentes Linux // A regra é que o agente mais atual estará na pasta current - $current = basename(readlink($linuxDir."current")); + $current = basename(readlink($cacicDir."current")); $finder = new Finder(); - $finder->directories()->in($linuxDir); + $finder->depth('== 0'); + $finder->directories()->in($cacicDir); foreach($finder as $version) { - $agentes = new Finder(); if ($version->getFileName() == 'current') { - // Aqui considera somente a última versão - $agentes->files()->in($version->getRealPath()); - foreach ($agentes as $file) { - if (!empty($nmModulos)) { - // Filtra por nome de módulo - if (!in_array($file->getFileName(), $nmModulos)) { - continue; + $tipos = new Finder(); + $tipos->depth('== 0'); + $tipos->directories()->in($version->getRealPath()); + foreach($tipos as $tipo_so) { + // Aqui considera somente a última versão + $agentes = new Finder(); + $agentes->depth('== 0'); + $agentes->files()->in($tipo_so->getRealPath()); + foreach ($agentes as $file) { + $filename = 'cacic/' . $version->getFileName() . '/' . $tipo_so->getFileName() . "/" . $file->getFileName(); + if (!empty($nmModulos)) { + // Filtra por nome de módulo + if (!in_array($filename, $nmModulos)) { + continue; + } } + $saida[$tipo_so->getFileName()][$file->getFileName()] = array( + 'name' => $file->getFileName(), + 'download_url' => $base_url . '/downloads/cacic/' . $version->getFileName() . '/' . $tipo_so->getFileName() . "/" . $file->getFileName(), + 'hash' => md5_file($file->getRealPath()), + 'size' => $file->getSize(), + 'filename' => $filename, + 'versao' => $current, + 'tipoSo' => $tipo_so->getFileName() + ); } - $saida[$file->getFileName()] = array( - 'name' => $file->getFileName(), - 'versao' => $current, - 'download_url' => $base_url . 'downloads/cacic/linux/' . $version->getFileName() . '/' . $file->getFileName(), - 'hash' => md5_file($file->getRealPath()), - 'size' => $file->getSize(), - 'filename' => 'cacic/linux/' . $version->getFileName() . '/' . $file->getFileName(), - 'tipoSo' => 'linux' - ); } - } else { - continue; - } - - } - // Get latest version - //$current = basename(readlink($cacicDir."current")); - //$saida['linux']['live_version'] = $current; - // Aí tratamos Windows - $finder = new Finder(); - $finder->directories()->in($windowsDir); - $current = basename(readlink($windowsDir."current")); - foreach($finder as $version) { - $agentes = new Finder(); - if ($version->getFileName() == 'current') { - // Aqui considera somente a última versão - $agentes->files()->in($version->getRealPath()); - foreach ($agentes as $file) { - if (!empty($nmModulos)) { - // Filtra por nome de módulo - if (!in_array($file->getFileName(), $nmModulos)) { - continue; - } - } - $saida[$file->getFileName()] = array( - 'name' => $file->getFileName(), - 'versao' => $current, - 'download_url' => $base_url . 'downloads/cacic/windows/' . $version->getFileName() . '/' . $file->getFileName(), - 'hash' => md5_file($file->getRealPath()), - 'size' => $file->getSize(), - 'filename' => 'cacic/windows/' . $version->getFileName() . '/' . $file->getFileName(), - 'tipoSo' => 'windows' - ); - } } else { continue; } } - // Get latest version - //$current = basename(readlink($windowsDir."current")); - //$saida['windows']['live_version'] = $current; + // Retorna o array com todos os resultados return $saida; @@ -934,66 +906,84 @@ class RedeController extends Controller $modulos = $this->modulosNeoArray($request, $modulos); //$logger->debug("6666666666666666666666666666666666666 ".print_r($modulos, true)); - foreach ($modulos as $key => $value) - { - $logger->debug("Nome do módulo: $key"); + foreach($modulos as $tipo => $modulo) { - // Carrega dados da rede - $em = $this->getDoctrine()->getManager(); - //$arrDadosRede = array( 'rede' => $em->getRepository( 'CacicCommonBundle:Rede' )->listar() ); - //Debug::dump($arrDadosRede['rede'][0][0]); - //$arrDadosRede = $arrDadosRede['rede'][0]; - $arrDadosRede = array( - 'teServUpdates' => $rede->getTeServUpdates(), - 'tePathServUpdates' => $rede->getTePathServUpdates(), - 'nmUsuarioLoginServUpdatesGerente' => $rede->getNmUsuarioLoginServUpdatesGerente(), - 'teSenhaLoginServUpdatesGerente' => $rede->getTeSenhaLoginServUpdatesGerente(), - 'nuPortaServUpdates' => $rede->getNuPortaServUpdates(), - ); - - $strResult = $this->checkAndSend( - $value['name'], - $downloadsDir . $value['filename'], - $arrDadosRede['teServUpdates'], - $arrDadosRede['tePathServUpdates'], - $arrDadosRede['nmUsuarioLoginServUpdatesGerente'], - $arrDadosRede['teSenhaLoginServUpdatesGerente'], - $arrDadosRede['nuPortaServUpdates'] - ); - - $arrResult = explode('_=_',$strResult); - - if ($arrResult[1] == 'Ok!') + foreach ($modulo as $key => $value) { - // Consertar CRUD no Symfony - $redeVersaoModulo = $em->getRepository('CacicCommonBundle:RedeVersaoModulo')->findOneBy( - array( - 'idRede' => $pIntIdRede, - 'nmModulo' => $value['name'] - ) + $logger->debug("Nome do módulo: ".$value['filename']); + + // Carrega dados da rede + $em = $this->getDoctrine()->getManager(); + //$arrDadosRede = array( 'rede' => $em->getRepository( 'CacicCommonBundle:Rede' )->listar() ); + //Debug::dump($arrDadosRede['rede'][0][0]); + //$arrDadosRede = $arrDadosRede['rede'][0]; + $arrDadosRede = array( + 'teServUpdates' => $rede->getTeServUpdates(), + 'tePathServUpdates' => $rede->getTePathServUpdates(), + 'nmUsuarioLoginServUpdatesGerente' => $rede->getNmUsuarioLoginServUpdatesGerente(), + 'teSenhaLoginServUpdatesGerente' => $rede->getTeSenhaLoginServUpdatesGerente(), + 'nuPortaServUpdates' => $rede->getNuPortaServUpdates(), ); - // Se não existir, instancia o objeto - if (empty($redeVersaoModulo)) { - $redeVersaoModulo = new RedeVersaoModulo(null, null, null, null, null, $rede); + if ($rede->getDownloadMethod() == 'ftp') { + $strResult = $this->checkAndSend( + $value['name'], + $downloadsDir . $value['filename'], + $arrDadosRede['teServUpdates'], + $arrDadosRede['tePathServUpdates'], + $arrDadosRede['nmUsuarioLoginServUpdatesGerente'], + $arrDadosRede['teSenhaLoginServUpdatesGerente'], + $arrDadosRede['nuPortaServUpdates'] + ); + + $arrResult = explode('_=_',$strResult); + } else { + $arrResult[1] = 'Ok!'; } - // Adicione o restante dos atributos - $redeVersaoModulo->setNmModulo($value['name']); - $redeVersaoModulo->setTeVersaoModulo($value['versao']); - $redeVersaoModulo->setDtAtualizacao(new \DateTime('NOW')); - $redeVersaoModulo->setCsTipoSo( $value['tipoSo'] ); - $redeVersaoModulo->setTeHash($value['hash']); - $redeVersaoModulo->setTipo('cacic'); - $em->persist($redeVersaoModulo); - $em->flush(); - } else { - $logger->error("Erro no envio dos módulos via FTP!\n".$arrResult[1]); - return false; + + if ($arrResult[1] == 'Ok!') + { + // Consertar CRUD no Symfony + $redeVersaoModulo = $em->getRepository('CacicCommonBundle:RedeVersaoModulo')->findOneBy( + array( + 'idRede' => $pIntIdRede, + 'nmModulo' => $value['name'], + 'filepath' => $value['filename'] + ) + ); + + // Se não existir, instancia o objeto + if (empty($redeVersaoModulo)) { + $redeVersaoModulo = new RedeVersaoModulo(null, null, null, null, null, $rede); + } + + $tipo_so = $em->getRepository('CacicCommonBundle:TipoSo')->findOneBy(array( + 'tipo' => $tipo + )); + + // Adicione o restante dos atributos + $redeVersaoModulo->setNmModulo($value['name']); + $redeVersaoModulo->setTeVersaoModulo($value['versao']); + $redeVersaoModulo->setDtAtualizacao(new \DateTime('NOW')); + $redeVersaoModulo->setCsTipoSo( $value['tipoSo'] ); + $redeVersaoModulo->setTeHash($value['hash']); + $redeVersaoModulo->setTipoSo($tipo_so); + $redeVersaoModulo->setFilepath($value['filename']); + $redeVersaoModulo->setTipo('cacic'); + + $em->persist($redeVersaoModulo); + $em->flush(); + } else { + $logger->error("Erro no envio dos módulos via FTP!\n".$arrResult[1]); + return false; + } } } + + return true; } diff --git a/src/Cacic/CommonBundle/Entity/RedeVersaoModulo.php b/src/Cacic/CommonBundle/Entity/RedeVersaoModulo.php index 314ec19..d2aa99c 100644 --- a/src/Cacic/CommonBundle/Entity/RedeVersaoModulo.php +++ b/src/Cacic/CommonBundle/Entity/RedeVersaoModulo.php @@ -239,4 +239,60 @@ class RedeVersaoModulo { return $this->tipo; } + /** + * @var \Cacic\CommonBundle\Entity\TipoSo + */ + private $tipoSo; + + + /** + * Set tipoSo + * + * @param \Cacic\CommonBundle\Entity\TipoSo $tipoSo + * @return RedeVersaoModulo + */ + public function setTipoSo(\Cacic\CommonBundle\Entity\TipoSo $tipoSo = null) + { + $this->tipoSo = $tipoSo; + + return $this; + } + + /** + * Get tipoSo + * + * @return \Cacic\CommonBundle\Entity\TipoSo + */ + public function getTipoSo() + { + return $this->tipoSo; + } + /** + * @var string + */ + private $filepath; + + + /** + * Set filepath + * + * @param string $filepath + * @return RedeVersaoModulo + */ + public function setFilepath($filepath) + { + $this->filepath = $filepath; + + return $this; + } + + /** + * Get filepath + * + * @return string + */ + public function getFilepath() + { + return $this->filepath; + } } diff --git a/src/Cacic/CommonBundle/Entity/RedeVersaoModuloRepository.php b/src/Cacic/CommonBundle/Entity/RedeVersaoModuloRepository.php index 0b08412..7a16e87 100644 --- a/src/Cacic/CommonBundle/Entity/RedeVersaoModuloRepository.php +++ b/src/Cacic/CommonBundle/Entity/RedeVersaoModuloRepository.php @@ -70,4 +70,39 @@ class RedeVersaoModuloRepository extends EntityRepository return $qb->getQuery()->getArrayResult(); } + /* + * Traz a lista de módulos para a subrede fornecida + */ + public function subredeFilePath($id = null, $modulo = null) + { + $qb = $this->createQueryBuilder('r') + ->select('red.idRede', + 'r.nmModulo', + 'r.teVersaoModulo', + 'r.teHash', + 'red.teIpRede', + 'red.nmRede', + 'red.teServUpdates', + 'red.tePathServUpdates', + 'l.nmLocal') + ->innerJoin('CacicCommonBundle:Rede', 'red', 'WITH', 'red.idRede = r.idRede') + ->innerJoin('CacicCommonBundle:Local', 'l', 'WITH', 'red.idLocal = l.idLocal') + ->groupBy('r', 'l', 'red') + ->orderBy('red.nmRede'); + + // Adiciona filtro por módulo se fornecido + if ($modulo != null) { + // Aqui trago somente a lista de todos os módulos naquela subrede + $qb->andWhere('r.filepath = :modulo')->setParameter('modulo', $modulo); + } + + // Adiciona filtro por subrede se fornecido + if ($id != null) { + // Somente os módulos desa subrede + $qb->andWhere('r.idRede = :id')->setParameter('id', $id); + } + + return $qb->getQuery()->getArrayResult(); + } + } \ No newline at end of file diff --git a/src/Cacic/CommonBundle/Entity/TipoSo.php b/src/Cacic/CommonBundle/Entity/TipoSo.php index ebf1e7e..206c2f8 100644 --- a/src/Cacic/CommonBundle/Entity/TipoSo.php +++ b/src/Cacic/CommonBundle/Entity/TipoSo.php @@ -97,4 +97,42 @@ class TipoSo { return $this->so; } + /** + * @var \Doctrine\Common\Collections\Collection + */ + private $redeVersaoModulo; + + + /** + * Add redeVersaoModulo + * + * @param \Cacic\CommonBundle\Entity\RedeVersaoModulo $redeVersaoModulo + * @return TipoSo + */ + public function addRedeVersaoModulo(\Cacic\CommonBundle\Entity\RedeVersaoModulo $redeVersaoModulo) + { + $this->redeVersaoModulo[] = $redeVersaoModulo; + + return $this; + } + + /** + * Remove redeVersaoModulo + * + * @param \Cacic\CommonBundle\Entity\RedeVersaoModulo $redeVersaoModulo + */ + public function removeRedeVersaoModulo(\Cacic\CommonBundle\Entity\RedeVersaoModulo $redeVersaoModulo) + { + $this->redeVersaoModulo->removeElement($redeVersaoModulo); + } + + /** + * Get redeVersaoModulo + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getRedeVersaoModulo() + { + return $this->redeVersaoModulo; + } } diff --git a/src/Cacic/CommonBundle/Form/Type/AgenteType.php b/src/Cacic/CommonBundle/Form/Type/AgenteType.php index be7efd9..a2bfc2d 100644 --- a/src/Cacic/CommonBundle/Form/Type/AgenteType.php +++ b/src/Cacic/CommonBundle/Form/Type/AgenteType.php @@ -10,6 +10,7 @@ namespace Cacic\CommonBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * Formulário para upload dos agentes @@ -30,33 +31,39 @@ class AgenteType extends AbstractType { public function buildForm( FormBuilderInterface $builder, array $options ) { - $builder->add('windows_version', 'text', - array( - 'label' => 'Versão dos Agentes Windows', - 'required' => false - ) - ); + $tipo_so = $options['tipo_so']; - $builder->add('windows', 'file', + $builder->add('version', 'text', array( - 'label' => 'Agentes Windows', + 'label' => 'Versão dos Agentes', 'required' => false ) ); - $builder->add('linux_version', 'text', - array( - 'label' => 'Versão dos Agentes Linux', - 'required' => false - ) - ); + foreach($tipo_so as $so) { + $builder->add($so->getTipo(), 'file', + array( + 'label' => 'Agentes para SO Tipo '.$so->getTipo(), + 'required' => false + ) + ); + } - $builder->add('linux', 'file', - array( - 'label' => 'Agentes Linux', - 'required' => false - ) - ); } + /** + * Add TipoSo as required option + * + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver + ->setRequired(array( + 'tipo_so', + )); + + } + + } \ No newline at end of file diff --git a/src/Cacic/CommonBundle/Resources/config/doctrine/RedeVersaoModulo.orm.yml b/src/Cacic/CommonBundle/Resources/config/doctrine/RedeVersaoModulo.orm.yml index ac7cc26..c692a79 100644 --- a/src/Cacic/CommonBundle/Resources/config/doctrine/RedeVersaoModulo.orm.yml +++ b/src/Cacic/CommonBundle/Resources/config/doctrine/RedeVersaoModulo.orm.yml @@ -40,6 +40,10 @@ Cacic\CommonBundle\Entity\RedeVersaoModulo: fixed: false nullable: true column: tipo + filepath: + type: text + nullable: true + column: filepath manyToOne: idRede: targetEntity: Rede @@ -50,4 +54,13 @@ Cacic\CommonBundle\Entity\RedeVersaoModulo: id_rede: referencedColumnName: id_rede orphanRemoval: false + tipoSo: + targetEntity: TipoSo + cascade: { } + mappedBy: null + inversedBy: null + joinColumns: + id_tipo_so: + referencedColumnName: id_tipo_so + orphanRemoval: false lifecycleCallbacks: { } diff --git a/src/Cacic/CommonBundle/Resources/config/doctrine/TipoSo.orm.yml b/src/Cacic/CommonBundle/Resources/config/doctrine/TipoSo.orm.yml index 6b07905..b7c44a4 100644 --- a/src/Cacic/CommonBundle/Resources/config/doctrine/TipoSo.orm.yml +++ b/src/Cacic/CommonBundle/Resources/config/doctrine/TipoSo.orm.yml @@ -20,4 +20,7 @@ Cacic\CommonBundle\Entity\TipoSo: so: targetEntity: So mappedBy: tipo + redeVersaoModulo: + targetEntity: RedeVersaoModulo + mappedBy: tipoSo lifecycleCallbacks: { } diff --git a/src/Cacic/CommonBundle/Resources/views/Agente/index.html.twig b/src/Cacic/CommonBundle/Resources/views/Agente/index.html.twig index 8ba5116..b5cc72b 100644 --- a/src/Cacic/CommonBundle/Resources/views/Agente/index.html.twig +++ b/src/Cacic/CommonBundle/Resources/views/Agente/index.html.twig @@ -40,13 +40,9 @@ {{ form_errors(form) }} - {{ form_row(form.windows_version) }} + {{ form_row(form.version) }} - {{ form_row(form.windows) }} - - {{ form_row(form.linux_version) }} - - {{ form_row(form.linux) }} + {{ form_rest(form) }} @@ -82,65 +78,12 @@
{{ 'Versão'|trans }} | -{{ 'Arquivo'|trans }} | -{{ 'Hash'|trans }} | -{{ 'Tamanho'|trans }} | -{{ "Ações"|trans }} | -
---|---|---|---|---|
- {{ "Versão"|trans }} {{ version }} {{ "(Em Produção)"|trans }} - |
- ||||
- {{ "Versão"|trans }} {{ version }} - | -
{{ "Versão"|trans }} {{ version }} {{ "(Em Produção)"|trans }} @@ -169,7 +112,6 @@ |
---|