Skip to content

Commit

Permalink
Add api to contribute custom views and a sample for custom views
Browse files Browse the repository at this point in the history
  • Loading branch information
joshiste committed Jul 19, 2018
1 parent abbcc7e commit 75a960a
Show file tree
Hide file tree
Showing 48 changed files with 13,668 additions and 484 deletions.
10 changes: 10 additions & 0 deletions spring-boot-admin-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@
<module>spring-boot-admin-sample-reactive</module>
<module>spring-boot-admin-sample-war</module>
<module>spring-boot-admin-sample-hazelcast</module>
<module>spring-boot-admin-sample-custom-ui</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-sample-custom-ui</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<!-- Turn on filtering by default for application properties -->
<resources>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.DS_Store
node_modules
/dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/app'
]
}
12,191 changes: 12,191 additions & 0 deletions spring-boot-admin-samples/spring-boot-admin-sample-custom-ui/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "spring-boot-admin-sample-custom-ui",
"private": true,
"scripts": {
"build": "vue-cli-service build",
"watch": "vue-cli-service build --watch",
"lint": "vue-cli-service lint"
},
"peerDependencies": {
"vue": "^2.5.16"
},
"dependencies": {},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.0-rc.5",
"@vue/cli-plugin-eslint": "^3.0.0-rc.5",
"@vue/cli-service": "^3.0.0-rc.5",
"@vue/eslint-config-standard": "^3.0.0-rc.5",
"vue-template-compiler": "^2.5.16"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"eslint:recommended",
"plugin:vue/strongly-recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2014-2018 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-boot-admin-sample-custom-ui</artifactId>
<name>Spring Boot Admin Server custom UI</name>
<description>Spring Boot Admin Server custom UI</description>
<parent>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-samples</artifactId>
<version>${revision}</version>
<relativePath>..</relativePath>
</parent>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>npm-install</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>npm-build</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
<environmentVariables>
<PROJECT_VERSION>${project.version}</PROJECT_VERSION>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>target/dist</directory>
<targetPath>META-INF/spring-boot-admin-server-ui/extensions/custom</targetPath>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--
- Copyright 2014-2018 the original author or authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-->

<template>
<div class="custom">
Instance: <span v-text="instance.id"/>
Output: <span v-text="text"/>
</div>
</template>

<script>
export default {
props: {
instance: {
type: Object,
required: true
}
},
data: () => ({
text: ''
}),
async created() {
const response = await this.instance.axios.get('actuator/custom');
this.text = response.data;
}
};
</script>

<style>
.custom {
font-size: 20px;
width: 80%;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
- Copyright 2014-2018 the original author or authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-->

<template>
<pre v-text="stringify(applications, null, 4)"/>
</template>

<script>
export default {
props: {
applications: {
type: Array,
required: true
}
},
methods: {
stringify: JSON.stringify
}
};
</script>

<style>
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import custom from './custom';
import customEndpoint from './custom-endpoint';

/* global SBA */
SBA.extensions.push({
install({viewRegistry}) {
viewRegistry.addView({
name: 'custom',
path: '/custom',
component: custom,
props: true,
label: 'Custom',
order: 1000,
});

viewRegistry.addView({
name: 'instances/custom',
parent: 'instances',
path: 'custom',
component: customEndpoint,
props: true,
label: 'Custom',
order: 1000,
isEnabled: ({instance}) => instance.hasEndpoint('custom')
});
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

module.exports = {
outputDir: 'target/dist',
chainWebpack: config => {
config.entryPoints.delete('app');
config.entry('custom').add('./src/index.js');
config.externals({
vue: {
commonjs: 'vue',
commonjs2: 'vue',
root: 'Vue'
}
});
config.output.libraryTarget('var');
config.optimization.splitChunks(false);
config.module
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => ({
...options,
hotReload: false
}));
config.plugins.delete('html');
config.plugins.delete('preload');
config.plugins.delete('prefetch');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<relativePath>..</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-sample-custom-ui</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package de.codecentric.boot.admin;

import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;

@Endpoint(id = "custom")
public class CustomEndpoint {

@ReadOperation
public String invoke() {
return "Hello World!";
}
}
Loading

0 comments on commit 75a960a

Please sign in to comment.