Changeset 13741
- Timestamp:
- 03/31/16 16:59:16 (9 years ago)
- Location:
- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/HomeController.cs
r13739 r13741 57 57 Common.Properties.Settings.Default.Save(); 58 58 hiveServiceLocator.Username = loginName; 59 hiveServiceLocator.Password = password; 59 hiveServiceLocator.Password = password;//Not encrypted for login to service 60 60 hiveServiceLocator.UserId = model.userId; 61 61 … … 73 73 model = new LoginViewModel(); 74 74 model.errorMessage = "Wrong login, try again"; 75 return View("Index", model); 76 } 77 catch(SecurityAccessDeniedException e) 78 { 79 ViewBag.Title = "Access denied - Login"; 80 model = new LoginViewModel(); 81 model.errorMessage = "Access denied, you have no permission to use this application." + 82 " Contact a HeuristicLab Hive admin to gain access."; 75 83 return View("Index", model); 76 84 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/UserController.cs
r13740 r13741 50 50 51 51 ViewBag.Title = "Users"; 52 // accessClient.RefreshUsers(); 53 UserViewModel vm = new UserViewModel(); 54 vm.users = new List<string>() { "Jean" }; 52 UserViewModel vm = new UserViewModel(accessClient).refreshUsers(); 53 ViewBag.SessionId = HttpContext.Session.GetString("UserId"); 55 54 return View("Index", vm); 56 55 } … … 60 59 } 61 60 } 61 62 62 public IActionResult SelectUser(string id) 63 63 { … … 66 66 { 67 67 Guid curr = Guid.Parse(id); 68 UserViewModel vm = new UserViewModel();69 vm.users = new List<string>() { "Jean" };68 69 UserViewModel vm = new UserViewModel(accessClient).refreshUsers(); 70 70 if (curr == Guid.Empty) 71 71 { 72 vm.SelectedUser = "";73 72 ViewBag.Title = "Add User"; 74 73 } 75 74 else 76 75 { 77 vm.SelectedUser = "Jean";78 ViewBag. Title = "Jean";76 vm.SelectedUser = vm.getUserById(curr); 77 ViewBag.title = vm.SelectedUser.UserName; 79 78 } 80 79 ViewBag.Title += " - Users"; 80 ViewBag.SessionId = HttpContext.Session.GetString("UserId"); 81 81 return View("Index", vm); 82 82 } … … 86 86 } 87 87 } 88 [HttpPost] 89 public IActionResult saveUser(string inpusername, string inpfullname, string inpemail, string u) 90 { 91 init(); 92 var uid = Guid.Parse(u); 93 Access.User user; 94 if (uid == Guid.Empty) 95 user = new Access.User(); 96 else 97 user = accessClient.Users.Find(x => x.Id == uid); 98 99 user.Id = uid; 100 user.UserName = inpusername; 101 user.FullName = inpfullname; 102 user.Email = inpemail; 103 104 105 if (uid == Guid.Empty) 106 { 107 uid = accessClient.addUser(user); 108 ViewBag.Title = inpusername + " added - User"; 109 } 110 else 111 { 112 accessClient.updateUser(user); 113 ViewBag.Title = inpusername + " updated - User"; 114 } 115 116 return RedirectToAction( "SelectUser", new { id = uid.ToString()}); 117 118 } 119 88 120 #endregion 89 121 -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/ViewModels/User/UserViewModel.cs
r13740 r13741 1 using System; 1 using HeuristicLab.Clients.Access.Administration; 2 using System; 2 3 using System.Collections.Generic; 3 4 using System.Linq; … … 10 11 11 12 public string message { get; set; } 12 public List<string> users { get; set; }//temp 13 public AccessAdministrationClient accessClient { get; set; } 14 public List<Access.User> users { get; set; } 15 public List<Access.Role> roles { get; set; } 16 public List<Access.UserGroup> ugroups { get; set; } 13 17 14 public string SelectedUser { get; set; }//temp18 public Access.User SelectedUser { get; set; } 15 19 16 public UserViewModel( )20 public UserViewModel(AccessAdministrationClient ac) 17 21 { 18 users = new List<string>(); 22 users = new List<Access.User>(); 23 accessClient = ac; 24 SelectedUser = new Access.User(); 25 26 } 27 public UserViewModel refreshUsers() 28 { 29 accessClient.RefreshUsers(); 30 users = accessClient.Users.ToList(); 31 return this; 32 } 33 public UserViewModel refreshRoles() 34 { 35 accessClient.RefreshRoles(); 36 roles = accessClient.Roles.ToList(); 37 return this; 38 } 39 public UserViewModel refreshGroups() 40 { 41 accessClient.RefreshUserGroups(); 42 ugroups= accessClient.Groups.ToList(); 43 return this; 44 } 45 public Access.User getUserById(Guid id) 46 { 47 return users.Find(x => x.Id == id); 19 48 } 20 49 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/UploaderPartial/_UploaderPartial.cshtml
r13740 r13741 58 58 </div> 59 59 </div> 60 <button style=" 60 <button style="box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 61 61 text-shadow:2px 2px black;" 62 62 disabled -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/User/Index.cshtml
r13740 r13741 1 1 @using HeuristicLab.Clients.Hive.WebJobManager.ViewModels.User; 2 2 @model UserViewModel 3 <div id="userId" style="display:none">@ViewBag.SessionId</div> 3 4 <div> 4 5 … … 53 54 </a> 54 55 <a class="btn btn-success btn-block 55 @(Model.SelectedUser == ""? "active" : "")56 @(Model.SelectedUser.Id == Guid.Empty ? "active" : "") 56 57 " 57 58 asp-controller="User" … … 63 64 <i class="fa fa-user-plus"></i> Add new user 64 65 </a> 65 @foreach (var user in Model.users)66 @foreach (var user in Model.users) 66 67 { 67 <a class="btn btn-default @( user == Model.SelectedUser? "active" : "" )"68 <a class="btn btn-default @( user.Id == Model.SelectedUser.Id ? "active" : "" )" 68 69 style="box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);" 69 70 asp-controller="User" 70 71 asp-action="SelectUser" 71 asp-route-id="@ Guid.NewGuid()"72 asp-route-id="@user.Id" 72 73 onclick="showUser()"> 73 @user 74 @user.UserName (@user.FullName) 74 75 </a> 75 76 } … … 97 98 </i> 98 99 </p> 99 <div id="content"> 100 101 </div> 100 <div class="col-sm-8" 101 id="content" 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; 107 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"> 110 @if (Model.SelectedUser.Id != Guid.Empty) 111 { 112 @Model.SelectedUser.UserName; 113 } 114 else 115 { 116 @("Add new user") 117 118 } 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"> 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 onchange="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 onchange="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 onchange="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-lg btn-default"> 206 Add user 207 </button> 208 </div> 209 </div> 210 211 212 } 213 else 214 { 215 <div class="form-group"> 216 <label class="col-sm-3 control-label"> 217 Last activity 218 </label> 219 <div id="inppassreset"> 220 <button type="button" 221 onclick="resetPass('@(Model.SelectedUser.Id)')" 222 class="btn btn-lg btn-default"> 223 Reset password 224 </button> 225 </div> 226 </div> 227 <div class="form-group"> 228 <div class="col-sm-offset-3 col-sm-9"> 229 <button type="submit" 230 id="inpsaver" 231 disabled 232 class="btn btn-lg btn-default"> 233 Save changes 234 </button> 235 </div> 236 </div> 237 238 239 } 240 <script type="text/javascript"> 241 function triggerSave() { 242 if ($("#inpusername").val() != "" && 243 $("#inpfullname").val() != "" && 244 $("#inpemail").val() != "") { 245 document.getElementById("inpsaver").className = "btn btn-lg btn-success"; 246 document.getElementById("inpsaver").disabled = false; 247 } 248 else { 249 document.getElementById("inpsaver").className = "btn btn-lg btn-default"; 250 document.getElementById("inpsaver").disabled = true; 251 252 } 253 254 } 255 </script> 256 </form> 257 258 </div> 259 </div> 260 261 } 262 263 264 265 266 </div> 102 267 } 103 268 </div> 269 270 <script src="~/js/scripts/userinfohubber.js" type="text/javascript"></script> 104 271 <script type="text/javascript"> 105 272 function showSaver() {
Note: See TracChangeset
for help on using the changeset viewer.