diff --git a/.gitignore b/.gitignore index 9c3d08d3c06..b720258a6a6 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ target # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/node_modules/ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml new file mode 100644 index 00000000000..cb06ef09800 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml @@ -0,0 +1,169 @@ + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt + 3.0.46-SNAPSHOT + + + org.wso2.carbon.device.application.mgt.publisher.ui + 3.0.46-SNAPSHOT + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + 4-p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.application.mgt + ../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + + org.eclipse.equinox.p2.type.group:false + + + + + + + + + + + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + npm install (initialize) + + exec + + initialize + + ${basedir}/src/main/resources/publisher + ${npm.executable} + + install + + + + + + + + npm run build (compile) + + exec + + compile + + ${basedir}/src/main/resources/publisher + ${npm.executable} + + run + ${npm.build.command} + + + + + + + + + + + + + + + + + + + + + ${npm.working.dir} + + + + + + + + platform-windows + + + windows + + + + + npm.cmd + + + + + false + npm + build_prod + ./src/main/ + + + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc new file mode 100644 index 00000000000..02f08fb6c0f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + "es2015" + ] +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json new file mode 100644 index 00000000000..c2513e64c52 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/package.json @@ -0,0 +1,51 @@ +{ + "name": "wso2_iot_app_publisher", + "version": "1.0.0", + "description": "WSO2 IoT Server App Publisher", + "main": "App.js", + "repository": { + "type": "git", + "url": "git://github.com/wso2/carbon-devicemgt" + }, + "author": "WSO2 Org", + "license": "Apache License 2.0", + "dependencies": { + "antd": "^2.12.3", + "axios": "^0.16.2", + "flux": "^3.1.3", + "history": "^4.6.3", + "react": "^15.6.1", + "react-dom": "^15.6.1", + "react-images-uploader": "^1.1.0", + "react-modal": "^2.2.2", + "react-router": "^4.1.2", + "react-router-dom": "^4.1.2", + "react-scripts": "1.0.10", + "react-sliding-pane": "^1.2.3", + "react-table": "^6.5.1" + }, + "devDependencies": { + "babel-core": "^6.24.1", + "babel-loader": "^7.0.0", + "babel-plugin-transform-class-properties": "^6.24.1", + "babel-preset-es2015": "^6.24.1", + "chai": "^4.0.2", + "babel-preset-react": "^6.24.1", + "babel-register": "^6.24.1", + "css-loader": "^0.28.2", + "less": "^2.7.2", + "less-loader": "^4.0.4", + "mocha": "^3.4.1", + "mock-local-storage": "^1.0.2", + "style-loader": "^0.18.1", + "webpack": "^2.5.0" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build --history-api-fallback", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject", + "build_prod": "NODE_ENV=production webpack -p --progress --colors --config webpack.config.js", + "build_dev": "NODE_ENV=development webpack -d --config webpack.config.js --watch " + } +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/images/favicon.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/images/favicon.png new file mode 100644 index 00000000000..a1deab3581b Binary files /dev/null and b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/images/favicon.png differ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html new file mode 100644 index 00000000000..7739ff27086 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/index.html @@ -0,0 +1,42 @@ + + + + + + + + + + + + + WSO2 IoT App Publisher + + + +
+ + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/manifest.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/manifest.json new file mode 100644 index 00000000000..2a700bb50e7 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "App Publisher", + "name": "WSO2 IoT App Publisher", + "icons": [ + { + "src": "images/favicon.png", + "sizes": "16x16", + "type": "image/png" + } + ], + "start_url": "./index.html", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.css new file mode 100644 index 00000000000..e69de29bb2d diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js new file mode 100644 index 00000000000..27c65444b7f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.js @@ -0,0 +1,33 @@ +/* + * 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. + */ + +import React, { Component } from 'react'; +import './App.css'; + +class App extends Component { + render() { + return ( +
+
+
+
+ ); + } +} + +export default App; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.test.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.test.js new file mode 100644 index 00000000000..79b7f3f6659 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/App.test.js @@ -0,0 +1,26 @@ +/* + * 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. + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); +}); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.css new file mode 100644 index 00000000000..b4cc7250b98 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.css @@ -0,0 +1,5 @@ +body { + margin: 0; + padding: 0; + font-family: sans-serif; +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js new file mode 100644 index 00000000000..369f8d3d362 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/index.js @@ -0,0 +1,26 @@ +/* + * 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. + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import './index.css'; +import App from './App'; +import registerServiceWorker from './registerServiceWorker'; + +ReactDOM.render(, document.getElementById('root')); +registerServiceWorker(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/registerServiceWorker.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/registerServiceWorker.js new file mode 100644 index 00000000000..94bc5f9982c --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/registerServiceWorker.js @@ -0,0 +1,126 @@ +/* + * 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. + */ + +// In production, we register a service worker to serve assets from local cache. + +// This lets the app load faster on subsequent visits in production, and gives +// it offline capabilities. However, it also means that developers (and users) +// will only see deployed updates on the "N+1" visit to a page, since previously +// cached resources are updated in the background. + +// To learn more about the benefits of this model, read https://goo.gl/KwvDNy. +// This link also includes instructions on opting out of this behavior. + +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) +); + +export default function register() { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 + return; + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/publisher/service-worker.js`; + + if (!isLocalhost) { + // Is not local host. Just register service worker + registerValidSW(swUrl); + } else { + // This is running on localhost. Lets check if a service worker still exists or not. + checkValidServiceWorker(swUrl); + } + }); + } +} + +function registerValidSW(swUrl) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the old content will have been purged and + // the fresh content will have been added to the cache. + // It's the perfect time to display a "New content is + // available; please refresh." message in your web app. + console.log('New content is available; please refresh.'); + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.'); + } + } + }; + }; + }) + .catch(error => { + console.error('Error during service worker registration:', error); + }); +} + +function checkValidServiceWorker(swUrl) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + if ( + response.status === 404 || + response.headers.get('content-type').indexOf('javascript') === -1 + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload(); + }); + }); + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl); + } + }) + .catch(() => { + console.log( + 'No internet connection found. App is running in offline mode.' + ); + }); +} + +export function unregister() { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.ready.then(registration => { + registration.unregister(); + }); + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js new file mode 100644 index 00000000000..c03279bd3df --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/webpack.config.js @@ -0,0 +1,51 @@ +var path = require('path'); + +const config = { + entry: { + index: './src/index.js' + }, + output: { + path: path.resolve(__dirname, 'public/dist'), + filename: '[name].js' + }, + devtool: "source-map", + plugins: [], + watch: false, + module: { + rules: [ + { + test: /\.(js|jsx)$/, + exclude: /node_modules/, + use: [ + { + loader: 'babel-loader', + options: { + presets: ['es2015', 'react'], + plugins: ['transform-class-properties'] + } + } + ] + }, + { + test: /\.css$/, + use: [ 'style-loader', 'css-loader' ] + }, + { + test: /\.less$/, + use: [{ + loader: "style-loader" // creates style nodes from JS strings + }, { + loader: "css-loader" // translates CSS into CommonJS + }, { + loader: "less-loader" // compiles Less to CSS + }] + } + ] + } +}; + +if (process.env.NODE_ENV === "development") { + config.watch = true; +} + +module.exports = config; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml new file mode 100644 index 00000000000..9cee98dd925 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml @@ -0,0 +1,168 @@ + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt + 3.0.46-SNAPSHOT + + org.wso2.carbon.device.application.mgt.store.ui + 3.0.46-SNAPSHOT + + + + + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + 4-p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.application.mgt.store + ../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + + org.eclipse.equinox.p2.type.group:false + + + + + + + + + + + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + npm install (initialize) + + exec + + initialize + + ${basedir}/src/main/resources/store + ${npm.executable} + + install + + + + + + + + npm run build (compile) + + exec + + compile + + ${basedir}/src/main/resources/publisher + ${npm.executable} + + run + ${npm.build.command} + + + + + + + + + + + + + + + + + + + + + ${npm.working.dir} + + + + + + + + platform-windows + + + windows + + + + + npm.cmd + + + + + false + npm + build_prod + ./src/main/ + + + \ No newline at end of file diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 9770fd06432..61523a4ba9f 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -37,7 +37,7 @@ org.wso2.carbon.device.application.mgt.core org.wso2.carbon.device.application.mgt.common org.wso2.carbon.device.application.mgt.api - org.wso2.carbon.device.application.mgt.ui + org.wso2.carbon.device.application.mgt.publisher.ui diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml new file mode 100644 index 00000000000..e9da7bcff09 --- /dev/null +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt-feature + 3.0.46-SNAPSHOT + + org.wso2.carbon.device.application.mgt.publisher.ui.feature + 3.0.46-SNAPSHOT + + + \ No newline at end of file diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml new file mode 100644 index 00000000000..33f45fc1e08 --- /dev/null +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + + org.wso2.carbon.devicemgt + application-mgt-feature + 3.0.46-SNAPSHOT + + org.wso2.carbon.device.application.mgt.store.ui.feature + 3.0.46-SNAPSHOT + + + \ No newline at end of file diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 4a39791ffc3..f70cb75863b 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -35,9 +35,10 @@ org.wso2.carbon.device.application.mgt.api.feature - org.wso2.carbon.device.application.mgt.ui.feature + org.wso2.carbon.device.application.mgt.feature org.wso2.carbon.device.application.mgt.server.feature + org.wso2.carbon.device.application.mgt.publisher.ui.feature \ No newline at end of file