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

Add available product features local storage. #4756

Merged
merged 1 commit into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion app/assets/javascripts/miq_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,16 @@ function miqEnterPressed(e) {
return (keycode === 13);
}

function storeUserFeatures() {
delete window.localStorage.userFeatures;
return window.http.get('/api?attributes=identity')
.then(function(data) {
window.localStorage.userFeatures = JSON.stringify(data.identity.miq_groups.find(function(group) {
return data.identity.group === group.description;
}).product_features);
});
}

// Send login authentication via ajax
function miqAjaxAuth(url) {
miqEnableLoginFields(false);
Expand All @@ -696,6 +706,9 @@ function miqAjaxAuth(url) {
.then(function() {
return vanillaJsAPI.ws_init();
})
.then(function() {
return storeUserFeatures();
})
.then(function() {
// API login ok, now do the normal one
miqJqueryRequest(url || '/dashboard/authenticate', {
Expand Down Expand Up @@ -980,7 +993,7 @@ function miqShowAE_Tree(typ) {

// Toggle the user options div in the page header
function miqToggleUserOptions(id) {
miqJqueryRequest(miqPassFields('/dashboard/change_group', {to_group: id}));
miqJqueryRequest(miqPassFields('/dashboard/change_group', {to_group: id}), { done: storeUserFeatures });
}

// Check for enter/escape on quick search box
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/http_api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ API.ws_destroy = function() {
};

API.logout = function() {
// delete user allowed features data from local storage
delete localStorage.userFeatures;
if (localStorage.miq_token) {
API.delete('/api/auth', {
skipErrors: [401],
Expand Down