Beispiel #1
0
  private void displayTargetCountStatus() {
    final TargetTableFilters targFilParams = managementUIState.getTargetTableFilters();
    final StringBuilder message = getTotalTargetMessage();

    if (targFilParams.hasFilter()) {
      message.append(HawkbitCommonUtil.SP_STRING_PIPE);
      message.append(i18n.get("label.filter.targets"));
      if (managementUIState.getTargetsTruncated() != null) {
        message.append(targetTable.size() + managementUIState.getTargetsTruncated());
      } else {
        message.append(targetTable.size());
      }
      message.append(HawkbitCommonUtil.SP_STRING_PIPE);
      final String status = i18n.get("label.filter.status");
      final String overdue = i18n.get("label.filter.overdue");
      final String tags = i18n.get("label.filter.tags");
      final String text = i18n.get("label.filter.text");
      final String dists = i18n.get("label.filter.dist");
      final String custom = i18n.get("label.filter.custom");
      final StringBuilder filterMesgBuf = new StringBuilder(i18n.get("label.filter"));
      filterMesgBuf.append(HawkbitCommonUtil.SP_STRING_SPACE);
      filterMesgBuf.append(getStatusMsg(targFilParams.getClickedStatusTargetTags(), status));
      filterMesgBuf.append(getOverdueStateMsg(targFilParams.isOverdueFilterEnabled(), overdue));
      filterMesgBuf.append(
          getTagsMsg(targFilParams.isNoTagSelected(), targFilParams.getClickedTargetTags(), tags));
      filterMesgBuf.append(
          targFilParams
              .getSearchText()
              .map(search -> text)
              .orElse(HawkbitCommonUtil.SP_STRING_SPACE));
      filterMesgBuf.append(
          targFilParams
              .getDistributionSet()
              .map(set -> dists)
              .orElse(HawkbitCommonUtil.SP_STRING_SPACE));
      filterMesgBuf.append(
          targFilParams
              .getTargetFilterQuery()
              .map(query -> custom)
              .orElse(HawkbitCommonUtil.SP_STRING_SPACE));
      final String filterMesageChk = filterMesgBuf.toString().trim();
      String filterMesage = filterMesageChk;
      if (filterMesage.endsWith(",")) {
        filterMesage = filterMesageChk.substring(0, filterMesageChk.length() - 1);
      }
      message.append(filterMesage);
    }

    if ((targetTable.size() + Optional.fromNullable(managementUIState.getTargetsTruncated()).or(0L))
        > SPUIDefinitions.MAX_TABLE_ENTRIES) {
      message.append(HawkbitCommonUtil.SP_STRING_PIPE);
      message.append(i18n.get("label.filter.shown"));
      message.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
    }

    setCaption(message.toString());
  }
Beispiel #2
0
  private StringBuilder getTotalTargetMessage() {
    if (managementUIState.getTargetsTruncated() != null) {
      // set the icon
      setIcon(FontAwesome.INFO_CIRCLE);
      setDescription(
          i18n.get(
              "label.target.filter.truncated",
              managementUIState.getTargetsTruncated(),
              SPUIDefinitions.MAX_TABLE_ENTRIES));
    } else {
      setIcon(null);
      setDescription(null);
    }

    final StringBuilder message = new StringBuilder(i18n.get("label.target.filter.count"));
    message.append(managementUIState.getTargetsCountAll());

    return message;
  }