mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-01-18 21:17:59 +00:00
Fixed some hosttree bugs
This commit is contained in:
parent
2ecc664e48
commit
7eb41630db
@ -25,6 +25,7 @@ function enterText(title = '', description = '', value = '') {
|
|||||||
instance.$close();
|
instance.$close();
|
||||||
resolve(event.detail.value);
|
resolve(event.detail.value);
|
||||||
});
|
});
|
||||||
|
instance.$on('close', () => resolve(undefined));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,14 +59,17 @@ async function refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const [ dbKey, database ] of Object.entries(host.databases)) {
|
for (const [ dbKey, database ] of Object.entries(host.databases)) {
|
||||||
if (!dbNames.includes(dbKey)) {
|
if (!database.new && !dbNames.includes(dbKey)) {
|
||||||
delete host.databases[dbKey];
|
delete host.databases[dbKey];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
database.key = dbKey;
|
database.key = dbKey;
|
||||||
database.hostKey = hostKey;
|
database.hostKey = hostKey;
|
||||||
database.collections = database.collections || {};
|
database.collections = database.collections || {};
|
||||||
|
|
||||||
|
delete database.new;
|
||||||
|
|
||||||
database.open = async function() {
|
database.open = async function() {
|
||||||
const progress = startProgress(`Opening database "${dbKey}"…`);
|
const progress = startProgress(`Opening database "${dbKey}"…`);
|
||||||
const { collections: collNames, stats } = await OpenDatabase(hostKey, dbKey);
|
const { collections: collNames, stats } = await OpenDatabase(hostKey, dbKey);
|
||||||
@ -81,8 +84,9 @@ async function refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const [ collKey, collection ] of Object.entries(database.collections)) {
|
for (const [ collKey, collection ] of Object.entries(database.collections)) {
|
||||||
if (!collNames.includes(collKey)) {
|
if (!collection.new && !collNames.includes(collKey)) {
|
||||||
delete database.collections[collKey];
|
delete database.collections[collKey];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.key = collKey;
|
collection.key = collKey;
|
||||||
@ -90,6 +94,8 @@ async function refresh() {
|
|||||||
collection.hostKey = hostKey;
|
collection.hostKey = hostKey;
|
||||||
collection.indexes = collection.indexes || [];
|
collection.indexes = collection.indexes || [];
|
||||||
|
|
||||||
|
delete collection.new;
|
||||||
|
|
||||||
collection.open = async function() {
|
collection.open = async function() {
|
||||||
const progress = startProgress(`Opening database "${dbKey}"…`);
|
const progress = startProgress(`Opening database "${dbKey}"…`);
|
||||||
const stats = await OpenCollection(hostKey, dbKey, collKey);
|
const stats = await OpenCollection(hostKey, dbKey, collKey);
|
||||||
@ -262,8 +268,8 @@ async function refresh() {
|
|||||||
database.newCollection = async function() {
|
database.newCollection = async function() {
|
||||||
const name = await dialogs.enterText('Create a collection', 'Note: collections in MongoDB do not exist until they have at least one item. Your new collection will not persist on the server; fill it to have it created.', '');
|
const name = await dialogs.enterText('Create a collection', 'Note: collections in MongoDB do not exist until they have at least one item. Your new collection will not persist on the server; fill it to have it created.', '');
|
||||||
if (name) {
|
if (name) {
|
||||||
database.collections[name] = {};
|
database.collections[name] = { key: name, new: true };
|
||||||
await refresh();
|
await database.open();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -271,8 +277,8 @@ async function refresh() {
|
|||||||
host.newDatabase = async function() {
|
host.newDatabase = async function() {
|
||||||
const name = await dialogs.enterText('Create a database', 'Enter the database name. Note: databases in MongoDB do not exist until they have a collection and an item. Your new database will not persist on the server; fill it to have it created.', '');
|
const name = await dialogs.enterText('Create a database', 'Enter the database name. Note: databases in MongoDB do not exist until they have a collection and an item. Your new database will not persist on the server; fill it to have it created.', '');
|
||||||
if (name) {
|
if (name) {
|
||||||
host.databases[name] = {};
|
host.databases[name] = { key: name, new: true };
|
||||||
await refresh();
|
await host.open();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user