use of cz.metacentrum.perun.webgui.model.Service in project perun by CESNET.
the class GetServicesBlockedOnFacility method onFinished.
/**
* Called when loading successfully finishes.
*/
public void onFinished(JavaScriptObject jso) {
for (Service e : JsonUtils.<Service>jsoAsList(jso)) {
e.setLocalEnabled("Disabled");
addToTable(e);
}
sortTable();
loaderImage.loadingFinished();
session.getUiElements().setLogText("Services loaded: " + list.size());
events.onFinished(jso);
}
use of cz.metacentrum.perun.webgui.model.Service in project perun by CESNET.
the class GetServicesFromServicesPackage method filterTable.
@Override
public void filterTable(String filter) {
// store list only for first time
if (backupList.isEmpty() || backupList == null) {
backupList.addAll(list);
}
// always clear selected items
selectionModel.clear();
list.clear();
if (filter.equalsIgnoreCase("")) {
list.addAll(backupList);
} else {
for (Service s : backupList) {
// store facility by filter
if (s.getName().toLowerCase().startsWith(filter.toLowerCase())) {
list.add(s);
}
}
}
dataProvider.flush();
dataProvider.refresh();
loaderImage.loadingFinished();
}
use of cz.metacentrum.perun.webgui.model.Service in project perun by CESNET.
the class GetAssignedServices method filterTable.
public void filterTable(String text) {
// store list only for first time
if (fullBackup.isEmpty() || fullBackup == null) {
fullBackup.addAll(list);
}
// always clear selected items
selectionModel.clear();
list.clear();
if (text.equalsIgnoreCase("")) {
list.addAll(fullBackup);
} else {
for (Service s : fullBackup) {
// store facility by filter
if (s.getName().toLowerCase().startsWith(text.toLowerCase())) {
list.add(s);
}
}
}
if (list.isEmpty() && !text.isEmpty()) {
loaderImage.setEmptyResultMessage("No service matching '" + text + "' found.");
} else {
loaderImage.setEmptyResultMessage("Resource has no services assigned.");
}
dataProvider.flush();
dataProvider.refresh();
loaderImage.loadingFinished();
}
use of cz.metacentrum.perun.webgui.model.Service in project perun by CESNET.
the class GetAssignedServices method setList.
public void setList(ArrayList<Service> list) {
clearTable();
this.list.addAll(list);
for (Service object : list) {
oracle.add(object.getName());
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.Service in project perun by CESNET.
the class EntitylessAttributesDetailTabItem method draw.
@Override
public Widget draw() {
titleWidget.setText(def.getName());
final TabItem tab = this;
// create main panel for content
final FlexTable mainPage = new FlexTable();
mainPage.setWidth("100%");
final ExtendedTextBox description = new ExtendedTextBox();
description.setWidth("100%");
description.getTextBox().setText(def.getDescription());
final ExtendedTextBox.TextBoxValidator validator = () -> {
if (description.getTextBox().getText().trim().isEmpty()) {
description.setError("Description can't be empty.");
return false;
}
description.setOk();
return true;
};
final ExtendedTextBox displayName = new ExtendedTextBox();
displayName.setWidth("100%");
displayName.getTextBox().setText(def.getDisplayName());
final ExtendedTextBox.TextBoxValidator validatorName = () -> {
if (displayName.getTextBox().getText().trim().isEmpty()) {
displayName.setError("Display name can't be empty.");
return false;
}
displayName.setOk();
return true;
};
description.setValidator(validator);
displayName.setValidator(validatorName);
// unique.setEnabled(false);
unique.setValue(def.isUnique());
if (Arrays.asList("core", "virt").contains(def.getDefinition()) || def.getEntity().equals("entityless")) {
unique.setEnabled(false);
} else {
unique.addValueChangeHandler(valueChangeEvent -> {
if (valueChangeEvent.getValue()) {
UiElements.generateAlert("Change confirmation", "Changing attribute to UNIQUE might take a lot of time if there is large number of entities with set values. Perun will check uniqueness during the process. If values are not unique, conversion will be stopped.<p style=\"color:red;\">We strongly recommend to refresh whole browser window after conversion is DONE to prevent errors when modyfying attributes from GUI.", clickEvent -> {
ConvertAttributeToUnique convert = new ConvertAttributeToUnique(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
unique.setValue(true);
unique.setEnabled(false);
def.setUnique(true);
}
@Override
public void onError(PerunError error) {
unique.setValue(false);
unique.setEnabled(true);
def.setUnique(false);
}
@Override
public void onLoadingStart() {
unique.setEnabled(false);
}
});
convert.convertAttributeDefinitionToUnique(def.getId());
}, clickEvent -> {
// action canceled
unique.setValue(false);
});
} else {
UiElements.generateInfo("Change not allowed", "Once converted to UNIQUE, attributes can't be converted back to non-unique.");
unique.setValue(true);
}
});
}
FlexTable attributeDetailTable = new FlexTable();
attributeDetailTable.setStyleName("inputFormFlexTable");
final CustomButton updateButton = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save attribute details");
updateButton.addClickHandler(event -> {
final ArrayList<AttributeRights> list = new ArrayList<>();
for (AttributeRights r : rights) {
if (r.getRole().equalsIgnoreCase("SELF")) {
list.add(getRightsFromWidgets(selfRead, selfWrite, selfReadPublic, selfWritePublic, selfReadVo, selfWriteVo, r));
} else if (r.getRole().equalsIgnoreCase("VOADMIN")) {
list.add(getRightsFromWidgets(voRead, voWrite, r));
} else if (r.getRole().equalsIgnoreCase("GROUPADMIN")) {
list.add(getRightsFromWidgets(groupRead, groupWrite, r));
} else if (r.getRole().equalsIgnoreCase("FACILITYADMIN")) {
list.add(getRightsFromWidgets(facilityRead, facilityWrite, r));
}
}
if ((!Objects.equals(def.getDescription(), description.getTextBox().getText().trim()) || !Objects.equals(def.getDisplayName(), displayName.getTextBox().getText().trim()))) {
if (!validator.validateTextBox() || !validatorName.validateTextBox())
return;
def.setDescription(description.getTextBox().getText().trim());
def.setDisplayName(displayName.getTextBox().getText().trim());
UpdateAttribute request = new UpdateAttribute(JsonCallbackEvents.disableButtonEvents(updateButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// after update - update rights
SetAttributeRights request = new SetAttributeRights(JsonCallbackEvents.disableButtonEvents(updateButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
enableDisableWidgets(true);
}
@Override
public void onLoadingStart() {
enableDisableWidgets(false);
}
@Override
public void onError(PerunError error) {
enableDisableWidgets(true);
}
}));
request.setAttributeRights(list);
}
}));
request.updateAttribute(def);
} else {
// after update - update rights
SetAttributeRights request = new SetAttributeRights(JsonCallbackEvents.disableButtonEvents(updateButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
enableDisableWidgets(true);
}
@Override
public void onLoadingStart() {
enableDisableWidgets(false);
}
@Override
public void onError(PerunError error) {
enableDisableWidgets(true);
}
}));
request.setAttributeRights(list);
}
});
attributeDetailTable.setHTML(0, 0, "Display name:");
attributeDetailTable.setWidget(0, 1, displayName);
attributeDetailTable.setHTML(1, 0, "Description:");
attributeDetailTable.setWidget(1, 1, description);
attributeDetailTable.setHTML(2, 0, "Unique:");
attributeDetailTable.setWidget(2, 1, unique);
for (int i = 0; i < attributeDetailTable.getRowCount(); i++) {
attributeDetailTable.getFlexCellFormatter().setStyleName(i, 0, "itemName");
}
final FlexTable rightsTable = new FlexTable();
rightsTable.setStyleName("inputFormFlexTable");
rightsTable.setHTML(0, 1, "<strong>SELF</strong>");
rightsTable.setHTML(0, 2, "<strong>SELF_PUBLIC</strong>");
rightsTable.setHTML(0, 3, "<strong>SELF_VO</strong>");
rightsTable.setHTML(0, 4, "<strong>VO</strong>");
rightsTable.setHTML(0, 5, "<strong>GROUP</strong>");
rightsTable.setHTML(0, 6, "<strong>FACILITY</strong>");
rightsTable.setHTML(1, 0, "<strong>READ</strong>");
rightsTable.setHTML(2, 0, "<strong>WRITE</strong>");
rightsTable.setWidget(1, 1, selfRead);
rightsTable.setWidget(2, 1, selfWrite);
rightsTable.setWidget(1, 2, selfReadPublic);
rightsTable.setWidget(2, 2, selfWritePublic);
rightsTable.setWidget(1, 3, selfReadVo);
rightsTable.setWidget(2, 3, selfWriteVo);
rightsTable.setWidget(1, 4, voRead);
rightsTable.setWidget(2, 4, voWrite);
rightsTable.setWidget(1, 5, groupRead);
rightsTable.setWidget(2, 5, groupWrite);
rightsTable.setWidget(1, 6, facilityRead);
rightsTable.setWidget(2, 6, facilityWrite);
rightsTable.addStyleName("centeredTable");
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addWidget(updateButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", event -> session.getTabManager().closeTab(tab, isRefreshParentOnClose())));
CustomButton showKeys = new CustomButton();
showKeys.setText("show keys");
showKeys.addClickHandler(clickEvent -> session.getTabManager().addTab(new EntitylessAttributeEditKeyTabItem(def)));
menu.addWidget(showKeys);
GetAttributeRights rightsCall = new GetAttributeRights(def.getId(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
rights = JsonUtils.jsoAsList(jso);
for (AttributeRights r : rights) {
if (r.getRole().equalsIgnoreCase("SELF")) {
setRightsToWidgets(selfRead, selfWrite, selfReadPublic, selfWritePublic, selfReadVo, selfWriteVo, r);
} else if (r.getRole().equalsIgnoreCase("VOADMIN")) {
setRightsToWidgets(voRead, voWrite, r);
} else if (r.getRole().equalsIgnoreCase("GROUPADMIN")) {
setRightsToWidgets(groupRead, groupWrite, r);
} else if (r.getRole().equalsIgnoreCase("FACILITYADMIN")) {
setRightsToWidgets(facilityRead, facilityWrite, r);
}
}
enableDisableWidgets(true);
rightsTable.setVisible(true);
}
@Override
public void onError(PerunError error) {
enableDisableWidgets(true);
rightsTable.setVisible(false);
}
@Override
public void onLoadingStart() {
enableDisableWidgets(false);
rightsTable.setVisible(false);
}
});
rightsCall.retrieveData();
// create new instance for jsonCall
final GetServicesByAttrDefinition services = new GetServicesByAttrDefinition(def.getId());
services.setCheckable(false);
CellTable<Service> attrDefTable = services.getTable((index, object, value) -> session.getTabManager().addTab(new ServiceDetailTabItem(object)));
attrDefTable.setStyleName("perun-table");
ScrollPanel scrollTable = new ScrollPanel(attrDefTable);
scrollTable.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(scrollTable, 350, this);
// set content to page
mainPage.setWidget(0, 0, menu);
mainPage.getFlexCellFormatter().setColSpan(0, 0, 2);
mainPage.setWidget(1, 0, attributeDetailTable);
mainPage.setWidget(1, 1, rightsTable);
mainPage.getFlexCellFormatter().setWidth(1, 0, "50%");
mainPage.getFlexCellFormatter().setWidth(1, 1, "50%");
HTML title = new HTML("<p>Required by service</p>");
title.setStyleName("subsection-heading");
mainPage.setWidget(2, 0, title);
mainPage.getFlexCellFormatter().setColSpan(2, 0, 2);
// put page into scroll panel
mainPage.setWidget(3, 0, scrollTable);
mainPage.getFlexCellFormatter().setColSpan(3, 0, 2);
mainPage.getFlexCellFormatter().setHeight(3, 0, "100%");
this.contentWidget.setWidget(mainPage);
return getWidget();
}
Aggregations