Changeset 16202
- Timestamp:
- 10/01/18 15:14:44 (6 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Clients.Hive.Administrator/3.3/Views/HiveAdministratorView.Designer.cs
r16117 r16202 29 29 this.components = new System.ComponentModel.Container(); 30 30 this.tabAdmin = new System.Windows.Forms.TabControl(); 31 this.tab Slaves = new System.Windows.Forms.TabPage();31 this.tabResources = new System.Windows.Forms.TabPage(); 32 32 this.resourcesView = new HeuristicLab.Clients.Hive.Administrator.Views.ResourcesView(); 33 this.tabP age1= new System.Windows.Forms.TabPage();33 this.tabProjects = new System.Windows.Forms.TabPage(); 34 34 this.imageListUsers = new System.Windows.Forms.ImageList(this.components); 35 35 this.projectsView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectsView(); 36 36 this.tabAdmin.SuspendLayout(); 37 this.tab Slaves.SuspendLayout();38 this.tabP age1.SuspendLayout();37 this.tabResources.SuspendLayout(); 38 this.tabProjects.SuspendLayout(); 39 39 this.SuspendLayout(); 40 40 // … … 44 44 | System.Windows.Forms.AnchorStyles.Left) 45 45 | System.Windows.Forms.AnchorStyles.Right))); 46 this.tabAdmin.Controls.Add(this.tab Slaves);47 this.tabAdmin.Controls.Add(this.tabP age1);46 this.tabAdmin.Controls.Add(this.tabResources); 47 this.tabAdmin.Controls.Add(this.tabProjects); 48 48 this.tabAdmin.Location = new System.Drawing.Point(3, 0); 49 49 this.tabAdmin.Name = "tabAdmin"; … … 52 52 this.tabAdmin.TabIndex = 0; 53 53 // 54 // tab Slaves54 // tabResources 55 55 // 56 this.tab Slaves.Controls.Add(this.resourcesView);57 this.tab Slaves.Location = new System.Drawing.Point(4, 22);58 this.tab Slaves.Name = "tabSlaves";59 this.tab Slaves.Padding = new System.Windows.Forms.Padding(3);60 this.tab Slaves.Size = new System.Drawing.Size(734, 520);61 this.tab Slaves.TabIndex = 3;62 this.tab Slaves.Text = "Slaves";63 this.tab Slaves.UseVisualStyleBackColor = true;56 this.tabResources.Controls.Add(this.resourcesView); 57 this.tabResources.Location = new System.Drawing.Point(4, 22); 58 this.tabResources.Name = "tabResources"; 59 this.tabResources.Padding = new System.Windows.Forms.Padding(3); 60 this.tabResources.Size = new System.Drawing.Size(734, 520); 61 this.tabResources.TabIndex = 3; 62 this.tabResources.Text = "Resources"; 63 this.tabResources.UseVisualStyleBackColor = true; 64 64 // 65 65 // resourcesView … … 76 76 this.resourcesView.TabIndex = 0; 77 77 // 78 // tabP age178 // tabProjects 79 79 // 80 this.tabP age1.Controls.Add(this.projectsView);81 this.tabP age1.Location = new System.Drawing.Point(4, 22);82 this.tabP age1.Name = "tabPage1";83 this.tabP age1.Size = new System.Drawing.Size(734, 520);84 this.tabP age1.TabIndex = 4;85 this.tabP age1.Text = "Projects";86 this.tabP age1.UseVisualStyleBackColor = true;80 this.tabProjects.Controls.Add(this.projectsView); 81 this.tabProjects.Location = new System.Drawing.Point(4, 22); 82 this.tabProjects.Name = "tabProjects"; 83 this.tabProjects.Size = new System.Drawing.Size(734, 520); 84 this.tabProjects.TabIndex = 4; 85 this.tabProjects.Text = "Projects"; 86 this.tabProjects.UseVisualStyleBackColor = true; 87 87 // 88 88 // imageListUsers … … 112 112 this.Size = new System.Drawing.Size(745, 546); 113 113 this.tabAdmin.ResumeLayout(false); 114 this.tab Slaves.ResumeLayout(false);115 this.tabP age1.ResumeLayout(false);114 this.tabResources.ResumeLayout(false); 115 this.tabProjects.ResumeLayout(false); 116 116 this.ResumeLayout(false); 117 117 … … 122 122 private System.ComponentModel.IContainer components; 123 123 private System.Windows.Forms.ImageList imageListUsers; 124 private System.Windows.Forms.TabPage tab Slaves;125 private System.Windows.Forms.TabPage tabP age1;124 private System.Windows.Forms.TabPage tabResources; 125 private System.Windows.Forms.TabPage tabProjects; 126 126 private ProjectsView projectsView; 127 127 } -
trunk/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs
r16117 r16202 86 86 UpdateAssignedResources(); 87 87 UpdateIncludedResources(); 88 var top = BuildResourceTree(); 89 detailsViewHost.Content = top; 90 detailsViewHost.Locked = true; 91 } 88 detailsViewHost.Content = BuildResourceTree(); 89 } 90 SetEnabledStateOfControls(); 92 91 } 93 92 … … 99 98 saveButton.Enabled = enabled; 100 99 treeView.Enabled = enabled; 100 101 if (detailsViewHost != null) { 102 detailsViewHost.Locked = true; 103 } 101 104 } 102 105 #endregion -
trunk/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs
r16185 r16202 118 118 endDateTimePicker.Enabled = !indefiniteCheckBox.Checked; 119 119 } 120 SetEnabledStateOfControls(); 120 121 RegisterControlEvents(); 121 122 } … … 141 142 } 142 143 143 if ( !IsAdmin() && !HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)) {144 if (Content.Id != Guid.Empty && !IsAdmin() && !HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)) { 144 145 ownerComboBox.Enabled = false; 145 146 startDateTimePicker.Enabled = false; -
trunk/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs
r16185 r16202 43 43 private const string NOT_STORED_TAG = "*"; // " [not stored]"; 44 44 private const string CHANGES_NOT_STORED_TAG = "*"; // " [changes not stored]"; 45 private const string INACTIVE_TAG = " [inactive]"; 45 46 46 47 private readonly Color selectedBackColor = Color.DodgerBlue; … … 476 477 if (HiveAdminClient.Instance.DisabledParentProjects.Select(x => x.Id).Contains(p.Id)) { 477 478 n.ForeColor = grayTextColor; 478 } else if (p.Id == Guid.Empty) { 479 n.Text += NOT_STORED_TAG; 480 } else if (p.Modified) { 481 n.Text += CHANGES_NOT_STORED_TAG; 479 } else { 480 if (p.Id == Guid.Empty) { 481 n.Text += NOT_STORED_TAG; 482 } else if (p.Modified) { 483 n.Text += CHANGES_NOT_STORED_TAG; 484 } 485 486 if (!IsActive(p)) { 487 n.ForeColor = grayTextColor; 488 n.Text += INACTIVE_TAG; 489 } 482 490 } 483 491 } … … 536 544 } 537 545 546 private bool IsActive(Project project) { 547 return DateTime.Now >= project.StartDate 548 && (project.EndDate == null 549 || DateTime.Now < project.EndDate.Value); 550 } 551 538 552 private bool IsAuthorized(Project project) { 539 553 return project != null && UserInformation.Instance.UserExists; -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r16117 r16202 263 263 var node = resourcesTreeView.GetNodeAt(new Point(e.X, e.Y)); 264 264 265 if (node == null || node == additionalNode) {265 if (node == null && e.Button == MouseButtons.Left) { 266 266 resourcesTreeView.SelectedNode = null; 267 267 ExtractStatistics(); 268 } else {269 var r = (Resource)node.Tag;270 if (!HiveClient.Instance.DisabledParentResources.Contains(r)) {271 ExtractStatistics((Resource)node.Tag);272 } else {273 resourcesTreeView.SelectedNode = null;274 ExtractStatistics();275 }276 268 } 277 269 } 278 270 279 271 private void resourcesTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) { 280 if(e.Node == null || e.Node == additionalNode) { 272 if(e.Node == null) { 273 e.Cancel = true; 274 resourcesTreeView.SelectedNode = null; 275 ExtractStatistics(); 276 } else if (e.Node == additionalNode) { 281 277 e.Cancel = true; 282 278 } else { 283 279 var r = (Resource)e.Node.Tag; 284 if(r == null || HiveClient.Instance.DisabledParentResources.Contains(r)) { 280 if(r != null && !HiveClient.Instance.DisabledParentResources.Contains(r)) { 281 ExtractStatistics(r); 282 } else { 285 283 e.Cancel = true; 286 284 } … … 299 297 || newIncludedResources.Contains(checkedResource)) { 300 298 e.Cancel = true; 301 302 var selectedNode = resourcesTreeView.SelectedNode;303 var selectedResource = (Resource)(selectedNode != null ? selectedNode.Tag : null);304 305 ExtractStatistics(selectedResource);306 299 } 307 300 } … … 317 310 318 311 UpdateResourceTreeAfterCheck(); 319 ExtractStatistics(); 312 if(resourcesTreeView.SelectedNode == null) 313 ExtractStatistics(); 320 314 OnAssignedResourcesChanged(); 321 315 } … … 548 542 resourcesTreeView.AfterCheck -= resourcesTreeView_AfterCheck; 549 543 550 var disabledParentResources = HiveClient.Instance.DisabledParentResources; 544 //var disabledParentResources = HiveClient.Instance.DisabledParentResources; 545 var disabledParentResources = HiveClient.Instance.GetDisabledResourceAncestors(resources); 551 546 var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null)); 552 547 //var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() -
trunk/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs
r16117 r16202 26 26 using System.Collections.Generic; 27 27 using System.Linq; 28 using HeuristicLab.Clients.Access; 28 29 29 30 namespace HeuristicLab.Clients.Hive { … … 438 439 } 439 440 441 public IEnumerable<Resource> GetDisabledResourceAncestors(IEnumerable<Resource> availableResources) { 442 var missingParentIds = availableResources 443 .Where(x => x.ParentResourceId.HasValue) 444 .SelectMany(x => resourceAncestors[x.Id]).Distinct() 445 .Where(x => !availableResources.Select(y => y.Id).Contains(x)); 446 447 return resources.OfType<SlaveGroup>().Union(disabledParentResources).Where(x => missingParentIds.Contains(x.Id)); 448 } 449 440 450 public bool CheckAccessToAdminAreaGranted() { 441 451 if(projects != null) { … … 478 488 479 489 if(projectAncestors.ContainsKey(pro.Id)) { 480 return GetAvailableProjectAncestors(pro.Id).Where(x => x.OwnerUserId == userId).Any(); 490 return GetAvailableProjectAncestors(pro.Id).Any(x => x.OwnerUserId == userId); 491 } 492 493 if (pro.ParentProjectId != null && pro.ParentProjectId != Guid.Empty) { 494 var parent = projects.FirstOrDefault(x => x.Id == pro.ParentProjectId.Value); 495 if (parent != null) 496 return parent.OwnerUserId == userId || GetAvailableProjectAncestors(parent.Id).Any(x => x.OwnerUserId == userId); 481 497 } 482 498 … … 491 507 // ... or the new parent is not stored yet 492 508 // ... or there is not parental change 493 if (child == null 494 || (parent != null && parent.Id == Guid.Empty) 495 || (parent != null && parent.Id == child.ParentProjectId)) { 509 if (child == null 510 || (parent != null && parent.Id == Guid.Empty) 511 || (parent != null && parent.Id == child.ParentProjectId)) { 512 changePossible = false; 513 } else if (parent == null && !IsAdmin()) { 514 // ... if parent is null, but user is no admin (only admins are allowed to create root projects) 515 changePossible = false; 516 } else if (parent != null && (!IsAdmin() && parent.OwnerUserId != UserInformation.Instance.User.Id && !CheckOwnershipOfParentProject(parent, UserInformation.Instance.User.Id))) { 517 // ... if the user is no admin nor owner of the new parent or grand..grandparents 496 518 changePossible = false; 497 519 } else if(parent != null && projectDescendants.ContainsKey(child.Id)) { … … 525 547 return changePossible; 526 548 } 549 550 private bool IsAdmin() { 551 return HiveRoles.CheckAdminUserPermissions(); 552 } 527 553 #endregion 528 554 } -
trunk/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r16117 r16202 324 324 return resources.Where(x => assignedProjectResources.Select(y => y.ResourceId).Contains(x.Id)); 325 325 } 326 327 public IEnumerable<Resource> GetDisabledResourceAncestors(IEnumerable<Resource> availableResources) { 328 var missingParentIds = availableResources 329 .Where(x => x.ParentResourceId.HasValue) 330 .SelectMany(x => resourceAncestors[x.Id]).Distinct() 331 .Where(x => !availableResources.Select(y => y.Id).Contains(x)); 332 333 return resources.OfType<SlaveGroup>().Union(disabledParentResources).Where(x => missingParentIds.Contains(x.Id)); 334 } 326 335 #endregion 327 336
Note: See TracChangeset
for help on using the changeset viewer.