repacked bundle

This commit is contained in:
2018-07-22 13:36:43 +05:30
parent d09a5e6b95
commit ac9391f9f9
11 changed files with 685 additions and 890 deletions

674
dist/bundle.js vendored

File diff suppressed because one or more lines are too long

235
dist/index.html vendored
View File

@@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Webpack</title>
<title>Microbot</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700">
@@ -14,9 +14,10 @@
</head>
<body>
<h2 id="microbot-body" style="display:none">Micorbot Body</h2>
<div class="wrapper">
<!-- Sidebar -->
<nav id="sidebar">
<nav id="sidebar" class="active">
<div class="sidebar-header">
<button type="button" id="sidebarCollapse" class="btn btn-info">
@@ -31,28 +32,17 @@
<!-- data-toggle="collapse" -->
<a href="#homeSubmenu">
<i class="fas fa-home"></i>
<span class="hideable">Home</span>
<span class="hideable hide">Home</span>
</a>
<!-- <ul class="collapse list-unstyled" id="homeSubmenu">
<li>
<a href="#">Home 1</a>
</li>
<li>
<a href="#">Home 2</a>
</li>
<li>
<a href="#">Home 3</a>
</li>
</ul> -->
</li>
<li>
<a href="#">
<i class="fas fa-briefcase"></i>
<span class="hideable">About</span>
<span class="hideable hide">About</span>
</a>
<a href="#pageSubmenu" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle">
<i class="fas fa-copy"></i>
<span class="hideable">Tasks</span>
<span class="hideable hide">Tasks</span>
</a>
<ul class="collapse list-unstyled" id="pageSubmenu">
<li>
@@ -69,19 +59,19 @@
<li>
<a href="#">
<i class="fas fa-image"></i>
<span class="hideable">Favorites</span>
<span class="hideable hide">Favorites</span>
</a>
</li>
<li>
<a href="#">
<i class="fas fa-question"></i>
<span class="hideable">FAQ</span>
<span class="hideable hide">FAQ</span>
</a>
</li>
<li>
<a href="#">
<i class="fas fa-paper-plane"></i>
<span class="hideable">Contact</span>
<span class="hideable hide">Contact</span>
</a>
</li>
</ul>
@@ -104,9 +94,7 @@
</div>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<form id="bot-cli" class="navbar-form" role="search">
<input type="text" class="form-control" placeholder="What you need..." name="command" id="command">
</form>
<input type="text" class="form-control" placeholder="What you need..." name="command" id="command">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="nav navbar-nav ml-auto">
<li class="nav-item">
@@ -128,72 +116,161 @@
</div>
</div>
</nav>
<input type="hidden" id="intentHidden">
</div>
<div>
<h2>Placeholder header</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.</p>
<!-- Alerts -->
<div class="alert alert-success alert-dismissible fade show hide good" id="successAlert" role="alert">
<strong>Success! </strong><span id="op-msg"> Repository Added!</span>
<button type="button" id="hideSuccessAlert" class="close" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="alert alert-danger alert-dismissible hide good" id="dangerAlert" role="alert">
<button type="button" id="hideDangerAlert" class="close" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<strong>Oh snap!</strong> Change a few things up and try submitting again.
</div>
<div class="alert alert-info alert-dismissible hide good" id="intentBox" role="alert">
<button type="button" id="hideInfoAlert" class="close" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<strong>I understand you intend to: &nbsp;&nbsp;</strong><span id="intentName"></span>&nbsp;&nbsp;If not, please choose the correct option:
</div>
<!-- Widgets -->
<div class="card-group" id="widgets">
<div class="card hide widget good" id="createissue">
<!-- <img class="card-img-top" src="..." alt="Card image cap"> -->
<div class="card-body">
<h5 class="card-title">Create Issue</h5>
<form>
<div class="form-row">
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="issueTitle">Issue Title</label>
<input type="text" class="form-control" id="issueTitle" placeholder="Issue title" required>
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="issueRepository">Issue Repository</label>
<input type="text" class="form-control" id="issueRepository" placeholder="Issue's Repository here" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="assignees">Assignees</label>
<input type="text" class="form-control" id="assignees" placeholder="Comma Separated user IDs...">
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="labels">Issue Labels</label>
<input type="text" class="form-control" id="labels" placeholder="Comma Separated Labels...">
</div>
</div>
<div class="form-group">
<label for="description">Issue Description:</label>
<textarea class="form-control" rows="3" id="description"></textarea>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitConfirm" data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>
<div class="card hide widget good" id="addcollab">
<!-- <img class="card-img-top" src="..." alt="Card image cap"> -->
<div class="card-body">
<h5 class="card-title">Create Collaborator</h5>
<form>
<div class="form-row">
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="collaboratorName">Collaborator Name</label>
<input type="text" class="form-control" id="collaboratorName" placeholder="Collaborator ID" required>
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="repoForCollab">Repository Name</label>
<input type="text" class="form-control" id="repoForCollab" placeholder="Repository To Add collaborator on ...." required>
</div>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitAddCollab " data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>
<div id="viewrepos" class="card hide widget good">
<div class="card-body">
<h5 class="card-title">View Repositories</h5>
<form>
<div class="form-row">
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<p>View Repositories for the user mohiit1502?</p>
</div>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitAddCollab " data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>
<div class="line hide" id="underWidgetLine"></div>
</div>
<!-- Modals -->
<div class="modal" id="submitConfirm" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalCenterTitle">Confirm!</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Are you sure you want to submit?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" id="btnCancelConfirm" data-dismiss="modal">Cancel</button>
<button id="submitGitData" type="button" data-dimsiss="modal" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="emptyCommandMessageModal" tabindex="-1" role="dialog" aria-labelledby="emptyCommandMessageModalTitle"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="emptyCommandMessageModalTitle">No Command!</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Please type some relevant words in the command box.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
<button style="display: none" id="emptyCommandMsgDisplayer" type="submit" data-toggle="modal" data-target="#emptyCommandMessageModal"></button>
<!-- Cards -->
<div class="card-group" id="conversations">
<div class="card">
<!-- <img class="card-img-top" src="..." alt="Card image cap"> -->
<div class="card-body">
<h5 class="card-title">
Card title
<a class="close" href="#"><h6>x</h6></a>
</h5>
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
</div>
<div class="card-footer">
<small class="text-muted">Commanded 1 mins ago</small>
</div>
</div>
<div class="line"></div>
</div>
<div class="line"></div>
<h2>Lorem Ipsum Dolor</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="line"></div>
<h2>Lorem Ipsum Dolor</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="line"></div>
<h3>Lorem Ipsum Dolor</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
<!-- jQuery CDN - Slim version (=without AJAX) -->
<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
<!-- Popper.JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ"
crossorigin="anonymous"></script>
<!-- Bootstrap JS -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js" crossorigin="anonymous"></script>
<script>
$(document).ready(function () {
$('#sidebarCollapse').on('click', function () {
$('#sidebar').toggleClass('active');
$('.hideable').toggleClass('hide');
});
$('#content nav div.collapse li a.nav-link i.far.fa-star').hover(function () {
$('#content nav div.collapse li a.nav-link i.far.fa-star').toggleClass('fas');
});
$('#content nav div.collapse li a.nav-link i.far.fa-trash-alt').hover(function () {
$('#content nav div.collapse li a.nav-link i.far.fa-trash-alt').toggleClass('fas');
});
$('#content nav div.collapse li a.nav-link i.far.fa-paper-plane').hover(function () {
$('#content nav div.collapse li a.nav-link i.far.fa-paper-plane').toggleClass('fas');
});
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.5/jstree.min.js"></script>
<script type="text/javascript" src="./bundle.js"></script></body>
</html>

View File

@@ -116,16 +116,17 @@
</div>
</div>
</nav>
<input type="hidden" id="intentHidden">
</div>
<!-- Alerts -->
<div class="alert alert-success alert-dismissible fade show hide good" id="successAlert" role="alert">
<strong>Success! </strong><span id="op-msg"> Repository Added!</span>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<button type="button" id="hideSuccessAlert" class="close" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="alert alert-danger alert-dismissible hide good" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<div class="alert alert-danger alert-dismissible hide good" id="dangerAlert" role="alert">
<button type="button" id="hideDangerAlert" class="close" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<strong>Oh snap!</strong> Change a few things up and try submitting again.
@@ -134,7 +135,7 @@
<button type="button" id="hideInfoAlert" class="close" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<strong>I understand you intend to: &nbsp;&nbsp;&nbsp;&nbsp;</strong><span id="intentName"></span>&nbsp;&nbsp;&nbsp;&nbsp;If not, please choose the correct option:
<strong>I understand you intend to: &nbsp;&nbsp;</strong><span id="intentName"></span>&nbsp;&nbsp;If not, please choose the correct option:
</div>
<!-- Widgets -->
<div class="card-group" id="widgets">
@@ -144,30 +145,68 @@
<h5 class="card-title">Create Issue</h5>
<form>
<div class="form-row">
<div class="form-group col-md-12 col-sm-12 col-lg-12 col-xs-12 mb-3">
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="issueTitle">Issue Title</label>
<input type="text" class="form-control" id="issueTitle" placeholder="Issue title" required>
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="issueRepository">Issue Repository</label>
<input type="text" class="form-control" id="issueRepository" placeholder="Issue's Repository here" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="assignees">assignees</label>
<input type="text" class="form-control" id="assignees" placeholder="Comma separated user IDs">
<label for="assignees">Assignees</label>
<input type="text" class="form-control" id="assignees" placeholder="Comma Separated user IDs...">
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="labels">Issue Labels</label>
<input type="text" class="form-control" id="labels" placeholder="Comma Separated Labels">
<input type="text" class="form-control" id="labels" placeholder="Comma Separated Labels...">
</div>
</div>
<div class="form-group">
<label for="description">Issue Description:</label>
<textarea class="form-control" rows="3" id="description"></textarea>
</div>
<button class="btn btn-primary" type="submit" data-toggle="modal" data-target="#exampleModalCenter">Submit</button>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitConfirm" data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>
<div class="card hide widget good" id="addcollab">
<!-- <img class="card-img-top" src="..." alt="Card image cap"> -->
<div class="card-body">
<h5 class="card-title">Create Collaborator</h5>
<form>
<div class="form-row">
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="collaboratorName">Collaborator Name</label>
<input type="text" class="form-control" id="collaboratorName" placeholder="Collaborator ID" required>
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="repoForCollab">Repository Name</label>
<input type="text" class="form-control" id="repoForCollab" placeholder="Repository To Add collaborator on ...." required>
</div>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitAddCollab " data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>
<div id="viewrepos" class="card hide widget good">
<div class="card-body">
<h5 class="card-title">View Repositories</h5>
<form>
<div class="form-row">
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<p>View Repositories for the user mohiit1502?</p>
</div>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitAddCollab " data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>
<div class="line hide" id="underWidgetLine"></div>
</div>
<!-- Modals -->
<div class="modal" id="submitConfirm" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
@@ -181,8 +220,8 @@
Are you sure you want to submit?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button id="submitGitData" type="button" class="btn btn-primary">Submit</button>
<button type="button" class="btn btn-secondary" id="btnCancelConfirm" data-dismiss="modal">Cancel</button>
<button id="submitGitData" type="button" data-dimsiss="modal" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
@@ -207,11 +246,15 @@
</div>
</div>
<button style="display: none" id="emptyCommandMsgDisplayer" type="submit" data-toggle="modal" data-target="#emptyCommandMessageModal"></button>
<div class="card-group">
<!-- Cards -->
<div class="card-group" id="conversations">
<div class="card">
<!-- <img class="card-img-top" src="..." alt="Card image cap"> -->
<div class="card-body">
<h5 class="card-title">Card title</h5>
<h5 class="card-title">
Card title
<a class="close" href="#"><h6>x</h6></a>
</h5>
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
</div>
<div class="card-footer">
@@ -219,17 +262,6 @@
</div>
</div>
<div class="line"></div>
<div class="card">
<!-- <img class="card-img-top" src="..." alt="Card image cap"> -->
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This
card has even longer content than the first to show that equal height action.</p>
</div>
<div class="card-footer">
<small class="text-muted">Commanded 3 mins ago</small>
</div>
</div>
</div>
</div>
</div>

View File

@@ -1,4 +1,5 @@
const config = require('./config.js');
const $configBot = require('./config.js');
const $config = require('./../config.js');
const Microbot = require("./../microbot-ops.js");
const app = new Microbot();
const DomManipulator = require('./../dom-ops.js');
@@ -6,7 +7,7 @@ const domManipulator = new DomManipulator();
module.exports = class Recast {
constructor() {
this.recastToken = config.recasttoken;
this.recastToken = $configBot.recasttoken;
this.requestUrl = "https://api.recast.ai/v2/request";
}
@@ -27,6 +28,7 @@ module.exports = class Recast {
response.json().then(function(body) {
bodyRelevant = body.results;
intent = bodyRelevant.intents[0]["slug"];
$('#' + $config.costants.hiddenIntentFieldId).val(intent)
if(intent !== undefined) {
domManipulator.displayIntentBox(intent);
domManipulator.showWidget(intent);

View File

@@ -1,3 +1,56 @@
module.exports = {
gitToken: "b5f624887b686467decb0b707521baa171308df4"
gitToken: "96ead73c54cbbf023a73ee57af145b205d460851",
intentSlugToOperations: {
'createrepo' : {
"requestMethod": 'post',
"intentMessage": "Create a Repository in Github",
"getDataOperation": "getCreateRepoJson",
"githubOperation": "createRepository",
"showWidgetOperation": "showCreateRepoWidget",
"populateDataOperation": "populateCreateRepoData",
"successMessage": "Repository Added!",
"cardMsg": "Requested Repository has been added and is available at ",
"cardDataUrl": "html_url",
"cardDataName": "name"
},
'createissue' : {
"requestMethod": 'post',
"intentMessage": "Raise an issue in Github",
"getDataOperation": "getCreateIssueJson",
"githubOperation": "createIssue",
"showWidgetOperation": "showCreateIssueWidget",
"populateDataOperation": "populateCreateIssueData",
"successMessage": "Issue Created!",
"cardMsg": "Issue Created as requested, issue details available at ",
"cardDataUrl": "html_url",
"cardDataName": "title"
},
'addcollab' : {
"Method": 'post',
"intentMessage": "Add a collaborator",
"getDataOperation": "getAddCollaboratorJson",
"githubOperation": "addCollaborator",
"showWidgetOperation": "showAddCollaboratorWidget",
"populateDataOperation": "populateAddCollaboratorData",
"successMessage": "Collaborator Added!",
"cardMsg": "Collaborator added, details available at ",
"cardDataUrl": "html_url",
"cardDataName": "invitee,login"
},
'viewrepos': {
"requestMethod": 'get',
"intentMessage": "View Repositories for current user",
"getDataOperation": "getViewRepositoryJson",
"githubOperation": "viewRepositories",
"showWidgetOperation": "showViewRepoWidget",
"populateDataOperation": "populateViewRepoData",
"successMessage": "Showing repositories",
"cardMsg": "Repository Details available below: ",
"cardDataUrl": "html_url",
"cardDataName": "invitee,login"
}
},
costants: {
"hiddenIntentFieldId": "intentHidden",
}
}

View File

@@ -1,72 +1,18 @@
const $config = require('./config.js');
module.exports = class DomManipulator {
constructor() {
this.createRepoWidgetCreated = false;
this.intentSlugToIntention = {
'createrepo' : "Create a Repository in Github",
'createissue' : "Raise an issue in Github",
};
}
showWidget(widgetName) {
self = this;
switch(widgetName) {
case "createrepo":
self.showCreateRepoWidget();
break;
case "updaterepo":
app.updateRepository();
break;
case "viewrepos":
app.viewRepositories();
break;
case "deleterepo":
app.deleteRepository();
break;
case "createissue":
self.showCreateIssueWidget();
break;
case "updateissue":
app.updateIssue();
break;
case "closeissue":
app.closeIssue();
break;
case "reopenissue":
app.reopenIssue();
break;
case "displayissue":
app.displayIssue();
break;
case "addissuecomment":
app.addIssueComment();
break;
case "displaylastcomment":
app.displayLastComment();
break;
case "addcollab":
app.addCollaborator();
break;
case "removecollab":
app.removeCollaborator();
break;
default:
console.log("default");
}
this.commandCardCounter = 1;
}
showCreateRepoWidget() {
var createRepoWidget = self.createRepoWidget();
if(!this.isVisible(createRepoWidget)) {
createRepoWidget.classList.remove('hide');
$('#underWidgetLine').show();
}
}
showCreateIssueWidget() {
var createIssueWidget = document.getElementById('createissue');
if(!this.isVisible(createIssueWidget)) {
createIssueWidget.classList.remove('hide');
$('#underWidgetLine').show();
showWidget(intent) {
//var intent = $('#' + $config.costants.hiddenIntentFieldId).val();
var widget = this.createRepoWidget(intent);
if(!this.isVisible(widget)) {
widget.classList.remove('hide');
$('#underWidgetLine').removeClass('hide');
}
}
@@ -75,11 +21,11 @@ module.exports = class DomManipulator {
if(!this.isVisible(intentBox)) {
intentBox.classList.remove('hide');
}
$('#intentName').text(this.intentSlugToIntention[intent] + ' [slug: ' + intent + '].');
$('#intentName').text($config.intentSlugToOperations[intent]['intentMessage'] + ' [slug: ' + intent + '].');
}
createRepoWidget() {
var existingWidget = document.getElementById('createrepo')
createRepoWidget(intent) {
var existingWidget = document.getElementById(intent)
if(existingWidget) {
return existingWidget;
}
@@ -119,8 +65,6 @@ module.exports = class DomManipulator {
var submitRepoCreate = document.createElement('button')
var line = document.createElement('div');
// Add Attributes
widgets.classList.add('card-group');
createRepoWidget.setAttribute('id', 'createrepo');
@@ -183,9 +127,6 @@ module.exports = class DomManipulator {
submitRepoCreate.setAttribute('id', 'submitForm');
submitRepoCreate.classList.add('btn', 'btn-primary');
line.classList.add('line');
line.setAttribute('id', 'underWidgetLine');
// Add inner HTML
header.innerHTML = "Create Repository";
repoNamelabel.innerHTML = "Repository Name";
@@ -234,10 +175,9 @@ module.exports = class DomManipulator {
cardBody.appendChild(header);
cardBody.appendChild(form);
widgets.appendChild(createRepoWidget);
createRepoWidget.appendChild(cardBody);
widgets.appendChild(line);
widgets.appendChild(createRepoWidget);
$('#createrepo').insertBefore($('#underWidgetLine'));
this.createRepoWidgetCreated = true;
@@ -248,57 +188,15 @@ module.exports = class DomManipulator {
$('#emptyCommandMsgDisplayer').click();
}
populateWidgetWithRecastResponse() {
}
populateWidgetWithGithubResponse() {
}
populateRecastData(widgetName, recastResponse) {
switch(widgetName) {
case "createrepo":
self.populateCreateRepoData(recastResponse);
break;
case "updaterepo":
app.updateRepository();
break;
case "viewrepos":
app.viewRepositories();
break;
case "deleterepo":
app.deleteRepository();
break;
case "createissue":
self.populateCreateIssueData(recastResponse);
break;
case "updateissue":
app.updateIssue();
break;
case "closeissue":
app.closeIssue();
break;
case "reopenissue":
app.reopenIssue();
break;
case "displayissue":
app.displayIssue();
break;
case "addissuecomment":
app.addIssueComment();
break;
case "displaylastcomment":
app.displayLastComment();
break;
case "addcollab":
app.addCollaborator();
break;
case "removecollab":
app.removeCollaborator();
break;
default:
console.log("default");
var requestMethod = $config.intentSlugToOperations[widgetName]['requestMethod'];
if(requestMethod == 'post') {
var operation = $config.intentSlugToOperations[widgetName]['populateDataOperation'];
this[operation](recastResponse);
}
}
@@ -313,11 +211,32 @@ module.exports = class DomManipulator {
populateCreateIssueData(recastResponse) {
var issueTitleTextField = document.getElementById('issueTitle');
if(issueTitleTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0
&& recastResponse.entities['git-repository']['0']['value']) {
var issueTitle = recastResponse.entities['git-repository']['0']['value'];
var issueRepositoryTextField = document.getElementById('issueRepository');
if(issueTitleTextField && recastResponse && recastResponse.entities['issue_title'] && recastResponse.entities['issue_title'].length > 0
&& recastResponse.entities['issue_title']['0']['value']) {
var issueTitle = recastResponse.entities['issue_title']['0']['value'];
issueTitleTextField.value = issueTitle;
}
if(issueRepositoryTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0
&& recastResponse.entities['git-repository']['0']['value']) {
var repoName = recastResponse.entities['git-repository']['0']['value'];
issueRepositoryTextField.value = repoName;
}
}
populateAddCollaboratorData(recastResponse) {
var collaboratorNameTextField = document.getElementById('collaboratorName');
var repoForCollabTextField = document.getElementById('repoForCollab');
if(collaboratorNameTextField && recastResponse && recastResponse.entities['git_collaborator'] && recastResponse.entities['git_collaborator'].length > 0
&& recastResponse.entities['git_collaborator']['0']['value']) {
var collaboratorName = recastResponse.entities['git_collaborator']['0']['value'];
collaboratorNameTextField.value = collaboratorName;
}
if(repoForCollabTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0
&& recastResponse.entities['git-repository']['0']['value']) {
var repoName = recastResponse.entities['git-repository']['0']['value'];
repoForCollabTextField.value = repoName;
}
}
isVisible(element) {
@@ -325,6 +244,20 @@ module.exports = class DomManipulator {
}
getDataFromFormAsJSON() {
var data = {};
var intent = $('#' + $config.costants.hiddenIntentFieldId).val();
var requestMethod = $config.intentSlugToOperations[intent]['requestMethod'];
if(requestMethod == 'post') {
if(intent) {
var operation = $config.intentSlugToOperations[intent]['getDataOperation'];
data = this[operation]();
}
}
return data;
}
getCreateRepoJson() {
var data = {};
var request = {};
if(this.isVisible(document.getElementById("createrepo"))) {
request.name = document.getElementById("repositoryName").value;
@@ -334,24 +267,238 @@ module.exports = class DomManipulator {
request.has_issues = document.getElementById("issuesChk").checked;
request.has_wiki = document.getElementById("wikiChk").checked;
}
return request;
data.request = request;
return data;
}
addGitOperationHistory(response) {
getCreateIssueJson() {
var data = {};
data.urlParams = {};
var request = {};
if(this.isVisible(document.getElementById("createissue"))) {
request.title = document.getElementById("issueTitle").value;
request.body = document.getElementById("description").value;
request.assignees = document.getElementById("assignees").value ? document.getElementById("assignees").value.split(',') : [];
request.labels = document.getElementById("labels").value ? document.getElementById("labels").value.split(',') : [];
data.urlParams.repoName = document.getElementById("issueRepository").value;
}
data.request = request;
return data;
}
getAddCollaboratorJson() {
var data = {};
data.urlParams = {};
if(this.isVisible(document.getElementById("addcollab"))) {
data.urlParams.collaborator = document.getElementById("collaboratorName").value;
data.urlParams.repoName = document.getElementById("repoForCollab").value;
}
return data;
}
addGitOperationHistory(data, type) {
var intent = $('#' + $config.costants.hiddenIntentFieldId).val();
var requestMethod = $config.intentSlugToOperations[intent].requestMethod;
var conversations = document.getElementById('conversations');
var table = undefined;
// Create Elements
var card = document.createElement('div');
var cardBody = document.createElement('div');
var cardTitle = document.createElement('h5');
var cardText = document.createElement('p');
var cardFooter = document.createElement('div');
var textMuted = document.createElement('small');
var underCardLine = document.createElement('div');
// Add Attributes
card.classList.add('card', type);
cardBody.classList.add('card-body');
cardTitle.classList.add('card-title');
cardText.classList.add('card-text');
cardFooter.classList.add('card-footer');
textMuted.classList.add('text-muted');
underCardLine.classList.add('line');
var x = this.display_ct(0, textMuted);
if(type === 'command') {
// Add content
cardTitle.innerHTML = 'You Said';
cardText.innerHTML = data;
var repeat = document.createElement('a');
repeat.classList.add('btn', 'btn-info', 'float-right');
repeat.setAttribute('role', 'button');
repeat.setAttribute('href', '#');
repeat.setAttribute('id', 'btnRepeatCommand' + this.commandCardCounter++);
repeat.innerHTML = "Repeat";
cardText.appendChild(repeat)
} else if(type === "response") {
// Add content
cardTitle.innerHTML = 'Server Responded As..';
if(requestMethod == 'post') {
cardText.innerHTML = $config.intentSlugToOperations[intent]['cardMsg'] + "<a class='repoLink' href='" + data[$config.intentSlugToOperations[intent].cardDataUrl] + "'>" + this.getVariable(data, $config.intentSlugToOperations[intent].cardDataName) + "</a>";
} else if (requestMethod == 'get') {
cardText.innerHTML = $config.intentSlugToOperations[intent]['cardMsg'];
if(data && data.length && data.length > 0) {
table = this.createRepoTable(data);
}
}
} else {
cardTitle.innerHTML = 'Server Responded As..';
cardText.innerHTML = "Operation failed with status: " + type;
}
// Associations
cardBody.appendChild(cardTitle);
cardBody.appendChild(cardText);
cardFooter.appendChild(textMuted);
card.appendChild(cardBody);
if(table) { card.appendChild(table); }
card.appendChild(cardFooter);
conversations.insertBefore(underCardLine, conversations.firstChild);
conversations.insertBefore(card, conversations.firstChild);
}
getVariable(data, commaSeparatedValue) {
var arr = commaSeparatedValue.split(',');
for(var i = 0; i < arr.length; i++) {
data = data[arr[i]];
}
return data;
}
createRepoTable(data) {
// Create Elements
var table = document.createElement('table');
var thead = document.createElement('thead');
var tr_head = document.createElement('tr');
var th_1 = document.createElement('th');
var th_2 = document.createElement('th');
var th_3 = document.createElement('th');
var th_4 = document.createElement('th');
var th_5 = document.createElement('th');
var th_6 = document.createElement('th');
var th_7 = document.createElement('th');
// Add Attributes
table.classList.add('table', 'tabled-bordered', 'table-striped', 'table-hover');
thead.classList.add('thead-dark');
th_1.setAttribute('scope', 'col');
th_2.setAttribute('scope', 'col');
th_3.setAttribute('scope', 'col');
th_4.setAttribute('scope', 'col');
th_5.setAttribute('scope', 'col');
th_6.setAttribute('scope', 'col');
th_7.setAttribute('scope', 'col');
// Add Inner HTML
th_1.innerHTML = "#";
th_2.innerHTML = "Repository Name";
th_3.innerHTML = "Repository ID";
th_4.innerHTML = "Created On";
th_5.innerHTML = "Created By";
th_6.innerHTML = "View Raw";
th_7.innerHTML = "Delete Repository";
// Associations
tr_head.appendChild(th_1);
tr_head.appendChild(th_2);
tr_head.appendChild(th_3);
tr_head.appendChild(th_4);
tr_head.appendChild(th_5);
tr_head.appendChild(th_6);
tr_head.appendChild(th_7);
thead.appendChild(tr_head);
table.appendChild(thead);
for(var i = 0; i < data.length; i++) {
var currentRepo = data[i];
// Create Elements
var tbody = document.createElement('tbody');
var tr_body = document.createElement('tr');
var th_vertical = document.createElement('th');
var td_1 = document.createElement('td');
var td_2 = document.createElement('td');
var td_3 = document.createElement('td');
var td_4 = document.createElement('td');
var td_5 = document.createElement('td');
var td_6 = document.createElement('td');
// Add Attributes
th_vertical.setAttribute('scope', 'row');
tr_body.setAttribute('id', 'repoRow' + i);
// Add Inner HTML
th_vertical.innerHTML = i + 1;
td_1.innerHTML = currentRepo.name;
td_2.innerHTML = "<a href='" + currentRepo.html_url + "' class='repoLink'>" + currentRepo.id + "</a>";
td_3.innerHTML = currentRepo.created_at;
td_4.innerHTML = "<a href='" + currentRepo.owner.html_url + "' class='btn btn-info'>" + currentRepo.owner.login + "</a>";
td_5.innerHTML = "<a href='" + currentRepo.owner.url + "' class='btn btn-info'>View</a>";
td_6.innerHTML = "<a href='" + currentRepo.owner.html_url + "' class='btn btn-danger'>Delete</a>";
// Associations
tr_body.appendChild(th_vertical);
tr_body.appendChild(td_1);
tr_body.appendChild(td_2);
tr_body.appendChild(td_3);
tr_body.appendChild(td_4);
tr_body.appendChild(td_5);
tr_body.appendChild(td_6);
tbody.appendChild(tr_body);
table.appendChild(tbody);
}
return table;
}
toggleModals(response) {
var self = this;
var promise = response.json();
$('#submitConfirm').hide();
var intent = $('#' + $config.costants.hiddenIntentFieldId).val();
$('#submitConfirm').addClass('hide');
$('#btnCancelConfirm').click();
$('.modal-backdrop').removeClass('modal-backdrop');
$('#underWidgetLine').hide();
if(response && response.status && response.status === 201) {
$('#successAlert').show();
$('#createrepo').hide();
$('#underWidgetLine').addClass('hide');
$('#intentBox').addClass('hide');
if(response && response.status && (response.status === 201 || response.status === 200 || response.status === 204)) {
$('#successAlert').removeClass('hide');
$('#widgets').children().addClass('hide');
promise.then(function(body) {
$('#op-msg').text($config.intentSlugToOperations[intent]['successMessage']);
$('#successAlert').removeClass('hide');
self.addGitOperationHistory(body, "response");
})
} else {
$('#widgets').children().addClass('hide');
$('#dangerAlert').removeClass('hide');
self.addGitOperationHistory(response.status);
}
promise.then(function(body) {
addGitOperationHistory(body);
})
}
display_ct (start, element) {
this.start = start;
this.element = element;
var days = Math.floor(this.start / 86400);
var hours = Math.floor((this.start - (days * 86400 ))/3600)
var minutes = Math.floor((this.start - (days * 86400 ) - (hours *3600 ))/60)
var secs = Math.floor((this.start - (days * 86400 ) - (hours *3600 ) - (minutes*60)))
var x = '';
if(days != 0) {
x = x + days + ' days';
}
if(hours != 0) {
x = x + hours + ' hours';
}
if(minutes != 0) {
x = x + minutes + ' minutes';
}
x = x + secs + ' seconds ago';
element.innerHTML = x;
this.start = this.start + 1;
// setTimeout(this['display_ct](this.start, this.element)', 1000 )
}
}

View File

@@ -4,6 +4,7 @@ const DomManipulator = require('./dom-ops.js');
const dom = new DomManipulator();
const Microbot = require('./microbot-ops.js');
const app = new Microbot();
const $config = require('./config.js');
module.exports = $(document).ready(function () {
@@ -24,21 +25,42 @@ module.exports = $(document).ready(function () {
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13) {
$('#widgets').children().addClass('hide');
$('#successAlert').addClass('hide');
$('#dangetAlert').addClass('hide');
$('#intentBox').addClass('hide');
var command = document.getElementById('command').value;
if(command) {
var text = { "text": command};
recastclient.getAndCallProcessIntent(command, text);
dom.addGitOperationHistory(command, 'command');
} else {
dom.showEmptyCommandMessage();
}
}
});
$('#btnSubmitConfirm').on('click', function() {
$('#submitConfirm').removeClass('hide');
})
$('#submitGitData').on('click', function() {
var requestJSON = dom.getDataFromFormAsJSON();
app.createRepository(requestJSON);
var data = dom.getDataFromFormAsJSON();
var intent = $('#' + $config.costants.hiddenIntentFieldId).val();
if(intent) {
var operation = $config.intentSlugToOperations[intent]['githubOperation'];
app[operation](data);
}
})
$("#hideInfoAlert").on('click', function(){
$('#intentBox').addClass('hide');
})
$("#hideSuccessAlert").on('click', function(){
$('#successAlert').addClass('hide');
})
$('.close').click(function(){
var $target = $(this).closest('.card');
$target.hide('slow', function(){ $target.remove(); });
})
$("#hideDangerAlert").on('click', function(){
$('#dangerAlert').addClass('hide');
})
});

View File

@@ -30,11 +30,12 @@ module.exports = class Github {
}
)
.then(function(response) {
response.json().then(function(body){
repositories = body;
console.log(repositories);
return repositories;
});
// response.json().then(function(body){
// repositories = body;
// console.log(repositories);
// return repositories;
// });
dom.toggleModals(response);
})
.catch(error => console.error('Fetch Error =\n', error));
return repositories;
@@ -89,8 +90,8 @@ module.exports = class Github {
.catch(error => console.error('Fetch Error =\n', error));
}
createIssue(newIssueJson) {
let url = 'https://api.github.com/repos/mohiit1502/stack_route_prj7/issues';
createIssue(newIssueJson, repoName) {
let url = 'https://api.github.com/repos/mohiit1502/' + repoName + '/issues';
fetch(url, {
method: "POST",
headers: {
@@ -100,7 +101,9 @@ module.exports = class Github {
body: JSON.stringify(newIssueJson)
}
)
.then(response => response.json())
.then(function(response) {
dom.toggleModals(response);
})
.catch(error => console.error('Fetch Error =\n', error));
}
@@ -265,7 +268,9 @@ module.exports = class Github {
}
}
)
.then(response => response.json())
.then(function(response) {
dom.toggleModals(response);
})
.catch(error => console.error('Fetch Error =\n', error));
}

View File

@@ -1,9 +0,0 @@
module.exports = class Greeter {
constructor(name) {
this.name = name;
}
greet() {
return 'Hello' + this.name;
}
}

View File

@@ -13,8 +13,9 @@ module.exports = class Microbot {
return $github.viewRepositories();
}
createRepository(requestJson) {
var promise = $github.createRepository(requestJson);
createRepository(requestData) {
var requestJson = requestData.request;
$github.createRepository(requestJson);
// $github.createRepository({
// "name": "new-test-js-git-api-repo",
// "description": "This is your first repository",
@@ -42,17 +43,10 @@ module.exports = class Microbot {
$github.deleteRepository();
}
createIssue() {
$github.createIssue({
"title": "Found a bug",
"body": "I'm having a problem with this.",
"assignees": [
"mohiit1502"
],
"labels": [
"bug"
]
})
createIssue(requestData) {
var requestJson = requestData.request;
var repoName = requestData.urlParams.repoName;
$github.createIssue(requestJson, repoName);
}
updateIssue() {
@@ -98,20 +92,17 @@ module.exports = class Microbot {
return $github.displayLastComment();
}
addCollaborator() {
$github.addCollaborator({
"title": "Found a bug",
"body": "I'm having a problem with this.",
"assignees": [
"mohiit1502"
],
"labels": [
"bug"
]
});
addCollaborator(requestData) {
var repoName = requestData.urlParams.repoName;
var collaborator = requestData.urlParams.collaborator;
$github.addCollaborator(repoName, collaborator);
}
removeCollaborator() {
$github.removeCollaborator();
}
callAppropriate(intent) {
}
}

View File

@@ -28,7 +28,7 @@ a:focus {
padding: 15px 10px;
background: #fff;
border: none;
border-radius: 0;
border-radius: 0 5px 5px 0;
margin-bottom: 40px;
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}
@@ -43,7 +43,7 @@ a:focus {
width: 100%;
height: 1px;
border-bottom: 1px dashed #ddd;
margin: 40px 0;
margin: 20px 0;
}
i,
@@ -259,6 +259,9 @@ a.article:hover {
#sidebarCollapse span {
display: none;
}
.text-muted {
color: #bcb !important;
}
}
/* -------------------------------------------------
ADDITIONS
@@ -290,6 +293,12 @@ ADDITIONS
animation: anim .3s ease-in-out;
}
.repoLink {
color: #000;
font-weight: bolder;
text-decoration: underline;
}
@keyframes anim {
0% {
display: none;