Browse Source

first commit

master
Venturinha 2 years ago
commit
a77c9e5f7c
46 changed files with 594 additions and 0 deletions
  1. +7
    -0
      .editor.config
  2. +18
    -0
      .gitignore
  3. +0
    -0
      README.md
  4. +3
    -0
      config/_development.js
  5. +3
    -0
      config/_production.js
  6. BIN
      config/icon.png
  7. BIN
      public/images/logo-main.png
  8. BIN
      public/images/logo.png
  9. +159
    -0
      public/scripts/ui.js
  10. +1
    -0
      public/scripts/ui.js.map
  11. +13
    -0
      public/styles/main.css
  12. +1
    -0
      public/styles/ui.css
  13. +22
    -0
      server/core/_config.js
  14. +5
    -0
      server/core/_init.js
  15. +0
    -0
      server/core/_request_close.js
  16. +0
    -0
      server/core/_request_end.js
  17. +17
    -0
      server/core/_request_error.js
  18. +2
    -0
      server/core/_request_start.js
  19. +14
    -0
      server/core/_request_url.js
  20. +13
    -0
      server/core/_service_config.js
  21. +0
    -0
      server/core/_service_end.js
  22. +5
    -0
      server/core/_service_error.js
  23. +0
    -0
      server/core/_service_start.js
  24. +7
    -0
      server/package.json
  25. +0
    -0
      server/setup/_end.js
  26. +0
    -0
      server/setup/_start.js
  27. +24
    -0
      server/templates/dashboard.html
  28. +31
    -0
      server/templates/dev/dashboard.html
  29. +1
    -0
      server/templates/scripts.html
  30. +0
    -0
      server/templates/scripts_dev.html
  31. +0
    -0
      server/templates/scripts_login.html
  32. +2
    -0
      server/templates/styles.html
  33. +1
    -0
      server/templates/styles_dev.html
  34. +0
    -0
      server/templates/styles_login.html
  35. +4
    -0
      storage/filesystem/private/info.txt
  36. +2
    -0
      storage/filesystem/public/info.txt
  37. +4
    -0
      storage/filesystem/server/info.txt
  38. +15
    -0
      ui/.gitignore
  39. +8
    -0
      ui/README.md
  40. +35
    -0
      ui/package.json
  41. +20
    -0
      ui/src/components/MyButton/index.jsx
  42. +29
    -0
      ui/src/containers/DashboardContainer/index.jsx
  43. +8
    -0
      ui/src/containers/DashboardContainer/index.less
  44. +78
    -0
      ui/src/index.jsx
  45. +3
    -0
      ui/src/styles/main.less
  46. +39
    -0
      ui/vite.config.js

+ 7
- 0
.editor.config View File

@ -0,0 +1,7 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2

+ 18
- 0
.gitignore View File

@ -0,0 +1,18 @@
node_modules/
.DS_Store
*.log
.idea/
.metadata/
.vscode
package-lock.json
/trash/*
.Trash
*~*
*#*
config/_development.json
config/_production.json

+ 0
- 0
README.md View File


+ 3
- 0
config/_development.js View File

@ -0,0 +1,3 @@
/*
* Development dynamic configurations is here.
*/

+ 3
- 0
config/_production.js View File

@ -0,0 +1,3 @@
/*
* Production dynamic configurations is here.
*/

BIN
config/icon.png View File

Before After
Width: 1024  |  Height: 1024  |  Size: 68 KiB

BIN
public/images/logo-main.png View File

Before After
Width: 740  |  Height: 225  |  Size: 12 KiB

BIN
public/images/logo.png View File

Before After
Width: 600  |  Height: 180  |  Size: 22 KiB

+ 159
- 0
public/scripts/ui.js
File diff suppressed because it is too large
View File


+ 1
- 0
public/scripts/ui.js.map
File diff suppressed because it is too large
View File


+ 13
- 0
public/styles/main.css View File

@ -0,0 +1,13 @@
/**
HERE YOUR CUSTOM CSS
**/
.navbar, .navbar-inverse {
background-color: #5b5ce1 !important;
}
.dev .navbar, .dev .navbar-inverse {
background-color: #333333 !important;
}

+ 1
- 0
public/styles/ui.css View File

@ -0,0 +1 @@
.my-dashboard{width:100%}.my-dashboard__button{padding:80px;text-align:center}

+ 22
- 0
server/core/_config.js View File

@ -0,0 +1,22 @@
_config.set("_lang", _config.get("_lang:default"))
if (_env.is("dev")
&& (_url.equals("/") || _url.equals("/Index.netuno"))) {
_config
.set("_login:user", "dev")
.set("_login:pass", "dev")
.set("_login:auto", _req.getString("action") != "logout")
}
/**
* DISABLE BROWSER CACHE
*/
if (_url.download.isDownloadable()) {
if (_env.is("dev") && _url.indexOf("/public/scripts/main.js") > 0) {
_header.noCache()
} else {
_header.cache(2628000)
}
}

+ 5
- 0
server/core/_init.js View File

@ -0,0 +1,5 @@
/**
* FIREBASE - Set your listeners
*/
// _firebase.listener("my-test", _header.baseURL() + "/services/firebase/listener/my-test.netuno")

+ 0
- 0
server/core/_request_close.js View File


+ 0
- 0
server/core/_request_end.js View File


+ 17
- 0
server/core/_request_error.js View File

@ -0,0 +1,17 @@
if (!_out.isClosed()) {
_out.print(
"### SERVER ERROR ###"
)
/*
// Is insecure but the code below will print errors with more details...
_out.print(
"SERVER ERROR # " +
_error.data().getString("file")
+":"+
_error.data().getString("line")
+" # "+
_error.data().getString("message")
)
*/
}

+ 2
- 0
server/core/_request_start.js View File

@ -0,0 +1,2 @@
_config.set("_script:_request_end", true)

+ 14
- 0
server/core/_request_url.js View File

@ -0,0 +1,14 @@
// _log.info(_url.url())
/**
* ALLOW CORS
*/
/*
_header.response.set("Access-Control-Allow-Origin", "https://www.netuno.org")
_header.response.set("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS")
_header.response.set("Access-Control-Allow-Headers", "content-type,x-requested-with,authorization")
_header.response.set("Access-Control-Allow-Credentials", true)
*/
_url.to(_url.request())

+ 13
- 0
server/core/_service_config.js View File

@ -0,0 +1,13 @@
/**
* When service need public access...
*/
if (_env.is("dev")) {
_service.allow()
}
/*
if (_service.path == 'samples/my-service') {
_service.allow()
}
*/

+ 0
- 0
server/core/_service_end.js View File


+ 5
- 0
server/core/_service_error.js View File

@ -0,0 +1,5 @@
/*
// Print error:
_log.fatal("Service "+ _service.path, _error.data().get("throwable"))
*/

+ 0
- 0
server/core/_service_start.js View File


+ 7
- 0
server/package.json View File

@ -0,0 +1,7 @@
{
"name": "server",
"version": "1.0.0",
"description": "Server modules dependencies.",
"author": "netuno.org",
"license": "ISC"
}

+ 0
- 0
server/setup/_end.js View File


+ 0
- 0
server/setup/_start.js View File


+ 24
- 0
server/templates/dashboard.html View File

@ -0,0 +1,24 @@
<div class="row">
<div class="col-lg-12">
<div class="with-form">
<h1 class="page-header">
_{&lang=netuno.main.dashboard.title}
</h1>
</div>
<div class="no-form">
<h1 class="page-header">
_{&lang=netuno.main.dashboard.welcome_netuno}
</h1>
<p>_{&lang=netuno.main.dashboard.you_not_form}</p>
<p>_{&lang=netuno.main.dashboard.you_can_start_by_clicking_top_bar}</p>
<br>
<img src="_{netuno-config=url-styles}/build-button-tutorial.png" height="80">
</div>
</div>
</div>
<div id="app-dashboard"></div>

+ 31
- 0
server/templates/dev/dashboard.html View File

@ -0,0 +1,31 @@
<div class="row">
<div class="col-lg-12">
<div class="with-form">
<h1 class="page-header">
_{&lang=netuno.main.dashboard.title}
</h1>
<p>_{&lang=netuno.main.dashboard.description}</p>
</div>
<div class="no-form">
<h1 class="page-header">
_{&lang=netuno.main.dashboard.welcome_netuno}
</h1>
<p>_{&lang=netuno.dev.main.you_not_form}</p>
<p>_{&lang=netuno.dev.main.you_can_start_by_clicking_top_bar}</p>
<br>
<img src="_{netuno-config=url-styles}/build-button-tutorial-dev.png" height="200">
</div>
#macro(listFormItems $items)
<ul>
#foreach($item in $items)
<li>
<a href="#" netuno-dev-form="$item.getString('name')">$item.getString('text')</a>
#listFormItems($item.get('items'))
</li>
#end
</ul>
#end
#listFormItems($data.get('menu').get('forms'))
</div>
</div>

+ 1
- 0
server/templates/scripts.html View File

@ -0,0 +1 @@
<script src="_{netuno-config=url-app-scripts}/ui.js?_{util=requestuuid}"></script>

+ 0
- 0
server/templates/scripts_dev.html View File


+ 0
- 0
server/templates/scripts_login.html View File


+ 2
- 0
server/templates/styles.html View File

@ -0,0 +1,2 @@
<link href='_{netuno-config=url-app-styles}/ui.css?_{util=requestuuid}' rel='stylesheet' />
<link href='_{netuno-config=url-app-styles}/main.css?_{util=requestuuid}' rel='stylesheet' />

+ 1
- 0
server/templates/styles_dev.html View File

@ -0,0 +1 @@
<link href='_{netuno-config=url-app-styles}/main.css' rel='stylesheet' />

+ 0
- 0
server/templates/styles_login.html View File


+ 4
- 0
storage/filesystem/private/info.txt View File

@ -0,0 +1,4 @@
Secure data files comes here...
Only accessible for logged users!

+ 2
- 0
storage/filesystem/public/info.txt View File

@ -0,0 +1,2 @@
Public storage files comes here...

+ 4
- 0
storage/filesystem/server/info.txt View File

@ -0,0 +1,4 @@
Secure data files comes here...
Only accessible through server side!

+ 15
- 0
ui/.gitignore View File

@ -0,0 +1,15 @@
node_modules/
.DS_Store
*.log
.idea/
.metadata/
.vscode
package-lock.json
yarn.lock
.Trash
*~*
*#*

+ 8
- 0
ui/README.md View File

@ -0,0 +1,8 @@
### Install Packages
`npm install`
### Watch changes and auto recompile
`npm run watch`

+ 35
- 0
ui/package.json View File

@ -0,0 +1,35 @@
{
"name": "ui",
"private": true,
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build ",
"watch": "vite build --watch",
"lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"antd": "^5.5.2",
"less": "4.1.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@ant-design/icons": "^5.1.4",
"@netuno/service-client": "^1.1.0",
"@netuno/ws-client": "^1.0.8",
"json-loader": "^0.5.7"
},
"devDependencies": {
"@types/react": "^18.0.37",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react-swc": "^3.0.0",
"eslint": "^8.38.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"prop-types": "^15.8.1",
"vite": "^4.3.9",
"vite-plugin-imp": "^2.4.0"
}
}

+ 20
- 0
ui/src/components/MyButton/index.jsx View File

@ -0,0 +1,20 @@
import React from "react";
import PropTypes from "prop-types";
import { Button } from 'antd';
function MyButton({ text, onClick }) {
return (
<div>
<Button type="primary" onClick={ onClick }>
{ text }
</Button>
</div>
);
};
MyButton.propTypes = {
text: PropTypes.string.isRequired,
onClick: PropTypes.func.isRequired
};
export default MyButton;

+ 29
- 0
ui/src/containers/DashboardContainer/index.jsx View File

@ -0,0 +1,29 @@
import React, { useState, useEffect, useRef } from "react";
import MyButton from "../../components/MyButton";
import "./index.less";
function DashboardContainer() {
const [counter, setCounter] = useState(0);
const refButton = useRef();
useEffect(() => {
$(refButton.current).fadeOut(250).fadeIn(250);
}, [counter]);
const onClick = () => {
setCounter(counter + 1);
};
return (
<div className="my-dashboard">
<div ref={refButton} className="my-dashboard__button">
<MyButton text={`ReactJS ⚡ Ant.Design 👉 Click me! ${counter}`} onClick={onClick} />
</div>
</div>
);
}
export default DashboardContainer;

+ 8
- 0
ui/src/containers/DashboardContainer/index.less View File

@ -0,0 +1,8 @@
.my-dashboard {
width: 100%;
&__button {
padding: 80px;
text-align: center;
}
}

+ 78
- 0
ui/src/index.jsx View File

@ -0,0 +1,78 @@
import React from "react";
import ReactDOM from "react-dom/client";
import _service from '@netuno/service-client';
import DashboardContainer from "./containers/DashboardContainer";
import { ConfigProvider, theme } from "antd";
import antLocale_enGB from "antd/lib/locale/en_GB";
import antLocale_enUS from "antd/lib/locale/en_US";
import antLocale_esES from "antd/lib/locale/es_ES";
import antLocale_ptBR from "antd/lib/locale/pt_BR";
import antLocale_ptPT from "antd/lib/locale/pt_PT";
_service.config({
prefix: netuno.config.urlServices
});
const dashboardDiv = document.getElementById("app-dashboard");
const dashboardContainer = dashboardDiv ? ReactDOM.createRoot(dashboardDiv) : false;
if (dashboardContainer) {
dashboardContainer.render(
<ConfigProvider
theme={{
token: {
colorPrimary: '#5b5ce1',
colorLink: '#5b5ce1',
borderRadius: 5,
},
algorithm: theme.darkAlgorithm
}}
locale={
{
'en_us': antLocale_enUS,
'en_gb': antLocale_enGB,
'es_es': antLocale_esES,
'pt_br': antLocale_ptBR,
'pt_pt': antLocale_ptPT
}[netuno.config.langCode]
}
>
<DashboardContainer/>
</ConfigProvider>
);
}
netuno.addNavigationLoad(() => {
$('[netuno-navigation]').find('a').on('netuno:click', (e)=> {
const link = $(e.target);
if (dashboardContainer && link.is('[netuno-navigation-dashboard]')) {
// Menu > Dashboard > Clicked!
}
});
});
netuno.addContentLoad((container) => {
// When any content is loaded dinamically this is executed...
if (container.is('[netuno-form-search="YOUR_FORM_NAME"]')) {
// When search page is loaded...
} else if (container.is('[netuno-form-edit="YOUR_FORM_NAME"]')) {
// When form edit is loaded...
}
});
netuno.addPageLoad(() => {
// When page is loaded...
let modal = $('#app-dashboard-modal-form');
modal.on('hidden.bs.modal', ()=> {
modal.find('[netuno-form-edit]').empty();
});
$('#app-dashboard-modal-form-button').on('click', ()=> {
modal.modal('show');
netuno.loadFormEdit(modal.find('[netuno-form]'));
});
modal.find('[netuno-form]').on('netuno:save', ()=> {
modal.modal('hide');
});
});

+ 3
- 0
ui/src/styles/main.less View File

@ -0,0 +1,3 @@
/*** GLOBAL CSS ***/

+ 39
- 0
ui/vite.config.js View File

@ -0,0 +1,39 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
// https://vitejs.dev/config/
/**
* Library Mode
* https://vitejs.dev/guide/build.html#library-mode
*/
export default defineConfig({
plugins: [
react()
],
build: {
sourcemap: true,
rollupOptions: {
input: 'src/index.jsx',
output: {
dir: './../public',
entryFileNames: 'scripts/ui.js',
assetFileNames: (assetInfo) => {
const info = assetInfo.name.split(".");
let extType = info[info.length - 1];
if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(extType)) {
return `images/[name][extname]`;
} else if (/css/i.test(extType)) {
return `styles/ui[extname]`;
} else {
return `[name][extname]`;
}
},
chunkFileNames: "ui-chunk.js",
manualChunks: undefined,
}
}
}
})

Loading…
Cancel
Save