Skip to content

Commit

Permalink
Show project version overview on the Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
anilmujagic committed Apr 14, 2015
1 parent 44bad52 commit 77037c3
Show file tree
Hide file tree
Showing 18 changed files with 251 additions and 1 deletion.
Expand Up @@ -58,6 +58,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\CredentialService.cs" />
<Compile Include="Services\CrudService.cs" />
<Compile Include="Services\DashboardService.cs" />
<Compile Include="Services\DataService.cs" />
<Compile Include="Services\DeploymentJobExecutionService.cs" />
<Compile Include="Services\DeploymentPlanParameterService.cs" />
Expand Down
27 changes: 27 additions & 0 deletions src/DeploymentCockpit.BusinessLogic/Services/DashboardService.cs
@@ -0,0 +1,27 @@
using DeploymentCockpit.ApiDtos;
using DeploymentCockpit.Interfaces;
using DeploymentCockpit.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeploymentCockpit.Services
{
public class DashboardService : DataService, IDashboardService
{
public DashboardService(IUnitOfWorkFactory unitOfWorkFactory)
: base(unitOfWorkFactory)
{
}

public IEnumerable<ProjectVersionInfo> GetProjectVersionInfo()
{
using (var uow = _unitOfWorkFactory.Create())
{
return uow.DashboardRepository.GetProjectVersionInfo();
}
}
}
}
17 changes: 17 additions & 0 deletions src/DeploymentCockpit.Core/ApiDtos/ProjectVersionInfo.cs
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeploymentCockpit.ApiDtos
{
public class ProjectVersionInfo
{
public string ProjectName { get; set; }
public string EnvironmentName { get; set; }
public int? DeploymentJobID { get; set; }
public string ProductVersion { get; set; }
public string DeploymentJobTime { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/DeploymentCockpit.Core/DeploymentCockpit.Core.csproj
Expand Up @@ -68,6 +68,7 @@
<Compile Include="ApiDtos\DeploymentJobDto.cs" />
<Compile Include="ApiDtos\DeploymentPlanDto.cs" />
<Compile Include="ApiDtos\DeploymentPlanStepDto.cs" />
<Compile Include="ApiDtos\ProjectVersionInfo.cs" />
<Compile Include="Common\NameValuePair.cs" />
<Compile Include="ApiDtos\ProjectDto.cs" />
<Compile Include="ApiDtos\ProjectEnvironmentDto.cs" />
Expand All @@ -92,6 +93,8 @@
<Compile Include="Interfaces\IConfigurationProvider.cs" />
<Compile Include="Interfaces\ICredentialService.cs" />
<Compile Include="Interfaces\ICrudService.cs" />
<Compile Include="Interfaces\IDashboardRepository.cs" />
<Compile Include="Interfaces\IDashboardService.cs" />
<Compile Include="Interfaces\IDeploymentJobExecutionService.cs" />
<Compile Include="Interfaces\IDeploymentPlanParameterService.cs" />
<Compile Include="Interfaces\IDeploymentJobStepTargetService.cs" />
Expand Down
14 changes: 14 additions & 0 deletions src/DeploymentCockpit.Core/Interfaces/IDashboardRepository.cs
@@ -0,0 +1,14 @@
using DeploymentCockpit.ApiDtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeploymentCockpit.Interfaces
{
public interface IDashboardRepository
{
IEnumerable<ProjectVersionInfo> GetProjectVersionInfo();
}
}
14 changes: 14 additions & 0 deletions src/DeploymentCockpit.Core/Interfaces/IDashboardService.cs
@@ -0,0 +1,14 @@
using DeploymentCockpit.ApiDtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeploymentCockpit.Interfaces
{
public interface IDashboardService
{
IEnumerable<ProjectVersionInfo> GetProjectVersionInfo();
}
}
1 change: 1 addition & 0 deletions src/DeploymentCockpit.Core/Interfaces/IUnitOfWork.cs
Expand Up @@ -9,5 +9,6 @@ public interface IUnitOfWork : IDisposable
{
void Commit();
IRepository<T> Repository<T>() where T : class;
IDashboardRepository DashboardRepository { get; }
}
}
3 changes: 2 additions & 1 deletion src/DeploymentCockpit.Data/DeploymentCockpit.Data.csproj
Expand Up @@ -76,6 +76,7 @@
<DependentUpon>DeploymentCockpitModel.edmx</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Repositories\DashboardRepository.cs" />
<Compile Include="Repositories\Repository.cs" />
<Compile Include="UnitOfWork.cs" />
<Compile Include="UnitOfWorkFactory.cs" />
Expand Down Expand Up @@ -116,4 +117,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
58 changes: 58 additions & 0 deletions src/DeploymentCockpit.Data/Repositories/DashboardRepository.cs
@@ -0,0 +1,58 @@
using DeploymentCockpit.ApiDtos;
using DeploymentCockpit.Common;
using DeploymentCockpit.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Insula.Common;

namespace DeploymentCockpit.Data.Repositories
{
public class DashboardRepository : IDashboardRepository
{
protected readonly DeploymentCockpitEntities _db;

public DashboardRepository(DeploymentCockpitEntities db)
{
if (db == null)
throw new ArgumentNullException("db");
_db = db;
}

public IEnumerable<ProjectVersionInfo> GetProjectVersionInfo()
{
var statusKey = DeploymentStatus.Finished.GetName();

return _db.ProjectEnvironments
.Select(e =>
new
{
ProjectName = e.Project.Name,
EnvironmentName = e.Name,
DeploymentJob = e.DeploymentJobs
.Where(j => j.StatusKey == statusKey)
.OrderByDescending(j => j.DeploymentJobID)
.FirstOrDefault()
})
.ToList()
.Select(i =>
new ProjectVersionInfo
{
ProjectName = i.ProjectName,
EnvironmentName = i.EnvironmentName,
DeploymentJobID = i.DeploymentJob != null
? i.DeploymentJob.DeploymentJobID as int?
: null,
DeploymentJobTime = i.DeploymentJob != null
? i.DeploymentJob.SubmissionTime.ToString(DomainContext.DateTimeFormatString)
: null,
ProductVersion = i.DeploymentJob != null
? i.DeploymentJob.ProductVersion
: null,
})
.ToList();
}
}
}
11 changes: 11 additions & 0 deletions src/DeploymentCockpit.Data/UnitOfWork.cs
Expand Up @@ -41,5 +41,16 @@ public IRepository<T> Repository<T>()

return _repositories[key] as Repository<T>;
}

private IDashboardRepository _dashboardRepository;
public IDashboardRepository DashboardRepository
{
get
{
if (_dashboardRepository == null)
_dashboardRepository = new DashboardRepository(_db);
return _dashboardRepository;
}
}
}
}
6 changes: 6 additions & 0 deletions src/DeploymentCockpit.Server/App_Start/WebApiConfig.cs
Expand Up @@ -17,6 +17,12 @@ public static void Register(HttpConfiguration config)
new { id = RouteParameter.Optional }
);

config.Routes.MapHttpRoute(
"DashboardApi",
"api/Dashboard/{action}/{id}",
new { id = RouteParameter.Optional }
);

GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver =
new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
#if DEBUG
Expand Down
@@ -0,0 +1,28 @@
using DeploymentCockpit.ApiDtos;
using DeploymentCockpit.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace DeploymentCockpit.Server.Controllers.Api
{
public class DashboardController : ApiController
{
private readonly IDashboardService _dashboardService;

public DashboardController(IDashboardService dashboardService)
{
if (dashboardService == null)
throw new ArgumentNullException("dashboardService");
_dashboardService = dashboardService;
}

public IEnumerable<ProjectVersionInfo> GetProjectVersionInfo()
{
return _dashboardService.GetProjectVersionInfo();
}
}
}
4 changes: 4 additions & 0 deletions src/DeploymentCockpit.Server/DeploymentCockpit.Server.csproj
Expand Up @@ -117,6 +117,9 @@
<Content Include="app\credentials\credentialEdit.html" />
<Content Include="app\dashboard\dashboard.html" />
<Content Include="app\dashboard\DashboardCtrl.js" />
<Content Include="app\dashboard\dashboardDataSvc.js" />
<Content Include="app\dashboard\myProjectVersionInfo.html" />
<Content Include="app\dashboard\myProjectVersionInfo.js" />
<Content Include="app\deploymentPlanParameters\deploymentPlanParametersSvc.js" />
<Content Include="app\deploymentPlanParameters\myDeploymentPlanParameters.html" />
<Content Include="app\deploymentPlanParameters\myDeploymentPlanParameters.js" />
Expand Down Expand Up @@ -234,6 +237,7 @@
</Compile>
<Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Common\ApiException.cs" />
<Compile Include="Controllers\Api\DashboardController.cs" />
<Compile Include="Controllers\Api\DeploymentPlanParametersController.cs" />
<Compile Include="Controllers\Api\UsersController.cs" />
<Compile Include="Filters\AuthorizedUsersFilter.cs" />
Expand Down
5 changes: 5 additions & 0 deletions src/DeploymentCockpit.Server/app/dashboard/dashboard.html
Expand Up @@ -4,6 +4,11 @@ <h2>Dashboard</h2>
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">
<div my-project-version-info></div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div my-active-deployment-jobs></div>
Expand Down
@@ -0,0 +1,9 @@
"use strict";

app.factory("dashboardDataSvc", function ($resource) {
return {
getProjectVersionInfo: function () {
return $resource("api/Dashboard/GetProjectVersionInfo").query();
}
};
});
@@ -0,0 +1,30 @@
<div class="panel panel-info panel-borderless">
<div class="panel-heading">
Project Version Overview
<a href="" class="pull-right" title="Refresh" ng-click="reloadData()">
<span class="glyphicon glyphicon-refresh"></span>
</a>
</div>
<div class="panel-body">
<table class="table table-condensed table-hover table-striped table-borderless">
<thead>
<tr>
<th>Project</th>
<th>Environment</th>
<th>Version</th>
<th>Time</th>
</tr>
</thead>
<tr ng-repeat="versionInfo in data | orderBy:['projectName', 'projectEnvironmentName']">
<td>{{versionInfo.projectName}}</td>
<td>{{versionInfo.environmentName}}</td>
<td>{{versionInfo.productVersion}}</td>
<td>
<a href="#/DeploymentJob/Details/{{versionInfo.deploymentJobID}}">
{{versionInfo.deploymentJobTime}}
</a>
</td>
</tr>
</table>
</div>
</div>
19 changes: 19 additions & 0 deletions src/DeploymentCockpit.Server/app/dashboard/myProjectVersionInfo.js
@@ -0,0 +1,19 @@
"use strict";

app.directive("myProjectVersionInfo", function () {
return {
templateUrl: "app/dashboard/myProjectVersionInfo.html",
scope: {},
controller: function ($scope, $interval, dashboardDataSvc) {
$scope.reloadData = function () {
$scope.data = dashboardDataSvc.getProjectVersionInfo();
};

$scope.reloadData();

$scope.isLoading = function () {
return !$scope.data.$resolved;
};
}
};
});
2 changes: 2 additions & 0 deletions src/DeploymentCockpit.Server/index.html
Expand Up @@ -35,7 +35,9 @@
<script src="app/common/myNavBar.js"></script>
<script src="app/common/myLoadingIndicator.js"></script>

<script src="app/dashboard/dashboardDataSvc.js"></script>
<script src="app/dashboard/DashboardCtrl.js"></script>
<script src="app/dashboard/myProjectVersionInfo.js"></script>

<script src="app/users/usersSvc.js"></script>
<script src="app/users/myUsers.js"></script>
Expand Down

0 comments on commit 77037c3

Please sign in to comment.