Skip to content

Commit c530571

Browse files
committed
added dynamic github button
1 parent e40aafc commit c530571

6 files changed

Lines changed: 113 additions & 9 deletions

File tree

src/main/java/com/microsoft/azure/samples/perfsimjava/controller/HealthController.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,18 @@ public ResponseEntity<Map<String, String>> readiness() {
8989
*/
9090
@GetMapping("/config")
9191
public ResponseEntity<Map<String, Object>> config() {
92-
return ResponseEntity.ok(Map.of(
93-
"latencyProbeIntervalMs", appConfig.getProbeIntervalMs(),
94-
"metricsIntervalMs", appConfig.getMetricsIntervalMs(),
95-
"idleTimeoutMinutes", idleService.getIdleTimeoutMinutes()
96-
));
92+
Map<String, Object> response = new HashMap<>();
93+
response.put("latencyProbeIntervalMs", appConfig.getProbeIntervalMs());
94+
response.put("metricsIntervalMs", appConfig.getMetricsIntervalMs());
95+
response.put("idleTimeoutMinutes", idleService.getIdleTimeoutMinutes());
96+
97+
// GitHub repository link configuration (optional)
98+
String githubRepoName = System.getenv("GITHUB_REPO_NAME");
99+
String githubUserName = System.getenv("GITHUB_USER_NAME");
100+
response.put("githubRepoName", githubRepoName);
101+
response.put("githubUserName", githubUserName);
102+
103+
return ResponseEntity.ok(response);
97104
}
98105

99106
/**

src/main/resources/static/azure-deployment.html

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ <h2><svg class="java-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 3
368368
</a>
369369
<div class="sidebar-divider"></div>
370370
<div class="sidebar-section-label">External</div>
371-
<a href="https://github.com/rhamlett/perfsimjava" target="_blank" class="sidebar-nav-item">
371+
<a id="github-repo-link" href="#" target="_blank" class="sidebar-nav-item" style="display:none">
372372
<span class="nav-icon">🐙</span>
373373
<span class="nav-label">GitHub Repository<span class="nav-desc">Source code & issues</span></span>
374374
</a>
@@ -748,6 +748,41 @@ <h4>Setting via Azure Portal</h4>
748748
<li>Click <strong>Apply</strong>, then <strong>Confirm</strong></li>
749749
</ol>
750750

751+
<h3>GitHub Repository Link</h3>
752+
<p>By default, the GitHub Repository link in the sidebar menu is hidden. Set both environment variables below to display a link to your GitHub repository in the navigation menu.</p>
753+
754+
<h4>Environment Variables</h4>
755+
<table class="env-table">
756+
<thead>
757+
<tr>
758+
<th>Variable Name</th>
759+
<th>Description</th>
760+
</tr>
761+
</thead>
762+
<tbody>
763+
<tr>
764+
<td><code>GITHUB_USER_NAME</code></td>
765+
<td>The GitHub username or organization that owns the repository.</td>
766+
</tr>
767+
<tr>
768+
<td><code>GITHUB_REPO_NAME</code></td>
769+
<td>The name of the GitHub repository.</td>
770+
</tr>
771+
</tbody>
772+
</table>
773+
774+
<h4>Example</h4>
775+
<p>To link to <code>https://github.com/myorg/myrepo</code>, set:</p>
776+
<ul>
777+
<li><code>GITHUB_USER_NAME=myorg</code></li>
778+
<li><code>GITHUB_REPO_NAME=myrepo</code></li>
779+
</ul>
780+
781+
<h4>Setting via Azure CLI</h4>
782+
<pre><code># Set the GitHub repository link
783+
az webapp config appsettings set --name $APP_NAME --resource-group $RESOURCE_GROUP \
784+
--settings GITHUB_USER_NAME=myorg GITHUB_REPO_NAME=myrepo</code></pre>
785+
751786
</section>
752787

753788
<section id="troubleshooting" class="card">
@@ -992,6 +1027,23 @@ <h2>Quick Reference - CLI One-Liner</h2>
9921027
console.error('Failed to fetch config', e);
9931028
}
9941029
})();
1030+
1031+
// Load GitHub link configuration
1032+
(async function() {
1033+
try {
1034+
const response = await fetch('/api/health/config');
1035+
const config = await response.json();
1036+
if (config.githubUserName && config.githubRepoName) {
1037+
const githubLink = document.getElementById('github-repo-link');
1038+
if (githubLink) {
1039+
githubLink.href = `https://github.com/${config.githubUserName}/${config.githubRepoName}`;
1040+
githubLink.style.display = '';
1041+
}
1042+
}
1043+
} catch (error) {
1044+
console.log('Could not load GitHub link config');
1045+
}
1046+
})();
9951047
</script>
9961048
</body>
9971049
</html>

src/main/resources/static/azure-diagnostics.html

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ <h2><svg class="java-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 3
5050
</a>
5151
<div class="sidebar-divider"></div>
5252
<div class="sidebar-section-label">External</div>
53-
<a href="https://github.com/rhamlett/perfsimjava" target="_blank" class="sidebar-nav-item">
53+
<a id="github-repo-link" href="#" target="_blank" class="sidebar-nav-item" style="display:none">
5454
<span class="nav-icon">🐙</span>
5555
<span class="nav-label">GitHub Repository<span class="nav-desc">Source code & issues</span></span>
5656
</a>
@@ -513,6 +513,24 @@ <h2>ON THIS PAGE</h2>
513513
}
514514
}
515515
loadBuildInfo();
516+
517+
// Load GitHub link configuration
518+
async function loadGithubLink() {
519+
try {
520+
const response = await fetch('/api/health/config');
521+
const config = await response.json();
522+
if (config.githubUserName && config.githubRepoName) {
523+
const githubLink = document.getElementById('github-repo-link');
524+
if (githubLink) {
525+
githubLink.href = `https://github.com/${config.githubUserName}/${config.githubRepoName}`;
526+
githubLink.style.display = '';
527+
}
528+
}
529+
} catch (error) {
530+
console.log('Could not load GitHub link config');
531+
}
532+
}
533+
loadGithubLink();
516534
</script>
517535
</body>
518536
</html>

src/main/resources/static/docs.html

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ <h2><svg class="java-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 3
5050
</a>
5151
<div class="sidebar-divider"></div>
5252
<div class="sidebar-section-label">External</div>
53-
<a href="https://github.com/rhamlett/perfsimjava" target="_blank" class="sidebar-nav-item">
53+
<a id="github-repo-link" href="#" target="_blank" class="sidebar-nav-item" style="display:none">
5454
<span class="nav-icon">🐙</span>
5555
<span class="nav-label">GitHub Repository<span class="nav-desc">Source code & issues</span></span>
5656
</a>
@@ -794,6 +794,24 @@ <h2>ON THIS PAGE</h2>
794794
}
795795
}
796796
loadBuildInfo();
797+
798+
// Load GitHub link configuration
799+
async function loadGithubLink() {
800+
try {
801+
const response = await fetch('/api/health/config');
802+
const config = await response.json();
803+
if (config.githubUserName && config.githubRepoName) {
804+
const githubLink = document.getElementById('github-repo-link');
805+
if (githubLink) {
806+
githubLink.href = `https://github.com/${config.githubUserName}/${config.githubRepoName}`;
807+
githubLink.style.display = '';
808+
}
809+
}
810+
} catch (error) {
811+
console.log('Could not load GitHub link config');
812+
}
813+
}
814+
loadGithubLink();
797815
</script>
798816
</body>
799817
</html>

src/main/resources/static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ <h2><svg class="java-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 3
5454
</a>
5555
<div class="sidebar-divider"></div>
5656
<div class="sidebar-section-label">External</div>
57-
<a href="https://github.com/rhamlett/perfsimjava" target="_blank" class="sidebar-nav-item">
57+
<a id="github-repo-link" href="#" target="_blank" class="sidebar-nav-item" style="display:none">
5858
<span class="nav-icon">🐙</span>
5959
<span class="nav-label">GitHub Repository<span class="nav-desc">Source code & issues</span></span>
6060
</a>

src/main/resources/static/js/dashboard.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,15 @@ const Dashboard = (function() {
717717
const idleTimeoutStr = idleTimeout === 0 ? 'disabled' : `${idleTimeout}m`;
718718

719719
addEvent('success', `Dashboard initialized (probe rate: ${probeRate}ms, idle timeout: ${idleTimeoutStr})`);
720+
721+
// Show GitHub link if both GITHUB_USER_NAME and GITHUB_REPO_NAME are configured
722+
if (config.githubUserName && config.githubRepoName) {
723+
const githubLink = document.getElementById('github-repo-link');
724+
if (githubLink) {
725+
githubLink.href = `https://github.com/${config.githubUserName}/${config.githubRepoName}`;
726+
githubLink.style.display = '';
727+
}
728+
}
720729
} catch (error) {
721730
console.error('[Dashboard] Failed to load config:', error);
722731
addEvent('success', 'Dashboard initialized');

0 commit comments

Comments
 (0)