From f5de367fe6b65d7d16a37a68e9f42debafb6b409 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Wed, 9 Feb 2022 20:10:07 +0100 Subject: [PATCH] sort extensions by recently updated --- .../GExtensionStoreController.java | 9 ++-- .../queriedoverviews/ByUpdateOverview.java | 54 +++++++++++++++++++ .../application/webview/index.html | 2 +- 3 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/entities/queriedoverviews/ByUpdateOverview.java diff --git a/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/GExtensionStoreController.java b/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/GExtensionStoreController.java index d22ae0e..f01de68 100644 --- a/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/GExtensionStoreController.java +++ b/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/GExtensionStoreController.java @@ -7,6 +7,7 @@ import gearth.services.internal_extensions.extensionstore.application.entities.c import gearth.services.internal_extensions.extensionstore.application.entities.installed.InstalledOverview; import gearth.services.internal_extensions.extensionstore.application.entities.queriedoverviews.ByDateOverview; import gearth.services.internal_extensions.extensionstore.application.entities.queriedoverviews.ByRatingOverview; +import gearth.services.internal_extensions.extensionstore.application.entities.queriedoverviews.ByUpdateOverview; import gearth.services.internal_extensions.extensionstore.application.entities.search.SearchOverview; import gearth.services.internal_extensions.extensionstore.repository.StoreRepository; import javafx.application.Platform; @@ -47,20 +48,20 @@ public class GExtensionStoreController implements Initializable { JSObject window = (JSObject) webView.getEngine().executeScript("window"); window.setMember("app", extensionStore); - Element by_date_link = webView.getEngine().getDocument().getElementById("overview_by_date"); + Element by_update_link = webView.getEngine().getDocument().getElementById("overview_by_update"); Element by_rating_link = webView.getEngine().getDocument().getElementById("overview_by_rating"); Element by_category_link = webView.getEngine().getDocument().getElementById("overview_by_category"); Element installed_link = webView.getEngine().getDocument().getElementById("overview_installed"); Element seach_link = webView.getEngine().getDocument().getElementById("search_page"); Map> hOverviewSupplier = new HashMap<>(); - hOverviewSupplier.put(by_date_link, () -> new ByDateOverview(null, 0, GExtensionStore.PAGESIZE, getStoreRepository())); + hOverviewSupplier.put(by_update_link, () -> new ByUpdateOverview(null, 0, GExtensionStore.PAGESIZE, getStoreRepository())); hOverviewSupplier.put(by_rating_link, () -> new ByRatingOverview(null, 0, GExtensionStore.PAGESIZE, getStoreRepository())); hOverviewSupplier.put(by_category_link, () -> new CategoryOverview(null, 0, GExtensionStore.PAGESIZE, getStoreRepository())); hOverviewSupplier.put(installed_link, () -> new InstalledOverview(null, 0, GExtensionStore.PAGESIZE, getStoreRepository())); hOverviewSupplier.put(seach_link, () -> new SearchOverview(null, getStoreRepository())); - Arrays.asList(by_date_link, by_rating_link, by_category_link, installed_link, seach_link).forEach(l -> + Arrays.asList(by_update_link, by_rating_link, by_category_link, installed_link, seach_link).forEach(l -> ((EventTarget) l).addEventListener("click", event -> { if (initialized) setRootOverview(hOverviewSupplier.get(l).get()); }, true)); @@ -210,7 +211,7 @@ public class GExtensionStoreController implements Initializable { private void onFullInitialize() { initialized = true; - setRootOverview(new ByDateOverview(null, 0, GExtensionStore.PAGESIZE, getStoreRepository())); + setRootOverview(new ByUpdateOverview(null, 0, GExtensionStore.PAGESIZE, getStoreRepository())); } public void gExtensionStore(GExtensionStore gExtensionStore) { diff --git a/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/entities/queriedoverviews/ByUpdateOverview.java b/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/entities/queriedoverviews/ByUpdateOverview.java new file mode 100644 index 0000000..36137ba --- /dev/null +++ b/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/entities/queriedoverviews/ByUpdateOverview.java @@ -0,0 +1,54 @@ +package gearth.services.internal_extensions.extensionstore.application.entities.queriedoverviews; + +import gearth.misc.OSValidator; +import gearth.services.internal_extensions.extensionstore.application.entities.HOverview; +import gearth.services.internal_extensions.extensionstore.repository.StoreRepository; +import gearth.services.internal_extensions.extensionstore.repository.models.StoreExtension; +import gearth.services.internal_extensions.extensionstore.repository.querying.ExtensionOrdering; + +import java.util.Collections; +import java.util.List; + +public class ByUpdateOverview extends QueriedExtensionOverview { + + + public ByUpdateOverview(HOverview parent, int startIndex, int size, StoreRepository storeRepository) { + super(parent, startIndex, size, storeRepository); + } + + protected List query(int startIndex, int size) { + return storeRepository.getExtensions(startIndex, size, "", ExtensionOrdering.LAST_UPDATED, + Collections.singletonList(OSValidator.getOSFull()), null, null, null, false, false); + } + + @Override + public Header header() { + return new Header() { + @Override + public String iconUrl() { + return "images/overviews/clock.png"; + } + + @Override + public String title() { + return "Recently Updated"; + } + + @Override + public String description() { + return "Extensions that were recently updated"; + } + + @Override + public String contentTitle() { + return "Recently Updated"; + } + }; + } + + + @Override + public HOverview getNewPage(int startIndex, int size) { + return new ByUpdateOverview(parent, startIndex, size, storeRepository); + } +} diff --git a/G-Earth/src/main/resources/gearth/services/internal_extensions/extensionstore/application/webview/index.html b/G-Earth/src/main/resources/gearth/services/internal_extensions/extensionstore/application/webview/index.html index 71a837a..e24148e 100644 --- a/G-Earth/src/main/resources/gearth/services/internal_extensions/extensionstore/application/webview/index.html +++ b/G-Earth/src/main/resources/gearth/services/internal_extensions/extensionstore/application/webview/index.html @@ -36,7 +36,7 @@