Skip to content

Configurable UI branding, keyboard list and hide-able columns through a new config.js file#3258

Merged
yadvr merged 4 commits intoapache:masterfrom
shapeblue:configure-hiding-columns
May 30, 2019
Merged

Configurable UI branding, keyboard list and hide-able columns through a new config.js file#3258
yadvr merged 4 commits intoapache:masterfrom
shapeblue:configure-hiding-columns

Conversation

@anuragaw
Copy link
Contributor

@anuragaw anuragaw commented Apr 4, 2019

Description

We want to support hiding selective columns in metrics tables for "users" through a config file so that admins can make the relevant information hidden as per their organization needs.

Current PR code will supports metrics tables but can be extended to any table with minimal work in future. Config file will take the key of the metrics column from metrics.js file for the sake of minimal changes and simplicity of development along with future extension.

(#3217 was merged with this PR)
Problem: The keyboard list in the UI is not consistent across views such as in the instance wizard and in the register template form. There is also no way to customize about url/text and doc title and help URL in the UI.
Root Cause: The list is hardcoded in the UI allowing no centralised configuration.
Solution: Introduce a new config.js file installed at the /usr/share/cloudstackmanagement/webapp/config.js location. The config.js allows configurable keyboard list, about url/text, doc title, and help URL. It will also allow defining which columns need to be hidden.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Screenshots (if appropriate):

How Has This Been Tested?

Testing and further documentation in progress and will be updated with proper notes.

Image with all columns showing up -
unhiddencolumn

Change in config.js file -

// Define custom options configurable by admins for UI
cloudStackOptions = {
    aboutText: "label.app.name", // This is the text shown in the 'About' box
    aboutTitle: "label.about.app", // This is the Application 'Title' shown in the 'About' box
    docTitle: "label.app.name", // This is the Application 'Title' shown on browser tab.

    helpURL: "http://docs.cloudstack.apache.org/", // This is the URL that opens when users click Help
    keyboardOptions: {
        "us": "label.standard.us.keyboard",
        "uk": "label.uk.keyboard",
        "fr": "label.french.azerty.keyboard",
        "jp": "label.japanese.keyboard",
        "sc": "label.simplified.chinese.keyboard"
    },
    hiddenFields: {
        "metrics.zones":[], // Options - "name", "state", "clusters", "cpuused", "cpuallocated", "memused", "memallocated"
        "metrics.clusters": [], // Options - "name", "state", "hosts", "cpuused", "cpuallocated", "memused", "memallocated"
        "metrics.hosts": [], // Options - "name", "state", "powerstate", "instances", "cpuused", "memused", "network"
        "metrics.storagepool": [], // Options - "name", "property", "disk",
        "metrics.instances": ["memused"], // Options - "name", "state", "ipaddress", "zonename", "cpuused", "memused", "network", "disk"
        "metrics.volumes": [] // Options - "name", "state", "vmname", "sizegb", "physicalsize", "utilization", "storagetype", "storage"
    }
};

View after change in config file -
hiddencolumn

Post Merge Update:

Please note that Admins can still see all information and only Users cannot see the columns that are specified. Consequently metrics tables that users don't see have no relevance in the config file. These include zone, clusters, hosts.

This introduces a new UI `config.js` file using which the UI could be
configured by the admin from a single config/js file.

In the first commit this allows for easy configuration of list of
keyboards.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
@yadvr
Copy link
Member

yadvr commented Apr 4, 2019

At some point, let's merge this with PR #3217 otherwise this will lead to merge conflicts for related features extending/using config.js

@anuragaw anuragaw force-pushed the configure-hiding-columns branch from abd0f19 to d43d696 Compare April 4, 2019 10:57
@anuragaw
Copy link
Contributor Author

anuragaw commented Apr 4, 2019

@blueorangutan package

@blueorangutan
Copy link

@anuragaw a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2678

@yadvr
Copy link
Member

yadvr commented Apr 5, 2019

Put some after-loaded method/js file that does something looping over sections minimizing changes to the listview/widget/library:

            $.each(cloudStack.sections, function(idx, section) {                   
                if (section.listView) {                                            
                    section.listView.preFilter = function(args) {                  
                        const original = section.listView.preFilter(args);         
                        return ['name'] + original;                                                                                                                     
                    };                                                             
                    console.log(Object.keys(section.listView.fields));             
                }                                                                  
            }); 

@yadvr
Copy link
Member

yadvr commented Apr 5, 2019

Closed #3217 in favour of this one

This helps brands in setting up relevant resources in their deployement.
@anuragaw anuragaw force-pushed the configure-hiding-columns branch from 21a052e to 924e4da Compare April 9, 2019 08:03
We want users to be able to hide some columns in metrics tables
that may not be necessary for their organizations. The current
commit will start supporting metrics table and it can be extended
to any table with similar logic

Added all options to the config file for ease of use
@anuragaw anuragaw force-pushed the configure-hiding-columns branch from 924e4da to 37abd92 Compare April 9, 2019 08:11
@@ -860,6 +860,8 @@
if (groupableColumns) {
$tr.addClass('groupable-header-columns').addClass('groupable-header');
$.each(fields, function(key) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was broken in existing code and needed fixing. If an upper field is hidden we must not draw it's containing columns.

@anuragaw
Copy link
Contributor Author

anuragaw commented Apr 9, 2019

@rhtyd I have updated the PR with the changes we discussed.

@yadvr yadvr changed the title [WIP DO NOT MERGE] Configure hiding table columns through config.js file [WIP DO NOT MERGE] Configurable UI branding, keyboard list and hide-able columns through a new config.js file Apr 10, 2019
@borisstoyanov
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@borisstoyanov a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2708

Copy link
Contributor

@borisstoyanov borisstoyanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, manually checked all the changes

Copy link
Member

@PaulAngus PaulAngus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Background: show/hide column feature enables cloud operator to hide 'sensitive' infrastructure data from users.

  • Columns hidden from users are also hidden from administrator

Consolidation of keyboard types:

  • keyboard list on console proxy does not reflect the configured (in config.js) keyboard types.

@anuragaw
Copy link
Contributor Author

anuragaw commented May 1, 2019

@PaulAngus - addressed all the comments in the latest commit. There are 5 keyboards specified in the config.js. I get first 4 of them. I wanted to confirm if the keyboard options you get were only missing "Simplified Chinese Keyboard" or any more?

@yadvr
Copy link
Member

yadvr commented May 23, 2019

@blueorangutan package

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2765

@yadvr yadvr changed the title [WIP DO NOT MERGE] Configurable UI branding, keyboard list and hide-able columns through a new config.js file Configurable UI branding, keyboard list and hide-able columns through a new config.js file May 30, 2019
@yadvr
Copy link
Member

yadvr commented May 30, 2019

Purely UI changes, merging based on tests and reviews.

@yadvr yadvr merged commit 3bf4e5c into apache:master May 30, 2019
@anuragaw
Copy link
Contributor Author

Created PR #3429 to clean up config file with redundant columns.

yadvr pushed a commit that referenced this pull request Jun 27, 2019
This is a purely documentation change of config file.
The cleanup was needed post merge of PR #3258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants