- Timestamp:
- 03/24/16 17:19:13 (9 years ago)
- Location:
- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/HomeController.cs
r13689 r13733 8 8 namespace HeuristicLab.Clients.Hive.WebJobManager.Controllers 9 9 { 10 /// <summary> 11 /// Controller for initial landing page 12 /// </summary> 10 13 public class HomeController : Controller 11 14 { 12 private ILoginViewModelService loginViewModelService;15 private LoginViewModelService loginViewModelService; 13 16 private HiveServiceClient client; 14 17 public HomeController(ILoginViewModelService loginViewModelService) 15 18 { 16 this.loginViewModelService = loginViewModelService;19 this.loginViewModelService = (LoginViewModelService)loginViewModelService; 17 20 } 21 #region Login 22 /// <summary> 23 /// Opens initial home page 24 /// </summary> 25 /// <returns>View from home page</returns> 18 26 public IActionResult Index() 19 27 { 20 28 ViewBag.Title = "Login"; 29 loginViewModelService.clear(); 21 30 return View(loginViewModelService.GetLoginViewModel()); 22 31 } 23 public IActionResult Login(string loginName, string password) 32 /// <summary> 33 /// Checks login 34 /// </summary> 35 /// <param name="loginName">Login name</param> 36 /// <param name="password">Login password</param> 37 /// <returns>Logged in view if correct or shows error</returns> 38 public IActionResult Login(string loginName, string password)//Checks login 24 39 { 25 40 if (!string.IsNullOrEmpty(loginName) && !string.IsNullOrEmpty(password)) 26 41 { 27 42 var model = loginViewModelService.GetLoginViewModel(); 28 HiveServiceLocatorWeb ManagerService hiveServiceLocator = (HiveServiceLocatorWebManagerService)HiveServiceLocatorWebManagerService.Instance;43 HiveServiceLocatorWeb hiveServiceLocator = (HiveServiceLocatorWeb)HiveServiceLocatorWeb.Instance; 29 44 HeuristicLab.Clients.Common.Properties.Settings.Default.UserName = loginName; 30 45 HeuristicLab.Clients.Common.Properties.Settings.Default.Password = Common.CryptoService.EncryptString(password); … … 37 52 var test = client.GetJobs();//Throws messageSecurityException if login failss 38 53 ViewBag.Title = "Login succesful"; 39 return View("LoginHome"); 54 55 return RedirectToAction("Index","Job"); 40 56 } 41 57 catch(MessageSecurityException e) … … 55 71 } 56 72 } 73 public IActionResult Logout() 74 { 75 return RedirectToAction("Index","Home"); 76 } 77 #endregion 57 78 } 58 79 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/JobController.cs
r13714 r13733 18 18 namespace HeuristicLab.Clients.Hive.WebJobManager.Controllers 19 19 { 20 /// <summary> 21 /// Controller for everything Job related (includes uploads and uploader) 22 /// </summary> 20 23 public class JobController : Controller 21 24 { … … 26 29 public JobController(IHostingEnvironment env) 27 30 { 28 HiveServiceLocatorWeb ManagerService hiveServiceLocator = (HiveServiceLocatorWebManagerService)HiveServiceLocatorWebManagerService.Instance;31 HiveServiceLocatorWeb hiveServiceLocator = (HiveServiceLocatorWeb)HiveServiceLocatorWeb.Instance; 29 32 client = hiveServiceLocator.getHiveServiceClient(); 30 33 vm = new JobViewModel(); … … 34 37 } 35 38 #region Jobs 39 /// <summary> 40 /// initial job page, shows all jobs 41 /// </summary> 42 /// <returns></returns> 36 43 public IActionResult Index() 37 44 { … … 46 53 if (e is MessageSecurityException || e is InvalidOperationException) 47 54 { 48 HiveServiceLocatorWeb ManagerService.SetLoginErrorMessage();55 HiveServiceLocatorWeb.SetLoginErrorMessage(); 49 56 return RedirectToAction("Index", "Home"); 50 57 } … … 54 61 return View(vm); 55 62 } 63 /// <summary> 64 /// Initial page and a selected job 65 /// </summary> 66 /// <param name="id">Job id selected</param> 67 /// <returns></returns> 56 68 public IActionResult Selected(Guid id) 57 69 { 58 if (((HiveServiceLocatorWeb ManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin())70 if (((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).CheckLogin()) 59 71 { 60 72 HiveClientWeb.Instance.Refresh(); … … 77 89 else 78 90 { 79 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 80 return RedirectToAction("Index", "Home"); 81 } 82 } 83 public IActionResult Delete(Guid id)// delete a job 84 { 85 if (((HiveServiceLocatorWebManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin()) 91 HiveServiceLocatorWeb.SetLoginErrorMessage(); 92 return RedirectToAction("Index", "Home"); 93 } 94 } 95 /// <summary> 96 /// Deletes a job 97 /// </summary> 98 /// <param name="id">Job id</param> 99 /// <returns></returns> 100 public IActionResult Delete(Guid id) 101 { 102 if (((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).CheckLogin()) 86 103 { 87 104 … … 96 113 else 97 114 { 98 HiveServiceLocatorWeb ManagerService.SetLoginErrorMessage();115 HiveServiceLocatorWeb.SetLoginErrorMessage(); 99 116 return RedirectToAction("Index", "Home"); 100 117 } … … 103 120 104 121 #region Uploads 122 /// <summary> 123 /// Shows the uploaded directories 124 /// </summary> 125 /// <returns></returns> 105 126 public IActionResult Uploads() 106 127 { 107 if (((HiveServiceLocatorWeb ManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin())128 if (((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).CheckLogin()) 108 129 { 109 130 UploadedJobViewModel upper = new UploadedJobViewModel(); 110 131 fillUploadsPaths(upper, -1); 111 132 ViewBag.Name = client.ClientCredentials.UserName.UserName; 112 133 ViewBag.Title = "Uploaded files"; 113 134 return View("Uploads", upper); … … 115 136 else 116 137 { 117 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 118 return RedirectToAction("Index", "Home"); 119 } 120 } 138 HiveServiceLocatorWeb.SetLoginErrorMessage(); 139 return RedirectToAction("Index", "Home"); 140 } 141 } 142 /// <summary> 143 /// //Shows content of selected dir 144 /// </summary> 145 /// <param name="index">Array index selected directory</param> 146 /// <returns></returns> 121 147 public IActionResult UploadDir(int index) 122 148 { 123 if (((HiveServiceLocatorWeb ManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin())149 if (((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).CheckLogin()) 124 150 { 125 151 UploadedJobViewModel upper = new UploadedJobViewModel(); … … 131 157 else 132 158 { 133 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 134 return RedirectToAction("Index", "Home"); 135 } 136 } 159 HiveServiceLocatorWeb.SetLoginErrorMessage(); 160 return RedirectToAction("Index", "Home"); 161 } 162 } 163 /// <summary> 164 /// Loads all the paths from the selected uploads folder 165 /// </summary> 166 /// <param name="vm">Viewmodel to save every directory path</param> 167 /// <param name="index">Index selected directory</param> 137 168 private void fillUploadsPaths(UploadedJobViewModel vm, int index) 169 138 170 { 139 171 var tempdex = index; //Fix when maps gets deleted … … 165 197 } 166 198 } 199 /// <summary> 200 /// Deletes a file 201 /// </summary> 202 /// <param name="index">Index directory</param> 203 /// <param name="filedex">Index file to delete</param> 204 /// <returns></returns> 167 205 public IActionResult DeleteFile(int index, int filedex) 168 206 { 169 if (((HiveServiceLocatorWeb ManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin())207 if (((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).CheckLogin()) 170 208 { 171 209 UploadedJobViewModel upper = new UploadedJobViewModel(); … … 183 221 else 184 222 { 185 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 186 return RedirectToAction("Index", "Home"); 187 } 188 } 189 223 HiveServiceLocatorWeb.SetLoginErrorMessage(); 224 return RedirectToAction("Index", "Home"); 225 } 226 } 227 /// <summary> 228 /// Opens a selected file 229 /// </summary> 230 /// <param name="index">Index directory</param> 231 /// <param name="filedex">Index selected file</param> 232 /// <returns></returns> 190 233 public IActionResult OpenFile(int index, int filedex) 191 234 { 192 if (((HiveServiceLocatorWeb ManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin())235 if (((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).CheckLogin()) 193 236 { 194 237 UploadedJobViewModel upper = new UploadedJobViewModel(); … … 221 264 else 222 265 { 223 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 224 return RedirectToAction("Index", "Home"); 225 } 226 } 227 266 HiveServiceLocatorWeb.SetLoginErrorMessage(); 267 return RedirectToAction("Index", "Home"); 268 } 269 } 270 /// <summary> 271 /// Adds current opened file to hive, uses FileOpeningService singleton 272 /// </summary> 273 /// <returns></returns> 228 274 public IActionResult AddToHive() 229 275 { 230 if (((HiveServiceLocatorWeb ManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin())276 if (((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).CheckLogin()) 231 277 { 232 278 var job = FileOpeningService.Instance.AddCurrentModelToHive(); … … 241 287 else 242 288 { 243 HiveServiceLocatorWeb ManagerService.SetLoginErrorMessage();289 HiveServiceLocatorWeb.SetLoginErrorMessage(); 244 290 return RedirectToAction("Index", "Home"); 245 291 } … … 248 294 /* public async Task<IActionResult> DownloadFile(int index, int filedex) 249 295 { 250 if (((HiveServiceLocatorWeb ManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin())296 if (((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).CheckLogin()) 251 297 { 252 298 UploadedJobViewModel upper = new UploadedJobViewModel(); … … 269 315 else 270 316 { 271 HiveServiceLocatorWeb ManagerService.SetLoginErrorMessage();317 HiveServiceLocatorWeb.SetLoginErrorMessage(); 272 318 return RedirectToAction("Index", "Home"); 273 319 } … … 277 323 278 324 #region Uploader 279 public IActionResult Uploader() 280 { 281 if (((HiveServiceLocatorWebManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin()) 282 { 283 ViewBag.Title = "Upload Jobs"; 284 ViewBag.Name = client.ClientCredentials.UserName.UserName; 285 return View("Uploader"); 286 } 287 else 288 { 289 HiveServiceLocatorWebManagerService.SetLoginErrorMessage(); 290 return RedirectToAction("Index", "Home"); 291 } 292 } 325 326 /// <summary> 327 /// Uploads file onto server directory 328 /// </summary> 329 /// <param name="files">Files</param> 330 /// <param name="directory">Directory path for server</param> 331 /// <returns></returns> 293 332 [HttpPost] 294 333 public async Task<IActionResult> Uploader(ICollection<IFormFile> files, string directory) -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/ResourceController.cs
r13689 r13733 17 17 public ResourceController(IHostingEnvironment env) 18 18 { 19 HiveServiceLocatorWeb ManagerService hiveServiceLocator = (HiveServiceLocatorWebManagerService)HiveServiceLocatorWebManagerService.Instance;19 HiveServiceLocatorWeb hiveServiceLocator = (HiveServiceLocatorWeb)HiveServiceLocatorWeb.Instance; 20 20 client = hiveServiceLocator.getHiveServiceClient(); 21 21 … … 24 24 public IActionResult Index() 25 25 { 26 if (((HiveServiceLocatorWeb ManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin())26 if (((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).CheckLogin()) 27 27 { 28 28 … … 32 32 else 33 33 { 34 HiveServiceLocatorWeb ManagerService.SetLoginErrorMessage();34 HiveServiceLocatorWeb.SetLoginErrorMessage(); 35 35 return RedirectToAction("Index", "Home"); 36 36 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/UserController.cs
r13689 r13733 17 17 public UserController(IHostingEnvironment env) 18 18 { 19 HiveServiceLocatorWeb ManagerService hiveServiceLocator = (HiveServiceLocatorWebManagerService)HiveServiceLocatorWebManagerService.Instance;19 HiveServiceLocatorWeb hiveServiceLocator = (HiveServiceLocatorWeb)HiveServiceLocatorWeb.Instance; 20 20 client = hiveServiceLocator.getHiveServiceClient(); 21 21 … … 24 24 public IActionResult Index() 25 25 { 26 if (((HiveServiceLocatorWeb ManagerService)(HiveServiceLocatorWebManagerService.Instance)).CheckLogin())26 if (((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).CheckLogin()) 27 27 { 28 28 … … 32 32 else 33 33 { 34 HiveServiceLocatorWeb ManagerService.SetLoginErrorMessage();34 HiveServiceLocatorWeb.SetLoginErrorMessage(); 35 35 return RedirectToAction("Index", "Home"); 36 36 }
Note: See TracChangeset
for help on using the changeset viewer.