popup info ; token update
This commit is contained in:
@@ -95,8 +95,6 @@ var uploadSkill = function(skill){
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
updateSkill: function(skill, db){
|
updateSkill: function(skill, db){
|
||||||
console.log("update skill function");
|
|
||||||
|
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve,reject)=>{
|
||||||
if (new Date() / 1000 > config.TOKEN_EXPIRES_IN){
|
if (new Date() / 1000 > config.TOKEN_EXPIRES_IN){
|
||||||
refreshToken(db).then(()=>{
|
refreshToken(db).then(()=>{
|
||||||
|
|||||||
@@ -10,12 +10,18 @@ module.exports = {
|
|||||||
|
|
||||||
loadTokens : function(){
|
loadTokens : function(){
|
||||||
db.collection('token_list').findOne().then(tokens=>{
|
db.collection('token_list').findOne().then(tokens=>{
|
||||||
config.TOKEN = tokens.access_token;
|
if (tokens !== null){
|
||||||
config.REFRESH_TOKEN = tokens.refresh_token;
|
config.TOKEN = tokens.access_token;
|
||||||
config.TOKEN_EXPIRES_IN = tokens.expires_in;
|
config.REFRESH_TOKEN = tokens.refresh_token;
|
||||||
console.log("Tokens loaded");
|
config.TOKEN_EXPIRES_IN = tokens.expires_in;
|
||||||
|
}else{
|
||||||
|
//Cannot continue without tokens
|
||||||
|
console.log("Cannot continue without tokens in database");
|
||||||
|
process.exit(-1);
|
||||||
|
}
|
||||||
}).catch(e=>{
|
}).catch(e=>{
|
||||||
console.log("Error loading tokens");
|
console.log("Error loading tokens ! Cannot continue without tokens in database");
|
||||||
|
process.exit(-1);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,9 +3,11 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"keymaster": "^1.6.2",
|
||||||
"react": "^16.2.0",
|
"react": "^16.2.0",
|
||||||
"react-dom": "^16.2.0",
|
"react-dom": "^16.2.0",
|
||||||
"react-md": "^1.2.8",
|
"react-md": "^1.2.8",
|
||||||
|
"react-popup": "^0.9.1",
|
||||||
"react-scripts": "1.0.17",
|
"react-scripts": "1.0.17",
|
||||||
"webfontloader": "^1.6.28"
|
"webfontloader": "^1.6.28"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import './css/App.css';
|
import './css/App.css';
|
||||||
|
import './css/popup.css';
|
||||||
import IntentList from './components/IntentList';
|
import IntentList from './components/IntentList';
|
||||||
import IntentDetails from './components/IntentDetails';
|
import IntentDetails from './components/IntentDetails';
|
||||||
import LaunchRequest from './components/LaunchRequest';
|
import LaunchRequest from './components/LaunchRequest';
|
||||||
|
import Popup from 'react-popup';
|
||||||
|
|
||||||
import {getSkill, updateSkill} from './lib/api'
|
import {getSkill, updateSkill} from './lib/api'
|
||||||
|
|
||||||
@@ -42,6 +44,7 @@ class App extends Component {
|
|||||||
if(this.state.launchRequest){
|
if(this.state.launchRequest){
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
|
<Popup/>
|
||||||
<div className="App-header">
|
<div className="App-header">
|
||||||
<h1> Tell All </h1>
|
<h1> Tell All </h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -59,6 +62,7 @@ class App extends Component {
|
|||||||
}else{
|
}else{
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
|
<Popup/>
|
||||||
<div className="App-header">
|
<div className="App-header">
|
||||||
<h1> Tell All </h1>
|
<h1> Tell All </h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -100,10 +104,15 @@ class App extends Component {
|
|||||||
console.log("handleSaveLaunchRequest");
|
console.log("handleSaveLaunchRequest");
|
||||||
updateSkill(this.createSkill(this.state.allIntents,name,answer)).then(l=>l.text()).then(result=>{
|
updateSkill(this.createSkill(this.state.allIntents,name,answer)).then(l=>l.text()).then(result=>{
|
||||||
let jResult = JSON.parse(result);
|
let jResult = JSON.parse(result);
|
||||||
console.log(jResult.result);
|
if (jResult.result !== 0){
|
||||||
|
Popup.alert('Model was not saved. Please try again');
|
||||||
|
}else{
|
||||||
|
Popup.alert('Saved');
|
||||||
|
}
|
||||||
console.log(jResult.message);
|
console.log(jResult.message);
|
||||||
}).catch(e=>{
|
}).catch(e=>{
|
||||||
console.log("Error :" + e);
|
console.log("Error :" + e);
|
||||||
|
Popup.alert('Model was not saved. Please try again');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,10 +127,15 @@ class App extends Component {
|
|||||||
this.setState({allIntents: newAllIntents, selectedIntent: {intentName:'', questions:[''],answer:''}});
|
this.setState({allIntents: newAllIntents, selectedIntent: {intentName:'', questions:[''],answer:''}});
|
||||||
updateSkill(this.createSkill(newAllIntents)).then(l=>l.text()).then(result=>{
|
updateSkill(this.createSkill(newAllIntents)).then(l=>l.text()).then(result=>{
|
||||||
let jResult = JSON.parse(result);
|
let jResult = JSON.parse(result);
|
||||||
console.log(jResult.result);
|
if (jResult.result !== 0){
|
||||||
|
Popup.alert('Model was not saved. Please try again');
|
||||||
|
}else{
|
||||||
|
Popup.alert('Saved');
|
||||||
|
}
|
||||||
console.log(jResult.message);
|
console.log(jResult.message);
|
||||||
}).catch(e=>{
|
}).catch(e=>{
|
||||||
console.log("error : " + e);
|
console.log("error : " + e);
|
||||||
|
Popup.alert('Model was not saved. Please try again');
|
||||||
});
|
});
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log("error : " + e);
|
console.log("error : " + e);
|
||||||
@@ -143,9 +157,14 @@ class App extends Component {
|
|||||||
|
|
||||||
updateSkill(this.createSkill(newAllIntents)).then(l=>l.text()).then(result=>{
|
updateSkill(this.createSkill(newAllIntents)).then(l=>l.text()).then(result=>{
|
||||||
let jResult = JSON.parse(result);
|
let jResult = JSON.parse(result);
|
||||||
console.log(jResult.result);
|
if (jResult.result !== 0){
|
||||||
|
Popup.alert('Model was not saved. Please try again');
|
||||||
|
}else{
|
||||||
|
Popup.alert('Saved');
|
||||||
|
}
|
||||||
console.log(jResult.message);
|
console.log(jResult.message);
|
||||||
}).catch(e=>{
|
}).catch(e=>{
|
||||||
|
Popup.alert('Model was not saved. Please try again');
|
||||||
console.log("error : " + e);
|
console.log("error : " + e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user