From 22e7a4afc0e52fdb09e7b393c182b8fa07bc1582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20R=C3=BCckin?= Date: Thu, 12 Apr 2018 14:19:58 +0200 Subject: [PATCH 1/5] Toggle form for adding new datasets on login --- pika/src/Components/Login.js | 92 +++++++++++++++++++++++++----- pika/src/actions/AccountActions.js | 4 +- pika/src/stores/AccountStore.js | 6 +- 3 files changed, 83 insertions(+), 19 deletions(-) diff --git a/pika/src/Components/Login.js b/pika/src/Components/Login.js index 1cdb4a8..02a930e 100644 --- a/pika/src/Components/Login.js +++ b/pika/src/Components/Login.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; -import { Button, Icon, Dropdown, Form, Input } from 'semantic-ui-react'; +import { Button, Icon, Dropdown, Form, Input, Transition } from 'semantic-ui-react'; import AccountStore from '../stores/AccountStore'; import AccountActions from '../actions/AccountActions'; @@ -17,13 +17,19 @@ class Login extends Component { this.handleDatasetChange = this.handleDatasetChange.bind(this); this.handleUsernameChange = this.handleUsernameChange.bind(this); this.renderNaming = this.renderNaming.bind(this); + this.toggleDatasetField = this.toggleDatasetField.bind(this); + this.saveDataset = this.saveDataset.bind(this); this.state = { is_loading: true, available_datasets: [], user_name: "", similarity_type: "deprecated", - dataset: "" + dataset: {}, + show_dataset_form: false, + dataset_btn_icon: 'add', + dataset_btn_text: 'Add Dataset', + submit_btn_margin: '20px' }; } @@ -58,13 +64,42 @@ class Login extends Component { AccountActions.updateUsername(data.value); } - submitNaming() { - AccountActions.login(this.state.user_name, this.state.dataset); + toggleDatasetField(e){ + e.preventDefault(); + e.stopPropagation(); + + if(!this.state.show_dataset_form){ + this.setState({ + show_dataset_form: true, + dataset_btn_icon: 'remove', + dataset_btn_text: 'Remove Dataset', + submit_btn_margin: '0px' + }); + } + else{ + this.setState({ + show_dataset_form: false, + dataset_btn_icon: 'add', + dataset_btn_text: 'Add Dataset', + submit_btn_margin: '20px' + }); + } + } + + saveDataset(){ + alert('Dataset saved!'); + } + + submitNaming(e) { + e.preventDefault(); + e.stopPropagation(); + + AccountActions.login(this.state.user_name, this.state.dataset.name); } renderNaming() { let available_datasets = this.state.available_datasets.map((dataset, index) => { - return { key: index, value: dataset.name, text: dataset.name }; + return { key: index, value: index, text: dataset.name }; }); return ( @@ -73,15 +108,44 @@ class Login extends Component { this.handleUsernameChange(data)} /> - - - this.handleDatasetChange(data)} /> - - - +
+
+ + + this.handleDatasetChange(data)} /> + +
+
+ this.toggleDatasetField(e)} icon primary={false} style={{marginTop: 23 + 'px'}}> + + {this.state.dataset_btn_text} + +
+
+ + +
+
+ + + + + +
+
+ this.saveDataset(e)} floated='right' icon primary={true} style={{marginTop: 23 + 'px'}}> + + Save + +
+
+
+
+ + this.submitNaming(e)} icon primary={true}> + + Sign In + ); diff --git a/pika/src/actions/AccountActions.js b/pika/src/actions/AccountActions.js index f3fb6a5..c2a5b14 100644 --- a/pika/src/actions/AccountActions.js +++ b/pika/src/actions/AccountActions.js @@ -32,10 +32,10 @@ const Actions = { MetaPathAPI.getAvailableDatasets(); }, - selectDataset(dataset){ + selectDataset(dataset_id){ AccountDispatcher.dispatch({ type: AccountActionTypes.DATASET_SELECTION, - payload: {dataset: dataset} + payload: {dataset_id: dataset_id} }) }, diff --git a/pika/src/stores/AccountStore.js b/pika/src/stores/AccountStore.js index 2de3ff5..194f49f 100644 --- a/pika/src/stores/AccountStore.js +++ b/pika/src/stores/AccountStore.js @@ -44,8 +44,8 @@ class AccountStore extends EventEmitter { this.emit("change"); } - setDataset(dataset){ - this.dataset = dataset; + setDataset(dataset_id){ + this.dataset = this.availableDatasets[dataset_id]; this.emit("change"); } @@ -73,7 +73,7 @@ class AccountStore extends EventEmitter { return this.loggedIn; }; case AccountActionTypes.DATASET_SELECTION:{ - this.setDataset(action.payload.dataset); + this.setDataset(action.payload.dataset_id); return this.dataset; }; case AccountActionTypes.LOAD_DATASETS_RESPONSE:{ From ae927a373aa7a0d0f48df2091f48126624140603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20R=C3=BCckin?= Date: Thu, 12 Apr 2018 14:57:09 +0200 Subject: [PATCH 2/5] Add and update new dataset properties to/at store --- pika/src/Components/Login.js | 39 +++++++++++++++++++++--- pika/src/actions/AccountActionTypes.js | 5 ++- pika/src/actions/AccountActions.js | 21 +++++++++++++ pika/src/stores/AccountStore.js | 42 ++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 6 deletions(-) diff --git a/pika/src/Components/Login.js b/pika/src/Components/Login.js index 02a930e..4903d88 100644 --- a/pika/src/Components/Login.js +++ b/pika/src/Components/Login.js @@ -19,6 +19,10 @@ class Login extends Component { this.renderNaming = this.renderNaming.bind(this); this.toggleDatasetField = this.toggleDatasetField.bind(this); this.saveDataset = this.saveDataset.bind(this); + this.changeNewDatasetUrl = this.changeNewDatasetUrl.bind(this); + this.changeNewDatasetUsername = this.changeNewDatasetUsername.bind(this); + this.changeNewDatasetPassword = this.changeNewDatasetPassword.bind(this); + this.getNewDatasetProperties = this.getNewDatasetProperties.bind(this); this.state = { is_loading: true, @@ -29,7 +33,10 @@ class Login extends Component { show_dataset_form: false, dataset_btn_icon: 'add', dataset_btn_text: 'Add Dataset', - submit_btn_margin: '20px' + submit_btn_margin: '20px', + new_dataset_url: '', + new_dataset_username: '', + new_dataset_password: '' }; } @@ -37,11 +44,21 @@ class Login extends Component { MetaPathAPI.getAvailableDatasets(); AccountStore.on("change", this.getDatasets); AccountStore.on("change", this.getUserName); + AccountStore.on("change", this.getNewDatasetProperties); } componentWillUnmount(){ AccountStore.removeListener("change", this.getDatasets); AccountStore.removeListener("change", this.getUserName); + AccountStore.removeListener("change", this.getNewDatasetProperties); + } + + getNewDatasetProperties(){ + this.setState({ + new_dataset_url: AccountStore.getNewDatasetUrl(), + new_dataset_username: AccountStore.getNewDatasetUsername(), + new_dataset_password: AccountStore.getNewDatasetPassword() + }); } getDatasets(){ @@ -64,6 +81,18 @@ class Login extends Component { AccountActions.updateUsername(data.value); } + changeNewDatasetUrl(data){ + AccountActions.updateNewDatasetUrl(data.value); + } + + changeNewDatasetUsername(data){ + AccountActions.updateNewDatasetUsername(data.value); + } + + changeNewDatasetPassword(data){ + AccountActions.updateNewDatasetPassword(data.value); + } + toggleDatasetField(e){ e.preventDefault(); e.stopPropagation(); @@ -101,7 +130,7 @@ class Login extends Component { let available_datasets = this.state.available_datasets.map((dataset, index) => { return { key: index, value: index, text: dataset.name }; }); - + //alert("URL: " + this.state.new_dataset_url + "\n" + "User: " + this.state.new_dataset_username + "\n" + "Password: " + this.state.new_dataset_password); return (
@@ -127,9 +156,9 @@ class Login extends Component {
- - - + this.changeNewDatasetUrl(data)} fluid label='URL' placeholder='URL to Database' value={this.state.new_dataset_url} /> + this.changeNewDatasetUsername(data)} fluid label='Username' placeholder='Username of Database' value={this.state.new_dataset_username} /> + this.changeNewDatasetPassword(data)} fluid label='Password' placeholder='Password of Database' type='password' value={this.state.new_dataset_password} />
diff --git a/pika/src/actions/AccountActionTypes.js b/pika/src/actions/AccountActionTypes.js index ab604c3..dafa430 100644 --- a/pika/src/actions/AccountActionTypes.js +++ b/pika/src/actions/AccountActionTypes.js @@ -7,7 +7,10 @@ const ActionTypes = { LOGIN: 'LOGIN', LOGIN_RESPONSE: 'LOGIN_RESPONSE', LOGOUT: 'LOGOUT', - LOGOUT_RESPONSE: 'LOGOUT_RESPONSE' + LOGOUT_RESPONSE: 'LOGOUT_RESPONSE', + UPDATE_NEW_DATASET_URL: 'UPDATE_NEW_DATASET_URL', + UPDATE_NEW_DATASET_USERNAME: 'UPDATE_NEW_DATASET_USERNAME', + UPDATE_NEW_DATASET_PASSWORD: 'UPDATE_NEW_DATASET_PASSWORD' } export default ActionTypes; diff --git a/pika/src/actions/AccountActions.js b/pika/src/actions/AccountActions.js index c2a5b14..9ba08b6 100644 --- a/pika/src/actions/AccountActions.js +++ b/pika/src/actions/AccountActions.js @@ -56,6 +56,27 @@ const Actions = { type: AccountActionTypes.LOAD_DATASETS_RESPONSE, payload: {datasets: datasets} }); + }, + + updateNewDatasetUrl(url){ + AccountDispatcher.dispatch({ + type: AccountActionTypes.UPDATE_NEW_DATASET_URL, + payload: {url: url} + }); + }, + + updateNewDatasetUsername(username){ + AccountDispatcher.dispatch({ + type: AccountActionTypes.UPDATE_NEW_DATASET_USERNAME, + payload: {username: username} + }); + }, + + updateNewDatasetPassword(password){ + AccountDispatcher.dispatch({ + type: AccountActionTypes.UPDATE_NEW_DATASET_PASSWORD, + payload: {password: password} + }); } }; diff --git a/pika/src/stores/AccountStore.js b/pika/src/stores/AccountStore.js index 194f49f..3a8eb6f 100644 --- a/pika/src/stores/AccountStore.js +++ b/pika/src/stores/AccountStore.js @@ -12,12 +12,42 @@ class AccountStore extends EventEmitter { this.dataset = ''; this.availableDatasets = []; this.isLoading = true; + this.newDatasetUrl = ''; + this.newDatasetUsername = ''; + this.newDatasetPassword = ''; } loading(){ return this.isLoading; } + getNewDatasetUrl(){ + return this.newDatasetUrl; + } + + getNewDatasetUsername(){ + return this.newDatasetUsername; + } + + getNewDatasetPassword(){ + return this.newDatasetPassword; + } + + setNewDatasetUrl(dataset_url){ + this.newDatasetUrl = dataset_url; + this.emit("change"); + } + + setNewDatasetUsername(username){ + this.newDatasetUsername = username; + this.emit("change"); + } + + setNewDatasetPassword(password){ + this.newDatasetPassword = password; + this.emit("change"); + } + getAvailableDatasets(){ return this.availableDatasets; } @@ -84,6 +114,18 @@ class AccountStore extends EventEmitter { this.setUsername(action.payload.userName); return this.userName; }; + case AccountActionTypes.UPDATE_NEW_DATASET_URL:{ + this.setNewDatasetUrl(action.payload.url); + return this.newDatasetUrl; + }; + case AccountActionTypes.UPDATE_NEW_DATASET_USERNAME:{ + this.setNewDatasetUsername(action.payload.username); + return this.newDatasetUrl; + }; + case AccountActionTypes.UPDATE_NEW_DATASET_PASSWORD:{ + this.setNewDatasetPassword(action.payload.password); + return this.newDatasetUrl; + }; default:{ return this.state; }; From ce5d124e15617d6fb4b967b9ae3eeb0de8854939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20R=C3=BCckin?= Date: Thu, 12 Apr 2018 15:10:45 +0200 Subject: [PATCH 3/5] Save new dataset properties at backend --- pika/src/Components/Login.js | 9 ++++++--- pika/src/actions/AccountActionTypes.js | 3 ++- pika/src/actions/AccountActions.js | 7 +++++++ pika/src/utils/MetaPathAPI.js | 24 ++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/pika/src/Components/Login.js b/pika/src/Components/Login.js index 4903d88..06723ba 100644 --- a/pika/src/Components/Login.js +++ b/pika/src/Components/Login.js @@ -115,8 +115,11 @@ class Login extends Component { } } - saveDataset(){ - alert('Dataset saved!'); + saveDataset(e){ + e.preventDefault(); + e.stopPropagation(); + + AccountActions.saveNewDataset(this.state.new_dataset_url, this.state.new_dataset_username, this.state.new_dataset_password); } submitNaming(e) { @@ -130,7 +133,7 @@ class Login extends Component { let available_datasets = this.state.available_datasets.map((dataset, index) => { return { key: index, value: index, text: dataset.name }; }); - //alert("URL: " + this.state.new_dataset_url + "\n" + "User: " + this.state.new_dataset_username + "\n" + "Password: " + this.state.new_dataset_password); + return ( diff --git a/pika/src/actions/AccountActionTypes.js b/pika/src/actions/AccountActionTypes.js index dafa430..0f33ab8 100644 --- a/pika/src/actions/AccountActionTypes.js +++ b/pika/src/actions/AccountActionTypes.js @@ -10,7 +10,8 @@ const ActionTypes = { LOGOUT_RESPONSE: 'LOGOUT_RESPONSE', UPDATE_NEW_DATASET_URL: 'UPDATE_NEW_DATASET_URL', UPDATE_NEW_DATASET_USERNAME: 'UPDATE_NEW_DATASET_USERNAME', - UPDATE_NEW_DATASET_PASSWORD: 'UPDATE_NEW_DATASET_PASSWORD' + UPDATE_NEW_DATASET_PASSWORD: 'UPDATE_NEW_DATASET_PASSWORD', + SAVE_NEW_DATASET: 'SAVE_NEW_DATASET' } export default ActionTypes; diff --git a/pika/src/actions/AccountActions.js b/pika/src/actions/AccountActions.js index 9ba08b6..d26d8f4 100644 --- a/pika/src/actions/AccountActions.js +++ b/pika/src/actions/AccountActions.js @@ -77,6 +77,13 @@ const Actions = { type: AccountActionTypes.UPDATE_NEW_DATASET_PASSWORD, payload: {password: password} }); + }, + + saveNewDataset(url, username, password){ + AccountDispatcher.dispatch({ + type: AccountActionTypes.SAVE_NEW_DATASET + }); + MetaPathAPI.saveNewDataset(url, username, password); } }; diff --git a/pika/src/utils/MetaPathAPI.js b/pika/src/utils/MetaPathAPI.js index 8e1e6a5..23d2dd3 100644 --- a/pika/src/utils/MetaPathAPI.js +++ b/pika/src/utils/MetaPathAPI.js @@ -121,6 +121,30 @@ const Actions = { }).catch((error) => { console.error(error); }); + }, + saveNewDataset(url, username, password){ + fetch(process.env.REACT_APP_API_HOST + 'save-new-dataset', { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: { + url: url, + username: username, + password: password + }, + credentials: 'include' + }).then((response) => { return response.json(); }).then((json) => { + if (!(json.status === 200)){ + alert('Could not save new dataset'); + } + else { + AccountActions.loadDatasets(); + } + }).catch((error) => { + console.error(error); + }); } } From ff058c1f72178aefa105fb0931710c6a7d917907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20R=C3=BCckin?= Date: Thu, 12 Apr 2018 16:20:49 +0200 Subject: [PATCH 4/5] Toggle 'new dataset form' when form is submitted --- pika/src/Components/Login.js | 15 +++++++++------ pika/src/utils/MetaPathAPI.js | 6 ++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pika/src/Components/Login.js b/pika/src/Components/Login.js index 06723ba..2c63934 100644 --- a/pika/src/Components/Login.js +++ b/pika/src/Components/Login.js @@ -93,10 +93,7 @@ class Login extends Component { AccountActions.updateNewDatasetPassword(data.value); } - toggleDatasetField(e){ - e.preventDefault(); - e.stopPropagation(); - + toggleDatasetField(){ if(!this.state.show_dataset_form){ this.setState({ show_dataset_form: true, @@ -119,7 +116,13 @@ class Login extends Component { e.preventDefault(); e.stopPropagation(); - AccountActions.saveNewDataset(this.state.new_dataset_url, this.state.new_dataset_username, this.state.new_dataset_password); + var url = this.state.new_dataset_url; + var username = this.state.new_dataset_username; + var password = this.state.new_dataset_password; + + this.toggleDatasetField(); + + AccountActions.saveNewDataset(url, username, password); } submitNaming(e) { @@ -148,7 +151,7 @@ class Login extends Component {
- this.toggleDatasetField(e)} icon primary={false} style={{marginTop: 23 + 'px'}}> + this.toggleDatasetField()} icon primary={false} style={{marginTop: 23 + 'px'}}> {this.state.dataset_btn_text} diff --git a/pika/src/utils/MetaPathAPI.js b/pika/src/utils/MetaPathAPI.js index 23d2dd3..3d454b7 100644 --- a/pika/src/utils/MetaPathAPI.js +++ b/pika/src/utils/MetaPathAPI.js @@ -123,23 +123,25 @@ const Actions = { }); }, saveNewDataset(url, username, password){ + alert("URL: " + url + "\nUsername: " + username + "\nPassword: " + password); fetch(process.env.REACT_APP_API_HOST + 'save-new-dataset', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, - body: { + body: JSON.stringify({ url: url, username: username, password: password - }, + }), credentials: 'include' }).then((response) => { return response.json(); }).then((json) => { if (!(json.status === 200)){ alert('Could not save new dataset'); } else { + alert('Saved dataset'); AccountActions.loadDatasets(); } }).catch((error) => { From 59d1e3124c4429a8e823979e6c6abf5c39bbc5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20R=C3=BCckin?= Date: Thu, 12 Apr 2018 16:41:11 +0200 Subject: [PATCH 5/5] Add dataset name --- pika/src/Components/Login.js | 11 ++++++++++- pika/src/actions/AccountActionTypes.js | 1 + pika/src/actions/AccountActions.js | 11 +++++++++-- pika/src/stores/AccountStore.js | 18 ++++++++++++++++-- pika/src/utils/MetaPathAPI.js | 5 +++-- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/pika/src/Components/Login.js b/pika/src/Components/Login.js index 2c63934..d7967c6 100644 --- a/pika/src/Components/Login.js +++ b/pika/src/Components/Login.js @@ -20,6 +20,7 @@ class Login extends Component { this.toggleDatasetField = this.toggleDatasetField.bind(this); this.saveDataset = this.saveDataset.bind(this); this.changeNewDatasetUrl = this.changeNewDatasetUrl.bind(this); + this.changeNewDatasetName = this.changeNewDatasetName.bind(this); this.changeNewDatasetUsername = this.changeNewDatasetUsername.bind(this); this.changeNewDatasetPassword = this.changeNewDatasetPassword.bind(this); this.getNewDatasetProperties = this.getNewDatasetProperties.bind(this); @@ -35,6 +36,7 @@ class Login extends Component { dataset_btn_text: 'Add Dataset', submit_btn_margin: '20px', new_dataset_url: '', + new_dataset_name: '', new_dataset_username: '', new_dataset_password: '' }; @@ -56,6 +58,7 @@ class Login extends Component { getNewDatasetProperties(){ this.setState({ new_dataset_url: AccountStore.getNewDatasetUrl(), + new_dataset_name: AccountStore.getNewDatasetName(), new_dataset_username: AccountStore.getNewDatasetUsername(), new_dataset_password: AccountStore.getNewDatasetPassword() }); @@ -85,6 +88,10 @@ class Login extends Component { AccountActions.updateNewDatasetUrl(data.value); } + changeNewDatasetName(data){ + AccountActions.updateNewDatasetName(data.value); + } + changeNewDatasetUsername(data){ AccountActions.updateNewDatasetUsername(data.value); } @@ -117,12 +124,13 @@ class Login extends Component { e.stopPropagation(); var url = this.state.new_dataset_url; + var name = this.state.new_dataset_name; var username = this.state.new_dataset_username; var password = this.state.new_dataset_password; this.toggleDatasetField(); - AccountActions.saveNewDataset(url, username, password); + AccountActions.saveNewDataset(url, name, username, password); } submitNaming(e) { @@ -163,6 +171,7 @@ class Login extends Component {
this.changeNewDatasetUrl(data)} fluid label='URL' placeholder='URL to Database' value={this.state.new_dataset_url} /> + this.changeNewDatasetName(data)} fluid label='Dataset-Name' placeholder='Name of Dataset' value={this.state.new_dataset_name} /> this.changeNewDatasetUsername(data)} fluid label='Username' placeholder='Username of Database' value={this.state.new_dataset_username} /> this.changeNewDatasetPassword(data)} fluid label='Password' placeholder='Password of Database' type='password' value={this.state.new_dataset_password} /> diff --git a/pika/src/actions/AccountActionTypes.js b/pika/src/actions/AccountActionTypes.js index 0f33ab8..30b4051 100644 --- a/pika/src/actions/AccountActionTypes.js +++ b/pika/src/actions/AccountActionTypes.js @@ -9,6 +9,7 @@ const ActionTypes = { LOGOUT: 'LOGOUT', LOGOUT_RESPONSE: 'LOGOUT_RESPONSE', UPDATE_NEW_DATASET_URL: 'UPDATE_NEW_DATASET_URL', + UPDATE_NEW_DATASET_NAME: 'UPDATE_NEW_DATASET_NAME', UPDATE_NEW_DATASET_USERNAME: 'UPDATE_NEW_DATASET_USERNAME', UPDATE_NEW_DATASET_PASSWORD: 'UPDATE_NEW_DATASET_PASSWORD', SAVE_NEW_DATASET: 'SAVE_NEW_DATASET' diff --git a/pika/src/actions/AccountActions.js b/pika/src/actions/AccountActions.js index d26d8f4..e6b59db 100644 --- a/pika/src/actions/AccountActions.js +++ b/pika/src/actions/AccountActions.js @@ -65,6 +65,13 @@ const Actions = { }); }, + updateNewDatasetName(name){ + AccountDispatcher.dispatch({ + type: AccountActionTypes.UPDATE_NEW_DATASET_NAME, + payload: {name: name} + }); + }, + updateNewDatasetUsername(username){ AccountDispatcher.dispatch({ type: AccountActionTypes.UPDATE_NEW_DATASET_USERNAME, @@ -79,11 +86,11 @@ const Actions = { }); }, - saveNewDataset(url, username, password){ + saveNewDataset(url, name, username, password){ AccountDispatcher.dispatch({ type: AccountActionTypes.SAVE_NEW_DATASET }); - MetaPathAPI.saveNewDataset(url, username, password); + MetaPathAPI.saveNewDataset(url, name, username, password); } }; diff --git a/pika/src/stores/AccountStore.js b/pika/src/stores/AccountStore.js index 3a8eb6f..9508394 100644 --- a/pika/src/stores/AccountStore.js +++ b/pika/src/stores/AccountStore.js @@ -13,6 +13,7 @@ class AccountStore extends EventEmitter { this.availableDatasets = []; this.isLoading = true; this.newDatasetUrl = ''; + this.newDatasetName = ''; this.newDatasetUsername = ''; this.newDatasetPassword = ''; } @@ -25,6 +26,10 @@ class AccountStore extends EventEmitter { return this.newDatasetUrl; } + getNewDatasetName(){ + return this.newDatasetName; + } + getNewDatasetUsername(){ return this.newDatasetUsername; } @@ -33,8 +38,13 @@ class AccountStore extends EventEmitter { return this.newDatasetPassword; } - setNewDatasetUrl(dataset_url){ - this.newDatasetUrl = dataset_url; + setNewDatasetUrl(url){ + this.newDatasetUrl = url; + this.emit("change"); + } + + setNewDatasetName(name){ + this.newDatasetName = name; this.emit("change"); } @@ -118,6 +128,10 @@ class AccountStore extends EventEmitter { this.setNewDatasetUrl(action.payload.url); return this.newDatasetUrl; }; + case AccountActionTypes.UPDATE_NEW_DATASET_NAME:{ + this.setNewDatasetName(action.payload.name); + return this.newDatasetName; + }; case AccountActionTypes.UPDATE_NEW_DATASET_USERNAME:{ this.setNewDatasetUsername(action.payload.username); return this.newDatasetUrl; diff --git a/pika/src/utils/MetaPathAPI.js b/pika/src/utils/MetaPathAPI.js index 3d454b7..e8ff6a6 100644 --- a/pika/src/utils/MetaPathAPI.js +++ b/pika/src/utils/MetaPathAPI.js @@ -122,8 +122,8 @@ const Actions = { console.error(error); }); }, - saveNewDataset(url, username, password){ - alert("URL: " + url + "\nUsername: " + username + "\nPassword: " + password); + saveNewDataset(url, name, username, password){ + alert("URL: " + url + "\nName: " + name + "\nUsername: " + username + "\nPassword: " + password); fetch(process.env.REACT_APP_API_HOST + 'save-new-dataset', { method: 'POST', headers: { @@ -132,6 +132,7 @@ const Actions = { }, body: JSON.stringify({ url: url, + name: name, username: username, password: password }),