Search in sources :

Example 1 with App

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;
}
Also used : App(org.eclipse.kuksa.appstore.model.App) CssLayout(com.vaadin.ui.CssLayout) VerticalLayout(com.vaadin.ui.VerticalLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 2 with App

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;
}
Also used : App(org.eclipse.kuksa.appstore.model.App) PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable)

Example 3 with App

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);
}
Also used : App(org.eclipse.kuksa.appstore.model.App) NavHeader(org.eclipse.kuksa.appstore.ui.component.NavHeader) ItemCaptionGenerator(com.vaadin.ui.ItemCaptionGenerator) HorizontalLayout(com.vaadin.ui.HorizontalLayout) PostConstruct(javax.annotation.PostConstruct)

Example 4 with App

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);
}
Also used : App(org.eclipse.kuksa.appstore.model.App) CssLayout(com.vaadin.ui.CssLayout)

Example 5 with App

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;
}
Also used : App(org.eclipse.kuksa.appstore.model.App) PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) BadRequestException(org.eclipse.kuksa.appstore.exception.BadRequestException) Notification(com.vaadin.ui.Notification)

Aggregations

App (org.eclipse.kuksa.appstore.model.App)16 BadRequestException (org.eclipse.kuksa.appstore.exception.BadRequestException)9 NotFoundException (org.eclipse.kuksa.appstore.exception.NotFoundException)8 AlreadyExistException (org.eclipse.kuksa.appstore.exception.AlreadyExistException)6 SoftwareModuleResult (org.eclipse.kuksa.appstore.model.hawkbit.SoftwareModuleResult)6 Response (feign.Response)4 SoftwareModule (org.eclipse.kuksa.appstore.model.hawkbit.SoftwareModule)4 CssLayout (com.vaadin.ui.CssLayout)3 ArrayList (java.util.ArrayList)3 User (org.eclipse.kuksa.appstore.model.User)3 ThemeResource (com.vaadin.server.ThemeResource)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 AssignedResult (org.eclipse.kuksa.appstore.model.hawkbit.AssignedResult)2 Distribution (org.eclipse.kuksa.appstore.model.hawkbit.Distribution)2 DistributionResult (org.eclipse.kuksa.appstore.model.hawkbit.DistributionResult)2 Rule (org.eclipse.kuksa.appstore.model.hawkbit.Rule)2 RuleMain (org.eclipse.kuksa.appstore.model.hawkbit.RuleMain)2 PageRequest (org.springframework.data.domain.PageRequest)2 Pageable (org.springframework.data.domain.Pageable)2 FileResource (com.vaadin.server.FileResource)1