- Timestamp:
- 05/12/16 17:09:12 (9 years ago)
- Location:
- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/JobController.cs
r13841 r13847 30 30 private Guid userId; 31 31 32 32 33 private JobViewModel vm; 34 private UploadedJobViewModel upper; 33 35 private IHostingEnvironment _environment; 34 36 … … 38 40 { 39 41 weblog = WebLoginService.Instance; 40 vm = new JobViewModel();42 41 43 _environment = env; 42 44 } … … 48 50 { 49 51 var u = HttpContext.Session.GetString("UserId"); 52 50 53 if (u == null || u == "" || Guid.Parse(u) == Guid.Empty) 51 54 { … … 55 58 { 56 59 userId = Guid.Parse(u); 60 vm = new JobViewModel(weblog.getCurrentUser(userId)); 61 upper = new UploadedJobViewModel(weblog.getCurrentUser(userId)); 62 57 63 serviceLocator = weblog.getServiceLocator(userId); 58 64 serviceClient = serviceLocator.getHiveServiceClient(); 59 65 clientWeb = weblog.getClientWeb(userId); 66 60 67 return serviceLocator.CheckLogin(); 61 68 } … … 149 156 if (init()) 150 157 { 151 UploadedJobViewModel upper = new UploadedJobViewModel();152 158 fillUploadsPaths(upper, -1); 153 159 ViewBag.Name = serviceClient.ClientCredentials.UserName.UserName; … … 172 178 if (init()) 173 179 { 174 UploadedJobViewModel upper = new UploadedJobViewModel();175 180 fillUploadsPaths(upper, index); 176 181 if (index != -1) … … 188 193 } 189 194 } 195 [HttpPost] 196 public IActionResult changeDirName(string olddir, string dirname) 197 { 198 if (init()) 199 { 200 fillUploadsPaths(upper, -1); 201 var ind = upper.DisplayDatePaths.IndexOf(olddir); 202 try { 203 204 205 var start = Path.Combine(_environment.WebRootPath, "uploads", serviceClient.ClientCredentials.UserName.UserName, dirname); 206 if (Directory.Exists(start)) 207 { 208 var files = Directory.GetFiles(upper.FullDatePaths[ind]); 209 foreach(var f in files) { 210 var target = start + "\\" + f.Split('\\').Last(); 211 if (System.IO.File.Exists(target)) 212 System.IO.File.Delete(target); 213 System.IO.File.Move(f, target); 214 } 215 } 216 else 217 { 218 Directory.Move(upper.FullDatePaths[ind], start); 219 } 220 221 upper.clear(); 222 fillUploadsPaths(upper, -1); 223 ind = upper.DisplayDatePaths.IndexOf(dirname); 224 upper.clear(); 225 return RedirectToAction("UploadDir",new { index=ind}); 226 }catch(IOException e) 227 { 228 upper.clear(); 229 fillUploadsPaths(upper, ind); 230 upper.message = "Error in new directory name. Try again and don't use any special signs"; 231 ViewBag.Title = "Error renaming - "+ upper.DisplayDatePaths[ind] + " - Uploads"; 232 if (weblog.getFileOpener(userId).Job != null) 233 ViewBag.active = true; 234 return View("Uploads", upper); 235 } 236 } 237 else 238 { 239 return RedirectToAction("Index", "Home"); 240 } 241 } 190 242 /// <summary> 191 243 /// Loads all the paths from the selected uploads folder … … 195 247 private void fillUploadsPaths(UploadedJobViewModel vm, int index) 196 248 { 249 197 250 var tempdex = index; //Fix when maps gets deleted 198 251 var start = Path.Combine(_environment.WebRootPath, "uploads", serviceClient.ClientCredentials.UserName.UserName); 252 try 253 { 254 Directory.GetDirectories(start); 255 } 256 catch(DirectoryNotFoundException e) 257 { 258 Directory.CreateDirectory(start); 259 } 199 260 var dirs = Directory.GetDirectories(start); 200 261 foreach (string dir in dirs) … … 234 295 if (init()) 235 296 { 236 UploadedJobViewModel upper = new UploadedJobViewModel();237 297 fillUploadsPaths(upper, index); 238 298 System.IO.File.Delete(upper.FullFilesPaths[filedex]); 239 299 var message = upper.DisplayFilesPaths[filedex] + " has been deleted"; 240 300 241 upper = new UploadedJobViewModel( );301 upper = new UploadedJobViewModel(weblog.getCurrentUser(userId)); 242 302 fillUploadsPaths(upper, index); 243 303 upper.message = message; … … 264 324 if (init()) 265 325 { 266 UploadedJobViewModel upper = new UploadedJobViewModel();267 326 fillUploadsPaths(upper, index); 268 327 … … 270 329 serve.NewModel(); 271 330 serve.env = _environment; 272 331 serve.vm.directories = upper.DisplayDatePaths; 273 332 var ioptimizer = ContentManager.Load(upper.FullFilesPaths[filedex]); 274 333 … … 306 365 { 307 366 var serve = weblog.getFileOpener(userId); 367 fillUploadsPaths(upper, -1); 368 serve.vm.directories = upper.DisplayDatePaths; 308 369 ViewBag.JobsCount = serve.Job.Job.JobCount; 309 370 ViewBag.Title = serve.vm.SelectedTask.ItemTask.Name + " - Uploads"; … … 339 400 } 340 401 [HttpPost] 341 public IActionResult saveToFile(string fname) 342 { 343 if (init()) 344 { 345 weblog.getFileOpener(userId).SaveToFile(fname); 346 return RedirectToAction("Uploads", "Job"); 402 public IActionResult saveToFile(string fname, string dname) 403 { 404 if (init()) 405 { 406 weblog.getFileOpener(userId).SaveToFile(fname, dname); 407 fillUploadsPaths(upper, -1); 408 var ind = upper.DisplayDatePaths.IndexOf(dname); 409 return RedirectToAction("UploadDir", new { index = ind}); 347 410 } 348 411 else … … 356 419 if (init()) 357 420 { 358 UploadedJobViewModel upper = new UploadedJobViewModel();359 421 fillUploadsPaths(upper, index); 360 422 … … 385 447 if (init()) 386 448 { 387 UploadedJobViewModel upper = new UploadedJobViewModel();388 449 var uploads = Path.Combine(_environment.WebRootPath, "uploads", serviceClient.ClientCredentials.UserName.UserName, 389 450 directory); -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/ResourceController.cs
r13805 r13847 1 1 using HeuristicLab.Clients.Access; 2 2 using HeuristicLab.Clients.Access.Administration; 3 using HeuristicLab.Clients.Hive.WebJobManager.Models; 3 4 using HeuristicLab.Clients.Hive.WebJobManager.Services; 4 5 using Microsoft.AspNet.Hosting; … … 24 25 private HiveAdminClientWeb adminClient; 25 26 private Guid userId; 27 private HiveWebUser currentUser; 26 28 27 29 private IHostingEnvironment _environment; … … 49 51 adminClient = weblog.getAdminClient(userId); 50 52 accessClient = weblog.getAccessAdminClient(userId); 51 return serviceLocator.CheckLogin(); 52 53 currentUser = weblog.getCurrentUser(userId); 54 if (currentUser.hasResourceAdminAccess()) 55 return serviceLocator.CheckLogin(); 56 else 57 return false; 53 58 } 54 59 } … … 64 69 ViewBag.SessionId = HttpContext.Session.GetString("UserId"); 65 70 ViewBag.Title = "Resources"; 66 return View("Index" );67 } 68 else 69 { 70 return RedirectToAction("Index", " Home");71 return View("Index", currentUser); 72 } 73 else 74 { 75 return RedirectToAction("Index", "Job"); 71 76 } 72 77 } … … 116 121 else 117 122 { 118 return RedirectToAction("Index", " Home");123 return RedirectToAction("Index", "Job"); 119 124 } 120 125 } … … 164 169 else 165 170 { 166 return RedirectToAction("Index", " Home");171 return RedirectToAction("Index", "Job"); 167 172 } 168 173 } … … 195 200 else 196 201 { 197 return RedirectToAction("Index", " Home");202 return RedirectToAction("Index", "Job"); 198 203 } 199 204 } … … 237 242 else 238 243 { 239 return RedirectToAction("Index", " Home");244 return RedirectToAction("Index", "Job"); 240 245 } 241 246 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/UserController.cs
r13841 r13847 24 24 private Guid userId; 25 25 26 private UserViewModel vm; 26 27 private IHostingEnvironment _environment; 27 28 … … 47 48 serviceLocator = weblog.getServiceLocator(userId); 48 49 accessClient = weblog.getAccessAdminClient(userId); 49 return serviceLocator.CheckLogin(); 50 vm = new UserViewModel(accessClient, weblog.getCurrentUser(userId)); 51 if (weblog.getCurrentUser(userId).HasUserAdminAccess()) 52 return serviceLocator.CheckLogin(); 53 else 54 return false; 50 55 51 56 } … … 61 66 { 62 67 ViewBag.Title = "Users"; 63 UserViewModel vm = new UserViewModel(accessClient).refreshAll() ;68 vm.refreshAll() ; 64 69 //Refreshall for users, groups and roles 65 70 ViewBag.SessionId = HttpContext.Session.GetString("UserId"); … … 68 73 else 69 74 { 70 return RedirectToAction("Index", " Home");75 return RedirectToAction("Index", "Job"); 71 76 } 72 77 } … … 78 83 Guid curr = Guid.Parse(id); 79 84 80 UserViewModel vm = new UserViewModel(accessClient).refreshAll();85 vm.refreshAll(); 81 86 if (curr == Guid.Empty) 82 87 {//new user … … 97 102 else 98 103 { 99 return RedirectToAction("Index", " Home");104 return RedirectToAction("Index", "Job"); 100 105 } 101 106 } … … 162 167 else 163 168 { 164 return RedirectToAction("Index", " Home");169 return RedirectToAction("Index", "Job"); 165 170 } 166 171 … … 199 204 Guid curr = Guid.Parse(id); 200 205 201 UserViewModel vm = new UserViewModel(accessClient).refreshAll();206 vm.refreshAll(); 202 207 203 208 var us = vm.getUserById(curr); … … 209 214 else 210 215 { 211 return RedirectToAction("Index", " Home");216 return RedirectToAction("Index", "Job"); 212 217 } 213 218 } … … 222 227 { 223 228 var uid = Guid.Parse(id); 224 UserViewModel vm = new UserViewModel(accessClient).refreshUsers();229 vm.refreshUsers(); 225 230 226 231 if (uid == Guid.Empty) … … 241 246 else 242 247 { 243 return RedirectToAction("Index", " Home");248 return RedirectToAction("Index", "Job"); 244 249 } 245 250 … … 256 261 { 257 262 var uid = Guid.Parse(id); 258 UserViewModel vm = new UserViewModel(accessClient).refreshAll();263 vm.refreshAll(); 259 264 260 265 var user = vm.getUserById(uid); … … 266 271 else 267 272 { 268 return RedirectToAction("Index", " Home");273 return RedirectToAction("Index", "Job"); 269 274 } 270 275 } … … 281 286 var gid = Guid.Parse(group); 282 287 var mid = Guid.Parse(id); 283 UserViewModel vm = new UserViewModel(accessClient).refreshGroups().refreshUsers();288 vm.refreshGroups().refreshUsers(); 284 289 285 290 var user = vm.getUserById(mid); … … 291 296 else 292 297 { 293 return RedirectToAction("Index", " Home");298 return RedirectToAction("Index", "Job"); 294 299 } 295 300 … … 308 313 309 314 ViewBag.Title = "Groups"; 310 UserViewModel vm = new UserViewModel(accessClient).refreshGroups().refreshUsers();315 vm.refreshGroups().refreshUsers(); 311 316 return View("Groups", vm); 312 317 } 313 318 else 314 319 { 315 return RedirectToAction("Index", " Home");320 return RedirectToAction("Index", "Job"); 316 321 } 317 322 } … … 327 332 Guid curr = Guid.Parse(id); 328 333 329 UserViewModel vm = new UserViewModel(accessClient)334 vm 330 335 .refreshGroups() 331 336 .refreshUsers(); … … 345 350 else 346 351 { 347 return RedirectToAction("Index", " Home");352 return RedirectToAction("Index", "Job"); 348 353 } 349 354 } … … 362 367 { 363 368 var uid = Guid.Parse(u); 364 v ar vm = new UserViewModel(accessClient).refreshGroups().refreshUsers();369 vm.refreshGroups().refreshUsers(); 365 370 366 371 Access.UserGroup group; … … 403 408 else 404 409 { 405 return RedirectToAction("Index", " Home");410 return RedirectToAction("Index", "Job"); 406 411 } 407 412 } … … 416 421 { 417 422 var uid = Guid.Parse(id); 418 UserViewModel vm = new UserViewModel(accessClient).refreshGroups();423 vm.refreshGroups(); 419 424 420 425 if (uid == Guid.Empty) … … 434 439 else 435 440 { 436 return RedirectToAction("Index", " Home");441 return RedirectToAction("Index", "Job"); 437 442 } 438 443 … … 450 455 var gid = Guid.Parse(g); 451 456 var mid = Guid.Parse(m); 452 UserViewModel vm = new UserViewModel(accessClient).refreshGroups().refreshUsers();457 vm.refreshGroups().refreshUsers(); 453 458 454 459 if (gid == Guid.Empty || mid == Guid.Empty) … … 473 478 else 474 479 { 475 return RedirectToAction("Index", " Home");480 return RedirectToAction("Index", "Job"); 476 481 } 477 482 … … 490 495 491 496 ViewBag.Title = "Roles"; 492 UserViewModel vm = new UserViewModel(accessClient).refreshRoles();497 vm.refreshRoles(); 493 498 494 499 return View("Roles", vm); … … 496 501 else 497 502 { 498 return RedirectToAction("Index", " Home");503 return RedirectToAction("Index", "Job"); 499 504 } 500 505 } … … 509 514 { 510 515 511 UserViewModel vm = new UserViewModel(accessClient).refreshRoles();516 vm.refreshRoles(); 512 517 if (name == "" || name == null) 513 518 {//Add role … … 526 531 else 527 532 { 528 return RedirectToAction("Index", " Home");533 return RedirectToAction("Index", "Job"); 529 534 } 530 535 } … … 552 557 else 553 558 { 554 return RedirectToAction("Index", " Home");559 return RedirectToAction("Index", "Job"); 555 560 } 556 561 } … … 569 574 else 570 575 { 571 return RedirectToAction("Index", " Home");576 return RedirectToAction("Index", "Job"); 572 577 } 573 578 } … … 583 588 { 584 589 var uid = Guid.Parse(id); 585 UserViewModel vm = new UserViewModel(accessClient).refreshAll();590 vm.refreshAll(); 586 591 587 592 var user = vm.getUserById(uid); … … 593 598 else 594 599 { 595 return RedirectToAction("Index", " Home");600 return RedirectToAction("Index", "Job"); 596 601 } 597 602 }
Note: See TracChangeset
for help on using the changeset viewer.