Skip to content

Commit a3cb55d

Browse files
committed
avniproject/avni-webapp#1618 | Add show_templates to CopilotConfig
1 parent ddc64d3 commit a3cb55d

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

avni-server-api/src/main/java/org/avni/server/web/AuthDetailsController.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.avni.server.web;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import org.avni.server.config.AvniKeycloakConfig;
45
import org.avni.server.config.CognitoConfig;
56
import org.avni.server.config.IdpType;
@@ -32,6 +33,9 @@ public class AuthDetailsController {
3233
@Value("${avni.copilot.enabled}")
3334
private boolean copilotEnabled;
3435

36+
@JsonProperty("show_templates")
37+
private boolean showTemplates;
38+
3539
@Autowired
3640
public AuthDetailsController(AvniKeycloakConfig avniKeycloakConfig, AdapterConfig adapterConfig, CognitoConfig cognitoConfig) {
3741
this.avniKeycloakConfig = avniKeycloakConfig;
@@ -54,7 +58,7 @@ public CompositeIDPDetails getIDPDetails() {
5458
String cognitoConfigClientId = cognitoConfig.getClientId();
5559
return new AuthDetailsController.CompositeIDPDetails( keycloakAuthServerUrl, keycloakClientId,
5660
keycloakGrantType, keycloakScope, avniKeycloakConfig.getRealm(), cognitoConfigPoolId,
57-
cognitoConfigClientId, idpType, webAppTimeoutInMinutes, avniEnvironment, avniMcpServerUrl, copilotEnabled);
61+
cognitoConfigClientId, idpType, webAppTimeoutInMinutes, avniEnvironment, avniMcpServerUrl, copilotEnabled, showTemplates);
5862
}
5963

6064
public static class CompositeIDPDetails {
@@ -64,11 +68,11 @@ public static class CompositeIDPDetails {
6468
private final Cognito cognito;
6569

6670
public CompositeIDPDetails( String authServerUrl, String keycloakClientId, String grantType, String scope, String keycloakRealm,
67-
String poolId, String clientId, IdpType idpType, int webAppTimeoutInMinutes, String avniEnvironment, String avniMcpServerUrl, boolean copilotEnabled) {
71+
String poolId, String clientId, IdpType idpType, int webAppTimeoutInMinutes, String avniEnvironment, String avniMcpServerUrl, boolean copilotEnabled, boolean showTemplates) {
6872
this.idpType = idpType;
6973
this.keycloak = new Keycloak(authServerUrl, keycloakClientId, grantType, scope, keycloakRealm);
7074
this.cognito = new Cognito(poolId, clientId);
71-
this.genericConfig = new GenericConfig(webAppTimeoutInMinutes, avniEnvironment, avniMcpServerUrl, copilotEnabled);
75+
this.genericConfig = new GenericConfig(webAppTimeoutInMinutes, avniEnvironment, avniMcpServerUrl, copilotEnabled, showTemplates);
7276
}
7377

7478
public Keycloak getKeycloak() {
@@ -146,12 +150,14 @@ public static class GenericConfig {
146150
private final String avniEnvironment;
147151
private final String avniMcpServerUrl;
148152
private final boolean copilotEnabled;
153+
private final boolean showTemplates;
149154

150-
public GenericConfig(int webAppTimeoutInMinutes, String avniEnvironment, String avniMcpServerUrl, boolean copilotEnabled) {
155+
public GenericConfig(int webAppTimeoutInMinutes, String avniEnvironment, String avniMcpServerUrl, boolean copilotEnabled, boolean showTemplates) {
151156
this.webAppTimeoutInMinutes = webAppTimeoutInMinutes;
152157
this.avniEnvironment = avniEnvironment;
153158
this.avniMcpServerUrl = avniMcpServerUrl;
154159
this.copilotEnabled = copilotEnabled;
160+
this.showTemplates = showTemplates;
155161
}
156162

157163
public int getWebAppTimeoutInMinutes() {
@@ -169,6 +175,10 @@ public String getAvniMcpServerUrl() {
169175
public boolean isCopilotEnabled() {
170176
return copilotEnabled;
171177
}
178+
179+
public boolean isShowTemplates() {
180+
return showTemplates;
181+
}
172182
}
173183
}
174184
}

avni-server-api/src/main/java/org/avni/server/web/util/Configuration.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public class Configuration {
2929
@Value("${avni.mcp.server.url}")
3030
private String mcpServerUrl;
3131

32+
@Value("${avni.showTemplates}")
33+
private boolean showTemplates;
34+
3235
public List<ReportingSystem> getReportingSystems() {
3336
return reportingSystems;
3437
}
@@ -50,9 +53,9 @@ public RestTemplate restTemplate() {
5053

5154
public CopilotConfig createCopilotConfig() {
5255
if ("dummy".equals(copilotToken)) {
53-
return new CopilotConfig(null, copilotEnabled, baseUrl, mcpServerUrl);
56+
return new CopilotConfig(null, copilotEnabled, baseUrl, mcpServerUrl, showTemplates);
5457
}
5558

56-
return new CopilotConfig(copilotToken, copilotEnabled, baseUrl, mcpServerUrl);
59+
return new CopilotConfig(copilotToken, copilotEnabled, baseUrl, mcpServerUrl, showTemplates);
5760
}
5861
}

avni-server-api/src/main/java/org/avni/server/web/util/CopilotConfig.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ public class CopilotConfig {
1616
@JsonProperty("mcp_server_url")
1717
private String mcpServerUrl;
1818

19+
@JsonProperty("show_templates")
20+
private Boolean showTemplates;
21+
1922
public CopilotConfig() {
2023
}
2124

22-
public CopilotConfig(String avniCopilotToken, Boolean avniCopilotEnabled, String baseUrl, String mcpServerUrl) {
25+
public CopilotConfig(String avniCopilotToken, Boolean avniCopilotEnabled, String baseUrl, String mcpServerUrl, Boolean showTemplates) {
2326
this.avniCopilotToken = avniCopilotToken;
2427
this.avniCopilotEnabled = avniCopilotEnabled;
2528
this.baseUrl = baseUrl;
2629
this.mcpServerUrl = mcpServerUrl;
30+
this.showTemplates = showTemplates;
2731
}
2832

2933
public String getAvniCopilotToken() {
@@ -57,4 +61,12 @@ public String getMcpServerUrl() {
5761
public void setMcpServerUrl(String mcpServerUrl) {
5862
this.mcpServerUrl = mcpServerUrl;
5963
}
64+
65+
public Boolean getShowTemplates() {
66+
return showTemplates;
67+
}
68+
69+
public void setShowTemplates(Boolean showTemplates) {
70+
this.showTemplates = showTemplates;
71+
}
6072
}

avni-server-api/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ spring.servlet.multipart.max-request-size=100MB
8686
avni.mcp.server.url=${AVNI_MCP_SERVER_URL:https://localhost:8023}
8787
avni.copilot.token=${AVNI_COPILOT_TOKEN:dummy}
8888
avni.copilot.enabled=${AVNI_COPILOT_ENABLED:false}
89+
avni.showTemplates=${AVNI_SHOW_TEMPLATES:false}
8990
avni.base.url=${AVNI_BASE_URL:https://localhost:8021}
9091
# Network
9192
server.tomcat.protocol-header=x-forwarded-proto

avni-server-api/src/test/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ spring.flyway.schemas=public
2020
spring.flyway.baseline-on-migrate=false
2121
avni.mcp.server.url=${AVNI_MCP_SERVER_URL:https://localhost:8023}
2222
avni.copilot.enabled=${AVNI_COPILOT_ENABLED:false}
23+
avni.showTemplates=${AVNI_SHOW_TEMPLATES:false}
2324
avni.copilot.token=${AVNI_COPILOT_TOKEN:dummy}
2425
avni.base.url=${AVNI_BASE_URL:https://localhost:8021}
2526

0 commit comments

Comments
 (0)