Refactor - stage 1

This commit is contained in:
2018-07-26 04:38:05 +05:30
parent b271e11b10
commit 8f0aa2bcbd
28 changed files with 694 additions and 626 deletions

88
dist/bundle.js vendored

File diff suppressed because one or more lines are too long

View File

View File

@@ -7,6 +7,7 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Microbot</title>
<script src="https://unpkg.com/redux@4.0.0/dist/redux.min.js"></script>
<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">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt"
@@ -94,20 +95,20 @@
</div>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<input type="text" class="form-control" placeholder="What you need..." name="command" id="command">
<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">
<li id="btnFavorites" class="nav-item">
<a class="nav-link" href="#">
<i class="far fa-star"></i>
</a>
</li>
<li class="nav-item">
<li id="btnClearCommand" class="nav-item">
<a class="nav-link" href="#">
<i class="far fa-trash-alt"></i>
</a>
</li>
<li class="nav-item">
<li id="btnFireCommand" class="nav-item">
<a class="nav-link" href="#">
<i class="far fa-paper-plane"></i>
</a>
@@ -120,7 +121,8 @@
</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>
<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>
@@ -135,138 +137,11 @@
<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:
<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 id="createissue" class="card hide widget good">
<!-- <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 id="addcollab" class="card hide widget good">
<!-- <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>
<div class="form-group">
<label for="comment">Comment:</label>
<textarea class="form-control" rows="3" id="comment"></textarea>
</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="addissuecomment" class="card hide widget good">
<!-- <img class="card-img-top" src="..." alt="Card image cap"> -->
<div class="card-body">
<h5 class="card-title">Add Comment</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="repoForIssueComment">Repository Name</label>
<input type="text" class="form-control" id="repoForIssueComment" placeholder="Repository Name...." required>
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="issueNumber">Issue Number</label>
<input type="text" class="form-control" id="issueNumber" placeholder="Issue To Comment On..." required>
</div>
</div>
<div class="form-group">
<label for="issueComment">Comment:</label>
<textarea class="form-control" rows="3" id="issueComment"></textarea>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitAddComment" 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="btnSubmitViewRepo" data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>
<div id="closeissue" class="card hide widget good">
<div class="card-body">
<h5 class="card-title">Close 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="repoForIssueClose">Repository Name</label>
<input type="text" class="form-control" id="repoForIssueClose" placeholder="Repository Name...." required>
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="issueNumerToClose">Issue To Close</label>
<input type="text" class="form-control" id="issueNumerToClose" placeholder="Specify issue number..." required>
</div>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitCloseIssue" data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>
<div id="displaylastcomment" class="card hide widget good">
<div class="card-body">
<h5 class="card-title">Display Last Comment</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="repoForCommentView">Repository Name</label>
<input type="text" class="form-control" id="repoForCommentView" placeholder="Repository Name...." required>
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="issueNumberForCommentView">Issue To Close</label>
<input type="text" class="form-control" id="issueNumberForCommentView" placeholder="Specify issue number..." required>
</div>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitCommentView" data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>
<div class="line hide" id="underWidgetLine"></div>
</div>
<!-- Modals -->
@@ -313,22 +188,7 @@
<div id="loading-img"></div>
</div>
<!-- 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="card-group" id="conversations"></div>
</div>
</div>

View File

@@ -1,16 +1,21 @@
const Recast = require('./bot/recast-ops.js');
import * as recastOps from './services/recast-ops.js';
const recastclient = new recastOps.Recast();
const recastclient = new Recast();
const DomManipulator = require('./dom-ops.js');
import * as domManipulator from './services/dom-ops.js';
const dom = new domManipulator.DomManipulator();
const dom = new DomManipulator();
const Microbot = require('./microbot-ops.js');
import * as microbotOps from './services/microbot-ops.js';
const app = new microbotOps.Microbot();
import { Helper } from './helpers/helper.js';
const helper = new Helper();
import { store } from './services/persistent-ops.js';
const app = new Microbot();
const $config = require('./config.js');
module.exports = $(document).ready(() => {
$(document).ready(() => {
// console.log('test');
app.setToken();
$('#sidebarCollapse').on('click', () => {
@@ -42,6 +47,16 @@ module.exports = $(document).ready(() => {
}
}
});
$('#btnFavorites').click(function() {
});
$('#btnClearCommand').click(function() {
$('#command').val('');
$('#command').focus();
});
$('#btnFireCommand').click(function() {
hitEnter()
});
$('#btnSubmitConfirm').on('click', () => {
$('#submitConfirm').removeClass('hide');
});
@@ -65,18 +80,32 @@ module.exports = $(document).ready(() => {
$target.hide('slow', () => { $target.remove(); });
line.hide('slow', () => { line.remove(); });
});
$('#conversations').on('click', '.btn.btn-info.float-right', function () {
let parentText = $(this).closest('.card-text').text();
const command = parentText.substring(0, parentText.indexOf('Repeat'));
hitEnter(command)
});
$('#hideDangerAlert').on('click', () => {
$('#dangerAlert').addClass('hide');
});
$('#git_bridge').on('click', () => {
window.location.href = 'https://github.com/login/oauth/authorize?scope=user:email:repo&client_id=f6f649a1fe2dfea082ba';
// var user = app.getCurrentUser();
// if(user) {
// window.location.href = './../continue.html'
// } else {
// window.location.href = 'https://github.com/login/oauth/authorize?scope=user:email:repo&client_id=f6f649a1fe2dfea082ba';
// }
});
let localHistory = JSON.parse(window.localStorage.getItem('currentState'));
window.onload = initOps();
function initOps() {
$('#command').focus();
dom.loadConversations(helper.concatenateAndSort(localHistory));
}
function hitEnter(command) {
let commandInputField = $('#command');
if(command) commandInputField.val(command);
let e = jQuery.Event("keyup");
e.which = 13;
commandInputField.focus();
commandInputField.trigger(e);
}
if (window.location.href.match(/\?code=(.*)/)) {
const code = window.location.href.match(/\?code=(.*)/)[1];
app.getToken(code);

View File

@@ -1,4 +1,4 @@
import '../styles/scss/base.scss';
import '../styles/css/base.css';
require('./event-toggles.js');
require('./app-event-triggers');

View File

@@ -1,57 +0,0 @@
/*
* bot.js
*
* In this file:
* - received message from a connected channel will be transformed with Recast.AI SDK
* - received message from test command will be processed by Recast.AI
* You can run this command for testing:
* curl -X "POST" "http://localhost:5000" -d '{"text": "YOUR_TEXT"}' -H "Content-Type: application/json; charset=utf-8"
*
*
* The Recast.AI SDK will handle the message and call your reply bot function (ie. replyMessage function)
*/
const recastai = require('recastai').default
const config = require('./config.js');
// Instantiate Recast.AI SDK
const client = new recastai(config.recasttoken);
/*
* Callback for BotConnector messages
* Parameters:
* - message: Message received from BotConnector
*/
const replyMessage = message => {
// Get text from message received
const text = message.content
console.log('I receive: ', text)
return client.request.analyseText(text)
.then(nlp => {
let reply = 'I\'m sorry but I don\'t understand what you are talking about.'
const intent = nlp.intent()
if (intent) {
reply = `I understand that you talk about ${intent.slug}.`
}
message.addReply({ type: 'text', content: reply })
return message.reply().then(p => p.body)
})
}
/*
* Main bot function
* Parameters are:
* - body: Request body
* - response: Response of your server (can be a blank object if not needed: {})
*/
const reply = (request, response) => {
return client.connect.handleMessage(request, response, replyMessage)
}
module.exports = {
reply,
}

View File

@@ -1,3 +0,0 @@
module.exports = {
recasttoken: "26021d055040a9d9f1ad48476efab4a0"
}

View File

@@ -1,92 +0,0 @@
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');
const domManipulator = new DomManipulator();
module.exports = class Recast {
constructor() {
this.recastToken = $configBot.recasttoken;
this.requestUrl = "https://api.recast.ai/v2/request";
}
getAndCallProcessIntent(command, text) {
self = this;
var url = this.requestUrl + "?text=" + command;
var bodyRelevant = '';
var intent = '';
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json; charset=utf-8",
"Authorization": "Token " + this.recastToken
},
data: text
})
.then(function(response) {
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);
domManipulator.addGitOperationHistory(command, 'command');
domManipulator.populateRecastData(intent, bodyRelevant);
// self.processIntent(intent);
}
return intent;
});
})
.catch(function(error) {
console.error('Fetch Error =\n', error);
});
};
processIntent(intent) {
switch(intent) {
case "createrepo":
app.createRepository();
break;
case "updaterepo":
app.updateRepository();
break;
case "viewrepos":
app.viewRepositories();
break;
case "deleterepo":
app.deleteRepository();
break;
case "createissue":
app.createIssue();
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");
}
}
}

View File

@@ -1,47 +0,0 @@
/*
* server.js
* This file is the core of your bot
*
* It creates a little server using express
* So, your bot can be triggered throught "/" route
*
* This file was made for locally testing your bot
* You can test it by running this command
* curl -X "POST" "http://localhost:5000" -d '{"text": "YOUR_TEXT"}' -H "Content-Type: application/json; charset=utf-8"
* You might modify the server port ^^^^ depending on your configuration in config.js file
*/
const express = require('express')
const bodyParser = require('body-parser')
// Load configuration
require('./config')
const bot = require('./bot')
// Start Express server
const app = express()
app.set('port', process.env.PORT || 5000)
app.use(bodyParser.json())
// Handle / route
app.use('/', (request, response) => {
bot.reply(request, response)
.then(success => {
console.log(success)
if (!response.headersSent) { response.status(200) }
}).catch(error => {
console.log('Error in your bot:', error)
if (!response.headersSent) { response.sendStatus(400) }
})
})
if (!process.env.REQUEST_TOKEN) {
console.log('ERROR: process.env.REQUEST_TOKEN variable in src/config.js file is empty ! You must fill this field with the request_token of your bot before launching your bot locally')
process.exit(0)
} else {
// Run Express server, on right port
app.listen(app.get('port'), () => {
console.log('Our bot is running on port', app.get('port'))
})
}

View File

@@ -1,5 +1,6 @@
module.exports = {
gitToken: '96ead73c54cbbf023a73ee57af145b205d460851',
recasttoken: "26021d055040a9d9f1ad48476efab4a0",
intentSlugToOperations: {
createrepo: {
requestMethod: 'post',
@@ -85,8 +86,25 @@ module.exports = {
cardDataUrl: 'html_url',
cardDataName: 'invitee,login',
},
resethistory: {
requestMethod: 'purge',
intentMessage: 'Clear all Operations History',
successMessage: 'Purged!',
cardMsg: 'Purged history of all Operations and Commands!'
},
},
costants: {
hiddenIntentFieldId: 'intentHidden',
},
actions: {
createrepo: { type: 'ADD_REPO'},
addcollab: { type: 'ADD_COLLAB'},
createissue: { type: 'ADD_ISSUE'},
addissuecomment: { type: 'ADD_COMMENT'},
closeissue: { type: 'CLOSE_ISSUE'},
displaylastcomment: { type: 'SHOW_LAST_COMMENT'},
viewrepos: { type: 'VIEW_REPO' },
action_add_query: { type: 'ADD_QUERY'},
action_clear_history: { type: 'CLEAR_HISTORY' }
}
};

14
src/js/data/history.js Normal file
View File

@@ -0,0 +1,14 @@
const state = {
createrepo: [],
createissue:[],
closeissue:[],
addissuecomment: [],
displaylastcomment: [],
addcollab: [],
viewrepos: [],
queries: [],
messages: [],
insertionCounter: 0
}
module.exports = state;

View File

@@ -1,5 +0,0 @@
module.exports = class GithubHelper {
getLatestComment(comments) {
if (comments && comments.length > 0) { return comments[comments.length - 1].body; }
}
};

36
src/js/helpers/helper.js Normal file
View File

@@ -0,0 +1,36 @@
export class Helper {
getLatestComment(comments) {
if (comments && comments.length > 0) { return comments[comments.length - 1].body; }
}
compareByProperty(property) {
return function (a, b) {
if (a[property] < b[property])
return -1;
if (a[property] > b[property])
return 1;
return 0;
}
}
clone(obj) {
if (null == obj || "object" != typeof obj) return obj;
var copy = Object.assign({}, obj);
return copy;
}
concatenateAndSort(history) {
// let counter = 1;
let historyAll = [];
for (var property in history) {
if (history.hasOwnProperty(property) && Array.isArray(history[property])) {
historyAll = historyAll.concat(history[property]);
}
}
historyAll.sort(this.compareByProperty('insertionCounter'))
return historyAll;
}
};

View File

@@ -1,28 +0,0 @@
module.exports = class PersistentOps {
getLatestComment(comments) {
if (comments && comments.length > 0) { return comments[comments.length - 1].body; }
}
setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
const expires = `expires=${d.toUTCString()}`;
document.cookie = `${cname}=${cvalue};${expires};path=/`;
}
getCookie(cname) {
const name = `${cname}=`;
const decodedCookie = decodeURIComponent(document.cookie);
const ca = decodedCookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return '';
}
};

View File

@@ -1,20 +1,45 @@
const $config = require('./config.js');
const GithubHelper = require('./helper.js');
const $config = require('../config.js');
import * as helperOps from '../helpers/helper.js';
const helper = new helperOps.Helper();
import { addcollab } from './../views/addcollab.js';
import { addissuecomment } from './../views/addissuecomment.js';
import { closeissue } from './../views/closeissue.js';
import { createissue } from './../views/createissue.js';
import { createrepo } from './../views/createrepo.js';
import { displaylastcomment } from './../views/displaylastcomment.js';
import { viewrepos } from './../views/viewrepos.js';
const githubHelper = new GithubHelper();
module.exports = class DomManipulator {
export class DomManipulator {
constructor() {
this.createRepoWidgetCreated = false;
this.commandCardCounter = 1;
this.map = {
'addcollab': addcollab,
'addissuecomment': addissuecomment,
'closeissue': closeissue,
'createissue': createissue,
'createrepo': createrepo,
'displaylastcomment': displaylastcomment,
'viewrepos': viewrepos
}
}
showWidget(intent) {
// var intent = $('#' + $config.costants.hiddenIntentFieldId).val();
const widget = this.createRepoWidget(intent);
if (!this.isVisible(widget)) {
widget.classList.remove('hide');
$('#underWidgetLine').removeClass('hide');
let widget = document.getElementById(intent);
if (widget) {
if (!this.isVisible(widget)) {
widget.classList.remove('hide');
$('#underWidgetLine').removeClass('hide');
}
} else {
let template = document.createElement('template')
template.innerHTML = this.map[intent];
widget = template.content.firstChild;
if (!this.isVisible(widget)) {
widget.classList.remove('hide');
$('#underWidgetLine').removeClass('hide');
}
widgets.prepend(template.content.firstElementChild);
}
}
@@ -26,174 +51,10 @@ module.exports = class DomManipulator {
$('#intentName').text(`${$config.intentSlugToOperations[intent].intentMessage} [slug: ${intent}].`);
}
createRepoWidget(intent) {
const existingWidget = document.getElementById(intent);
if (existingWidget) {
return existingWidget;
}
// Create Elements
const widgets = document.getElementById('widgets');
const createRepoWidget = document.createElement('div');
const cardBody = document.createElement('div');
const header = document.createElement('div');
const form = document.createElement('form');
const formRow1 = document.createElement('div');
const formGroup1_1 = document.createElement('div');
const repoNamelabel = document.createElement('label');
const repoNameTextField = document.createElement('input');
const formGroup1_2 = document.createElement('div');
const homePageURLLabel = document.createElement('label');
const homePageURLTextField = document.createElement('input');
const formRow2 = document.createElement('div');
const formGroup2_1 = document.createElement('div');
const formCheck1 = document.createElement('div');
const privateLabel = document.createElement('label');
const privateCB = document.createElement('input');
const formGroup2_2 = document.createElement('div');
const formCheck2 = document.createElement('div');
const addIssueLabel = document.createElement('label');
const addIssueCB = document.createElement('input');
const formGroup2_3 = document.createElement('div');
const formCheck3 = document.createElement('div');
const addWikiLabel = document.createElement('label');
const addWikiCB = document.createElement('input');
const formGroup3_1 = document.createElement('div');
const descriptionLabel = document.createElement('label');
const descriptionTextArea = document.createElement('textarea');
const submitRepoCreate = document.createElement('button');
// Add Attributes
widgets.classList.add('card-group');
createRepoWidget.setAttribute('id', 'createrepo');
createRepoWidget.classList.add('card', 'hide', 'widget', 'good');
cardBody.classList.add('card-body');
header.classList.add('card-title');
formRow1.classList.add('form-row');
formGroup1_1.classList.add('form-group', 'col-md-6', 'col-sm-6', 'col-lg-6', 'col-xs-6', 'mb-3');
repoNamelabel.setAttribute('for', 'repositoryName');
repoNameTextField.setAttribute('type', 'text');
repoNameTextField.setAttribute('id', 'repositoryName');
repoNameTextField.setAttribute('placeholder', 'Repository Name... ');
repoNameTextField.required = true;
repoNameTextField.classList.add('form-control');
formGroup1_2.classList.add('form-group', 'col-md-6', 'col-sm-6', 'col-lg-6', 'col-xs-6', 'mb-3');
homePageURLLabel.setAttribute('for', 'homePageURL');
homePageURLTextField.setAttribute('type', 'text');
homePageURLTextField.setAttribute('id', 'homePageURL');
homePageURLTextField.setAttribute('placeholder', 'Home Page URL... ');
homePageURLTextField.classList.add('form-control');
formRow2.classList.add('form-row');
formGroup2_1.classList.add('form-group', 'col-md-3', 'col-sm-3', 'col-lg-3', 'col-xs-3', 'mb-3');
formCheck1.classList.add('form-check', 'form-check-inline');
privateLabel.setAttribute('for', 'privateRepoChk');
privateLabel.classList.add('form-check-label');
privateCB.setAttribute('type', 'checkbox');
privateCB.setAttribute('id', 'privateRepoChk');
privateCB.setAttribute('value', 'Option 1');
privateCB.classList.add('form-check-input');
formGroup2_2.classList.add('form-group', 'col-md-4', 'col-sm-4', 'col-lg-4', 'col-xs-4', 'mb-3');
formCheck2.classList.add('form-check', 'form-check-inline');
addIssueLabel.setAttribute('for', 'issuesChk');
addIssueLabel.classList.add('form-check-label');
addIssueCB.setAttribute('type', 'checkbox');
addIssueCB.setAttribute('id', 'issuesChk');
addIssueCB.setAttribute('value', 'Option 2');
addIssueCB.classList.add('form-check-input');
formGroup2_3.classList.add('form-group', 'col-md-4', 'col-sm-4', 'col-lg-4', 'col-xs-4', 'mb-3');
formCheck3.classList.add('form-check', 'form-check-inline');
addWikiLabel.setAttribute('for', 'wikiChk');
addWikiLabel.classList.add('form-check-label');
addWikiCB.setAttribute('type', 'checkbox');
addWikiCB.setAttribute('id', 'wikiChk');
addWikiCB.setAttribute('value', 'Option 3');
addWikiCB.classList.add('form-check-input');
formGroup3_1.classList.add('form-group');
descriptionLabel.setAttribute('for', 'description');
descriptionTextArea.setAttribute('rows', '3');
descriptionTextArea.classList.add('form-control');
descriptionTextArea.setAttribute('id', 'description');
submitRepoCreate.setAttribute('type', 'button');
submitRepoCreate.setAttribute('data-toggle', 'modal');
submitRepoCreate.setAttribute('data-target', '#submitConfirm');
submitRepoCreate.setAttribute('id', 'submitForm');
submitRepoCreate.classList.add('btn', 'btn-primary');
// Add inner HTML
header.innerHTML = 'Create Repository';
repoNamelabel.innerHTML = 'Repository Name';
homePageURLLabel.innerHTML = 'Home Page URL';
privateLabel.innerHTML = 'Private';
addIssueLabel.innerHTML = 'Allow Adding Issues?';
addWikiLabel.innerHTML = 'Add Wiki?';
descriptionLabel.innerHTML = 'Add some Description for this repository:';
submitRepoCreate.innerHTML = 'Submit';
// Associations
formCheck1.appendChild(privateCB);
formCheck1.appendChild(privateLabel);
formCheck2.appendChild(addIssueCB);
formCheck2.appendChild(addIssueLabel);
formCheck3.appendChild(addWikiCB);
formCheck3.appendChild(addWikiLabel);
formGroup1_1.appendChild(repoNamelabel);
formGroup1_1.appendChild(repoNameTextField);
formGroup1_2.appendChild(homePageURLLabel);
formGroup1_2.appendChild(homePageURLTextField);
formGroup2_1.appendChild(formCheck1);
formGroup2_2.appendChild(formCheck2);
formGroup2_3.appendChild(formCheck3);
formGroup3_1.appendChild(descriptionLabel);
formGroup3_1.appendChild(descriptionTextArea);
formRow1.appendChild(formGroup1_1);
formRow1.appendChild(formGroup1_2);
formRow2.appendChild(formGroup2_1);
formRow2.appendChild(formGroup2_2);
formRow2.appendChild(formGroup2_3);
form.appendChild(formRow1);
form.appendChild(formRow2);
form.appendChild(formGroup3_1);
form.appendChild(submitRepoCreate);
cardBody.appendChild(header);
cardBody.appendChild(form);
createRepoWidget.appendChild(cardBody);
widgets.appendChild(createRepoWidget);
$('#createrepo').insertBefore($('#underWidgetLine'));
this.createRepoWidgetCreated = true;
return createRepoWidget;
}
showEmptyCommandMessage() {
$('#emptyCommandMsgDisplayer').click();
}
populateWidgetWithGithubResponse() {
}
populateRecastData(widgetName, recastResponse) {
// var requestMethod = $config.intentSlugToOperations[widgetName]['requestMethod'];
const operation = $config.intentSlugToOperations[widgetName].populateDataOperation;
@@ -205,7 +66,7 @@ module.exports = class DomManipulator {
populateCreateRepoData(recastResponse) {
const repoNameTextField = document.getElementById('repositoryName');
if (repoNameTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0
&& recastResponse.entities['git-repository']['0'].value) {
&& recastResponse.entities['git-repository']['0'].value) {
const repoName = recastResponse.entities['git-repository']['0'].value;
repoNameTextField.value = repoName;
}
@@ -215,12 +76,12 @@ module.exports = class DomManipulator {
const issueTitleTextField = document.getElementById('issueTitle');
const issueRepositoryTextField = document.getElementById('issueRepository');
if (issueTitleTextField && recastResponse && recastResponse.entities.issue_title && recastResponse.entities.issue_title.length > 0
&& recastResponse.entities.issue_title['0'].value) {
&& recastResponse.entities.issue_title['0'].value) {
const 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) {
&& recastResponse.entities['git-repository']['0'].value) {
const repoName = recastResponse.entities['git-repository']['0'].value;
issueRepositoryTextField.value = repoName;
}
@@ -230,12 +91,12 @@ module.exports = class DomManipulator {
const issueNumberTextField = document.getElementById('issueNumerToClose');
const issueRepositoryTextField = document.getElementById('repoForIssueClose');
if (issueNumberTextField && recastResponse && recastResponse.entities.issue_id && recastResponse.entities.issue_id.length > 0
&& recastResponse.entities.issue_id['0'].value) {
&& recastResponse.entities.issue_id['0'].value) {
const issueNumber = recastResponse.entities.issue_id['0'].value;
issueNumberTextField.value = issueNumber;
}
if (issueRepositoryTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0
&& recastResponse.entities['git-repository']['0'].value) {
&& recastResponse.entities['git-repository']['0'].value) {
const repoName = recastResponse.entities['git-repository']['0'].value;
issueRepositoryTextField.value = repoName;
}
@@ -245,12 +106,12 @@ module.exports = class DomManipulator {
const collaboratorNameTextField = document.getElementById('collaboratorName');
const repoForCollabTextField = document.getElementById('repoForCollab');
if (collaboratorNameTextField && recastResponse && recastResponse.entities.git_collaborator && recastResponse.entities.git_collaborator.length > 0
&& recastResponse.entities.git_collaborator['0'].value) {
&& recastResponse.entities.git_collaborator['0'].value) {
const 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) {
&& recastResponse.entities['git-repository']['0'].value) {
const repoName = recastResponse.entities['git-repository']['0'].value;
repoForCollabTextField.value = repoName;
}
@@ -261,17 +122,17 @@ module.exports = class DomManipulator {
const issueNumberTextField = document.getElementById('issueNumber');
const issueCommentTextArea = document.getElementById('issueComment');
if (repoForIssueCommentTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0
&& recastResponse.entities['git-repository']['0'].value) {
&& recastResponse.entities['git-repository']['0'].value) {
const repoForIssueComment = recastResponse.entities['git-repository']['0'].value;
repoForIssueCommentTextField.value = repoForIssueComment;
}
if (issueNumberTextField && recastResponse && recastResponse.entities.issue_id && recastResponse.entities.issue_id.length > 0
&& recastResponse.entities.issue_id['0'].value) {
&& recastResponse.entities.issue_id['0'].value) {
const issueNumber = recastResponse.entities.issue_id['0'].value;
issueNumberTextField.value = issueNumber;
}
if (issueCommentTextArea && recastResponse && recastResponse.entities.issue_comment && recastResponse.entities.issue_comment.length > 0
&& recastResponse.entities.issue_comment['0'].value) {
&& recastResponse.entities.issue_comment['0'].value) {
const issueComment = recastResponse.entities.issue_comment['0'].value;
issueCommentTextArea.value = issueComment;
}
@@ -281,12 +142,12 @@ module.exports = class DomManipulator {
const issueNumberTextField = document.getElementById('issueNumberForCommentView');
const issueRepositoryTextField = document.getElementById('repoForCommentView');
if (issueNumberTextField && recastResponse && recastResponse.entities.issue_id && recastResponse.entities.issue_id.length > 0
&& recastResponse.entities.issue_id['0'].value) {
&& recastResponse.entities.issue_id['0'].value) {
const issueNumber = recastResponse.entities.issue_id['0'].value;
issueNumberTextField.value = issueNumber;
}
if (issueRepositoryTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0
&& recastResponse.entities['git-repository']['0'].value) {
&& recastResponse.entities['git-repository']['0'].value) {
const repoName = recastResponse.entities['git-repository']['0'].value;
issueRepositoryTextField.value = repoName;
}
@@ -382,9 +243,12 @@ module.exports = class DomManipulator {
return data;
}
addGitOperationHistory(data, type) {
const intent = $(`#${$config.costants.hiddenIntentFieldId}`).val();
const requestMethod = $config.intentSlugToOperations[intent].requestMethod;
addGitOperationHistory(data) {
const intent = data.intent;
let requestMethod = ''
if(intent) {
requestMethod = $config.intentSlugToOperations[intent].requestMethod;
}
const conversations = document.getElementById('conversations');
let table;
let comment;
@@ -401,7 +265,7 @@ module.exports = class DomManipulator {
// Add Attributes
card.classList.add('card', type);
card.classList.add('card');
cardBody.classList.add('card-body');
cardTitle.classList.add('card-title');
closeAnchor.classList.add('close');
@@ -415,18 +279,19 @@ module.exports = class DomManipulator {
closeHeader.innerHTML = 'x';
const x = this.display_ct(0, textMuted);
if (type === 'command') {
if (data.type === 'command') {
// Add content
cardTitle.innerHTML = 'You Said';
cardText.innerHTML = data;
cardText.innerHTML = data.command;
card.classList.add('light-red');
const 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.setAttribute('id', `btnRepeatCommand${data.insertionCounter}`);
repeat.innerHTML = 'Repeat';
cardText.appendChild(repeat);
} else if (type === 'response') {
} else if (data.type === 'response') {
// Add content
cardTitle.innerHTML = 'Server Responded As..';
if (requestMethod == 'post') {
@@ -440,10 +305,13 @@ module.exports = class DomManipulator {
comment = this.createCommentBody(data);
}
}
} else if (requestMethod == 'purge'){
cardTitle.innerHTML = 'Operation Completed!';
cardText.innerHTML = data.command;
}
} else {
cardTitle.innerHTML = 'Server Responded As..';
cardText.innerHTML = `Operation failed with status: ${type}`;
cardText.innerHTML = `Operation failed with status: ${data.status}`;
}
// Associations
@@ -469,6 +337,7 @@ module.exports = class DomManipulator {
return data;
}
// Create table of repositories ==================================================================================================
createRepoTable(data) {
// Create Elements
const table = document.createElement('table');
@@ -555,9 +424,17 @@ module.exports = class DomManipulator {
return table;
}
loadConversations(historyAll) {
if (historyAll) {
historyAll.forEach(element => {
this.addGitOperationHistory(element);
});
}
}
createCommentBody(data) {
const commentPara = document.createElement('p');
const lastComment = githubHelper.getLatestComment(data);
const lastComment = helper.getLatestComment(data);
commentPara.classList.add('card-text');
commentPara.innerHTML = `<strong style='color:black'>COMMENT:</strong> <i>${lastComment}</i>`;
return commentPara;
@@ -582,14 +459,14 @@ module.exports = class DomManipulator {
promise.then((body) => {
$('#op-msg').text($config.intentSlugToOperations[intent].successMessage);
$('#successAlert').removeClass('hide');
self.addGitOperationHistory(body, 'response');
// self.addGitOperationHistory(body, 'response');
// clear intent
$(`#${$config.costants.hiddenIntentFieldId}`).val('');
});
} else {
$('#widgets').children().addClass('hide');
$('#dangerAlert').removeClass('hide');
self.addGitOperationHistory(response.status);
// self.addGitOperationHistory(response.status);
// clear intent
$(`#${$config.costants.hiddenIntentFieldId}`).val('');
}

View File

@@ -1,16 +1,13 @@
const config = require('./config.js');
const GithubHelper = require('./helper.js');
const config = require('../config.js');
const githubHelper = new GithubHelper();
const DomManipulator = require('./dom-ops.js');
import * as domManipulator from './dom-ops.js';
const dom = new domManipulator.DomManipulator();
const dom = new DomManipulator();
const PersistentOps = require('./persistent-ops.js');
const persistentOps = new PersistentOps();
import * as persistent_Ops from './persistent-ops.js';
const persistentOps = new persistent_Ops.PersistentOps();
module.exports = class Github {
export class Github {
constructor() {
this.authorizationToken = `token ${config.gitToken}`;
}
@@ -18,7 +15,7 @@ module.exports = class Github {
getToken(code) {
let token = '';
self = this;
$.getJSON(`http://localhost:9999/authenticate/${code}`, (data) => {
$.getJSON(`https://micobot.herokuapp.com/authenticate/${code}`, (data) => {
console.log(data.token);
token = data.token;
// set cookie here

View File

@@ -1,11 +1,10 @@
const Github = require('./github-ops.js');
import * as githubOps from './github-ops.js';
const $github = new githubOps.Github();
const $github = new Github();
const PersistentOps = require('./persistent-ops.js');
import * as persistent_Ops from './persistent-ops.js';
const persistentOps = new persistent_Ops.PersistentOps();
const persistentOps = new PersistentOps();
module.exports = class Microbot {
export class Microbot {
constructor(clientId, clientSecret) {
// TODO move to config or env variables
this.clientId = 'f6f649a1fe2dfea082ba';

View File

@@ -0,0 +1,182 @@
import { createStore } from 'redux';
const state = require('./../data/history');
import * as helperOps from '../helpers/helper';
const helper = new helperOps.Helper();
import * as domManipulator from './dom-ops';
const dom = new domManipulator.DomManipulator();
const $config = require('../config');
export class PersistentOps {
setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
const expires = `expires=${d.toUTCString()}`;
document.cookie = `${cname}=${cvalue};${expires};path=/`;
}
getCookie(cname) {
const name = `${cname}=`;
const decodedCookie = decodeURIComponent(document.cookie);
const ca = decodedCookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return '';
}
}
function mbReducer(currentState, action) {
var nextState = {
}
let newHistory = {};
switch (action.type) {
case 'ADD_REPO':
// let command = document.getElementById('command').value;
// nextState = window.localStorage.getItem('currentState') ? JSON.parse(window.localStorage.getItem('currentState')) : currentState;
// newHistory.command = command;
// newHistory.type = 'command';
// // newHistory.intent = 'commandbot'
// newHistory.insertionCounter = ++nextState.insertionCounter;
// if(nextState.queries) {
// nextState.queries = [ ...nextState.queries, newHistory ];
// } else {
// nextState.queries = [ newHistory ];
// }
// window.localStorage.setItem('currentState', JSON.stringify(nextState));
// return nextState;
break;
case 'ADD_COLLAB':
// let command = document.getElementById('command').value;
// nextState = window.localStorage.getItem('currentState') ? JSON.parse(window.localStorage.getItem('currentState')) : currentState;
// newHistory.command = command;
// newHistory.type = 'command';
// // newHistory.intent = 'commandbot'
// newHistory.insertionCounter = ++nextState.insertionCounter;
// if(nextState.queries) {
// nextState.queries = [ ...nextState.queries, newHistory ];
// } else {
// nextState.queries = [ newHistory ];
// }
// window.localStorage.setItem('currentState', JSON.stringify(nextState));
// return nextState;
break;
case 'ADD_ISSUE':
// let command = document.getElementById('command').value;
// nextState = window.localStorage.getItem('currentState') ? JSON.parse(window.localStorage.getItem('currentState')) : currentState;
// newHistory.command = command;
// newHistory.type = 'command';
// // newHistory.intent = 'commandbot'
// newHistory.insertionCounter = ++nextState.insertionCounter;
// if(nextState.queries) {
// nextState.queries = [ ...nextState.queries, newHistory ];
// } else {
// nextState.queries = [ newHistory ];
// }
// window.localStorage.setItem('currentState', JSON.stringify(nextState));
// return nextState;
break;
case 'ADD_COMMENT':
// let command = document.getElementById('command').value;
// nextState = window.localStorage.getItem('currentState') ? JSON.parse(window.localStorage.getItem('currentState')) : currentState;
// newHistory.command = command;
// newHistory.type = 'command';
// // newHistory.intent = 'commandbot'
// newHistory.insertionCounter = ++nextState.insertionCounter;
// if(nextState.queries) {
// nextState.queries = [ ...nextState.queries, newHistory ];
// } else {
// nextState.queries = [ newHistory ];
// }
// window.localStorage.setItem('currentState', JSON.stringify(nextState));
// return nextState;
break;
case 'CLOSE_ISSUE':
// let command = document.getElementById('command').value;
// nextState = window.localStorage.getItem('currentState') ? JSON.parse(window.localStorage.getItem('currentState')) : currentState;
// newHistory.command = command;
// newHistory.type = 'command';
// // newHistory.intent = 'commandbot'
// newHistory.insertionCounter = ++nextState.insertionCounter;
// if(nextState.queries) {
// nextState.queries = [ ...nextState.queries, newHistory ];
// } else {
// nextState.queries = [ newHistory ];
// }
// window.localStorage.setItem('currentState', JSON.stringify(nextState));
// return nextState;
break;
case 'SHOW_LAST_COMMENT':
// let command = document.getElementById('command').value;
// nextState = window.localStorage.getItem('currentState') ? JSON.parse(window.localStorage.getItem('currentState')) : currentState;
// newHistory.command = command;
// newHistory.type = 'command';
// // newHistory.intent = 'commandbot'
// newHistory.insertionCounter = ++nextState.insertionCounter;
// if(nextState.queries) {
// nextState.queries = [ ...nextState.queries, newHistory ];
// } else {
// nextState.queries = [ newHistory ];
// }
// window.localStorage.setItem('currentState', JSON.stringify(nextState));
// return nextState;
break;
case 'VIEW_REPO':
// let command = document.getElementById('command').value;
// nextState = window.localStorage.getItem('currentState') ? JSON.parse(window.localStorage.getItem('currentState')) : currentState;
// newHistory.command = command;
// newHistory.type = 'command';
// // newHistory.intent = 'commandbot'
// newHistory.insertionCounter = ++nextState.insertionCounter;
// if(nextState.queries) {
// nextState.queries = [ ...nextState.queries, newHistory ];
// } else {
// nextState.queries = [ newHistory ];
// }
// window.localStorage.setItem('currentState', JSON.stringify(nextState));
// return nextState;
break;
case 'ADD_QUERY':
let command = document.getElementById('command').value;
nextState = window.localStorage.getItem('currentState') ? JSON.parse(window.localStorage.getItem('currentState')) : currentState;
newHistory.command = command;
newHistory.type = 'command';
// newHistory.intent = 'commandbot'
newHistory.insertionCounter = ++nextState.insertionCounter;
if(nextState.queries) {
nextState.queries = [ ...nextState.queries, newHistory ];
} else {
nextState.queries = [ newHistory ];
}
window.localStorage.setItem('currentState', JSON.stringify(nextState));
return nextState;
break;
case 'CLEAR_HISTORY':
nextState = helper.clone(state);
newHistory.command = $config.intentSlugToOperations.resethistory.cardMsg;
newHistory.type = 'response';
newHistory.insertionCounter = 0;
newHistory.intent = $('#' + $config.costants.hiddenIntentFieldId).val();
nextState.messages = [newHistory];
window.localStorage.setItem('currentState', JSON.stringify(nextState));
return nextState;
default:
return currentState;
}
}
function renderCards() {
$('#conversations').empty();
let historyAll = helper.concatenateAndSort(store.getState());
dom.loadConversations(historyAll);
}
export const store = createStore(mbReducer, state)
store.subscribe(renderCards);

View File

@@ -0,0 +1,50 @@
import * as PersistentOps from './persistent-ops';
const store = PersistentOps.store;
const $config = require('../config');
import * as domManipulator from './dom-ops';
const dom = new domManipulator.DomManipulator();
const $actions = $config.actions;
export class Recast {
constructor() {
this.recastToken = $config.recasttoken;
this.requestUrl = "https://api.recast.ai/v2/request";
}
getAndCallProcessIntent(command, text) {
self = this;
var url = this.requestUrl + "?text=" + command;
var bodyRelevant = '';
var intent = '';
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json; charset=utf-8",
"Authorization": "Token " + this.recastToken
},
data: text
})
.then(function(response) {
response.json().then(function(body) {
bodyRelevant = body.results;
intent = bodyRelevant.intents[0]["slug"];
$('#' + $config.costants.hiddenIntentFieldId).val(intent)
if(intent !== undefined) {
dom.displayIntentBox(intent);
if(intent == 'resethistory') {
store.dispatch($actions.action_clear_history);
return;
}
dom.showWidget(intent);
dom.populateRecastData(intent, bodyRelevant);
store.dispatch($actions.action_add_query);
}
return intent;
});
})
.catch(function(error) {
console.error('Fetch Error =\n', error);
});
};
}

View File

@@ -1,7 +0,0 @@
const state = {
repos: [],
issues:[],
collaborators:[]
}
module.exports = state;

23
src/js/views/addcollab.js Normal file
View File

@@ -0,0 +1,23 @@
export const addcollab = `<div id="addcollab" class="card hide widget good">
<!-- <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">
</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 ....">
</div>
</div>
<div class="form-group">
<label for="comment">Comment:</label>
<textarea class="form-control" rows="3" id="comment"></textarea>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitAddCollab" data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>`

View File

@@ -0,0 +1,23 @@
export const addissuecomment = `<div id="addissuecomment" class="card hide widget good">
<!-- <img class="card-img-top" src="..." alt="Card image cap"> -->
<div class="card-body">
<h5 class="card-title">Add Comment</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="repoForIssueComment">Repository Name</label>
<input type="text" class="form-control" id="repoForIssueComment" placeholder="Repository Name....">
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="issueNumber">Issue Number</label>
<input type="text" class="form-control" id="issueNumber" placeholder="Issue To Comment On...">
</div>
</div>
<div class="form-group">
<label for="issueComment">Comment:</label>
<textarea class="form-control" rows="3" id="issueComment"></textarea>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitAddComment" data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>`

View File

@@ -0,0 +1,18 @@
export const closeissue = `<div id="closeissue" class="card hide widget good">
<div class="card-body">
<h5 class="card-title">Close 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="repoForIssueClose">Repository Name</label>
<input type="text" class="form-control" id="repoForIssueClose" placeholder="Repository Name....">
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="issueNumerToClose">Issue To Close</label>
<input type="text" class="form-control" id="issueNumerToClose" placeholder="Specify issue number...">
</div>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitCloseIssue" data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>`

View File

@@ -0,0 +1,33 @@
export const createissue = `<div id="createissue" class="card hide widget good">
<!-- <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">
</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">
</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>`

View File

@@ -0,0 +1,43 @@
export const createrepo = `<div id="createrepo" class="card hide widget good">
<div class="card-body">
<div class="card-title">Create Repository</div>
<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="repositoryName">Repository Name</label>
<input type="text" id="repositoryName" placeholder="Repository Name... " class="form-control">
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="homePageURL">Home Page URL</label>
<input type="text" id="homePageURL" placeholder="Home Page URL... " class="form-control">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3 col-sm-3 col-lg-3 col-xs-3 mb-3">
<div class="form-check form-check-inline">
<input type="checkbox" id="privateRepoChk" value="Option 1" class="form-check-input">
<label for="privateRepoChk" class="form-check-label">Private</label>
</div>
</div>
<div class="form-group col-md-4 col-sm-4 col-lg-4 col-xs-4 mb-3">
<div class="form-check form-check-inline">
<input type="checkbox" id="issuesChk" value="Option 2" class="form-check-input">
<label for="issuesChk" class="form-check-label">Allow Adding Issues?</label>
</div>
</div>
<div class="form-group col-md-4 col-sm-4 col-lg-4 col-xs-4 mb-3">
<div class="form-check form-check-inline">
<input type="checkbox" id="wikiChk" value="Option 3" class="form-check-input">
<label for="wikiChk" class="form-check-label">Add Wiki?</label>
</div>
</div>
</div>
<div class="form-group">
<label for="description">Add some Description for this repository:</label>
<textarea rows="3" class="form-control" id="description"></textarea>
</div>
<button type="button" data-toggle="modal" data-target="#submitConfirm" id="submitForm" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
`

View File

@@ -0,0 +1,18 @@
export const displaylastcomment = `<div id="displaylastcomment" class="card hide widget good">
<div class="card-body">
<h5 class="card-title">Display Last Comment</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="repoForCommentView">Repository Name</label>
<input type="text" class="form-control" id="repoForCommentView" placeholder="Repository Name....">
</div>
<div class="form-group col-md-6 col-sm-6 col-lg-6 col-xs-6 mb-3">
<label for="issueNumberForCommentView">Issue To Close</label>
<input type="text" class="form-control" id="issueNumberForCommentView" placeholder="Specify issue number...">
</div>
</div>
<button class="btn btn-primary" type="button" data-toggle="modal" data-dismiss="modal" id="btnSubmitCommentView" data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>`

13
src/js/views/viewrepos.js Normal file
View File

@@ -0,0 +1,13 @@
export const viewrepos = `<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="btnSubmitViewRepo" data-target="#submitConfirm">Submit</button>
</form>
</div>
</div>`

View File

@@ -355,6 +355,10 @@ ADDITIONS
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}
.light-red {
background-color: #f3d98c;
}
@keyframes spin {
0% { transform: rotate(0deg); }