style: Apply Prettier formatting with 4-space indentation
Applied consistent code formatting across the project using Prettier, now configured to use 4-space indentation instead of tabs.
This commit is contained in:
@@ -19,18 +19,18 @@ The Electron integration is composed of three main parts:
|
||||
The native functions in `electron_native.js` provide the following key functionalities for the Event Launcher:
|
||||
|
||||
- **File Caching:**
|
||||
- `check_hash_file_cache()`: Checks if a file with a specific hash exists in the local cache.
|
||||
- `download_hash_file_to_cache()`: Downloads a file from the API and stores it in the local cache.
|
||||
- `check_hash_file_cache()`: Checks if a file with a specific hash exists in the local cache.
|
||||
- `download_hash_file_to_cache()`: Downloads a file from the API and stores it in the local cache.
|
||||
- **File Operations:**
|
||||
- `open_hash_file_to_temp()`: Copies a file from the cache to a temporary directory and opens it.
|
||||
- `open_local_file()`: Opens a local file.
|
||||
- `open_hash_file_to_temp()`: Copies a file from the cache to a temporary directory and opens it.
|
||||
- `open_local_file()`: Opens a local file.
|
||||
- **Process Management:**
|
||||
- `kill_processes()`: Kills processes by name or ID. This is used to close presentation applications after a presentation is finished.
|
||||
- `kill_processes()`: Kills processes by name or ID. This is used to close presentation applications after a presentation is finished.
|
||||
- **Command Execution:**
|
||||
- `run_osascript()`: Runs an AppleScript command (macOS only).
|
||||
- `run_cmd()`: Runs a shell command.
|
||||
- `run_osascript()`: Runs an AppleScript command (macOS only).
|
||||
- `run_cmd()`: Runs a shell command.
|
||||
- **Device Information:**
|
||||
- `get_device_info()`: Gets information about the device, which can be used for logging and debugging.
|
||||
- `get_device_info()`: Gets information about the device, which can be used for logging and debugging.
|
||||
|
||||
## UI Integration
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -60,110 +60,110 @@
|
||||
|
||||
// Updated 2022-05-07
|
||||
export let kill_processes = async function kill_processes({ process_name_li = [] }) {
|
||||
console.log('*** kill_processes() ***');
|
||||
console.log(`Process Name List: ${process_name_li}`);
|
||||
console.log('*** kill_processes() ***');
|
||||
console.log(`Process Name List: ${process_name_li}`);
|
||||
|
||||
let fail_flag = null;
|
||||
if (process_name_li) {
|
||||
for (let i = 0; i < process_name_li.length; i++) {
|
||||
// separate the keys and the values
|
||||
let process_name = process_name_li[i];
|
||||
let signal = null;
|
||||
let fail_flag = null;
|
||||
if (process_name_li) {
|
||||
for (let i = 0; i < process_name_li.length; i++) {
|
||||
// separate the keys and the values
|
||||
let process_name = process_name_li[i];
|
||||
let signal = null;
|
||||
|
||||
if (process_name == 'osit_aperture_wrapper') {
|
||||
signal = 'INT'; // INT (interrupt) correctly stops the wrapper
|
||||
}
|
||||
if (process_name == 'osit_aperture_wrapper') {
|
||||
signal = 'INT'; // INT (interrupt) correctly stops the wrapper
|
||||
}
|
||||
|
||||
let kill_processes_result = await native_app.kill_processes({
|
||||
process_name: process_name,
|
||||
signal: signal
|
||||
});
|
||||
console.log(kill_processes_result);
|
||||
if (kill_processes_result) {
|
||||
console.log('Killed process.');
|
||||
// return kill_processes_result;
|
||||
} else {
|
||||
console.log('Did not kill process. Something went wrong.');
|
||||
fail_flag = true;
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
let kill_processes_result = await native_app.kill_processes({
|
||||
process_name: process_name,
|
||||
signal: signal
|
||||
});
|
||||
console.log(kill_processes_result);
|
||||
if (kill_processes_result) {
|
||||
console.log('Killed process.');
|
||||
// return kill_processes_result;
|
||||
} else {
|
||||
console.log('Did not kill process. Something went wrong.');
|
||||
fail_flag = true;
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fail_flag;
|
||||
return fail_flag;
|
||||
|
||||
// let kill_processes_result = await native_app.kill_processes({process_name: process_name});
|
||||
// console.log(kill_processes_result);
|
||||
// if (kill_processes_result) {
|
||||
// console.log('Killed process.');
|
||||
// return kill_processes_result;
|
||||
// } else {
|
||||
// console.log('Did not kill process. Something went wrong.');
|
||||
// return false;
|
||||
// }
|
||||
// let kill_processes_result = await native_app.kill_processes({process_name: process_name});
|
||||
// console.log(kill_processes_result);
|
||||
// if (kill_processes_result) {
|
||||
// console.log('Killed process.');
|
||||
// return kill_processes_result;
|
||||
// } else {
|
||||
// console.log('Did not kill process. Something went wrong.');
|
||||
// return false;
|
||||
// }
|
||||
};
|
||||
|
||||
// Updated 2022-05-06
|
||||
export let open_local_file = async function open_local_file({ file_path, filename }) {
|
||||
console.log('*** open_local_file() ***');
|
||||
console.log(`File Path: ${file_path}; Filename: ${filename}`);
|
||||
console.log('*** open_local_file() ***');
|
||||
console.log(`File Path: ${file_path}; Filename: ${filename}`);
|
||||
|
||||
console.log(
|
||||
'Process: Check local hash file cache, Download hash file to cache, and Open cached hash file after copying to temp directory'
|
||||
);
|
||||
console.log(
|
||||
'Process: Check local hash file cache, Download hash file to cache, and Open cached hash file after copying to temp directory'
|
||||
);
|
||||
|
||||
// let check_local_file_result = await native_app.check_local_file({local_file_path: file_path, filename: filename});
|
||||
// console.log(check_local_file_result);
|
||||
// if (check_local_file_result) {
|
||||
// console.log('Local file found.');
|
||||
// } else {
|
||||
// console.log('Local file not found. Will not attempt to open.');
|
||||
// return false;
|
||||
// }
|
||||
// let check_local_file_result = await native_app.check_local_file({local_file_path: file_path, filename: filename});
|
||||
// console.log(check_local_file_result);
|
||||
// if (check_local_file_result) {
|
||||
// console.log('Local file found.');
|
||||
// } else {
|
||||
// console.log('Local file not found. Will not attempt to open.');
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// console.log('Local file file found and ready to be opened.');
|
||||
let open_local_file_result = await native_app.open_local_file({
|
||||
local_file_path: file_path,
|
||||
filename: filename
|
||||
});
|
||||
console.log(open_local_file_result);
|
||||
if (open_local_file_result) {
|
||||
console.log('Local file was opened.');
|
||||
return open_local_file_result;
|
||||
} else {
|
||||
console.log('Local file was not opened. Something went wrong.');
|
||||
return false;
|
||||
}
|
||||
// console.log('Local file file found and ready to be opened.');
|
||||
let open_local_file_result = await native_app.open_local_file({
|
||||
local_file_path: file_path,
|
||||
filename: filename
|
||||
});
|
||||
console.log(open_local_file_result);
|
||||
if (open_local_file_result) {
|
||||
console.log('Local file was opened.');
|
||||
return open_local_file_result;
|
||||
} else {
|
||||
console.log('Local file was not opened. Something went wrong.');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// exports.open_local_file should no longer be needed with this.
|
||||
// Updated 2022-10-11
|
||||
export let open_local_file_v2 = async function open_local_file_v2({ file_path, filename }) {
|
||||
console.log('*** open_local_file_v2() ***');
|
||||
console.log(`Local File Path: ${file_path}; Filename: ${filename}`);
|
||||
console.log('*** open_local_file_v2() ***');
|
||||
console.log(`Local File Path: ${file_path}; Filename: ${filename}`);
|
||||
|
||||
console.log(
|
||||
'Process: Check local hash file cache, Download hash file to cache, and Open cached hash file after copying to temp directory'
|
||||
);
|
||||
console.log(
|
||||
'Process: Check local hash file cache, Download hash file to cache, and Open cached hash file after copying to temp directory'
|
||||
);
|
||||
|
||||
let open_local_file_result = await ipcRenderer
|
||||
.invoke('open_local_file', file_path, filename)
|
||||
.then((result) => {
|
||||
console.log('IPC open local file finished');
|
||||
if (result) {
|
||||
console.log('Local file was opened.');
|
||||
return result;
|
||||
} else {
|
||||
console.log('Local file was not opened. Something went wrong.');
|
||||
console.log(result);
|
||||
return false;
|
||||
}
|
||||
let open_local_file_result = await ipcRenderer
|
||||
.invoke('open_local_file', file_path, filename)
|
||||
.then((result) => {
|
||||
console.log('IPC open local file finished');
|
||||
if (result) {
|
||||
console.log('Local file was opened.');
|
||||
return result;
|
||||
} else {
|
||||
console.log('Local file was not opened. Something went wrong.');
|
||||
console.log(result);
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log(result);
|
||||
return true;
|
||||
});
|
||||
console.log(result);
|
||||
return true;
|
||||
});
|
||||
|
||||
return open_local_file_result;
|
||||
return open_local_file_result;
|
||||
};
|
||||
|
||||
// // Updated 2022-05-06
|
||||
@@ -236,97 +236,97 @@ export let open_local_file_v2 = async function open_local_file_v2({ file_path, f
|
||||
|
||||
// Updated 2022-05-07
|
||||
export let run_cmd = async function run_cmd({ cmd = null, return_stdout = null }) {
|
||||
console.log('*** run_cmd() ***');
|
||||
console.log('*** run_cmd() ***');
|
||||
|
||||
let run_cmd_result = await native_app
|
||||
.run_cmd({ cmd: cmd, return_stdout: return_stdout })
|
||||
.then(function (result) {
|
||||
if (result) {
|
||||
console.log('Command ran');
|
||||
} else {
|
||||
console.log('Command did not run. Something went wrong.');
|
||||
return false;
|
||||
}
|
||||
if (return_stdout) {
|
||||
return result;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
let run_cmd_result = await native_app
|
||||
.run_cmd({ cmd: cmd, return_stdout: return_stdout })
|
||||
.then(function (result) {
|
||||
if (result) {
|
||||
console.log('Command ran');
|
||||
} else {
|
||||
console.log('Command did not run. Something went wrong.');
|
||||
return false;
|
||||
}
|
||||
if (return_stdout) {
|
||||
return result;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Run Command Result:', run_cmd_result);
|
||||
console.log('Run Command Result:', run_cmd_result);
|
||||
|
||||
return run_cmd_result;
|
||||
return run_cmd_result;
|
||||
};
|
||||
|
||||
// Updated 2022-10-27
|
||||
export let run_cmd_sync = function run_cmd_sync({ cmd = null, return_stdout = null }) {
|
||||
console.log('*** run_cmd_sync() ***');
|
||||
console.log('*** run_cmd_sync() ***');
|
||||
|
||||
let run_cmd_result = native_app.run_cmd_sync({ cmd: cmd, return_stdout: return_stdout });
|
||||
let run_cmd_result = native_app.run_cmd_sync({ cmd: cmd, return_stdout: return_stdout });
|
||||
|
||||
// if (run_cmd_result) {
|
||||
// console.log('Command ran');
|
||||
// } else {
|
||||
// console.log('Command did not run. Something went wrong.');
|
||||
// // return false;
|
||||
// }
|
||||
// if (run_cmd_result) {
|
||||
// console.log('Command ran');
|
||||
// } else {
|
||||
// console.log('Command did not run. Something went wrong.');
|
||||
// // return false;
|
||||
// }
|
||||
|
||||
// if (return_stdout) {
|
||||
// return run_cmd_result;
|
||||
// } else {
|
||||
// return true;
|
||||
// }
|
||||
// if (return_stdout) {
|
||||
// return run_cmd_result;
|
||||
// } else {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
console.log('Run Command Result:', run_cmd_result);
|
||||
console.log('Run Command Result:', run_cmd_result);
|
||||
|
||||
return run_cmd_result;
|
||||
return run_cmd_result;
|
||||
};
|
||||
|
||||
// Updated 2022-05-07
|
||||
export let run_osascript = async function run_osascript({
|
||||
cmd = null,
|
||||
interactive = false,
|
||||
language = null,
|
||||
flags = 'h',
|
||||
program_file = null
|
||||
cmd = null,
|
||||
interactive = false,
|
||||
language = null,
|
||||
flags = 'h',
|
||||
program_file = null
|
||||
}) {
|
||||
console.log('*** run_osascript() ***');
|
||||
console.log('*** run_osascript() ***');
|
||||
|
||||
let run_osascript_result = await native_app.run_osascript({
|
||||
cmd: cmd,
|
||||
interactive: interactive,
|
||||
language: language,
|
||||
flags: flags,
|
||||
program_file: program_file
|
||||
});
|
||||
let run_osascript_result = await native_app.run_osascript({
|
||||
cmd: cmd,
|
||||
interactive: interactive,
|
||||
language: language,
|
||||
flags: flags,
|
||||
program_file: program_file
|
||||
});
|
||||
|
||||
console.log(run_osascript_result);
|
||||
console.log(run_osascript_result);
|
||||
|
||||
if (run_osascript_result) {
|
||||
console.log('Apple Script ran');
|
||||
} else {
|
||||
console.log('Apple Script did not run. Something went wrong.');
|
||||
}
|
||||
if (run_osascript_result) {
|
||||
console.log('Apple Script ran');
|
||||
} else {
|
||||
console.log('Apple Script did not run. Something went wrong.');
|
||||
}
|
||||
|
||||
return run_osascript_result;
|
||||
return run_osascript_result;
|
||||
};
|
||||
|
||||
// Updated 2022-05-07
|
||||
export let get_device_info = async function get_device_info({ event_device_id }) {
|
||||
console.log('*** get_device_info() ***');
|
||||
console.log('*** get_device_info() ***');
|
||||
|
||||
console.log(event_device_id);
|
||||
console.log(event_device_id);
|
||||
|
||||
let get_device_info_result = await native_app.get_device_info();
|
||||
let get_device_info_result = await native_app.get_device_info();
|
||||
|
||||
console.log(get_device_info_result);
|
||||
console.log(get_device_info_result);
|
||||
|
||||
if (get_device_info_result) {
|
||||
console.log('Success');
|
||||
} else {
|
||||
console.log('Failed? Something went wrong.');
|
||||
}
|
||||
if (get_device_info_result) {
|
||||
console.log('Success');
|
||||
} else {
|
||||
console.log('Failed? Something went wrong.');
|
||||
}
|
||||
|
||||
return get_device_info_result;
|
||||
return get_device_info_result;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user