Skip to content

Commit

Permalink
Merge pull request #521 from omoluabidotcom/development
Browse files Browse the repository at this point in the history
Team Update
  • Loading branch information
sundayAdu authored Sep 7, 2023
2 parents 54354a8 + 1b565fa commit cdf50ce
Show file tree
Hide file tree
Showing 7 changed files with 418 additions and 226 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,7 @@ public boolean createOrEditCluster(CommunityDto communityDto) {
for (DistrictIndexDto districtIndexDto : pcode) {
String checkerName = districtIndexDto.getName();

if (checkerName.trim().equals(districtOfCluster.getValue().toString().trim())) {
System.out.println("shout you catch me egbon: pcode here == "
+ districtIndexDto.getExternalId() + " my name is " + districtIndexDto.getName());
if (checkerName.trim().equals(districtOfCluster.getValue().toString().trim())) {
DistrictReferenceDto nuller = new DistrictReferenceDto(districtIndexDto.getUuid(),
districtIndexDto.getName(), districtIndexDto.getExternalId());
dcex.setDistrict(nuller);
Expand Down Expand Up @@ -787,9 +785,12 @@ public boolean createOrEditCluster(CommunityDto communityDto) {
notification.close();
});

Paragraph text = new Paragraph(
"An unexpected error occurred. Please contact your supervisor or administrator and inform them about it.");
// Paragraph text = new Paragraph(
// "An unexpected error occurred. Please contact your supervisor or administrator and inform them about it.");

Paragraph text = new Paragraph(
"Cluster number taken, choose another");

HorizontalLayout layout = new HorizontalLayout(text, closeButton);
layout.setAlignItems(Alignment.CENTER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.select.Select;
Expand All @@ -36,6 +37,7 @@
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.router.RouterLayout;
import com.vaadin.flow.server.VaadinService;
import com.vaadin.flow.server.VaadinSession;

import de.symeda.sormas.api.FacadeProvider;
Expand Down Expand Up @@ -63,7 +65,7 @@
@JavaScript("https://code.highcharts.com/modules/accessibility.js")
@JavaScript("https://code.highcharts.com/modules/no-data-to-display.js")

public class DashboardView extends VerticalLayout implements RouterLayout , BeforeEnterObserver {
public class DashboardView extends VerticalLayout implements RouterLayout, BeforeEnterObserver {

private static final long serialVersionUID = 1851726752523985165L;

Expand All @@ -85,7 +87,7 @@ public class DashboardView extends VerticalLayout implements RouterLayout , Befo
ComboBox<CommunityReferenceDto> cluster = new ComboBox<>();
Select<CampaignJurisdictionLevel> groupby = new Select<>();

List<CampaignReferenceDto> campaigns;
List<CampaignReferenceDto> campaigns, campaignss;
List<CampaignReferenceDto> campaignPhases;
List<AreaReferenceDto> regions;
List<RegionReferenceDto> provinces;
Expand All @@ -94,7 +96,7 @@ public class DashboardView extends VerticalLayout implements RouterLayout , Befo
List<String> campaingYears = new ArrayList<>();

boolean isCampaignChanged;

private boolean isSubAvaialable = false;
private CampaignJurisdictionLevel campaignJurisdictionLevel;

Expand All @@ -103,6 +105,8 @@ public class DashboardView extends VerticalLayout implements RouterLayout , Befo
private Div mainContentContainerx;

UserProvider userProvider = new UserProvider();

String firstSubtabId = null;

public DashboardView() {
if (I18nProperties.getUserLanguage() == null) {
Expand All @@ -117,34 +121,39 @@ public DashboardView() {
setSpacing(false);
// UI.getCurrent().getPage().reload();
// UI.getCurrent().setDirection(Direction.RIGHT_TO_LEFT);

if(VaadinService.getCurrentRequest().getWrappedSession().getAttribute("mtabtrack") != null) {

System.out.println(VaadinService.getCurrentRequest().getWrappedSession().getAttribute("mtabtrack")
+ " Pluto is active");
System.out.println(VaadinService.getCurrentRequest().getWrappedSession().getAttribute("stabtrack")
+ " Elon is active");
}

dataProvider = new CampaignDashboardDataProvider();
// String deletab = FacadeProvider.getUserFacade().getCurrentUser().getUsertype().toString();

UserProvider usr = new UserProvider();

campaignYear.setLabel(I18nProperties.getCaption(Captions.campaignYear));
campaigns = FacadeProvider.getCampaignFacade().getAllActiveCampaignsAsReference();
campaigns = FacadeProvider.getCampaignFacade().getAllActiveCampaignsAsReference();

for (CampaignReferenceDto cmfdto : campaigns) {
campaingYears.add(cmfdto.getCampaignYear().trim());

}


Set<String> setDeduplicated = new HashSet<>(campaingYears);
campaingYears.clear();
campaingYears.addAll(setDeduplicated);



campaignYear.setItems(campaingYears);
campaignYear.getStyle().set("padding-top", "0px");
campaignYear.setClassName("col-sm-6, col-xs-6");


campaign.setLabel(I18nProperties.getCaption(Captions.Campaign));

campaigns = FacadeProvider.getCampaignFacade().getAllActiveCampaignsAsReference();

campaign.setItems(campaigns);
campaign.getStyle().set("padding-top", "0px");
campaign.setClassName("col-sm-6, col-xs-6");
Expand Down Expand Up @@ -369,7 +378,6 @@ public DashboardView() {
setSizeFull();
}


private Div drawDashboardAndTabs(String UIs) {
Div mainContentContainer = new Div();
mainContentContainer.setId(UIs);
Expand All @@ -396,7 +404,7 @@ private Div drawDashboardAndTabs(String UIs) {
int defctr = 0;

String firstMntabId = null;
String firstSubtabId = null;
// String firstSubtabId = null;

// creating bucket tabs to hold tabs and subtabs
for (String tabIdc : mainTabs) {
Expand All @@ -418,7 +426,7 @@ private Div drawDashboardAndTabs(String UIs) {
for (String sbTabId : subTabx) {
defctr++;

// String sbtabId = WordUtils.capitalizeFully(tabIdc);
String sbtabId = WordUtils.capitalizeFully(tabIdc);
Tab stabx = new Tab(sbTabId);
stabx.setId("submain_" + sbTabId);
stabx.getStyle().set("font-weight", "500");
Expand All @@ -435,7 +443,12 @@ private Div drawDashboardAndTabs(String UIs) {
}
}


mtabs.addSelectedChangeListener(e -> {

VaadinService.getCurrentRequest().getWrappedSession().setAttribute("mtabtrack", mtabs.getSelectedIndex());

System.out.println("entered main tab");
int listnrCtr = 0;

final List<String> subTabx = new ArrayList<>(
Expand All @@ -448,7 +461,9 @@ private Div drawDashboardAndTabs(String UIs) {
for (String sbTabId : subTabx) {
listnrCtr++;
if (listnrCtr == 1) {
firstSbTabId = sbTabId;

firstSbTabId = sbTabId;
System.out.println(firstSbTabId + " first subtab IDDDDDDDDDDDDDDDDDDDDDD");
}
// String sbtabId = WordUtils.capitalizeFully(tabIdc);
Tab stabx = new Tab(sbTabId);
Expand All @@ -458,6 +473,14 @@ private Div drawDashboardAndTabs(String UIs) {
sTabs.add(stabx);

}
if (VaadinService.getCurrentRequest().getWrappedSession().getAttribute("stabtrack") != null) {
firstSbTabId = (String) VaadinService.getCurrentRequest().getWrappedSession().getAttribute("stabtrack");
firstSbTabId = firstSbTabId.replaceAll("submain_", "");
firstSubtabId = firstSbTabId;
System.out.println(firstSbTabId + " first subtab IIDDDDDDDDDDDDDDDDDDDDDD");
// sTabs.setSelectedTab(
// (String) VaadinService.getCurrentRequest().getWrappedSession().getAttribute("stabtrack").toString());
}
// //Notification.show(e.getSelectedTab().getId().get().toString().replaceAll("main_", ""));
// //Notification.show(firstSbTabId);

Expand All @@ -472,11 +495,17 @@ private Div drawDashboardAndTabs(String UIs) {
});

sTabs.addSelectedChangeListener(e -> {
System.out.println("Subtab enteredddddddddddddddddddddddd");

String listnrCtr = listerCheck;

if (e.getSelectedTab() != null) {
// System.out.print(isSubAvaialable);
System.out.print(e.getSelectedTab().getId().get() + " hhhkkkkk " + e.getSelectedTab());
VaadinService.getCurrentRequest().getWrappedSession().setAttribute("stabtrack", e.getSelectedTab().getId().get());

System.out.print(e.getSelectedTab().getId().get().toString() + " e.getSelectedTab().getId().get().toString() ");
String listnrCtrx = e.getSelectedTab().getId().get().replaceAll("submain_", "");

System.out.print(listnrCtrx + " listnrCtrx");
// Notification.show(listnrCtr +" _____________________________ "+listnrCtrx);

contentContainer.removeAll();
Expand All @@ -492,14 +521,23 @@ private Div drawDashboardAndTabs(String UIs) {
contentContainer.add(campaignSummaryGridView.CampaignSummaryGridViewInit(firstMntabId, dataProvider,
campaignPhase.getValue(), firstSubtabId));
}

contentContainer.getStyle().set("margin-top", "0.4rem");

contentContainer.setId("tabsSheet");
contentContainer.setSizeFull();

try {
if (VaadinService.getCurrentRequest().getWrappedSession().getAttribute("mtabtrack") != null) {

mtabs.setSelectedIndex(
(int) VaadinService.getCurrentRequest().getWrappedSession().getAttribute("mtabtrack"));
}
} finally {

}

mainContentContainer.add(mtabs, sTabs, contentContainer);
return mainContentContainer;

}

public class LazyComponent extends Div {
Expand Down Expand Up @@ -535,7 +573,7 @@ private void changeCampaignJuridictionLevel(CampaignJurisdictionLevel campaignJu
}

}

private String getLabelForEnum(CampaignPhase campaignPhase) {
switch (campaignPhase) {
case PRE:
Expand All @@ -554,22 +592,22 @@ private String getLabelForEnum(CampaignPhase campaignPhase) {

@Override
public void beforeEnter(BeforeEnterEvent event) {
try {
UserProvider usrP = new UserProvider();
System.out.println("trying ti use camp data "+usrP);
System.out.println("trying ti use camp data "+usrP.getCurrent().hasUserRole(UserRole.CASE_OFFICER));
try {
UserProvider usrP = new UserProvider();
System.out.println("trying ti use camp data " + usrP);

System.out.println("trying ti use camp data " + usrP.getCurrent().hasUserRole(UserRole.CASE_OFFICER));
if (!usrP.getCurrent().hasUserRole(UserRole.ADMIN)) {
event.rerouteTo(CampaignDataView.class); // Redirect to a different view
}
event.rerouteTo(CampaignDataView.class); // Redirect to a different view
}
} catch (Exception e) {
System.err.println("ubnable tooooooooooo trying ti use camp data ");

System.err.println("ubnable tooooooooooo trying ti use camp data ");

// TODO Auto-generated catch block
e.printStackTrace();
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public CredentialPassWordChanger(UserDto usedto) {

if (I18nProperties.getUserLanguage() == null) {

I18nProperties.setUserLanguage(Language.EN);
I18nProperties.setUserLanguage(Language.EN);
} else {

I18nProperties.setUserLanguage(currentUser.getUser().getLanguage());
I18nProperties.getUserLanguage();
}
FacadeProvider.getI18nFacade().setUserLanguage(currentUser.getUser().getLanguage());

this.userName = usedto;

_dialog = new ConfirmDialog();
Expand All @@ -71,7 +71,7 @@ public CredentialPassWordChanger(UserDto usedto) {
}

protected void continuePasswrd() {

accessControl = AccessControlFactory.getInstance().createAccessControl();
UserProvider userProvider = new UserProvider();
UserDto userxs = userProvider.getUser();
Expand All @@ -83,8 +83,8 @@ protected void continuePasswrd() {

FormLayout layout = new FormLayout();

PasswordField oldPassField = new PasswordField(I18nProperties.getCaption(Captions.oldPassword));
oldPassField.setSizeFull();
// PasswordField oldPassField = new PasswordField(I18nProperties.getCaption(Captions.oldPassword));
// oldPassField.setSizeFull();

PasswordField passField1 = new PasswordField(I18nProperties.getString(Strings.headingNewPassword));
passField1.setSizeFull();
Expand All @@ -95,54 +95,50 @@ protected void continuePasswrd() {
// layout.add(new Label("*Must be at least 8 characters"));
// layout.add(new Label("*Must contain 1 Uppercase and 1 special character "));

Label instructionLabel = new Label( I18nProperties.getString(Strings.mustBeAt8Char) +" \r\n <br>"
Label instructionLabel = new Label(I18nProperties.getString(Strings.mustBeAt8Char) + " \r\n <br>"
+ I18nProperties.getString(Strings.mustContain1UppercaseChar) + " \r\n" + "");
instructionLabel.getElement().setProperty("innerHTML", instructionLabel.getText());
instructionLabel.getElement().getStyle().set("font-size", "12px");

passField2.setSizeFull();
layout.add(oldPassField, passField1, passField2, instructionLabel);
layout.add(passField1, passField2, instructionLabel);

Button saveButton = new Button(I18nProperties.getCaption(Captions.actionSave));
// changePassword.setStyleName(CssStyles.VAADIN_BUTTON);
// changePassword.setStyleName(ValoTheme.BUTTON_PRIMARY);
// changePassword.setStyleName(CssStyles.FLOAT_RIGHT);

saveButton.addClickListener(e -> {
String oldPass = oldPassField.getValue().trim();
// String oldPass = oldPassField.getValue().trim();
String newpass1 = passField1.getValue().trim();
String newpass2 = passField2.getValue().trim();

if ((oldPass != null && !oldPass.isEmpty()) && newpass1.equals(newpass2) && !newpass1.equals(oldPass)) {
if(accessControl.upDatePassWordCheck(userxs.getUserName(), oldPass)) {

FacadeProvider.getUserFacade().changePassword(userxs.getUserName(), newpass1);
UI.getCurrent().getPage().reload();
Notification.show(I18nProperties.getString(Strings.passwordChangedSuccessfully));
} else {

Notification.show(I18nProperties.getString(Strings.passwordChangedSuccessfully));
}
} else {
Notification notification = new Notification();
notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
notification.setPosition(Position.MIDDLE);
Button closeButton = new Button(new Icon("lumo", "cross"));
closeButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY_INLINE);
closeButton.getElement().setAttribute("aria-label", "Close");
closeButton.addClickListener(event -> {
notification.close();
});

Paragraph text = new Paragraph(
I18nProperties.getString(Strings.passwordDoesNotMatch) + " and New password must not be same with old.");

HorizontalLayout errorLayout = new HorizontalLayout(text, closeButton);
errorLayout.setAlignItems(Alignment.CENTER);

notification.add(errorLayout);
notification.open();
}
if (newpass1.equals(newpass2)) {
if (accessControl.upDatePassWordCheck(userxs.getUserName(), newpass1)) {

FacadeProvider.getUserFacade().changePassword(userxs.getUserName(), newpass1);
UI.getCurrent().getPage().reload();
Notification.show(I18nProperties.getString(Strings.passwordChangedSuccessfully));
}
} else {
Notification notification = new Notification();
notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
notification.setPosition(Position.MIDDLE);
Button closeButton = new Button(new Icon("lumo", "cross"));
closeButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY_INLINE);
closeButton.getElement().setAttribute("aria-label", "Close");
closeButton.addClickListener(event -> {
notification.close();
});

Paragraph text = new Paragraph(I18nProperties.getString(Strings.passwordDoesNotMatch));

HorizontalLayout errorLayout = new HorizontalLayout(text, closeButton);
errorLayout.setAlignItems(Alignment.CENTER);

notification.add(errorLayout);
notification.open();
}
});

dialog.add(layout);
Expand Down
Loading

0 comments on commit cdf50ce

Please sign in to comment.