Initial commit
This commit is contained in:
commit
815d56d96e
91
.gitignore
vendored
Normal file
91
.gitignore
vendored
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# nuxt.js build output
|
||||||
|
.nuxt
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# Webpack
|
||||||
|
.webpack/
|
||||||
|
|
||||||
|
# Electron-Forge
|
||||||
|
out/
|
||||||
|
|
||||||
|
.idea/
|
58
package.json
Normal file
58
package.json
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"name": "webeditor",
|
||||||
|
"productName": "webeditor",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "My Electron application description",
|
||||||
|
"main": "src/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "electron-forge start",
|
||||||
|
"package": "electron-forge package",
|
||||||
|
"make": "electron-forge make",
|
||||||
|
"publish": "electron-forge publish",
|
||||||
|
"lint": "echo \"No linting configured\""
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": {
|
||||||
|
"name": "Matthew Welch",
|
||||||
|
"email": "matt@narnian.us"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"config": {
|
||||||
|
"forge": {
|
||||||
|
"packagerConfig": {},
|
||||||
|
"makers": [
|
||||||
|
{
|
||||||
|
"name": "@electron-forge/maker-squirrel",
|
||||||
|
"config": {
|
||||||
|
"name": "webeditor"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "@electron-forge/maker-zip",
|
||||||
|
"platforms": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "@electron-forge/maker-deb",
|
||||||
|
"config": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "@electron-forge/maker-rpm",
|
||||||
|
"config": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"electron-squirrel-startup": "^1.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@electron-forge/cli": "6.0.0-beta.52",
|
||||||
|
"@electron-forge/maker-deb": "6.0.0-beta.52",
|
||||||
|
"@electron-forge/maker-rpm": "6.0.0-beta.52",
|
||||||
|
"@electron-forge/maker-squirrel": "6.0.0-beta.52",
|
||||||
|
"@electron-forge/maker-zip": "6.0.0-beta.52",
|
||||||
|
"electron": "11.1.0"
|
||||||
|
}
|
||||||
|
}
|
10717
src/css/bootstrap.css
vendored
Normal file
10717
src/css/bootstrap.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
src/css/bootstrap.css.map
Normal file
1
src/css/bootstrap.css.map
Normal file
File diff suppressed because one or more lines are too long
7
src/css/bootstrap.min.css
vendored
Normal file
7
src/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
src/css/bootstrap.min.css.map
Normal file
1
src/css/bootstrap.min.css.map
Normal file
File diff suppressed because one or more lines are too long
13
src/css/style.css
Normal file
13
src/css/style.css
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav {
|
||||||
|
overflow-y: hidden;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
31
src/default.json
Normal file
31
src/default.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "table0",
|
||||||
|
"name": "Table 1",
|
||||||
|
"filter": false,
|
||||||
|
"hidden": false,
|
||||||
|
"tab-name": "",
|
||||||
|
"description": "",
|
||||||
|
"col-def": [
|
||||||
|
{
|
||||||
|
"field": "column0",
|
||||||
|
"title": "Column 1",
|
||||||
|
"sortable": true,
|
||||||
|
"selectable": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "column1",
|
||||||
|
"title": "Column 2",
|
||||||
|
"sortable": true,
|
||||||
|
"selectable": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rows": [
|
||||||
|
{
|
||||||
|
"uid": "row0",
|
||||||
|
"column0": "cell data",
|
||||||
|
"column1": "cell data"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
29
src/editor.html
Normal file
29
src/editor.html
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Web Editor</title>
|
||||||
|
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="css/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<nav class="nav nav-tabs text-nowrap flex-nowrap"></nav>
|
||||||
|
<div class="row">
|
||||||
|
<div id="details" class="col-3"></div>
|
||||||
|
<div id="tables" class="tab-content"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
if (typeof module === 'object') {
|
||||||
|
window.module = module;
|
||||||
|
module = undefined;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script src="js/jquery-3.5.1.min.js"></script>
|
||||||
|
<script src="js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script>if (window.module) module = window.module;</script>
|
||||||
|
<script src="js/editor.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
75
src/index.js
Normal file
75
src/index.js
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||||
|
|
||||||
|
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||||
|
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method will be called when Electron has finished
|
||||||
|
// initialization and is ready to create browser windows.
|
||||||
|
// Some APIs can only be used after this event occurs.
|
||||||
|
app.on('ready', createSplashScreen);
|
||||||
|
|
||||||
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
|
// for applications and their menu bar to stay active until the user quits
|
||||||
|
// explicitly with Cmd + Q.
|
||||||
|
app.on('window-all-closed', () => {
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('activate', () => {
|
||||||
|
// On OS X it's common to re-create a window in the app when the
|
||||||
|
// dock icon is clicked and there are no other windows open.
|
||||||
|
if (BrowserWindow.getAllWindows().length === 0) {
|
||||||
|
createSplashScreen();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function createSplashScreen() {
|
||||||
|
// Create the browser window.
|
||||||
|
const splash_screen = new BrowserWindow({
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
autoHideMenuBar: true,
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// and load the splash.html of the app.
|
||||||
|
splash_screen.loadFile('src/splash.html');
|
||||||
|
|
||||||
|
// Open the DevTools.
|
||||||
|
splash_screen.webContents.openDevTools();
|
||||||
|
}
|
||||||
|
|
||||||
|
function createEditorWindow() {
|
||||||
|
let main_window = new BrowserWindow({
|
||||||
|
width: 1000,
|
||||||
|
height: 600,
|
||||||
|
autoHideMenuBar: true,
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
main_window.loadFile("src/editor.html");
|
||||||
|
// Open the DevTools.
|
||||||
|
main_window.webContents.openDevTools();
|
||||||
|
return main_window;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createNew() {
|
||||||
|
let old_window = BrowserWindow.getFocusedWindow();
|
||||||
|
let main_window = createEditorWindow();
|
||||||
|
main_window.once("ready-to-show", () => {
|
||||||
|
main_window.webContents.send("open-default");
|
||||||
|
})
|
||||||
|
old_window.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
ipcMain.on("create-new", (event) => {
|
||||||
|
createNew();
|
||||||
|
})
|
6701
src/js/bootstrap.bundle.js
vendored
Normal file
6701
src/js/bootstrap.bundle.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
src/js/bootstrap.bundle.js.map
Normal file
1
src/js/bootstrap.bundle.js.map
Normal file
File diff suppressed because one or more lines are too long
7
src/js/bootstrap.bundle.min.js
vendored
Normal file
7
src/js/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
src/js/bootstrap.bundle.min.js.map
Normal file
1
src/js/bootstrap.bundle.min.js.map
Normal file
File diff suppressed because one or more lines are too long
91
src/js/editor.js
Normal file
91
src/js/editor.js
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
const { ipcRenderer } = require('electron');
|
||||||
|
let tables_data;
|
||||||
|
|
||||||
|
function openFile(file_name) {
|
||||||
|
$.ajax({
|
||||||
|
dataType: "json",
|
||||||
|
url: file_name,
|
||||||
|
cache: false,
|
||||||
|
success: (json, textStatus, jqXHR) => {
|
||||||
|
tables_data = json;
|
||||||
|
refreshPage();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearPage() {
|
||||||
|
$("#tables").empty();
|
||||||
|
$("nav").empty();
|
||||||
|
// TODO clear the input values in the details panel
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshPage() {
|
||||||
|
clearPage();
|
||||||
|
generateTables();
|
||||||
|
showTab(tables_data[0]["id"]+"-tab");
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateTables() {
|
||||||
|
for (let table_data of tables_data) {
|
||||||
|
const table_id = table_data["id"];
|
||||||
|
let a = $("<a></a>")
|
||||||
|
.attr("id", table_id+"-nav")
|
||||||
|
.addClass("nav-link")
|
||||||
|
.attr("href", "#"+table_id)
|
||||||
|
.text(table_data["name"])
|
||||||
|
.on("click", () => {
|
||||||
|
showTab(table_id+"-tab");
|
||||||
|
});
|
||||||
|
$("nav").append(a);
|
||||||
|
|
||||||
|
let table_div = $("<div></div>")
|
||||||
|
.attr("id", table_id+"-tab")
|
||||||
|
.addClass("tab-pane table-responsive");
|
||||||
|
|
||||||
|
let table = $("<table></table>")
|
||||||
|
.attr("id", table_id)
|
||||||
|
.addClass("table table-bordered")
|
||||||
|
.append($("<thead></thead>")
|
||||||
|
.append($("<tr></tr>")
|
||||||
|
.addClass("text-nowrap")))
|
||||||
|
.append("<tbody>");
|
||||||
|
|
||||||
|
for (let i=0; i < table_data["col-def"].length; i++) {
|
||||||
|
const col_id = table_data["col-def"][i]["field"];
|
||||||
|
table.find("thead > tr")
|
||||||
|
.append($("<th>")
|
||||||
|
.attr("id", table_id+"-"+col_id)
|
||||||
|
.text(table_data["col-def"][i]["title"]));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i=0; i < table_data["rows"].length; i++) {
|
||||||
|
const row = table_data["rows"][i];
|
||||||
|
const row_id = row["uid"];
|
||||||
|
let tr = $("<tr></tr>")
|
||||||
|
.attr("id", table_id+"-"+row_id);
|
||||||
|
for (let j=0; j < table_data["col-def"].length; j++) {
|
||||||
|
const col = table_data["col-def"][j];
|
||||||
|
const col_id = col["field"];
|
||||||
|
let td = $("<td></td>")
|
||||||
|
.attr("id", table_id+"-"+col_id+"-"+row_id)
|
||||||
|
.text(row[col_id]);
|
||||||
|
tr.append(td);
|
||||||
|
}
|
||||||
|
table.find("tbody").append(tr);
|
||||||
|
}
|
||||||
|
|
||||||
|
table_div.append(table)
|
||||||
|
$("#tables").append(table_div);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showTab(tab_name) {
|
||||||
|
$("#tables").children().removeClass("show active");
|
||||||
|
$("nav").children().removeClass("active");
|
||||||
|
$("#"+tab_name).addClass("show active");
|
||||||
|
$("#"+tab_name.replace("-tab", "-nav")).addClass("active");
|
||||||
|
}
|
||||||
|
|
||||||
|
ipcRenderer.on("open-default", (event) => {
|
||||||
|
openFile("default.json");
|
||||||
|
})
|
10872
src/js/jquery-3.5.1.js
vendored
Normal file
10872
src/js/jquery-3.5.1.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
src/js/jquery-3.5.1.min.js
vendored
Normal file
2
src/js/jquery-3.5.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
src/js/jquery-3.5.1.min.js.map
Normal file
1
src/js/jquery-3.5.1.min.js.map
Normal file
File diff suppressed because one or more lines are too long
7
src/js/splash.js
Normal file
7
src/js/splash.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
const { ipcRenderer } = require('electron')
|
||||||
|
|
||||||
|
$("#recent-files").css("display", "none");
|
||||||
|
|
||||||
|
$("#create-new").on("click", () => {
|
||||||
|
ipcRenderer.send("create-new");
|
||||||
|
});
|
30
src/splash.html
Normal file
30
src/splash.html
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Web Editor</title>
|
||||||
|
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="css/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div id="recent-files" class="col-4"></div>
|
||||||
|
<div class="col-12 text-center">
|
||||||
|
<h1 class="text-center">Web Editor</h1>
|
||||||
|
<button id="create-new" class="btn btn-primary">Create New!</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
if (typeof module === 'object') {
|
||||||
|
window.module = module;
|
||||||
|
module = undefined;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script src="js/jquery-3.5.1.min.js"></script>
|
||||||
|
<script src="js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script>if (window.module) module = window.module;</script>
|
||||||
|
<script src="js/splash.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user