diff --git a/.eslintrc.json b/.eslintrc.json
index 6f67564..0f9f106 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -1,3 +1,77 @@
{
- "extends": "airbnb-base"
+ "env": {
+ "browser": true,
+ "commonjs": true,
+ "es6": true
+ },
+ "extends": [
+ "eslint:recommended"
+ ],
+ "parserOptions": {
+ "sourceType": "module"
+ },
+ "plugins": [
+ "dollar-sign",
+ "jquery"
+ ],
+ "rules": {
+ "indent": [
+ "error"
+ ],
+ "linebreak-style": [
+ "error",
+ "windows"
+ ],
+ "quotes": [
+ "error",
+ "double"
+ ],
+ "semi": [
+ "error",
+ "always"
+ ],
+ "jquery/no-ajax": 2,
+ "jquery/no-animate": 2,
+ "jquery/no-attr": 2,
+ "jquery/no-bind": 2,
+ "jquery/no-class": 2,
+ "jquery/no-clone": 2,
+ "jquery/no-closest": 2,
+ "jquery/no-css": 2,
+ "jquery/no-data": 2,
+ "jquery/no-deferred": 2,
+ "jquery/no-delegate": 2,
+ "jquery/no-each": 2,
+ "jquery/no-fade": 2,
+ "jquery/no-filter": 2,
+ "jquery/no-find": 2,
+ "jquery/no-global-eval": 2,
+ "jquery/no-has": 2,
+ "jquery/no-hide": 2,
+ "jquery/no-html": 2,
+ "jquery/no-in-array": 2,
+ "jquery/no-is": 2,
+ "jquery/no-map": 2,
+ "jquery/no-merge": 2,
+ "jquery/no-param": 2,
+ "jquery/no-parent": 2,
+ "jquery/no-parents": 2,
+ "jquery/no-parse-html": 2,
+ "jquery/no-prop": 2,
+ "jquery/no-proxy": 2,
+ "jquery/no-serialize": 2,
+ "jquery/no-show": 2,
+ "jquery/no-sizzle": 2,
+ "jquery/no-slide": 2,
+ "jquery/no-text": 2,
+ "jquery/no-toggle": 2,
+ "jquery/no-trigger": 2,
+ "jquery/no-trim": 2,
+ "jquery/no-val": 2,
+ "jquery/no-wrap": 2,
+ "dollar-sign/dollar-sign": [
+ 2,
+ "ignoreProperties"
+ ]
+ }
}
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 184a999..96b57af 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3801,6 +3801,11 @@
}
}
},
+ "eslint-plugin-dollar-sign": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-dollar-sign/-/eslint-plugin-dollar-sign-1.0.1.tgz",
+ "integrity": "sha512-uOJ3Fyq+3Hf73YXBZBTvqCjUo12lfMYtI4WHhjCKWK4LuSd2p/WO46cW5sPs50o+dupOypJJsScIPA7TaNtx3g=="
+ },
"eslint-plugin-import": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.13.0.tgz",
@@ -3900,6 +3905,11 @@
}
}
},
+ "eslint-plugin-jquery": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-jquery/-/eslint-plugin-jquery-1.3.1.tgz",
+ "integrity": "sha512-ymFQ6K7BXPg9z6ZWVGnaRObsxS5rZ1w6Cwgg4GW6lWaMBS5XO2rW34ddlOEccG6DANQyNrpt70nVSuaqKb0uzQ=="
+ },
"eslint-restricted-globals": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz",
diff --git a/package.json b/package.json
index 29995e1..5a481da 100644
--- a/package.json
+++ b/package.json
@@ -36,6 +36,8 @@
"bootswatch": "^4.1.1",
"browser-sync": "^2.24.5",
"css-loader": "^1.0.0",
+ "eslint-plugin-dollar-sign": "^1.0.1",
+ "eslint-plugin-jquery": "^1.3.1",
"express": "^4.16.3",
"github-api": "^3.0.0",
"gulp": "^4.0.0",
diff --git a/public/index.html b/public/index.html
index f762e00..eb5dfb3 100644
--- a/public/index.html
+++ b/public/index.html
@@ -174,7 +174,7 @@
×
-
+
Please type some relevant words in the command box.
+
+
+
diff --git a/src/js/app-event-triggers.js b/src/js/app-event-triggers.js
index f2ca0e6..b6f5169 100644
--- a/src/js/app-event-triggers.js
+++ b/src/js/app-event-triggers.js
@@ -1,20 +1,18 @@
-import * as recastOps from './services/recast-ops.js';
+import * as recastOps from './services/recast-ops';
+
+import * as domManipulator from './services/dom-ops';
+
+import * as microbotOps from './services/microbot-ops';
+
+import { Helper } from './helpers/helper';
+
const recastclient = new recastOps.Recast();
-
-import * as domManipulator from './services/dom-ops.js';
const dom = new domManipulator.DomManipulator();
-
-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 $config = require('./config.js');
-
$(document).ready(() => {
// console.log('test');
app.setToken();
@@ -33,7 +31,7 @@ $(document).ready(() => {
});
$('#command').keyup((e) => {
const code = (e.keyCode ? e.keyCode : e.which);
- if (code == 13) {
+ if (code === 13) {
$('#widgets').children().addClass('hide');
$('#successAlert').addClass('hide');
$('#dangetAlert').addClass('hide');
@@ -43,27 +41,37 @@ $(document).ready(() => {
const text = { text: command };
recastclient.getAndCallProcessIntent(command, text);
} else {
- dom.showEmptyCommandMessage();
+ dom.showEmptyCommandMessage('Please type some relevant words in the command box.');
}
}
});
- $('#btnFavorites').click(function() {
+ $('#btnFavorites').click(() => {
});
- $('#btnClearCommand').click(function() {
+ $('#btnClearCommand').click(() => {
$('#command').val('');
$('#command').focus();
});
- $('#btnFireCommand').click(function() {
- hitEnter()
+ function hitEnter(command) {
+ const commandInputField = $('#command');
+ if (command) commandInputField.val(command);
+ const e = jQuery.Event('keyup');
+ e.which = 13;
+ commandInputField.focus();
+ commandInputField.trigger(e);
+ }
+ $('#btnFireCommand').click(() => {
+ hitEnter();
});
$('#btnSubmitConfirm').on('click', () => {
$('#submitConfirm').removeClass('hide');
});
$('#submitGitData').on('click', () => {
const data = dom.getDataFromFormAsJSON();
- const intent = $(`#${$config.costants.hiddenIntentFieldId}`).val();
+ const intent = $(`#${$config.constants.hiddenIntentFieldId}`).val();
if (intent) {
+ data.intent = intent;
+ // store.dispatch($)
const operation = $config.intentSlugToOperations[intent].githubOperation;
app[operation](data);
}
@@ -81,31 +89,23 @@ $(document).ready(() => {
line.hide('slow', () => { line.remove(); });
});
$('#conversations').on('click', '.btn.btn-info.float-right', function () {
- let parentText = $(this).closest('.card-text').text();
+ const parentText = $(this).closest('.card-text').text();
const command = parentText.substring(0, parentText.indexOf('Repeat'));
- hitEnter(command)
+ 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';
- });
- let localHistory = JSON.parse(window.localStorage.getItem('currentState'));
+ // $('#git_bridge').on('click', () => {
+ // window.location.href = 'https://github.com/login/oauth/authorize?scope=user:email:repo&client_id=f6f649a1fe2dfea082ba';
+ // });
+ const 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);
diff --git a/src/js/config.js b/src/js/config.js
index 5e1dd63..185187c 100644
--- a/src/js/config.js
+++ b/src/js/config.js
@@ -1,6 +1,6 @@
module.exports = {
gitToken: '96ead73c54cbbf023a73ee57af145b205d460851',
- recasttoken: "26021d055040a9d9f1ad48476efab4a0",
+ recasttoken: '26021d055040a9d9f1ad48476efab4a0',
intentSlugToOperations: {
createrepo: {
requestMethod: 'post',
@@ -13,6 +13,8 @@ module.exports = {
cardMsg: 'Requested Repository has been added and is available at ',
cardDataUrl: 'html_url',
cardDataName: 'name',
+ action: { type: 'ADD_REPO' },
+ response_action: { type: 'ADD_REPO_RESPONSE' },
},
createissue: {
requestMethod: 'post',
@@ -25,6 +27,8 @@ module.exports = {
cardMsg: 'Issue Created as requested, issue details available at ',
cardDataUrl: 'html_url',
cardDataName: 'title',
+ action: { type: 'ADD_ISSUE' },
+ response_action: { type: 'ADD_ISSUE_RESPONSE' },
},
closeissue: {
requestMethod: 'post',
@@ -37,6 +41,8 @@ module.exports = {
cardMsg: 'Issue Closed as requested, closed issue available at: ',
cardDataUrl: 'html_url',
cardDataName: 'title',
+ action: { type: 'CLOSE_ISSUE' },
+ response_action: { type: 'CLOSE_ISSUE_RESPONSE' },
},
addissuecomment: {
requestMethod: 'post',
@@ -49,6 +55,8 @@ module.exports = {
cardMsg: 'Comment Added as Requested, view here: ',
cardDataUrl: 'html_url',
cardDataName: 'title',
+ action: { type: 'ADD_COMMENT' },
+ response_action: { type: 'ADD_ISSUE_COMMENT_RESPONSE' },
},
displaylastcomment: {
requestMethod: 'get',
@@ -61,6 +69,8 @@ module.exports = {
cardMsg: 'Please find requested comment below: ',
cardDataUrl: 'html_url',
cardDataName: 'title',
+ action: { type: 'SHOW_LAST_COMMENT' },
+ response_action: { type: 'SHOW_LAST_COMMENT_RESPONSE' },
},
addcollab: {
requestMethod: 'post',
@@ -73,6 +83,8 @@ module.exports = {
cardMsg: 'Collaborator added, details available at ',
cardDataUrl: 'html_url',
cardDataName: 'invitee,login',
+ action: { type: 'ADD_COLLAB' },
+ response_action: { type: 'ADD_COLLAB_RESPONSE' },
},
viewrepos: {
requestMethod: 'get',
@@ -85,26 +97,22 @@ module.exports = {
cardMsg: 'Repository Details available below: ',
cardDataUrl: 'html_url',
cardDataName: 'invitee,login',
+ action: { type: 'VIEW_REPO' },
+ response_action: { type: 'VIEW_REPO_RESPONSE' },
},
resethistory: {
requestMethod: 'purge',
intentMessage: 'Clear all Operations History',
successMessage: 'Purged!',
- cardMsg: 'Purged history of all Operations and Commands!'
+ cardMsg: 'Purged history of all Operations and Commands!',
+ action: { type: 'CLEAR_HISTORY' },
+ response_action: { type: 'CLEAR_HISTORY_RESPONSE' },
+ },
+ addquery: {
+ action: { type: 'ADD_QUERY' },
},
},
- costants: {
+ constants: {
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' }
- }
};
diff --git a/src/js/controllers/controller.js b/src/js/controllers/controller.js
new file mode 100644
index 0000000..4442a66
--- /dev/null
+++ b/src/js/controllers/controller.js
@@ -0,0 +1,3 @@
+export const controller = function() {
+
+}
\ No newline at end of file
diff --git a/src/js/data/history.js b/src/js/data/history.js
index 776c599..9d173a4 100644
--- a/src/js/data/history.js
+++ b/src/js/data/history.js
@@ -1,14 +1,14 @@
const state = {
createrepo: [],
- createissue:[],
- closeissue:[],
+ createissue: [],
+ closeissue: [],
addissuecomment: [],
displaylastcomment: [],
addcollab: [],
viewrepos: [],
queries: [],
messages: [],
- insertionCounter: 0
-}
+ insertionCounter: 0,
+};
-module.exports = state;
\ No newline at end of file
+module.exports = state;
diff --git a/src/js/helpers/helper.js b/src/js/helpers/helper.js
index 7c01146..dbaa8a9 100644
--- a/src/js/helpers/helper.js
+++ b/src/js/helpers/helper.js
@@ -1,36 +1,31 @@
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;
+ getLatestComment(comments) {
+ if (comments && comments.length > 0) { return comments[comments.length - 1].body; }
}
- }
- clone(obj) {
- if (null == obj || "object" != typeof obj) return obj;
- var copy = Object.assign({}, obj);
- return copy;
- }
+ compareByProperty(property) {
+ return function (a, b) {
+ if (a[property] < b[property]) return -1;
+ if (a[property] > b[property]) return 1;
+ return 0;
+ };
+ }
- concatenateAndSort(history) {
+ clone(obj) {
+ if (obj == null || typeof obj !== "object") return obj;
+ const 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]);
- }
+ let historyAll = [];
+ for (const property in history) {
+ if (history.hasOwnProperty(property) && Array.isArray(history[property])) {
+ historyAll = historyAll.concat(history[property]);
+ }
+ }
+ historyAll.sort(this.compareByProperty("insertionCounter"));
+ return historyAll;
}
- historyAll.sort(this.compareByProperty('insertionCounter'))
- return historyAll;
- }
-
-
-};
+}
diff --git a/src/js/services/dom-ops.js b/src/js/services/dom-ops.js
index 8f955f8..45c009c 100644
--- a/src/js/services/dom-ops.js
+++ b/src/js/services/dom-ops.js
@@ -1,497 +1,503 @@
-const $config = require('../config.js');
-import * as helperOps from '../helpers/helper.js';
+import * as helperOps from "../helpers/helper.js";
+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";
+import { PersistentOps } from "./persistent-ops.js";
+import { store } from "./persistent-ops.js";
+
+const $config = require("../config.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';
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) {
- 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);
+ constructor() {
+ this.createRepoWidgetCreated = false;
+ this.commandCardCounter = 1;
+ this.map = {
+ addcollab,
+ addissuecomment,
+ closeissue,
+ createissue,
+ createrepo,
+ displaylastcomment,
+ viewrepos,
+ };
}
- }
- displayIntentBox(intent) {
- const intentBox = document.getElementById('intentBox');
- if (!this.isVisible(intentBox)) {
- intentBox.classList.remove('hide');
- }
- $('#intentName').text(`${$config.intentSlugToOperations[intent].intentMessage} [slug: ${intent}].`);
- }
-
- showEmptyCommandMessage() {
- $('#emptyCommandMsgDisplayer').click();
- }
-
- populateRecastData(widgetName, recastResponse) {
- // var requestMethod = $config.intentSlugToOperations[widgetName]['requestMethod'];
- const operation = $config.intentSlugToOperations[widgetName].populateDataOperation;
- if (typeof this[operation] === 'function') {
- this[operation](recastResponse);
- }
- }
-
- 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) {
- const repoName = recastResponse.entities['git-repository']['0'].value;
- repoNameTextField.value = repoName;
- }
- }
-
- populateCreateIssueData(recastResponse) {
- 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) {
- 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) {
- const repoName = recastResponse.entities['git-repository']['0'].value;
- issueRepositoryTextField.value = repoName;
- }
- }
-
- populateCloseIssueData(recastResponse) {
- 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) {
- 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) {
- const repoName = recastResponse.entities['git-repository']['0'].value;
- issueRepositoryTextField.value = repoName;
- }
- }
-
- populateAddCollaboratorData(recastResponse) {
- 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) {
- 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) {
- const repoName = recastResponse.entities['git-repository']['0'].value;
- repoForCollabTextField.value = repoName;
- }
- }
-
- populateAddCommentData(recastResponse) {
- const repoForIssueCommentTextField = document.getElementById('repoForIssueComment');
- 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) {
- 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) {
- 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) {
- const issueComment = recastResponse.entities.issue_comment['0'].value;
- issueCommentTextArea.value = issueComment;
- }
- }
-
- populateDisplayCommentData(recastResponse) {
- 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) {
- 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) {
- const repoName = recastResponse.entities['git-repository']['0'].value;
- issueRepositoryTextField.value = repoName;
- }
- }
-
- isVisible(element) {
- return element ? !element.classList.contains('hide') : false;
- }
-
- getDataFromFormAsJSON() {
- let data = {};
- const intent = $(`#${$config.costants.hiddenIntentFieldId}`).val();
- const requestMethod = $config.intentSlugToOperations[intent].requestMethod;
- if (intent) {
- const operation = $config.intentSlugToOperations[intent].getDataOperation;
- if (typeof this[operation] === 'function') {
- data = this[operation]();
- }
- }
- return data;
- }
-
- getCreateRepoJson() {
- const data = {};
- const request = {};
- if (this.isVisible(document.getElementById('createrepo'))) {
- request.name = document.getElementById('repositoryName').value;
- request.description = document.getElementById('description').value;
- request.homepage = document.getElementById('homePageURL').value;
- request.private = document.getElementById('privateRepoChk').checked;
- request.has_issues = document.getElementById('issuesChk').checked;
- request.has_wiki = document.getElementById('wikiChk').checked;
- }
- data.request = request;
- return data;
- }
-
- getCreateIssueJson() {
- const data = {};
- data.urlParams = {};
- const 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;
- }
-
- getCloseIssueJson() {
- const data = {};
- data.urlParams = {};
- if (this.isVisible(document.getElementById('closeissue'))) {
- data.urlParams.issueId = document.getElementById('issueNumerToClose').value;
- data.urlParams.repoName = document.getElementById('repoForIssueClose').value;
- }
- return data;
- }
-
- getAddCollaboratorJson() {
- const 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;
- }
-
- getAddCommentJson() {
- const data = {};
- data.urlParams = {};
- const request = {};
- if (this.isVisible(document.getElementById('addissuecomment'))) {
- request.body = document.getElementById('issueComment').value;
- data.urlParams.issueId = document.getElementById('issueNumber').value;
- data.urlParams.repoName = document.getElementById('repoForIssueComment').value;
- }
- data.request = request;
- return data;
- }
-
- getDisplayCommentJson() {
- const data = {};
- data.urlParams = {};
- if (this.isVisible(document.getElementById('displaylastcomment'))) {
- data.urlParams.issueId = document.getElementById('issueNumberForCommentView').value;
- data.urlParams.repoName = document.getElementById('repoForCommentView').value;
- }
- return data;
- }
-
- addGitOperationHistory(data) {
- const intent = data.intent;
- let requestMethod = ''
- if(intent) {
- requestMethod = $config.intentSlugToOperations[intent].requestMethod;
- }
- const conversations = document.getElementById('conversations');
- let table;
- let comment;
- // Create Elements
- const card = document.createElement('div');
- const cardBody = document.createElement('div');
- const cardTitle = document.createElement('h5');
- const closeAnchor = document.createElement('a');
- const closeHeader = document.createElement('h6');
- const cardText = document.createElement('p');
- const cardFooter = document.createElement('div');
- const textMuted = document.createElement('small');
- const underCardLine = document.createElement('div');
-
-
- // Add Attributes
- card.classList.add('card');
- cardBody.classList.add('card-body');
- cardTitle.classList.add('card-title');
- closeAnchor.classList.add('close');
- // closeAnchor.setAttribute('href', '#');
- cardText.classList.add('card-text');
- cardFooter.classList.add('card-footer');
- textMuted.classList.add('text-muted');
- underCardLine.classList.add('line');
-
- // Add content
- closeHeader.innerHTML = 'x';
-
- const x = this.display_ct(0, textMuted);
- if (data.type === 'command') {
- // Add content
- cardTitle.innerHTML = 'You Said';
- 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${data.insertionCounter}`);
- repeat.innerHTML = 'Repeat';
- cardText.appendChild(repeat);
- } else if (data.type === 'response') {
- // Add content
- cardTitle.innerHTML = 'Server Responded As..';
- if (requestMethod == 'post') {
- cardText.innerHTML = `${$config.intentSlugToOperations[intent].cardMsg}${this.getVariable(data, $config.intentSlugToOperations[intent].cardDataName)}`;
- } else if (requestMethod == 'get') {
- cardText.innerHTML = $config.intentSlugToOperations[intent].cardMsg;
- if (data && data.length && data.length > 0) {
- if (intent === 'viewrepos') {
- table = this.createRepoTable(data);
- } else if (intent === 'displaylastcomment') {
- comment = this.createCommentBody(data);
- }
+ showWidget(intent) {
+ let widget = document.getElementById(intent);
+ if (widget) {
+ if (!this.isVisible(widget)) {
+ widget.classList.remove("hide");
+ $("#underWidgetLine").removeClass("hide");
+ }
+ } else {
+ const 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);
}
- } else if (requestMethod == 'purge'){
- cardTitle.innerHTML = 'Operation Completed!';
- cardText.innerHTML = data.command;
- }
- } else {
- cardTitle.innerHTML = 'Server Responded As..';
- cardText.innerHTML = `Operation failed with status: ${data.status}`;
}
- // Associations
- closeAnchor.appendChild(closeHeader);
- cardTitle.appendChild(closeAnchor);
- cardBody.appendChild(cardTitle);
- cardBody.appendChild(cardText);
- if (comment) { cardBody.appendChild(comment); }
- 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) {
- const arr = commaSeparatedValue.split(',');
- for (let i = 0; i < arr.length; i++) {
- data = data[arr[i]];
+ displayIntentBox(intent) {
+ const intentBox = document.getElementById("intentBox");
+ if (!this.isVisible(intentBox)) {
+ intentBox.classList.remove("hide");
+ }
+ $("#intentName").text(`${$config.intentSlugToOperations[intent].intentMessage} [slug: ${intent}].`);
}
- return data;
- }
- // Create table of repositories ==================================================================================================
- createRepoTable(data) {
+ showEmptyCommandMessage(message) {
+ $("#randomModal").text(message);
+ $("#emptyCommandMsgDisplayer").click();
+ }
+
+ populateRecastData(widgetName, recastResponse) {
+ // var requestMethod = $config.intentSlugToOperations[widgetName]['requestMethod'];
+ const operation = $config.intentSlugToOperations[widgetName].populateDataOperation;
+ if (typeof this[operation] === "function") {
+ this[operation](recastResponse);
+ }
+ }
+
+ 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) {
+ const repoName = recastResponse.entities["git-repository"]["0"].value;
+ repoNameTextField.value = repoName;
+ }
+ }
+
+ populateCreateIssueData(recastResponse) {
+ 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) {
+ 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) {
+ const repoName = recastResponse.entities["git-repository"]["0"].value;
+ issueRepositoryTextField.value = repoName;
+ }
+ }
+
+ populateCloseIssueData(recastResponse) {
+ 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) {
+ 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) {
+ const repoName = recastResponse.entities["git-repository"]["0"].value;
+ issueRepositoryTextField.value = repoName;
+ }
+ }
+
+ populateAddCollaboratorData(recastResponse) {
+ 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) {
+ 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) {
+ const repoName = recastResponse.entities["git-repository"]["0"].value;
+ repoForCollabTextField.value = repoName;
+ }
+ }
+
+ populateAddCommentData(recastResponse) {
+ const repoForIssueCommentTextField = document.getElementById("repoForIssueComment");
+ 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) {
+ 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) {
+ 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) {
+ const issueComment = recastResponse.entities.issue_comment["0"].value;
+ issueCommentTextArea.value = issueComment;
+ }
+ }
+
+ populateDisplayCommentData(recastResponse) {
+ 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) {
+ 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) {
+ const repoName = recastResponse.entities["git-repository"]["0"].value;
+ issueRepositoryTextField.value = repoName;
+ }
+ }
+
+ isVisible(element) {
+ return element ? !element.classList.contains("hide") : false;
+ }
+
+ getDataFromFormAsJSON() {
+ let data = {};
+ const intent = $(`#${$config.constants.hiddenIntentFieldId}`).val();
+ const requestMethod = $config.intentSlugToOperations[intent].requestMethod;
+ if (intent) {
+ const operation = $config.intentSlugToOperations[intent].getDataOperation;
+ if (typeof this[operation] === "function") {
+ data = this[operation]();
+ }
+ }
+ return data;
+ }
+
+ getCreateRepoJson() {
+ const data = {};
+ const request = {};
+ if (this.isVisible(document.getElementById("createrepo"))) {
+ request.name = document.getElementById("repositoryName").value;
+ request.description = document.getElementById("description").value;
+ request.homepage = document.getElementById("homePageURL").value;
+ request.private = document.getElementById("privateRepoChk").checked;
+ request.has_issues = document.getElementById("issuesChk").checked;
+ request.has_wiki = document.getElementById("wikiChk").checked;
+ }
+ data.request = request;
+ return data;
+ }
+
+ getCreateIssueJson() {
+ const data = {};
+ data.urlParams = {};
+ const 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;
+ }
+
+ getCloseIssueJson() {
+ const data = {};
+ data.urlParams = {};
+ if (this.isVisible(document.getElementById("closeissue"))) {
+ data.urlParams.issueId = document.getElementById("issueNumerToClose").value;
+ data.urlParams.repoName = document.getElementById("repoForIssueClose").value;
+ }
+ return data;
+ }
+
+ getAddCollaboratorJson() {
+ const 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;
+ }
+
+ getAddCommentJson() {
+ const data = {};
+ data.urlParams = {};
+ const request = {};
+ if (this.isVisible(document.getElementById("addissuecomment"))) {
+ request.body = document.getElementById("issueComment").value;
+ data.urlParams.issueId = document.getElementById("issueNumber").value;
+ data.urlParams.repoName = document.getElementById("repoForIssueComment").value;
+ }
+ data.request = request;
+ return data;
+ }
+
+ getDisplayCommentJson() {
+ const data = {};
+ data.urlParams = {};
+ if (this.isVisible(document.getElementById("displaylastcomment"))) {
+ data.urlParams.issueId = document.getElementById("issueNumberForCommentView").value;
+ data.urlParams.repoName = document.getElementById("repoForCommentView").value;
+ }
+ return data;
+ }
+
+ addGitOperationHistory(data) {
+ const intent = data.intent;
+ let requestMethod = "";
+ if (intent) {
+ requestMethod = $config.intentSlugToOperations[intent].requestMethod;
+ }
+ const conversations = document.getElementById("conversations");
+ let table;
+ let comment;
+ // Create Elements
+ const card = document.createElement("div");
+ const cardBody = document.createElement("div");
+ const cardTitle = document.createElement("h5");
+ const closeAnchor = document.createElement("a");
+ const closeHeader = document.createElement("h6");
+ const cardText = document.createElement("p");
+ const cardFooter = document.createElement("div");
+ const textMuted = document.createElement("small");
+ const underCardLine = document.createElement("div");
+
+
+ // Add Attributes
+ card.classList.add("card");
+ cardBody.classList.add("card-body");
+ cardTitle.classList.add("card-title");
+ closeAnchor.classList.add("close");
+ // closeAnchor.setAttribute('href', '#');
+ cardText.classList.add("card-text");
+ cardFooter.classList.add("card-footer");
+ textMuted.classList.add("text-muted");
+ underCardLine.classList.add("line");
+
+ // Add content
+ closeHeader.innerHTML = "x";
+
+ const x = this.display_ct(0, textMuted);
+ if (data.type === "command") {
+ // Add content
+ cardTitle.innerHTML = "You Said";
+ 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${data.insertionCounter}`);
+ repeat.innerHTML = "Repeat";
+ cardText.appendChild(repeat);
+ } else if (data.type === "response") {
+ // Add content
+ cardTitle.innerHTML = "Server Responded As..";
+ if (requestMethod == "post") {
+ cardText.innerHTML = `${$config.intentSlugToOperations[intent].cardMsg}${this.getVariable(data, $config.intentSlugToOperations[intent].cardDataName)}`;
+ } else if (requestMethod == "get") {
+ cardText.innerHTML = $config.intentSlugToOperations[intent].cardMsg;
+ if (data && data.length && data.length > 0) {
+ if (intent === "viewrepos") {
+ table = this.createRepoTable(data);
+ } else if (intent === "displaylastcomment") {
+ 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: ${data.status}`;
+ }
+
+ // Associations
+ closeAnchor.appendChild(closeHeader);
+ cardTitle.appendChild(closeAnchor);
+ cardBody.appendChild(cardTitle);
+ cardBody.appendChild(cardText);
+ if (comment) { cardBody.appendChild(comment); }
+ 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) {
+ const arr = commaSeparatedValue.split(",");
+ for (let i = 0; i < arr.length; i++) {
+ data = data[arr[i]];
+ }
+ return data;
+ }
+
+ // Create table of repositories ==================================================================================================
+ createRepoTable(data) {
// Create Elements
- const table = document.createElement('table');
- const thead = document.createElement('thead');
- const tr_head = document.createElement('tr');
- const th_1 = document.createElement('th');
- const th_2 = document.createElement('th');
- const th_3 = document.createElement('th');
- const th_4 = document.createElement('th');
- const th_5 = document.createElement('th');
- const th_6 = document.createElement('th');
- const th_7 = document.createElement('th');
+ const table = document.createElement("table");
+ const thead = document.createElement("thead");
+ const tr_head = document.createElement("tr");
+ const th_1 = document.createElement("th");
+ const th_2 = document.createElement("th");
+ const th_3 = document.createElement("th");
+ const th_4 = document.createElement("th");
+ const th_5 = document.createElement("th");
+ const th_6 = document.createElement("th");
+ const 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 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';
+ // 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);
+ // 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 (let i = 0; i < data.length; i++) {
- const currentRepo = data[i];
- // Create Elements
- const tbody = document.createElement('tbody');
- const tr_body = document.createElement('tr');
- const th_vertical = document.createElement('th');
- const td_1 = document.createElement('td');
- const td_2 = document.createElement('td');
- const td_3 = document.createElement('td');
- const td_4 = document.createElement('td');
- const td_5 = document.createElement('td');
- const td_6 = document.createElement('td');
+ for (let i = 0; i < data.length; i++) {
+ const currentRepo = data[i];
+ // Create Elements
+ const tbody = document.createElement("tbody");
+ const tr_body = document.createElement("tr");
+ const th_vertical = document.createElement("th");
+ const td_1 = document.createElement("td");
+ const td_2 = document.createElement("td");
+ const td_3 = document.createElement("td");
+ const td_4 = document.createElement("td");
+ const td_5 = document.createElement("td");
+ const td_6 = document.createElement("td");
- // Add Attributes
- th_vertical.setAttribute('scope', 'row');
- tr_body.setAttribute('id', `repoRow${i}`);
+ // 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 = `${currentRepo.id}`;
- td_3.innerHTML = currentRepo.created_at;
- td_4.innerHTML = `${currentRepo.owner.login}`;
- td_5.innerHTML = `View`;
- td_6.innerHTML = `Delete`;
+ // Add Inner HTML
+ th_vertical.innerHTML = i + 1;
+ td_1.innerHTML = currentRepo.name;
+ td_2.innerHTML = `${currentRepo.id}`;
+ td_3.innerHTML = currentRepo.created_at;
+ td_4.innerHTML = `${currentRepo.owner.login}`;
+ td_5.innerHTML = `View`;
+ td_6.innerHTML = `Delete`;
- // 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);
+ // 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;
}
- return table;
- }
-
- loadConversations(historyAll) {
- if (historyAll) {
- historyAll.forEach(element => {
- this.addGitOperationHistory(element);
- });
+ loadConversations(historyAll) {
+ if (historyAll) {
+ historyAll.forEach((element) => {
+ this.addGitOperationHistory(element);
+ });
+ }
}
- }
- createCommentBody(data) {
- const commentPara = document.createElement('p');
- const lastComment = helper.getLatestComment(data);
- commentPara.classList.add('card-text');
- commentPara.innerHTML = `COMMENT: ${lastComment}`;
- return commentPara;
- }
+ createCommentBody(data) {
+ const commentPara = document.createElement("p");
+ const lastComment = helper.getLatestComment(data);
+ commentPara.classList.add("card-text");
+ commentPara.innerHTML = `COMMENT: ${lastComment}`;
+ return commentPara;
+ }
- concealCodeInUrl() {
- window.location = 'http://localhost:8080';
- }
+ concealCodeInUrl() {
+ window.location = "http://localhost:8080";
+ }
- toggleModals(response) {
- const self = this;
- const promise = response.json();
- const intent = $(`#${$config.costants.hiddenIntentFieldId}`).val();
- $('#submitConfirm').addClass('hide');
- $('#btnCancelConfirm').click();
- $('.modal-backdrop').removeClass('modal-backdrop');
- $('#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((body) => {
- $('#op-msg').text($config.intentSlugToOperations[intent].successMessage);
- $('#successAlert').removeClass('hide');
- // self.addGitOperationHistory(body, 'response');
+ toggleModals(response) {
+ const self = this;
+ const promise = response.json();
+ const intent = $(`#${$config.constants.hiddenIntentFieldId}`).val();
+ $("#submitConfirm").addClass("hide");
+ $("#btnCancelConfirm").click();
+ $(".modal-backdrop").removeClass("modal-backdrop");
+ $("#underWidgetLine").addClass("hide");
+ $("#intentBox").addClass("hide");
+ $("#widgets").children().addClass("hide");
+ if (response && response.status && (response.status === 201 || response.status === 200 || response.status === 204)) {
+ $("#successAlert").removeClass("hide");
+ promise.then((body) => {
+ $("#op-msg").text($config.intentSlugToOperations[intent].successMessage);
+ $("#successAlert").removeClass("hide");
+ const action = $config.intentSlugToOperations[intent].response_action;
+ body.intent = intent;
+ action.payload = body;
+ store.dispatch(action);
+ // self.addGitOperationHistory(body, 'response');
+ });
+ } else {
+ $("#dangerAlert").removeClass("hide");
+ // self.addGitOperationHistory(response.status);
+ }
// clear intent
- $(`#${$config.costants.hiddenIntentFieldId}`).val('');
- });
- } else {
- $('#widgets').children().addClass('hide');
- $('#dangerAlert').removeClass('hide');
- // self.addGitOperationHistory(response.status);
- // clear intent
- $(`#${$config.costants.hiddenIntentFieldId}`).val('');
+ $(`#${$config.constants.hiddenIntentFieldId}`).val("");
}
- }
- display_ct(start, element) {
- this.start = start;
- this.element = element;
- const days = Math.floor(this.start / 86400);
- const hours = Math.floor((this.start - (days * 86400)) / 3600);
- const minutes = Math.floor((this.start - (days * 86400) - (hours * 3600)) / 60);
- const secs = Math.floor((this.start - (days * 86400) - (hours * 3600) - (minutes * 60)));
- let 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;
+ display_ct(start, element) {
+ this.start = start;
+ this.element = element;
+ const days = Math.floor(this.start / 86400);
+ const hours = Math.floor((this.start - (days * 86400)) / 3600);
+ const minutes = Math.floor((this.start - (days * 86400) - (hours * 3600)) / 60);
+ const secs = Math.floor((this.start - (days * 86400) - (hours * 3600) - (minutes * 60)));
+ let 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 )
- }
-};
+ }
+}
diff --git a/src/js/services/github-ops.js b/src/js/services/github-ops.js
index 907f108..4f987fc 100644
--- a/src/js/services/github-ops.js
+++ b/src/js/services/github-ops.js
@@ -1,320 +1,321 @@
-const config = require('../config.js');
+import * as domManipulator from "./dom-ops.js";
+
+import * as persistent_Ops from "./persistent-ops.js";
+
+const config = require("../config.js");
-import * as domManipulator from './dom-ops.js';
const dom = new domManipulator.DomManipulator();
-
-import * as persistent_Ops from './persistent-ops.js';
const persistentOps = new persistent_Ops.PersistentOps();
export class Github {
- constructor() {
- this.authorizationToken = `token ${config.gitToken}`;
- }
+ constructor() {
+ this.authorizationToken = `token ${config.gitToken}`;
+ }
- getToken(code) {
- let token = '';
- self = this;
- $.getJSON(`https://micobot.herokuapp.com/authenticate/${code}`, (data) => {
- console.log(data.token);
- token = data.token;
- // set cookie here
- persistentOps.setCookie('gitToken', token, 30);
- // self.authorizationToken = "token " + persistentOps.getCookie('gitToken');
- dom.concealCodeInUrl();
- });
- return token;
- }
-
- getCurrentUser() {
- let repositories = '';
- const url = 'https://api.github.com/user/';
- fetch(url, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- },
- })
- .then((response) => {
- response.json().then((body) => {
- repositories = body;
- console.log(repositories);
- return repositories;
+ getToken(code) {
+ let token = "";
+ self = this;
+ $.getJSON(`https://micobot.herokuapp.com/authenticate/${code}`, (data) => {
+ console.log(data.token);
+ token = data.token;
+ // set cookie here
+ persistentOps.setCookie("gitToken", token, 30);
+ // self.authorizationToken = "token " + persistentOps.getCookie('gitToken');
+ dom.concealCodeInUrl();
});
- dom.toggleModals(response);
- })
- .catch(error => console.error('Fetch Error =\n', error));
- return repositories;
- }
+ return token;
+ }
- authenticate() {
+ getCurrentUser() {
+ let repositories = "";
+ const url = "https://api.github.com/user/";
+ fetch(url, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ },
+ })
+ .then((response) => {
+ response.json().then((body) => {
+ repositories = body;
+ console.log(repositories);
+ return repositories;
+ });
+ dom.toggleModals(response);
+ })
+ .catch(error => console.error("Fetch Error =\n", error));
+ return repositories;
+ }
- }
+ authenticate() {
- viewRepositories() {
- const repositories = '';
- const url = 'https://api.github.com/user/repos';
- fetch(url, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- })
- .then((response) => {
- // 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;
- }
+ }
- createRepository(newRepoJson) {
- const url = 'https://api.github.com/user/repos';
- const responsePromise = '';
- fetch(url, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- body: JSON.stringify(newRepoJson),
- })
- .then((response) => {
- dom.toggleModals(response);
- })
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ viewRepositories() {
+ const repositories = "";
+ const url = "https://api.github.com/user/repos";
+ fetch(url, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ })
+ .then((response) => {
+ // 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;
+ }
- updateRepository(updateRepoJson, repoName) {
- repoName = 'Hello-World3';
- const url = `https://api.github.com/repos/mohiit1502/${repoName}`;
- fetch(url, {
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- body: JSON.stringify(updateRepoJson),
- })
- .then(response => response.json())
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ createRepository(newRepoJson) {
+ const url = "https://api.github.com/user/repos";
+ const responsePromise = "";
+ fetch(url, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ body: JSON.stringify(newRepoJson),
+ })
+ .then((response) => {
+ dom.toggleModals(response);
+ })
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- deleteRepository(repoName) {
- repoName = 'Hello-World2';
- const url = `https://api.github.com/repos/mohiit1502/${repoName}`;
- fetch(url, {
- method: 'DELETE',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- })
- .then(response => response.json())
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ updateRepository(updateRepoJson, repoName) {
+ repoName = "Hello-World3";
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}`;
+ fetch(url, {
+ method: "PATCH",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ body: JSON.stringify(updateRepoJson),
+ })
+ .then(response => response.json())
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- createIssue(newIssueJson, repoName) {
- const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues`;
- fetch(url, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- body: JSON.stringify(newIssueJson),
- })
- .then((response) => {
- dom.toggleModals(response);
- })
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ deleteRepository(repoName) {
+ repoName = "Hello-World2";
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}`;
+ fetch(url, {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ })
+ .then(response => response.json())
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- updateIssue(updateIssueJson, repoName, issueNumber) {
- repoName = 'stack_route_prj7';
- issueNumber = 2;
- const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;
- fetch(url, {
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- body: JSON.stringify(updateIssueJson),
- })
- .then(response => response.json())
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ createIssue(newIssueJson, repoName) {
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues`;
+ fetch(url, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ body: JSON.stringify(newIssueJson),
+ })
+ .then((response) => {
+ dom.toggleModals(response);
+ })
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- closeIssue(closeIssueJson, repoName, issueNumber) {
- const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;
- fetch(url, {
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- body: JSON.stringify(closeIssueJson),
- })
- .then((response) => {
- dom.toggleModals(response);
- })
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ updateIssue(updateIssueJson, repoName, issueNumber) {
+ repoName = "stack_route_prj7";
+ issueNumber = 2;
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;
+ fetch(url, {
+ method: "PATCH",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ body: JSON.stringify(updateIssueJson),
+ })
+ .then(response => response.json())
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- reopenIssue(reopenIssueJson, repoName, issueNumber) {
- repoName = 'stack_route_prj7';
- issueNumber = 2;
- const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;
- fetch(url, {
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- body: JSON.stringify(reopenIssueJson),
- })
- .then(response => response.json())
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ closeIssue(closeIssueJson, repoName, issueNumber) {
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;
+ fetch(url, {
+ method: "PATCH",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ body: JSON.stringify(closeIssueJson),
+ })
+ .then((response) => {
+ dom.toggleModals(response);
+ })
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- displayIssue(repoName, issueNumber) {
- repoName = 'stack_route_prj7';
- issueNumber = 2;
- const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;
- let issues = '';
- fetch(url, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- })
- .then((response) => {
- response.json().then((body) => {
- issues = body;
- console.log(issues);
- return issues;
- });
- })
- .catch(error => console.error('Fetch Error =\n', error));
- return issues;
- }
+ reopenIssue(reopenIssueJson, repoName, issueNumber) {
+ repoName = "stack_route_prj7";
+ issueNumber = 2;
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;
+ fetch(url, {
+ method: "PATCH",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ body: JSON.stringify(reopenIssueJson),
+ })
+ .then(response => response.json())
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- addIssueComment(commentBodyJson, repoName, issueId) {
- const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueId}/comments`;
- fetch(url, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- body: JSON.stringify(commentBodyJson),
- })
- .then((response) => {
- dom.toggleModals(response);
- })
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ displayIssue(repoName, issueNumber) {
+ repoName = "stack_route_prj7";
+ issueNumber = 2;
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;
+ let issues = "";
+ fetch(url, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ })
+ .then((response) => {
+ response.json().then((body) => {
+ issues = body;
+ console.log(issues);
+ return issues;
+ });
+ })
+ .catch(error => console.error("Fetch Error =\n", error));
+ return issues;
+ }
- displayLastComment(repoName, issueNumber) {
- const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}/comments`;
- const comments = [];
- const latestComment = '';
- fetch(url, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- })
- .then((response) => {
- dom.toggleModals(response);
- // response.json().then(function(body){
- // comments = body;
- // latestComment = githubHelper.getLatestComment(comments);
- // console.log(comments);
- // console.log(latestComment);
- // });
- })
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ addIssueComment(commentBodyJson, repoName, issueId) {
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueId}/comments`;
+ fetch(url, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ body: JSON.stringify(commentBodyJson),
+ })
+ .then((response) => {
+ dom.toggleModals(response);
+ })
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- displayIssuesForUser() {
- const url = 'https://api.github.com/user/issues';
- fetch(url, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- })
- .then(response => response.json())
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ displayLastComment(repoName, issueNumber) {
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}/comments`;
+ const comments = [];
+ const latestComment = "";
+ fetch(url, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ })
+ .then((response) => {
+ dom.toggleModals(response);
+ // response.json().then(function(body){
+ // comments = body;
+ // latestComment = githubHelper.getLatestComment(comments);
+ // console.log(comments);
+ // console.log(latestComment);
+ // });
+ })
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- displayIssuesOnRepo() {
- repoName = 'stack_route_prj7';
- issueNumber = 2;
- const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/`;
- fetch(url, {
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8',
- Authorization: this.authorizationToken,
- },
- body: JSON.stringify(updateIssueJson),
- })
- .then(response => response.json())
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ displayIssuesForUser() {
+ const url = "https://api.github.com/user/issues";
+ fetch(url, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ })
+ .then(response => response.json())
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- addCollaborator(repoName, collaborator) {
- repoName = 'stack_route_prj7';
- collaborator = 'swat1508';
- const url = `https://api.github.com/repos/mohiit1502/${repoName}/collaborators/${collaborator}`;
- fetch(url, {
- method: 'PUT',
- headers: {
- 'Content-Type': 'application/json',
- Authorization: this.authorizationToken,
- },
- })
- .then((response) => {
- dom.toggleModals(response);
- })
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ displayIssuesOnRepo() {
+ repoName = "stack_route_prj7";
+ issueNumber = 2;
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/`;
+ fetch(url, {
+ method: "PATCH",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ Authorization: this.authorizationToken,
+ },
+ body: JSON.stringify(updateIssueJson),
+ })
+ .then(response => response.json())
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- removeCollaborator(repoName, collaborator) {
- repoName = 'stack_route_prj7';
- collaborator = 'swat1508';
- const url = `https://api.github.com/repos/mohiit1502/${repoName}/collaborators/${collaborator}`;
- fetch(url, {
- method: 'DELETE',
- headers: {
- 'Content-Type': 'application/json',
- Authorization: this.authorizationToken,
- },
- })
- .then(response => response.json())
- .catch(error => console.error('Fetch Error =\n', error));
- }
+ addCollaborator(repoName, collaborator) {
+ repoName = "stack_route_prj7";
+ collaborator = "swat1508";
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}/collaborators/${collaborator}`;
+ fetch(url, {
+ method: "PUT",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: this.authorizationToken,
+ },
+ })
+ .then((response) => {
+ dom.toggleModals(response);
+ })
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- createUser(newuserJson) {
+ removeCollaborator(repoName, collaborator) {
+ repoName = "stack_route_prj7";
+ collaborator = "swat1508";
+ const url = `https://api.github.com/repos/mohiit1502/${repoName}/collaborators/${collaborator}`;
+ fetch(url, {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: this.authorizationToken,
+ },
+ })
+ .then(response => response.json())
+ .catch(error => console.error("Fetch Error =\n", error));
+ }
- }
+ createUser(newuserJson) {
- updateUser(updateUserJson) {
+ }
- }
+ updateUser(updateUserJson) {
- deleteUser(userId) {
+ }
- }
-};
+ deleteUser(userId) {
+
+ }
+}
diff --git a/src/js/services/microbot-ops.js b/src/js/services/microbot-ops.js
index 67e7948..251e18f 100644
--- a/src/js/services/microbot-ops.js
+++ b/src/js/services/microbot-ops.js
@@ -1,35 +1,40 @@
-import * as githubOps from './github-ops.js';
-const $github = new githubOps.Github();
+import * as githubOps from "./github-ops.js";
-import * as persistent_Ops from './persistent-ops.js';
+import * as persistent_Ops from "./persistent-ops.js";
+
+const $github = new githubOps.Github();
const persistentOps = new persistent_Ops.PersistentOps();
+const store = persistent_Ops.store;
+
+const $config = require("../config.js");
export class Microbot {
- constructor(clientId, clientSecret) {
+ constructor(clientId, clientSecret) {
// TODO move to config or env variables
- this.clientId = 'f6f649a1fe2dfea082ba';
- this.clientSecret = '7e9a33d05ffdb36b4a498140bb9bb06d62de4f0e';
- }
+ this.clientId = "f6f649a1fe2dfea082ba";
+ this.clientSecret = "7e9a33d05ffdb36b4a498140bb9bb06d62de4f0e";
+ }
- getToken(code) {
- $github.getToken(code);
- }
+ getToken(code) {
+ $github.getToken(code);
+ }
- setToken() {
- $github.authorizationToken = `token ${persistentOps.getCookie('gitToken')}`;
- }
+ setToken() {
+ $github.authorizationToken = `token ${persistentOps.getCookie("gitToken")}`;
+ }
- getCurrentUser() {
- $github.getCurrentUser();
- }
+ getCurrentUser() {
+ $github.getCurrentUser();
+ }
- viewRepositories() {
- return $github.viewRepositories();
- }
+ viewRepositories() {
+ return $github.viewRepositories();
+ }
- createRepository(requestData) {
- const requestJson = requestData.request;
- $github.createRepository(requestJson);
+ createRepository(requestData) {
+ const requestJson = requestData.request;
+ store.dispatch($config.intentSlugToOperations.createrepo.action);
+ $github.createRepository(requestJson);
// $github.createRepository({
// "name": "new-test-js-git-api-repo",
// "description": "This is your first repository",
@@ -38,89 +43,89 @@ export class Microbot {
// "has_issues": true,
// "has_wiki": true
// })
- }
+ }
- updateRepository(repoName, repoType) {
- $github.authenticate();
- $github.updateRepository({
- name: 'Hello-World4',
- description: 'This is your test description',
- homepage: 'https://github.com',
- private: false,
- has_issues: true,
- has_projects: true,
- has_wiki: true,
- });
- }
+ updateRepository(repoName, repoType) {
+ $github.authenticate();
+ $github.updateRepository({
+ name: "Hello-World4",
+ description: "This is your test description",
+ homepage: "https://github.com",
+ private: false,
+ has_issues: true,
+ has_projects: true,
+ has_wiki: true,
+ });
+ }
- deleteRepository() {
- $github.deleteRepository();
- }
+ deleteRepository() {
+ $github.deleteRepository();
+ }
- createIssue(requestData) {
- const requestJson = requestData.request;
- const repoName = requestData.urlParams.repoName;
- $github.createIssue(requestJson, repoName);
- }
+ createIssue(requestData) {
+ const requestJson = requestData.request;
+ const repoName = requestData.urlParams.repoName;
+ $github.createIssue(requestJson, repoName);
+ }
- updateIssue() {
- $github.updateIssue({
- title: 'Found a bug - title updated',
- body: 'This is the updated problem description.',
- assignees: [
- 'mohiit1502',
- ],
- milestone: 1,
- state: 'open',
- labels: [
- 'bug', 'issue',
- ],
- });
- }
+ updateIssue() {
+ $github.updateIssue({
+ title: "Found a bug - title updated",
+ body: "This is the updated problem description.",
+ assignees: [
+ "mohiit1502",
+ ],
+ milestone: 1,
+ state: "open",
+ labels: [
+ "bug", "issue",
+ ],
+ });
+ }
- closeIssue(requestData) {
- const repoName = requestData.urlParams.repoName;
- const issueId = requestData.urlParams.issueId;
- $github.closeIssue({
- state: 'close',
- }, repoName, issueId);
- }
+ closeIssue(requestData) {
+ const repoName = requestData.urlParams.repoName;
+ const issueId = requestData.urlParams.issueId;
+ $github.closeIssue({
+ state: "close",
+ }, repoName, issueId);
+ }
- displayIssue() {
- return $github.displayIssue();
- }
+ displayIssue() {
+ return $github.displayIssue();
+ }
- reopenIssue() {
- $github.reopenIssue({
- milestone: 1,
- state: 'open',
- });
- }
+ reopenIssue() {
+ $github.reopenIssue({
+ milestone: 1,
+ state: "open",
+ });
+ }
- addIssueComment(requestData) {
- const requestJson = requestData.request;
- const repoName = requestData.urlParams.repoName;
- const issueId = requestData.urlParams.issueId;
- $github.addIssueComment(requestJson, repoName, issueId);
- }
+ addIssueComment(requestData) {
+ const requestJson = requestData.request;
+ const repoName = requestData.urlParams.repoName;
+ const issueId = requestData.urlParams.issueId;
+ $github.addIssueComment(requestJson, repoName, issueId);
+ }
- displayLastComment(requestData) {
- const repoName = requestData.urlParams.repoName;
- const issueId = requestData.urlParams.issueId;
- return $github.displayLastComment(repoName, issueId);
- }
+ displayLastComment(requestData) {
+ const repoName = requestData.urlParams.repoName;
+ const issueId = requestData.urlParams.issueId;
+ return $github.displayLastComment(repoName, issueId);
+ }
- addCollaborator(requestData) {
- const repoName = requestData.urlParams.repoName;
- const collaborator = requestData.urlParams.collaborator;
- $github.addCollaborator(repoName, collaborator);
- }
+ addCollaborator(requestData) {
+ const repoName = requestData.urlParams.repoName;
+ const collaborator = requestData.urlParams.collaborator;
+ $github.addCollaborator(repoName, collaborator);
+ }
- removeCollaborator() {
- $github.removeCollaborator();
- }
+ removeCollaborator() {
+ $github.removeCollaborator();
+ }
- callAppropriate(intent) {
+ callAppropriate(intent) {
- }
-};
+ }
+}
diff --git a/src/js/services/persistent-ops.js b/src/js/services/persistent-ops.js
index c3659aa..04ed694 100644
--- a/src/js/services/persistent-ops.js
+++ b/src/js/services/persistent-ops.js
@@ -1,182 +1,281 @@
-import { createStore } from 'redux';
-const state = require('./../data/history');
-import * as helperOps from '../helpers/helper';
+import { createStore } from "redux";
+import * as helperOps from "../helpers/helper";
+import * as domManipulator from "./dom-ops";
+
+const state = require("./../data/history");
+
const helper = new helperOps.Helper();
-import * as domManipulator from './dom-ops';
const dom = new domManipulator.DomManipulator();
-const $config = require('../config');
+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);
- }
+ 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=/`;
}
- return '';
- }
+ 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;
+ let nextState = {
+ };
+ let newHistory = {};
+ let response = {};
+ switch (action.type) {
+ case "ADD_REPO_RESPONSE":
+ response = action.payload;
+ nextState = window.localStorage.getItem("currentState") ? JSON.parse(window.localStorage.getItem("currentState")) : currentState;
+ newHistory = response;
+ newHistory.type = "response";
+ newHistory.insertionCounter = ++nextState.insertionCounter;
+ if (nextState.messages) {
+ nextState.messages = [...nextState.messages, newHistory];
+ } else {
+ nextState.messages = [newHistory];
+ }
+ window.localStorage.setItem("currentState", JSON.stringify(nextState));
+ return nextState;
+ break;
+ case "ADD_ISSUE_RESPONSE":
+ response = action.payload;
+ nextState = window.localStorage.getItem("currentState") ? JSON.parse(window.localStorage.getItem("currentState")) : currentState;
+ newHistory = response;
+ newHistory.type = "response";
+ newHistory.insertionCounter = ++nextState.insertionCounter;
+ if (nextState.messages) {
+ nextState.messages = [...nextState.messages, newHistory];
+ } else {
+ nextState.messages = [newHistory];
+ }
+ window.localStorage.setItem("currentState", JSON.stringify(nextState));
+ return nextState;
+ break;
+ case "ADD_COLLAB_RESPONSE":
+ response = action.payload;
+ nextState = window.localStorage.getItem("currentState") ? JSON.parse(window.localStorage.getItem("currentState")) : currentState;
+ newHistory = response;
+ newHistory.type = "response";
+ newHistory.insertionCounter = ++nextState.insertionCounter;
+ if (nextState.messages) {
+ nextState.messages = [...nextState.messages, newHistory];
+ } else {
+ nextState.messages = [newHistory];
+ }
+ window.localStorage.setItem("currentState", JSON.stringify(nextState));
+ return nextState;
+ break;
+ case "ADD_COMMENT_RESPONSE":
+ response = action.payload;
+ nextState = window.localStorage.getItem("currentState") ? JSON.parse(window.localStorage.getItem("currentState")) : currentState;
+ newHistory = response;
+ newHistory.type = "response";
+ newHistory.insertionCounter = ++nextState.insertionCounter;
+ if (nextState.messages) {
+ nextState.messages = [...nextState.messages, newHistory];
+ } else {
+ nextState.messages = [newHistory];
+ }
+ window.localStorage.setItem("currentState", JSON.stringify(nextState));
+ return nextState;
+ break;
+ case "CLOSE_ISSUE_RESPONSE":
+ response = action.payload;
+ nextState = window.localStorage.getItem("currentState") ? JSON.parse(window.localStorage.getItem("currentState")) : currentState;
+ newHistory = response;
+ newHistory.type = "response";
+ newHistory.insertionCounter = ++nextState.insertionCounter;
+ if (nextState.messages) {
+ nextState.messages = [...nextState.messages, newHistory];
+ } else {
+ nextState.messages = [newHistory];
+ }
+ window.localStorage.setItem("currentState", JSON.stringify(nextState));
+ return nextState;
+ break;
+ case "SHOW_LAST_COMMENT_RESPONSE":
+ response = action.payload;
+ nextState = window.localStorage.getItem("currentState") ? JSON.parse(window.localStorage.getItem("currentState")) : currentState;
+ newHistory = response;
+ newHistory.type = "response";
+ newHistory.insertionCounter = ++nextState.insertionCounter;
+ if (nextState.messages) {
+ nextState.messages = [...nextState.messages, newHistory];
+ } else {
+ nextState.messages = [newHistory];
+ }
+ window.localStorage.setItem("currentState", JSON.stringify(nextState));
+ return nextState;
+ break;
+ case "VIEW_REPO_RESPONSE":
+ response = action.payload;
+ nextState = window.localStorage.getItem("currentState") ? JSON.parse(window.localStorage.getItem("currentState")) : currentState;
+ newHistory = response;
+ newHistory.type = "response";
+ newHistory.insertionCounter = ++nextState.insertionCounter;
+ if (nextState.messages) {
+ nextState.messages = [...nextState.messages, newHistory];
+ } else {
+ nextState.messages = [newHistory];
+ }
+ window.localStorage.setItem("currentState", JSON.stringify(nextState));
+ return nextState;
+ break;
+ 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":
+ const 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.constants.hiddenIntentFieldId}`).val();
+ nextState.messages = [newHistory];
+ window.localStorage.setItem("currentState", JSON.stringify(nextState));
+ return nextState;
default:
- return currentState;
- }
+ return currentState;
+ }
}
function renderCards() {
- $('#conversations').empty();
- let historyAll = helper.concatenateAndSort(store.getState());
- dom.loadConversations(historyAll);
+ $("#conversations").empty();
+ const historyAll = helper.concatenateAndSort(store.getState());
+ dom.loadConversations(historyAll);
}
-export const store = createStore(mbReducer, state)
-store.subscribe(renderCards);
\ No newline at end of file
+export const store = createStore(mbReducer, state);
+store.subscribe(renderCards);
diff --git a/src/js/services/recast-ops.js b/src/js/services/recast-ops.js
index a8db9ae..2e5f9c2 100644
--- a/src/js/services/recast-ops.js
+++ b/src/js/services/recast-ops.js
@@ -1,10 +1,10 @@
-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();
+import * as PersistentOps from "./persistent-ops";
+import * as domManipulator from "./dom-ops";
-const $actions = $config.actions;
+const store = PersistentOps.store;
+const $config = require("../config");
+
+const dom = new domManipulator.DomManipulator();
export class Recast {
constructor() {
@@ -14,37 +14,41 @@ export class Recast {
getAndCallProcessIntent(command, text) {
self = this;
- var url = this.requestUrl + "?text=" + command;
- var bodyRelevant = '';
- var intent = '';
+ const url = `${this.requestUrl}?text=${command}`;
+ let bodyRelevant = "";
+ let intent = "";
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json; charset=utf-8",
- "Authorization": "Token " + this.recastToken
+ Authorization: `Token ${this.recastToken}`,
},
- data: text
+ 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;
+ .then((response) => {
+ response.json().then((body) => {
+ bodyRelevant = body.results;
+ intent = bodyRelevant.intents[0] ? bodyRelevant.intents[0].slug : "";
+ if (intent !== undefined && intent !== "") {
+ if (!Object.keys($config.intentSlugToOperations).includes(intent)) {
+ dom.showEmptyCommandMessage("Intent is either not Identified or is not supported, please try again with a different text.");
+ return;
+ }
+ $(`#${$config.constants.hiddenIntentFieldId}`).val(intent);
+ dom.displayIntentBox(intent);
+ if (intent == "resethistory") {
+ store.dispatch($config.intentSlugToOperations.resethistory.action);
+ return;
+ }
+ dom.showWidget(intent);
+ dom.populateRecastData(intent, bodyRelevant);
+ store.dispatch($config.intentSlugToOperations.addquery.action);
}
- dom.showWidget(intent);
- dom.populateRecastData(intent, bodyRelevant);
- store.dispatch($actions.action_add_query);
- }
- return intent;
+ return intent;
+ });
+ })
+ .catch((error) => {
+ console.error("Fetch Error =\n", error);
});
- })
- .catch(function(error) {
- console.error('Fetch Error =\n', error);
- });
- };
-}
\ No newline at end of file
+ }
+}
diff --git a/src/js/views/addcollab.js b/src/js/views/addcollab.js
index b59334c..276bf1a 100644
--- a/src/js/views/addcollab.js
+++ b/src/js/views/addcollab.js
@@ -20,4 +20,4 @@ export const addcollab = `
-`
\ No newline at end of file
+`;
diff --git a/src/js/views/addissuecomment.js b/src/js/views/addissuecomment.js
index f8c39b5..dc35f6e 100644
--- a/src/js/views/addissuecomment.js
+++ b/src/js/views/addissuecomment.js
@@ -20,4 +20,4 @@ export const addissuecomment = `
-`
\ No newline at end of file
+`;
diff --git a/src/js/views/closeissue.js b/src/js/views/closeissue.js
index cb725b4..891760f 100644
--- a/src/js/views/closeissue.js
+++ b/src/js/views/closeissue.js
@@ -15,4 +15,4 @@ export const closeissue = `
-`
\ No newline at end of file
+`;
diff --git a/src/js/views/createissue.js b/src/js/views/createissue.js
index 0459deb..3412aeb 100644
--- a/src/js/views/createissue.js
+++ b/src/js/views/createissue.js
@@ -30,4 +30,4 @@ export const createissue = `
-`
\ No newline at end of file
+`;
diff --git a/src/js/views/createrepo.js b/src/js/views/createrepo.js
index 95f0d35..cfad95a 100644
--- a/src/js/views/createrepo.js
+++ b/src/js/views/createrepo.js
@@ -40,4 +40,4 @@ export const createrepo = `
-`
\ No newline at end of file
+`;
diff --git a/src/js/views/displaylastcomment.js b/src/js/views/displaylastcomment.js
index e0dab70..42a066b 100644
--- a/src/js/views/displaylastcomment.js
+++ b/src/js/views/displaylastcomment.js
@@ -15,4 +15,4 @@ export const displaylastcomment = `
-`
\ No newline at end of file
+`;
diff --git a/src/js/views/viewrepos.js b/src/js/views/viewrepos.js
index f746fd9..9959478 100644
--- a/src/js/views/viewrepos.js
+++ b/src/js/views/viewrepos.js
@@ -10,4 +10,4 @@ export const viewrepos = `
-`
\ No newline at end of file
+`;
diff --git a/src/styles/scss/base.scss b/src/styles/scss/base.scss
index b7be146..b191b4e 100644
--- a/src/styles/scss/base.scss
+++ b/src/styles/scss/base.scss
@@ -360,6 +360,21 @@ ADDITIONS
background-color: #f3d98c;
}
+.featureRequest {
+ background-color : #007bff;
+ color: white;
+ font-size: 1.5em;
+ padding: 10px 20px;
+ border-radius: 30px;
+ border-color: #f3912c;
+}
+
+ #featureRequest {
+ position: fixed;
+ bottom: 10px;
+ right: 10px;
+ }
+
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
@@ -391,7 +406,7 @@ ADDITIONS
/* --------------------------------------------------
OVERRIDES
--------------------------------------------------*/
- .btn {
+ .btn:not(.featureRequest) {
background-color: $theme-supplementer;
color: $themeColor-Dark
}