Skip to content

Commit

Permalink
Add ability to only show own properties
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Kruger <[email protected]>
  • Loading branch information
phillip-kruger committed May 31, 2023
1 parent b95c6ec commit 410494a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.quarkus.devui.spi.page.Page;
import io.quarkus.vertx.http.deployment.devmode.console.ConfigEditorProcessor;
import io.quarkus.vertx.http.runtime.devmode.ConfigDescription;
import io.smallrye.config.ConfigValue;
import io.smallrye.config.SmallRyeConfig;

/**
Expand Down Expand Up @@ -158,7 +159,7 @@ private List<ConfigDescription> calculate(List<ConfigDescription> cd, Set<String
}
}
properties.add(item.getName());
item.setConfigValue(current.getConfigValue(item.getName()));
item.setConfigValue(getConfigValue(current,item.getName()));
ordered.add(item);
} else if (!item.getName().startsWith("quarkus.log.filter")) { //special case, we use this internally and we don't want it clogging up the editor
//we need to figure out how to expand it
Expand Down Expand Up @@ -239,7 +240,7 @@ private List<ConfigDescription> calculate(List<ConfigDescription> cd, Set<String
item.getConfigPhase());

properties.add(newDesc.getName());
newDesc.setConfigValue(current.getConfigValue(newDesc.getName()));
newDesc.setConfigValue(getConfigValue(current,newDesc.getName()));
ordered.add(newDesc);
}

Expand All @@ -265,7 +266,7 @@ private List<ConfigDescription> calculate(List<ConfigDescription> cd, Set<String
ConfigDescription newDesc = new ConfigDescription(expandedName, true);

properties.add(newDesc.getName());
newDesc.setConfigValue(current.getConfigValue(newDesc.getName()));
newDesc.setConfigValue(getConfigValue(current,newDesc.getName()));
ordered.add(newDesc);
}

Expand All @@ -281,7 +282,7 @@ private List<ConfigDescription> calculate(List<ConfigDescription> cd, Set<String
continue;
}

ConfigDescription item = new ConfigDescription(propertyName, null, null, current.getConfigValue(propertyName));
ConfigDescription item = new ConfigDescription(propertyName, null, null, getConfigValue(current,propertyName));
ordered.add(item);

configDescriptions.add(item);
Expand All @@ -291,6 +292,14 @@ private List<ConfigDescription> calculate(List<ConfigDescription> cd, Set<String
return ordered;
}

private ConfigValue getConfigValue(SmallRyeConfig config, String name){
try {
return config.getConfigValue(name);
} catch(java.util.NoSuchElementException nse){
return null;
}
}

private String ensureQuoted(String part) {
if (isQuoted(part)) {
return part;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export class QwcConfiguration extends observeState(LitElement) {
overflow: hidden;
}
.confTopBar {
display: flex;
justify-content: space-between;
align-items: center;
}
vaadin-grid {
height: 100%;
}
Expand Down Expand Up @@ -82,10 +88,13 @@ export class QwcConfiguration extends observeState(LitElement) {
`;

static properties = {
_filtered: {state: true, type: Array},
_filtered: {state: true, type: Array}, // Filter the visible configuration
_visibleConfiguration: {state: true, type: Array}, // Either all or just user's configuration
_values: {state: true},
_detailsOpenedItem: {state: true, type: Array},
_busy: {state: true},
_showOnlyOwnProperties: {state: true},
_searchTerm: {state: true}
};

constructor() {
Expand All @@ -96,13 +105,16 @@ export class QwcConfiguration extends observeState(LitElement) {
if(this._filteredValue){
this._filteredValue = this._filteredValue.replaceAll(",", " OR ");
}

this._filtered = devuiState.allConfiguration;
this._visibleConfiguration = devuiState.allConfiguration;
this._filtered = this._visibleConfiguration;
this.jsonRpc.getAllValues().then(e => {
this._values = e.result;
});
this._detailsOpenedItem = [];
this._busy = null;

this._showOnlyOwnProperties = false;
this._searchTerm = '';
}

render() {
Expand Down Expand Up @@ -132,31 +144,56 @@ export class QwcConfiguration extends observeState(LitElement) {
}

_filterTextChanged(e) {
const searchTerm = (e.detail.value || '').trim();
if (searchTerm === '') {
this._filtered = devuiState.allConfiguration;
this._searchTerm = (e.detail.value || '').trim();
return this._filterGrid();
}

_filterGrid(){
if (this._searchTerm === '') {
this._filtered = this._visibleConfiguration;
return;
}

this._filtered = devuiState.allConfiguration.filter((prop) => {
return this._match(prop.name, searchTerm) || this._match(prop.description, searchTerm)
this._filtered = this._visibleConfiguration.filter((prop) => {
return this._match(prop.name, this._searchTerm) || this._match(prop.description, this._searchTerm)
});
}

_render() {
return html`<div class="conf">
<vaadin-text-field
placeholder="Filter"
value="${this._filteredValue}"
style="width: 100%;"
@value-changed="${(e) => this._filterTextChanged(e)}">
<vaadin-icon slot="prefix" icon="font-awesome-solid:filter"></vaadin-icon>
<qui-badge slot="suffix"><span>${this._filtered.length}</span></qui-badge>
</vaadin-text-field>
<div class="confTopBar">
<vaadin-text-field
placeholder="Filter"
value="${this._filteredValue}"
style="flex: 1;"
@value-changed="${(e) => this._filterTextChanged(e)}">
<vaadin-icon slot="prefix" icon="font-awesome-solid:filter"></vaadin-icon>
<qui-badge slot="suffix"><span>${this._filtered.length}</span></qui-badge>
</vaadin-text-field>
<vaadin-checkbox theme="small" label="Show only my properties"
@change="${(event) => {
this._toggleShowOnlyOwnProperties(event.target.checked);
}}"
.checked=${this._showOnlyOwnProperties}>
</vaadin-checkbox>
</div>
${this._renderGrid()}
</div>`;
}

_toggleShowOnlyOwnProperties(onlyMine){
this._showOnlyOwnProperties = onlyMine;
if(this._showOnlyOwnProperties){
this._visibleConfiguration = devuiState.allConfiguration.filter((prop) => {
return (prop.configValue.sourceName && prop.configValue.sourceName.startsWith("PropertiesConfigSource[source")
&& prop.configValue.sourceName.endsWith("/application.properties]"));
});
}else {
this._visibleConfiguration = devuiState.allConfiguration;
}
return this._filterGrid();
}

_renderGrid(){
if(this._busy){
return html`${this._renderStyledGrid("disabledDatatable")}`;
Expand Down

0 comments on commit 410494a

Please sign in to comment.