Skip to content

Commit

Permalink
Merge pull request #139 from Paul-Blanchaert/configurable-search-inde…
Browse files Browse the repository at this point in the history
…x-name

Configurable search index name: solr/elastic/opensearch
  • Loading branch information
epugh authored Feb 20, 2024
2 parents 3668efb + 2ad986b commit 01c1259
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 17 deletions.
16 changes: 15 additions & 1 deletion app/models/FeatureToggleModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ package object FeatureToggleModel extends Logging {
private val FEATURE_TOGGLE_RULE_DEPLOYMENT_CUSTOM_SCRIPT = "toggle.rule-deployment.custom-script"
private val FEATURE_TOGGLE_RULE_DEPLOYMENT_CUSTOM_SCRIPT_SMUI2SOLR_SH_PATH = "toggle.rule-deployment.custom-script-SMUI2SOLR-SH_PATH"
private val FEATURE_TOGGLE_HEADLINE = "toggle.headline"
private val FEATURE_TOGGLE_DEPLOYMENT_LABEL = "toggle.rule-deployment-label"
private val FEATURE_TOGGLE_DEPLOYMENT_PRELIVE_LABEL = "toggle.rule-deployment-prelive-label"
private val ACTIVATE_RULE_TAGGING = "toggle.rule-tagging"
private val PREDEFINED_TAGS_FILE = "toggle.predefined-tags-file"
private val SMUI_VERSION = "smui.version"
Expand Down Expand Up @@ -160,7 +162,11 @@ package object FeatureToggleModel extends Logging {
}
}
)
)
),
JsFeatureToggle(FEATURE_TOGGLE_DEPLOYMENT_LABEL, new JsStringFeatureToggleValue(
appConfig.getOptional[String](FEATURE_TOGGLE_DEPLOYMENT_LABEL).getOrElse("LIVE"))),
JsFeatureToggle(FEATURE_TOGGLE_DEPLOYMENT_PRELIVE_LABEL, new JsStringFeatureToggleValue(
appConfig.getOptional[String](FEATURE_TOGGLE_DEPLOYMENT_PRELIVE_LABEL).getOrElse("PRELIVE")))
)
}

Expand Down Expand Up @@ -216,6 +222,14 @@ package object FeatureToggleModel extends Logging {
appConfig.getOptional[Boolean](FEATURE_TOGGLE_RULE_DEPLOYMENT_PRE_LIVE_PRESENT).getOrElse(false)
}

def getSmuiRuleDeploymentLabel: String = {
appConfig.getOptional[String](FEATURE_TOGGLE_DEPLOYMENT_LABEL).getOrElse("LIVE")
}

def getSmuiRuleDeploymentPreliveLabel: String = {
appConfig.getOptional[String](FEATURE_TOGGLE_DEPLOYMENT_PRELIVE_LABEL).getOrElse("PRELIVE")
}

}

}
6 changes: 3 additions & 3 deletions app/models/SearchManagementRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ class SearchManagementRepository @Inject()(dbapi: DBApi, toggleService: FeatureT
val solrIndexIdId = SolrIndexId(solrIndexId)
val inputTags = InputTag.loadAll.filter(_.solrIndexId== Option(solrIndexIdId))
if (inputTags.size > 0) {
throw new Exception("Can't delete Solr Index that has " + inputTags.size + "tags existing");
throw new Exception("Can't delete rules collection that has " + inputTags.size + "tags existing");
}

val canonicalSpellings = CanonicalSpelling.loadAllForIndex(solrIndexIdId)
if (canonicalSpellings.size > 0) {
throw new Exception("Can't delete Solr Index that has " + canonicalSpellings.size + " canonical spellings existing");
throw new Exception("Can't delete rules collection that has " + canonicalSpellings.size + " canonical spellings existing");
}

val searchInputs = SearchInput.loadAllForIndex(solrIndexIdId)
if (searchInputs.size > 0) {
throw new Exception("Can't delete Solr Index that has " + searchInputs.size + " inputs existing");
throw new Exception("Can't delete rules collection that has " + searchInputs.size + " inputs existing");
}

// TODO consider reconfirmation and deletion of history entries (if some exist) (see https://github.com/querqy/smui/issues/97)
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import com.typesafe.sbt.GitBranchPrompt

name := "search-management-ui"
version := "4.0.8"
version := "4.0.9"
maintainer := "Contact productful.io <[email protected]>"

scalaVersion := "2.12.17"
Expand Down
6 changes: 6 additions & 0 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ toggle.rule-deployment.custom-script-SMUI2SOLR-SH_PATH=${?SMUI_TOGGLE_DEPL_CUSTO
toggle.headline="Search Management UI"
toggle.headline=${?SMUI_HEADLINE}

toggle.rule-deployment-label="LIVE"
toggle.rule-deployment-label=${?SMUI_TOGGLE_DEPL_NAME}

toggle.deploy-prelive-fn-label="PRELIVE"
toggle.deploy-prelive-fn-label=${?SMUI_TOGGLE_PRELIVE_NAME}

toggle.rule-tagging=false
toggle.rule-tagging=${?SMUI_RULE_TAGGING_ACTIVE}

Expand Down
19 changes: 11 additions & 8 deletions frontend/src/app/components/header-nav/header-nav.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</ul>

<div *ngIf="hideSolrIndexSelector()">
In order to push the rules, <a routerLink="/admin">please create a Solr collection first</a>.
In order to push the rules, <a routerLink="/admin">please create a rules collection first</a>.
</div>
<div
*ngIf="currentSolrIndexId && currentSolrIndexId !== '-1'"
Expand All @@ -80,7 +80,10 @@

<div class="depl-info-container border-left border-right pl-2">
<ng-container *ngFor="let singleDeploymentInfo of deploymentLogInfo; index as idxDeploy">
<span class="depl-info-row-instance"><b>{{ singleDeploymentInfo.targetSystem }}</b> deployment:</span>
<span class="depl-info-row-instance">
<b>{{ (singleDeploymentInfo.targetSystem == 'PRELIVE' ?
featureToggleService.getSync('toggle.rule-deployment-prelive-label') :
featureToggleService.getSync('toggle.rule-deployment-label'))}}</b> deployment:</span>
<span class="depl-info-row-datetime"><b>{{ singleDeploymentInfo.formattedDateTime }}</b></span>
<span class="depl-info-row-result">
<b
Expand All @@ -105,6 +108,9 @@
</div>
<div class="btn-group">
<button
*ngIf="
featureToggleService.getSyncToggleRuleDeploymentPreLivePresent()
"
type="button"
class="btn btn-outline-primary"
(click)="publishSolrConfig()"
Expand All @@ -117,9 +123,6 @@
{{ publishToPreliveButtonText() }}
</button>
<button
*ngIf="
featureToggleService.getSyncToggleRuleDeploymentPreLivePresent()
"
type="button"
class="btn btn-outline-danger"
(click)="modalService.open('confirm-publish-live')"
Expand Down Expand Up @@ -161,9 +164,9 @@
</div>
</app-smui-modal>

<app-smui-modal id="confirm-publish-live" title="Confirm publish to LIVE">
<app-smui-modal id="confirm-publish-live" title="Confirm publish to {{ featureToggleService.getSync('toggle.rule-deployment-label') }}">
<div content>
<p>Are you sure to publish current Search Rules to LIVE?</p>
<p>Are you sure to publish current Search Rules to {{ featureToggleService.getSync('toggle.rule-deployment-label') }}?</p>
</div>
<div footer class="btn-toolbar">
<button
Expand All @@ -172,7 +175,7 @@
(click)="requestPublishRulesTxtToSolr('LIVE')"
>
<i class="fa fa-thumbs-up smui-icon"></i>
Yes, publish to LIVE
Yes, publish to {{ featureToggleService.getSync('toggle.rule-deployment-label') }}
</button>
<button
class="btn btn-danger"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ export class HeaderNavComponent implements OnInit {

public publishToPreliveButtonText(): string {
return this.deploymentRunningForStage === 'PRELIVE'
? 'Pushing to Solr...'
: 'Push Config to Solr';
? 'Publishing to ' + this.featureToggleService.getSync('toggle.rule-deployment-prelive-label') + '...'
: 'Publish to ' + this.featureToggleService.getSync('toggle.rule-deployment-prelive-label') + '';
}

public publishToLiveButtonText(): string {
return this.deploymentRunningForStage === 'LIVE'
? 'Publishing to LIVE...'
: 'Publish to LIVE';
? 'Publishing to ' + this.featureToggleService.getSync('toggle.rule-deployment-label') + '...'
: 'Publish to ' + this.featureToggleService.getSync('toggle.rule-deployment-label') + '';
}

public publishSolrConfig() {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/app/services/feature-toggle.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const FEATURE_TOGGLE_UI_LIST_LIMIT_ITEMS_TO = 'toggle.ui-list.limit-items-to';
const FEATURE_ACTIVATE_SPELLING = 'toggle.activate-spelling';
const FEATURE_ACTIVATE_EVENTHISTORY = 'toggle.activate-eventhistory';
const FEATURE_CUSTOM_UP_DOWN_MAPPINGS = 'toggle.ui-concept.custom.up-down-dropdown-mappings';
const FEATURE_TOGGLE_DEPLOYMENT_LABEL = "toggle.rule-deployment-label";
const FEATURE_TOGGLE_DEPLOYMENT_PRELIVE_LABEL = "toggle.rule-deployment-prelive-label";


@Injectable({
providedIn: 'root'
Expand Down

0 comments on commit 01c1259

Please sign in to comment.