Skip to content

Commit

Permalink
temp bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GanadiniAkshay committed Jan 23, 2018
1 parent 434b41a commit 5b913eb
Show file tree
Hide file tree
Showing 107 changed files with 70 additions and 50 deletions.
4 changes: 2 additions & 2 deletions client/actions/intentActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function deleteIntent(index){

export function getIntents(payload){
return dispatch => {
return axios.get(config.url + '/intents/'+ payload.bot_guid).then(res => {
return axios.get(config.url + '/intents/'+ payload.bot_guid + '?base=' + payload.base).then(res => {
const intents = res.data.intents;
dispatch(setActiveIntents(intents));
})
Expand All @@ -40,7 +40,7 @@ export function getIntents(payload){

export function addIntent(payload){
return dispatch => {
return axios.post(config.url + '/intents/' + payload.bot_guid, payload).then(res => {
return axios.post(config.url + '/intents/' + payload.bot_guid+ '?base=' + payload.base, payload).then(res => {
const success = res.data;
dispatch(addNewIntent(payload.name));
})
Expand Down
38 changes: 32 additions & 6 deletions client/components/intents/FolderTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class FolderTable extends React.Component{
id:'',
bot_guid:'',
name:'',
base:'/',
json_button: 'Import JSON',
activeIntents:[],
int_button: 'Add',
Expand All @@ -38,6 +39,7 @@ class FolderTable extends React.Component{
this.addKeyFolder = this.addKeyFolder.bind(this);
this.openIntent = this.openIntent.bind(this);
this.deleteIntent = this.deleteIntent.bind(this);
this.reloadIntents = this.reloadIntents.bind(this);
}

componentDidMount(){
Expand All @@ -48,14 +50,25 @@ class FolderTable extends React.Component{
var url_path = window.location.pathname.split('/');
var bot_name = decodeURI(url_path[2]);

var base = '/';

var items = url_path.slice(4);

if (items.length == 0){
this.setState({"base":base});
}else{
base = '/'+items.join('/');
this.setState({"base":base});
}

var activeBot = current_bots.find(function(o){ return o.name == bot_name});

this.setState({name:activeBot.name,id:activeBot.id,bot_guid:activeBot.bot_guid});

if (!activeBot){
activeBot = current_bots[0];
browserHistory.push('/bots/'+activeBot.name+'/intents');
}else{
this.setState({name:activeBot.name,id:activeBot.id,bot_guid:activeBot.bot_guid});

this.props.getIntents(this.state).then(
() => {
this.setState({loader:false,activeIntents:this.props.activeIntents.activeIntents})
Expand All @@ -71,7 +84,15 @@ class FolderTable extends React.Component{
});
}


reloadIntents(){
console.log("Reloading with " + this.props.base);
var payload = {"bot_guid":this.state.bot_guid,"base":this.props.base}
this.props.getIntents(this.state).then(
() => {
this.setState({loader:false,activeIntents:this.props.activeIntents.activeIntents})
}
)
}


onChange(e){
Expand All @@ -90,13 +111,16 @@ class FolderTable extends React.Component{
payload['responses'] = [];
payload['has_entities'] = true;
payload['is_folder'] = false;
payload['base'] = this.state.base;

this.props.addIntent(payload).then(
() => {
this.setState({int_button:"Add", activeIntents:this.props.activeIntents.activeIntents});
browserHistory.push('/bots/'+ this.state.name +'/intents/'+ intent_name);
browserHistory.push('/bots/'+ this.state.name +'/intents'+ this.state.base +'/' + intent_name);
}
)

$('#intent_form').modal('close');
}

addFolder(e){
Expand All @@ -111,13 +135,15 @@ class FolderTable extends React.Component{
payload['responses'] = [];
payload['has_entities'] = true;
payload['is_folder'] = true
payload['base'] = this.state.base;

this.props.addIntent(payload).then(
() => {
this.setState({int_button:"Add", activeIntents:this.props.activeIntents.activeIntents});
browserHistory.push('/bots/'+ this.state.name +'/intents/'+ intent_name);
browserHistory.push('/bots/'+ this.state.name +'/intents'+ this.state.base +'/' + intent_name);
}
)
$('#folder_form').modal('close');
}

addKeyFolder(e){
Expand Down Expand Up @@ -256,7 +282,7 @@ class FolderTable extends React.Component{
<div className="card-content" style={{"margin":0,"padding":0,"border":0}}>
<br/>
<span className="card-title">
<h5 style={{"paddingLeft":"25px"}}>Intents</h5>
<h5 style={{"paddingLeft":"25px"}}>{this.state.base}</h5>
</span>
<table className="bordered highlight centered">
<thead>
Expand Down
13 changes: 3 additions & 10 deletions client/components/intents/IntentEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class IntentEditPage extends React.Component{
intent_name:'',
button:'save',
utterances:'',
is_folder:true,
is_folder:null,
disabled:true,
loader:true,
errors:{}
Expand All @@ -37,6 +37,7 @@ class IntentEditPage extends React.Component{
}

componentDidMount(){
console.log("IntentEditPage");
this.props.getBots(this.state).then(
() => {
var current_bots = this.props.bots.bots;
Expand Down Expand Up @@ -77,20 +78,12 @@ class IntentEditPage extends React.Component{
}
}

// <main>
// <IntentTable />
// <ResponsesTable/>
// </main>

render(){
const { errors } = this.state;
console.log(this.state.is_folder);
return (
<div className="full">
<Navbar active="settings_none"/>
<main>
{this.state.is_folder?(<FolderTable/>):(<IntentTable/>)}
</main>
{this.state.is_folder == null?(<p></p>):this.state.is_folder?(<main><FolderTable/></main>):(<main><IntentTable bot_name={this.props.params.botname} intent_name={this.state.intent_name}/><ResponsesTable/></main>)}
</div>
)
}
Expand Down
54 changes: 27 additions & 27 deletions client/components/intents/IntentTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,36 @@ class IntentTable extends React.Component{

componentDidMount(){
$('ul.tabs').tabs();
// this.props.getBots(this.state).then(
// () => {
// var current_bots = this.props.bots.bots;
this.props.getBots(this.state).then(
() => {
var current_bots = this.props.bots.bots;

// var url_path = window.location.pathname.split('/');
// var bot_name = decodeURI(url_path[2]);
// var intent_name = decodeURI(url_path[4]);
var url_path = window.location.pathname.split('/');
var bot_name = this.props.bot_name;
var intent_name = this.props.intent_name;

// var activeBot = current_bots.find(function(o){ return o.name == bot_name});
var activeBot = current_bots.find(function(o){ return o.name == bot_name});

// if (!activeBot){
// activeBot = current_bots[0];
// browserHistory.push('/bots/'+activeBot.name+'/intents');
// }else{
// this.setState({bot_guid:activeBot.bot_guid, intent_name:intent_name, old_intent_name:intent_name});

// // this.props.getUtterances(this.state).then(
// // () => {
// // this.setState({utterances:this.props.utterances.utterances});
// // }
// // )

// // this.props.getPatterns(this.state).then(
// // () => {
// // this.setState({patterns:this.props.patterns.patterns});
// // }
// // )
// }
// }
// );
if (!activeBot){
activeBot = current_bots[0];
browserHistory.push('/bots/'+activeBot.name+'/intents');
}else{
this.setState({bot_guid:activeBot.bot_guid, intent_name:intent_name, old_intent_name:intent_name});

this.props.getUtterances(this.state).then(
() => {
this.setState({utterances:this.props.utterances.utterances});
}
)

// this.props.getPatterns(this.state).then(
// () => {
// this.setState({patterns:this.props.patterns.patterns});
// }
// )
}
}
);

$('.tooltipped').tooltip({delay: 50});
$('#intent_form').modal('close');
Expand Down
1 change: 1 addition & 0 deletions client/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default (
<Route path="bots/:botname/learn" component={requireBotAuth(LearningDemoPage)} />
<Route path="bots/:botname/persona" component={requireBotAuth(PersonaPage)} />
<Route path="bots/:botname/intents/:intentname/*" component={requireBotAuth(IntentEditPage)} />
<Route path="bots/:botname/intents/:intentname/*/*" component={requireBotAuth(IntentEditPage)} />
<Route path="*" component={NotFound}/>
</Route>
)
2 changes: 1 addition & 1 deletion releases/release.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version" : "0.10.8"
"version" : "0.10.12"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions server/dist/js/bundle.js

Large diffs are not rendered by default.

0 comments on commit 5b913eb

Please sign in to comment.