Skip to content

Commit

Permalink
Fetcher, Configuration chooser component
Browse files Browse the repository at this point in the history
  • Loading branch information
sstenchlak committed Jul 16, 2020
1 parent 9723e41 commit a2ea91f
Show file tree
Hide file tree
Showing 9 changed files with 533 additions and 303 deletions.
61 changes: 47 additions & 14 deletions locales/cs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,6 @@ add_node_dialog:
Při stahování některých vrcholů došlo k chybě. Vrcholy, co se
nepodařilo stáhnout, jsou v textovém poli. Více informací najdete ve
vývojářské konzoli prohlížeče. Zkontrolujte správnost IRI.
configuration_and_stylesheet_dialog:
title: Konfigurace a styly
predefined: Předdefinované konfigurace a styly
config: IRI konfigurace
stylesheet: IRI stylesheetu
destroy_warning: >-
Změnou konfigurace dojde ke smazání celého grafu. Bude vám nabídnuto
uložení změn.
cancel: Zrušit
load: Načíst
update: Změnit
update_stylesheet: Změnit stylesheet
update_general: Změnit
load_from_file: Načíst existující graf ze souboru
filter_dialog:
title: Filtrování uzlů
select_all: zaškrtnout vše
Expand Down Expand Up @@ -267,3 +253,50 @@ layout_dialog:
close: Zavřít
graph:
groupNode: 'jeden uzel | {n} uzly | {n} uzlů'
configuration_selection:
meta_configuration:
title: Výběr konfigurace
unnamed: Nepojmenovaná meta konfigurace
loading: Načítání informací o meta konfiguraci...
custom_panel:
title: Ruční výběr konfigurace
button: Nastavit ručně
meta_configuration:
title: Meta konfigurace
tab: Meta konfigurace podle IRI
input: IRI meta konfigurace
configuration:
title: Konfigurace
tab: Konfigurace podle IRI
input: IRI konfigurace
custom_configuration:
title: Vlastní konfigurace
tab: Vlastní konfigurace
configuration: IRI konfigurace
stylesheet: IRI stylesheetu
pattern: Pattern IRI
autocomplete: Autocomplete .json soubor(y)
confirm: Potvrdit
messages:
metaconfiguration_failed: Nepodařilo se načíst meta konfiguraci. Prosím zkontrolujte správnost IRI.
configuration_failed: Nepodařilo se načíst konfiguraci. Prosím zkontrolujte správnost IRI.
custom_configuration_failed: Nepodařilo se načíst konfiguraci. Prosím zkontrolujte správnost IRI. Stále můžete zadat parametry ručně.
custom_configuration_succeeded: Knfigurace úspěšně načtena. Nyní můžete změnit její parametry před použitím.
node_selection:
unnamed: Nepojmenovaná konfigurace
choose_message: Vyberte počíteční uzel
choose_info: Můžete zadat IRI identifikátor uzlu nebo se ho pokusit vyhledat, pokud to daná konfigurace umožňuje.
predefined: Předdefinované uzly
loading: Načítání uzlu...
open_from_file: Otevřít ze souboru / URL
load: Načíst
close: Zavřít
back: Zpět
go_to_graph: Jít ke grafu
load_dialog:
error: Nepodařilo se načíst graf z URL. Zkontrolujte její správnost.
load_from_url: Z URL adresy
url: URL
load: Načíst
load_from_file: Ze souboru
cancel: Zrušit
38 changes: 18 additions & 20 deletions locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ settings:
content: All the settings are stored in local storage container in your browser.
language: Language
remote_url: Application API server
metaconfiguration: Default metaconfiguration URI
metaconfiguration: Default meta configuration URI
search:
label: Insert IRI, name, code...
change_configuration_and_stylesheet: Change configuration and stylesheet
Expand Down Expand Up @@ -112,20 +112,6 @@ add_node_dialog:
input: IRIs of the resources
error: Error occured while fetching the resources. Nodes listed in the textarea werent loaded. See developers console for more detailed information. Try to check the corectness of IRI.

# Dialog to change configuration and stylesheet
configuration_and_stylesheet_dialog:
title: Configuration and stylesheet
predefined: Predefined configurations and stylesheets
config: Configuration IRI
stylesheet: Stylesheet IRI
destroy_warning: By changing the configuration IRI the whole graph will be destroyed. You will be asked to save changes.
cancel: Cancel
load: Load # Fresh start
update: Update # Changing configuration
update_stylesheet: Update stylesheet # Updating only stylesheet
update_general: Update # Text when button is disabled
load_from_file: Load existing graph from file

# Dialog to filter nodes
filter_dialog:
title: Filter nodes
Expand Down Expand Up @@ -233,20 +219,23 @@ graph:

configuration_selection:
meta_configuration:
title: Configuration selection
unnamed: Unnamed metaconfiguration
title: Select a configuration
unnamed: Unnamed meta configuration
loading: Loading meta configuration info...
custom_panel:
title: Configuration selection
title: Custom configuration
button: Set by hand
meta_configuration:
title: Meta configuration
input: Metaconfiguration IRI
tab: Meta configuration by IRI
input: Meta configuration IRI
configuration:
title: Configuration
tab: Configuration by IRI
input: Configuration IRI
custom_configuration:
title: Custom configuration
tab: Custom configuration
configuration: Configuration IRI
stylesheet: Stylesheet IRI
pattern: IRI pattern
Expand All @@ -260,10 +249,19 @@ configuration_selection:
node_selection:
unnamed: Unnamed configuration
choose_message: Choose a starting node
choose_info: You can type in IRI identifier of the node or try to search it if searching is supported by the configuration.
predefined: Predefined nodes
loading: Loading node...
open_from_file: Open from file
open_from_file: Open from file / URL
load: Load
close: Close
back: Back
go_to_graph: Go to graph

load_dialog:
error: Failed to load graph from URL. Please check the correctness.
load_from_url: Load from URL
url: URL
load: Load
load_from_file: Load from file
cancel: Cancel
13 changes: 7 additions & 6 deletions src/component/Application.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
></settings>
<load-dialog
ref="loadDialog"
:load-url-function="loadFromUrl"
@selected="loadFromFile($event)"
/>
<layout-dialog
Expand Down Expand Up @@ -327,11 +328,12 @@
private async loadStylesheet() {
// For now, only the first stylesheet is supported
if (this.configuration?.stylesheet?.length > 0) {
try {
this.visualStyleSheet = await this.graph.server.getStylesheet(this.configuration.stylesheet[0]);
} catch (e) {
console.warn("Error occurred while fetching the stylesheet.\nCheck the correctness of the IRI, configuration IRI, URL of remote server or the internet connection.\nStyles will be emptied.");
let stylesheet = await this.graph.server.getStylesheet(this.configuration.stylesheet[0]);
if (stylesheet === false) {
console.error("Error occurred while fetching the stylesheet.\nCheck the correctness of IRI, URL of remote server or the internet connection.\nStyles will be emptied.");
this.visualStyleSheet.styles = [];
} else {
this.visualStyleSheet = stylesheet;
}
} else {
this.visualStyleSheet.styles = [];
Expand Down Expand Up @@ -418,8 +420,6 @@
console.error("Creating a new graph, but areaManipulator still not exists.");
}
if (loadStylesheet) this.loadStylesheet();
this.graph = new Graph();
this.graph.server = this.server;
this.graph.configuration = this.configuration;
Expand All @@ -431,6 +431,7 @@
this.manipulator = new GraphManipulator(this.graph, this.areaManipulator, this.layouts);
if (loadStylesheet) this.loadStylesheet();
this.updateGraphSearcher();
}
Expand Down
16 changes: 10 additions & 6 deletions src/component/ApplicationLoadStoreMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,21 @@ import ConfigurationManager from "../configurations/ConfigurationManager";
this.restoreFromObject(parsed);
}

protected async loadFromUrl(url: string) {
protected async loadFromUrl(url: string): Promise<boolean> {
let data: Response = null;
let object: Object = null;
try {
data = await fetch(url);
object = await data.json();
} catch (e) {
console.warn("Unable to load save file from URL", url, "Error", data.status, data.statusText);
return;
data = null;
}
if (data && data.ok) {
let object = await data.json();
this.restoreFromObject(object);
return true;
} else {
console.warn("Unable to load save file from URL", url);
return false;
}
this.restoreFromObject(object);
}

protected async saveToFile() {
Expand Down
Loading

0 comments on commit a2ea91f

Please sign in to comment.