Changeset 13754
- Timestamp:
- 04/12/16 15:28:19 (9 years ago)
- Location:
- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager
- Files:
-
- 35 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/JobController.cs
r13740 r13754 45 45 /// initializes the connection for the right user. Not constructor because httpcontext is needed. 46 46 /// </summary> 47 private voidinit()47 private bool init() 48 48 { 49 49 var u = HttpContext.Session.GetString("UserId"); 50 50 if (u == null || u == "" || Guid.Parse(u) == Guid.Empty) 51 51 { 52 userId = Guid.Empty; 53 serviceLocator = new HiveServiceLocatorWeb(); 54 serviceClient = serviceLocator.getHiveServiceClient(); 55 clientWeb = new HiveClientWeb(serviceLocator, userId); 52 return false; 56 53 } 57 54 else … … 61 58 serviceClient = serviceLocator.getHiveServiceClient(); 62 59 clientWeb = weblog.getClientWeb(userId); 60 return serviceLocator.CheckLogin(); 63 61 } 64 62 } … … 71 69 public IActionResult Index() 72 70 { 73 try 74 { 75 init(); 71 if (init()) 72 { 76 73 clientWeb.Refresh(); 77 74 vm.userJobs = clientWeb.Jobs.ToList(); 78 } 79 catch (Exception e) 80 { 81 if (e is MessageSecurityException || e is InvalidOperationException) 82 { 83 return RedirectToAction("Index", "Home"); 84 } 85 throw; 86 } 87 ViewBag.SessionId = HttpContext.Session.GetString("UserId"); 88 ViewBag.Title = "Jobs"; 89 return View(vm); 75 76 ViewBag.SessionId = HttpContext.Session.GetString("UserId"); 77 ViewBag.Title = "Jobs"; 78 return View(vm); 79 } 80 else 81 { 82 return RedirectToAction("Index", "Home"); 83 } 90 84 } 91 85 /// <summary> … … 96 90 public IActionResult Selected(Guid id) 97 91 { 98 init(); 99 if (serviceLocator.CheckLogin()) 92 if (init()) 100 93 { 101 94 clientWeb.Refresh(); … … 129 122 public IActionResult Delete(Guid id) 130 123 { 131 init(); 132 if (serviceLocator.CheckLogin()) 124 if (init()) 133 125 { 134 126 … … 155 147 public IActionResult Uploads() 156 148 { 157 init(); 158 if (serviceLocator.CheckLogin()) 149 if (init()) 159 150 { 160 151 UploadedJobViewModel upper = new UploadedJobViewModel(); … … 176 167 public IActionResult UploadDir(int index) 177 168 { 178 init(); 179 if (serviceLocator.CheckLogin()) 169 if (init()) 180 170 { 181 171 UploadedJobViewModel upper = new UploadedJobViewModel(); 182 172 fillUploadsPaths(upper, index); 183 if (index != -1)173 if (index != -1) 184 174 ViewBag.Title = upper.DisplayDatePaths[index] + " - Uploads"; 185 175 else … … 209 199 tempdex = -1; 210 200 } 211 else { 201 else 202 { 212 203 vm.FullDatePaths.Add(dir); 213 204 var temp = dir.Split('\\'); … … 235 226 public IActionResult DeleteFile(int index, int filedex) 236 227 { 237 init(); 238 if (serviceLocator.CheckLogin()) 228 if (init()) 239 229 { 240 230 UploadedJobViewModel upper = new UploadedJobViewModel(); … … 263 253 public IActionResult OpenFile(int index, int filedex) 264 254 { 265 init(); 266 if (serviceLocator.CheckLogin()) 255 if (init()) 267 256 { 268 257 UploadedJobViewModel upper = new UploadedJobViewModel(); … … 305 294 public IActionResult AddToHive() 306 295 { 307 init(); 308 if (serviceLocator.CheckLogin()) 296 if (init()) 309 297 { 310 298 var job = weblog.getFileOpener(userId).AddCurrentModelToHive(); … … 364 352 public async Task<IActionResult> Uploader(ICollection<IFormFile> files, string directory) 365 353 { 366 init(); 367 UploadedJobViewModel upper = new UploadedJobViewModel(); 368 var uploads = Path.Combine(_environment.WebRootPath, "uploads", serviceClient.ClientCredentials.UserName.UserName, 369 directory); 370 Directory.CreateDirectory(uploads); 371 foreach (var file in files) 372 { 373 if (file.Length > 0) 374 { 375 var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); 376 await file.SaveAsAsync(Path.Combine(uploads, fileName)); 377 // var ioptimizer = ContentManager.Load(Path.Combine(uploads, fileName)); 378 //OptimizerHiveTask task = new OptimizerHiveTask((IOptimizer)ioptimizer); 379 //upper.Tasks.Add(task); 380 } 381 } 382 ViewBag.Title = "Upload complete - Uploads"; 383 return RedirectToAction("Uploads", "Job"); 384 354 if (init()) 355 { 356 UploadedJobViewModel upper = new UploadedJobViewModel(); 357 var uploads = Path.Combine(_environment.WebRootPath, "uploads", serviceClient.ClientCredentials.UserName.UserName, 358 directory); 359 Directory.CreateDirectory(uploads); 360 foreach (var file in files) 361 { 362 if (file.Length > 0) 363 { 364 var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); 365 await file.SaveAsAsync(Path.Combine(uploads, fileName)); 366 // var ioptimizer = ContentManager.Load(Path.Combine(uploads, fileName)); 367 //OptimizerHiveTask task = new OptimizerHiveTask((IOptimizer)ioptimizer); 368 //upper.Tasks.Add(task); 369 } 370 } 371 ViewBag.Title = "Upload complete - Uploads"; 372 return RedirectToAction("Uploads", "Job"); 373 } 374 else 375 { 376 return RedirectToAction("Index", "Home"); 377 } 385 378 } 386 379 #endregion -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/ResourceController.cs
r13740 r13754 1 using HeuristicLab.Clients.Hive.WebJobManager.Services; 1 using HeuristicLab.Clients.Access.Administration; 2 using HeuristicLab.Clients.Hive.WebJobManager.Services; 2 3 using Microsoft.AspNet.Hosting; 3 4 using Microsoft.AspNet.Http; … … 15 16 private WebLoginService weblog; 16 17 private HiveServiceLocatorWeb serviceLocator; 17 private HiveServiceClient serviceClient; 18 private HiveClientWeb clientWeb; 18 private AccessAdministrationClient accessClient; 19 19 private Guid userId; 20 20 … … 26 26 _environment = env; 27 27 } 28 private voidinit()28 private bool init() 29 29 { 30 30 var u = HttpContext.Session.GetString("UserId"); 31 31 if (u == null || u == "" || Guid.Parse(u) == Guid.Empty) 32 32 { 33 userId = Guid.Empty; 34 serviceLocator = new HiveServiceLocatorWeb(); 35 serviceClient = serviceLocator.getHiveServiceClient(); 36 clientWeb = new HiveClientWeb(serviceLocator, userId); 33 return false; 37 34 } 38 35 else … … 40 37 userId = Guid.Parse(u); 41 38 serviceLocator = weblog.getServiceLocator(userId); 42 serviceClient = serviceLocator.getHiveServiceClient(); 43 clientWeb = weblog.getClientWeb(userId); 39 accessClient = weblog.getAccessAdminClient(userId); 40 return serviceLocator.CheckLogin(); 41 44 42 } 45 43 } 46 44 public IActionResult Index() 47 45 { 48 init();49 if ( serviceLocator.CheckLogin())46 47 if (init()) 50 48 { 51 49 ViewBag.SessionId = HttpContext.Session.GetString("UserId"); 52 50 ViewBag.Title = "Resources"; 53 51 return View("Index"); -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/UserController.cs
r13742 r13754 27 27 _environment = env; 28 28 } 29 private voidinit()29 private bool init() 30 30 { 31 31 var u = HttpContext.Session.GetString("UserId"); 32 32 if (u == null || u == "" || Guid.Parse(u) == Guid.Empty) 33 33 { 34 userId = Guid.Empty; 35 serviceLocator = new HiveServiceLocatorWeb(); 34 return false; 36 35 } 37 36 else … … 40 39 serviceLocator = weblog.getServiceLocator(userId); 41 40 accessClient = weblog.getAccessAdminClient(userId); 41 return serviceLocator.CheckLogin(); 42 42 43 } 43 44 } … … 46 47 public IActionResult Index() 47 48 { 48 init(); 49 if (serviceLocator.CheckLogin()) 50 { 51 49 if (init()) 50 { 52 51 ViewBag.Title = "Users"; 53 UserViewModel vm = new UserViewModel(accessClient).refresh Users();52 UserViewModel vm = new UserViewModel(accessClient).refreshAll() ; 54 53 ViewBag.SessionId = HttpContext.Session.GetString("UserId"); 55 54 return View("Index", vm); … … 63 62 public IActionResult SelectUser(string id) 64 63 { 65 init();66 if ( serviceLocator.CheckLogin())64 ; 65 if (init()) 67 66 { 68 67 Guid curr = Guid.Parse(id); 69 70 UserViewModel vm = new UserViewModel(accessClient).refresh Users();68 69 UserViewModel vm = new UserViewModel(accessClient).refreshAll(); 71 70 if (curr == Guid.Empty) 72 71 { … … 77 76 vm.SelectedUser = vm.getUserById(curr); 78 77 vm.SelectedUserSubscriptions = accessClient.getSubscribedGroups(curr); 78 vm.SelectedUserRoles = accessClient.getRoles(vm.SelectedUser); 79 79 ViewBag.title = vm.SelectedUser.UserName; 80 80 } … … 89 89 } 90 90 [HttpPost] 91 public IActionResult saveUser(string inpusername, string inpfullname, string inpemail, string u) 92 { 93 init(); 94 var uid = Guid.Parse(u); 95 Access.User user; 96 if (uid == Guid.Empty) 97 user = new Access.User(); 98 else 91 public IActionResult saveUser(string inpusername, string inpfullname, string inpemail, string u, string[] rolestoadd, string[] groupstoadd) 92 { 93 94 if (init()) 95 { 96 var uid = Guid.Parse(u); 97 Access.User user; 98 if (uid == Guid.Empty) 99 user = new Access.User(); 100 else 101 user = accessClient.Users.Find(x => x.Id == uid); 102 103 104 user.FullName = inpfullname; 105 user.Email = inpemail; 106 107 108 if (uid == Guid.Empty) 109 { 110 user.UserName = inpusername; 111 uid = accessClient.addUser(user); 112 ViewBag.Title = user.UserName + " added - User"; 113 } 114 else 115 { 116 accessClient.updateUser(user); 117 ViewBag.Title = user.UserName + " updated - User"; 118 } 119 accessClient.RefreshUsers(); 99 120 user = accessClient.Users.Find(x => x.Id == uid); 100 101 102 user.FullName = inpfullname;103 user.Email = inpemail; 104 105 106 if (uid == Guid.Empty)107 {108 user.UserName = inpusername;109 uid = accessClient.addUser(user);110 ViewBag.Title = user.UserName + " added - User";111 }112 else113 {114 accessClient.updateUser(user);115 ViewBag.Title = user.UserName + " updated - User";116 }117 118 return RedirectToAction( "SelectUser", new { id = uid.ToString()});121 foreach (var s in rolestoadd) 122 { 123 var role = accessClient.Roles.Find(x => x.Name == s); 124 125 accessClient.addRoleToUser(user, role); 126 } 127 accessClient.RefreshUserGroups(); 128 foreach(var g in groupstoadd) 129 { 130 var gid = Guid.Parse(g); 131 var group = accessClient.Groups.Find(x => x.Id == gid); 132 accessClient.addMember(user, group); 133 } 134 return RedirectToAction("SelectUser", new { id = uid.ToString() }); 135 } 136 else 137 { 138 return RedirectToAction("Index", "Home"); 139 } 119 140 120 141 } 121 142 public IActionResult deleteUser(string id) 122 143 { 123 init(); 124 var uid = Guid.Parse(id); 125 UserViewModel vm = new UserViewModel(accessClient).refreshUsers(); 126 127 if (uid == Guid.Empty) 128 { 129 vm.message = "Something went wrong, user is not deleted"; 130 return View("Index", vm); 131 } 132 else 133 { 144 if (init()) 145 { 146 var uid = Guid.Parse(id); 147 UserViewModel vm = new UserViewModel(accessClient).refreshUsers(); 148 149 if (uid == Guid.Empty) 150 { 151 vm.message = "Something went wrong, user is not deleted"; 152 return View("Index", vm); 153 } 154 else 155 { 156 var user = vm.getUserById(uid); 157 vm.message = user.UserName + " (" + user.FullName + ") has been deleted"; 158 accessClient.DeleteUser(user); 159 vm.refreshAll(); 160 ViewBag.Title = "Users"; 161 return View("Index", vm); 162 } 163 } 164 else 165 { 166 return RedirectToAction("Index", "Home"); 167 } 168 169 } 170 171 public IActionResult deleteUserRole(string id, string role) 172 { 173 if (init()) 174 { 175 var uid = Guid.Parse(id); 176 UserViewModel vm = new UserViewModel(accessClient).refreshAll(); 177 134 178 var user = vm.getUserById(uid); 135 vm.message = user.UserName + " ("+user.FullName+") has been deleted"; 136 accessClient.DeleteUser(user); 137 vm.refreshUsers(); 138 return View("Index", vm); 139 } 140 141 } 142 179 var r = vm.getRoleByName(role); 180 accessClient.deleteUserRole(user, r); 181 return RedirectToAction("SelectUser", new { id = id }); 182 } 183 else 184 { 185 return RedirectToAction("Index", "Home"); 186 } 187 } 188 public IActionResult deleteUserGroup(string id, string group) 189 { 190 if (init()) 191 { 192 var gid = Guid.Parse(group); 193 var mid = Guid.Parse(id); 194 UserViewModel vm = new UserViewModel(accessClient).refreshGroups().refreshUsers(); 195 196 var user = vm.getUserById(mid); 197 var gr = vm.getGroupById(gid); 198 accessClient.deleteMember(user, gr); 199 return RedirectToAction("SelectUser", new { id = id}); 200 } 201 else 202 { 203 return RedirectToAction("Index", "Home"); 204 } 205 206 } 143 207 #endregion 144 208 … … 146 210 public IActionResult Groups() 147 211 { 148 init(); 149 if (serviceLocator.CheckLogin()) 212 if (init()) 150 213 { 151 214 … … 161 224 public IActionResult SelectGroup(string id) 162 225 { 163 init(); 164 if (serviceLocator.CheckLogin()) 226 if (init()) 165 227 { 166 228 Guid curr = Guid.Parse(id); … … 190 252 public IActionResult saveGroup(string inpgroupname, string u, string[] userstoadd, string[] groupstoadd) 191 253 { 192 init(); 193 var uid = Guid.Parse(u); 194 var vm = new UserViewModel(accessClient).refreshGroups().refreshUsers(); 195 196 Access.UserGroup group; 197 198 if (uid == Guid.Empty) 199 group = new Access.UserGroup(); 200 else 201 group = accessClient.Groups.Find(x => x.Id == uid); 202 203 group.Name = inpgroupname; 204 205 if (uid == Guid.Empty) 206 { 207 uid = accessClient.addGroup(group); 208 ViewBag.Title = group.Name + " added - Group"; 209 } 210 else 211 { 212 accessClient.updateGroup(group); 213 ViewBag.Title = group.Name + " updated - Group"; 214 } 215 vm.refreshGroups(); 216 group = vm.getGroupById(uid); 217 foreach(var s in userstoadd) 218 { 219 var tempid = Guid.Parse(s); 220 var member = vm.getUserById(tempid); 221 accessClient.addMember(member, group); 222 } 223 foreach (var g in groupstoadd) 224 { 225 var tempid = Guid.Parse(g); 226 var member = vm.getGroupById(tempid); 227 accessClient.addMember(member, group); 228 } 229 230 return RedirectToAction("SelectGroup", new { id = uid.ToString() }); 231 254 if (init()) 255 { 256 var uid = Guid.Parse(u); 257 var vm = new UserViewModel(accessClient).refreshGroups().refreshUsers(); 258 259 Access.UserGroup group; 260 261 if (uid == Guid.Empty) 262 group = new Access.UserGroup(); 263 else 264 group = accessClient.Groups.Find(x => x.Id == uid); 265 266 group.Name = inpgroupname; 267 268 if (uid == Guid.Empty) 269 { 270 uid = accessClient.addGroup(group); 271 ViewBag.Title = group.Name + " added - Group"; 272 } 273 else 274 { 275 accessClient.updateGroup(group); 276 ViewBag.Title = group.Name + " updated - Group"; 277 } 278 vm.refreshGroups(); 279 group = vm.getGroupById(uid); 280 foreach (var s in userstoadd) 281 { 282 var tempid = Guid.Parse(s); 283 var member = vm.getUserById(tempid); 284 accessClient.addMember(member, group); 285 } 286 foreach (var g in groupstoadd) 287 { 288 var tempid = Guid.Parse(g); 289 var member = vm.getGroupById(tempid); 290 accessClient.addMember(member, group); 291 } 292 293 return RedirectToAction("SelectGroup", new { id = uid.ToString() }); 294 } 295 else 296 { 297 return RedirectToAction("Index", "Home"); 298 } 232 299 } 233 300 public IActionResult deleteGroup(string id) 234 301 { 235 init(); 236 var uid = Guid.Parse(id); 237 UserViewModel vm = new UserViewModel(accessClient).refreshGroups(); 238 239 if (uid == Guid.Empty) 240 { 241 vm.message = "Something went wrong, group is not deleted"; 242 return View("Groups", vm); 243 } 244 else 245 { 246 var group = vm.getGroupById(uid); 247 vm.message = group.Name + " has been deleted"; 248 accessClient.deleteUserGroup(group); 249 vm.refreshGroups(); 250 return View("Groups", vm); 302 if (init()) 303 { 304 var uid = Guid.Parse(id); 305 UserViewModel vm = new UserViewModel(accessClient).refreshGroups(); 306 307 if (uid == Guid.Empty) 308 { 309 vm.message = "Something went wrong, group is not deleted"; 310 return View("Groups", vm); 311 } 312 else 313 { 314 var group = vm.getGroupById(uid); 315 vm.message = group.Name + " has been deleted"; 316 accessClient.deleteUserGroup(group); 317 vm.refreshGroups(); 318 return View("Groups", vm); 319 } 320 } 321 else 322 { 323 return RedirectToAction("Index", "Home"); 251 324 } 252 325 … … 254 327 public IActionResult deleteMember(string g, string m) 255 328 { 256 init(); 257 var gid = Guid.Parse(g); 258 var mid = Guid.Parse(m); 259 UserViewModel vm = new UserViewModel(accessClient).refreshGroups().refreshUsers() ; 260 261 if (gid == Guid.Empty || mid == Guid.Empty) 262 { 263 vm.message = "Something went wrong, member is not deleted"; 264 return View("Groups", vm); 265 } 266 else 267 { 268 var group = vm.getGroupById(gid); 269 Access.UserGroupBase member = vm.getUserById(mid); 270 if(member == null) 271 { 272 member = vm.getGroupById(mid); 273 } 274 vm.message = " Member deleted"; 275 accessClient.deleteMember(member,group); 276 vm.refreshGroups(); 277 return RedirectToAction("SelectGroup", new { id = g }); 329 if (init()) 330 { 331 var gid = Guid.Parse(g); 332 var mid = Guid.Parse(m); 333 UserViewModel vm = new UserViewModel(accessClient).refreshGroups().refreshUsers(); 334 335 if (gid == Guid.Empty || mid == Guid.Empty) 336 { 337 vm.message = "Something went wrong, member is not deleted"; 338 return View("Groups", vm); 339 } 340 else 341 { 342 var group = vm.getGroupById(gid); 343 Access.UserGroupBase member = vm.getUserById(mid); 344 if (member == null) 345 { 346 member = vm.getGroupById(mid); 347 } 348 vm.message = " Member deleted"; 349 accessClient.deleteMember(member, group); 350 vm.refreshGroups(); 351 return RedirectToAction("SelectGroup", new { id = g }); 352 } 353 } 354 else 355 { 356 return RedirectToAction("Index", "Home"); 278 357 } 279 358 … … 284 363 public IActionResult Roles() 285 364 { 286 init(); 287 if (serviceLocator.CheckLogin()) 365 if (init()) 288 366 { 289 367 290 368 ViewBag.Title = "Roles"; 291 // accessClient.RefreshUsers(); 292 293 return View("Roles"); 369 UserViewModel vm = new UserViewModel(accessClient).refreshRoles(); 370 371 return View("Roles", vm); 372 } 373 else 374 { 375 return RedirectToAction("Index", "Home"); 376 } 377 } 378 public IActionResult SelectRole(string name) 379 { 380 if (init()) 381 { 382 383 UserViewModel vm = new UserViewModel(accessClient).refreshRoles(); 384 if (name == "" || name == null) 385 { 386 ViewBag.Title = "Add Role"; 387 } 388 else 389 { 390 vm.SelectedRole = vm.getRoleByName(name); 391 vm.SelectedRoleEnrolled = accessClient.getEnrolled(vm.SelectedRole); 392 393 ViewBag.title = vm.SelectedRole.Name; 394 } 395 ViewBag.Title += " - Roles"; 396 return View("Roles", vm); 397 } 398 else 399 { 400 return RedirectToAction("Index", "Home"); 401 } 402 } 403 [HttpPost] 404 public IActionResult saveRole(string inprolename) 405 { 406 if (init()) 407 { 408 Access.Role role = accessClient.Roles.Find(x => x.Name == inprolename); 409 if (role == null) 410 { 411 role = new Access.Role(); 412 role.Name = inprolename; 413 accessClient.addRole(role); 414 } 415 416 accessClient.RefreshRoles(); 417 return RedirectToAction("SelectRole", new { name = inprolename }); 418 } 419 else 420 { 421 return RedirectToAction("Index", "Home"); 422 } 423 } 424 public IActionResult deleteRole(string name) 425 { 426 if (init()) 427 { 428 accessClient.deleteRole(name); 429 return RedirectToAction("Roles"); 430 } 431 else 432 { 433 return RedirectToAction("Index", "Home"); 434 } 435 } 436 public IActionResult deleteRoleUser(string id, string role) 437 { 438 if (init()) 439 { 440 var uid = Guid.Parse(id); 441 UserViewModel vm = new UserViewModel(accessClient).refreshAll(); 442 443 var user = vm.getUserById(uid); 444 var r = vm.getRoleByName(role); 445 vm.message = role + " role has been deleted from " + user.FullName; 446 accessClient.deleteUserRole(user, r); 447 return RedirectToAction("SelectRole", new { name = role }); 294 448 } 295 449 else -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/HeuristicLab.Clients.Hive.WebJobManager.xproj.user
r13656 r13754 3 3 <PropertyGroup> 4 4 <ActiveDebugProfile>web</ActiveDebugProfile> 5 <ShowAllFiles>true</ShowAllFiles> 5 6 </PropertyGroup> 6 7 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Services/Imports/AccessAdministrationClient.cs
r13742 r13754 251 251 CallAccessService(s => s.UpdateUser(u)); 252 252 } 253 public List<Role> getRoles(User u) 254 { 255 return CallAccessService(s => s.GetUserRoles(u)); 256 } 257 public void addRoleToUser(User u, Role r) 258 { 259 CallAccessService(s => s.AddUserToRole(r, u)); 260 } 261 public void deleteUserRole(User u, Role r) 262 { 263 CallAccessService(s => s.RemoveUserFromRole(r, u)); 264 } 253 265 #endregion 254 266 … … 331 343 } 332 344 #endregion 345 346 #region Roles 347 public Role addRole(Access.Role r) 348 { 349 return CallAccessService(s => s.AddRole(r)); 350 } 351 public void deleteRole(string name) 352 { 353 Role r = Roles.Find(x => x.Name == name); 354 CallAccessService(s => s.DeleteRole(r)); 355 } 356 357 public List<UserGroupBase> getEnrolled(Role r) 358 { 359 var enroll = new List<UserGroupBase>(); 360 RefreshUsers(); 361 foreach(var us in users) 362 { 363 var temp = CallAccessService(s => s.GetUserRoles(us)); 364 if (temp.Contains(r)) 365 enroll.Add(us); 366 } 367 368 return enroll; 369 } 370 #endregion 371 333 372 334 373 #region Helpers -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Services/WebLoginService.cs
r13740 r13754 21 21 private List<FileOpeningService> fileopeners; 22 22 private List<AccessAdministrationClient> accessclients; 23 private List<HiveAdminClientWeb> adminclients; 23 24 /// <summary> 24 25 /// Service instance that keeps all the information per user seperated. Data is in different lists so … … 47 48 fileopeners = new List<FileOpeningService>(); 48 49 accessclients = new List<AccessAdministrationClient>(); 50 adminclients = new List<HiveAdminClientWeb>(); 49 51 } 50 52 /// <summary> … … 69 71 var temp3 = new AccessAdministrationClient(log.userId); 70 72 accessclients.Add(temp3); 73 var temp4 = new HiveAdminClientWeb(log.userId); 74 adminclients.Add(temp4); 71 75 } 72 76 /// <summary> … … 124 128 return accessclients.Find(x => x.userId == id); 125 129 } 130 public HiveAdminClientWeb getAdminClient(Guid id) 131 { 132 return adminclients.Find(x => x.userId == id); 133 } 126 134 /// <summary> 127 135 /// Removes all traces from the logged in user. … … 135 143 fileopeners.RemoveAll(x => x.UserId == id); 136 144 accessclients.RemoveAll(x => x.userId == id); 145 adminclients.RemoveAll(x => x.userId == id); 137 146 loggedIn.RemoveAll(x => x.userId == id); 147 138 148 } 139 149 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/ViewModels/User/UserViewModel.cs
r13742 r13754 18 18 public Access.User SelectedUser { get; set; } 19 19 public List<Access.UserGroup> SelectedUserSubscriptions { get; set; } 20 public List<Access.Role> SelectedUserRoles { get; set; } 20 21 public Access.UserGroup SelectedGroup { get; set; } 21 22 public List<Access.UserGroupBase> SelectedGroupMembers { get; set; } 23 public Access.Role SelectedRole { get; set; } 24 public List<Access.UserGroupBase> SelectedRoleEnrolled { get; set; } 22 25 23 26 public UserViewModel(AccessAdministrationClient ac) … … 25 28 users = new List<Access.User>(); 26 29 accessClient = ac; 30 27 31 SelectedUser = new Access.User(); 28 32 SelectedGroup = new Access.UserGroup(); 33 SelectedRole = new Access.Role(); 34 SelectedRole.Name = ""; 35 29 36 SelectedUserSubscriptions = new List<Access.UserGroup>(); 37 SelectedUserRoles = new List<Access.Role>(); 30 38 SelectedGroupMembers = new List<Access.UserGroupBase>(); 31 39 32 40 41 } 42 public UserViewModel refreshAll() 43 { 44 refreshUsers(); 45 refreshGroups(); 46 refreshRoles(); 47 return this; 33 48 } 34 49 public UserViewModel refreshUsers() … … 58 73 return ugroups.Find(x => x.Id == id); 59 74 } 75 public Access.Role getRoleByName(string name) 76 { 77 return roles.Find(x => x.Name == name); 78 } 60 79 } 61 80 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/Index.cshtml
r13742 r13754 135 135 136 136 </div> 137 <script src="~/js/scripts/graphs/graphdatacollector.min.js"></script> 138 <script src="~/js/scripts/graphs/graphhubber.min.js"></script> 137 <script src="~/js/hubs/graphhubber.js"></script> 139 138 <div class="row" style="text-align:center"> 140 139 @Html.Partial("_Graphlegend") -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/OpenFile.cshtml
r13742 r13754 181 181 </nav> 182 182 183 <script src="~/js/ scripts/hubber.min.js"></script>183 <script src="~/js/hubs/progresshubber.js"></script> 184 184 185 185 <script> -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/OpenFilePartials/_Algorithm.cshtml
r13735 r13754 9 9 </div> 10 10 <div class="row" style="text-align:center"> 11 <h1 data-toggle="tooltip" title="@Model.SelectedTask.ItemTask.ItemName 12 @Model.SelectedTask.ItemTask.Description"> 11 <h1> 13 12 <span class="label label-primary">Algorithm: @Model.SelectedTask.ItemTask.Name</span> 14 13 </h1> … … 71 70 </div> 72 71 73 74 <script type="text/javascript">75 $(document).ready(function () {76 $('[data-toggle="tooltip"]').tooltip();77 });78 </script>79 72 80 73 </div> -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/OpenFilePartials/_BatchRun.cshtml
r13735 r13754 9 9 style="text-align:center"> 10 10 <h1 11 data-toggle="tooltip" 12 title="@Model.SelectedTask.ItemTask.ItemName 13 @Model.SelectedTask.ItemTask.Description "> 11 > 14 12 <span class="label label-warning " 15 13 style="text-shadow:2px 2px black;"> … … 66 64 } 67 65 </div> 68 69 <script type="text/javascript">70 71 $(document).ready(function () {72 $('[data-toggle="tooltip"]').tooltip();73 });74 </script>75 66 </div> -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/OpenFilePartials/_Experiment.cshtml
r13735 r13754 10 10 <div class="row" style="text-align:center"> 11 11 <h1 12 data-toggle="tooltip" 13 title=" @Model.SelectedTask.ItemTask.ItemName 14 @Model.SelectedTask.ItemTask.Description "> 12 > 15 13 <span class="label label-danger" 16 14 style="text-shadow:2px 2px black;"> … … 65 63 } 66 64 </div> 67 68 <script type="text/javascript">69 70 $(document).ready(function () {71 $('[data-toggle="tooltip"]').tooltip();72 });73 </script>74 65 </div> -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Resource/Index.cshtml
r13733 r13754 1 1 2 <div> 2 <div ng-app="wjm" ng-controller="resourceCtrl" data-ng-init="init()"> 3 <div id="userId" style="display:none">@ViewBag.SessionId</div> 3 4 4 5 @Html.Partial("Navbar", new HeuristicLab.Clients.Hive.WebJobManager.ViewModels.NavbarViewModel("Resource")) 5 6 7 <p>Alert: {{alertMessage}} {{treeview.currentNode.Name}}</p> 6 8 9 <div class="col-sm-4"> 10 <div data-angular-treeview="true" 11 data-tree-id="treeview" 12 data-tree-model="tree" 13 data-node-id="Id" 14 data-node-label="Name" 15 data-node-children="children"> 16 </div> 17 </div> 18 <div ng-if="treeview.currentNode" class="col-sm-8 panel panel-primary"> 19 <div class="row panel-heading" > 20 <h3>{{treeview.currentNode.Name}} <span ng-if="treeview.currentNode.IsDisposable === undefined"> - Client group</span></h3> 21 <table class="table"> 22 <tbody> 23 <tr> 24 <td>Heartbeat</td> 25 <td>Every {{treeview.currentNode.HbInterval}} sec 26 <span ng-if="treeview.currentNode.IsDisposable !== undefined"> 27 - Last beat {{treeview.currentNode.LastHeartbeat | date:'HH:mm dd/MM/yyyy' }} 28 </span> 29 </td> 30 </tr> 31 <tr> 32 <td>Name</td> 33 <td>{{treeview.currentNode.Name}}</td> 34 </tr> 35 <tr> 36 <td>Id</td> 37 <td>{{treeview.currentNode.Id}}</td> 38 </tr> 39 <tr> 40 <td>Disposable</td> 41 <td><input type="checkbox" ng-checked="treeview.currentNode.IsDisposable" /></td> 42 </tr> 43 </tbody> 44 <tbody ng-if="treeview.currentNode.IsDisposable !== undefined"> 45 <tr> 46 <td>Cores (free/total)</td> 47 <td>{{treeview.currentNode.FreeCores}} | {{treeview.currentNode.Cores}}</td> 48 49 50 </tr> 51 <tr> 52 <td>Memory (free/total)</td> 53 <td>{{treeview.currentNode.FreeMemory}} MB | {{treeview.currentNode.Memory}} MB</td> 54 </tr> 55 56 </tbody> 57 </table> 58 </div> 59 <div class="panel-body row" style="text-align:center"> 60 <i ng-if="currentcal.length === 0" class="fa fa-cog fa-5x fa-spin" ></i> 61 <div ng-if="currentcal.length != 0" 62 ui-calendar="uiConfig.calendar" 63 id="resourcecalendar" 64 class="span8 calendar" 65 ng-model="currentcal.down"></div> 66 </div> 67 68 <div class="row panel-footer"> 69 70 </div> 71 </div> 72 <script src="~/js/hubs/calendarhubber.js"></script> 7 73 </div> -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Shared/_Layout.cshtml
r13740 r13754 4 4 <head> 5 5 <meta name="viewport" content="width=device-width" /> 6 <title>@ViewBag.Title - Heuristic Lab Hive WJM</title> 7 <environment names="Development"> 8 <link asp-href-include="~/css/*.css" rel="stylesheet"/> 9 </environment> 10 <environment names="Staging, Production"> 11 <link href="~/css/min/site.min.css" rel="stylesheet" /> 12 </environment> 6 <title>@ViewBag.Title - HeuristicLab HiveWeb</title> 7 8 <link href="~/css/site.min.css" rel="stylesheet" /> 9 13 10 <link href="https://gitcdn.github.io/bootstrap-toggle/2.2.0/css/bootstrap-toggle.min.css" rel="stylesheet"> 14 11 <link rel="shortcut icon" type="image/x-icon" href="~/favicon.ico" /> 15 12 <link rel="stylesheet" href="//rawgithub.com/Caged/d3-tip/master/examples/example-styles.css"> 16 13 </head> 17 <body 14 <body> 18 15 <div> 19 16 <nav class="navbar navbar-default navbar-static-top" 20 17 role="navigation" style="margin-bottom: 0"> 21 <div class="navbar-header" 22 <img alt="Heuristic Lab Hive" src="~/img/HeuristicLabBanner.png" style="margin-bottom:15px; margin-top:15px" />18 <div class="navbar-header"> 19 <img alt="Heuristic Lab Hive" src="~/img/HeuristicLabBanner.png" style="margin-bottom:15px; margin-top:15px" /> 23 20 </div> 24 21 </nav> 25 22 26 <script src="~/js/jquery-2.1.1.min.js"></script> 27 <script src="~/js/bootstrap.min.js"></script> 28 <script src="https://gitcdn.github.io/bootstrap-toggle/2.2.0/js/bootstrap-toggle.min.js"></script> 29 <script src="~/js/jquery.signalr-2.1.2.min.js"></script> 23 <script src="~/js/app.js"></script> 30 24 <script src='~/signalr/js'></script> 31 <script src="~/js/plotly.min.js"></script> 32 <script src="~/js/d3.v3.min.js"></script> 33 <script src="~/js/d3-gantt-jobstatus.js"></script> 34 <script src="~/js/d3-tip.min.js"></script> 25 35 26 @RenderBody() 36 27 </div> -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/User/Groups.cshtml
r13742 r13754 26 26 <a asp-controller="User" 27 27 asp-action="Roles"> 28 <i class="fa fa- sitemap"></i> Roles28 <i class="fa fa-gavel"></i> Roles 29 29 </a> 30 30 </li> … … 129 129 </div> 130 130 131 <div class="form-group"> 132 <label class="col-sm-3 control-label"> 133 Group id 134 </label> 135 <label class="col-sm-8 control-label" style="text-align:left"> 136 @Model.SelectedGroup.Id 137 </label> 138 <input type="text" 139 style="display:none" 140 id="u" 141 name="u" 142 value="@Model.SelectedGroup.Id" /> 143 </div> 131 144 132 @if (Model.SelectedGroup.Id != Guid.Empty) 145 133 { 146 <div style="padding-left:20px"> 147 <h3>@Model.SelectedGroupMembers.Count Member@(Model.SelectedGroupMembers.Count != 1 ? "s" : "")</h3> 148 @foreach (var member in Model.SelectedGroupMembers) 149 { 150 <p> 151 <a class="btn btn-danger" 152 asp-controller="User" 153 asp-action="deleteMember" 154 asp-route-g="@Model.SelectedGroup.Id" 155 asp-route-m="@member.Id" 156 onclick="showDeleter()"> 157 <i class="fa fa-trash-o"></i> 158 </a> 159 @if (member is User) 160 { 161 var umember = (User)member; 162 <i class="fa fa-user"></i> @(umember.UserName + "(" + umember.FullName + ")") 163 164 165 } 166 else if (member is UserGroup) 167 { 168 var gmember = (UserGroup)member; 169 <i class="fa fa-group"></i> @(gmember.Name) 170 171 } 172 173 </p> 174 } 175 @if (Model.SelectedGroupMembers.Count == 0) 176 { 177 <p>This group currently has no members</p> 178 179 } 134 <div class="form-group"> 135 <label class="col-sm-3 control-label"> 136 Group id 137 </label> 138 <label class="col-sm-8 control-label" style="text-align:left"> 139 @Model.SelectedGroup.Id 140 </label> 141 <input type="text" 142 style="display:none" 143 id="u" 144 name="u" 145 value="@Model.SelectedGroup.Id" /> 146 </div> 147 <div class="form-group"> 148 <label class="col-sm-3 control-label"> 149 Members 150 </label> 151 <div class="col-sm-8 control-label" > 152 153 @foreach (var member in Model.SelectedGroupMembers) 154 { 155 <div class="row"> 156 <p class="col-sm-10" style="text-align:left"> 157 158 @if (member is User) 159 { 160 var umember = (User)member; 161 <i class="fa fa-user"></i> @(umember.UserName + "(" + umember.FullName + ")") 162 163 164 } 165 else if (member is UserGroup) 166 { 167 var gmember = (UserGroup)member; 168 <i class="fa fa-group"></i> @(gmember.Name) 169 170 } 171 172 </p> 173 <p class="col-sm-2"> 174 <a class="btn btn-danger" 175 asp-controller="User" 176 asp-action="deleteMember" 177 asp-route-g="@Model.SelectedGroup.Id" 178 asp-route-m="@member.Id" 179 onclick="showDeleter()"> 180 <i class="fa fa-trash-o"></i> 181 </a> 182 </p> 183 </div> 184 } 185 @if (Model.SelectedGroupMembers.Count == 0) 186 { 187 <p style="text-align:left">This group currently has no members</p> 188 189 } 190 </div> 180 191 </div> 181 192 } … … 196 207 <p> 197 208 <i class="fa fa-user"></i> Users 198 <button class="btn btn-sm btn-default" 209 <button class="btn btn-sm btn-default" 199 210 type="button" 200 onclick="selectAll('userstoadd'); triggerSave()">Select all</button> 211 onclick="selectAll('userstoadd'); triggerSave()"> 212 Select all 213 </button> 201 214 <button class="btn btn-sm btn-default" 202 type="button" 203 onclick="deselectAll('userstoadd'); triggerSave()">Deselect all</button> 215 type="button" 216 onclick="deselectAll('userstoadd'); triggerSave()"> 217 Deselect all 218 </button> 204 219 </p> 205 220 </div> … … 223 238 <div class="panel panel-primary col-sm-6" style="padding:0px"> 224 239 <div class="panel-heading"> 225 <p><i class="fa fa-group"></i> Groups 226 240 <p> 241 <i class="fa fa-group"></i> Groups 242 227 243 <button class="btn btn-sm btn-default" 228 244 type="button" … … 234 250 onclick="deselectAll('groupstoadd'); triggerSave()"> 235 251 Deselect all 236 </button> 252 </button> 237 253 </p> 238 254 </div> … … 244 260 <input type="checkbox" 245 261 name="groupstoadd" 246 @(Model.SelectedGroupMembers.Contains(group) ? "checked disabled" : "") 262 @(Model.SelectedGroupMembers.Contains(group) || 263 Model.SelectedGroup.Id == group.Id ? "checked disabled" : "") 247 264 value="@group.Id" 248 265 onclick="triggerSave()"> 249 @group.Name 266 @group.Name @( Model.SelectedGroup.Id == group.Id ? "(selected group)" : "") 250 267 </label> 251 268 </div> … … 338 355 function selectAll(name) { 339 356 checkboxes = document.getElementsByName(name); 340 for (var i=0, n=checkboxes.length;i<n;i++) {357 for (var i = 0, n = checkboxes.length; i < n; i++) { 341 358 checkboxes[i].checked = true; 342 359 } … … 345 362 checkboxes = document.getElementsByName(name); 346 363 for (var i = 0, n = checkboxes.length; i < n; i++) { 347 if (checkboxes[i].disabled == false)348 checkboxes[i].checked = false;364 if (checkboxes[i].disabled == false) 365 checkboxes[i].checked = false; 349 366 } 350 367 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/User/Index.cshtml
r13742 r13754 25 25 <a asp-controller="User" 26 26 asp-action="Roles"> 27 <i class="fa fa- sitemap"></i> Roles27 <i class="fa fa-gavel"></i> Roles 28 28 </a> 29 29 </li> … … 101 101 id="content" 102 102 style="padding:5px; padding-left:10px;"> 103 @if (Model.SelectedUser != null) 104 { 105 <div class="panel panel-default" 106 style="border-width:2px!important;padding:17px; 103 <div class="panel panel-default" 104 style="border-width:2px!important;padding:17px; 107 105 box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);"> 108 <div class="row"> 109 <h2 style="padding-left:20px"> 106 <div class="row"> 107 <h2 style="padding-left:20px"> 108 @if (Model.SelectedUser.Id != Guid.Empty) 109 { 110 <i class="fa fa-user "></i> @Model.SelectedUser.UserName; 111 } 112 else 113 { 114 <i class="fa fa-user-plus "></i> @("Add new user") 115 116 } 117 </h2> 118 <form class="form-horizontal" 119 method="post" 120 asp-action="saveUser" 121 asp-controller="User" 122 enctype="multipart/form-data" 123 onsubmit="showSaver()"> 124 <div class="form-group" style="@(Model.SelectedUser.Id == Guid.Empty ? "" : "display:none")"> 125 <label for="inpusername" 126 class="col-sm-3 control-label"> 127 Username 128 </label> 129 <div class="col-sm-8"> 130 <input type="text" 131 class="form-control" 132 id="inpusername" 133 name="inpusername" 134 placeholder="Username" 135 onkeydown="triggerSave()" 136 value="@Model.SelectedUser.UserName"> 137 </div> 138 </div> 139 <div class="form-group"> 140 <label for="inpfullname" 141 class="col-sm-3 control-label"> 142 Full name 143 </label> 144 <div class="col-sm-8"> 145 <input type="text" 146 class="form-control" 147 id="inpfullname" 148 name="inpfullname" 149 placeholder="Full name" 150 onkeydown="triggerSave()" 151 value="@Model.SelectedUser.FullName"> 152 </div> 153 </div> 154 <div class="form-group"> 155 <label for="inpemail" 156 class="col-sm-3 control-label"> 157 Email 158 </label> 159 <div class="col-sm-8"> 160 <input type="email" 161 class="form-control" 162 id="inpemail" 163 name="inpemail" 164 placeholder="Email" 165 onkeydown="triggerSave()" 166 value="@Model.SelectedUser.Email"> 167 </div> 168 </div> 169 <input type="text" 170 style="display:none" 171 id="u" 172 name="u" 173 value="@Model.SelectedUser.Id" /> 174 @if (Model.SelectedUser.Id != Guid.Empty) 175 { 176 <div class="form-group"> 177 <label class="col-sm-3 control-label"> 178 User id 179 </label> 180 <label class="col-sm-8 control-label" style="text-align:left"> 181 @Model.SelectedUser.Id 182 </label> 183 184 </div> 185 <div class="form-group"> 186 <label class="col-sm-3 control-label"> 187 User created 188 </label> 189 <label class="col-sm-8 control-label" style="text-align:left"> 190 @Model.SelectedUser.CreationDate.AddHours(2).ToString(); 191 </label> 192 </div> 193 <div class="form-group"> 194 <label class="col-sm-3 control-label"> 195 Last activity 196 </label> 197 <label class="col-sm-8 control-label" style="text-align:left"> 198 @Model.SelectedUser.LastActivityDate.AddHours(2).ToString() 199 </label> 200 </div> 201 <div class="form-group"> 202 <label class="col-sm-3 control-label"> 203 Password 204 </label> 205 <div id="inppassreset" class="col-sm-8"> 206 Last change: @Model.SelectedUser.LastPasswordChangedDate.ToShortDateString() 207 <button type="button" 208 onclick="resetPass('@(Model.SelectedUser.Id)')" 209 class="btn btn-default"> 210 <i class="fa fa-unlock"></i> Reset password 211 </button> 212 </div> 213 </div> 214 215 <div class="form-group"> 216 <label class="col-sm-3 control-label"> 217 Member of 218 </label> 219 <div class="col-sm-8 control-label" style="text-align:left"> 220 @if (Model.SelectedUserSubscriptions.Count > 0) 221 { 222 @foreach (var g in Model.SelectedUserSubscriptions) 223 { 224 <div class="row"> 225 <p class="col-sm-10"><i class="fa fa-group"></i> @g.Name</p> 226 <p class="col-sm-2"> 227 <a class="btn btn-danger pull-right" 228 asp-controller="User" 229 asp-action="deleteUserGroup" 230 asp-route-id="@Model.SelectedUser.Id" 231 asp-route-group="@g.Id" 232 onclick="showDeleter()"> 233 <i class="fa fa-trash-o"></i> 234 </a> 235 </p> 236 </div> 237 } 238 } 239 else 240 { 241 <p>Not a member of any groups</p> 242 } 243 </div> 244 </div> 245 } 246 247 <div class="row" style="margin-left:10px;margin-right:10px;margin-top:-10px"> 248 <a class="btn btn-primary col-sm-3" 249 data-toggle="collapse" 250 href="#addgroups" 251 aria-expanded="false" 252 aria-controls="addgroups" 253 style="margin:10px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 254 text-shadow:2px 2px black;"> 255 @(Model.SelectedUser.Id == Guid.Empty ? "Set groups" : "Add groups") 256 </a> 257 <div class="collapse col-sm-12" 258 id="addgroups"> 259 <div class="panel panel-primary" style="padding:0px"> 260 <div class="panel-heading"> 261 <p> 262 <i class="fa fa-group"></i> Groups 263 </p> 264 </div> 265 <div class="panel-body"> 266 @foreach (var group in Model.ugroups) 267 { 268 <div class="checkbox"> 269 <label> 270 <input type="checkbox" 271 name="groupstoadd" 272 @(Model.SelectedUserSubscriptions.Contains(group) ? "checked disabled" : "") 273 value="@group.Id" 274 onclick="triggerSave()"> 275 @group.Name 276 </label> 277 </div> 278 279 } 280 </div> 281 </div> 282 </div> 283 </div> 284 285 @if (Model.SelectedUser.Id != Guid.Empty) 286 { 287 <div class="form-group"> 288 <label class="col-sm-3 control-label"> 289 Roles 290 </label> 291 <div class="col-sm-8 control-label" style="text-align:left"> 292 @if (Model.SelectedUserRoles.Count > 0) 293 { 294 @foreach (var r in Model.SelectedUserRoles) 295 { 296 <div class="row"> 297 298 <p class="col-sm-10"><i class="fa fa-gavel"></i> @r.Name</p> 299 <p class="col-sm-2"> 300 <a class="btn btn-danger pull-right" 301 asp-controller="User" 302 asp-action="deleteUserRole" 303 asp-route-id="@Model.SelectedUser.Id" 304 asp-route-role="@r.Name" 305 onclick="showDeleter()"> 306 <i class="fa fa-trash-o"></i> 307 </a> 308 </p> 309 </div> 310 } 311 } 312 else 313 { 314 <p>User has no roles</p> 315 } 316 </div> 317 </div> 318 } 319 <div class="row" style="margin-left:10px;margin-right:10px;"> 320 <a class="btn btn-primary col-sm-3" 321 data-toggle="collapse" 322 href="#addroles" 323 aria-expanded="false" 324 aria-controls="addroles" 325 style="margin:10px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 326 text-shadow:2px 2px black;"> 327 @(Model.SelectedUser.Id == Guid.Empty ? "Set roles" : "Add roles") 328 </a> 329 <div class="collapse col-sm-12" 330 id="addroles"> 331 <div class="panel panel-primary" style="padding:0px"> 332 <div class="panel-heading"> 333 <p> 334 <i class="fa fa-gavel"></i> Roles 335 </p> 336 </div> 337 <div class="panel-body"> 338 @foreach (var role in Model.roles) 339 { 340 <div class="checkbox"> 341 <label> 342 <input type="checkbox" 343 name="rolestoadd" 344 @(Model.SelectedUserRoles.Contains(role) ? "checked disabled" : "") 345 value="@role.Name" 346 onclick="triggerSave()"> 347 @role.Name 348 </label> 349 </div> 350 351 } 352 </div> 353 </div> 354 </div> 355 </div> 356 <div class="form-group"> 357 <div class="col-sm-offset-3 col-sm-3"> 358 <button type="submit" 359 id="inpsaver" 360 disabled 361 class="btn btn-default" 362 > 363 <i class="fa fa-save"></i> 364 @(Model.SelectedUser.Id != Guid.Empty ? "Save changes" : "Add user") 365 </button> 366 </div> 110 367 @if (Model.SelectedUser.Id != Guid.Empty) 111 368 { 112 <i class="fa fa-user "></i> @Model.SelectedUser.UserName; 369 <div class="col-sm-5"> 370 <a class="btn btn-danger pull-right" 371 asp-controller="User" 372 asp-action="deleteUser" 373 asp-route-id="@Model.SelectedUser.Id" 374 onclick="showDeleter()"> 375 <i class="fa fa-trash-o"></i> Delete user 376 </a> 377 </div> 113 378 } 114 else 115 { 116 <i class="fa fa-user-plus "></i> @("Add new user") 379 </div> 380 381 382 383 384 <script type="text/javascript"> 385 function triggerSave() { 386 if ($("#inpfullname").val() != "" && 387 $("#inpemail").val() != "") { 388 document.getElementById("inpsaver").className = "btn btn-lg btn-success"; 389 document.getElementById("inpsaver").disabled = false; 390 } 391 else { 392 document.getElementById("inpsaver").className = "btn btn-default"; 393 document.getElementById("inpsaver").disabled = true; 394 395 } 117 396 118 397 } 119 </h2> 120 <form class="form-horizontal" 121 method="post" 122 asp-action="saveUser" 123 asp-controller="User" enctype="multipart/form-data"> 124 <div class="form-group" style="@(Model.SelectedUser.Id == Guid.Empty ? "" : "display:none")"> 125 <label for="inpusername" 126 class="col-sm-3 control-label"> 127 Username 128 </label> 129 <div class="col-sm-8"> 130 <input type="text" 131 class="form-control" 132 id="inpusername" 133 name="inpusername" 134 placeholder="Username" 135 onkeydown="triggerSave()" 136 value="@Model.SelectedUser.UserName"> 137 </div> 138 </div> 139 <div class="form-group"> 140 <label for="inpfullname" 141 class="col-sm-3 control-label"> 142 Full name 143 </label> 144 <div class="col-sm-8"> 145 <input type="text" 146 class="form-control" 147 id="inpfullname" 148 name="inpfullname" 149 placeholder="Full name" 150 onkeydown="triggerSave()" 151 value="@Model.SelectedUser.FullName"> 152 </div> 153 </div> 154 <div class="form-group"> 155 <label for="inpemail" 156 class="col-sm-3 control-label"> 157 Email 158 </label> 159 <div class="col-sm-8"> 160 <input type="email" 161 class="form-control" 162 id="inpemail" 163 name="inpemail" 164 placeholder="Email" 165 onkeydown="triggerSave()" 166 value="@Model.SelectedUser.Email"> 167 </div> 168 </div> 169 <div class="form-group"> 170 <label class="col-sm-3 control-label"> 171 User id 172 </label> 173 <label class="col-sm-8 control-label" style="text-align:left"> 174 @Model.SelectedUser.Id 175 </label> 176 <input type="text" 177 style="display:none" 178 id="u" 179 name="u" 180 value="@Model.SelectedUser.Id" /> 181 </div> 182 <div class="form-group"> 183 <label class="col-sm-3 control-label"> 184 Last login 185 </label> 186 <label class="col-sm-8 control-label" style="text-align:left"> 187 @Model.SelectedUser.LastLoginDate.AddHours(2).ToString() 188 </label> 189 </div> 190 <div class="form-group"> 191 <label class="col-sm-3 control-label"> 192 Last activity 193 </label> 194 <label class="col-sm-8 control-label" style="text-align:left"> 195 @Model.SelectedUser.LastActivityDate.AddHours(2).ToString() 196 </label> 197 </div> 198 @if (Model.SelectedUser.Id == Guid.Empty) 199 { 200 <div class="form-group"> 201 <div class="col-sm-offset-3 col-sm-9"> 202 <button type="submit" 203 id="inpsaver" 204 disabled 205 class="btn btn-default" 206 onclick="showSaver()"> 207 <i class="fa fa-plus-square-o"></i> Add user 208 </button> 209 </div> 210 </div> 211 212 213 } 214 else 215 { 216 <div class="form-group"> 217 <label class="col-sm-3 control-label"> 218 Password 219 </label> 220 <div id="inppassreset" class="col-sm-8"> 221 <button type="button" 222 onclick="resetPass('@(Model.SelectedUser.Id)')" 223 class="btn btn-default"> 224 <i class="fa fa-unlock"></i> Reset password 225 </button> 226 </div> 227 </div> 228 229 <div class="form-group"> 230 <label class="col-sm-3 control-label"> 231 Member of 232 </label> 233 <div class="col-sm-8"> 234 @if (Model.SelectedUserSubscriptions.Count > 0) 235 { 236 @foreach (var g in Model.SelectedUserSubscriptions) 237 { 238 <p><i class="fa fa-group"></i> @g.Name</p> 239 } 240 } 241 else 242 { 243 <p>Not a member of any groups</p> 244 } 245 </div> 246 </div> 247 <div class="form-group"> 248 <div class="col-sm-offset-3 col-sm-3"> 249 <button type="submit" 250 id="inpsaver" 251 disabled 252 class="btn btn-default" 253 onclick="showSaver()"> 254 <i class="fa fa-save"></i> Save changes 255 </button> 256 </div> 257 <div class="col-sm-5"> 258 <a class="btn btn-danger pull-right" 259 asp-controller="User" 260 asp-action="deleteUser" 261 asp-route-id="@Model.SelectedUser.Id" 262 onclick="showDeleter()"> 263 <i class="fa fa-trash-o"></i> Delete user 264 </a> 265 </div> 266 </div> 267 268 269 270 } 271 <script type="text/javascript"> 272 function triggerSave() { 273 if ($("#inpfullname").val() != "" && 274 $("#inpemail").val() != "") { 275 document.getElementById("inpsaver").className = "btn btn-lg btn-success"; 276 document.getElementById("inpsaver").disabled = false; 277 } 278 else { 279 document.getElementById("inpsaver").className = "btn btn-default"; 280 document.getElementById("inpsaver").disabled = true; 281 282 } 283 284 } 285 </script> 286 </form> 287 288 </div> 398 </script> 399 </form> 400 289 401 </div> 290 402 291 } 403 </div> 404 292 405 293 406 … … 298 411 </div> 299 412 300 <script src="~/js/ scripts/userinfohubber.js" type="text/javascript"></script>413 <script src="~/js/hubs/userinfohubber.js"></script> 301 414 <script type="text/javascript"> 302 415 function showSaver() { -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/User/Roles.cshtml
r13740 r13754 1 1 @using HeuristicLab.Clients.Hive.WebJobManager.ViewModels.User; 2 2 @using HeuristicLab.Clients.Access; 3 @model UserViewModel 3 4 4 5 <div> … … 11 12 <a asp-controller="User" 12 13 asp-action="Index"> 13 Users14 <i class="fa fa-user"></i> Users 14 15 </a> 15 16 </li> … … 18 19 <a asp-controller="User" 19 20 asp-action="Groups"> 20 Groups21 <i class="fa fa-users"></i> Groups 21 22 </a> 22 23 </li> … … 25 26 <a asp-controller="User" 26 27 asp-action="Roles"> 27 Roles28 <i class="fa fa-gavel"></i> Roles 28 29 </a> 29 30 </li> … … 31 32 <div class="row" 32 33 style="text-align:center"> 33 Model.message34 @Model.message 34 35 </div> 35 36 <div class="row" 36 37 style="padding:10px; margin-right:0px!important"> 37 38 39 <div class="col-sm-4"> 40 <div class="btn-group-vertical btn-block"> 41 <a class="btn btn-info btn-lg btn-block disabled" 42 style="box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 43 text-shadow:2px 2px black;"> 44 <i class="fa fa-gavel"></i> @Model.roles.Count Role@(Model.roles.Count != 1 ? "s" : "") 45 </a> 46 <a class="btn btn-success btn-block 47 @(Model.SelectedRole.Name == "" ? "active" : "") 48 " 49 asp-controller="User" 50 asp-action="SelectRole" 51 asp-route-name="" 52 onclick="showRole()" 53 style="box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 54 text-shadow:2px 2px black;"> 55 <i class="fa fa-plus-circle"></i> Add new role 56 </a> 57 @foreach (var role in Model.roles) 58 { 59 <a class="btn btn-default @( role.Name == Model.SelectedRole.Name ? "active" : "" )" 60 style="box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);" 61 asp-controller="User" 62 asp-action="SelectRole" 63 asp-route-name="@role.Name" 64 onclick="showRole()"> 65 @role.Name 66 </a> 67 } 68 </div> 69 </div> 70 <p style="display:none" 71 id="saver" 72 class="text-center"> 73 <br /><br /><br /><br /><br /><br /><br /> 74 <i class="fa fa-save fa-spin fa-5x" id="spinner"> 75 </i> 76 </p> 77 <p style="display:none" 78 id="role" 79 class="text-center"> 80 <br /><br /><br /><br /><br /><br /><br /> 81 <i class="fa fa-gavel fa-spin fa-5x" id="spinner"> 82 </i> 83 </p> 84 <p style="display:none" 85 id="deleter" 86 class="text-center"> 87 <br /><br /><br /><br /><br /><br /><br /> 88 <i class="fa fa-trash-o fa-spin fa-5x" id="spinner"> 89 </i> 90 </p> 91 <div class="col-sm-8" 92 id="content" 93 style="padding:5px; padding-left:10px;"> 94 <div class="panel panel-default" 95 style="border-width:2px!important;padding:17px; 96 box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);"> 97 <div class="row"> 98 <h2 style="padding-left:20px"> 99 @if (Model.SelectedRole.Name != "") 100 { 101 <i class="fa fa-gavel "></i> @Model.SelectedRole.Name; 102 } 103 else 104 { 105 <i class="fa fa-plus-circle "></i> @("Add new role") 106 107 } 108 </h2> 109 <form class="form-horizontal" 110 method="post" 111 asp-action="saveRole" 112 asp-controller="User" enctype="multipart/form-data"> 113 <div class="form-group"> 114 <label class="col-sm-3 control-label"> 115 Role name 116 </label> 117 <label class="col-sm-8 control-label" 118 style="text-align:left; @(Model.SelectedRole.Name == "" ? "display:none" : "")"> 119 @Model.SelectedRole.Name 120 </label> 121 <div class="col-sm-8" 122 style="@(Model.SelectedRole.Name == "" ? "" : "display:none")"> 123 <input type="text" 124 class="form-control" 125 id="inprolename" 126 name="inprolename" 127 placeholder="Role name" 128 value="@Model.SelectedRole.Name" 129 onkeydown="triggerSave()" /> 130 </div> 131 </div> 132 133 @if (Model.SelectedRole.Name == "") 134 { 135 <div class="form-group"> 136 <div class="col-sm-offset-3 col-sm-9"> 137 <button type="submit" 138 id="inpsaver" 139 disabled 140 class="btn btn-default" 141 onclick="showSaver()"> 142 <i class="fa fa-plus-square-o"></i> Add role 143 </button> 144 </div> 145 </div> 146 147 148 } 149 else 150 { 151 152 <div class="form-group"> 153 <label class="col-sm-3 control-label"> 154 Users 155 </label> 156 <div class="col-sm-8 control-label" style="text-align:left"> 157 @foreach (var us in Model.SelectedRoleEnrolled) 158 { 159 <div class="row"> 160 <p class="col-sm-10"> 161 <i class="fa fa-user"></i> @(((User)us).UserName) (@(((User)us).FullName)) 162 </p> 163 <p class="col-sm-2"> 164 <a class="btn btn-danger pull-right" 165 asp-controller="User" 166 asp-action="deleteRoleUser" 167 asp-route-id="@us.Id" 168 asp-route-role="@Model.SelectedRole.Name" 169 onclick="showDeleter()"> 170 <i class="fa fa-trash-o"></i> 171 </a> 172 </p> 173 174 </div> 175 } 176 @if (Model.SelectedRoleEnrolled.Count == 0) 177 { 178 <p> 179 There are currently no users who have this role 180 </p> 181 182 } 183 </div> 184 </div> 185 <div class="form-group"> 186 <div class="col-sm-offset-3 col-sm-3"> 187 <button type="submit" 188 id="inpsaver" 189 disabled 190 class="btn btn-default" 191 onclick="showSaver()"> 192 <i class="fa fa-save"></i> Save changes 193 </button> 194 </div> 195 <div class="col-sm-5"> 196 <a class="btn btn-danger pull-right" 197 asp-controller="User" 198 asp-action="deleteRole" 199 asp-route-name="@Model.SelectedRole.Name" 200 201 onclick="showDeleter()"> 202 <i class="fa fa-trash-o"></i> Delete role 203 </a> 204 </div> 205 </div> 206 207 208 209 } 210 <script type="text/javascript"> 211 function triggerSave() { 212 if ($("#inprolename").val() != "") { 213 document.getElementById("inpsaver").className = "btn btn-lg btn-success"; 214 document.getElementById("inpsaver").disabled = false; 215 } 216 else { 217 document.getElementById("inpsaver").className = "btn btn-default"; 218 document.getElementById("inpsaver").disabled = true; 219 220 } 221 222 } 223 </script> 224 </form> 225 </div> 226 </div> 227 </div> 38 228 </div> 229 <script type="text/javascript"> 230 function showSaver() { 231 document.getElementById("content").style.display = "none"; 232 document.getElementById("saver").style.display = ""; 233 234 } 235 function showRole() { 236 document.getElementById("content").style.display = "none"; 237 document.getElementById("role").style.display = ""; 238 239 } 240 function showDeleter() { 241 document.getElementById("content").style.display = "none"; 242 document.getElementById("deleter").style.display = ""; 243 } 244 </script> 39 245 </div>
Note: See TracChangeset
for help on using the changeset viewer.