Skip to content

Commit

Permalink
make Widget State sample widget to a Maven module
Browse files Browse the repository at this point in the history
org.wso2.carbon.dashboards.samples.widgets.widget-state
  • Loading branch information
this authored and lasanthaS committed Nov 8, 2017
1 parent 1923f43 commit 8b86bca
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 55 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@
<version>${carbon.dashboards.version}</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.wso2.carbon.dashboards.samples.widgets</groupId>
<artifactId>org.wso2.carbon.dashboards.samples.widgets.widget-state</artifactId>
<version>${carbon.dashboards.version}</version>
<type>zip</type>
</dependency>
<!--Feature-->
<dependency>
<groupId>org.wso2.carbon.dashboards.samples</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
<artifactId>org.wso2.carbon.dashboards.samples.widgets.total-updates</artifactId>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.wso2.carbon.dashboards.samples.widgets</groupId>
<artifactId>org.wso2.carbon.dashboards.samples.widgets.widget-state</artifactId>
<type>zip</type>
</dependency>

<!--Gson-->
<dependency>
Expand Down
51 changes: 27 additions & 24 deletions samples/widgets/WidgetState/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"scripts": {
"start": "react-scripts start",
"build": "webpack -p",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"ajv": "^5.2.2",
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-register": "^6.26.0",
"node-sass": "^4.5.3",
"sass-loader": "^6.0.6",
"webpack": "^3.5.5"
}
"name": "widget-state-widget",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"scripts": {
"start": "react-scripts start",
"build": "webpack -p",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"clean": "rimraf dist"
},
"devDependencies": {
"ajv": "^5.2.2",
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-register": "^6.26.0",
"copy-webpack-plugin": "^4.2.0",
"node-sass": "^4.5.3",
"recharts": "^1.0.0-alpha.4",
"sass-loader": "^6.0.6",
"webpack": "^3.5.6"
}
}
50 changes: 50 additions & 0 deletions samples/widgets/WidgetState/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>org.wso2.carbon.dashboards.samples.widgets.widget-state</artifactId>
<packaging>pom</packaging>
<version>4.0.0.alpha4-SNAPSHOT</version>

<name>WSO2 Carbon Dashboards - Samples - Widgets - Widget State</name>
<url>http://wso2.org</url>

<parent>
<groupId>org.wso2.carbon.dashboards.samples.widgets</groupId>
<artifactId>widgets-parent</artifactId>
<version>4.0.0.alpha4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
6 changes: 6 additions & 0 deletions samples/widgets/WidgetState/src/resources/widgetConf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "WidgetState",
"id": "WidgetState",
"thumbnailURL": "",
"configs": {}
}
74 changes: 43 additions & 31 deletions samples/widgets/WidgetState/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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.
*/

const path = require('path');
const webpack = require('webpack')
const webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
context: path.resolve(__dirname, './src'),
entry: {
index: './WidgetState.jsx',
index: './WidgetState.jsx'
},
output: {
path: path.resolve(__dirname, './dist/'),
filename: 'bundle.js',
path: path.resolve(__dirname, './dist/WidgetState/'),
filename: 'WidgetState.js'
},
module: {
loaders: [
{
test: /\.html$/,
use: [{
loader: 'html-loader',
}],
use: [{loader: 'html-loader'}]
},
{
test: /\.js$/,
Expand All @@ -24,51 +42,45 @@ module.exports = {
{
loader: 'babel-loader',
query: {
presets: ['es2015', 'react'],
},
},
],
presets: ['es2015', 'react']
}
}
]
},
{
test: /\.(png|jpg|svg|cur|gif|eot|svg|ttf|woff|woff2)$/,
use: ['url-loader'],
use: ['url-loader']
},
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react'],
},
presets: ['es2015', 'react']
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
use: ['style-loader', 'css-loader']
},
{
test: /\.scss$/,
use: [{
loader: 'style-loader',
}, {
loader: 'css-loader',
}, {
loader: 'sass-loader',
}],
},
use: [{loader: 'style-loader'}, {loader: 'css-loader'}, {loader: 'sass-loader'}]
}

],
]
},
plugins: [
new webpack.ProvidePlugin({
'React': 'react',
'ReactDOM': 'react-dom'
})
new CopyWebpackPlugin([
{from: path.resolve(__dirname, './src/resources/')}
])
],
resolve: {
extensions: ['.js', '.json', '.jsx', '.scss'],
extensions: ['.js', '.json', '.jsx', '.scss']
},
devtool: 'source-map',
devServer: {
contentBase: path.join(__dirname, 'public'),
publicPath: '/dist/',
},
publicPath: '/dist/'
}
};
1 change: 1 addition & 0 deletions samples/widgets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<module>ServerStatus</module>
<module>Subscriber</module>
<module>TotalUpdates</module>
<module>WidgetState</module>
</modules>

<build>
Expand Down

0 comments on commit 8b86bca

Please sign in to comment.