mirror of
https://github.com/umap-project/umap.git
synced 2025-05-02 04:52:22 +02:00
Merge pull request #1916 from umap-project/1913-alert-on-import
fix: display an alert if the import is successful
This commit is contained in:
commit
f78320d153
1 changed files with 19 additions and 8 deletions
|
@ -234,9 +234,17 @@ export default class Importer {
|
||||||
}
|
}
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
if (this.format === 'umap') this.full()
|
let hasErrors = false
|
||||||
else if (!this.url) this.copy()
|
if (this.format === 'umap') {
|
||||||
else if (this.action) this[this.action]()
|
hasErrors = !this.full()
|
||||||
|
} else if (!this.url) {
|
||||||
|
hasErrors = !this.copy()
|
||||||
|
} else if (this.action) {
|
||||||
|
hasErrors = !this[this.action]()
|
||||||
|
}
|
||||||
|
if (!hasErrors) {
|
||||||
|
Alert.info(translate('Data successfully imported!'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
full() {
|
full() {
|
||||||
|
@ -254,16 +262,19 @@ export default class Importer {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Alert.error(translate('Invalid umap data'))
|
Alert.error(translate('Invalid umap data'))
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
link() {
|
link() {
|
||||||
if (!this.url) return
|
if (!this.url) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if (!this.format) {
|
if (!this.format) {
|
||||||
Alert.error(translate('Please choose a format'))
|
Alert.error(translate('Please choose a format'))
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
let layer = this.layer
|
const layer = this.layer
|
||||||
layer.options.remoteData = {
|
layer.options.remoteData = {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
format: this.format,
|
format: this.format,
|
||||||
|
@ -280,9 +291,9 @@ export default class Importer {
|
||||||
// Usefull in case of multiple files with different formats.
|
// Usefull in case of multiple files with different formats.
|
||||||
if (!this.format && !this.files.length) {
|
if (!this.format && !this.files.length) {
|
||||||
Alert.error(translate('Please choose a format'))
|
Alert.error(translate('Please choose a format'))
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
let layer = this.layer
|
const layer = this.layer
|
||||||
if (this.clear) layer.empty()
|
if (this.clear) layer.empty()
|
||||||
if (this.files.length) {
|
if (this.files.length) {
|
||||||
for (const file of this.files) {
|
for (const file of this.files) {
|
||||||
|
|
Loading…
Reference in a new issue