- Timestamp:
- 03/11/16 12:56:12 (9 years ago)
- Location:
- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager
- Files:
-
- 27 added
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager
-
Property
svn:ignore
set to
project.lock.json
-
Property
svn:ignore
set to
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/HomeController.cs
r13656 r13689 27 27 var model = loginViewModelService.GetLoginViewModel(); 28 28 HiveServiceLocatorWebManagerService hiveServiceLocator = (HiveServiceLocatorWebManagerService)HiveServiceLocatorWebManagerService.Instance; 29 Settings.Default.UserName = loginName;30 Settings.Default.Password = Common.CryptoService.EncryptString(password);31 Settings.Default.Save();29 HeuristicLab.Clients.Common.Properties.Settings.Default.UserName = loginName; 30 HeuristicLab.Clients.Common.Properties.Settings.Default.Password = Common.CryptoService.EncryptString(password); 31 HeuristicLab.Clients.Common.Properties.Settings.Default.Save(); 32 32 hiveServiceLocator.Username = loginName; 33 33 hiveServiceLocator.Password = password; -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/JobController.cs
r13656 r13689 14 14 using HeuristicLab.Core; 15 15 using HeuristicLab.Optimization; 16 using System.Threading; 16 17 17 18 namespace HeuristicLab.Clients.Hive.WebJobManager.Controllers … … 32 33 _environment = env; 33 34 } 35 #region Jobs 34 36 public IActionResult Index() 35 37 { 36 38 try 37 39 { 40 38 41 vm.userJobs = client.GetJobs(); 39 42 } … … 56 59 vm.userJobs = client.GetJobs(); 57 60 vm.selectedJob = client.GetJob(id); 58 vm.jobTasks = client.GetLightweightJobTasks(id); 61 62 vm.lightJobTasks = client.GetLightweightJobTasks(id); 63 foreach (var light in vm.lightJobTasks) 64 { 65 vm.filledJobTasks.Add(client.GetTask(light.Id)); 66 } 59 67 ViewBag.Title = vm.selectedJob.Name + " - Jobs"; 60 68 return View("Index", vm); … … 66 74 } 67 75 } 68 public IActionResult Delete(Guid id) 76 public IActionResult Delete(Guid id)// delete a job 69 77 { 70 78 if (((HiveServiceLocatorWebManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin()) … … 83 91 } 84 92 } 85 86 public IActionResult Upload() 93 #endregion 94 95 #region Uploads 96 public IActionResult Uploads() 97 { 98 if (((HiveServiceLocatorWebManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin()) 99 { 100 UploadedJobViewModel upper = new UploadedJobViewModel(); 101 fillUploadsPaths(upper, -1); 102 103 ViewBag.Title = "Uploaded files"; 104 return View("Uploads", upper); 105 } 106 else 107 { 108 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 109 return RedirectToAction("Index", "Home"); 110 } 111 } 112 public IActionResult UploadDir(int index) 113 { 114 if (((HiveServiceLocatorWebManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin()) 115 { 116 UploadedJobViewModel upper = new UploadedJobViewModel(); 117 fillUploadsPaths(upper, index); 118 119 ViewBag.Title = "Uploaded files"; 120 return View("Uploads", upper); 121 } 122 else 123 { 124 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 125 return RedirectToAction("Index", "Home"); 126 } 127 } 128 private void fillUploadsPaths(UploadedJobViewModel vm, int index) 129 { 130 var tempdex = index; //Fix when maps gets deleted 131 var start = Path.Combine(_environment.WebRootPath, "uploads", client.ClientCredentials.UserName.UserName); 132 var dirs = Directory.GetDirectories(start); 133 foreach (string dir in dirs) 134 { 135 if (Directory.GetFiles(dir).Length == 0 && Directory.GetDirectories(dir).Length == 0) 136 { 137 Directory.Delete(dir, false); 138 tempdex = -1; 139 } 140 else { 141 vm.FullDatePaths.Add(dir); 142 var temp = dir.Split('\\'); 143 vm.DisplayDatePaths.Add(temp[temp.Length - 1]); 144 } 145 } 146 if (tempdex != -1) 147 { 148 vm.SelectedIndex = tempdex; 149 dirs = Directory.GetFiles(vm.FullDatePaths[tempdex]); 150 foreach (string dir in dirs) 151 { 152 vm.FullFilesPaths.Add(dir); 153 var temp = dir.Split('\\'); 154 vm.DisplayFilesPaths.Add(temp[temp.Length - 1]); 155 } 156 } 157 } 158 public IActionResult DeleteFile(int index, int filedex) 159 { 160 if (((HiveServiceLocatorWebManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin()) 161 { 162 UploadedJobViewModel upper = new UploadedJobViewModel(); 163 fillUploadsPaths(upper, index); 164 System.IO.File.Delete(upper.FullFilesPaths[filedex]); 165 var message = upper.DisplayFilesPaths[filedex] + " has been deleted"; 166 167 upper = new UploadedJobViewModel(); 168 fillUploadsPaths(upper, index); 169 upper.message = message; 170 ViewBag.Title = "Uploaded files"; 171 172 return View("Uploads", upper); 173 } 174 else 175 { 176 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 177 return RedirectToAction("Index", "Home"); 178 } 179 } 180 181 public IActionResult OpenFile(int index, int filedex) 182 { 183 if (((HiveServiceLocatorWebManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin()) 184 { 185 UploadedJobViewModel upper = new UploadedJobViewModel(); 186 fillUploadsPaths(upper, index); 187 188 FileOpeningService serve = FileOpeningService.Instance; 189 serve.NewModel(); 190 serve.env = _environment; 191 192 var ioptimizer = ContentManager.Load(upper.FullFilesPaths[filedex]); 193 194 serve.vm.SelectedTask = new OptimizerHiveTask((IOptimizer)ioptimizer); 195 if (serve.vm.SelectedTask.ItemTask.Item is IAlgorithm) 196 { 197 serve.vm.SelectedAlgorithm = (IAlgorithm)serve.vm.SelectedTask.ItemTask.Item; 198 } 199 else if (serve.vm.SelectedTask.ItemTask.Item is BatchRun) 200 { 201 serve.vm.SelectedBatchRun = (BatchRun)serve.vm.SelectedTask.ItemTask.Item; 202 } 203 else if (serve.vm.SelectedTask.ItemTask.Item is Experiment) 204 { 205 serve.vm.SelectedExperiment = (Experiment)serve.vm.SelectedTask.ItemTask.Item; 206 } 207 208 ViewBag.Title = serve.vm.SelectedTask.ItemTask.Name + " - Open file"; 209 210 return View("OpenFile", serve.vm); 211 } 212 else 213 { 214 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 215 return RedirectToAction("Index", "Home"); 216 } 217 } 218 219 public IActionResult AddToHive() 220 { 221 if (((HiveServiceLocatorWebManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin()) 222 { 223 var job = FileOpeningService.Instance.AddCurrentModelToHive(); 224 while (job.Progress.ProgressValue != 1) 225 { } 226 227 Thread.Sleep(1000); 228 job.Progress.Status = "Upload finished"; 229 Thread.Sleep(2000); 230 return RedirectToAction("Index", "Job"); 231 } 232 else 233 { 234 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 235 return RedirectToAction("Index", "Home"); 236 } 237 } 238 //TODO Work in progress 239 /* public async Task<IActionResult> DownloadFile(int index, int filedex) 240 { 241 if (((HiveServiceLocatorWebManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin()) 242 { 243 UploadedJobViewModel upper = new UploadedJobViewModel(); 244 fillUploadsPaths(upper, index); 245 246 HttpContext.Response.ContentType = "APPLICATION/OCTET-STREAM"; 247 String Header = "Attachment; Filename=" + upper.DisplayFilesPaths[filedex]; 248 HttpContext.Response.Headers.Add("Content-Disposition", Header); 249 System.IO.FileInfo Dfile = new System.IO.FileInfo(upper.FullFilesPaths[filedex]); 250 await HttpContext.Response.WriteAsync(Dfile.FullName); 251 //HttpContext.Response.End(); 252 253 var message = upper.DisplayFilesPaths[filedex] + " has been downloaded"; 254 255 upper.message = message; 256 ViewBag.Title = "Downloaded file"; 257 258 return View("Uploads", upper); 259 } 260 else 261 { 262 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 263 return RedirectToAction("Index", "Home"); 264 } 265 }*/ 266 267 #endregion 268 269 #region Uploader 270 public IActionResult Uploader() 87 271 { 88 272 if (((HiveServiceLocatorWebManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin()) 89 273 { 90 274 ViewBag.Title = "Upload Jobs"; 91 return View("Upload"); 275 ViewBag.Name = client.ClientCredentials.UserName.UserName; 276 return View("Uploader"); 92 277 } 93 278 else … … 98 283 } 99 284 [HttpPost] 100 public async Task<IActionResult> Upload (ICollection<IFormFile> files)285 public async Task<IActionResult> Uploader(ICollection<IFormFile> files, string directory) 101 286 { 102 287 103 288 UploadedJobViewModel upper = new UploadedJobViewModel(); 104 var uploads = Path.Combine(_environment.WebRootPath, "uploads"); 289 var uploads = Path.Combine(_environment.WebRootPath, "uploads", client.ClientCredentials.UserName.UserName, 290 directory); 291 Directory.CreateDirectory(uploads); 105 292 foreach (var file in files) 106 293 { … … 109 296 var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); 110 297 await file.SaveAsAsync(Path.Combine(uploads, fileName)); 111 var ioptimizer = ContentManager.Load(Path.Combine(uploads, fileName));112 OptimizerHiveTask task = new OptimizerHiveTask((IOptimizer)ioptimizer);113 upper.Tasks.Add(task);298 // var ioptimizer = ContentManager.Load(Path.Combine(uploads, fileName)); 299 //OptimizerHiveTask task = new OptimizerHiveTask((IOptimizer)ioptimizer); 300 //upper.Tasks.Add(task); 114 301 } 115 302 } 116 303 ViewBag.Title = "Upload complete"; 117 return View(); 118 119 } 304 return RedirectToAction("Uploads", "Job"); 305 306 } 307 #endregion 120 308 } 121 309 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Startup.cs
r13656 r13689 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Threading.Tasks; 5 using Microsoft.AspNet.Builder; 1 using Microsoft.AspNet.Builder; 6 2 using Microsoft.AspNet.Hosting; 7 using Microsoft.AspNet.Http;8 3 using Microsoft.Extensions.DependencyInjection; 9 4 using HeuristicLab.Clients.Hive.WebJobManager.Services; … … 11 6 using HeuristicLab.Common; 12 7 using HeuristicLab.Core; 8 using HeuristicLab.PluginInfrastructure; 9 13 10 14 11 namespace HeuristicLab.Clients.Hive.WebJobManager … … 16 13 public class Startup 17 14 { 18 private IHostingEnvironment hostingEnvironment; 15 public IHostingEnvironment hostingEnvironment { 16 get; set; } 19 17 public Startup(IHostingEnvironment hostingEnvironment) 20 18 { … … 23 21 .AddEnvironmentVariables(); 24 22 var config = builder.Build(); 23 24 ApplicationManager.InitializeForWeb(); 25 26 25 27 ContentManager.Initialize(new PersistenceContentManager()); 26 28 //Console.WriteLine(""+ config.Get("configuration")); … … 34 36 services.AddMvc(); 35 37 services.AddSingleton<ILoginViewModelService, LoginViewModelService>(); 38 services.AddSingleton<IHiveServiceLocator, HiveServiceLocatorWebManagerService>(); 39 services.AddSignalR(); 36 40 } 37 41 … … 39 43 public void Configure(IApplicationBuilder app) 40 44 { 45 41 46 if (hostingEnvironment.IsDevelopment()) 42 47 app.UseDeveloperExceptionPage(); 43 48 44 49 app.UseIISPlatformHandler(); 50 51 app.UseStaticFiles(); 52 app.UseSignalR(); 53 app.UseStatusCodePages(); 54 app.UseMvcWithDefaultRoute(); 55 } 45 56 46 app.UseMvcWithDefaultRoute(); 47 app.UseStaticFiles(); 48 app.UseStatusCodePages(); 49 } 57 50 58 51 59 // Entry point for the application. -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/ViewModels/JobViewModel.cs
r13656 r13689 10 10 public List<Job> userJobs { get; set; } 11 11 12 public List<LightweightTask> jobTasks { get; set; } 12 public List<LightweightTask> lightJobTasks { get; set; } 13 public List<Task> filledJobTasks { get; set; } 13 14 public Job selectedJob { get; set; } 14 15 public string message { get; set; } … … 17 18 userJobs = null; 18 19 selectedJob = null; 20 filledJobTasks = new List<Task>(); 19 21 message = ""; 20 22 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/ViewModels/UploadedJobViewModel.cs
r13656 r13689 1 using System; 1 using HeuristicLab.Optimization; 2 using System; 2 3 using System.Collections.Generic; 3 4 using System.Linq; … … 8 9 public class UploadedJobViewModel 9 10 { 10 public List<OptimizerHiveTask> Tasks { get; set; } 11 public UploadedJobViewModel() 12 { 13 FullDatePaths = new List<string>(); 14 DisplayDatePaths = new List<string>(); 15 FullFilesPaths = new List<string>(); 16 DisplayFilesPaths = new List<string>(); 17 SelectedIndex = -1; 18 } 19 20 public List<string> FullDatePaths { get; set; } 21 public List<string> DisplayDatePaths { get; set; } 22 public List<string> FullFilesPaths { get; set; } 23 public List<string> DisplayFilesPaths { get; set; } 24 public int SelectedIndex { get; set; } 25 public string message { get; set; } 26 27 11 28 } 12 29 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/Index.cshtml
r13656 r13689 12 12 </div> 13 13 <div class="row" style="margin:10px"> 14 <a class="btn btn- successbtn-lg btn-block"14 <a class="btn btn-info btn-lg btn-block" 15 15 asp-controller="Job" 16 asp-action="Upload ">17 Add job16 asp-action="Uploads"> 17 Uploads 18 18 </a> 19 19 </div> … … 46 46 <div class="col-sm-8" style="padding:5px; padding-left:10px;"> 47 47 <div class="row"> 48 <h2 style="padding-left:20px"> @Model.selectedJob.Name 49 <a asp-action="Delete" asp-route-id="@Model.selectedJob.Id" asp-controller="Job" style="margin-bottom:10px;" id="del" class='btn btn-danger'> 48 <h2 style="padding-left:20px"> 49 @Model.selectedJob.Name 50 <a onclick="popUpDelete()" 51 style="margin-bottom:10px;" 52 53 class='btn btn-danger'> 50 54 <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> 51 55 </a> 52 </h2> 56 <a style="display:none" 57 asp-action="Delete" 58 asp-route-id="@Model.selectedJob.Id" 59 asp-controller="Job" id="del" ></a> 60 61 <script type="text/javascript"> 62 function popUpDelete() { 63 if (confirm("Are you sure you want to delete this job?") == true) { 64 document.getElementById("del").click(); 65 } 66 67 } 68 </script> 69 70 </h2> 53 71 <div class="col-sm-6" style="padding-left:30px"> 54 72 <p>Description: @Model.selectedJob.Description</p> … … 59 77 </div> 60 78 <div class="col-sm-6" style="padding-left:30px"> 61 <p>Jobs: @Model.selectedJob.JobCount</p>62 79 <p>Calculating: @Model.selectedJob.CalculatingCount</p> 63 80 <p>Finished: @Model.selectedJob.FinishedCount</p> … … 66 83 </div> 67 84 <div class="row"> 68 <h3 style="padding-left:20px">@Model. jobTasks.Count Task@(Model.jobTasks != null && Model.jobTasks.Count != 1 ? "s" : "" )</h3>69 @foreach (var task in Model. jobTasks)85 <h3 style="padding-left:20px">@Model.lightJobTasks.Count Task@(Model.lightJobTasks != null && Model.lightJobTasks.Count != 1 ? "s" : "" )</h3> 86 @foreach (var task in Model.lightJobTasks) 70 87 { 71 <p style="padding-left:30px" > 72 Last update @task.LastTaskDataUpdate - @task.State - @task.ExecutionTime executed - created @task.DateCreated 73 </p> 88 <table class="table " 89 style="margin-left:20px;"> 90 <thead> 91 <tr> 92 <th>@task</th> 93 </tr> 94 </thead> 95 <tbody> 96 <tr> 97 <td>Last update @task.LastTaskDataUpdate</td> 98 <td>State: @task.State</td> 99 100 </tr> 101 <tr> 102 <td>@task.ExecutionTime executed</td> 103 <td>Created: @task.DateCreated</td> 104 </tr> 105 </tbody> 106 </table> 107 74 108 } 75 109 </div> -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Shared/_Layout.cshtml
r13656 r13689 20 20 </div> 21 21 </nav> 22 <environment names="Development"> 23 <script asp-src-include="~/js/*.js"></script> 24 </environment> 25 <environment names="Staging, Production"> 26 <script src="~/js/min/site.min.js"></script> 27 </environment> 22 23 <script src="~/js/jquery-2.1.1.js"></script> 24 <script src="~/js/bootstrap.js"></script> 25 26 <script src="~/js/jquery.signalr-2.1.2.js"></script> 27 <script src='~/signalr/js'></script> 28 <script src="~/js/morris.js"></script> 29 <script src="~/js/npm.js"></script> 30 <script src="~/js/raphael.js"></script> 28 31 @RenderBody() 29 32 </div> -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/project.json
r13656 r13689 10 10 11 11 "dependencies": { 12 "Microsoft.AspNet.Http.Abstractions": "1.0.0-rc1-final", 12 13 "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final", 13 14 "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", 14 15 "Microsoft.AspNet.Loader.IIS": "1.0.0-beta7", 15 16 "Microsoft.AspNet.Mvc": "6.0.0-rc1-final", 17 "Microsoft.AspNet.Owin": "1.0.0-rc1-final", 16 18 "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final", 17 19 "Microsoft.AspNet.Server.IIS": "1.0.0-beta7", 18 20 "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", 19 "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final" 21 "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final", 22 "Microsoft.AspNet.SignalR.Server": "3.0.0-rc1-final", 23 "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final", 24 "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final" 20 25 }, 21 26 … … 28 33 "dnx451": { 29 34 "dependencies": { 35 "ALGLIB-3.7.0": "1.0.0-*", 36 "AutoDiff-1.0": "1.0.0-*", 30 37 "HeuristicLab.Algorithms.ALPS-3.3": "1.0.0-*", 31 38 "HeuristicLab.Algorithms.Benchmarks-3.3": "1.0.0-*", … … 65 72 "HeuristicLab.Encodings.LinearLinkageEncoding-3.3": "1.0.0-*", 66 73 "HeuristicLab.Encodings.PermutationEncoding-3.3": "1.0.0-*", 74 "HeuristicLab.Encodings.PermutationEncoding.Views-3.3": "1.0.0-*", 67 75 "HeuristicLab.Encodings.RealVectorEncoding-3.3": "1.0.0-*", 68 76 "HeuristicLab.Encodings.ScheduleEncoding-3.3": "1.0.0-*", … … 122 130 "HeuristicLab.SequentialEngine-3.3": "1.0.0-*", 123 131 "HeuristicLab.Tracing-3.3": "1.0.0-*", 124 "ALGLIB-3.7.0": "1.0.0-*", 125 "AutoDiff-1.0": "1.0.0-*" 132 "HeuristicLab 3.3": "1.0.0-*" 126 133 }, 127 134 "frameworkAssemblies": { 135 "System.configuration": "4.0.0.0", 128 136 "System.Drawing": "4.0.0.0", 129 137 "System.IdentityModel": "4.0.0.0", 138 "System.Net.Http": "4.0.0.0", 139 "System.Runtime.Serialization": "4.0.0.0", 130 140 "System.ServiceModel": "4.0.0.0", 131 141 "System.Web": "4.0.0.0"
Note: See TracChangeset
for help on using the changeset viewer.