- Timestamp:
- 01/26/18 08:51:30 (7 years ago)
- Location:
- branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/MenuItems/AdministratorMenuItem.cs
r15401 r15658 38 38 39 39 public override void Execute() { 40 if (HiveRoles.CheckAdminUserPermissions()) { 40 41 if (HiveRoles.CheckAdminUserPermissions() || HiveAdminClient.Instance.CheckAccessToAdminAreaGranted()) { 41 42 MainFormManager.MainForm.ShowContent(HiveAdminClient.Instance); 42 43 } else if (!UserInformation.Instance.UserExists) { -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs
r15642 r15658 44 44 private readonly HashSet<Resource> inheritedResources = new HashSet<Resource>(); 45 45 private readonly HashSet<Resource> newInheritedResources = new HashSet<Resource>(); 46 47 private readonly Dictionary<Guid, HashSet<Project>> projectAncestors = new Dictionary<Guid, HashSet<Project>>(); 48 private readonly Dictionary<Guid, HashSet<Project>> projectDescendants = new Dictionary<Guid, HashSet<Project>>(); 46 49 private readonly Dictionary<Guid, HashSet<Resource>> resourceAncestors = new Dictionary<Guid, HashSet<Resource>>(); 47 50 private readonly Dictionary<Guid, HashSet<Resource>> resourceDescendants = new Dictionary<Guid, HashSet<Resource>>(); 51 48 52 //private readonly Color addedAssignmentColor = Color.FromArgb(255, 0, 174, 179); // #00aeb3 49 53 private readonly Color addedAssignmentColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1 … … 75 79 detailsViewHost.Content = null; 76 80 } else { 81 UpdateProjectGenealogy(); 77 82 UpdateAssignedResources(); 78 83 UpdateResourceGenealogy(); … … 91 96 92 97 private void refreshButton_Click(object sender, EventArgs e) { 98 UpdateProjectGenealogy(); 93 99 UpdateAssignedResources(); 94 100 UpdateResourceGenealogy(); … … 120 126 private void treeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) { 121 127 var checkedResource = (Resource)e.Node.Tag; 122 if (newInheritedResources.Contains(checkedResource) || checkedResource.Id == Guid.Empty) e.Cancel = true; 128 if (newInheritedResources.Contains(checkedResource) || checkedResource.Id == Guid.Empty) { 129 e.Cancel = true; 130 } else if (!HiveRoles.CheckAdminUserPermissions()) { 131 if (!projectAncestors[Content.Id].Any()) { 132 e.Cancel = true; 133 } 134 } 123 135 } 124 136 … … 285 297 if (newAssignedResources.Contains(newResource)) { 286 298 newNode.Checked = true; 299 if(!HiveRoles.CheckAdminUserPermissions()) { 300 if(!projectAncestors[Content.Id].Any()) { 301 newNode.ForeColor = SystemColors.GrayText; 302 newNode.Text += " [immutable]"; 303 } 304 } 305 287 306 } else if (newInheritedResources.Contains(newResource)) { 288 307 newNode.Checked = true; … … 331 350 } 332 351 333 var ungroupedNode = new TreeNode(ungroupedGroupName) { 334 ForeColor = SystemColors.GrayText, 335 Tag = new SlaveGroup() { 336 Name = ungroupedGroupName, 337 Description = ungroupedGroupDescription 338 } 339 }; 340 341 foreach (var slave in subResources.OfType<Slave>().OrderBy(x => x.Name)) { 342 var slaveNode = new TreeNode(slave.Name) { Tag = slave }; 343 ungroupedNode.Nodes.Add(slaveNode); 344 } 345 346 treeView.Nodes.Add(ungroupedNode); 352 var ungroupedSlaves = subResources.OfType<Slave>().OrderBy(x => x.Name); 353 if(ungroupedSlaves.Any()) { 354 var ungroupedNode = new TreeNode(ungroupedGroupName) { 355 ForeColor = SystemColors.GrayText, 356 Tag = new SlaveGroup() { 357 Name = ungroupedGroupName, 358 Description = ungroupedGroupDescription 359 } 360 }; 361 362 foreach (var slave in ungroupedSlaves) { 363 var slaveNode = new TreeNode(slave.Name) { Tag = slave }; 364 ungroupedNode.Nodes.Add(slaveNode); 365 } 366 treeView.Nodes.Add(ungroupedNode); 367 } 368 347 369 treeView.BeforeCheck += treeView_BeforeCheck; 348 370 treeView.AfterCheck += treeView_AfterCheck; … … 352 374 } 353 375 376 private void UpdateProjectGenealogy() { 377 projectAncestors.Clear(); 378 projectDescendants.Clear(); 379 var projects = HiveAdminClient.Instance.Projects; 380 381 foreach(var p in projects) { 382 projectAncestors.Add(p.Id, new HashSet<Project>()); 383 projectDescendants.Add(p.Id, new HashSet<Project>()); 384 } 385 386 foreach (var p in projects) { 387 var parentProjectId = p.ParentProjectId; 388 while (parentProjectId != null) { 389 var parent = projects.SingleOrDefault(x => x.Id == parentProjectId); 390 if (parent != null) { 391 projectAncestors[p.Id].Add(parent); 392 projectDescendants[parent.Id].Add(p); 393 parentProjectId = parent.ParentProjectId; 394 } else { 395 parentProjectId = null; 396 } 397 } 398 } 399 } 400 354 401 #endregion 355 402 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs
r15627 r15658 270 270 // selectedProject.PropertyChanged += ProjectViewContent_PropertyChanged; 271 271 272 if (IsAuthorized(selectedProject)) {273 if (!tabControl.TabPages.Contains(permissionsTabPage))274 tabControl.TabPages.Add(permissionsTabPage);275 if (!tabControl.TabPages.Contains(resourcesTabPage))276 tabControl.TabPages.Add(resourcesTabPage);277 } else {278 if (tabControl.TabPages.Contains(permissionsTabPage))279 tabControl.TabPages.Remove(permissionsTabPage);280 if (tabControl.TabPages.Contains(resourcesTabPage))281 tabControl.TabPages.Remove(resourcesTabPage);282 }272 //if (IsAuthorized(selectedProject)) { 273 // if (!tabControl.TabPages.Contains(permissionsTabPage)) 274 // tabControl.TabPages.Add(permissionsTabPage); 275 // if (!tabControl.TabPages.Contains(resourcesTabPage)) 276 // tabControl.TabPages.Add(resourcesTabPage); 277 //} else { 278 // if (tabControl.TabPages.Contains(permissionsTabPage)) 279 // tabControl.TabPages.Remove(permissionsTabPage); 280 // if (tabControl.TabPages.Contains(resourcesTabPage)) 281 // tabControl.TabPages.Remove(resourcesTabPage); 282 //} 283 283 } 284 284 … … 416 416 417 417 private bool IsAuthorized(Project project) { 418 return project != null 419 && UserInformation.Instance.UserExists 420 && (project.OwnerUserId == UserInformation.Instance.User.Id || HiveRoles.CheckAdminUserPermissions()); 418 return project != null && UserInformation.Instance.UserExists; 419 //&& (project.OwnerUserId == UserInformation.Instance.User.Id || HiveRoles.CheckAdminUserPermissions()); 421 420 } 422 421 -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r15576 r15658 302 302 303 303 var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null)); 304 var subResources = new HashSet<Resource>(resources.Except(mainResources)); 304 var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() 305 .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value))); 306 mainResources.UnionWith(parentedMainResources); 307 var subResources = new HashSet<Resource>(resources.Except(mainResources).OrderByDescending(x => x.Name)); 305 308 306 309 var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name)); 307 var top = stack.Peek();310 Resource top = null; 308 311 309 312 TreeNode currentNode = null; … … 311 314 312 315 while(stack.Any()) { 316 if (top == null) top = stack.Peek(); 313 317 var newResource = stack.Pop(); 314 318 var newNode = new TreeNode(newResource.Name) { Tag = newResource };
Note: See TracChangeset
for help on using the changeset viewer.