Skip to content

Commit

Permalink
Atualização da lista de pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
gpfernando2024 committed Nov 6, 2024
1 parent a7e197c commit 0084b5f
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 62 deletions.
31 changes: 29 additions & 2 deletions Controllers/PipelinesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.Util;
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
using GestaoDemandas.Models;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using Org.BouncyCastle.Bcpg.OpenPgp;

namespace GestaoDemandas.Controllers
{
Expand All @@ -30,7 +33,7 @@ static PipelinesController()
Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes($":{pat}")));
}

public async Task<ActionResult> Index(int page = 1, int pageSize = 160)
public async Task<ActionResult> Index(string SearchipelineSK, string SearchRunNumber, int page = 1, int pageSize = 160, bool clear = false)
{
var url = "https://analytics.dev.azure.com/devopssee/CFIEE%20-%20Coordenadoria%20de%20Finan%C3%A7as%20e%20Infra%20Estrutura%20Escolar/_odata/v4.0-preview/PipelineRuns?%20&$select=PipelineRunId,StartedDateSK,CompletedDate,RunNumber,RunReason,QueuedDate,SucceededCount,QueueDurationSeconds%20&$expand=Pipeline($select=PipelineSK,PipelineId,PipelineName),Project($select=ProjectId,ProjectName),Branch($select=RepositoryId,BranchName,AnalyticsUpdatedDate)&$orderby=PipelineRunId%20desc";

Expand All @@ -52,13 +55,37 @@ public async Task<ActionResult> Index(int page = 1, int pageSize = 160)
// Deserialize the JSON to a list of PipelineRun objects
var pipelineRuns = responseObj.value;

if (clear)
{
// Clear search parameters and return the initial list of Pipelines
SearchipelineSK = null;
SearchRunNumber = null;
ViewBag.SearchRunNumber = null;
ViewBag.SearchipelineSK = null;

}
// Filtrar workItems com base nos critérios de pesquisa
if (!string.IsNullOrEmpty(SearchipelineSK))
{
pipelineRuns = pipelineRuns.Where(w => w.pipeline.PipelineSK.ToString().Contains(SearchipelineSK)).ToList();
}

if (!string.IsNullOrEmpty(SearchRunNumber))
{
pipelineRuns = pipelineRuns.Where(w => w.RunNumber.ToString().Contains(SearchRunNumber)).ToList();
}

// Pagination logic
var totalItems = pipelineRuns.Count;
var totalPages = (int)Math.Ceiling((double)totalItems / pageSize);
var itemsToDisplay = pipelineRuns.Skip((page - 1) * pageSize).Take(pageSize).ToList();
ViewBag.CurrentPage = page;
ViewBag.TotalPages = totalPages;
return View(itemsToDisplay);

ViewBag.SearchRunNumber = SearchRunNumber;
ViewBag.SearchipelineSK = SearchipelineSK;

return View(pipelineRuns.Take(10));

}
catch (JsonSerializationException ex)
Expand Down
140 changes: 80 additions & 60 deletions Views/Pipelines/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,64 @@

<h3>@ViewBag.Title</h3>

<table class="table table-striped table-bordered table-hover font-size-12">
<thead class="thead-dark">
<form method="get" action="@Url.Action("Index")" class="font-size-12">
<table class="table table-bordered">
<tr>
<th>Ident.Pipeline</th>
<th>Cód.Execução Pipeline</th>
<th>Numero Execução</th>
<th>Projeto</th>
<th>Descrição Pipeline</th>
<th>Nome Branch</th>
<th>Cód. Pipeline</th>
<th>Data Atualização Análise</th>
<td>
<label for="SearchipelineSK">Cód.Pipeline</label>
<input type="text" id="SearchipelineSK" name="SearchipelineSK" class="form-control" value="@ViewBag.SearchipelineSK" placeholder="" />
</td>
<td>
<label for="SearchRunNumber">Cód.Execução Pipeline</label>
<input type="text" id="SearchRunNumber" name="SearchRunNumber" class="form-control" value="@ViewBag.SearchRunNumber" placeholder="" />
</td>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Take(10))
{
<tr>
<td>@item.pipeline.PipelineId</td>
<td>@item.RunNumber</td>
<td>@item.PipelineRunId</td>
<td>@item.project.ProjectName</td>
<td>@item.pipeline.PipelineName</td>
<td>@item.BranchTo.BranchName</td>
<td>@item.pipeline.PipelineSK</td>
<td>
@(item.BranchTo.AnalyticsUpdatedDate.HasValue ?
item.BranchTo.AnalyticsUpdatedDate.Value.ToString("dd/MM/yyyy") : "")
</td>
</tr>
}
</tbody>
</table>
<tr>
<td colspan="3" class="align-bottom">
<button type="submit" class="btn btn-primary mr-2 mt-4">Pesquisar</button>
<a href="@Url.Action("Index", "Pipelines", new { clear = true })" class="btn btn-secondary mr-2 mt-4">Limpar</a>
<a href="@Url.Action("Index", "Home", new { clear = true })" class="btn btn-primary mt-4">Voltar</a>
</td>
</tr>
</table>
</form>
<table class="table table-striped table-bordered table-hover font-size-12">
<thead class="thead-dark">
<tr>
<th>Ident.Pipeline</th>
<th>Cód.Execução Pipeline</th>
<th>Numero Execução</th>
<th>Projeto</th>
<th>Descrição Pipeline</th>
<th>Cód. Pipeline</th>
<th>Data/Hora Deploy</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Take(10))
{
<tr>
<td>@item.pipeline.PipelineId</td>
<td>@item.RunNumber</td>
<td>@item.PipelineRunId</td>
<td>@item.project.ProjectName</td>
<td>@item.pipeline.PipelineName</td>
<td>@item.pipeline.PipelineSK</td>
<td>
@(item.CompletedDate.HasValue == true
? item.CompletedDate.Value.ToString("dd/MM/yyyy HH:mm:ss")
: "")
</td>
</tr>
}
</tbody>
</table>


<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item @(ViewBag.CurrentPage == 1 ? "disabled" : "")">
<a class="page-link" href="@Url.Action("Index", new {
<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item @(ViewBag.CurrentPage == 1 ? "disabled" : "")">
<a class="page-link" href="@Url.Action("Index", new {
page = ViewBag.CurrentPage - 1,
searchId = ViewBag.SearchId,
searchDataAbertura = ViewBag.SearchDataAbertura,
Expand All @@ -63,14 +83,14 @@
searchSistema = ViewBag.SearchSistema,
searchTeam = ViewBag.SearchTeam
})" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
<span class="sr-only">Previous</span>
</a>
</li>
@for (int i = 1; i <= ViewBag.TotalPages; i++)
{
<li class="page-item @(ViewBag.CurrentPage == i ? "active" : "")">
<a class="page-link" href="@Url.Action("Index", new {
<span aria-hidden="true">&laquo;</span>
<span class="sr-only">Previous</span>
</a>
</li>
@for (int i = 1; i <= ViewBag.TotalPages; i++)
{
<li class="page-item @(ViewBag.CurrentPage == i ? "active" : "")">
<a class="page-link" href="@Url.Action("Index", new {
page = i,
searchId = ViewBag.SearchId,
searchDataAbertura = ViewBag.SearchDataAbertura,
Expand All @@ -84,8 +104,8 @@
})">@i</a>
</li>
}
<li class="page-item @(ViewBag.CurrentPage == ViewBag.TotalPages ? "disabled" : "")">
<a class="page-link" href="@Url.Action("Index", new {
<li class="page-item @(ViewBag.CurrentPage == ViewBag.TotalPages ? "disabled" : "")">
<a class="page-link" href="@Url.Action("Index", new {
page = ViewBag.CurrentPage + 1,
searchId = ViewBag.SearchId,
searchDataAbertura = ViewBag.SearchDataAbertura,
Expand All @@ -97,21 +117,21 @@
searchSistema = ViewBag.SearchSistema,
searchTeam = ViewBag.SearchTeam
})" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
<span class="sr-only">Next</span>
</a>
</li>
</ul>
</nav>
<span aria-hidden="true">&raquo;</span>
<span class="sr-only">Next</span>
</a>
</li>
</ul>
</nav>


<script>
$(function () {
$(".datepicker").datepicker({
dateFormat: "dd/mm/yy",
showOn: "focus",
showOtherMonths: true,
selectOtherMonths: true
}).mask("99/99/9999", { placeholder: "__/__/____" });
});
</script>
<script>
$(function () {
$(".datepicker").datepicker({
dateFormat: "dd/mm/yy HH:mm:ss",
showOn: "focus",
showOtherMonths: true,
selectOtherMonths: true
}).mask("99/99/9999 99:99:99", { placeholder: "__/__/____ __:__:__" });
});
</script>

0 comments on commit 0084b5f

Please sign in to comment.