This is an automated email from the ASF dual-hosted git repository.
magicaltrout pushed a commit to branch development
in repository https://gitbox.apache.org/repos/asf/oodt.git
The following commit(s) were added to refs/heads/development by this push:
new b9ec596 [OODT-986] Add OODT NodeJS File Viewer Prototype (#92)
b9ec596 is described below
commit b9ec596cfb0c0e9efc2d566087d19de082dd41c2
Author: Nadeeshan Gimhana <[email protected]>
AuthorDate: Wed Apr 24 17:44:16 2019 +0530
[OODT-986] Add OODT NodeJS File Viewer Prototype (#92)
* Add oodt-fm-react-plugin-sample
* Add sample fm_swagger
* Remove React-Plugin-Sample
* Add OODT NodeJS File Viewer prototype
* Rename react-webapp to react-components
* Merge top-level .gitignore with react-component.gitignore
* Add Apache2.0eLicense Headers
* Update Apache-2.0 License Headers in react-components
* epdate .gitignore
---
.gitignore | 9 +
.../fm_swagger_implementation/swagger_fm.json | 44 +++++
react-components/oodt_fm_plugin/.babelrc | 4 +
react-components/oodt_fm_plugin/.npmignore | 7 +
react-components/oodt_fm_plugin/README.md | 64 +++++++
react-components/oodt_fm_plugin/package.json | 39 +++++
.../src/components/Product/Product.js | 184 +++++++++++++++++++++
.../oodt_fm_plugin/src/components/Product/index.js | 21 +++
.../oodt_fm_plugin/src/components/index.js | 18 ++
.../oodt_fm_plugin/src/constants/fmconnection.js | 22 +++
react-components/oodt_fm_plugin/src/index.js | 20 +++
react-components/oodt_fm_plugin/webpack.config.js | 21 +++
12 files changed, 453 insertions(+)
diff --git a/.gitignore b/.gitignore
index 954abc0..d0ed242 100644
--- a/.gitignore
+++ b/.gitignore
@@ -120,3 +120,12 @@ local.properties
# Apple OS X folder attributes
.DS_Store
+
+# node_modules
+/react-components/oodt_fm_plugin/node_modules
+
+# npm build/Tarball ignores
+/react-components/oodt_fm_plugin/dist
+
+# Runtime package.json ignores
+/react-components/oodt_fm_plugin/package-lock.json
\ No newline at end of file
diff --git a/react-components/fm_swagger_implementation/swagger_fm.json
b/react-components/fm_swagger_implementation/swagger_fm.json
new file mode 100644
index 0000000..1976b8e
--- /dev/null
+++ b/react-components/fm_swagger_implementation/swagger_fm.json
@@ -0,0 +1,44 @@
+{
+ "swagger" : "2.0",
+ "info" : {
+ "description" : "This is a sample API for Apache-OODT File Manager",
+ "version" : "1.0.0",
+ "title" : "Apache OODT FM API",
+ "contact" : {
+ "email" : "[email protected]"
+ },
+ "license" : {
+ "name" : "Apache 2.0",
+ "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
+ }
+ },
+ "host" : "46.4.26.22:8012",
+ "basePath" : "/fmprod/jaxrs",
+ "schemes" : [ "http" ],
+ "paths" : {
+ "/product" : {
+ "get" : {
+ "summary" : "searches product",
+ "description" : "By passing in the appropriate options, you can search
for\navailable products in the system\n",
+ "operationId" : "searchProduct",
+ "produces" : [ "application/json" ],
+ "parameters" : [ {
+ "name" : "productId",
+ "in" : "query",
+ "description" : "pass an productId. As an example
ce4380c5-d0d2-11e8-89ca-971c29fc9f21",
+ "required" : true,
+ "type" : "string"
+ } ],
+ "responses" : {
+ "200" : {
+ "description" : "search results matching criteria"
+ },
+ "400" : {
+ "description" : "bad input parameter"
+ }
+ }
+ }
+ }
+ },
+ "definitions" : { }
+}
\ No newline at end of file
diff --git a/react-components/oodt_fm_plugin/.babelrc
b/react-components/oodt_fm_plugin/.babelrc
new file mode 100644
index 0000000..e60d303
--- /dev/null
+++ b/react-components/oodt_fm_plugin/.babelrc
@@ -0,0 +1,4 @@
+{
+ "presets": ["@babel/preset-env", "@babel/preset-react"],
+ "plugins": ["@babel/plugin-proposal-class-properties"]
+}
diff --git a/react-components/oodt_fm_plugin/.npmignore
b/react-components/oodt_fm_plugin/.npmignore
new file mode 100644
index 0000000..fcfcf05
--- /dev/null
+++ b/react-components/oodt_fm_plugin/.npmignore
@@ -0,0 +1,7 @@
+# IDE temp files
+.idea
+
+# Development Tarball of the plugin
+oodt_fm_plugin_sample-1.0.0.tgz
+
+package-lock.json
\ No newline at end of file
diff --git a/react-components/oodt_fm_plugin/README.md
b/react-components/oodt_fm_plugin/README.md
new file mode 100644
index 0000000..59f60f0
--- /dev/null
+++ b/react-components/oodt_fm_plugin/README.md
@@ -0,0 +1,64 @@
+# React OODT File Manager Plugin Sample
+
+
+## Requirements
+
+- [Node.js](https://nodejs.org/en/download/) v6.0.0 or higher
+- NPM (v3.0.0+ recommended) (this comes with Node.js)
+
+## Installation
+
+**Using NPM:**
+
+Since this Plugin is not officially published yet please follow below steps
for local testing.
+1. Install Node Modules for web pack dependencies.
+ ```
+ npm install
+ ```
+
+1. In the root of your NPM package, do this to build.
+ ```
+ npm run build
+ ```
+
+2. Install the Package into local node_modules.
+ ```
+ npm install . -g
+ ```
+3. Create a symlink package that points to your working directory.
+ ```
+ npm link
+ ```
+
+4. Local NPM Package installation. Use this command in relevant React project
directory. This will link global node_module plugin directory to project's
local node_modules directory.
+ ```
+ npm link oodt_fm_plugin_sample
+ ```
+## Usage
+
+Here's an example of basic usage:
+
+```
+import React, { Component } from 'react';
+import { Product } from 'oodt_fm_plugin_sample';
+
+class MyApp extends Component {
+ render() {
+ return (
+ <div>
+ <Product productId="ce4380c5-d0d2-11e8-89ca-121c29fc9f21" />
+ </div>
+ );
+ }
+}
+
+export default MyApp;
+```
+
+#### props
+
+- `productId`: Product ID key (eg.: `ce4380c5-d0d2-11e8-89ca-121c29fc9f21`).
+
+## Contributing
+
+Developers can add New Components (eg: Product, ProductList...) by following
the directory structure and export them accordingly in index.js files.
\ No newline at end of file
diff --git a/react-components/oodt_fm_plugin/package.json
b/react-components/oodt_fm_plugin/package.json
new file mode 100644
index 0000000..f81ce33
--- /dev/null
+++ b/react-components/oodt_fm_plugin/package.json
@@ -0,0 +1,39 @@
+{
+ "name": "oodt_fm_plugin_sample",
+ "version": "1.0.0",
+ "description": "This is a Sample React Plugin for Apache OODT File Manager",
+ "main": "dist/build.js",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/NGimhana/oodt_fm_plugin"
+ },
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "build": "webpack --mode production"
+ },
+ "keywords": [
+ "react",
+ "components",
+ "Apache",
+ "OODT",
+ "File Manager"
+ ],
+ "author": "Nadeeshan Gimhana",
+ "license": "Apache-2.0",
+ "devDependencies": {
+ "@babel/core": "^7.2.2",
+ "@babel/preset-env": "^7.2.3",
+ "@babel/preset-react": "^7.0.0",
+ "@babel/plugin-proposal-class-properties": "^7.4.0",
+ "babel-loader": "^8.0.5",
+ "webpack": "^4.28.3",
+ "webpack-cli": "^3.2.0"
+ },
+ "dependencies": {
+ "@material-ui/core": "^3.9.3",
+ "axios": "^0.18.0",
+ "react": "^16.7.0",
+ "react-dom": "^16.7.0",
+ "prop-types": "latest"
+ }
+}
diff --git a/react-components/oodt_fm_plugin/src/components/Product/Product.js
b/react-components/oodt_fm_plugin/src/components/Product/Product.js
new file mode 100644
index 0000000..c5acc2f
--- /dev/null
+++ b/react-components/oodt_fm_plugin/src/components/Product/Product.js
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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 Card from '@material-ui/core/Card';
+import CardContent from '@material-ui/core/CardContent';
+import Button from '@material-ui/core/Button';
+import Typography from '@material-ui/core/Typography';
+import {withStyles} from "@material-ui/core";
+import PropTypes from "prop-types";
+import {fmconnection} from "../../constants/fmconnection";
+import Grid from "@material-ui/core/Grid";
+import Fab from "@material-ui/core/Fab";
+
+const styles = theme => ({
+ root: {
+ flexGrow: 1,
+ backgroundColor: theme.palette.background.paper,
+ },
+ card: {
+ minWidth: 275,
+ backgroundColor: "#dcdcdc",
+
+ },
+ bullet: {
+ display: 'inline-block',
+ margin: '0 2px',
+ transform: 'scale(0.8)',
+ },
+ title: {
+ fontSize: 14,
+
+ },
+ pos: {
+ marginBottom: 12,
+ },
+});
+
+class Product extends Component {
+
+
+ constructor(props) {
+ super(props);
+ }
+
+ state = {
+ productData: [],
+ productMetaDataFileLocation:[],
+ productMetaDataFileType:[],
+ productMetaDataMimeType:[],
+ productReferencesData: [],
+ productId : this.props.productId,
+ };
+
+ render() {
+
+ const { classes } = this.props;
+ return(
+ <div className={classes.root}>
+ <Card className={classes.card}>
+
+ <Grid>
+ <Grid container spacing={24}>
+ <Grid item xs={3}>
+ <CardContent>
+ <Typography variant="h4" color="textPrimary" gutterBottom>
+ FILE INFO
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ FILE NAME : <strong>{this.state.productData["name"]}</strong>
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ PRODUCT ID : <strong>{this.state.productData["id"]}</strong>
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ STRUCTURE : <strong>{this.state.productData["structure"]}</strong>
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ TRANSFER STATUS :
<strong>{this.state.productData["transferStatus"]}</strong>
+ </Typography>
+ </CardContent>
+ </Grid>
+
+ <Grid item xs={3}>
+ <CardContent>
+ <Typography variant="h4" color="textPrimary" gutterBottom>
+ <span style={{color:"black"}}>METADATA INFO</span>
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ <span style={{color:"black"}}>FILE LOCATION</span> :
<strong>{this.state.productMetaDataFileLocation["val"]}</strong>
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ PRODUCT TYPE :
<strong>{this.state.productMetaDataFileType["val"]}</strong>
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ MIME TYPE : <strong>{this.state.productMetaDataMimeType[0]}</strong>
+ </Typography>
+ </CardContent>
+ <Button style={{background:"green"}}><span
style={{color:"white"}}>View All Metadata</span></Button>
+ </Grid>
+
+ <Grid item xs={3}>
+ <CardContent>
+ <Typography variant="h4" color="textPrimary" gutterBottom>
+ REFERENCE INFO
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ DATA STORE REF LOCATION :
<strong>{this.state.productReferencesData["dataStoreReference"]}</strong>
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ FILE SIZE :
<strong>{this.state.productReferencesData["fileSize"]}</strong>
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ ORIGINAL REFERENCE :
<strong>{this.state.productReferencesData["originalReference"]}</strong>
+ </Typography>
+ </CardContent>
+ <Button style={{background:"green"}}><span
style={{color:"white"}}>View All References</span></Button>
+ </Grid>
+
+ <Grid item xs={3}>
+ <CardContent>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ <Fab variant="extended" color="primary"
style={{fontSize:20}}>Download File</Fab>
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ <Fab variant="extended" color="primary" style={{fontSize:20
,background:"green"}}>View in File Manager</Fab>
+ </Typography>
+ <Typography variant="h6" color="textPrimary" gutterBottom>
+ <Fab variant="extended" color="secondary" style={{fontSize:20}}>Remove
Record</Fab>
+ </Typography>
+ </CardContent>
+ </Grid>
+ </Grid>
+ </Grid>
+
+
+ </Card>
+ </div>
+ );
+ }
+
+ componentDidMount() {
+ console.log(this.state.productId);
+ // Make a request for a product with a given ID
+ fmconnection.get("/product?productId=" +this.state.productId)
+
+ .then(res => {
+ this.setState({
+ productData:res.data.product,
+
productMetaDataFileLocation:Object.values(res.data.product.metadata)[0][0],
+
productMetaDataFileType:Object.values(res.data.product.metadata)[0][1],
+
productMetaDataMimeType:Object.values(res.data.product.metadata)[0][7]["val"],
+
productReferencesData:res.data.product.references.reference,
+ });
+ console.log(this.state.productMetaDataFileLocation["val"]);
+ console.log(this.state.productMetaDataFileType["val"]);
+ console.log(this.state.productMetaDataMimeType[0]);
+
+ })
+ .catch(err=>{
+ console.log(err);
+ })
+ }
+}
+
+Product.propTypes = {
+ classes: PropTypes.object.isRequired,
+};
+
+export default withStyles(styles)(Product);
diff --git a/react-components/oodt_fm_plugin/src/components/Product/index.js
b/react-components/oodt_fm_plugin/src/components/Product/index.js
new file mode 100644
index 0000000..2e2501e
--- /dev/null
+++ b/react-components/oodt_fm_plugin/src/components/Product/index.js
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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 the Product component from this folder and send it down to
./components/index.js
+import Product from './Product';
+
+export default Product;
diff --git a/react-components/oodt_fm_plugin/src/components/index.js
b/react-components/oodt_fm_plugin/src/components/index.js
new file mode 100644
index 0000000..b4c8c0c
--- /dev/null
+++ b/react-components/oodt_fm_plugin/src/components/index.js
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.
+ */
+
+export { default as Product } from './Product';
diff --git a/react-components/oodt_fm_plugin/src/constants/fmconnection.js
b/react-components/oodt_fm_plugin/src/constants/fmconnection.js
new file mode 100644
index 0000000..e3597d9
--- /dev/null
+++ b/react-components/oodt_fm_plugin/src/constants/fmconnection.js
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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 axios from "axios";
+
+export const fmconnection = axios.create({
+ baseURL: 'http://46.4.26.22:8012/fmprod/jaxrs',
+});
diff --git a/react-components/oodt_fm_plugin/src/index.js
b/react-components/oodt_fm_plugin/src/index.js
new file mode 100644
index 0000000..3dc3ab3
--- /dev/null
+++ b/react-components/oodt_fm_plugin/src/index.js
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.
+ */
+
+// Export all the explicitly exported components, this file will contain our
+// components when built by webpack and sent off to the world.
+export * from './components';
\ No newline at end of file
diff --git a/react-components/oodt_fm_plugin/webpack.config.js
b/react-components/oodt_fm_plugin/webpack.config.js
new file mode 100644
index 0000000..d0e1a26
--- /dev/null
+++ b/react-components/oodt_fm_plugin/webpack.config.js
@@ -0,0 +1,21 @@
+const path = require('path');
+
+module.exports = {
+ entry: './src/index.js',
+ module: {
+ rules: [
+ {
+ test: /\.js$/,
+ use:{
+ loader: "babel-loader",
+ },
+ },
+ ]
+ },
+ output: {
+ path: path.resolve(__dirname, 'dist/'),
+ publicPath: '',
+ filename: 'build.js',
+ libraryTarget: 'umd'
+ }
+};
\ No newline at end of file