-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from nokia-wroclaw/develop
First demo in NOKIA
- Loading branch information
Showing
88 changed files
with
3,267 additions
and
1,845 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.sh text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -318,3 +318,5 @@ ASALocalRun/ | |
|
||
# MSBuild Binary and Structured Log | ||
*.binlog | ||
|
||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
# innovativeproject-dev-dashboard [![Build Status](https://travis-ci.org/nokia-wroclaw/innovativeproject-dev-dashboard.svg?branch=develop)](https://travis-ci.org/nokia-wroclaw/innovativeproject-dev-dashboard) | ||
# innovativeproject-dev-dashboard | ||
[![Build Status](https://travis-ci.org/nokia-wroclaw/innovativeproject-dev-dashboard.svg?branch=develop)](https://travis-ci.org/nokia-wroclaw/innovativeproject-dev-dashboard) | ||
--------- | ||
|
||
## Goal | ||
The goal of this project is to build an app, which will show current states of CI systems for repositories on source control systems. | ||
|
||
|
||
## Description | ||
This app is designed to be viewed on TVs or other displays which are not used at the moment. It allows to configure static panels, which always shows given branch or dynamic panels for discovering newest pipelines/branches. It should be able to track many projects in many CI systems. Also, writing own plugins to make this app able to deal with new CI systems is supported. | ||
|
||
At this moment, only [GitLab](https://gitlab.com) is supported. | ||
|
||
### Technologies | ||
Project is divided into frontend and backend. Technologies in use | ||
|
||
| FrontEnd | BackEnd | Both | | ||
| :--------------------:|:------------------:|:-----------------:| | ||
| [Angular](https://angular.io/)| [Autofac](https://autofac.org/)| [Docker](https://www.docker.com/)| | ||
| [Angular Material](https://material.angular.io/)| [Hangfire](https://www.hangfire.io/)| [Swagger](https://swagger.io/)| | ||
| [Bootstrap](https://getbootstrap.com/)| [RestSHarp](http://restsharp.org/)| [Heroku](https://www.heroku.com/)| | ||
| [angular2gridster](https://github.com/swiety85/angular2gridster)| [.NET Core 2.0](https://docs.microsoft.com/pl-pl/aspnet/core/)|| | ||
|
||
## Deployment | ||
After push to **develop** branch and **successful** Travis build, applications will be deployed to Heroku and can be accessed here: | ||
[Online application](http://cidasher.herokuapp.com/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ docker-compose.yml | |
docker-compose.*.yml | ||
*/bin | ||
*/obj | ||
node_modules | ||
**/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Dashboard.Application.Interfaces.Services; | ||
using Hangfire; | ||
|
||
namespace Dashboard.Application | ||
{ | ||
public static class CronJobs | ||
{ | ||
public static void Register() | ||
{ | ||
//Fetch Data Panels Project | ||
RecurringJob.AddOrUpdate<EnqueueFetchProjectsCiDataJob>("fetch-cidata-projects", | ||
j => j.EnqueueFetching(), EnqueueFetchProjectsCiDataJob.CronExpression); | ||
} | ||
} | ||
|
||
public class EnqueueFetchProjectsCiDataJob | ||
{ | ||
public static readonly string CronExpression = "*/4 * * * *"; | ||
|
||
private readonly IPanelService _panelService; | ||
|
||
public EnqueueFetchProjectsCiDataJob(IPanelService panelService) | ||
{ | ||
_panelService = panelService; | ||
} | ||
|
||
public async Task EnqueueFetching() | ||
{ | ||
var activeProjects = (await _panelService.GetActiveProjectIds()).ToList(); | ||
|
||
activeProjects.ForEach(projectId => | ||
BackgroundJob.Enqueue<IProjectService>(s => s.UpdateCiDataForProjectAsync(projectId))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,112 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Web; | ||
using Dashboard.Application.GitLabApi.Models; | ||
using RestSharp; | ||
using RestSharp.Extensions; | ||
|
||
namespace Dashboard.Application.GitLabApi | ||
{ | ||
//https://github.com/emilianoeloi/gitlab-ci-dashboard/blob/master/src/gitlab.js | ||
public class GitLabClient | ||
{ | ||
private RestClient Client { get; } | ||
|
||
public GitLabClient(string apiHost, string apiKey) | ||
{ | ||
// Convert snake_casing to CamelCasing | ||
SimpleJson.SimpleJson.CurrentJsonSerializerStrategy = new SnakeJsonSerializerStrategy(); | ||
|
||
Client = new RestClient | ||
{ | ||
Authenticator = new ApiTokenAuthenticator(apiKey), | ||
BaseUrl = new Uri($"{apiHost}/api/v4/") | ||
}; | ||
} | ||
|
||
public async Task<Pipeline> GetPipelineById(string projectId, string pipelineId) | ||
{ | ||
var r = await GetPipelines(projectId, pipelineId : pipelineId); | ||
return r.FirstOrDefault(); | ||
} | ||
|
||
public async Task<Pipeline> GetPipelineByBranch(string projectId, string pipelineBranch) | ||
{ | ||
var r = await GetPipelines(projectId, branchName : pipelineBranch); | ||
return r.FirstOrDefault(); | ||
} | ||
|
||
public async Task<IEnumerable<Pipeline>> GetPipelines(string projectId, string pipelineId = "", int numberOfPipelines = 20, string branchName = "") | ||
{ | ||
var request = new RestRequest("projects/{projectId}/pipelines/{pipelineId}", Method.GET); | ||
request.AddUrlSegment("projectId", HttpUtility.UrlEncode(projectId)); | ||
request.AddUrlSegment("pipelineId", pipelineId); | ||
|
||
request.AddQueryParameter("per_page", numberOfPipelines.ToString()); | ||
|
||
if (!string.IsNullOrEmpty(branchName)) | ||
request.AddQueryParameter("ref", branchName); | ||
|
||
var r = await Client.ExecuteTaskAsync<List<Pipeline>>(request); | ||
return r.Data; | ||
} | ||
|
||
public async Task<Branch> GetBranch(string projectId, string branchName) | ||
{ | ||
var r = await GetBranches(projectId, branchName : branchName); | ||
return r.FirstOrDefault(); | ||
} | ||
|
||
public async Task<IEnumerable<Branch>> GetBranches(string projectId, string branchName = "") | ||
{ | ||
var request = new RestRequest("projects/{projectId}/repository/branches/{branchName}", Method.GET); | ||
request.AddUrlSegment("projectId", HttpUtility.UrlEncode(projectId)); | ||
request.AddUrlSegment("branchName", branchName); | ||
|
||
var r = await Client.ExecuteTaskAsync<List<Branch>>(request); | ||
return r.Data; | ||
} | ||
|
||
public async Task<Commit> GetCommitBySHA(string projectId, string commitSHA) | ||
{ | ||
var r = await GetCommits(projectId, commitSHA : commitSHA); | ||
return r.FirstOrDefault(); | ||
} | ||
|
||
public async Task<IEnumerable<Commit>> GetCommits(string projectId, string commitSHA = "") | ||
{ | ||
var request = new RestRequest("projects/{projectId}/repository/commits/{commitSHA}", Method.GET); | ||
request.AddUrlSegment("projectId", HttpUtility.UrlEncode(projectId)); | ||
request.AddUrlSegment("commitSHA", commitSHA); | ||
|
||
var r = await Client.ExecuteTaskAsync<List<Commit>>(request); | ||
return r.Data; | ||
} | ||
|
||
public async Task<IEnumerable<Job>> GetJobs(string projectId, string pipelineId) | ||
{ | ||
var request = new RestRequest("projects/{projectId}/pipelines/{pipelineId}/jobs", Method.GET); | ||
request.AddUrlSegment("projectId", HttpUtility.UrlEncode(projectId)); | ||
request.AddUrlSegment("pipelineId", pipelineId); | ||
|
||
request.AddQueryParameter("per_page", "10000");//Arbitrary value | ||
|
||
var r = await Client.ExecuteTaskAsync<IEnumerable<Job>>(request); | ||
return r.Data; | ||
} | ||
|
||
public async Task<IEnumerable<Branch>> SearchForBranchInProject(string projectId, string branchPartialName) | ||
{ | ||
var request = new RestRequest("projects/{projectId}/repository/branches?search={branchPartialName}", Method.GET); | ||
request.AddUrlSegment("projectId", HttpUtility.UrlEncode(projectId)); | ||
request.AddUrlSegment("branchPartialName", branchPartialName); | ||
|
||
request.AddQueryParameter("per_page", "10000"); | ||
|
||
var r = await Client.ExecuteTaskAsync<List<Branch>>(request); | ||
return r.Data; | ||
} | ||
} | ||
} | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Web; | ||
using Dashboard.Application.GitLabApi.Models; | ||
using RestSharp; | ||
using RestSharp.Extensions; | ||
|
||
namespace Dashboard.Application.GitLabApi | ||
{ | ||
//https://github.com/emilianoeloi/gitlab-ci-dashboard/blob/master/src/gitlab.js | ||
public class GitLabClient | ||
{ | ||
private RestClient Client { get; } | ||
|
||
public GitLabClient(string apiHost, string apiKey) | ||
{ | ||
// Convert snake_casing to CamelCasing | ||
SimpleJson.SimpleJson.CurrentJsonSerializerStrategy = new SnakeJsonSerializerStrategy(); | ||
|
||
Client = new RestClient | ||
{ | ||
Authenticator = new ApiTokenAuthenticator(apiKey), | ||
BaseUrl = new Uri($"{apiHost}/api/v4/") | ||
}; | ||
} | ||
|
||
public async Task<Pipeline> GetPipelineById(string projectId, string pipelineId) | ||
{ | ||
var r = await GetPipelines(projectId, pipelineId : pipelineId); | ||
return r.FirstOrDefault(); | ||
} | ||
|
||
public async Task<Pipeline> GetPipelineByBranch(string projectId, string pipelineBranch) | ||
{ | ||
var r = await GetPipelines(projectId, branchName : pipelineBranch); | ||
return r.FirstOrDefault(); | ||
} | ||
|
||
public async Task<IEnumerable<Pipeline>> GetPipelines(string projectId, string pipelineId = "", int numberOfPipelines = 20, string branchName = "") | ||
{ | ||
var request = new RestRequest("projects/{projectId}/pipelines/{pipelineId}", Method.GET); | ||
request.AddUrlSegment("projectId", HttpUtility.UrlEncode(projectId)); | ||
request.AddUrlSegment("pipelineId", pipelineId); | ||
|
||
request.AddQueryParameter("per_page", numberOfPipelines.ToString()); | ||
|
||
if (!string.IsNullOrEmpty(branchName)) | ||
request.AddQueryParameter("ref", branchName); | ||
|
||
var r = await Client.ExecuteTaskAsync<List<Pipeline>>(request); | ||
return r.Data; | ||
} | ||
|
||
public async Task<Branch> GetBranch(string projectId, string branchName) | ||
{ | ||
var r = await GetBranches(projectId, branchName : branchName); | ||
return r.FirstOrDefault(); | ||
} | ||
|
||
public async Task<IEnumerable<Branch>> GetBranches(string projectId, string branchName = "") | ||
{ | ||
var request = new RestRequest("projects/{projectId}/repository/branches/{branchName}", Method.GET); | ||
request.AddUrlSegment("projectId", HttpUtility.UrlEncode(projectId)); | ||
request.AddUrlSegment("branchName", branchName); | ||
|
||
var r = await Client.ExecuteTaskAsync<List<Branch>>(request); | ||
return r.Data; | ||
} | ||
|
||
public async Task<Commit> GetCommitBySHA(string projectId, string commitSHA) | ||
{ | ||
var r = await GetCommits(projectId, commitSHA : commitSHA); | ||
return r.FirstOrDefault(); | ||
} | ||
|
||
public async Task<IEnumerable<Commit>> GetCommits(string projectId, string commitSHA = "") | ||
{ | ||
var request = new RestRequest("projects/{projectId}/repository/commits/{commitSHA}", Method.GET); | ||
request.AddUrlSegment("projectId", HttpUtility.UrlEncode(projectId)); | ||
request.AddUrlSegment("commitSHA", commitSHA); | ||
|
||
var r = await Client.ExecuteTaskAsync<List<Commit>>(request); | ||
return r.Data; | ||
} | ||
|
||
public async Task<IEnumerable<Job>> GetJobs(string projectId, string pipelineId) | ||
{ | ||
var request = new RestRequest("projects/{projectId}/pipelines/{pipelineId}/jobs", Method.GET); | ||
request.AddUrlSegment("projectId", HttpUtility.UrlEncode(projectId)); | ||
request.AddUrlSegment("pipelineId", pipelineId); | ||
|
||
request.AddQueryParameter("per_page", "10000");//Arbitrary value | ||
|
||
var r = await Client.ExecuteTaskAsync<IEnumerable<Job>>(request); | ||
return r.Data; | ||
} | ||
|
||
public async Task<IEnumerable<Branch>> SearchForBranchInProject(string projectId, string branchPartialName) | ||
{ | ||
var request = new RestRequest("projects/{projectId}/repository/branches?search={branchPartialName}", Method.GET); | ||
request.AddUrlSegment("projectId", HttpUtility.UrlEncode(projectId)); | ||
request.AddUrlSegment("branchPartialName", branchPartialName); | ||
|
||
request.AddQueryParameter("per_page", "10000"); | ||
|
||
var r = await Client.ExecuteTaskAsync<List<Branch>>(request); | ||
return r.Data; | ||
} | ||
} | ||
} |
Oops, something went wrong.