use of org.eclipse.kuksa.appstore.model.App in project Eclipse-Kuksa-Automotive-Edge-Extension by max-grzanna.
the class AppGridView method crateAppGridView.
public static CssLayout crateAppGridView(Page<App> appsList, int intFetchSize) {
CssLayout mainlayout = new CssLayout();
VerticalLayout vlayout = new VerticalLayout();
HorizontalLayout hlayout;
List<App> listsApp = appsList.getContent();
int noOfRec = listsApp.size();
int rows = noOfRec / intFetchSize;
if (noOfRec % intFetchSize != 0) {
rows++;
}
for (int i = 0; i < rows; i++) {
hlayout = new HorizontalLayout();
for (int j = 0; j < intFetchSize; j++) {
int index = (i * intFetchSize) + (j);
if (index < listsApp.size()) {
hlayout.addComponent(AppViewBox.createAppViewBox(listsApp.get(index)));
} else {
break;
}
}
vlayout.addComponent(hlayout);
}
mainlayout.addComponent(vlayout);
mainlayout.setSizeFull();
mainlayout.addStyleName("v-scrollable");
mainlayout.addStyleName("h-scrollable");
mainlayout.setHeight("100%");
return mainlayout;
}
use of org.eclipse.kuksa.appstore.model.App in project Eclipse-Kuksa-Automotive-Edge-Extension by max-grzanna.
the class AppsListView method findByText.
public Page<App> findByText(String text, String categoryId, int page, int size) {
Pageable pageable = new PageRequest(page, size);
Page<App> users;
if (text == null && categoryId == null) {
return null;
} else if (text == null && categoryId != null) {
users = appService.findByAppcategoryId(Long.parseLong(categoryId), pageable);
} else if (text != null && categoryId == null) {
users = appService.findByNameStartsWithIgnoreCase(text, pageable);
} else {
users = appService.findByNameStartsWithIgnoreCaseAndAppcategoryId(text, Long.parseLong(categoryId), pageable);
}
return users;
}
use of org.eclipse.kuksa.appstore.model.App in project Eclipse-Kuksa-Automotive-Edge-Extension by max-grzanna.
the class AppsListView method init.
@PostConstruct
public void init() {
int currentpage = 1;
int limit = 9;
int total;
Page<App> appsList = findByText(serachText.getValue(), comboBox.getValue(), currentpage - 1, limit);
total = (int) appsList.getTotalElements();
appslayout = AppGridView.crateAppGridView(appsList, 3);
navHeaderLayout = new NavHeader().create(VIEW_NAME, VaadinSession.getCurrent().getAttribute("isCurrentUserAdmin").toString());
mainlayout.addComponent(navHeaderLayout);
ItemCaptionGenerator<String> icg = new ItemCaptionGenerator<String>() {
@Override
public String apply(String item) {
return appCategoryService.findById(Long.parseLong(item)).getName();
}
};
comboBox.setItemCaptionGenerator(icg);
comboBox.setItems(appCategoryService.getAllId());
comboBox.setPlaceholder("Select a category");
comboBox.setEmptySelectionCaption("All");
comboBox.setEmptySelectionAllowed(true);
comboBox.addValueChangeListener(event -> {
listApps(serachText.getValue(), event.getValue());
});
actions = new HorizontalLayout(comboBox, serachText);
actions.setStyleName("v-actions");
serachText.setPlaceholder("Search by App Name");
// Listen changes made by the filter textbox, refresh data from backend
serachText.addValueChangeListener(event -> {
listApps(event.getValue(), comboBox.getValue());
});
mainlayout.addComponent(actions);
mainlayout.addComponent(appslayout);
paginationComponent = createPaginationComponent(total, currentpage, limit);
mainlayout.addComponent(paginationComponent);
setCompositionRoot(mainlayout);
}
use of org.eclipse.kuksa.appstore.model.App in project Eclipse-Kuksa-Automotive-Edge-Extension by max-grzanna.
the class PurchasedAppsListView method listApps.
public void listApps(String text) {
int currentpage = 1;
int limit = 6;
int total;
Page<App> appsList = findOwnApps(currentpage - 1, limit);
total = (int) appsList.getTotalElements();
CssLayout appslayoutnew = new CssLayout();
appslayoutnew = AppGridView.crateAppGridView(appsList, 2);
mainlayout.removeAllComponents();
mainlayout.addComponent(navHeaderLayout);
mainlayout.addComponent(appslayoutnew);
paginationComponent = createPaginationComponent(total, currentpage, limit);
mainlayout.addComponent(paginationComponent);
setCompositionRoot(mainlayout);
}
use of org.eclipse.kuksa.appstore.model.App in project Eclipse-Kuksa-Automotive-Edge-Extension by max-grzanna.
the class PurchasedAppsListView method findOwnApps.
public Page<App> findOwnApps(int page, int size) {
Pageable pageable = new PageRequest(page, size);
currentUser = userService.findByUserName(VaadinSession.getCurrent().getAttribute("user").toString());
Page<App> apps;
try {
apps = appService.findUsersApps(currentUser.getId().toString(), appService.getListOfOem(appService.getListOfTargets(currentUser.getId())), pageable);
} catch (BadRequestException e) {
new Notification(e.getMessage(), Notification.Type.ERROR_MESSAGE).show(com.vaadin.server.Page.getCurrent());
return null;
}
return apps;
}
Aggregations