diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 9e5501a..0451a77 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -5,11 +5,12 @@ body } #header { - margin-top : -10px; + top: 0px; width : 100%; background-color : #2b3643; height : 50px; padding : 5px; + position: fixed } #header h3 { @@ -189,7 +190,7 @@ font-family: "Century Gothic" text-align: center; } #main > #divCredential,#divInformation { - padding: 10px 25px 10px 25px; + padding: 30px 25px 10px 25px; } #main > #successMessage { margin: 25px; @@ -206,3 +207,6 @@ font-family: "Century Gothic" padding: 20px; opacity: 1; } +#maincontent { + margin-top: 50px; +} diff --git a/routes/sessions.js b/routes/sessions.js index bde5a6c..ac5757c 100644 --- a/routes/sessions.js +++ b/routes/sessions.js @@ -2,6 +2,8 @@ var express = require('express') var request = require('request') var router = express.Router() var headers +var session +var chats = [] /* GET users listing. */ router.get('/sessions', function (req, res, next) { console.log(req.session.userId) @@ -36,4 +38,97 @@ router.get('/sessions', function (req, res, next) { request.post(options, callback) }) +router.get('/sessions/:id', function (req, res, next) { + console.log(req.session.userId) + var id = req.params.id + headers = { + 'app_id': req.session.kiboappid, + 'app_secret': req.session.kiboappsecret, + 'content-type': 'application/json' + } + var options = { + url: `https://staging.kibopush.com/api/sessions/${id}`, + headers: headers, + rejectUnauthorized: false + } + + function callback (error, response, body) { + console.log('Response-Body', response.body) + if (!error && response.statusCode === 200) { + console.log('Response-Parse', JSON.parse(response.body)) + var info = JSON.parse(response.body) + session = info.payload + chats = session.chats + console.log(session) + res.render('sessionDetails', { title: 'Sessions Details', session: session, chats: chats }) + } else { + error = JSON.parse(response.body) + res.render('sessionDetails', { title: 'Sessions Details', session: session, error: error }) + } + } + request.get(options, callback) +}) + +router.get('/sessions/markRead/:id', function (req, res, next) { + console.log(req.session.userId) + var id = req.params.id + headers = { + 'app_id': req.session.kiboappid, + 'app_secret': req.session.kiboappsecret, + 'content-type': 'application/json' + } + var options = { + url: `https://staging.kibopush.com/api/sessions/markread/${id}`, + headers: headers, + rejectUnauthorized: false + } + + function callback (error, response, body) { + console.log('Response-Body', response.body) + if (!error && response.statusCode === 200) { + console.log('Response-Parse', JSON.parse(response.body)) + var info = JSON.parse(response.body) + var chatSeen + chatSeen = info.payload + console.log(chatSeen) + res.render('sessionDetails', { title: 'Sessions Details', session: session, chats: chats, chatSeen: chatSeen }) + } else { + var errorChatSeen = JSON.parse(response.body) + res.render('sessionDetails', { title: 'Sessions Details', session: session, chats: chats, chatSeen: chatSeen, errorChatSeen: errorChatSeen }) + } + } + request.get(options, callback) +}) + +router.get('/sessions/liveChat/:id', function (req, res, next) { + console.log(req.session.userId) + var id = req.params.id + headers = { + 'app_id': req.session.kiboappid, + 'app_secret': req.session.kiboappsecret, + 'content-type': 'application/json' + } + var options = { + url: `https://staging.kibopush.com/api/livechat/${id}`, + headers: headers, + rejectUnauthorized: false + } + + function callback (error, response, body) { + console.log('Response-Body', response.body) + if (!error && response.statusCode === 200) { + console.log('Response-Parse', JSON.parse(response.body)) + var info = JSON.parse(response.body) + var liveChat + liveChat = info.payload + console.log(liveChat) + res.render('liveChat', { title: 'Live Chat', liveChat: liveChat }) + } else { + error = JSON.parse(response.body) + res.render('liveChat', {title: 'Live Chat', liveChat: liveChat, error: error}) + } + } + request.get(options, callback) +}) + module.exports = router diff --git a/routes/workflows.js b/routes/workflows.js index b6912de..5ea4026 100644 --- a/routes/workflows.js +++ b/routes/workflows.js @@ -23,7 +23,7 @@ router.get('/workflows', function (req, res, next) { if (!error && response.statusCode === 200) { console.log('Response-Parse', JSON.parse(response.body)) var info = JSON.parse(response.body) - var workflows = info + var workflows = info.payload res.render('workflows', { title: 'Workflows', workflows: workflows }) } else { error = JSON.parse(response.body) diff --git a/views/index.jade b/views/index.jade index e0aaa0e..57c15c8 100644 --- a/views/index.jade +++ b/views/index.jade @@ -1,7 +1,7 @@ extends sidebar block div#content div#main - h1 Welcome to KiboPush Sample Client Application for calling API + h1(style='padding: 10px') Welcome to KiboPush Sample Client Application for calling API div#divCredential h3 Enter your credentials form(action="/",method="post") diff --git a/views/liveChat.jade b/views/liveChat.jade new file mode 100644 index 0000000..97463c3 --- /dev/null +++ b/views/liveChat.jade @@ -0,0 +1,69 @@ +extends sidebar +block div#content + div#divInformation + h1= title + div#divDatadiv.table-scrollable + div(class = "control-group span6") + label + | Search : + + input(type="search" class="light-table-filter form-control input-medium input-inline" data-table="liveChat" placeholder="Enter search term") + table(class = "table table-striped table-bordered table-hover liveChat") + thead + tr + td + span + |Format + td + span + |Sender Id + td + span + |Recipient Id + td + span + |Sender Facebook Id + td + span + |Recipient Facebook Id + td + span + |Status + td + span + |Date Time + td + span + |Url Meta + td + span + |Payload + + tbody + if (liveChat) + form(action="/downloadcsv",method="post") + - var dd=JSON.stringify(liveChat) + input(type="hidden" name ="dd" value = dd) + + if (liveChat.length != 0) + - each object in liveChat + tr + td=object.format + td=object.sender_id + td=object.recipient_id + td=object.sender_fb_id + td=object.recipient_fb_id + td=object.status + td=object.datetime + td=object.url_meta + td(colspan = 12)=JSON.stringify(object.payload) + tr + td(colspan = 12,style = "text-align:right;") + button(class = "downloadcsv btn btn-info" type="submit") + |Export Record in CSV + else + tr + td(colspan = 12,style = "text-align:center;")="No live chat record found." + else + tr + td(colspan = 8,style = "text-align:center;")="No live chat record found. " + error.description diff --git a/views/sessionDetails.jade b/views/sessionDetails.jade new file mode 100644 index 0000000..cc3a695 --- /dev/null +++ b/views/sessionDetails.jade @@ -0,0 +1,152 @@ +extends sidebar +block div#content + div#divInformation + h1= title + div#divDatadiv.table-scrollable + div(class = "control-group span6") + label + | Search : + + input(type="search" class="light-table-filter form-control input-medium input-inline" data-table="session" placeholder="Enter search term") + table(class = "table table-striped table-bordered table-hover session") + thead + tr + td + span + |Id + td + span + |Chats + td + span + |Subscriber Id + td + span + |Page Id + td + span + |Company Id + td + span + | Status + td + span + |Request Time + td + span + |Mark Read + td + span + |View Live Chat + + tbody + if (session) + form(action="/downloadcsv",method="post") + - var dd=JSON.stringify(session) + input(type="hidden" name ="dd" value = dd) + td=session._id + td=chats.length + td=session.subscriber_id._id + td=session.page_id._id + td=session.company_id + td=session.status + td=session.request_time + td + a(href='/sessions/markRead/' + session._id) Mark Read + td + a(href='/sessions/liveChat/' + session._id) View LiveChat + tr + td(colspan = 12,style = "text-align:right;") + button(class = "downloadcsv btn btn-info" type="submit") + |Export Record in CSV + else + tr + td(colspan = 8,style = "text-align:center;")="No record found. " + error.description + if (typeof chatSeen != 'undefined') + div.divDatadiv.table-scrollable + h3='Chat Marked Seen Response' + table(class = "table table-striped table-bordered table-hover session") + thead + tr + td + span + |Status + td + span + |No.of Chats Modified + td + span + |No.of Chat + tbody + td=chatSeen.ok + td=chatSeen.nModified + td=chatSeen.n + + div.divDatadiv.table-scrollable + h3='Chats' + div(class = "control-group span6") + label + | Search : + + input(type="search" class="light-table-filter form-control input-medium input-inline" data-table="chats" placeholder="Enter search term") + table(class = "table table-striped table-bordered table-hover chats") + thead + tr + td + span + |Format + td + span + |Sender Id + td + span + |Recipient Id + td + span + |Sender Facebook Id + td + span + |Recipient Facebook Id + td + span + |Session Id + td + span + |Company Id + td + span + |Status + td + span + |Date Time + td + span + |Payload + tbody + if (chats) + form(action="/downloadcsv",method="post") + - var dd=JSON.stringify(chats) + input(type="hidden" name ="dd" value = dd) + if (chats.length != 0) + - each chat in chats + tr + td=chat.format + td=chat.sender_id + td=chat.recipient_id + td=chat.sender_fb_id + td=chat.recipient_fb_id + td=chat.session_id + td=chat.company_id + td=chat.status + td=chat.datetime + td=JSON.stringify(chat.payload) + tr + td(colspan = 12,style = "text-align:right;") + button(class = "downloadcsv btn btn-info" type="submit") + |Export Record in CSV + else + tr + td(colspan = 12,style = "text-align:center;")="No record found. " + else + tr + td(colspan = 12,style = "text-align:center;")="No record found. " + error.description diff --git a/views/sessions.jade b/views/sessions.jade index ba35802..c45ae0b 100644 --- a/views/sessions.jade +++ b/views/sessions.jade @@ -38,13 +38,14 @@ block div#content if (sessions != 0) - each session in sessions - tr - td=session._id - td=session.subscriber_id._id - td=session.page_id._id - td=session.company_id - td=session.status - td=session.request_time + tr + td + a(href='/sessions/' + session._id) #{session._id} + td=session.subscriber_id._id + td=session.page_id._id + td=session.company_id + td=session.status + td=session.request_time tr td(colspan = 8,style = "text-align:right;") button(class = "downloadcsv btn btn-info" type="submit") diff --git a/views/sidebar.jade b/views/sidebar.jade index e02bb5a..b1e8248 100644 --- a/views/sidebar.jade +++ b/views/sidebar.jade @@ -5,72 +5,72 @@ block content center KiboPush Sample Client Application a(href="#",class="btn btn-default",id="opener") i(class="fa fa-bars") - - div(id = "slide-panel") - div#nav - ul - li - a(href='/') - i(class="fa fa-key" , aria-hidden="true") - span(class="title") - | Set Credentials - li - a(href='/userInformation/') - i(class="fa fa-user" , aria-hidden="true") - span(class="title") - | User Information - li - a(href='/workflows/') - i(class="fa fa-tasks" , aria-hidden="true") - span(class="title") - | Workflows - li - a(href='/dashboard/') - i(class="fa fa-user" , aria-hidden="true") - span(class="title") - | Dashboard Information - li - a(href='/pages/') - i(class="fa fa-object-group" , aria-hidden="true") - span(class="title") - | Pages - li - a(href='/subscribers/') - i(class="fa fa-comment" , aria-hidden="true") - span(class="title") - | Subscribers + div(id = 'maincontent') + div(id = "slide-panel") + div#nav + ul li - a(href='/surveys/') - i(class="fa fa-group" , aria-hidden="true") - span(class="title") - | Surveys - li - a(href='/polls/') - i(class="fa fa-link" , aria-hidden="true") - span(class="title") - | Polls - li - a(href='/broadcasts/') - i(class="fa fa-clock-o" , aria-hidden="true") - span(class="title") - | Broadcasts + a(href='/') + i(class="fa fa-key" , aria-hidden="true") + span(class="title") + | Set Credentials + li + a(href='/userInformation/') + i(class="fa fa-user" , aria-hidden="true") + span(class="title") + | User Information li - a(href='/autoPosting/') - i(class="fa fa-connectdevelop" , aria-hidden="true") - span(class="title") - | AutoPosting + a(href='/workflows/') + i(class="fa fa-tasks" , aria-hidden="true") + span(class="title") + | Workflows + li + a(href='/dashboard/') + i(class="fa fa-user" , aria-hidden="true") + span(class="title") + | Dashboard Information + li + a(href='/pages/') + i(class="fa fa-object-group" , aria-hidden="true") + span(class="title") + | Pages + li + a(href='/subscribers/') + i(class="fa fa-comment" , aria-hidden="true") + span(class="title") + | Subscribers + li + a(href='/surveys/') + i(class="fa fa-group" , aria-hidden="true") + span(class="title") + | Surveys + li + a(href='/polls/') + i(class="fa fa-link" , aria-hidden="true") + span(class="title") + | Polls li - a(href='/sessions/') - i(class="fa fa-clock-o" , aria-hidden="true") - span(class="title") - | Sessions + a(href='/broadcasts/') + i(class="fa fa-clock-o" , aria-hidden="true") + span(class="title") + | Broadcasts li - a(href='/menu/') - i(class="fa fa-clock-o" , aria-hidden="true") + a(href='/autoPosting/') + i(class="fa fa-connectdevelop" , aria-hidden="true") span(class="title") - | Menu + | AutoPosting + li + a(href='/sessions/') + i(class="fa fa-clock-o" , aria-hidden="true") + span(class="title") + | Chat Sessions + li + a(href='/menu/') + i(class="fa fa-clock-o" , aria-hidden="true") + span(class="title") + | Menu - block div#content + block div#content div#footer span(class = 'cc') center diff --git a/views/subscribers.jade b/views/subscribers.jade index a62f09f..8b6b009 100644 --- a/views/subscribers.jade +++ b/views/subscribers.jade @@ -3,7 +3,6 @@ block div#content div#divInformation h1= title div#divDatadiv.table-scrollable - h3= 'All Pages' div(class = "control-group span6") label | Search :