Skip to content

Commit

Permalink
style updates
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmc committed Nov 30, 2016
1 parent a86daed commit fec76b8
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 202 deletions.
34 changes: 28 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ console.log("Catalog URL is", catalog_url);
console.log("Orders URL is", orders_url);

var mongoDbUrl, mongoDbOptions = {};
var mongoDbCredentials = appEnv.getServiceCreds("insurance-bot-db") || appEnv.services["compose-for-mongodb"][0].credentials;
var mongoDbCredentials = appEnv.getServiceCreds("cloudlife-mongo") || appEnv.services["compose-for-mongodb"][0].credentials;
if (mongoDbCredentials) {
var ca = [new Buffer(mongoDbCredentials.ca_certificate_base64, 'base64')];
mongoDbUrl = mongoDbCredentials.uri;
Expand Down Expand Up @@ -214,6 +214,8 @@ app.get('/history', isLoggedIn, function(req, res) {
}
})

allclaims.sort(dateSortDescending);

var output = {
owner: req.user.local.email,
fname: req.user.local.fname,
Expand Down Expand Up @@ -289,7 +291,7 @@ function fileClaim(owner, claim, callback) {
claim.outcome = 'PARTIAL';
claim.payment = amountAvailable;
policy.amountClaimed = policy.Limit;
message = "You have reached max coverage. Remaining $"+ amountAvailable + " of policy limit applied.";
message = "You have reached max coverage. Remaining $" + amountAvailable + " of policy limit applied.";
}

if (possibleEligibility < amountAvailable) {
Expand All @@ -300,7 +302,7 @@ function fileClaim(owner, claim, callback) {
}

policy.claims.push(claim);
console.log("Claim is: ",claim);
console.log("Claim is: ", claim);

doc.save(function(err) {

Expand Down Expand Up @@ -502,17 +504,17 @@ function processChatMessage(req, res) {
claimFile.provider = context.claim_provider;
claimFile.amount = context.claim_amount;

console.log("Filing data: "+owner+ " claimFile: " + JSON.stringify(claimFile));
console.log("Filing data: " + owner + " claimFile: " + JSON.stringify(claimFile));

fileClaim(owner, claimFile, function(err, reply) {

data.output.text = '';
data.context.claim_step = '';

console.log("Reply for claim file: ",reply);
console.log("Reply for claim file: ", reply);

if (reply && reply.outcome === 'success') {
data.output.text = "Your " + context.claim_procedure + " claim for " + amount + " was successfully filed! "+reply.message;
data.output.text = "Your " + context.claim_procedure + " claim for " + amount + " was successfully filed! " + reply.message;
res.status(200).json(data);

} else {
Expand All @@ -529,6 +531,26 @@ function processChatMessage(req, res) {
}


// Date helpers

var dateSortAscending = function(claim1, claim2) {
// This is a comparison function that will result in dates being sorted in
// ASCENDING order. As you can see, JavaScript's native comparison operators
// can be used to compare dates. This was news to me.
if (claim1.date > claim2.date) return 1;
if (claim1.date < claim2.date) return -1;
return 0;
};

var dateSortDescending = function(claim1, claim2) {
// This is a comparison function that will result in dates being sorted in
// DESCENDING order.
if (claim1.date > claim2.date) return -1;
if (claim1.date < claim2.date) return 1;
return 0;
};


// launch ======================================================================

io.on('connection', function(socket) {
Expand Down
50 changes: 32 additions & 18 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,53 @@ var chrono = require('chrono-node');

// load local VCAP configuration
var vcapLocal = null
// try {
// vcapLocal = require("./vcap-local.json");
// console.log("Loaded local VCAP", vcapLocal);
// } catch (e) {
// console.error(e);
// }
//
// // get the app environment from Cloud Foundry, defaulting to local VCAP
// var appEnvOpts = vcapLocal ? {
// vcap: vcapLocal
// } : {}
try {
vcapLocal = require("./vcap-local.json");
console.log("Loaded local VCAP", vcapLocal);
} catch (e) {
console.error(e);
}

// get the app environment from Cloud Foundry, defaulting to local VCAP
var appEnvOpts = vcapLocal ? {
vcap: vcapLocal
} : {}
var appEnv = cfenv.getAppEnv(appEnvOpts);

var appEnvOpts = {};

var appEnv = cfenv.getAppEnv(appEnvOpts);

var appName;
if (appEnv.isLocal) {
require('dotenv').load();
}

console.log('PROCESS ENV\n\n');

console.log(process.env);

console.log('PROCESS ENV\n\n');

console.log('ANTON\n\n');


console.log('ANTON\n\n');


console.log('APP ENV\n\n');

console.log(appEnv.services.conversation);

console.log('APP ENV\n\n');


// =====================================
// CREATE THE SERVICE WRAPPER ==========
// =====================================
// Create the service wrapper
var conversationCredentials = appEnv.getServiceCreds("cloudlife-conversation");

console.log(conversationCredentials);

var conversationUsername = process.env.CONVERSATION_USERNAME || conversationCredentials.username;
var conversationPassword = process.env.CONVERSATION_PASSWORD || conversationCredentials.password;
var conversationWorkspace = process.env.CONVERSATION_WORKSPACE || "a2d6191a-5ba3-4578-adc5-3fa1c3edad84";
var conversationWorkspace = "68128b6e-8160-4d89-b7ef-dadde8c025d2";
console.log("Using Watson Conversation with username", conversationUsername, "and workspace", conversationWorkspace);

var conversation = watson.conversation({
Expand Down Expand Up @@ -254,7 +268,7 @@ function buildContextObject(req, callback) {
reprompt.message = "Sorry, Marty McFly, you can't make a claim in the future. Please try the date again.";
return callback(null, reprompt);
} else { // Otherwise format the date to YYYY-MM-DD - Ana will also verify
var month = '' + (userDate.getUTCMonth()+1),
var month = '' + (userDate.getUTCMonth() + 1),
day = '' + (userDate.getUTCDate()),
year = userDate.getFullYear();

Expand Down
99 changes: 74 additions & 25 deletions public/stylesheets/ana.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
min-width: 226px;
border-radius: 4px;
padding: 5px;
background-image: -moz-linear-gradient(bottom, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)), url("../images/ana.svg");
/*background-image: -moz-linear-gradient(bottom, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)), url("../images/ana.svg");
background-image: -webkit-linear-gradient(bottom, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)), url("../images/ana.svg");
background-image: -ms-linear-gradient(bottom, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)), url("../images/ana.svg");
background-image: linear-gradient(bottom, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)), url("../images/ana.svg");
background-image: linear-gradient(bottom, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)), url("../images/ana.svg");*/
background-attachment: inherit;
background-position: center center;
background-repeat: no-repeat;
background-size: 100px;
overflow-y: auto;
overflow-x: hidden;
color: #597a96;
border: 1px solid #12aaeb;
border: 1px dashed #12aaeb;
}

.dialoginput {
Expand All @@ -52,53 +52,102 @@

.ana {
padding: 0.5em;
border-radius: 5px;
background-color: #12aaeb;
word-spacing: 1px;
/* border-radius: 5px; */
/* background-color: #12aaeb; */
border-left: 7px solid #12aaeb;
color: #12aaeb;
margin-left: 0.5em;
padding-left: 0.8em;
margin-right: 30%;
-webkit-align-self: flex-start;
align-self: flex-start;
-webkit-animation: fadein 2s;
-moz-animation: fadein 2s;
-ms-animation: fadein 2s;
-o-animation: fadein 2s;
animation: fadein 2s;
-webkit-animation: fadein 1s;
-moz-animation: fadein 1s;
-ms-animation: fadein 1s;
-o-animation: fadein 1s;
animation: fadein 1s;
}

.anaTitle {
color: #aaa;
font-size: 9px;
/* font-weight: bold; */
margin-bottom: 5px;
margin-left: 6px;
display: none;
}

.user {
padding: 0.5em;
border-radius: 5px;
background-color: rgba(34, 82, 130, 0.9);
/* border-radius: 5px; */
/* background-color: #eb12aa; */
border-right: 7px solid #225282;
text-align: right;
padding-right: 0.7em;
color: #225282;
margin-right: 0.5em;
margin-left: 30%;
-webkit-align-self: flex-end;
align-self: flex-end;
-webkit-animation: fadein 1s;
-moz-animation: fadein 1s;
-ms-animation: fadein 1s;
-o-animation: fadein 1s;
animation: fadein 1s;
-webkit-animation: fadein 1s;
-moz-animation: fadein 1s;
-ms-animation: fadein 1s;
-o-animation: fadein 1s;
animation: fadein 1s;
}

.userTitle {
color: #aaa;
text-align: right;
font-size: 9px;
/* font-weight: bold; */
margin-bottom: 5px;
margin-right: 6px;
display: none;
}

@keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
from {
opacity: 0;
}
to {
opacity: 1;
}
}


/* Firefox < 16 */

@-moz-keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
from {
opacity: 0;
}
to {
opacity: 1;
}
}


/* Safari, Chrome and Opera > 12.1 */

@-webkit-keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
from {
opacity: 0;
}
to {
opacity: 1;
}
}


/* Internet Explorer */

@-ms-keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
from {
opacity: 0;
}
to {
opacity: 1;
}
}
Loading

0 comments on commit fec76b8

Please sign in to comment.