Redux changes and refactoring
This commit is contained in:
@@ -119,7 +119,7 @@ function createWindow() {
|
|||||||
// Unmount all items
|
// Unmount all items
|
||||||
for (const i in mountedLocations) {
|
for (const i in mountedLocations) {
|
||||||
const data = mountedData[mountedLocations[i]];
|
const data = mountedData[mountedLocations[i]];
|
||||||
helpers.stopMountProcessSync(data.DataDirectory, data.Version, data.StorageType);
|
helpers.stopMountProcessSync(data.Version, data.StorageType);
|
||||||
}
|
}
|
||||||
|
|
||||||
mountedLocations = [];
|
mountedLocations = [];
|
||||||
@@ -223,10 +223,10 @@ const loadUiSettings = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const monitorMount = (sender, storageType, dataDirectory, version, pid, location) => {
|
const monitorMount = (sender, storageType, version, pid, location) => {
|
||||||
manualMountDetection[storageType] = setInterval(() => {
|
manualMountDetection[storageType] = setInterval(() => {
|
||||||
helpers
|
helpers
|
||||||
.detectRepertoryMounts(dataDirectory, version)
|
.detectRepertoryMounts(version)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result[storageType].PID !== pid) {
|
if (result[storageType].PID !== pid) {
|
||||||
if (result[storageType].PID === -1) {
|
if (result[storageType].PID === -1) {
|
||||||
@@ -252,7 +252,7 @@ const monitorMount = (sender, storageType, dataDirectory, version, pid, location
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveUiSettings = () => {
|
const saveUiSettings = () => {
|
||||||
const settingFile = path.join(helpers.resolvePath(Constants.DATA_LOCATIONS[os.platform()]), 'ui.json');
|
const settingFile = path.join(helpers.getDataDirectory(), 'ui.json');
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(settingFile, JSON.stringify({
|
fs.writeFileSync(settingFile, JSON.stringify({
|
||||||
launch_hidden: launchHidden,
|
launch_hidden: launchHidden,
|
||||||
@@ -288,9 +288,8 @@ ipcMain.on(Constants.IPC_Browse_Directory + '_sync', (event, data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Check_Daemon_Version, (event, data) => {
|
ipcMain.on(Constants.IPC_Check_Daemon_Version, (event, data) => {
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
|
||||||
helpers
|
helpers
|
||||||
.checkDaemonVersion(dataDirectory, data.Version, data.StorageType)
|
.checkDaemonVersion(data.Version, data.StorageType)
|
||||||
.then(code => {
|
.then(code => {
|
||||||
standardIPCReply(event, Constants.IPC_Check_Daemon_Version_Reply, {
|
standardIPCReply(event, Constants.IPC_Check_Daemon_Version_Reply, {
|
||||||
Valid: (code === 0),
|
Valid: (code === 0),
|
||||||
@@ -304,9 +303,8 @@ ipcMain.on(Constants.IPC_Check_Daemon_Version, (event, data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Check_Daemon_Version + '_sync', (event, data) => {
|
ipcMain.on(Constants.IPC_Check_Daemon_Version + '_sync', (event, data) => {
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
|
||||||
helpers
|
helpers
|
||||||
.checkDaemonVersion(dataDirectory, data.Version, data.StorageType)
|
.checkDaemonVersion(data.Version, data.StorageType)
|
||||||
.then(code => {
|
.then(code => {
|
||||||
event.returnValue = {
|
event.returnValue = {
|
||||||
data: {
|
data: {
|
||||||
@@ -361,8 +359,7 @@ ipcMain.on(Constants.IPC_Check_Dependency_Installed + '_sync', (event, data) =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Check_Installed, (event, data) => {
|
ipcMain.on(Constants.IPC_Check_Installed, (event, data) => {
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
const destination = path.join(helpers.getDataDirectory(), data.Version);
|
||||||
const destination = path.join(dataDirectory, data.Version);
|
|
||||||
helpers
|
helpers
|
||||||
.getMissingDependencies(data.Dependencies)
|
.getMissingDependencies(data.Dependencies)
|
||||||
.then((dependencies) => {
|
.then((dependencies) => {
|
||||||
@@ -493,9 +490,8 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
mainWindowTray.setImage(image);
|
mainWindowTray.setImage(image);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
|
||||||
helpers
|
helpers
|
||||||
.detectRepertoryMounts(dataDirectory, data.Version)
|
.detectRepertoryMounts(data.Version)
|
||||||
.then((results) => {
|
.then((results) => {
|
||||||
let storageData = {};
|
let storageData = {};
|
||||||
let locations = {};
|
let locations = {};
|
||||||
@@ -510,7 +506,7 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
if (storageData[provider].PID !== -1) {
|
if (storageData[provider].PID !== -1) {
|
||||||
expectedUnmount[provider] = false;
|
expectedUnmount[provider] = false;
|
||||||
if (firstMountCheck) {
|
if (firstMountCheck) {
|
||||||
monitorMount(event.sender, provider, dataDirectory, data.Version, storageData[provider].PID, storageData[provider].Location);
|
monitorMount(event.sender, provider, data.Version, storageData[provider].PID, storageData[provider].Location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -540,8 +536,7 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Download_File, (event, data) => {
|
ipcMain.on(Constants.IPC_Download_File, (event, data) => {
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
const destination = path.join(helpers.getDataDirectory(), data.Filename);
|
||||||
const destination = path.join(dataDirectory, data.Filename);
|
|
||||||
helpers.downloadFile(data.URL, destination, (progress) => {
|
helpers.downloadFile(data.URL, destination, (progress) => {
|
||||||
standardIPCReply(event, Constants.IPC_Download_File_Progress, {
|
standardIPCReply(event, Constants.IPC_Download_File_Progress, {
|
||||||
Destination: destination,
|
Destination: destination,
|
||||||
@@ -557,8 +552,7 @@ ipcMain.on(Constants.IPC_Download_File, (event, data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Extract_Release, (event, data) => {
|
ipcMain.on(Constants.IPC_Extract_Release, (event, data) => {
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
const destination = path.join(helpers.getDataDirectory(), data.Version);
|
||||||
const destination = path.join(dataDirectory, data.Version);
|
|
||||||
helpers.mkDirByPathSync(destination);
|
helpers.mkDirByPathSync(destination);
|
||||||
|
|
||||||
const stream = fs.createReadStream(data.Source);
|
const stream = fs.createReadStream(data.Source);
|
||||||
@@ -598,9 +592,8 @@ ipcMain.on(Constants.IPC_Extract_Release, (event, data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Get_Config, (event, data) => {
|
ipcMain.on(Constants.IPC_Get_Config, (event, data) => {
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
|
||||||
helpers
|
helpers
|
||||||
.getConfig(dataDirectory, data.Version, data.StorageType)
|
.getConfig(data.Version, data.StorageType)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.Code === 0) {
|
if (data.Code === 0) {
|
||||||
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {
|
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {
|
||||||
@@ -616,9 +609,8 @@ ipcMain.on(Constants.IPC_Get_Config, (event, data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Get_Config_Template, (event, data) => {
|
ipcMain.on(Constants.IPC_Get_Config_Template, (event, data) => {
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
|
||||||
helpers
|
helpers
|
||||||
.getConfigTemplate(dataDirectory, data.Version, data.StorageType)
|
.getConfigTemplate(data.Version, data.StorageType)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
standardIPCReply(event, Constants.IPC_Get_Config_Template_Reply, {
|
standardIPCReply(event, Constants.IPC_Get_Config_Template_Reply, {
|
||||||
Template: data,
|
Template: data,
|
||||||
@@ -630,37 +622,35 @@ ipcMain.on(Constants.IPC_Get_Config_Template, (event, data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Get_Platform, (event) => {
|
ipcMain.on(Constants.IPC_Get_Platform, (event) => {
|
||||||
let platform = os.platform();
|
const platform = os.platform();
|
||||||
if (platform === 'linux') {
|
if (platform === 'linux') {
|
||||||
const scriptFile = path.join(os.tmpdir(), 'repertory_detect_linux.sh');
|
const scriptFile = path.join(os.tmpdir(), 'repertory_detect_linux.sh');
|
||||||
fs.writeFileSync(scriptFile, detectScript);
|
fs.writeFileSync(scriptFile, detectScript);
|
||||||
helpers
|
helpers
|
||||||
.executeScript(scriptFile)
|
.executeScript(scriptFile)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
platform = data.replace(/(\r\n|\n|\r)/gm,"");
|
|
||||||
event.sender.send(Constants.IPC_Get_Platform_Reply, {
|
event.sender.send(Constants.IPC_Get_Platform_Reply, {
|
||||||
OSPlatform: os.platform(),
|
AppPlatform: data.replace(/(\r\n|\n|\r)/gm,""),
|
||||||
Platform: platform,
|
Platform: platform,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
event.sender.send(Constants.IPC_Get_Platform_Reply, {
|
event.sender.send(Constants.IPC_Get_Platform_Reply, {
|
||||||
OSPlatform: os.platform(),
|
AppPlatform: platform,
|
||||||
Platform: platform,
|
Platform: platform,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
event.sender.send(Constants.IPC_Get_Platform_Reply, {
|
event.sender.send(Constants.IPC_Get_Platform_Reply, {
|
||||||
OSPlatform: os.platform(),
|
AppPlatform: platform,
|
||||||
Platform: platform,
|
Platform: platform,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Get_State, (event, data) => {
|
ipcMain.on(Constants.IPC_Get_State, event => {
|
||||||
const dataDirectory = helpers.resolvePath(data);
|
helpers.mkDirByPathSync(helpers.getDataDirectory());
|
||||||
helpers.mkDirByPathSync(dataDirectory);
|
const configFile = path.join(helpers.getDataDirectory(), 'settings.json');
|
||||||
const configFile = path.join(dataDirectory, 'settings.json');
|
|
||||||
if (fs.existsSync(configFile)) {
|
if (fs.existsSync(configFile)) {
|
||||||
event.sender.send(Constants.IPC_Get_State_Reply, {
|
event.sender.send(Constants.IPC_Get_State_Reply, {
|
||||||
data: JSON.parse(fs.readFileSync(configFile, 'utf8')),
|
data: JSON.parse(fs.readFileSync(configFile, 'utf8')),
|
||||||
@@ -815,14 +805,12 @@ ipcMain.on(Constants.IPC_Install_Upgrade, (event, data) => {
|
|||||||
|
|
||||||
ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
|
ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
|
||||||
expectedUnmount[data.StorageType] = false;
|
expectedUnmount[data.StorageType] = false;
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
|
||||||
|
|
||||||
if (mountedLocations.indexOf(data.Location) !== -1) {
|
if (mountedLocations.indexOf(data.Location) !== -1) {
|
||||||
console.log(data.StorageType + ' already mounted: ' + data.Location);
|
console.log(data.StorageType + ' already mounted: ' + data.Location);
|
||||||
} else {
|
} else {
|
||||||
mountedLocations.push(data.Location);
|
mountedLocations.push(data.Location);
|
||||||
mountedData[data.Location] = {
|
mountedData[data.Location] = {
|
||||||
DataDirectory: dataDirectory,
|
|
||||||
Version: data.Version,
|
Version: data.Version,
|
||||||
StorageType: data.StorageType,
|
StorageType: data.StorageType,
|
||||||
};
|
};
|
||||||
@@ -839,7 +827,7 @@ ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
|
|||||||
}, error || Error(data.StorageType + ' Unmounted'));
|
}, error || Error(data.StorageType + ' Unmounted'));
|
||||||
};
|
};
|
||||||
helpers
|
helpers
|
||||||
.executeMount(dataDirectory, data.Version, data.StorageType, data.Location, data.NoConsoleSupported, (error, pid) => {
|
.executeMount(data.Version, data.StorageType, data.Location, data.NoConsoleSupported, (error, pid) => {
|
||||||
errorHandler(pid, error);
|
errorHandler(pid, error);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -854,18 +842,16 @@ ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Save_State, (event, data) => {
|
ipcMain.on(Constants.IPC_Save_State, (event, data) => {
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
helpers.mkDirByPathSync(helpers.getDataDirectory());
|
||||||
helpers.mkDirByPathSync(dataDirectory);
|
const configFile = path.join(helpers.getDataDirectory(), 'settings.json');
|
||||||
const configFile = path.join(dataDirectory, 'settings.json');
|
|
||||||
fs.writeFileSync(configFile, JSON.stringify(data.State), 'utf8');
|
fs.writeFileSync(configFile, JSON.stringify(data.State), 'utf8');
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Set_Config_Values, (event, data) => {
|
ipcMain.on(Constants.IPC_Set_Config_Values, (event, data) => {
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
|
||||||
const setConfigValue = (i) => {
|
const setConfigValue = (i) => {
|
||||||
if (i < data.Items.length) {
|
if (i < data.Items.length) {
|
||||||
helpers
|
helpers
|
||||||
.setConfigValue(data.Items[i].Name, data.Items[i].Value, dataDirectory, data.StorageType, data.Version)
|
.setConfigValue(data.Items[i].Name, data.Items[i].Value, data.StorageType, data.Version)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setConfigValue(++i);
|
setConfigValue(++i);
|
||||||
})
|
})
|
||||||
@@ -895,10 +881,9 @@ ipcMain.on(Constants.IPC_Show_Window + '_sync', event => {
|
|||||||
ipcMain.on(Constants.IPC_Unmount_Drive, (event, data) => {
|
ipcMain.on(Constants.IPC_Unmount_Drive, (event, data) => {
|
||||||
clearManualMountDetection(data.StorageType);
|
clearManualMountDetection(data.StorageType);
|
||||||
|
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
|
||||||
expectedUnmount[data.StorageType] = true;
|
expectedUnmount[data.StorageType] = true;
|
||||||
helpers
|
helpers
|
||||||
.stopMountProcess(dataDirectory, data.Version, data.StorageType)
|
.stopMountProcess(data.Version, data.StorageType)
|
||||||
.then((result)=> {
|
.then((result)=> {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
})
|
})
|
||||||
|
|||||||
70
src/App.js
70
src/App.js
@@ -42,14 +42,12 @@ class App extends IPCContainer {
|
|||||||
this.setRequestHandler(Constants.IPC_Install_Dependency_Reply, this.onInstallDependencyReply);
|
this.setRequestHandler(Constants.IPC_Install_Dependency_Reply, this.onInstallDependencyReply);
|
||||||
this.setRequestHandler(Constants.IPC_Install_Upgrade_Reply, this.onInstallUpgradeReply);
|
this.setRequestHandler(Constants.IPC_Install_Upgrade_Reply, this.onInstallUpgradeReply);
|
||||||
|
|
||||||
this.sendRequest(Constants.IPC_Get_State, Constants.DATA_LOCATIONS[this.props.platform]);
|
this.sendRequest(Constants.IPC_Get_State);
|
||||||
Scheduler.scheduleJob('23 11 * * *', this.updateCheckScheduledJob);
|
Scheduler.scheduleJob('23 11 * * *', this.updateCheckScheduledJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
AllowDownload: false,
|
AllowDownload: false,
|
||||||
AutoMountProcessed: false,
|
|
||||||
ConfigStorageType: null,
|
|
||||||
DisplayError: false,
|
DisplayError: false,
|
||||||
DisplayMainContent: false,
|
DisplayMainContent: false,
|
||||||
Error: null,
|
Error: null,
|
||||||
@@ -106,7 +104,6 @@ class App extends IPCContainer {
|
|||||||
|
|
||||||
this.sendRequest(Constants.IPC_Check_Installed, {
|
this.sendRequest(Constants.IPC_Check_Installed, {
|
||||||
Dependencies: dependencies,
|
Dependencies: dependencies,
|
||||||
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
|
||||||
Version: selectedVersion,
|
Version: selectedVersion,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -137,7 +134,6 @@ class App extends IPCContainer {
|
|||||||
if (data.Success) {
|
if (data.Success) {
|
||||||
const selectedVersion = this.getSelectedVersion();
|
const selectedVersion = this.getSelectedVersion();
|
||||||
this.sendRequest(Constants.IPC_Extract_Release, {
|
this.sendRequest(Constants.IPC_Extract_Release, {
|
||||||
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
|
||||||
Source: data.Destination,
|
Source: data.Destination,
|
||||||
Version: selectedVersion,
|
Version: selectedVersion,
|
||||||
});
|
});
|
||||||
@@ -157,7 +153,7 @@ class App extends IPCContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
grabReleases = () => {
|
grabReleases = () => {
|
||||||
if (this.props.platform !== 'unknown') {
|
if (this.props.Platform !== 'unknown') {
|
||||||
this.sendRequest(Constants.IPC_Grab_Releases);
|
this.sendRequest(Constants.IPC_Grab_Releases);
|
||||||
this.sendRequest(Constants.IPC_Grab_UI_Releases);
|
this.sendRequest(Constants.IPC_Grab_UI_Releases);
|
||||||
}
|
}
|
||||||
@@ -187,18 +183,6 @@ class App extends IPCContainer {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
handleConfigClicked = (storageType) => {
|
|
||||||
this.setState({
|
|
||||||
ConfigStorageType: storageType,
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
handleConfigClosed = () => {
|
|
||||||
this.setState({
|
|
||||||
ConfigStorageType: null,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
handleDependencyDownload = (url) => {
|
handleDependencyDownload = (url) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
DownloadActive: true,
|
DownloadActive: true,
|
||||||
@@ -206,7 +190,6 @@ class App extends IPCContainer {
|
|||||||
DownloadName: this.extractFileNameFromURL(url),
|
DownloadName: this.extractFileNameFromURL(url),
|
||||||
}, ()=> {
|
}, ()=> {
|
||||||
this.sendRequest(Constants.IPC_Download_File, {
|
this.sendRequest(Constants.IPC_Download_File, {
|
||||||
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
|
||||||
Filename: this.state.DownloadName,
|
Filename: this.state.DownloadName,
|
||||||
URL: url,
|
URL: url,
|
||||||
});
|
});
|
||||||
@@ -246,7 +229,6 @@ class App extends IPCContainer {
|
|||||||
DownloadName: fileName,
|
DownloadName: fileName,
|
||||||
}, () => {
|
}, () => {
|
||||||
this.sendRequest(Constants.IPC_Download_File, {
|
this.sendRequest(Constants.IPC_Download_File, {
|
||||||
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
|
||||||
Filename: this.state.DownloadName,
|
Filename: this.state.DownloadName,
|
||||||
URL: this.state.LocationsLookup[selectedVersion].urls[0],
|
URL: this.state.LocationsLookup[selectedVersion].urls[0],
|
||||||
});
|
});
|
||||||
@@ -261,8 +243,7 @@ class App extends IPCContainer {
|
|||||||
}, ()=> {
|
}, ()=> {
|
||||||
const url = this.state.UpgradeData.urls[0];
|
const url = this.state.UpgradeData.urls[0];
|
||||||
this.sendRequest(Constants.IPC_Download_File, {
|
this.sendRequest(Constants.IPC_Download_File, {
|
||||||
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
Filename: this.props.Platform === 'win32' ? 'upgrade.exe' : this.extractFileNameFromURL(url),
|
||||||
Filename: this.props.platform === 'win32' ? 'upgrade.exe' : this.extractFileNameFromURL(url),
|
|
||||||
URL: url,
|
URL: url,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -295,8 +276,8 @@ class App extends IPCContainer {
|
|||||||
|
|
||||||
installUpgrade = data => {
|
installUpgrade = data => {
|
||||||
if (data.Success) {
|
if (data.Success) {
|
||||||
const sha256 = this.state.LocationsLookup[this.props.platform][this.state.VersionLookup[this.props.platform][0]].sha256;
|
const sha256 = this.state.LocationsLookup[this.props.Platform][this.state.VersionLookup[this.props.Platform][0]].sha256;
|
||||||
const signature = this.state.LocationsLookup[this.props.platform][this.state.VersionLookup[this.props.platform][0]].sig;
|
const signature = this.state.LocationsLookup[this.props.Platform][this.state.VersionLookup[this.props.Platform][0]].sig;
|
||||||
this.sendRequest(Constants.IPC_Install_Upgrade, {
|
this.sendRequest(Constants.IPC_Install_Upgrade, {
|
||||||
Sha256: sha256,
|
Sha256: sha256,
|
||||||
Signature: signature,
|
Signature: signature,
|
||||||
@@ -313,10 +294,6 @@ class App extends IPCContainer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
notifyAutoMountProcessed = () => {
|
|
||||||
this.setState({AutoMountProcessed: true});
|
|
||||||
};
|
|
||||||
|
|
||||||
onCheckInstalledReply = (event, arg) => {
|
onCheckInstalledReply = (event, arg) => {
|
||||||
const action = () => {
|
const action = () => {
|
||||||
const installedVersion = arg.data.Success && arg.data.Exists ? arg.data.Version : 'none';
|
const installedVersion = arg.data.Success && arg.data.Exists ? arg.data.Version : 'none';
|
||||||
@@ -431,13 +408,13 @@ class App extends IPCContainer {
|
|||||||
.get(Constants.RELEASES_URL)
|
.get(Constants.RELEASES_URL)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
const versionLookup = {
|
const versionLookup = {
|
||||||
Alpha: response.data.Versions.Alpha[this.props.platform],
|
Alpha: response.data.Versions.Alpha[this.props.Platform],
|
||||||
Beta: response.data.Versions.Beta[this.props.platform],
|
Beta: response.data.Versions.Beta[this.props.Platform],
|
||||||
RC: response.data.Versions.RC[this.props.platform],
|
RC: response.data.Versions.RC[this.props.Platform],
|
||||||
Release: response.data.Versions.Release[this.props.platform],
|
Release: response.data.Versions.Release[this.props.Platform],
|
||||||
};
|
};
|
||||||
const locationsLookup = {
|
const locationsLookup = {
|
||||||
...response.data.Locations[this.props.platform],
|
...response.data.Locations[this.props.Platform],
|
||||||
};
|
};
|
||||||
|
|
||||||
window.localStorage.setItem('releases', JSON.stringify({
|
window.localStorage.setItem('releases', JSON.stringify({
|
||||||
@@ -466,13 +443,13 @@ class App extends IPCContainer {
|
|||||||
.then(response => {
|
.then(response => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
if (data.Versions &&
|
if (data.Versions &&
|
||||||
data.Versions[this.props.platform] &&
|
data.Versions[this.props.Platform] &&
|
||||||
(data.Versions[this.props.platform].length > 0) &&
|
(data.Versions[this.props.Platform].length > 0) &&
|
||||||
(data.Versions[this.props.platform][0] !== this.props.version)) {
|
(data.Versions[this.props.Platform][0] !== this.props.version)) {
|
||||||
this.setState({
|
this.setState({
|
||||||
UpgradeAvailable: true,
|
UpgradeAvailable: true,
|
||||||
UpgradeDismissed: false,
|
UpgradeDismissed: false,
|
||||||
UpgradeData: data.Locations[this.props.platform][data.Versions[this.props.platform][0]],
|
UpgradeData: data.Locations[this.props.Platform][data.Versions[this.props.Platform][0]],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
@@ -529,7 +506,6 @@ class App extends IPCContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.sendRequest(Constants.IPC_Save_State, {
|
this.sendRequest(Constants.IPC_Save_State, {
|
||||||
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
|
||||||
State: state
|
State: state
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -546,7 +522,7 @@ class App extends IPCContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
updateCheckScheduledJob = () => {
|
updateCheckScheduledJob = () => {
|
||||||
if (this.props.platform !== 'unknown') {
|
if (this.props.Platform !== 'unknown') {
|
||||||
this.grabReleases();
|
this.grabReleases();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -593,7 +569,7 @@ class App extends IPCContainer {
|
|||||||
this.state.LocationsLookup[selectedVersion].no_console_supported;
|
this.state.LocationsLookup[selectedVersion].no_console_supported;
|
||||||
|
|
||||||
const showConfig = !missingDependencies &&
|
const showConfig = !missingDependencies &&
|
||||||
this.state.ConfigStorageType &&
|
this.props.DisplayConfiguration &&
|
||||||
allowConfig;
|
allowConfig;
|
||||||
|
|
||||||
const showUpgrade = this.state.UpgradeAvailable &&
|
const showUpgrade = this.state.UpgradeAvailable &&
|
||||||
@@ -621,10 +597,7 @@ class App extends IPCContainer {
|
|||||||
if (showConfig) {
|
if (showConfig) {
|
||||||
configDisplay = (
|
configDisplay = (
|
||||||
<Modal>
|
<Modal>
|
||||||
<Configuration closed={this.handleConfigClosed}
|
<Configuration errorHandler={this.setErrorState}
|
||||||
directory={Constants.DATA_LOCATIONS[this.props.platform]}
|
|
||||||
errorHandler={this.setErrorState}
|
|
||||||
storageType={this.state.ConfigStorageType}
|
|
||||||
version={selectedVersion} />
|
version={selectedVersion} />
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
@@ -695,14 +668,9 @@ class App extends IPCContainer {
|
|||||||
allowSiaPrime={allowSiaPrime}
|
allowSiaPrime={allowSiaPrime}
|
||||||
noConsoleSupported={noConsoleSupported}
|
noConsoleSupported={noConsoleSupported}
|
||||||
autoMountChanged={this.handleAutoMountChanged}
|
autoMountChanged={this.handleAutoMountChanged}
|
||||||
autoMountProcessed={this.notifyAutoMountProcessed}
|
|
||||||
autoRestartChanged={this.handleAutoRestartChanged}
|
autoRestartChanged={this.handleAutoRestartChanged}
|
||||||
changed={this.handleMountLocationChanged}
|
changed={this.handleMountLocationChanged}
|
||||||
configClicked={this.handleConfigClicked}
|
|
||||||
directory={Constants.DATA_LOCATIONS[this.props.platform]}
|
|
||||||
errorHandler={this.setErrorState}
|
errorHandler={this.setErrorState}
|
||||||
platform={this.props.platform}
|
|
||||||
processAutoMount={!this.state.AutoMountProcessed}
|
|
||||||
version={this.state.InstalledVersion}/>
|
version={this.state.InstalledVersion}/>
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
@@ -752,7 +720,9 @@ class App extends IPCContainer {
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
MountsBusy: state.mounts.MountsBusy
|
DisplayConfiguration: state.mounts.DisplayConfiguration,
|
||||||
|
MountsBusy: state.mounts.MountsBusy,
|
||||||
|
Platform: state.common.Platform,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './MountItem.css';
|
import './MountItem.css';
|
||||||
|
import {connect} from "react-redux";
|
||||||
import DropDown from '../UI/DropDown/DropDown';
|
import DropDown from '../UI/DropDown/DropDown';
|
||||||
import Button from '../UI/Button/Button';
|
import Button from '../UI/Button/Button';
|
||||||
import Loader from 'react-loader-spinner';
|
import Loader from 'react-loader-spinner';
|
||||||
@@ -8,7 +9,13 @@ import Grid from '../UI/Grid/Grid';
|
|||||||
import configureImage from '../../assets/images/configure.png';
|
import configureImage from '../../assets/images/configure.png';
|
||||||
import RootElem from '../../hoc/RootElem/RootElem';
|
import RootElem from '../../hoc/RootElem/RootElem';
|
||||||
|
|
||||||
export default props => {
|
const mapStateToProps = state => {
|
||||||
|
return {
|
||||||
|
Platform: state.common.Platform,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps)(props => {
|
||||||
let configButton = null;
|
let configButton = null;
|
||||||
let secondRow = 6;
|
let secondRow = 6;
|
||||||
if (props.allowConfig) {
|
if (props.allowConfig) {
|
||||||
@@ -27,7 +34,7 @@ export default props => {
|
|||||||
|
|
||||||
let inputColumnSpan;
|
let inputColumnSpan;
|
||||||
let inputControls = null;
|
let inputControls = null;
|
||||||
if (props.platform === 'win32') {
|
if (props.Platform === 'win32') {
|
||||||
inputColumnSpan = 20;
|
inputColumnSpan = 20;
|
||||||
inputControls = <DropDown changed={props.changed}
|
inputControls = <DropDown changed={props.changed}
|
||||||
colSpan={inputColumnSpan}
|
colSpan={inputColumnSpan}
|
||||||
@@ -121,4 +128,4 @@ export default props => {
|
|||||||
{autoRestartControl}
|
{autoRestartControl}
|
||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './Configuration.css';
|
import './Configuration.css';
|
||||||
|
import {connect} from 'react-redux';
|
||||||
import Box from '../../components/UI/Box/Box';
|
import Box from '../../components/UI/Box/Box';
|
||||||
import Button from '../../components/UI/Button/Button';
|
import Button from '../../components/UI/Button/Button';
|
||||||
import ConfigurationItem from '../../components/ConfigurationItem/ConfigurationItem';
|
import ConfigurationItem from '../../components/ConfigurationItem/ConfigurationItem';
|
||||||
import Modal from '../../components/UI/Modal/Modal';
|
import Modal from '../../components/UI/Modal/Modal';
|
||||||
import IPCContainer from '../IPCContainer/IPCContainer';
|
import IPCContainer from '../IPCContainer/IPCContainer';
|
||||||
|
import {displayConfiguration} from "../../redux/actions/mount_actions";
|
||||||
|
|
||||||
const Constants = require('../../constants');
|
const Constants = require('../../constants');
|
||||||
|
|
||||||
@@ -16,8 +18,7 @@ class Configuration extends IPCContainer {
|
|||||||
this.setRequestHandler(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply);
|
this.setRequestHandler(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply);
|
||||||
|
|
||||||
this.sendRequest(Constants.IPC_Get_Config_Template, {
|
this.sendRequest(Constants.IPC_Get_Config_Template, {
|
||||||
Directory: this.props.directory,
|
StorageType: this.props.DisplayConfiguration,
|
||||||
StorageType: this.props.storageType,
|
|
||||||
Version: this.props.version,
|
Version: this.props.version,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -67,7 +68,7 @@ class Configuration extends IPCContainer {
|
|||||||
ChangedObjectLookup: changedObjectLookup,
|
ChangedObjectLookup: changedObjectLookup,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.props.closed();
|
this.props.hideConfiguration();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -151,20 +152,19 @@ class Configuration extends IPCContainer {
|
|||||||
Template: arg.data.Template,
|
Template: arg.data.Template,
|
||||||
}, ()=> {
|
}, ()=> {
|
||||||
this.sendRequest(Constants.IPC_Get_Config, {
|
this.sendRequest(Constants.IPC_Get_Config, {
|
||||||
Directory: this.props.directory,
|
StorageType: this.props.DisplayConfiguration,
|
||||||
StorageType: this.props.storageType,
|
|
||||||
Version: this.props.version,
|
Version: this.props.version,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.props.errorHandler(arg.data.Error, () => {
|
this.props.errorHandler(arg.data.Error, () => {
|
||||||
this.props.closed();
|
this.props.hideConfiguration();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onSetConfigValuesReply = () => {
|
onSetConfigValuesReply = () => {
|
||||||
this.props.closed();
|
this.props.hideConfiguration();
|
||||||
};
|
};
|
||||||
|
|
||||||
saveAndClose = () => {
|
saveAndClose = () => {
|
||||||
@@ -191,9 +191,8 @@ class Configuration extends IPCContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.sendRequest(Constants.IPC_Set_Config_Values, {
|
this.sendRequest(Constants.IPC_Set_Config_Values, {
|
||||||
Directory: this.props.directory,
|
|
||||||
Items: changedItems,
|
Items: changedItems,
|
||||||
StorageType: this.props.storageType,
|
StorageType: this.props.DisplayConfiguration,
|
||||||
Version: this.props.version,
|
Version: this.props.version,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -209,7 +208,7 @@ class Configuration extends IPCContainer {
|
|||||||
<table width='100%'><tbody>
|
<table width='100%'><tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align='center' width='50%'><Button clicked={this.saveAndClose} disabled={this.state.Saving}>Yes</Button></td>
|
<td align='center' width='50%'><Button clicked={this.saveAndClose} disabled={this.state.Saving}>Yes</Button></td>
|
||||||
<td align='center' width='50%'><Button clicked={this.props.closed} disabled={this.state.Saving}>No</Button></td>
|
<td align='center' width='50%'><Button clicked={this.props.hideConfiguration} disabled={this.state.Saving}>No</Button></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -264,7 +263,7 @@ class Configuration extends IPCContainer {
|
|||||||
<b style={{cursor: 'pointer'}}
|
<b style={{cursor: 'pointer'}}
|
||||||
onClick={this.checkSaveRequired}>X</b>
|
onClick={this.checkSaveRequired}>X</b>
|
||||||
</div>
|
</div>
|
||||||
<h1 style={{width: '100%', textAlign: 'center'}}>{this.props.storageType + ' Configuration'}</h1>
|
<h1 style={{width: '100%', textAlign: 'center'}}>{this.props.DisplayConfiguration + ' Configuration'}</h1>
|
||||||
<div style={{overflowY: 'auto', height: '90%'}}>
|
<div style={{overflowY: 'auto', height: '90%'}}>
|
||||||
{objectItems}
|
{objectItems}
|
||||||
{(configurationItems.length > 0) ? <h1>Settings</h1> : null}
|
{(configurationItems.length > 0) ? <h1>Settings</h1> : null}
|
||||||
@@ -276,4 +275,16 @@ class Configuration extends IPCContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Configuration;
|
const mapStateToProps = state => {
|
||||||
|
return {
|
||||||
|
DisplayConfiguration: state.mounts.DisplayConfiguration,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => {
|
||||||
|
return {
|
||||||
|
hideConfiguration: () => dispatch(displayConfiguration(null)),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(Configuration);
|
||||||
@@ -6,7 +6,7 @@ import './MountItems.css';
|
|||||||
import Modal from '../../components/UI/Modal/Modal';
|
import Modal from '../../components/UI/Modal/Modal';
|
||||||
import MountItem from '../../components/MountItem/MountItem';
|
import MountItem from '../../components/MountItem/MountItem';
|
||||||
import IPCContainer from '../IPCContainer/IPCContainer';
|
import IPCContainer from '../IPCContainer/IPCContainer';
|
||||||
import {setBusy} from '../../redux/actions/mount_actions';
|
import {displayConfiguration, setAutoMountProcessed, setBusy} from '../../redux/actions/mount_actions';
|
||||||
|
|
||||||
const Constants = require('../../constants');
|
const Constants = require('../../constants');
|
||||||
|
|
||||||
@@ -71,7 +71,6 @@ class MountItems extends IPCContainer {
|
|||||||
if (!this.state.DisplayRetry) {
|
if (!this.state.DisplayRetry) {
|
||||||
this.props.setMountsBusy(true);
|
this.props.setMountsBusy(true);
|
||||||
this.sendRequest(Constants.IPC_Detect_Mounts, {
|
this.sendRequest(Constants.IPC_Detect_Mounts, {
|
||||||
Directory: this.props.directory,
|
|
||||||
Version: this.props.version,
|
Version: this.props.version,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -88,7 +87,7 @@ class MountItems extends IPCContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
handleMountLocationChanged = (storageType, value) => {
|
handleMountLocationChanged = (storageType, value) => {
|
||||||
if (this.props.platform === 'win32') {
|
if (this.props.Platform === 'win32') {
|
||||||
this.props.changed(storageType, this.state[storageType].DriveLetters[value]);
|
this.props.changed(storageType, this.state[storageType].DriveLetters[value]);
|
||||||
} else {
|
} else {
|
||||||
this.props.changed(storageType, value);
|
this.props.changed(storageType, value);
|
||||||
@@ -102,13 +101,12 @@ class MountItems extends IPCContainer {
|
|||||||
let allowAction = true;
|
let allowAction = true;
|
||||||
if (mount) {
|
if (mount) {
|
||||||
let result = this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
|
let result = this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
|
||||||
Directory: this.props.directory,
|
|
||||||
StorageType: storageType,
|
StorageType: storageType,
|
||||||
Version: this.props.version
|
Version: this.props.version
|
||||||
}).data;
|
}).data;
|
||||||
if (result.Success) {
|
if (result.Success) {
|
||||||
if (result.Valid) {
|
if (result.Valid) {
|
||||||
if (this.props.platform !== 'win32') {
|
if (this.props.Platform !== 'win32') {
|
||||||
result = this.sendSyncRequest(Constants.IPC_Check_Mount_Location, {
|
result = this.sendSyncRequest(Constants.IPC_Check_Mount_Location, {
|
||||||
Location: location,
|
Location: location,
|
||||||
});
|
});
|
||||||
@@ -140,7 +138,6 @@ class MountItems extends IPCContainer {
|
|||||||
}, () => {
|
}, () => {
|
||||||
if (mount) {
|
if (mount) {
|
||||||
this.sendRequest(Constants.IPC_Mount_Drive, {
|
this.sendRequest(Constants.IPC_Mount_Drive, {
|
||||||
Directory: this.props.directory,
|
|
||||||
Location: location,
|
Location: location,
|
||||||
NoConsoleSupported: this.props.noConsoleSupported,
|
NoConsoleSupported: this.props.noConsoleSupported,
|
||||||
StorageType: storageType,
|
StorageType: storageType,
|
||||||
@@ -148,7 +145,6 @@ class MountItems extends IPCContainer {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.sendRequest(Constants.IPC_Unmount_Drive, {
|
this.sendRequest(Constants.IPC_Unmount_Drive, {
|
||||||
Directory: this.props.directory,
|
|
||||||
Location: location,
|
Location: location,
|
||||||
StorageType: storageType,
|
StorageType: storageType,
|
||||||
Version: this.props.version,
|
Version: this.props.version,
|
||||||
@@ -179,7 +175,7 @@ class MountItems extends IPCContainer {
|
|||||||
const providerLower = provider.toLowerCase();
|
const providerLower = provider.toLowerCase();
|
||||||
let location = data.Locations[provider];
|
let location = data.Locations[provider];
|
||||||
if (location.length === 0) {
|
if (location.length === 0) {
|
||||||
location = (this.props.platform === 'win32') ?
|
location = (this.props.Platform === 'win32') ?
|
||||||
this.props[providerLower].MountLocation || data.DriveLetters[provider][0] :
|
this.props[providerLower].MountLocation || data.DriveLetters[provider][0] :
|
||||||
this.props[providerLower].MountLocation;
|
this.props[providerLower].MountLocation;
|
||||||
}
|
}
|
||||||
@@ -256,8 +252,9 @@ class MountItems extends IPCContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
performAutoMount = ()=> {
|
performAutoMount = ()=> {
|
||||||
if (this.props.processAutoMount) {
|
if (!this.props.AutoMountProcessed) {
|
||||||
this.props.autoMountProcessed();
|
this.props.setAutoMountProcessed(true);
|
||||||
|
|
||||||
const processAutoMount = (provider) => {
|
const processAutoMount = (provider) => {
|
||||||
const providerLower = provider.toLowerCase();
|
const providerLower = provider.toLowerCase();
|
||||||
if (this.props[providerLower].AutoMount &&
|
if (this.props[providerLower].AutoMount &&
|
||||||
@@ -313,12 +310,11 @@ class MountItems extends IPCContainer {
|
|||||||
browseClicked={this.handleBrowseLocation}
|
browseClicked={this.handleBrowseLocation}
|
||||||
changed={(e) => this.handleMountLocationChanged(provider, e.target.value)}
|
changed={(e) => this.handleMountLocationChanged(provider, e.target.value)}
|
||||||
clicked={this.handleMountUnMount}
|
clicked={this.handleMountUnMount}
|
||||||
configClicked={()=>this.props.configClicked(provider)}
|
configClicked={()=>this.props.displayConfiguration(provider)}
|
||||||
items={this.state[provider].DriveLetters}
|
items={this.state[provider].DriveLetters}
|
||||||
key={'mi_' + items.length}
|
key={'mi_' + items.length}
|
||||||
location={this.props[providerLower].MountLocation}
|
location={this.props[providerLower].MountLocation}
|
||||||
mounted={this.state[provider].Mounted}
|
mounted={this.state[provider].Mounted}
|
||||||
platform={this.props.platform}
|
|
||||||
title={provider} />
|
title={provider} />
|
||||||
));
|
));
|
||||||
if (items.length !== this.state.length) {
|
if (items.length !== this.state.length) {
|
||||||
@@ -335,10 +331,19 @@ class MountItems extends IPCContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
setMountsBusy: busy => dispatch(setBusy(busy))
|
AutoMountProcessed: state.mounts.AutoMountProcessed,
|
||||||
|
Platform: state.common.Platform,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps)(MountItems);
|
const mapDispatchToProps = dispatch => {
|
||||||
|
return {
|
||||||
|
displayConfiguration: storageType => dispatch(displayConfiguration(storageType)),
|
||||||
|
setAutoMountProcessed: processed => dispatch(setAutoMountProcessed(processed)),
|
||||||
|
setMountsBusy: busy => dispatch(setBusy(busy)),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(MountItems);
|
||||||
@@ -8,6 +8,20 @@ const spawn = require('child_process').spawn;
|
|||||||
const Constants = require('./constants');
|
const Constants = require('./constants');
|
||||||
const RandomString = require('randomstring');
|
const RandomString = require('randomstring');
|
||||||
|
|
||||||
|
const _getDataDirectory = () => {
|
||||||
|
return _resolvePath(Constants.DATA_LOCATIONS[os.platform()]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const _resolvePath = str => {
|
||||||
|
if (os.platform() === 'win32') {
|
||||||
|
return str.replace(/%([^%]+)%/g, (_, n) => {
|
||||||
|
return process.env[n];
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return str.replace('~', os.homedir());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const tryParse = (j, def) => {
|
const tryParse = (j, def) => {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(j);
|
return JSON.parse(j);
|
||||||
@@ -16,7 +30,7 @@ const tryParse = (j, def) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.checkDaemonVersion = (directory, version, storageType) => {
|
module.exports.checkDaemonVersion = (version, storageType) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
@@ -24,7 +38,7 @@ module.exports.checkDaemonVersion = (directory, version, storageType) => {
|
|||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = [];
|
const args = [];
|
||||||
args.push('-cv');
|
args.push('-cv');
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
||||||
@@ -67,7 +81,7 @@ module.exports.createSignatureFiles = (signature, publicKey) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.detectRepertoryMounts = (directory, version) => {
|
module.exports.detectRepertoryMounts = version => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
@@ -75,7 +89,7 @@ module.exports.detectRepertoryMounts = (directory, version) => {
|
|||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = [];
|
const args = [];
|
||||||
args.push('-status');
|
args.push('-status');
|
||||||
|
|
||||||
@@ -240,7 +254,7 @@ module.exports.executeScript = script => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.executeMount = (directory, version, storageType, location, noConsoleSupported, exitCallback) => {
|
module.exports.executeMount = (version, storageType, location, noConsoleSupported, exitCallback) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: false,
|
detached: false,
|
||||||
@@ -248,7 +262,7 @@ module.exports.executeMount = (directory, version, storageType, location, noCons
|
|||||||
stdio: 'ignore',
|
stdio: 'ignore',
|
||||||
};
|
};
|
||||||
|
|
||||||
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = [];
|
const args = [];
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
||||||
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
||||||
@@ -285,7 +299,7 @@ module.exports.executeMount = (directory, version, storageType, location, noCons
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getConfig = (directory, version, storageType) => {
|
module.exports.getConfig = (version, storageType) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
@@ -293,7 +307,7 @@ module.exports.getConfig = (directory, version, storageType) => {
|
|||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = [];
|
const args = [];
|
||||||
args.push('-dc');
|
args.push('-dc');
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
||||||
@@ -331,7 +345,7 @@ module.exports.getConfig = (directory, version, storageType) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getConfigTemplate = (directory, version, storageType) => {
|
module.exports.getConfigTemplate = (version, storageType) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
@@ -339,7 +353,7 @@ module.exports.getConfigTemplate = (directory, version, storageType) => {
|
|||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = [];
|
const args = [];
|
||||||
args.push('-gt');
|
args.push('-gt');
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
||||||
@@ -364,6 +378,8 @@ module.exports.getConfigTemplate = (directory, version, storageType) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.getDataDirectory = _getDataDirectory;
|
||||||
|
|
||||||
module.exports.getMissingDependencies = dependencies => {
|
module.exports.getMissingDependencies = dependencies => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!dependencies) {
|
if (!dependencies) {
|
||||||
@@ -482,17 +498,9 @@ module.exports.removeDirectoryRecursively = (p) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.resolvePath = str => {
|
module.exports.resolvePath = _resolvePath;
|
||||||
if (os.platform() === 'win32') {
|
|
||||||
return str.replace(/%([^%]+)%/g, (_, n) => {
|
|
||||||
return process.env[n];
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return str.replace('~', os.homedir());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.setConfigValue = (name, value, directory, storageType, version) => {
|
module.exports.setConfigValue = (name, value, storageType, version) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
@@ -500,7 +508,7 @@ module.exports.setConfigValue = (name, value, directory, storageType, version) =
|
|||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = [];
|
const args = [];
|
||||||
args.push('-set');
|
args.push('-set');
|
||||||
args.push(name);
|
args.push(name);
|
||||||
@@ -523,7 +531,7 @@ module.exports.setConfigValue = (name, value, directory, storageType, version) =
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.stopMountProcess = (directory, version, storageType) => {
|
module.exports.stopMountProcess = (version, storageType) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: os.platform() === 'darwin',
|
detached: os.platform() === 'darwin',
|
||||||
@@ -531,7 +539,7 @@ module.exports.stopMountProcess = (directory, version, storageType) => {
|
|||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = ['-unmount'];
|
const args = ['-unmount'];
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
||||||
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
||||||
@@ -555,14 +563,14 @@ module.exports.stopMountProcess = (directory, version, storageType) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.stopMountProcessSync = (directory, version, storageType) => {
|
module.exports.stopMountProcessSync = (version, storageType) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
shell: os.platform() !== 'darwin',
|
shell: os.platform() !== 'darwin',
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = ['-unmount'];
|
const args = ['-unmount'];
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
||||||
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
||||||
|
|||||||
12
src/index.js
12
src/index.js
@@ -3,27 +3,27 @@ import ReactDOM from 'react-dom';
|
|||||||
import './index.css';
|
import './index.css';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import createAppStore from './redux/store/createAppStore';
|
import createAppStore from './redux/store/createAppStore';
|
||||||
import * as serviceWorker from './serviceWorker';
|
|
||||||
import packageJson from '../package.json';
|
import packageJson from '../package.json';
|
||||||
import {Provider} from 'react-redux';
|
import {Provider} from 'react-redux';
|
||||||
|
import * as serviceWorker from './serviceWorker';
|
||||||
|
|
||||||
const Constants = require('./constants');
|
const Constants = require('./constants');
|
||||||
|
|
||||||
const store = createAppStore({});
|
|
||||||
|
|
||||||
if (!process.versions.hasOwnProperty('electron')) {
|
if (!process.versions.hasOwnProperty('electron')) {
|
||||||
const ipcRenderer = ((window && window.require) ? window.require('electron').ipcRenderer : null);
|
const ipcRenderer = ((window && window.require) ? window.require('electron').ipcRenderer : null);
|
||||||
if (ipcRenderer) {
|
if (ipcRenderer) {
|
||||||
ipcRenderer.on(Constants.IPC_Get_Platform_Reply, (event, arg) => {
|
ipcRenderer.on(Constants.IPC_Get_Platform_Reply, (event, arg) => {
|
||||||
if (arg.OSPlatform === 'linux') {
|
if (arg.Platform === 'linux') {
|
||||||
const root = document.documentElement;
|
const root = document.documentElement;
|
||||||
root.style.setProperty('--default_font_size', '15px');
|
root.style.setProperty('--default_font_size', '15px');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const store = createAppStore(arg.Platform, arg.AppPlatform);
|
||||||
ReactDOM.render((
|
ReactDOM.render((
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<App platform={arg.Platform} version={packageJson.version}/>
|
<App version={packageJson.version}/>
|
||||||
</Provider>), document.getElementById('root'));
|
</Provider>
|
||||||
|
), document.getElementById('root'));
|
||||||
serviceWorker.unregister();
|
serviceWorker.unregister();
|
||||||
});
|
});
|
||||||
ipcRenderer.send(Constants.IPC_Get_Platform);
|
ipcRenderer.send(Constants.IPC_Get_Platform);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
import {createAction} from "redux-starter-kit";
|
import {createAction} from 'redux-starter-kit';
|
||||||
|
|
||||||
|
export const displayConfiguration = createAction('mounts/displayConfiguration');
|
||||||
|
export const setAutoMountProcessed = createAction('mounts/setAutoMountProcessed');
|
||||||
export const setBusy = createAction('mounts/setBusy');
|
export const setBusy = createAction('mounts/setBusy');
|
||||||
@@ -1,9 +1,17 @@
|
|||||||
import {createReducer} from 'redux-starter-kit';
|
import {createReducer} from 'redux-starter-kit';
|
||||||
import {setBusy} from '../actions/mount_actions';
|
import {displayConfiguration, setAutoMountProcessed, setBusy} from '../actions/mount_actions';
|
||||||
|
|
||||||
export const mountReducer = createReducer({
|
export const mountReducer = createReducer({
|
||||||
|
AutoMountProcessed: false,
|
||||||
|
DisplayConfiguration: null,
|
||||||
MountsBusy: false,
|
MountsBusy: false,
|
||||||
}, {
|
}, {
|
||||||
|
[displayConfiguration]: (state, action) => {
|
||||||
|
return {...state, DisplayConfiguration: action.payload};
|
||||||
|
},
|
||||||
|
[setAutoMountProcessed]: (state, action) => {
|
||||||
|
return {...state, AutoMountProcessed: action.payload};
|
||||||
|
},
|
||||||
[setBusy]: (state, action) => {
|
[setBusy]: (state, action) => {
|
||||||
return {...state, MountsBusy: action.payload};
|
return {...state, MountsBusy: action.payload};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
import { configureStore, getDefaultMiddleware } from 'redux-starter-kit';
|
import {configureStore, createReducer, getDefaultMiddleware} from 'redux-starter-kit';
|
||||||
import {mountReducer} from '../reducers/mount_reducer';
|
import {mountReducer} from '../reducers/mount_reducer';
|
||||||
|
|
||||||
export default function createAppStore(preloadedState) {
|
export default function createAppStore(platform, appPlatform) {
|
||||||
|
const createCommonReducer = () => {
|
||||||
|
return createReducer({
|
||||||
|
AppPlatform: appPlatform,
|
||||||
|
Platform: platform,
|
||||||
|
}, {});
|
||||||
|
};
|
||||||
|
|
||||||
const reducer = {
|
const reducer = {
|
||||||
|
common: createCommonReducer(platform, appPlatform),
|
||||||
mounts: mountReducer,
|
mounts: mountReducer,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -11,7 +19,6 @@ export default function createAppStore(preloadedState) {
|
|||||||
return configureStore({
|
return configureStore({
|
||||||
reducer,
|
reducer,
|
||||||
middleware,
|
middleware,
|
||||||
devTools: process.env.NODE_ENV !== 'production',
|
devTools: process.env.NODE_ENV !== 'production'
|
||||||
preloadedState
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user