-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
webadmin: add Account Settings sub-tab
Add a new sub-tab under Administration -> Users -> {user} that allows viewing user settings. The settings are displayed unformated as JSON or plain text depending on the property type. Only remove operation is supported. Main use case is troubleshooting problems related to user settings. With the new view, the admin is able to restore the default configuration by removing incorrect user properties.
- Loading branch information
Showing
13 changed files
with
352 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...rc/main/java/org/ovirt/engine/ui/common/widget/uicommon/users/UserSettingsModelTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.ovirt.engine.ui.common.widget.uicommon.users; | ||
|
||
import org.ovirt.engine.core.common.businessentities.UserProfileProperty; | ||
import org.ovirt.engine.core.common.businessentities.aaa.DbUser; | ||
import org.ovirt.engine.ui.common.CommonApplicationConstants; | ||
import org.ovirt.engine.ui.common.gin.AssetProvider; | ||
import org.ovirt.engine.ui.common.presenter.DetailActionPanelPresenterWidget; | ||
import org.ovirt.engine.ui.common.system.ClientStorage; | ||
import org.ovirt.engine.ui.common.uicommon.model.SearchableTableModelProvider; | ||
import org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn; | ||
import org.ovirt.engine.ui.common.widget.uicommon.AbstractModelBoundTableWidget; | ||
import org.ovirt.engine.ui.uicommonweb.models.users.UserListModel; | ||
import org.ovirt.engine.ui.uicommonweb.models.users.UserSettingsModel; | ||
|
||
import com.google.gwt.event.shared.EventBus; | ||
|
||
public class UserSettingsModelTable extends AbstractModelBoundTableWidget<DbUser, UserProfileProperty, UserSettingsModel> { | ||
|
||
private static final CommonApplicationConstants constants = AssetProvider.getConstants(); | ||
|
||
public UserSettingsModelTable(SearchableTableModelProvider<UserProfileProperty, UserSettingsModel> modelProvider, | ||
EventBus eventBus, | ||
DetailActionPanelPresenterWidget<DbUser, UserProfileProperty, UserListModel, UserSettingsModel> actionPanel, | ||
ClientStorage clientStorage) { | ||
super(modelProvider, eventBus, actionPanel, clientStorage, false); | ||
} | ||
|
||
@Override | ||
public void initTable() { | ||
getTable().enableColumnResizing(); | ||
|
||
AbstractTextColumn<UserProfileProperty> nameColumn = new AbstractTextColumn<UserProfileProperty>() { | ||
@Override | ||
public String getValue(UserProfileProperty property) { | ||
return property.getName(); | ||
} | ||
}; | ||
nameColumn.makeSortable(); | ||
getTable().addColumn(nameColumn, constants.name(), "200px"); //$NON-NLS-1$ | ||
|
||
AbstractTextColumn<UserProfileProperty> idColumn = new AbstractTextColumn<UserProfileProperty>() { | ||
@Override | ||
public String getValue(UserProfileProperty property) { | ||
return property.getPropertyId().toString(); | ||
} | ||
}; | ||
getTable().addColumn(idColumn, constants.propertyId(), "250px"); //$NON-NLS-1$ | ||
|
||
AbstractTextColumn<UserProfileProperty> typeColumn = new AbstractTextColumn<UserProfileProperty>() { | ||
@Override | ||
public String getValue(UserProfileProperty property) { | ||
return property.getType().name(); | ||
} | ||
}; | ||
typeColumn.makeSortable(); | ||
getTable().addColumn(typeColumn, constants.typePermission(), "110px"); //$NON-NLS-1$ | ||
|
||
AbstractTextColumn<UserProfileProperty> contentColumn = new AbstractTextColumn<UserProfileProperty>() { | ||
@Override | ||
public String getValue(UserProfileProperty property) { | ||
return property.getContent(); | ||
} | ||
}; | ||
getTable().addColumn(contentColumn, constants.contentDisk(), "50%"); //$NON-NLS-1$ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
...mmonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/users/UserSettingsModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package org.ovirt.engine.ui.uicommonweb.models.users; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
import org.ovirt.engine.core.common.businessentities.UserProfileProperty; | ||
import org.ovirt.engine.core.common.businessentities.aaa.DbUser; | ||
import org.ovirt.engine.core.common.queries.QueryType; | ||
import org.ovirt.engine.core.common.queries.UserProfilePropertyIdQueryParameters; | ||
import org.ovirt.engine.ui.frontend.Frontend; | ||
import org.ovirt.engine.ui.frontend.NotificationStatus; | ||
import org.ovirt.engine.ui.frontend.UserProfileManager; | ||
import org.ovirt.engine.ui.uicommonweb.BaseCommandTarget; | ||
import org.ovirt.engine.ui.uicommonweb.UICommand; | ||
import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel; | ||
import org.ovirt.engine.ui.uicompat.ConstantsManager; | ||
import org.ovirt.engine.ui.uicompat.UIConstants; | ||
|
||
public class UserSettingsModel extends SearchableListModel<DbUser, UserProfileProperty> { | ||
|
||
private static final UIConstants constants = ConstantsManager.getInstance().getConstants(); | ||
|
||
private final UICommand removeCommand; | ||
|
||
public UserSettingsModel() { | ||
setTitle(ConstantsManager.getInstance().getConstants().accountSettings()); | ||
setHashName("user_settings"); //$NON-NLS-1$ | ||
|
||
removeCommand = new UICommand("Remove", new BaseCommandTarget() {//$NON-NLS-1$ | ||
@Override | ||
public void executeCommand(UICommand uiCommand) { | ||
removeUserProfileProperty(); | ||
} | ||
}); | ||
|
||
updateActionAvailability(); | ||
} | ||
|
||
private void removeUserProfileProperty() { | ||
List<UserProfileProperty> selected = getSelectedItems(); | ||
if (selected == null || selected.isEmpty()) { | ||
return; | ||
} | ||
|
||
List<Boolean> results = new ArrayList<>(); | ||
Consumer<Boolean> markAsDone = result -> { | ||
results.add(result); | ||
if (results.size() >= selected.size()) { | ||
syncSearch(); | ||
} | ||
}; | ||
|
||
for (UserProfileProperty prop : selected) { | ||
Frontend.getInstance() | ||
.getUserProfileManager() | ||
.deleteProperty( | ||
prop, | ||
property -> markAsDone.accept(true), | ||
error -> { | ||
String validationMessage = | ||
String.join("\n", error.getReturnValue().getValidationMessages()); //$NON-NLS-1$ | ||
String faultMessage = error.getReturnValue().getFault().getMessage(); | ||
String toastMessage = error.getReturnValue().isValid() ? faultMessage | ||
: validationMessage.isEmpty() ? constants.noValidateMessage() | ||
: validationMessage; | ||
Frontend.getInstance() | ||
.showToast( | ||
toastMessage, | ||
NotificationStatus.DANGER); | ||
markAsDone.accept(false); | ||
}, | ||
(remote, local) -> UserProfileManager.BaseConflictResolutionStrategy.REPORT_ERROR, | ||
this, | ||
false); | ||
} | ||
} | ||
|
||
private void updateActionAvailability() { | ||
getRemoveCommand().setIsExecutionAllowed(getSelectedItems() != null && getSelectedItems().size() > 0); | ||
} | ||
|
||
public UICommand getRemoveCommand() { | ||
return removeCommand; | ||
} | ||
|
||
@Override | ||
protected String getListName() { | ||
return "UserSettingsModel"; //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
protected void onEntityChanged() { | ||
super.onEntityChanged(); | ||
|
||
getSearchCommand().execute(); | ||
updateActionAvailability(); | ||
} | ||
|
||
@Override | ||
protected void syncSearch() { | ||
DbUser user = getEntity(); | ||
if (user != null) { | ||
super.syncSearch(QueryType.GetUserProfilePropertiesByUserId, | ||
new UserProfilePropertyIdQueryParameters(user.getId(), null)); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onSelectedItemChanged() { | ||
super.onSelectedItemChanged(); | ||
updateActionAvailability(); | ||
} | ||
|
||
@Override | ||
protected void selectedItemsChanged() { | ||
super.selectedItemsChanged(); | ||
updateActionAvailability(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.