Skip to content

Commit

Permalink
Display the version
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-yves-monnet committed Jul 3, 2024
1 parent 757e8bd commit 1cc66d9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main/frontend/src/parameter/Parameters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,25 @@ class Parameters extends React.Component {
</div>


<div className="row" style={{marginTop: "10px"}}>
<div className="col-md-6">
<div className="card" style={{width: "25rem;"}}>
<div className="card-header" style={{backgroundColor: "rgba(0,0,0,.03)"}}>About</div>
<div className="card-body">
<div className="row">
<div className="col-md-12">
<TextInput labelText="Version"
readonly="true"
value={this.state.parameters.version}
style={{width: "300px"}}
/>
</div>
</div>
</div>
</div>
</div>
</div>

</div>
)

Expand All @@ -307,7 +326,7 @@ class Parameters extends React.Component {


/**
* Set a parameter property property
* Set a parameter
* @param propertyName name of the property in parameters
* @param propertyValue the value
*/
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/io/camunda/cherry/admin/AdminRestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;

import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;

@RestController
@RequestMapping("cherry")
public class AdminRestController {
Expand Down Expand Up @@ -97,6 +103,9 @@ public Map<String, Object> getParameters() {
} catch (Exception e) {
logger.error("During getParameters() " + e);
}

parameters.put("version", getVersion());

return parameters;
}

Expand All @@ -110,4 +119,14 @@ public void setNumberOfThread(@RequestParam(name = "threads") Integer numberOfTh
jobRunnerFactory.setNumberOfThreads(numberOfThreads);
}

private String getVersion() {
MavenXpp3Reader reader = new MavenXpp3Reader();
try (FileReader fileReader = new FileReader("pom.xml")) {
Model model = reader.read(fileReader);
return model.getVersion();
} catch (IOException | XmlPullParserException e) {
logger.error("Exception during load pom.xml: {}", e);
return null;
}
}
}

0 comments on commit 1cc66d9

Please sign in to comment.