Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report data api #1750

Merged
merged 2 commits into from
Aug 1, 2017
Merged

Report data api #1750

merged 2 commits into from
Aug 1, 2017

Conversation

karelhala
Copy link
Contributor

This is improvement for QE report data (GTL) API, which allows more easily query data on screen and control GTLs more programmatically.

New methods:

  1. (stores) sendDataWithRx({controller: 'reportDataController', action: 'get_current_page'})
    Will store current page number.
  2. (stores) sendDataWithRx({controller: 'reportDataController', action: 'get_pages_amount'})
    Will store number of all items.
  3. (stores) sendDataWithRx({controller: 'reportDataController', action: 'get_items_per_page'})
    Will store number of shown items per page.
  4. sendDataWithRx({controller: 'reportDataController', action: 'set_items_per_page', data: [5]})
    Will change number of records per page, data is array with number of records per page.
  5. sendDataWithRx({controller: 'reportDataController', action: 'set_sorting', data: [{sortBy: 2, isAscending: true}]})
    Will change sort based on given data. sortBy ID of column to sort by, isAscending true|false direction.
  6. (stores) sendDataWithRx({controller: 'reportDataController', action: 'get_sorting'})
    Will store sorting object. sortBy column which is sorted by, sortDir is either ASC or DESC
  7. (stores) sendDataWithRx({controller: 'reportDataController', action: 'get_all_items'})
    Will store all items on screen in given format including helpful methods.
  8. (stores) sendDataWithRx({controller: 'reportDataController', action: 'get_item', data: ['name_or_id']}) data name_or_id can be number or string, since simple comparison (==) is used.
    Will query for item based on name or it's ID property. If record doesn't have name column set it will try to look up based on ID. This item will be stored in given format including helpful methods.

Store result in global scope

If we want to get some information from screen we can call method which will store this result (methods marked as stores) in global scope. We can then access it by calling ManageIQ.qe.gtl.result. Example:
endDataWithRx({controller: 'reportDataController', action: 'get_item', data: ['name_of_record']}) will store found item in ManageIQ.qe.gtl.result and calling ManageIQ.qe.gtl.result.click() will click on such item.

New callback function

If we want to check or play around with stored data we can now pass callback function. Example: sendDataWithRx({controller: 'reportDataController', action: 'get_item', data: ['name_of_record'], eventCallback: function(data) {data.click();}}) this will query GTL to find item with name name_of_record and once data are returned it will click on such item.

Item querying

It is possible to query for all items or to select one item (shown in 7) and 8) point), result will contain not only item, but couple of helpful methods, the result is:

{
  select: function(){},
  unselect: function(){},
  is_selected: function(){},
  click: function(){},
  item: {...}
}

@karelhala
Copy link
Contributor Author

@miq-bot add_label enhancement

@karelhala
Copy link
Contributor Author

@izapolsk, @psav please check on this PR and confirm that you are ok with these methods. Will update corresponding MOJO document once it's merged.

@karelhala karelhala force-pushed the reportDataAPI branch 3 times, most recently from f1acfd2 to 813b2a0 Compare July 26, 2017 12:07
@miq-bot
Copy link
Member

miq-bot commented Jul 27, 2017

Checked commits karelhala/manageiq-ui-classic@bc90985~...86f15a6 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
0 files checked, 0 offenses detected
Everything looks fine. 🏆

@karelhala
Copy link
Contributor Author

@himdel @martinpovolny can you please review this PR? CC complains about == where I need it and some places where is similar code, but we actually need it to be similar.

@martinpovolny martinpovolny merged commit 8629df2 into ManageIQ:master Aug 1, 2017
@martinpovolny martinpovolny added this to the Sprint 66 Ending Aug 7, 2017 milestone Aug 1, 2017
@martinpovolny
Copy link
Member

@karelhala, can you, please, take the description, and put it in a PR against https://github.com/ManageIQ/guides?

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.

4 participants