you can now open files externally !

This commit is contained in:
Florian Bouillon 2019-03-10 01:30:54 +01:00
parent efc0a0e1b9
commit 4e1339f8b2
3 changed files with 80 additions and 10 deletions

View File

@ -11,8 +11,14 @@
</thead> </thead>
<tbody> <tbody>
{% for file in files %} {% for file in files %}
<tr data-file="{{ file.path }}">
<tr class="type-{{file.type}}" data-file="{{ file.path }}">
{% set thumb = file.getThumbnail() %}
{% if thumb != undefined %}
<td style="background-image: url({{ thumb }})">{{ file.name }}</td>
{% else %}
<td >{{ file.name }}</td> <td >{{ file.name }}</td>
{% endif %}
<td>{{ file.formatTime() }}</td> <td>{{ file.formatTime() }}</td>
<td>{{ file.formatSize() }}</td> <td>{{ file.formatSize() }}</td>
</tr> </tr>

View File

@ -1,6 +1,9 @@
// import { render as nunjuckRender} from 'nunjucks'; // import { render as nunjuckRender} from 'nunjucks';
import fs from 'fs'; import fs from 'fs';
import { sep } from 'path'; import { sep } from 'path';
import {
shell
} from 'electron';
import DeltaFile from '../common/DeltaFile'; import DeltaFile from '../common/DeltaFile';
import './style.scss'; import './style.scss';
import { Template } from 'nunjucks'; import { Template } from 'nunjucks';
@ -36,17 +39,17 @@ const showFolder = (folder: string) => {
app.innerHTML = tpl.render({files: els}); app.innerHTML = tpl.render({files: els});
app.querySelectorAll("[data-file]").forEach((el) => { app.querySelectorAll("[data-file]").forEach((el) => {
el.addEventListener("click", function(this: HTMLElement) { el.addEventListener("click", function(this: HTMLElement) {
// console.log(this);
let folder = this.getAttribute("data-file"); let folder = this.getAttribute("data-file");
if(folder != null) showFolder(folder); if(folder != null) {
let file = DeltaFile.loadFileFromPath(folder);
if(file != undefined) {
if(file.type == 0) showFolder(folder);
else shell.openItem(file.path);
}
}
}); });
}); });
} }
showFolder("/"); showFolder("/");
// function loadFile(file: string) {
// shell.openItem(file);
// }
// console.log(render("index.njk"));
// console.log(loadFolder("/"));

View File

@ -108,3 +108,64 @@ html, body {
* { * {
user-select: none; user-select: none;
} }
/**
* List
*/
main {
display: flex;
flex-wrap: wrap;
}
table {
width: 100%;
border-collapse: collapse;
cursor: pointer;
}
table th {
text-align: left;
}
table tr {
border-bottom: 1px solid #aaa;
height: 50px;
}
table tr td {
border-left: 1px solid #eee;
}
table tr td:first-child {
padding-left: 60px;
background-repeat: no-repeat;
border-left: none;
background-size: 30px;
background-position-y: center;
background-position-x: 14px;
}
table tr.type-0 td:first-child {
background-image: url(../../static/icons/folder.svg);
}
table tr.type-1 td:first-child {
background-image: url(../../static/icons/file.svg)
}