1
0

Auto-mount

This commit is contained in:
Scott E. Graves
2017-05-04 12:03:35 -05:00
parent 9b078ba30a
commit 387919000d
2 changed files with 27 additions and 10 deletions

View File

@@ -178,7 +178,8 @@
document.body.innerHTML = '';
document.body.appendChild(div);
div.classList.remove('hidden-element');
}
},
notifyDriveMounting: _notifyDriveMounting
};
})();
@@ -301,6 +302,16 @@
}
}
function _notifyDriveMounting(mountLocation) {
const mountButton = document.getElementById('ID_MountButton');
const mountSelect = document.getElementById('ID_MountDrives');
mountButton.innerText = "Unmount";
mountButton.onclick = _mountHandler;
mountSelect['allow_change'] = false;
mountSelect.disabled = true;
mountSelect.value = mountLocation;
}
function _notifyDriveUnmounted() {
const mountButton = document.getElementById('ID_MountButton');
const mountSelect = document.getElementById('ID_MountDrives');

View File

@@ -72,11 +72,14 @@ private:
const auto lastMountLocation = _siaDriveConfig->GetLastMountLocation();
if (!lastMountLocation.empty())
{
// Change mount location
// Disable mount location
// Change mount button to 'Unmount'
// Disable mount button
std::thread([this, lastMountLocation, context, cb]()
auto global = context->GetGlobal();
auto uiUpdate = global->GetValue("uiUpdate");
auto notifyDriveMounting = uiUpdate->GetValue("notifyDriveMounting");;
CefV8ValueList args2;
args2.push_back(CefV8Value::CreateString(lastMountLocation));
notifyDriveMounting->ExecuteFunction(nullptr, args2);
std::thread([this, lastMountLocation, context]()
{
_siaDrive->Mount(lastMountLocation[0], _siaDriveConfig->GetCacheFolder(), 0);
}).detach();
@@ -616,10 +619,13 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
const auto lastMountLocation = _siaDriveConfig->GetLastMountLocation();
if (!lastMountLocation.empty())
{
// Change mount location
// Disable mount location
// Change mount button to 'Unmount'
// Disable mount button
auto uiUpdate = global->GetValue("uiUpdate");
auto notifyDriveMounting = uiUpdate->GetValue("notifyDriveMounting");;
CefV8ValueList args2;
args2.push_back(CefV8Value::CreateString(lastMountLocation));
notifyDriveMounting->ExecuteFunction(nullptr, args2);
std::thread([this, lastMountLocation]()
{
_siaDrive->Mount(lastMountLocation[0], _siaDriveConfig->GetCacheFolder(), 0);