Skip to content

Commit 0d6adfd

Browse files
committed
v0.5.0 - Snippets, Database
1 parent 6f8fad2 commit 0d6adfd

31 files changed

Lines changed: 1454 additions & 278 deletions

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"error",
2828
"always"
2929
],
30-
"no-whitespace-before-property": "off"
30+
"no-whitespace-before-property": "off",
31+
"array-callback-return": "off"
3132
}
3233
}

.idea/workspace.xml

Lines changed: 352 additions & 216 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const {ENGINE_TYPES} = require ('tch-database');
2+
const path = require ('path');
3+
4+
module.exports = {
5+
storageSystem: ENGINE_TYPES.NeDB,
6+
nedb: {
7+
directory: path.join ('var', 'nedb')
8+
}
9+
};

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tch-filector",
33
"productName": "FileCtor",
4-
"version": "0.4.1",
4+
"version": "0.5.0",
55
"author": "Tomas Chyly <chyly@tomas-chyly.com> (https://tomas-chyly.com/en/)",
66
"license": "GPL v3",
77
"description": "File inspector with interactive console.",
@@ -19,7 +19,7 @@
1919
"devDependencies": {
2020
"concurrently": "^4.1.0",
2121
"cross-env": "^5.2.0",
22-
"electron": "^4.0.4",
22+
"electron": "^4.0.5",
2323
"electron-devtools-installer": "^2.2.4",
2424
"find-free-port": "^2.0.0",
2525
"react": "^16.7.0",
@@ -33,7 +33,9 @@
3333
"codemirror": "^5.43.0",
3434
"extend": "^3.0.2",
3535
"fs-extra": "^7.0.1",
36+
"nedb": "^1.8.0",
3637
"systeminformation": "^4.0.3",
38+
"tch-database": "^0.3.2",
3739
"uuid": "^3.3.2",
3840
"write-file-atomic": "^2.4.2"
3941
},

public/scripts/main.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ if (typeof (window.TCH.Main) === 'undefined') {
88
window.TCH.Main = {
99
titleBar: null,
1010
navigation: null,
11+
popups: null,
12+
13+
/**
14+
* Show popup to ask user for action confirmation.
15+
*/
16+
ConfirmAction (action) {
17+
if (typeof (this.popups) !== 'undefined') {
18+
this.popups.ConfirmAction (action);
19+
}
20+
},
1121

1222
/**
1323
* Open console window with parameters.
@@ -92,6 +102,23 @@ if (typeof (window.TCH.Main) === 'undefined') {
92102
} while (parent !== null);
93103

94104
return null;
105+
},
106+
107+
Object: {
108+
/**
109+
* Check if object is empty (no elements).
110+
* @param {object} object Object to check is empty
111+
* @returns {boolean}
112+
*/
113+
IsEmpty (object) {
114+
for (let index in object) {
115+
if (object.hasOwnProperty (index)) {
116+
return false;
117+
}
118+
}
119+
120+
return true;
121+
}
95122
}
96123
}
97124
};

src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { HashRouter } from 'react-router-dom';
33
import TitleBar from './component/Titlebar';
44
import Navigation from './component/Navigation';
55
import Router from './Router';
6+
import Popups from './component/Popups';
67

78
const { ipcRenderer } = window.require ('electron');
89

@@ -61,6 +62,7 @@ class App extends Component {
6162
<div id="content">
6263
<Router />
6364
</div>
65+
<Popups/>
6466
</div>
6567
</HashRouter>;
6668
}

src/component/ButtonSelect.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class ButtonSelect extends Component {
2525
this.container = undefined;
2626

2727
this.state = {
28-
options: props.options,
2928
optionsVisible: false
3029
};
3130
}
@@ -56,18 +55,22 @@ class ButtonSelect extends Component {
5655
*/
5756
render () {
5857
let options = [];
59-
if (typeof (this.state.options) !== 'undefined' && Array.isArray (this.state.options)) {
60-
for (let index in this.state.options) {
61-
let rowData = this.state.options [index];
58+
if (typeof (this.props.options) !== 'undefined' && Array.isArray (this.props.options)) {
59+
for (let index in this.props.options) {
60+
if (this.props.options.hasOwnProperty (index)) {
61+
let rowData = this.props.options [index];
6262

63-
options.push (<button type="button" key={rowData.id} data-value={rowData.value} onClick={this.SelectOption.bind (this)}>{rowData.label}</button>);
63+
options.push (<button type="button" key={rowData.id} data-value={rowData.value} onClick={this.SelectOption.bind (this)}>{rowData.label}</button>);
64+
}
6465
}
6566
}
6667

68+
let current = typeof (this.props.icon) !== 'undefined' ? this.props.icon : this.props.value;
69+
6770
this.container = React.createRef ();
6871

6972
return <div ref={this.container} className={`button-select-container ${typeof (this.props.className) !== 'undefined' ? this.props.className : ''}`}>
70-
<button className="button icon" type="button" onClick={this.ToggleOptions.bind (this)}>{this.props.icon}</button>
73+
<button className="button icon" type="button" onClick={this.ToggleOptions.bind (this)}>{current}</button>
7174
<div className={`button-select-list${this.state.optionsVisible ? ' visible' : ''}`}>{options}</div>
7275
</div>;
7376
}

src/component/CodeMirrorEditor.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CodeMirrorEditor extends Component {
2727
*/
2828
componentDidMount () {
2929
this.editor = CodeMirror (this.node.current, {
30-
value: '',
30+
value: typeof (this.props.script) !== 'undefined' ? this.props.script : '',
3131
mode: 'javascript',
3232
theme: 'darcula',
3333
lineNumbers: true,
@@ -59,6 +59,13 @@ class CodeMirrorEditor extends Component {
5959

6060
return <div ref={this.node} className="code-mirror-editor-container" />;
6161
}
62+
63+
/**
64+
* Change script of the editor.
65+
*/
66+
ChangeScript (value) {
67+
this.editor.getDoc ().setValue (value);
68+
}
6269
}
6370

6471
export default CodeMirrorEditor;

0 commit comments

Comments
 (0)