Working on opening local files
This commit is contained in:
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
background-color: hsla(0,0%,100%,.98);
|
background-color: hsla(0,0%,100%,.98);
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
|
|
||||||
padding-right: .1em;
|
padding-right: .1em;
|
||||||
|
|
||||||
border-right: solid medium hsla(0,0%,90%,1);
|
border-right: solid medium hsla(0,0%,90%,1);
|
||||||
@@ -125,7 +125,7 @@
|
|||||||
.event_launcher_main_nav_menu .btn {
|
.event_launcher_main_nav_menu .btn {
|
||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
|
||||||
border-radius: .25em;
|
border-radius: .25em;
|
||||||
margin: .1em 0em;
|
margin: .1em 0em;
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: .7em;
|
font-size: .7em;
|
||||||
min-width: 5em;
|
min-width: 5em;
|
||||||
|
|
||||||
margin: .1em .2em;
|
margin: .1em .2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +173,39 @@
|
|||||||
z-index: 500;
|
z-index: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.event_launcher_status {
|
||||||
|
outline: dashed thin red;
|
||||||
|
margin: .1em .4em;
|
||||||
|
padding: .0em;
|
||||||
|
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
/* width: 12em; */
|
||||||
|
|
||||||
|
z-index: 500;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
/* flex-wrap: nowrap; */
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
|
|
||||||
|
font-size: .7em;
|
||||||
|
}
|
||||||
|
.event_launcher_status:hover {
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event_launcher_status > .network_status {
|
||||||
|
margin: .2em .2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event_launcher_status > .current_datetime {
|
||||||
|
margin: .2em .2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.event_launcher_main_content header.event_session_about {
|
.event_launcher_main_content header.event_session_about {
|
||||||
@@ -243,17 +276,17 @@ ul.event_presentation_list .btn_list>li {
|
|||||||
.event_launcher_main_content .event_presentation_datetime_name .event_presentation_datetime {
|
.event_launcher_main_content .event_presentation_datetime_name .event_presentation_datetime {
|
||||||
/*align-self: flex-start;*/
|
/*align-self: flex-start;*/
|
||||||
/*border-right: dashed thin green;*/
|
/*border-right: dashed thin green;*/
|
||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: .7em;
|
font-size: .7em;
|
||||||
min-width: 5em;
|
min-width: 5em;
|
||||||
|
|
||||||
margin: .1em .2em;
|
margin: .1em .2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.event_launcher_main_content .event_presentation_datetime_name .event_presentation_name {
|
.event_launcher_main_content .event_presentation_datetime_name .event_presentation_name {
|
||||||
border-left: solid thin gray;
|
border-left: solid thin gray;
|
||||||
|
|
||||||
margin: .1em .2em;
|
margin: .1em .2em;
|
||||||
padding-left: .2em;
|
padding-left: .2em;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,25 @@ exports.load_config = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check for local file
|
||||||
|
// Updated 2022-03-10
|
||||||
|
exports.check_local_file = async function ({local_file_path, filename}) {
|
||||||
|
console.log('*** Electron framework export: check_local_file() ***');
|
||||||
|
console.log('Check for local file');
|
||||||
|
console.log(`Local File Path: ${local_file_path}; Filename: ${filename}`);
|
||||||
|
|
||||||
|
let full_local_file_path = path.join(local_file_path, filename);
|
||||||
|
console.log(full_local_file_path);
|
||||||
|
|
||||||
|
if (fs.existsSync(full_local_file_path)) {
|
||||||
|
console.log(`Local file exists: ${full_local_file_path}`);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check local hash file cache
|
// Check local hash file cache
|
||||||
// Updated 2022-03-09
|
// Updated 2022-03-09
|
||||||
exports.check_hash_file_cache = async function ({host_file_cache_path, hash}) {
|
exports.check_hash_file_cache = async function ({host_file_cache_path, hash}) {
|
||||||
@@ -84,13 +103,15 @@ exports.check_hash_file_cache = async function ({host_file_cache_path, hash}) {
|
|||||||
// console.log(hash_file_cache_path);
|
// console.log(hash_file_cache_path);
|
||||||
|
|
||||||
if (fs.existsSync(hash_file_cache_path)) {
|
if (fs.existsSync(hash_file_cache_path)) {
|
||||||
console.log(`Hashed file cache already exists: ${hash_file_cache_path}`);
|
console.log(`Hashed file exists in cache: ${hash_file_cache_path}`);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
console.log(`Hashed file not found in cache: ${hash_file_cache_path}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Download hash file to cache
|
// Download hash file to cache
|
||||||
// Updated 2022-03-09
|
// Updated 2022-03-09
|
||||||
exports.download_hash_file_to_cache = async function ({host_file_cache_path, event_file_id=null, hash=null}) {
|
exports.download_hash_file_to_cache = async function ({host_file_cache_path, event_file_id=null, hash=null}) {
|
||||||
@@ -121,8 +142,9 @@ exports.download_hash_file_to_cache = async function ({host_file_cache_path, eve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Open cached hash file after copying to temp directory
|
// Open cached hash file after copying to temp directory
|
||||||
// Updated 2022-03-07
|
// Updated 2022-03-09
|
||||||
exports.open_hash_file_to_temp = async function ({host_file_cache_path, hash, host_file_temp_path, filename}) {
|
exports.open_hash_file_to_temp = async function ({host_file_cache_path, hash, host_file_temp_path, filename}) {
|
||||||
console.log('*** Electron framework export: open_hash_file_to_temp() ***');
|
console.log('*** Electron framework export: open_hash_file_to_temp() ***');
|
||||||
console.log('Open cached hash file after copying to temp directory');
|
console.log('Open cached hash file after copying to temp directory');
|
||||||
@@ -149,6 +171,40 @@ exports.open_hash_file_to_temp = async function ({host_file_cache_path, hash, ho
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Open local file
|
||||||
|
// Updated 2022-03-10
|
||||||
|
exports.open_local_file = async function ({local_file_path, filename}) {
|
||||||
|
console.log('*** Electron framework export: open_local_file() ***');
|
||||||
|
console.log('Open local file');
|
||||||
|
console.log(`Local File Path: ${local_file_path}; Filename: ${filename}`);
|
||||||
|
|
||||||
|
// let full_local_file_path = path.join(local_file_path, filename);
|
||||||
|
// console.log(full_local_file_path);
|
||||||
|
|
||||||
|
// if (fs.existsSync(full_local_file_path)) {
|
||||||
|
// console.log(`Local file exists: ${full_local_file_path}`);
|
||||||
|
// // return true;
|
||||||
|
// } else {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
let open_local_file_result = await ipcRenderer.invoke('open_local_file', local_file_path, filename).then((result) => {
|
||||||
|
console.log('IPC open local file finished');
|
||||||
|
console.log(result);
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(open_local_file_result);
|
||||||
|
console.log('End: open_local_file()');
|
||||||
|
if (open_local_file_result) {
|
||||||
|
console.log('File opened successfully');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
console.log('File was not opened successfully');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1
app/static/launcher.reset
Normal file
1
app/static/launcher.reset
Normal file
@@ -0,0 +1 @@
|
|||||||
|
launcher reset
|
||||||
1
app/static/test.txt
Normal file
1
app/static/test.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
test txt
|
||||||
39
index.js
39
index.js
@@ -203,8 +203,8 @@ ipcMain.handle('open_hash_file_to_temp', async (event, host_file_cache_path, has
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fs.existsSync(full_cache_file_path)) {
|
if (fs.existsSync(full_cache_file_path)) {
|
||||||
console.log('Hashed file cache exists: '+full_cache_file_path);
|
console.log(`Hashed file exists in cache: ${full_cache_file_path}`);
|
||||||
console.log('Copying file to temp: '+open_temp_file_path);
|
console.log(`Copying file to temp: ${open_temp_file_path}`);
|
||||||
try {
|
try {
|
||||||
await fs.copyFileSync(full_cache_file_path, open_temp_file_path);
|
await fs.copyFileSync(full_cache_file_path, open_temp_file_path);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -215,6 +215,7 @@ ipcMain.handle('open_hash_file_to_temp', async (event, host_file_cache_path, has
|
|||||||
// console.log('Creating file link: '+open_temp_file_path);
|
// console.log('Creating file link: '+open_temp_file_path);
|
||||||
// fs.linkSync(full_cache_file_path, open_temp_file_path);
|
// fs.linkSync(full_cache_file_path, open_temp_file_path);
|
||||||
} else {
|
} else {
|
||||||
|
console.log(`Hashed file not found in cache: ${full_cache_file_path}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,3 +231,37 @@ ipcMain.handle('open_hash_file_to_temp', async (event, host_file_cache_path, has
|
|||||||
// return 'Return from Electron IPC Main open_hash_file_to_temp()';
|
// return 'Return from Electron IPC Main open_hash_file_to_temp()';
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
ipcMain.handle('open_local_file', async (event, local_file_path, filename, use_cwd=true) => {
|
||||||
|
console.log('*** Electron IPC Main: open_local_file() ***');
|
||||||
|
console.log('ipcMain on open_local_file');
|
||||||
|
console.log(`ipcMain open local file from directory: ${local_file_path}/${filename}`);
|
||||||
|
|
||||||
|
let full_local_file_path = null;
|
||||||
|
|
||||||
|
if (use_cwd) {
|
||||||
|
full_local_file_path = path.join(process.cwd(), local_file_path, filename);
|
||||||
|
console.log(full_local_file_path);
|
||||||
|
} else {
|
||||||
|
full_local_file_path = path.join(local_file_path, filename);
|
||||||
|
console.log(full_local_file_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fs.existsSync(full_local_file_path)) {
|
||||||
|
console.log(`Local file exists: ${full_local_file_path}`);
|
||||||
|
} else {
|
||||||
|
console.log(`Local file not found: ${full_local_file_path}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await shell.openPath(full_local_file_path);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('End: Electron IPC Main: open_local_file()');
|
||||||
|
return true;
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user