Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16202


Ignore:
Timestamp:
10/01/18 15:14:44 (6 years ago)
Author:
jzenisek
Message:

#2839: fixed several bugs:

  • renamed tab "Slaves" to "Resources"
  • fixed bugs in job manager > resource selector reported by fholzinger
  • adapted client-side handling of disabled resource ancestors
  • adapted parentship check in HiveAdminClient
  • adapted seting of enabled state of controls for project details, project resources
  • introduced "inactive" tag in ProjectsView
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Clients.Hive.Administrator/3.3/Views/HiveAdministratorView.Designer.cs

    r16117 r16202  
    2929      this.components = new System.ComponentModel.Container();
    3030      this.tabAdmin = new System.Windows.Forms.TabControl();
    31       this.tabSlaves = new System.Windows.Forms.TabPage();
     31      this.tabResources = new System.Windows.Forms.TabPage();
    3232      this.resourcesView = new HeuristicLab.Clients.Hive.Administrator.Views.ResourcesView();
    33       this.tabPage1 = new System.Windows.Forms.TabPage();
     33      this.tabProjects = new System.Windows.Forms.TabPage();
    3434      this.imageListUsers = new System.Windows.Forms.ImageList(this.components);
    3535      this.projectsView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectsView();
    3636      this.tabAdmin.SuspendLayout();
    37       this.tabSlaves.SuspendLayout();
    38       this.tabPage1.SuspendLayout();
     37      this.tabResources.SuspendLayout();
     38      this.tabProjects.SuspendLayout();
    3939      this.SuspendLayout();
    4040      //
     
    4444            | System.Windows.Forms.AnchorStyles.Left)
    4545            | System.Windows.Forms.AnchorStyles.Right)));
    46       this.tabAdmin.Controls.Add(this.tabSlaves);
    47       this.tabAdmin.Controls.Add(this.tabPage1);
     46      this.tabAdmin.Controls.Add(this.tabResources);
     47      this.tabAdmin.Controls.Add(this.tabProjects);
    4848      this.tabAdmin.Location = new System.Drawing.Point(3, 0);
    4949      this.tabAdmin.Name = "tabAdmin";
     
    5252      this.tabAdmin.TabIndex = 0;
    5353      //
    54       // tabSlaves
     54      // tabResources
    5555      //
    56       this.tabSlaves.Controls.Add(this.resourcesView);
    57       this.tabSlaves.Location = new System.Drawing.Point(4, 22);
    58       this.tabSlaves.Name = "tabSlaves";
    59       this.tabSlaves.Padding = new System.Windows.Forms.Padding(3);
    60       this.tabSlaves.Size = new System.Drawing.Size(734, 520);
    61       this.tabSlaves.TabIndex = 3;
    62       this.tabSlaves.Text = "Slaves";
    63       this.tabSlaves.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;
    6464      //
    6565      // resourcesView
     
    7676      this.resourcesView.TabIndex = 0;
    7777      //
    78       // tabPage1
     78      // tabProjects
    7979      //
    80       this.tabPage1.Controls.Add(this.projectsView);
    81       this.tabPage1.Location = new System.Drawing.Point(4, 22);
    82       this.tabPage1.Name = "tabPage1";
    83       this.tabPage1.Size = new System.Drawing.Size(734, 520);
    84       this.tabPage1.TabIndex = 4;
    85       this.tabPage1.Text = "Projects";
    86       this.tabPage1.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;
    8787      //
    8888      // imageListUsers
     
    112112      this.Size = new System.Drawing.Size(745, 546);
    113113      this.tabAdmin.ResumeLayout(false);
    114       this.tabSlaves.ResumeLayout(false);
    115       this.tabPage1.ResumeLayout(false);
     114      this.tabResources.ResumeLayout(false);
     115      this.tabProjects.ResumeLayout(false);
    116116      this.ResumeLayout(false);
    117117
     
    122122    private System.ComponentModel.IContainer components;
    123123    private System.Windows.Forms.ImageList imageListUsers;
    124     private System.Windows.Forms.TabPage tabSlaves;
    125     private System.Windows.Forms.TabPage tabPage1;
     124    private System.Windows.Forms.TabPage tabResources;
     125    private System.Windows.Forms.TabPage tabProjects;
    126126    private ProjectsView projectsView;
    127127  }
  • trunk/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs

    r16117 r16202  
    8686        UpdateAssignedResources();
    8787        UpdateIncludedResources();
    88         var top = BuildResourceTree();
    89         detailsViewHost.Content = top;
    90         detailsViewHost.Locked = true;
    91       }
     88        detailsViewHost.Content = BuildResourceTree();
     89      }
     90      SetEnabledStateOfControls();
    9291    }
    9392
     
    9998      saveButton.Enabled = enabled;
    10099      treeView.Enabled = enabled;
     100
     101      if (detailsViewHost != null) {
     102        detailsViewHost.Locked = true;
     103      }
    101104    }
    102105    #endregion
  • trunk/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs

    r16185 r16202  
    118118        endDateTimePicker.Enabled = !indefiniteCheckBox.Checked;
    119119      }
     120      SetEnabledStateOfControls();
    120121      RegisterControlEvents();
    121122    }
     
    141142        }
    142143
    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)) {
    144145          ownerComboBox.Enabled = false;
    145146          startDateTimePicker.Enabled = false;
  • trunk/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r16185 r16202  
    4343    private const string NOT_STORED_TAG = "*"; // " [not stored]";
    4444    private const string CHANGES_NOT_STORED_TAG = "*"; // " [changes not stored]";
     45    private const string INACTIVE_TAG = " [inactive]";
    4546
    4647    private readonly Color selectedBackColor = Color.DodgerBlue;
     
    476477      if (HiveAdminClient.Instance.DisabledParentProjects.Select(x => x.Id).Contains(p.Id)) {
    477478        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        }
    482490      }
    483491    }
     
    536544    }
    537545
     546    private bool IsActive(Project project) {
     547      return DateTime.Now >= project.StartDate
     548             && (project.EndDate == null
     549                 || DateTime.Now < project.EndDate.Value);
     550    }
     551
    538552    private bool IsAuthorized(Project project) {
    539553      return project != null && UserInformation.Instance.UserExists;
  • trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r16117 r16202  
    263263      var node = resourcesTreeView.GetNodeAt(new Point(e.X, e.Y));
    264264
    265       if (node == null || node == additionalNode) {
     265      if (node == null && e.Button == MouseButtons.Left) {
    266266        resourcesTreeView.SelectedNode = null;
    267267        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         }
    276268      }
    277269    }
    278270
    279271    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) {
    281277        e.Cancel = true;
    282278      } else {
    283279        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 {
    285283          e.Cancel = true;
    286284        }
     
    299297          || newIncludedResources.Contains(checkedResource)) {
    300298          e.Cancel = true;
    301 
    302           var selectedNode = resourcesTreeView.SelectedNode;
    303           var selectedResource = (Resource)(selectedNode != null ? selectedNode.Tag : null);
    304 
    305           ExtractStatistics(selectedResource);
    306299        }
    307300      }
     
    317310
    318311      UpdateResourceTreeAfterCheck();
    319       ExtractStatistics();
     312      if(resourcesTreeView.SelectedNode == null)
     313        ExtractStatistics();
    320314      OnAssignedResourcesChanged();
    321315    }
     
    548542      resourcesTreeView.AfterCheck -= resourcesTreeView_AfterCheck;
    549543
    550       var disabledParentResources = HiveClient.Instance.DisabledParentResources;
     544      //var disabledParentResources = HiveClient.Instance.DisabledParentResources;
     545      var disabledParentResources = HiveClient.Instance.GetDisabledResourceAncestors(resources);
    551546      var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null));
    552547      //var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>()
  • trunk/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs

    r16117 r16202  
    2626using System.Collections.Generic;
    2727using System.Linq;
     28using HeuristicLab.Clients.Access;
    2829
    2930namespace HeuristicLab.Clients.Hive {
     
    438439    }
    439440
     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
    440450    public bool CheckAccessToAdminAreaGranted() {
    441451      if(projects != null) {
     
    478488
    479489      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);
    481497      }
    482498
     
    491507      // ... or the new parent is not stored yet
    492508      // ... 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
    496518        changePossible = false;
    497519      } else if(parent != null && projectDescendants.ContainsKey(child.Id)) {
     
    525547      return changePossible;
    526548    }
     549
     550    private bool IsAdmin() {
     551      return HiveRoles.CheckAdminUserPermissions();
     552    }
    527553    #endregion
    528554  }
  • trunk/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r16117 r16202  
    324324      return resources.Where(x => assignedProjectResources.Select(y => y.ResourceId).Contains(x.Id));
    325325    }
     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    }
    326335    #endregion
    327336
Note: See TracChangeset for help on using the changeset viewer.