Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
feat(portal): upgrade theme definition with autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
gcusnieux authored and aelamrani committed Mar 11, 2020
1 parent 48dba0d commit 9240a5f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 47 deletions.
Expand Up @@ -35,7 +35,6 @@
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.Instant;
Expand Down Expand Up @@ -103,9 +102,13 @@ private Number getNbHits(String apiId) {
query.setRootIdentifier(apiId);
query.setField("response-time");

StatsAnalytics analytics = analyticsService.execute(query);
if (analytics != null) {
return analytics.getCount();
try {
final StatsAnalytics analytics = analyticsService.execute(query);
if (analytics != null) {
return analytics.getCount();
}
} catch (final Exception e) {
// do nothing as the analytics errors should not break the portal
}
return null;
}
Expand Down
Expand Up @@ -17,7 +17,6 @@

import io.gravitee.common.http.MediaType;
import io.gravitee.rest.api.model.SubscriptionEntity;
import io.gravitee.rest.api.model.SubscriptionStatus;
import io.gravitee.rest.api.model.analytics.TopHitsAnalytics;
import io.gravitee.rest.api.model.analytics.query.GroupByQuery;
import io.gravitee.rest.api.model.api.ApiEntity;
Expand All @@ -37,7 +36,6 @@
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.*;
Expand Down Expand Up @@ -100,18 +98,20 @@ public Response getSubscriberApplicationsByApiId(@BeanParam PaginationParam pagi
}

private int compareApp(Map<String, Long> nbHitsByApp, Application o1, Application o2) {
if(nbHitsByApp.get(o1.getId()) == null && nbHitsByApp.get(o2.getId()) == null) {
return 0;
}
if(nbHitsByApp.get(o1.getId()) == null && nbHitsByApp.get(o2.getId()) != null) {
return 1;
}
if(nbHitsByApp.get(o1.getId()) != null && nbHitsByApp.get(o2.getId()) == null) {
return -1;
}
int compareTo = nbHitsByApp.get(o2.getId()).compareTo(nbHitsByApp.get(o1.getId()));
if(compareTo != 0) {
return compareTo;
if (nbHitsByApp != null) {
if(nbHitsByApp.get(o1.getId()) == null && nbHitsByApp.get(o2.getId()) == null) {
return 0;
}
if(nbHitsByApp.get(o1.getId()) == null && nbHitsByApp.get(o2.getId()) != null) {
return 1;
}
if(nbHitsByApp.get(o1.getId()) != null && nbHitsByApp.get(o2.getId()) == null) {
return -1;
}
int compareTo = nbHitsByApp.get(o2.getId()).compareTo(nbHitsByApp.get(o1.getId()));
if(compareTo != 0) {
return compareTo;
}
}
return o1.getName().compareTo(o2.getName());
}
Expand All @@ -126,9 +126,13 @@ private Map<String, Long> getNbHitsByApplication(String apiId) {
query.setRootField("api");
query.setRootIdentifier(apiId);

TopHitsAnalytics analytics = analyticsService.execute(query);
if (analytics != null) {
return analytics.getValues();
try {
final TopHitsAnalytics analytics = analyticsService.execute(query);
if (analytics != null) {
return analytics.getValues();
}
} catch (final Exception e) {
// do nothing as the analytics errors should not break the portal
}
return null;
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -56,8 +56,8 @@
"name": "--gv-theme-neutral-color",
"description": "Neutral color",
"type": "color",
"default": "#E5E5E5",
"value": "#E5E5E5"
"default": "#F5F5F5",
"value": "#F5F5F5"
},
{
"name": "--gv-theme-neutral-color-light",
Expand Down Expand Up @@ -512,26 +512,19 @@
{
"name": "gv-row",
"css": [
{
"name": "--gv-row--bgc",
"description": "Background color",
"type": "color",
"default": "var(--gv-theme-neutral-color-lightest, #FFFFFF)",
"value": ""
},
{
"name": "--gv-row-hover--bgc",
"description": "Background color when hover",
"description": "Hoover background color",
"type": "color",
"default": "var(--gv-theme-neutral-color-lighter, #FAFAFA)",
"value": ""
},
{
"name": "--gv-row-icon--s",
"description": "Height and icon width",
"type": "length",
"default": "14px",
"value": "14px"
"name": "--gv-row-hover--trf-ty",
"description": "Hoover transform translateY",
"type": "string",
"default": "0",
"value": "0"
},
{
"name": "--gv-row-image--h",
Expand Down Expand Up @@ -589,7 +582,7 @@
"name": "--gv-rating-list--bdc",
"description": "Border color",
"type": "color",
"default": "var(--gv-theme-neutral-color, #E5E5E5)",
"default": "var(--gv-theme-neutral-color, #F5F5F5)",
"value": ""
},
{
Expand Down Expand Up @@ -662,7 +655,7 @@
"name": "--gv-popover--bdc",
"description": "Border color",
"type": "color",
"default": "var(--gv-theme-neutral-color, #E5E5E5)",
"default": "var(--gv-theme-neutral-color, #F5F5F5)",
"value": ""
},
{
Expand Down Expand Up @@ -702,7 +695,7 @@
"name": "--gv-plans-characteristics--bdc",
"description": "Characteristics border color",
"type": "color",
"default": "var(--gv-theme-neutral-color, #E5E5E5)",
"default": "var(--gv-theme-neutral-color, #F5F5F5)",
"value": ""
},
{
Expand Down Expand Up @@ -1234,7 +1227,7 @@
"name": "--gv-select--bdc",
"description": "Border color",
"type": "color",
"default": "var(--gv-theme-neutral-color, #E5E5E5)",
"default": "var(--gv-theme-neutral-color, #F5F5F5)",
"value": ""
},
{
Expand Down Expand Up @@ -1443,7 +1436,7 @@
"name": "--gv-input--bdc",
"description": "Border color",
"type": "color",
"default": "var(--gv-theme-neutral-color, #E5E5E5)",
"default": "var(--gv-theme-neutral-color, #F5F5F5)",
"value": ""
}
]
Expand Down Expand Up @@ -1549,17 +1542,24 @@
"name": "gv-autocomplete",
"css": [
{
"name": "--gv-autocomplete-match--bgc",
"description": "Macth background color",
"name": "--gv-autocomplete-hover--bgc",
"description": "Hover background color",
"type": "color",
"default": "var(--gv-theme-color-light, #D5FDCB)",
"default": "var(--gv-theme-neutral-color-lighter, #FAFAFA)",
"value": ""
},
{
"name": "--gv-autocomplete-hover--bgc",
"description": "Hover background color",
"name": "--gv-autocomplete--bgc",
"description": "Background color",
"type": "color",
"default": "var(--gv-theme-neutral-color-lightest, #FFFFFF)",
"value": ""
},
{
"name": "--gv-autocomplete--c",
"description": "Color",
"type": "color",
"default": "var(--gv-theme-neutral-color-light, #EFEFEF)",
"default": "var(--gv-theme-font-color, #262626)",
"value": ""
}
]
Expand Down

0 comments on commit 9240a5f

Please sign in to comment.