From e95872e161fcb9cadc4ff2d650dbfa6c612fab39 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Fri, 22 Jun 2018 17:47:57 +0200 Subject: [PATCH] [WIP/IT] Batch interface & project controller * the batch don't expose any format consideration for the log file * a generated project controller, mostly to get a DbSet from db context --- Yavsc.Abstract/Interfaces/IBatch.cs | 2 +- Yavsc.Server/Models/IT/SourceCode/Batch.cs | 2 +- Yavsc.Server/Models/IT/SourceCode/GitBatch.cs | 4 +- Yavsc/Controllers/ProjectController.cs | 145 ++++++++++++++++ Yavsc/Views/Project/Create.cshtml | 155 +++++++++++++++++ Yavsc/Views/Project/Delete.cshtml | 106 ++++++++++++ Yavsc/Views/Project/Details.cshtml | 102 +++++++++++ Yavsc/Views/Project/Edit.cshtml | 161 ++++++++++++++++++ Yavsc/Views/Project/Index.cshtml | 110 ++++++++++++ cli/project.json | 8 +- rc-num.txt | 2 +- yavsc.code-workspace | 24 --- 12 files changed, 787 insertions(+), 34 deletions(-) create mode 100644 Yavsc/Controllers/ProjectController.cs create mode 100644 Yavsc/Views/Project/Create.cshtml create mode 100644 Yavsc/Views/Project/Delete.cshtml create mode 100644 Yavsc/Views/Project/Details.cshtml create mode 100644 Yavsc/Views/Project/Edit.cshtml create mode 100644 Yavsc/Views/Project/Index.cshtml diff --git a/Yavsc.Abstract/Interfaces/IBatch.cs b/Yavsc.Abstract/Interfaces/IBatch.cs index 7dc31305..e3dac450 100644 --- a/Yavsc.Abstract/Interfaces/IBatch.cs +++ b/Yavsc.Abstract/Interfaces/IBatch.cs @@ -8,6 +8,6 @@ namespace Yavsc.Abstract.Interfaces Action ResultHandler { get; } void Launch(TInput Input); - string HtmlLogPath { get; set; } + string LogPath { get; set; } } } \ No newline at end of file diff --git a/Yavsc.Server/Models/IT/SourceCode/Batch.cs b/Yavsc.Server/Models/IT/SourceCode/Batch.cs index 818af11e..2405c6e1 100644 --- a/Yavsc.Server/Models/IT/SourceCode/Batch.cs +++ b/Yavsc.Server/Models/IT/SourceCode/Batch.cs @@ -6,7 +6,7 @@ namespace Yavsc.Server.Models.IT.SourceCode public abstract class Batch : IBatch { public string WorkingDir { get; set; } - public string HtmlLogPath { get; set; } + public string LogPath { get; set; } public Action ResultHandler { get; private set; } public string []Args { get; set; } public abstract void Launch(TInput Input); diff --git a/Yavsc.Server/Models/IT/SourceCode/GitBatch.cs b/Yavsc.Server/Models/IT/SourceCode/GitBatch.cs index 6fb6490c..b2aaecec 100644 --- a/Yavsc.Server/Models/IT/SourceCode/GitBatch.cs +++ b/Yavsc.Server/Models/IT/SourceCode/GitBatch.cs @@ -44,13 +44,11 @@ namespace Yavsc.Server.Models.IT.SourceCode } bool Pull (GitRepositoryReference input) { - HtmlLogPath = Path.Combine( WorkingDir, "git.log"); + LogPath = Path.Combine( WorkingDir, "git.log"); var pStart = new ProcessStartInfo("git", "pull"); pStart.WorkingDirectory = Path.Combine(WorkingDir,input.Path); pStart.RedirectStandardOutput = true; - - HtmlLogPath = Path.Combine( WorkingDir, "git.log"); using (var mem = new MemoryStream()) { diff --git a/Yavsc/Controllers/ProjectController.cs b/Yavsc/Controllers/ProjectController.cs new file mode 100644 index 00000000..d8aa84dd --- /dev/null +++ b/Yavsc/Controllers/ProjectController.cs @@ -0,0 +1,145 @@ +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Mvc.Rendering; +using Microsoft.Data.Entity; +using Yavsc.Models; +using Yavsc.Server.Models.IT; +using Microsoft.AspNet.Authorization; + +namespace Yavsc.Controllers +{ + [Authorize("AdministratorOnly")] + public class ProjectController : Controller + { + private ApplicationDbContext _context; + + public ProjectController(ApplicationDbContext context) + { + _context = context; + } + + // GET: Project + public async Task Index() + { + var applicationDbContext = _context.Projects.Include(p => p.Client).Include(p => p.Context).Include(p => p.PerformerProfile).Include(p => p.Regularisation).Include(p => p.Repository); + return View(await applicationDbContext.ToListAsync()); + } + + // GET: Project/Details/5 + public async Task Details(long? id) + { + if (id == null) + { + return HttpNotFound(); + } + + Project project = await _context.Projects.SingleAsync(m => m.Id == id); + if (project == null) + { + return HttpNotFound(); + } + + return View(project); + } + + // GET: Project/Create + public IActionResult Create() + { + ViewData["ClientId"] = new SelectList(_context.ApplicationUser, "Id", "Client"); + ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context"); + ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "PerformerProfile"); + ViewData["PaymentId"] = new SelectList(_context.PayPalPayments, "CreationToken", "Regularisation"); + ViewData["Name"] = new SelectList(_context.GitRepositoryReference, "Path", "Repository"); + return View(); + } + + // POST: Project/Create + [HttpPost] + [ValidateAntiForgeryToken] + public async Task Create(Project project) + { + if (ModelState.IsValid) + { + _context.Projects.Add(project); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + ViewData["ClientId"] = new SelectList(_context.ApplicationUser, "Id", "Client", project.ClientId); + ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context", project.ActivityCode); + ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "PerformerProfile", project.PerformerId); + ViewData["PaymentId"] = new SelectList(_context.PayPalPayments, "CreationToken", "Regularisation", project.PaymentId); + ViewData["Name"] = new SelectList(_context.GitRepositoryReference, "Path", "Repository", project.Name); + return View(project); + } + + // GET: Project/Edit/5 + public async Task Edit(long? id) + { + if (id == null) + { + return HttpNotFound(); + } + + Project project = await _context.Projects.SingleAsync(m => m.Id == id); + if (project == null) + { + return HttpNotFound(); + } + ViewData["ClientId"] = new SelectList(_context.ApplicationUser, "Id", "Client", project.ClientId); + ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context", project.ActivityCode); + ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "PerformerProfile", project.PerformerId); + ViewData["PaymentId"] = new SelectList(_context.PayPalPayments, "CreationToken", "Regularisation", project.PaymentId); + ViewData["Name"] = new SelectList(_context.GitRepositoryReference, "Path", "Repository", project.Name); + return View(project); + } + + // POST: Project/Edit/5 + [HttpPost] + [ValidateAntiForgeryToken] + public async Task Edit(Project project) + { + if (ModelState.IsValid) + { + _context.Update(project); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + ViewData["ClientId"] = new SelectList(_context.ApplicationUser, "Id", "Client", project.ClientId); + ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context", project.ActivityCode); + ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "PerformerProfile", project.PerformerId); + ViewData["PaymentId"] = new SelectList(_context.PayPalPayments, "CreationToken", "Regularisation", project.PaymentId); + ViewData["Name"] = new SelectList(_context.GitRepositoryReference, "Path", "Repository", project.Name); + return View(project); + } + + // GET: Project/Delete/5 + [ActionName("Delete")] + public async Task Delete(long? id) + { + if (id == null) + { + return HttpNotFound(); + } + + Project project = await _context.Projects.SingleAsync(m => m.Id == id); + if (project == null) + { + return HttpNotFound(); + } + + return View(project); + } + + // POST: Project/Delete/5 + [HttpPost, ActionName("Delete")] + [ValidateAntiForgeryToken] + public async Task DeleteConfirmed(long id) + { + Project project = await _context.Projects.SingleAsync(m => m.Id == id); + _context.Projects.Remove(project); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + } +} diff --git a/Yavsc/Views/Project/Create.cshtml b/Yavsc/Views/Project/Create.cshtml new file mode 100644 index 00000000..73d871d3 --- /dev/null +++ b/Yavsc/Views/Project/Create.cshtml @@ -0,0 +1,155 @@ +@model Yavsc.Server.Models.IT.Project + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +
+
+

Project

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+ + + diff --git a/Yavsc/Views/Project/Delete.cshtml b/Yavsc/Views/Project/Delete.cshtml new file mode 100644 index 00000000..e3fc40b1 --- /dev/null +++ b/Yavsc/Views/Project/Delete.cshtml @@ -0,0 +1,106 @@ +@model Yavsc.Server.Models.IT.Project + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

Project

+
+
+
+ @Html.DisplayNameFor(model => model.Consent) +
+
+ @Html.DisplayFor(model => model.Consent) +
+
+ @Html.DisplayNameFor(model => model.DateCreated) +
+
+ @Html.DisplayFor(model => model.DateCreated) +
+
+ @Html.DisplayNameFor(model => model.DateModified) +
+
+ @Html.DisplayFor(model => model.DateModified) +
+
+ @Html.DisplayNameFor(model => model.Description) +
+
+ @Html.DisplayFor(model => model.Description) +
+
+ @Html.DisplayNameFor(model => model.LocalRepo) +
+
+ @Html.DisplayFor(model => model.LocalRepo) +
+
+ @Html.DisplayNameFor(model => model.OwnerId) +
+
+ @Html.DisplayFor(model => model.OwnerId) +
+
+ @Html.DisplayNameFor(model => model.Previsional) +
+
+ @Html.DisplayFor(model => model.Previsional) +
+
+ @Html.DisplayNameFor(model => model.Rejected) +
+
+ @Html.DisplayFor(model => model.Rejected) +
+
+ @Html.DisplayNameFor(model => model.RejectedAt) +
+
+ @Html.DisplayFor(model => model.RejectedAt) +
+
+ @Html.DisplayNameFor(model => model.Status) +
+
+ @Html.DisplayFor(model => model.Status) +
+
+ @Html.DisplayNameFor(model => model.UserCreated) +
+
+ @Html.DisplayFor(model => model.UserCreated) +
+
+ @Html.DisplayNameFor(model => model.UserModified) +
+
+ @Html.DisplayFor(model => model.UserModified) +
+
+ @Html.DisplayNameFor(model => model.ValidationDate) +
+
+ @Html.DisplayFor(model => model.ValidationDate) +
+
+ @Html.DisplayNameFor(model => model.Version) +
+
+ @Html.DisplayFor(model => model.Version) +
+
+ +
+
+ | + Back to List +
+
+
diff --git a/Yavsc/Views/Project/Details.cshtml b/Yavsc/Views/Project/Details.cshtml new file mode 100644 index 00000000..af07a929 --- /dev/null +++ b/Yavsc/Views/Project/Details.cshtml @@ -0,0 +1,102 @@ +@model Yavsc.Server.Models.IT.Project + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

Project

+
+
+
+ @Html.DisplayNameFor(model => model.Consent) +
+
+ @Html.DisplayFor(model => model.Consent) +
+
+ @Html.DisplayNameFor(model => model.DateCreated) +
+
+ @Html.DisplayFor(model => model.DateCreated) +
+
+ @Html.DisplayNameFor(model => model.DateModified) +
+
+ @Html.DisplayFor(model => model.DateModified) +
+
+ @Html.DisplayNameFor(model => model.Description) +
+
+ @Html.DisplayFor(model => model.Description) +
+
+ @Html.DisplayNameFor(model => model.LocalRepo) +
+
+ @Html.DisplayFor(model => model.LocalRepo) +
+
+ @Html.DisplayNameFor(model => model.OwnerId) +
+
+ @Html.DisplayFor(model => model.OwnerId) +
+
+ @Html.DisplayNameFor(model => model.Previsional) +
+
+ @Html.DisplayFor(model => model.Previsional) +
+
+ @Html.DisplayNameFor(model => model.Rejected) +
+
+ @Html.DisplayFor(model => model.Rejected) +
+
+ @Html.DisplayNameFor(model => model.RejectedAt) +
+
+ @Html.DisplayFor(model => model.RejectedAt) +
+
+ @Html.DisplayNameFor(model => model.Status) +
+
+ @Html.DisplayFor(model => model.Status) +
+
+ @Html.DisplayNameFor(model => model.UserCreated) +
+
+ @Html.DisplayFor(model => model.UserCreated) +
+
+ @Html.DisplayNameFor(model => model.UserModified) +
+
+ @Html.DisplayFor(model => model.UserModified) +
+
+ @Html.DisplayNameFor(model => model.ValidationDate) +
+
+ @Html.DisplayFor(model => model.ValidationDate) +
+
+ @Html.DisplayNameFor(model => model.Version) +
+
+ @Html.DisplayFor(model => model.Version) +
+
+
+

+ Edit | + Back to List +

diff --git a/Yavsc/Views/Project/Edit.cshtml b/Yavsc/Views/Project/Edit.cshtml new file mode 100644 index 00000000..91a1bccd --- /dev/null +++ b/Yavsc/Views/Project/Edit.cshtml @@ -0,0 +1,161 @@ +@model Yavsc.Server.Models.IT.Project + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +
+
+

Project

+
+
+ +
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+ + + diff --git a/Yavsc/Views/Project/Index.cshtml b/Yavsc/Views/Project/Index.cshtml new file mode 100644 index 00000000..2ab3eff1 --- /dev/null +++ b/Yavsc/Views/Project/Index.cshtml @@ -0,0 +1,110 @@ +@model IEnumerable + +@{ + ViewData["Title"] = "Index"; +} + +

Index

+ +

+ Create New +

+ + + + + + + + + + + + + + + + + + + +@foreach (var item in Model) { + + + + + + + + + + + + + + + + + +} +
+ @Html.DisplayNameFor(model => model.Consent) + + @Html.DisplayNameFor(model => model.DateCreated) + + @Html.DisplayNameFor(model => model.DateModified) + + @Html.DisplayNameFor(model => model.Description) + + @Html.DisplayNameFor(model => model.LocalRepo) + + @Html.DisplayNameFor(model => model.OwnerId) + + @Html.DisplayNameFor(model => model.Previsional) + + @Html.DisplayNameFor(model => model.Rejected) + + @Html.DisplayNameFor(model => model.RejectedAt) + + @Html.DisplayNameFor(model => model.Status) + + @Html.DisplayNameFor(model => model.UserCreated) + + @Html.DisplayNameFor(model => model.UserModified) + + @Html.DisplayNameFor(model => model.ValidationDate) + + @Html.DisplayNameFor(model => model.Version) +
+ @Html.DisplayFor(modelItem => item.Consent) + + @Html.DisplayFor(modelItem => item.DateCreated) + + @Html.DisplayFor(modelItem => item.DateModified) + + @Html.DisplayFor(modelItem => item.Description) + + @Html.DisplayFor(modelItem => item.LocalRepo) + + @Html.DisplayFor(modelItem => item.OwnerId) + + @Html.DisplayFor(modelItem => item.Previsional) + + @Html.DisplayFor(modelItem => item.Rejected) + + @Html.DisplayFor(modelItem => item.RejectedAt) + + @Html.DisplayFor(modelItem => item.Status) + + @Html.DisplayFor(modelItem => item.UserCreated) + + @Html.DisplayFor(modelItem => item.UserModified) + + @Html.DisplayFor(modelItem => item.ValidationDate) + + @Html.DisplayFor(modelItem => item.Version) + + Edit | + Details | + Delete +
diff --git a/cli/project.json b/cli/project.json index 86801006..362c46cf 100644 --- a/cli/project.json +++ b/cli/project.json @@ -44,13 +44,13 @@ "Microsoft.Framework.Configuration.Json": "1.0.0-beta8", "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4", "Newtonsoft.Json": "9.0.1", - "Yavsc": { "version": "1.0.5-rc21-beta1", "target": "package" }, - "Yavsc.Abstract": { "version": "1.0.5-rc21-beta1", "target": "package" }, - "Yavsc.Server": { "version": "1.0.5-rc21-beta1", "target": "package" } + "Yavsc": { "version": "1.0.5-rc21-beta2", "target": "package" }, + "Yavsc.Abstract": { "version": "1.0.5-rc21-beta2", "target": "package" }, + "Yavsc.Server": { "version": "1.0.5-rc21-beta2", "target": "package" } }, "frameworks": { "dnx451": { "System.Net": "4.0.0" } } -} \ No newline at end of file +} diff --git a/rc-num.txt b/rc-num.txt index a804a292..cbbf2ac2 100644 --- a/rc-num.txt +++ b/rc-num.txt @@ -1 +1 @@ -21-beta1 +21-beta2 diff --git a/yavsc.code-workspace b/yavsc.code-workspace index 494ebc4d..dd2d766d 100644 --- a/yavsc.code-workspace +++ b/yavsc.code-workspace @@ -20,30 +20,6 @@ }, { "path": "OAuth.AspNet.Token" - }, - { - "path": "." - }, - { - "path": "yaxwtui" - }, - { - "path": "yaxwtui.Gtk2" - }, - { - "path": "yaxwtui.Gtk3" - }, - { - "path": "yaxwtui.Mac" - }, - { - "path": "yaxwtui.Wpf" - }, - { - "path": "yaxwtui.XamMac" - }, - { - "path": "ZicMoove" } ], "settings": {