diff --git a/dist/bundle.js b/dist/bundle.js index 4cbfd29..4d32664 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -149,7 +149,7 @@ eval("\n/**\n * When source maps are enabled, `style-loader` uses a link element /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _styles_scss_base_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../styles/scss/base.scss */ \"./src/styles/scss/base.scss\");\n/* harmony import */ var _styles_scss_base_scss__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styles_scss_base_scss__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _styles_css_base_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../styles/css/base.css */ \"./src/styles/css/base.css\");\n/* harmony import */ var _styles_css_base_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_styles_css_base_css__WEBPACK_IMPORTED_MODULE_1__);\n\n\n\n__webpack_require__(/*! ./event-toggles.js */ \"./src/js/event-toggles.js\");\n\n//# sourceURL=webpack:///./src/js/app.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _styles_scss_base_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../styles/scss/base.scss */ \"./src/styles/scss/base.scss\");\n/* harmony import */ var _styles_scss_base_scss__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styles_scss_base_scss__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _styles_css_base_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../styles/css/base.css */ \"./src/styles/css/base.css\");\n/* harmony import */ var _styles_css_base_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_styles_css_base_css__WEBPACK_IMPORTED_MODULE_1__);\n\n\n\n__webpack_require__(/*! ./event-toggles.js */ \"./src/js/event-toggles.js\");\n\n//# sourceURL=webpack:///./src/js/app.js?"); /***/ }), @@ -171,7 +171,7 @@ eval("module.exports = {\n recasttoken: \"26021d055040a9d9f1ad48476efab4a0\"\ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const $configBot = __webpack_require__(/*! ./config.js */ \"./src/js/bot/config.js\");\nconst $config = __webpack_require__(/*! ./../config.js */ \"./src/js/config.js\");\nconst Microbot = __webpack_require__(/*! ./../microbot-ops.js */ \"./src/js/microbot-ops.js\");\nconst app = new Microbot();\nconst DomManipulator = __webpack_require__(/*! ./../dom-ops.js */ \"./src/js/dom-ops.js\");\nconst domManipulator = new DomManipulator();\n\nmodule.exports = class Recast {\n constructor() {\n this.recastToken = $configBot.recasttoken;\n this.requestUrl = \"https://api.recast.ai/v2/request\";\n }\n\n getAndCallProcessIntent(command, text) {\n self = this;\n var url = this.requestUrl + \"?text=\" + command;\n var bodyRelevant = '';\n var intent = '';\n fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": \"Token \" + this.recastToken\n },\n data: text\n }).then(function (response) {\n response.json().then(function (body) {\n bodyRelevant = body.results;\n intent = bodyRelevant.intents[0][\"slug\"];\n $('#' + $config.costants.hiddenIntentFieldId).val(intent);\n if (intent !== undefined) {\n domManipulator.displayIntentBox(intent);\n domManipulator.showWidget(intent);\n domManipulator.populateRecastData(intent, bodyRelevant);\n // self.processIntent(intent);\n }\n return intent;\n });\n }).catch(function (error) {\n console.error('Fetch Error =\\n', error);\n });\n }\n\n processIntent(intent) {\n switch (intent) {\n case \"createrepo\":\n app.createRepository();\n break;\n case \"updaterepo\":\n app.updateRepository();\n break;\n case \"viewrepos\":\n app.viewRepositories();\n break;\n case \"deleterepo\":\n app.deleteRepository();\n break;\n case \"createissue\":\n app.createIssue();\n break;\n case \"updateissue\":\n app.updateIssue();\n break;\n case \"closeissue\":\n app.closeIssue();\n break;\n case \"reopenissue\":\n app.reopenIssue();\n break;\n case \"displayissue\":\n app.displayIssue();\n break;\n case \"addissuecomment\":\n app.addIssueComment();\n break;\n case \"displaylastcomment\":\n app.displayLastComment();\n break;\n case \"addcollab\":\n app.addCollaborator();\n break;\n case \"removecollab\":\n app.removeCollaborator();\n break;\n default:\n console.log(\"default\");\n }\n }\n};\n\n//# sourceURL=webpack:///./src/js/bot/recast-ops.js?"); +eval("const $configBot = __webpack_require__(/*! ./config.js */ \"./src/js/bot/config.js\");\nconst $config = __webpack_require__(/*! ./../config.js */ \"./src/js/config.js\");\nconst Microbot = __webpack_require__(/*! ./../microbot-ops.js */ \"./src/js/microbot-ops.js\");\nconst app = new Microbot();\nconst DomManipulator = __webpack_require__(/*! ./../dom-ops.js */ \"./src/js/dom-ops.js\");\nconst domManipulator = new DomManipulator();\n\nmodule.exports = class Recast {\n constructor() {\n this.recastToken = $configBot.recasttoken;\n this.requestUrl = \"https://api.recast.ai/v2/request\";\n }\n\n getAndCallProcessIntent(command, text) {\n self = this;\n var url = this.requestUrl + \"?text=\" + command;\n var bodyRelevant = '';\n var intent = '';\n fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": \"Token \" + this.recastToken\n },\n data: text\n }).then(function (response) {\n response.json().then(function (body) {\n bodyRelevant = body.results;\n intent = bodyRelevant.intents[0][\"slug\"];\n $('#' + $config.costants.hiddenIntentFieldId).val(intent);\n if (intent !== undefined) {\n domManipulator.displayIntentBox(intent);\n domManipulator.showWidget(intent);\n domManipulator.addGitOperationHistory(command, 'command');\n domManipulator.populateRecastData(intent, bodyRelevant);\n // self.processIntent(intent);\n }\n return intent;\n });\n }).catch(function (error) {\n console.error('Fetch Error =\\n', error);\n });\n }\n\n processIntent(intent) {\n switch (intent) {\n case \"createrepo\":\n app.createRepository();\n break;\n case \"updaterepo\":\n app.updateRepository();\n break;\n case \"viewrepos\":\n app.viewRepositories();\n break;\n case \"deleterepo\":\n app.deleteRepository();\n break;\n case \"createissue\":\n app.createIssue();\n break;\n case \"updateissue\":\n app.updateIssue();\n break;\n case \"closeissue\":\n app.closeIssue();\n break;\n case \"reopenissue\":\n app.reopenIssue();\n break;\n case \"displayissue\":\n app.displayIssue();\n break;\n case \"addissuecomment\":\n app.addIssueComment();\n break;\n case \"displaylastcomment\":\n app.displayLastComment();\n break;\n case \"addcollab\":\n app.addCollaborator();\n break;\n case \"removecollab\":\n app.removeCollaborator();\n break;\n default:\n console.log(\"default\");\n }\n }\n};\n\n//# sourceURL=webpack:///./src/js/bot/recast-ops.js?"); /***/ }), @@ -182,7 +182,7 @@ eval("const $configBot = __webpack_require__(/*! ./config.js */ \"./src/js/bot/c /*! no static exports found */ /***/ (function(module, exports) { -eval("module.exports = {\n gitToken: \"96ead73c54cbbf023a73ee57af145b205d460851\",\n intentSlugToOperations: {\n 'createrepo': {\n \"requestMethod\": 'post',\n \"intentMessage\": \"Create a Repository in Github\",\n \"getDataOperation\": \"getCreateRepoJson\",\n \"githubOperation\": \"createRepository\",\n \"showWidgetOperation\": \"showCreateRepoWidget\",\n \"populateDataOperation\": \"populateCreateRepoData\",\n \"successMessage\": \"Repository Added!\",\n \"cardMsg\": \"Requested Repository has been added and is available at \",\n \"cardDataUrl\": \"html_url\",\n \"cardDataName\": \"name\"\n },\n 'createissue': {\n \"requestMethod\": 'post',\n \"intentMessage\": \"Raise an issue in Github\",\n \"getDataOperation\": \"getCreateIssueJson\",\n \"githubOperation\": \"createIssue\",\n \"showWidgetOperation\": \"showCreateIssueWidget\",\n \"populateDataOperation\": \"populateCreateIssueData\",\n \"successMessage\": \"Issue Created!\",\n \"cardMsg\": \"Issue Created as requested, issue details available at \",\n \"cardDataUrl\": \"html_url\",\n \"cardDataName\": \"title\"\n },\n 'addcollab': {\n \"Method\": 'post',\n \"intentMessage\": \"Add a collaborator\",\n \"getDataOperation\": \"getAddCollaboratorJson\",\n \"githubOperation\": \"addCollaborator\",\n \"showWidgetOperation\": \"showAddCollaboratorWidget\",\n \"populateDataOperation\": \"populateAddCollaboratorData\",\n \"successMessage\": \"Collaborator Added!\",\n \"cardMsg\": \"Collaborator added, details available at \",\n \"cardDataUrl\": \"html_url\",\n \"cardDataName\": \"invitee,login\"\n },\n 'viewrepos': {\n \"requestMethod\": 'get',\n \"intentMessage\": \"View Repositories for current user\",\n \"getDataOperation\": \"getViewRepositoryJson\",\n \"githubOperation\": \"viewRepositories\",\n \"showWidgetOperation\": \"showViewRepoWidget\",\n \"populateDataOperation\": \"populateViewRepoData\",\n \"successMessage\": \"Showing repositories\",\n \"cardMsg\": \"Repository Details available below: \",\n \"cardDataUrl\": \"html_url\",\n \"cardDataName\": \"invitee,login\"\n }\n },\n costants: {\n \"hiddenIntentFieldId\": \"intentHidden\"\n }\n};\n\n//# sourceURL=webpack:///./src/js/config.js?"); +eval("module.exports = {\n gitToken: '96ead73c54cbbf023a73ee57af145b205d460851',\n intentSlugToOperations: {\n createrepo: {\n requestMethod: 'post',\n intentMessage: 'Create a Repository in Github',\n getDataOperation: 'getCreateRepoJson',\n githubOperation: 'createRepository',\n showWidgetOperation: 'showCreateRepoWidget',\n populateDataOperation: 'populateCreateRepoData',\n successMessage: 'Repository Added!',\n cardMsg: 'Requested Repository has been added and is available at ',\n cardDataUrl: 'html_url',\n cardDataName: 'name'\n },\n createissue: {\n requestMethod: 'post',\n intentMessage: 'Raise an issue in Github',\n getDataOperation: 'getCreateIssueJson',\n githubOperation: 'createIssue',\n showWidgetOperation: 'showCreateIssueWidget',\n populateDataOperation: 'populateCreateIssueData',\n successMessage: 'Issue Created!',\n cardMsg: 'Issue Created as requested, issue details available at ',\n cardDataUrl: 'html_url',\n cardDataName: 'title'\n },\n closeissue: {\n requestMethod: 'post',\n intentMessage: 'Close an issue in Github',\n getDataOperation: 'getCloseIssueJson',\n githubOperation: 'closeIssue',\n showWidgetOperation: 'showCloseIssueWidget',\n populateDataOperation: 'populateCloseIssueData',\n successMessage: 'Issue Closed!',\n cardMsg: 'Issue Closed as requested, closed issue available at: ',\n cardDataUrl: 'html_url',\n cardDataName: 'title'\n },\n addissuecomment: {\n requestMethod: 'post',\n intentMessage: 'Add a comment on an issue in Github',\n getDataOperation: 'getAddCommentJson',\n githubOperation: 'addIssueComment',\n showWidgetOperation: 'showAddCommentWidget',\n populateDataOperation: 'populateAddCommentData',\n successMessage: 'Comment Added!',\n cardMsg: 'Comment Added as Requested, view here: ',\n cardDataUrl: 'html_url',\n cardDataName: 'title'\n },\n displaylastcomment: {\n requestMethod: 'get',\n intentMessage: 'Display last comment of an issue in Github',\n getDataOperation: 'getDisplayCommentJson',\n githubOperation: 'displayLastComment',\n showWidgetOperation: 'showDisplayCommentWidget',\n populateDataOperation: 'populateDisplayCommentData',\n successMessage: 'Comment Retrieved!',\n cardMsg: 'Please find requested comment below: ',\n cardDataUrl: 'html_url',\n cardDataName: 'title'\n },\n addcollab: {\n requestMethod: 'post',\n intentMessage: 'Add a collaborator',\n getDataOperation: 'getAddCollaboratorJson',\n githubOperation: 'addCollaborator',\n showWidgetOperation: 'showAddCollaboratorWidget',\n populateDataOperation: 'populateAddCollaboratorData',\n successMessage: 'Collaborator Added!',\n cardMsg: 'Collaborator added, details available at ',\n cardDataUrl: 'html_url',\n cardDataName: 'invitee,login'\n },\n viewrepos: {\n requestMethod: 'get',\n intentMessage: 'View Repositories for current user',\n getDataOperation: 'getViewRepositoryJson',\n githubOperation: 'viewRepositories',\n showWidgetOperation: 'showViewRepoWidget',\n populateDataOperation: 'populateViewRepoData',\n successMessage: 'Showing repositories',\n cardMsg: 'Repository Details available below: ',\n cardDataUrl: 'html_url',\n cardDataName: 'invitee,login'\n }\n },\n costants: {\n hiddenIntentFieldId: 'intentHidden'\n }\n};\n\n//# sourceURL=webpack:///./src/js/config.js?"); /***/ }), @@ -193,7 +193,7 @@ eval("module.exports = {\n gitToken: \"96ead73c54cbbf023a73ee57af145b205d4608 /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const $config = __webpack_require__(/*! ./config.js */ \"./src/js/config.js\");\n\nmodule.exports = class DomManipulator {\n\n constructor() {\n this.createRepoWidgetCreated = false;\n this.commandCardCounter = 1;\n }\n\n showWidget(intent) {\n //var intent = $('#' + $config.costants.hiddenIntentFieldId).val();\n var widget = this.createRepoWidget(intent);\n if (!this.isVisible(widget)) {\n widget.classList.remove('hide');\n $('#underWidgetLine').removeClass('hide');\n }\n }\n\n displayIntentBox(intent) {\n var intentBox = document.getElementById('intentBox');\n if (!this.isVisible(intentBox)) {\n intentBox.classList.remove('hide');\n }\n $('#intentName').text($config.intentSlugToOperations[intent]['intentMessage'] + ' [slug: ' + intent + '].');\n }\n\n createRepoWidget(intent) {\n var existingWidget = document.getElementById(intent);\n if (existingWidget) {\n return existingWidget;\n }\n\n // Create Elements\n var widgets = document.getElementById(\"widgets\");\n var createRepoWidget = document.createElement('div');\n var cardBody = document.createElement('div');\n var header = document.createElement('div');\n var form = document.createElement('form');\n\n var formRow1 = document.createElement('div');\n var formGroup1_1 = document.createElement('div');\n var repoNamelabel = document.createElement('label');\n var repoNameTextField = document.createElement('input');\n var formGroup1_2 = document.createElement('div');\n var homePageURLLabel = document.createElement('label');\n var homePageURLTextField = document.createElement('input');\n\n var formRow2 = document.createElement('div');\n var formGroup2_1 = document.createElement('div');\n var formCheck1 = document.createElement('div');\n var privateLabel = document.createElement('label');\n var privateCB = document.createElement('input');\n var formGroup2_2 = document.createElement('div');\n var formCheck2 = document.createElement('div');\n var addIssueLabel = document.createElement('label');\n var addIssueCB = document.createElement('input');\n var formGroup2_3 = document.createElement('div');\n var formCheck3 = document.createElement('div');\n var addWikiLabel = document.createElement('label');\n var addWikiCB = document.createElement('input');\n\n var formGroup3_1 = document.createElement('div');\n var descriptionLabel = document.createElement('label');\n var descriptionTextArea = document.createElement('textarea');\n\n var submitRepoCreate = document.createElement('button');\n\n // Add Attributes\n widgets.classList.add('card-group');\n createRepoWidget.setAttribute('id', 'createrepo');\n createRepoWidget.classList.add('card', 'hide', 'widget', 'good');\n cardBody.classList.add('card-body');\n header.classList.add('card-title');\n\n formRow1.classList.add('form-row');\n formGroup1_1.classList.add('form-group', 'col-md-6', 'col-sm-6', 'col-lg-6', 'col-xs-6', 'mb-3');\n repoNamelabel.setAttribute('for', 'repositoryName');\n repoNameTextField.setAttribute('type', 'text');\n repoNameTextField.setAttribute('id', 'repositoryName');\n repoNameTextField.setAttribute('placeholder', 'Repository Name... ');\n repoNameTextField.required = true;\n repoNameTextField.classList.add('form-control');\n formGroup1_2.classList.add('form-group', 'col-md-6', 'col-sm-6', 'col-lg-6', 'col-xs-6', 'mb-3');\n homePageURLLabel.setAttribute('for', 'homePageURL');\n homePageURLTextField.setAttribute('type', 'text');\n homePageURLTextField.setAttribute('id', 'homePageURL');\n homePageURLTextField.setAttribute('placeholder', 'Home Page URL... ');\n homePageURLTextField.classList.add('form-control');\n\n formRow2.classList.add('form-row');\n formGroup2_1.classList.add('form-group', 'col-md-3', 'col-sm-3', 'col-lg-3', 'col-xs-3', 'mb-3');\n formCheck1.classList.add('form-check', 'form-check-inline');\n privateLabel.setAttribute('for', 'privateRepoChk');\n privateLabel.classList.add('form-check-label');\n privateCB.setAttribute('type', 'checkbox');\n privateCB.setAttribute('id', 'privateRepoChk');\n privateCB.setAttribute('value', 'Option 1');\n privateCB.classList.add('form-check-input');\n\n formGroup2_2.classList.add('form-group', 'col-md-4', 'col-sm-4', 'col-lg-4', 'col-xs-4', 'mb-3');\n formCheck2.classList.add('form-check', 'form-check-inline');\n addIssueLabel.setAttribute('for', 'issuesChk');\n addIssueLabel.classList.add('form-check-label');\n addIssueCB.setAttribute('type', 'checkbox');\n addIssueCB.setAttribute('id', 'issuesChk');\n addIssueCB.setAttribute('value', 'Option 2');\n addIssueCB.classList.add('form-check-input');\n\n formGroup2_3.classList.add('form-group', 'col-md-4', 'col-sm-4', 'col-lg-4', 'col-xs-4', 'mb-3');\n formCheck3.classList.add('form-check', 'form-check-inline');\n addWikiLabel.setAttribute('for', 'wikiChk');\n addWikiLabel.classList.add('form-check-label');\n addWikiCB.setAttribute('type', 'checkbox');\n addWikiCB.setAttribute('id', 'wikiChk');\n addWikiCB.setAttribute('value', 'Option 3');\n addWikiCB.classList.add('form-check-input');\n\n formGroup3_1.classList.add('form-group');\n descriptionLabel.setAttribute('for', 'description');\n descriptionTextArea.setAttribute('rows', '3');\n descriptionTextArea.classList.add('form-control');\n descriptionTextArea.setAttribute('id', 'description');\n\n submitRepoCreate.setAttribute('type', 'button');\n submitRepoCreate.setAttribute('data-toggle', 'modal');\n submitRepoCreate.setAttribute('data-target', '#submitConfirm');\n submitRepoCreate.setAttribute('id', 'submitForm');\n submitRepoCreate.classList.add('btn', 'btn-primary');\n\n // Add inner HTML\n header.innerHTML = \"Create Repository\";\n repoNamelabel.innerHTML = \"Repository Name\";\n homePageURLLabel.innerHTML = \"Home Page URL\";\n privateLabel.innerHTML = \"Private\";\n addIssueLabel.innerHTML = \"Allow Adding Issues?\";\n addWikiLabel.innerHTML = \"Add Wiki?\";\n descriptionLabel.innerHTML = \"Add some Description for this repository:\";\n submitRepoCreate.innerHTML = \"Submit\";\n\n // Associations\n formCheck1.appendChild(privateCB);\n formCheck1.appendChild(privateLabel);\n\n formCheck2.appendChild(addIssueCB);\n formCheck2.appendChild(addIssueLabel);\n\n formCheck3.appendChild(addWikiCB);\n formCheck3.appendChild(addWikiLabel);\n\n formGroup1_1.appendChild(repoNamelabel);\n formGroup1_1.appendChild(repoNameTextField);\n\n formGroup1_2.appendChild(homePageURLLabel);\n formGroup1_2.appendChild(homePageURLTextField);\n\n formGroup2_1.appendChild(formCheck1);\n formGroup2_2.appendChild(formCheck2);\n formGroup2_3.appendChild(formCheck3);\n\n formGroup3_1.appendChild(descriptionLabel);\n formGroup3_1.appendChild(descriptionTextArea);\n\n formRow1.appendChild(formGroup1_1);\n formRow1.appendChild(formGroup1_2);\n\n formRow2.appendChild(formGroup2_1);\n formRow2.appendChild(formGroup2_2);\n formRow2.appendChild(formGroup2_3);\n\n form.appendChild(formRow1);\n form.appendChild(formRow2);\n form.appendChild(formGroup3_1);\n form.appendChild(submitRepoCreate);\n\n cardBody.appendChild(header);\n cardBody.appendChild(form);\n\n createRepoWidget.appendChild(cardBody);\n widgets.appendChild(createRepoWidget);\n $('#createrepo').insertBefore($('#underWidgetLine'));\n\n this.createRepoWidgetCreated = true;\n\n return createRepoWidget;\n }\n\n showEmptyCommandMessage() {\n $('#emptyCommandMsgDisplayer').click();\n }\n\n populateWidgetWithGithubResponse() {}\n\n populateRecastData(widgetName, recastResponse) {\n var requestMethod = $config.intentSlugToOperations[widgetName]['requestMethod'];\n if (requestMethod == 'post') {\n var operation = $config.intentSlugToOperations[widgetName]['populateDataOperation'];\n this[operation](recastResponse);\n }\n }\n\n populateCreateRepoData(recastResponse) {\n var repoNameTextField = document.getElementById('repositoryName');\n if (repoNameTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0 && recastResponse.entities['git-repository']['0']['value']) {\n var repoName = recastResponse.entities['git-repository']['0']['value'];\n repoNameTextField.value = repoName;\n }\n }\n\n populateCreateIssueData(recastResponse) {\n var issueTitleTextField = document.getElementById('issueTitle');\n var issueRepositoryTextField = document.getElementById('issueRepository');\n if (issueTitleTextField && recastResponse && recastResponse.entities['issue_title'] && recastResponse.entities['issue_title'].length > 0 && recastResponse.entities['issue_title']['0']['value']) {\n var issueTitle = recastResponse.entities['issue_title']['0']['value'];\n issueTitleTextField.value = issueTitle;\n }\n if (issueRepositoryTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0 && recastResponse.entities['git-repository']['0']['value']) {\n var repoName = recastResponse.entities['git-repository']['0']['value'];\n issueRepositoryTextField.value = repoName;\n }\n }\n\n populateAddCollaboratorData(recastResponse) {\n var collaboratorNameTextField = document.getElementById('collaboratorName');\n var repoForCollabTextField = document.getElementById('repoForCollab');\n if (collaboratorNameTextField && recastResponse && recastResponse.entities['git_collaborator'] && recastResponse.entities['git_collaborator'].length > 0 && recastResponse.entities['git_collaborator']['0']['value']) {\n var collaboratorName = recastResponse.entities['git_collaborator']['0']['value'];\n collaboratorNameTextField.value = collaboratorName;\n }\n if (repoForCollabTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0 && recastResponse.entities['git-repository']['0']['value']) {\n var repoName = recastResponse.entities['git-repository']['0']['value'];\n repoForCollabTextField.value = repoName;\n }\n }\n\n isVisible(element) {\n return element ? !element.classList.contains('hide') : false;\n }\n\n getDataFromFormAsJSON() {\n var data = {};\n var intent = $('#' + $config.costants.hiddenIntentFieldId).val();\n var requestMethod = $config.intentSlugToOperations[intent]['requestMethod'];\n if (requestMethod == 'post') {\n if (intent) {\n var operation = $config.intentSlugToOperations[intent]['getDataOperation'];\n data = this[operation]();\n }\n }\n return data;\n }\n\n getCreateRepoJson() {\n var data = {};\n var request = {};\n if (this.isVisible(document.getElementById(\"createrepo\"))) {\n request.name = document.getElementById(\"repositoryName\").value;\n request.description = document.getElementById(\"description\").value;\n request.homepage = document.getElementById(\"homePageURL\").value;\n request.private = document.getElementById(\"privateRepoChk\").checked;\n request.has_issues = document.getElementById(\"issuesChk\").checked;\n request.has_wiki = document.getElementById(\"wikiChk\").checked;\n }\n data.request = request;\n return data;\n }\n\n getCreateIssueJson() {\n var data = {};\n data.urlParams = {};\n var request = {};\n if (this.isVisible(document.getElementById(\"createissue\"))) {\n request.title = document.getElementById(\"issueTitle\").value;\n request.body = document.getElementById(\"description\").value;\n request.assignees = document.getElementById(\"assignees\").value ? document.getElementById(\"assignees\").value.split(',') : [];\n request.labels = document.getElementById(\"labels\").value ? document.getElementById(\"labels\").value.split(',') : [];\n data.urlParams.repoName = document.getElementById(\"issueRepository\").value;\n }\n data.request = request;\n return data;\n }\n\n getAddCollaboratorJson() {\n var data = {};\n data.urlParams = {};\n if (this.isVisible(document.getElementById(\"addcollab\"))) {\n data.urlParams.collaborator = document.getElementById(\"collaboratorName\").value;\n data.urlParams.repoName = document.getElementById(\"repoForCollab\").value;\n }\n return data;\n }\n\n addGitOperationHistory(data, type) {\n var intent = $('#' + $config.costants.hiddenIntentFieldId).val();\n var requestMethod = $config.intentSlugToOperations[intent].requestMethod;\n var conversations = document.getElementById('conversations');\n var table = undefined;\n // Create Elements\n var card = document.createElement('div');\n var cardBody = document.createElement('div');\n var cardTitle = document.createElement('h5');\n var cardText = document.createElement('p');\n var cardFooter = document.createElement('div');\n var textMuted = document.createElement('small');\n var underCardLine = document.createElement('div');\n\n // Add Attributes\n card.classList.add('card', type);\n cardBody.classList.add('card-body');\n cardTitle.classList.add('card-title');\n cardText.classList.add('card-text');\n cardFooter.classList.add('card-footer');\n textMuted.classList.add('text-muted');\n underCardLine.classList.add('line');\n\n var x = this.display_ct(0, textMuted);\n if (type === 'command') {\n // Add content\n cardTitle.innerHTML = 'You Said';\n cardText.innerHTML = data;\n var repeat = document.createElement('a');\n repeat.classList.add('btn', 'btn-info', 'float-right');\n repeat.setAttribute('role', 'button');\n repeat.setAttribute('href', '#');\n repeat.setAttribute('id', 'btnRepeatCommand' + this.commandCardCounter++);\n repeat.innerHTML = \"Repeat\";\n cardText.appendChild(repeat);\n } else if (type === \"response\") {\n // Add content\n cardTitle.innerHTML = 'Server Responded As..';\n if (requestMethod == 'post') {\n cardText.innerHTML = $config.intentSlugToOperations[intent]['cardMsg'] + \"\" + this.getVariable(data, $config.intentSlugToOperations[intent].cardDataName) + \"\";\n } else if (requestMethod == 'get') {\n cardText.innerHTML = $config.intentSlugToOperations[intent]['cardMsg'];\n if (data && data.length && data.length > 0) {\n table = this.createRepoTable(data);\n }\n }\n } else {\n cardTitle.innerHTML = 'Server Responded As..';\n cardText.innerHTML = \"Operation failed with status: \" + type;\n }\n\n // Associations\n cardBody.appendChild(cardTitle);\n cardBody.appendChild(cardText);\n cardFooter.appendChild(textMuted);\n card.appendChild(cardBody);\n if (table) {\n card.appendChild(table);\n }\n card.appendChild(cardFooter);\n\n conversations.insertBefore(underCardLine, conversations.firstChild);\n conversations.insertBefore(card, conversations.firstChild);\n }\n\n getVariable(data, commaSeparatedValue) {\n var arr = commaSeparatedValue.split(',');\n for (var i = 0; i < arr.length; i++) {\n data = data[arr[i]];\n }\n return data;\n }\n\n createRepoTable(data) {\n\n // Create Elements\n var table = document.createElement('table');\n var thead = document.createElement('thead');\n var tr_head = document.createElement('tr');\n var th_1 = document.createElement('th');\n var th_2 = document.createElement('th');\n var th_3 = document.createElement('th');\n var th_4 = document.createElement('th');\n var th_5 = document.createElement('th');\n var th_6 = document.createElement('th');\n var th_7 = document.createElement('th');\n\n // Add Attributes\n table.classList.add('table', 'tabled-bordered', 'table-striped', 'table-hover');\n thead.classList.add('thead-dark');\n th_1.setAttribute('scope', 'col');\n th_2.setAttribute('scope', 'col');\n th_3.setAttribute('scope', 'col');\n th_4.setAttribute('scope', 'col');\n th_5.setAttribute('scope', 'col');\n th_6.setAttribute('scope', 'col');\n th_7.setAttribute('scope', 'col');\n\n // Add Inner HTML\n th_1.innerHTML = \"#\";\n th_2.innerHTML = \"Repository Name\";\n th_3.innerHTML = \"Repository ID\";\n th_4.innerHTML = \"Created On\";\n th_5.innerHTML = \"Created By\";\n th_6.innerHTML = \"View Raw\";\n th_7.innerHTML = \"Delete Repository\";\n\n // Associations\n tr_head.appendChild(th_1);\n tr_head.appendChild(th_2);\n tr_head.appendChild(th_3);\n tr_head.appendChild(th_4);\n tr_head.appendChild(th_5);\n tr_head.appendChild(th_6);\n tr_head.appendChild(th_7);\n thead.appendChild(tr_head);\n table.appendChild(thead);\n\n for (var i = 0; i < data.length; i++) {\n var currentRepo = data[i];\n // Create Elements\n var tbody = document.createElement('tbody');\n var tr_body = document.createElement('tr');\n var th_vertical = document.createElement('th');\n var td_1 = document.createElement('td');\n var td_2 = document.createElement('td');\n var td_3 = document.createElement('td');\n var td_4 = document.createElement('td');\n var td_5 = document.createElement('td');\n var td_6 = document.createElement('td');\n\n // Add Attributes\n th_vertical.setAttribute('scope', 'row');\n tr_body.setAttribute('id', 'repoRow' + i);\n\n // Add Inner HTML\n th_vertical.innerHTML = i + 1;\n td_1.innerHTML = currentRepo.name;\n td_2.innerHTML = \"\" + currentRepo.id + \"\";\n td_3.innerHTML = currentRepo.created_at;\n td_4.innerHTML = \"\" + currentRepo.owner.login + \"\";\n td_5.innerHTML = \"View\";\n td_6.innerHTML = \"Delete\";\n\n // Associations\n tr_body.appendChild(th_vertical);\n tr_body.appendChild(td_1);\n tr_body.appendChild(td_2);\n tr_body.appendChild(td_3);\n tr_body.appendChild(td_4);\n tr_body.appendChild(td_5);\n tr_body.appendChild(td_6);\n tbody.appendChild(tr_body);\n table.appendChild(tbody);\n }\n\n return table;\n }\n\n toggleModals(response) {\n var self = this;\n var promise = response.json();\n var intent = $('#' + $config.costants.hiddenIntentFieldId).val();\n $('#submitConfirm').addClass('hide');\n $('#btnCancelConfirm').click();\n $('.modal-backdrop').removeClass('modal-backdrop');\n $('#underWidgetLine').addClass('hide');\n $('#intentBox').addClass('hide');\n if (response && response.status && (response.status === 201 || response.status === 200 || response.status === 204)) {\n $('#successAlert').removeClass('hide');\n $('#widgets').children().addClass('hide');\n promise.then(function (body) {\n $('#op-msg').text($config.intentSlugToOperations[intent]['successMessage']);\n $('#successAlert').removeClass('hide');\n self.addGitOperationHistory(body, \"response\");\n });\n } else {\n $('#widgets').children().addClass('hide');\n $('#dangerAlert').removeClass('hide');\n self.addGitOperationHistory(response.status);\n }\n }\n\n display_ct(start, element) {\n this.start = start;\n this.element = element;\n var days = Math.floor(this.start / 86400);\n var hours = Math.floor((this.start - days * 86400) / 3600);\n var minutes = Math.floor((this.start - days * 86400 - hours * 3600) / 60);\n var secs = Math.floor(this.start - days * 86400 - hours * 3600 - minutes * 60);\n var x = '';\n if (days != 0) {\n x = x + days + ' days';\n }\n if (hours != 0) {\n x = x + hours + ' hours';\n }\n if (minutes != 0) {\n x = x + minutes + ' minutes';\n }\n x = x + secs + ' seconds ago';\n element.innerHTML = x;\n this.start = this.start + 1;\n // setTimeout(this['display_ct](this.start, this.element)', 1000 )\n }\n};\n\n//# sourceURL=webpack:///./src/js/dom-ops.js?"); +eval("const $config = __webpack_require__(/*! ./config.js */ \"./src/js/config.js\");\nconst GithubHelper = __webpack_require__(/*! ./helper.js */ \"./src/js/helper.js\");\n\nconst githubHelper = new GithubHelper();\n\nmodule.exports = class DomManipulator {\n constructor() {\n this.createRepoWidgetCreated = false;\n this.commandCardCounter = 1;\n }\n\n showWidget(intent) {\n // var intent = $('#' + $config.costants.hiddenIntentFieldId).val();\n const widget = this.createRepoWidget(intent);\n if (!this.isVisible(widget)) {\n widget.classList.remove('hide');\n $('#underWidgetLine').removeClass('hide');\n }\n }\n\n displayIntentBox(intent) {\n const intentBox = document.getElementById('intentBox');\n if (!this.isVisible(intentBox)) {\n intentBox.classList.remove('hide');\n }\n $('#intentName').text(`${$config.intentSlugToOperations[intent].intentMessage} [slug: ${intent}].`);\n }\n\n createRepoWidget(intent) {\n const existingWidget = document.getElementById(intent);\n if (existingWidget) {\n return existingWidget;\n }\n\n // Create Elements\n const widgets = document.getElementById('widgets');\n const createRepoWidget = document.createElement('div');\n const cardBody = document.createElement('div');\n const header = document.createElement('div');\n const form = document.createElement('form');\n\n const formRow1 = document.createElement('div');\n const formGroup1_1 = document.createElement('div');\n const repoNamelabel = document.createElement('label');\n const repoNameTextField = document.createElement('input');\n const formGroup1_2 = document.createElement('div');\n const homePageURLLabel = document.createElement('label');\n const homePageURLTextField = document.createElement('input');\n\n const formRow2 = document.createElement('div');\n const formGroup2_1 = document.createElement('div');\n const formCheck1 = document.createElement('div');\n const privateLabel = document.createElement('label');\n const privateCB = document.createElement('input');\n const formGroup2_2 = document.createElement('div');\n const formCheck2 = document.createElement('div');\n const addIssueLabel = document.createElement('label');\n const addIssueCB = document.createElement('input');\n const formGroup2_3 = document.createElement('div');\n const formCheck3 = document.createElement('div');\n const addWikiLabel = document.createElement('label');\n const addWikiCB = document.createElement('input');\n\n const formGroup3_1 = document.createElement('div');\n const descriptionLabel = document.createElement('label');\n const descriptionTextArea = document.createElement('textarea');\n\n const submitRepoCreate = document.createElement('button');\n\n // Add Attributes\n widgets.classList.add('card-group');\n createRepoWidget.setAttribute('id', 'createrepo');\n createRepoWidget.classList.add('card', 'hide', 'widget', 'good');\n cardBody.classList.add('card-body');\n header.classList.add('card-title');\n\n formRow1.classList.add('form-row');\n formGroup1_1.classList.add('form-group', 'col-md-6', 'col-sm-6', 'col-lg-6', 'col-xs-6', 'mb-3');\n repoNamelabel.setAttribute('for', 'repositoryName');\n repoNameTextField.setAttribute('type', 'text');\n repoNameTextField.setAttribute('id', 'repositoryName');\n repoNameTextField.setAttribute('placeholder', 'Repository Name... ');\n repoNameTextField.required = true;\n repoNameTextField.classList.add('form-control');\n formGroup1_2.classList.add('form-group', 'col-md-6', 'col-sm-6', 'col-lg-6', 'col-xs-6', 'mb-3');\n homePageURLLabel.setAttribute('for', 'homePageURL');\n homePageURLTextField.setAttribute('type', 'text');\n homePageURLTextField.setAttribute('id', 'homePageURL');\n homePageURLTextField.setAttribute('placeholder', 'Home Page URL... ');\n homePageURLTextField.classList.add('form-control');\n\n formRow2.classList.add('form-row');\n formGroup2_1.classList.add('form-group', 'col-md-3', 'col-sm-3', 'col-lg-3', 'col-xs-3', 'mb-3');\n formCheck1.classList.add('form-check', 'form-check-inline');\n privateLabel.setAttribute('for', 'privateRepoChk');\n privateLabel.classList.add('form-check-label');\n privateCB.setAttribute('type', 'checkbox');\n privateCB.setAttribute('id', 'privateRepoChk');\n privateCB.setAttribute('value', 'Option 1');\n privateCB.classList.add('form-check-input');\n\n formGroup2_2.classList.add('form-group', 'col-md-4', 'col-sm-4', 'col-lg-4', 'col-xs-4', 'mb-3');\n formCheck2.classList.add('form-check', 'form-check-inline');\n addIssueLabel.setAttribute('for', 'issuesChk');\n addIssueLabel.classList.add('form-check-label');\n addIssueCB.setAttribute('type', 'checkbox');\n addIssueCB.setAttribute('id', 'issuesChk');\n addIssueCB.setAttribute('value', 'Option 2');\n addIssueCB.classList.add('form-check-input');\n\n formGroup2_3.classList.add('form-group', 'col-md-4', 'col-sm-4', 'col-lg-4', 'col-xs-4', 'mb-3');\n formCheck3.classList.add('form-check', 'form-check-inline');\n addWikiLabel.setAttribute('for', 'wikiChk');\n addWikiLabel.classList.add('form-check-label');\n addWikiCB.setAttribute('type', 'checkbox');\n addWikiCB.setAttribute('id', 'wikiChk');\n addWikiCB.setAttribute('value', 'Option 3');\n addWikiCB.classList.add('form-check-input');\n\n formGroup3_1.classList.add('form-group');\n descriptionLabel.setAttribute('for', 'description');\n descriptionTextArea.setAttribute('rows', '3');\n descriptionTextArea.classList.add('form-control');\n descriptionTextArea.setAttribute('id', 'description');\n\n submitRepoCreate.setAttribute('type', 'button');\n submitRepoCreate.setAttribute('data-toggle', 'modal');\n submitRepoCreate.setAttribute('data-target', '#submitConfirm');\n submitRepoCreate.setAttribute('id', 'submitForm');\n submitRepoCreate.classList.add('btn', 'btn-primary');\n\n // Add inner HTML\n header.innerHTML = 'Create Repository';\n repoNamelabel.innerHTML = 'Repository Name';\n homePageURLLabel.innerHTML = 'Home Page URL';\n privateLabel.innerHTML = 'Private';\n addIssueLabel.innerHTML = 'Allow Adding Issues?';\n addWikiLabel.innerHTML = 'Add Wiki?';\n descriptionLabel.innerHTML = 'Add some Description for this repository:';\n submitRepoCreate.innerHTML = 'Submit';\n\n // Associations\n formCheck1.appendChild(privateCB);\n formCheck1.appendChild(privateLabel);\n\n formCheck2.appendChild(addIssueCB);\n formCheck2.appendChild(addIssueLabel);\n\n formCheck3.appendChild(addWikiCB);\n formCheck3.appendChild(addWikiLabel);\n\n formGroup1_1.appendChild(repoNamelabel);\n formGroup1_1.appendChild(repoNameTextField);\n\n formGroup1_2.appendChild(homePageURLLabel);\n formGroup1_2.appendChild(homePageURLTextField);\n\n formGroup2_1.appendChild(formCheck1);\n formGroup2_2.appendChild(formCheck2);\n formGroup2_3.appendChild(formCheck3);\n\n formGroup3_1.appendChild(descriptionLabel);\n formGroup3_1.appendChild(descriptionTextArea);\n\n formRow1.appendChild(formGroup1_1);\n formRow1.appendChild(formGroup1_2);\n\n formRow2.appendChild(formGroup2_1);\n formRow2.appendChild(formGroup2_2);\n formRow2.appendChild(formGroup2_3);\n\n form.appendChild(formRow1);\n form.appendChild(formRow2);\n form.appendChild(formGroup3_1);\n form.appendChild(submitRepoCreate);\n\n cardBody.appendChild(header);\n cardBody.appendChild(form);\n\n createRepoWidget.appendChild(cardBody);\n widgets.appendChild(createRepoWidget);\n $('#createrepo').insertBefore($('#underWidgetLine'));\n\n this.createRepoWidgetCreated = true;\n\n return createRepoWidget;\n }\n\n showEmptyCommandMessage() {\n $('#emptyCommandMsgDisplayer').click();\n }\n\n populateWidgetWithGithubResponse() {}\n\n populateRecastData(widgetName, recastResponse) {\n // var requestMethod = $config.intentSlugToOperations[widgetName]['requestMethod'];\n const operation = $config.intentSlugToOperations[widgetName].populateDataOperation;\n if (typeof this[operation] === 'function') {\n this[operation](recastResponse);\n }\n }\n\n populateCreateRepoData(recastResponse) {\n const repoNameTextField = document.getElementById('repositoryName');\n if (repoNameTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0 && recastResponse.entities['git-repository']['0'].value) {\n const repoName = recastResponse.entities['git-repository']['0'].value;\n repoNameTextField.value = repoName;\n }\n }\n\n populateCreateIssueData(recastResponse) {\n const issueTitleTextField = document.getElementById('issueTitle');\n const issueRepositoryTextField = document.getElementById('issueRepository');\n if (issueTitleTextField && recastResponse && recastResponse.entities.issue_title && recastResponse.entities.issue_title.length > 0 && recastResponse.entities.issue_title['0'].value) {\n const issueTitle = recastResponse.entities.issue_title['0'].value;\n issueTitleTextField.value = issueTitle;\n }\n if (issueRepositoryTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0 && recastResponse.entities['git-repository']['0'].value) {\n const repoName = recastResponse.entities['git-repository']['0'].value;\n issueRepositoryTextField.value = repoName;\n }\n }\n\n populateCloseIssueData(recastResponse) {\n const issueNumberTextField = document.getElementById('issueNumerToClose');\n const issueRepositoryTextField = document.getElementById('repoForIssueClose');\n if (issueNumberTextField && recastResponse && recastResponse.entities.issue_id && recastResponse.entities.issue_id.length > 0 && recastResponse.entities.issue_id['0'].value) {\n const issueNumber = recastResponse.entities.issue_id['0'].value;\n issueNumberTextField.value = issueNumber;\n }\n if (issueRepositoryTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0 && recastResponse.entities['git-repository']['0'].value) {\n const repoName = recastResponse.entities['git-repository']['0'].value;\n issueRepositoryTextField.value = repoName;\n }\n }\n\n populateAddCollaboratorData(recastResponse) {\n const collaboratorNameTextField = document.getElementById('collaboratorName');\n const repoForCollabTextField = document.getElementById('repoForCollab');\n if (collaboratorNameTextField && recastResponse && recastResponse.entities.git_collaborator && recastResponse.entities.git_collaborator.length > 0 && recastResponse.entities.git_collaborator['0'].value) {\n const collaboratorName = recastResponse.entities.git_collaborator['0'].value;\n collaboratorNameTextField.value = collaboratorName;\n }\n if (repoForCollabTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0 && recastResponse.entities['git-repository']['0'].value) {\n const repoName = recastResponse.entities['git-repository']['0'].value;\n repoForCollabTextField.value = repoName;\n }\n }\n\n populateAddCommentData(recastResponse) {\n const repoForIssueCommentTextField = document.getElementById('repoForIssueComment');\n const issueNumberTextField = document.getElementById('issueNumber');\n const issueCommentTextArea = document.getElementById('issueComment');\n if (repoForIssueCommentTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0 && recastResponse.entities['git-repository']['0'].value) {\n const repoForIssueComment = recastResponse.entities['git-repository']['0'].value;\n repoForIssueCommentTextField.value = repoForIssueComment;\n }\n if (issueNumberTextField && recastResponse && recastResponse.entities.issue_id && recastResponse.entities.issue_id.length > 0 && recastResponse.entities.issue_id['0'].value) {\n const issueNumber = recastResponse.entities.issue_id['0'].value;\n issueNumberTextField.value = issueNumber;\n }\n if (issueCommentTextArea && recastResponse && recastResponse.entities.issue_comment && recastResponse.entities.issue_comment.length > 0 && recastResponse.entities.issue_comment['0'].value) {\n const issueComment = recastResponse.entities.issue_comment['0'].value;\n issueCommentTextArea.value = issueComment;\n }\n }\n\n populateDisplayCommentData(recastResponse) {\n const issueNumberTextField = document.getElementById('issueNumberForCommentView');\n const issueRepositoryTextField = document.getElementById('repoForCommentView');\n if (issueNumberTextField && recastResponse && recastResponse.entities.issue_id && recastResponse.entities.issue_id.length > 0 && recastResponse.entities.issue_id['0'].value) {\n const issueNumber = recastResponse.entities.issue_id['0'].value;\n issueNumberTextField.value = issueNumber;\n }\n if (issueRepositoryTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0 && recastResponse.entities['git-repository']['0'].value) {\n const repoName = recastResponse.entities['git-repository']['0'].value;\n issueRepositoryTextField.value = repoName;\n }\n }\n\n isVisible(element) {\n return element ? !element.classList.contains('hide') : false;\n }\n\n getDataFromFormAsJSON() {\n let data = {};\n const intent = $(`#${$config.costants.hiddenIntentFieldId}`).val();\n const requestMethod = $config.intentSlugToOperations[intent].requestMethod;\n if (intent) {\n const operation = $config.intentSlugToOperations[intent].getDataOperation;\n if (typeof this[operation] === 'function') {\n data = this[operation]();\n }\n }\n return data;\n }\n\n getCreateRepoJson() {\n const data = {};\n const request = {};\n if (this.isVisible(document.getElementById('createrepo'))) {\n request.name = document.getElementById('repositoryName').value;\n request.description = document.getElementById('description').value;\n request.homepage = document.getElementById('homePageURL').value;\n request.private = document.getElementById('privateRepoChk').checked;\n request.has_issues = document.getElementById('issuesChk').checked;\n request.has_wiki = document.getElementById('wikiChk').checked;\n }\n data.request = request;\n return data;\n }\n\n getCreateIssueJson() {\n const data = {};\n data.urlParams = {};\n const request = {};\n if (this.isVisible(document.getElementById('createissue'))) {\n request.title = document.getElementById('issueTitle').value;\n request.body = document.getElementById('description').value;\n request.assignees = document.getElementById('assignees').value ? document.getElementById('assignees').value.split(',') : [];\n request.labels = document.getElementById('labels').value ? document.getElementById('labels').value.split(',') : [];\n data.urlParams.repoName = document.getElementById('issueRepository').value;\n }\n data.request = request;\n return data;\n }\n\n getCloseIssueJson() {\n const data = {};\n data.urlParams = {};\n if (this.isVisible(document.getElementById('closeissue'))) {\n data.urlParams.issueId = document.getElementById('issueNumerToClose').value;\n data.urlParams.repoName = document.getElementById('repoForIssueClose').value;\n }\n return data;\n }\n\n getAddCollaboratorJson() {\n const data = {};\n data.urlParams = {};\n if (this.isVisible(document.getElementById('addcollab'))) {\n data.urlParams.collaborator = document.getElementById('collaboratorName').value;\n data.urlParams.repoName = document.getElementById('repoForCollab').value;\n }\n return data;\n }\n\n getAddCommentJson() {\n const data = {};\n data.urlParams = {};\n const request = {};\n if (this.isVisible(document.getElementById('addissuecomment'))) {\n request.body = document.getElementById('issueComment').value;\n data.urlParams.issueId = document.getElementById('issueNumber').value;\n data.urlParams.repoName = document.getElementById('repoForIssueComment').value;\n }\n data.request = request;\n return data;\n }\n\n getDisplayCommentJson() {\n const data = {};\n data.urlParams = {};\n if (this.isVisible(document.getElementById('displaylastcomment'))) {\n data.urlParams.issueId = document.getElementById('issueNumberForCommentView').value;\n data.urlParams.repoName = document.getElementById('repoForCommentView').value;\n }\n return data;\n }\n\n addGitOperationHistory(data, type) {\n const intent = $(`#${$config.costants.hiddenIntentFieldId}`).val();\n const requestMethod = $config.intentSlugToOperations[intent].requestMethod;\n const conversations = document.getElementById('conversations');\n let table;\n let comment;\n // Create Elements\n const card = document.createElement('div');\n const cardBody = document.createElement('div');\n const cardTitle = document.createElement('h5');\n const closeAnchor = document.createElement('a');\n const closeHeader = document.createElement('h6');\n const cardText = document.createElement('p');\n const cardFooter = document.createElement('div');\n const textMuted = document.createElement('small');\n const underCardLine = document.createElement('div');\n\n // Add Attributes\n card.classList.add('card', type);\n cardBody.classList.add('card-body');\n cardTitle.classList.add('card-title');\n closeAnchor.classList.add('close');\n // closeAnchor.setAttribute('href', '#');\n cardText.classList.add('card-text');\n cardFooter.classList.add('card-footer');\n textMuted.classList.add('text-muted');\n underCardLine.classList.add('line');\n\n // Add content\n closeHeader.innerHTML = 'x';\n\n const x = this.display_ct(0, textMuted);\n if (type === 'command') {\n // Add content\n cardTitle.innerHTML = 'You Said';\n cardText.innerHTML = data;\n const repeat = document.createElement('a');\n repeat.classList.add('btn', 'btn-info', 'float-right');\n repeat.setAttribute('role', 'button');\n repeat.setAttribute('href', '#');\n repeat.setAttribute('id', `btnRepeatCommand${this.commandCardCounter++}`);\n repeat.innerHTML = 'Repeat';\n cardText.appendChild(repeat);\n } else if (type === 'response') {\n // Add content\n cardTitle.innerHTML = 'Server Responded As..';\n if (requestMethod == 'post') {\n cardText.innerHTML = `${$config.intentSlugToOperations[intent].cardMsg}${this.getVariable(data, $config.intentSlugToOperations[intent].cardDataName)}`;\n } else if (requestMethod == 'get') {\n cardText.innerHTML = $config.intentSlugToOperations[intent].cardMsg;\n if (data && data.length && data.length > 0) {\n if (intent === 'viewrepos') {\n table = this.createRepoTable(data);\n } else if (intent === 'displaylastcomment') {\n comment = this.createCommentBody(data);\n }\n }\n }\n } else {\n cardTitle.innerHTML = 'Server Responded As..';\n cardText.innerHTML = `Operation failed with status: ${type}`;\n }\n\n // Associations\n closeAnchor.appendChild(closeHeader);\n cardTitle.appendChild(closeAnchor);\n cardBody.appendChild(cardTitle);\n cardBody.appendChild(cardText);\n if (comment) {\n cardBody.appendChild(comment);\n }\n cardFooter.appendChild(textMuted);\n card.appendChild(cardBody);\n if (table) {\n card.appendChild(table);\n }\n card.appendChild(cardFooter);\n\n conversations.insertBefore(underCardLine, conversations.firstChild);\n conversations.insertBefore(card, conversations.firstChild);\n }\n\n getVariable(data, commaSeparatedValue) {\n const arr = commaSeparatedValue.split(',');\n for (let i = 0; i < arr.length; i++) {\n data = data[arr[i]];\n }\n return data;\n }\n\n createRepoTable(data) {\n // Create Elements\n const table = document.createElement('table');\n const thead = document.createElement('thead');\n const tr_head = document.createElement('tr');\n const th_1 = document.createElement('th');\n const th_2 = document.createElement('th');\n const th_3 = document.createElement('th');\n const th_4 = document.createElement('th');\n const th_5 = document.createElement('th');\n const th_6 = document.createElement('th');\n const th_7 = document.createElement('th');\n\n // Add Attributes\n table.classList.add('table', 'tabled-bordered', 'table-striped', 'table-hover');\n thead.classList.add('thead-dark');\n th_1.setAttribute('scope', 'col');\n th_2.setAttribute('scope', 'col');\n th_3.setAttribute('scope', 'col');\n th_4.setAttribute('scope', 'col');\n th_5.setAttribute('scope', 'col');\n th_6.setAttribute('scope', 'col');\n th_7.setAttribute('scope', 'col');\n\n // Add Inner HTML\n th_1.innerHTML = '#';\n th_2.innerHTML = 'Repository Name';\n th_3.innerHTML = 'Repository ID';\n th_4.innerHTML = 'Created On';\n th_5.innerHTML = 'Created By';\n th_6.innerHTML = 'View Raw';\n th_7.innerHTML = 'Delete Repository';\n\n // Associations\n tr_head.appendChild(th_1);\n tr_head.appendChild(th_2);\n tr_head.appendChild(th_3);\n tr_head.appendChild(th_4);\n tr_head.appendChild(th_5);\n tr_head.appendChild(th_6);\n tr_head.appendChild(th_7);\n thead.appendChild(tr_head);\n table.appendChild(thead);\n\n for (let i = 0; i < data.length; i++) {\n const currentRepo = data[i];\n // Create Elements\n const tbody = document.createElement('tbody');\n const tr_body = document.createElement('tr');\n const th_vertical = document.createElement('th');\n const td_1 = document.createElement('td');\n const td_2 = document.createElement('td');\n const td_3 = document.createElement('td');\n const td_4 = document.createElement('td');\n const td_5 = document.createElement('td');\n const td_6 = document.createElement('td');\n\n // Add Attributes\n th_vertical.setAttribute('scope', 'row');\n tr_body.setAttribute('id', `repoRow${i}`);\n\n // Add Inner HTML\n th_vertical.innerHTML = i + 1;\n td_1.innerHTML = currentRepo.name;\n td_2.innerHTML = `${currentRepo.id}`;\n td_3.innerHTML = currentRepo.created_at;\n td_4.innerHTML = `${currentRepo.owner.login}`;\n td_5.innerHTML = `View`;\n td_6.innerHTML = `Delete`;\n\n // Associations\n tr_body.appendChild(th_vertical);\n tr_body.appendChild(td_1);\n tr_body.appendChild(td_2);\n tr_body.appendChild(td_3);\n tr_body.appendChild(td_4);\n tr_body.appendChild(td_5);\n tr_body.appendChild(td_6);\n tbody.appendChild(tr_body);\n table.appendChild(tbody);\n }\n\n return table;\n }\n\n createCommentBody(data) {\n const commentPara = document.createElement('p');\n const lastComment = githubHelper.getLatestComment(data);\n commentPara.classList.add('card-text');\n commentPara.innerHTML = `COMMENT: ${lastComment}`;\n return commentPara;\n }\n\n concealCodeInUrl() {\n window.location = 'http://localhost:8080';\n }\n\n toggleModals(response) {\n const self = this;\n const promise = response.json();\n const intent = $(`#${$config.costants.hiddenIntentFieldId}`).val();\n $('#submitConfirm').addClass('hide');\n $('#btnCancelConfirm').click();\n $('.modal-backdrop').removeClass('modal-backdrop');\n $('#underWidgetLine').addClass('hide');\n $('#intentBox').addClass('hide');\n if (response && response.status && (response.status === 201 || response.status === 200 || response.status === 204)) {\n $('#successAlert').removeClass('hide');\n $('#widgets').children().addClass('hide');\n promise.then(body => {\n $('#op-msg').text($config.intentSlugToOperations[intent].successMessage);\n $('#successAlert').removeClass('hide');\n self.addGitOperationHistory(body, 'response');\n // clear intent\n $(`#${$config.costants.hiddenIntentFieldId}`).val('');\n });\n } else {\n $('#widgets').children().addClass('hide');\n $('#dangerAlert').removeClass('hide');\n self.addGitOperationHistory(response.status);\n // clear intent\n $(`#${$config.costants.hiddenIntentFieldId}`).val('');\n }\n }\n\n display_ct(start, element) {\n this.start = start;\n this.element = element;\n const days = Math.floor(this.start / 86400);\n const hours = Math.floor((this.start - days * 86400) / 3600);\n const minutes = Math.floor((this.start - days * 86400 - hours * 3600) / 60);\n const secs = Math.floor(this.start - days * 86400 - hours * 3600 - minutes * 60);\n let x = '';\n if (days != 0) {\n x = `${x + days} days`;\n }\n if (hours != 0) {\n x = `${x + hours} hours`;\n }\n if (minutes != 0) {\n x = `${x + minutes} minutes`;\n }\n x = `${x + secs} seconds ago`;\n element.innerHTML = x;\n this.start = this.start + 1;\n // setTimeout(this['display_ct](this.start, this.element)', 1000 )\n }\n};\n\n//# sourceURL=webpack:///./src/js/dom-ops.js?"); /***/ }), @@ -204,7 +204,7 @@ eval("const $config = __webpack_require__(/*! ./config.js */ \"./src/js/config.j /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const Recast = __webpack_require__(/*! ./bot/recast-ops.js */ \"./src/js/bot/recast-ops.js\");\nconst recastclient = new Recast();\nconst DomManipulator = __webpack_require__(/*! ./dom-ops.js */ \"./src/js/dom-ops.js\");\nconst dom = new DomManipulator();\nconst Microbot = __webpack_require__(/*! ./microbot-ops.js */ \"./src/js/microbot-ops.js\");\nconst app = new Microbot();\nconst $config = __webpack_require__(/*! ./config.js */ \"./src/js/config.js\");\n\nmodule.exports = $(document).ready(function () {\n $('#sidebarCollapse').on('click', function () {\n $('#sidebar').toggleClass('active');\n $('.hideable').toggleClass('hide');\n });\n $('#content nav div.collapse li a.nav-link i.far.fa-star').hover(function () {\n $('#content nav div.collapse li a.nav-link i.far.fa-star').toggleClass('fas');\n });\n $('#content nav div.collapse li a.nav-link i.far.fa-trash-alt').hover(function () {\n $('#content nav div.collapse li a.nav-link i.far.fa-trash-alt').toggleClass('fas');\n });\n $('#content nav div.collapse li a.nav-link i.far.fa-paper-plane').hover(function () {\n $('#content nav div.collapse li a.nav-link i.far.fa-paper-plane').toggleClass('fas');\n });\n $('#command').keyup(function (e) {\n var code = e.keyCode ? e.keyCode : e.which;\n if (code == 13) {\n $('#widgets').children().addClass('hide');\n $('#successAlert').addClass('hide');\n $('#dangetAlert').addClass('hide');\n $('#intentBox').addClass('hide');\n var command = document.getElementById('command').value;\n if (command) {\n var text = { \"text\": command };\n recastclient.getAndCallProcessIntent(command, text);\n dom.addGitOperationHistory(command, 'command');\n } else {\n dom.showEmptyCommandMessage();\n }\n }\n });\n $('#btnSubmitConfirm').on('click', function () {\n $('#submitConfirm').removeClass('hide');\n });\n $('#submitGitData').on('click', function () {\n var data = dom.getDataFromFormAsJSON();\n var intent = $('#' + $config.costants.hiddenIntentFieldId).val();\n if (intent) {\n var operation = $config.intentSlugToOperations[intent]['githubOperation'];\n app[operation](data);\n }\n });\n $(\"#hideInfoAlert\").on('click', function () {\n $('#intentBox').addClass('hide');\n });\n $(\"#hideSuccessAlert\").on('click', function () {\n $('#successAlert').addClass('hide');\n });\n $('.close').click(function () {\n var $target = $(this).closest('.card');\n $target.hide('slow', function () {\n $target.remove();\n });\n });\n $(\"#hideDangerAlert\").on('click', function () {\n $('#dangerAlert').addClass('hide');\n });\n $('#git_bridge').on('click', function () {\n window.location.href = 'https://github.com/login/oauth/authorize?scope=user:email:repo&client_id=f6f649a1fe2dfea082ba';\n // var user = app.getCurrentUser();\n // if(user) {\n // window.location.href = './../continue.html'\n // } else {\n // window.location.href = 'https://github.com/login/oauth/authorize?scope=user:email:repo&client_id=f6f649a1fe2dfea082ba';\n // }\n });\n});\n\n//# sourceURL=webpack:///./src/js/event-toggles.js?"); +eval("const Recast = __webpack_require__(/*! ./bot/recast-ops.js */ \"./src/js/bot/recast-ops.js\");\n\nconst recastclient = new Recast();\nconst DomManipulator = __webpack_require__(/*! ./dom-ops.js */ \"./src/js/dom-ops.js\");\n\nconst dom = new DomManipulator();\nconst Microbot = __webpack_require__(/*! ./microbot-ops.js */ \"./src/js/microbot-ops.js\");\n\nconst app = new Microbot();\nconst $config = __webpack_require__(/*! ./config.js */ \"./src/js/config.js\");\n\nmodule.exports = $(document).ready(() => {\n // console.log('test');\n app.setToken();\n $('#sidebarCollapse').on('click', () => {\n $('#sidebar').toggleClass('active');\n $('.hideable').toggleClass('hide');\n });\n $('#content nav div.collapse li a.nav-link i.far.fa-star').hover(() => {\n $('#content nav div.collapse li a.nav-link i.far.fa-star').toggleClass('fas');\n });\n $('#content nav div.collapse li a.nav-link i.far.fa-trash-alt').hover(() => {\n $('#content nav div.collapse li a.nav-link i.far.fa-trash-alt').toggleClass('fas');\n });\n $('#content nav div.collapse li a.nav-link i.far.fa-paper-plane').hover(() => {\n $('#content nav div.collapse li a.nav-link i.far.fa-paper-plane').toggleClass('fas');\n });\n $('#command').keyup(e => {\n const code = e.keyCode ? e.keyCode : e.which;\n if (code == 13) {\n $('#widgets').children().addClass('hide');\n $('#successAlert').addClass('hide');\n $('#dangetAlert').addClass('hide');\n $('#intentBox').addClass('hide');\n const command = document.getElementById('command').value;\n if (command) {\n const text = { text: command };\n recastclient.getAndCallProcessIntent(command, text);\n } else {\n dom.showEmptyCommandMessage();\n }\n }\n });\n $('#btnSubmitConfirm').on('click', () => {\n $('#submitConfirm').removeClass('hide');\n });\n $('#submitGitData').on('click', () => {\n const data = dom.getDataFromFormAsJSON();\n const intent = $(`#${$config.costants.hiddenIntentFieldId}`).val();\n if (intent) {\n const operation = $config.intentSlugToOperations[intent].githubOperation;\n app[operation](data);\n }\n });\n $('#hideInfoAlert').on('click', () => {\n $('#intentBox').addClass('hide');\n });\n $('#hideSuccessAlert').on('click', () => {\n $('#successAlert').addClass('hide');\n });\n $('#conversations').on('click', '.close', function () {\n const $target = $(this).closest('.card');\n const line = $target.next();\n $target.hide('slow', () => {\n $target.remove();\n });\n line.hide('slow', () => {\n line.remove();\n });\n });\n $('#hideDangerAlert').on('click', () => {\n $('#dangerAlert').addClass('hide');\n });\n $('#git_bridge').on('click', () => {\n window.location.href = 'https://github.com/login/oauth/authorize?scope=user:email:repo&client_id=f6f649a1fe2dfea082ba';\n // var user = app.getCurrentUser();\n // if(user) {\n // window.location.href = './../continue.html'\n // } else {\n // window.location.href = 'https://github.com/login/oauth/authorize?scope=user:email:repo&client_id=f6f649a1fe2dfea082ba';\n // }\n });\n if (window.location.href.match(/\\?code=(.*)/)) {\n const code = window.location.href.match(/\\?code=(.*)/)[1];\n app.getToken(code);\n }\n});\n\n//# sourceURL=webpack:///./src/js/event-toggles.js?"); /***/ }), @@ -215,7 +215,7 @@ eval("const Recast = __webpack_require__(/*! ./bot/recast-ops.js */ \"./src/js/b /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const config = __webpack_require__(/*! ./config.js */ \"./src/js/config.js\");\nconst GithubHelper = __webpack_require__(/*! ./helper.js */ \"./src/js/helper.js\");\nconst githubHelper = new GithubHelper();\nconst DomManipulator = __webpack_require__(/*! ./dom-ops.js */ \"./src/js/dom-ops.js\");\nconst dom = new DomManipulator();\n\nmodule.exports = class Github {\n\n constructor() {\n this.authorizationToken = \"token \" + config.gitToken;\n }\n\n getToken(code) {\n var token = '';\n $.getJSON('http://localhost:9999/authenticate/' + code, function (data) {\n console.log(data.token);\n token = data.token;\n this.authorizationToken = \"token \" + token;\n });\n return token;\n }\n\n getCurrentUser() {\n var repositories = '';\n let url = 'https://api.github.com/user/';\n fetch(url, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\"\n }\n }).then(function (response) {\n response.json().then(function (body) {\n repositories = body;\n console.log(repositories);\n return repositories;\n });\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n return repositories;\n }\n authenticate() {}\n\n viewRepositories() {\n var repositories = '';\n let url = 'https://api.github.com/user/repos';\n fetch(url, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n }\n }).then(function (response) {\n // response.json().then(function(body){\n // repositories = body; \n // console.log(repositories); \n // return repositories;\n // });\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n return repositories;\n }\n\n createRepository(newRepoJson) {\n let url = 'https://api.github.com/user/repos';\n var responsePromise = '';\n fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n },\n body: JSON.stringify(newRepoJson)\n }).then(function (response) {\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n updateRepository(updateRepoJson, repoName) {\n repoName = \"Hello-World3\";\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName;\n fetch(url, {\n method: \"PATCH\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n },\n body: JSON.stringify(updateRepoJson)\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n deleteRepository(repoName) {\n repoName = \"Hello-World2\";\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName;\n fetch(url, {\n method: \"DELETE\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n }\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n createIssue(newIssueJson, repoName) {\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName + '/issues';\n fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n },\n body: JSON.stringify(newIssueJson)\n }).then(function (response) {\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n updateIssue(updateIssueJson, repoName, issueNumber) {\n repoName = 'stack_route_prj7';\n issueNumber = 2;\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName + '/issues/' + issueNumber;\n fetch(url, {\n method: \"PATCH\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n },\n body: JSON.stringify(updateIssueJson)\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n closeIssue(closeIssueJson, repoName, issueNumber) {\n repoName = 'stack_route_prj7';\n issueNumber = 2;\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName + '/issues/' + issueNumber;\n fetch(url, {\n method: \"PATCH\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n },\n body: JSON.stringify(closeIssueJson)\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n reopenIssue(reopenIssueJson, repoName, issueNumber) {\n repoName = 'stack_route_prj7';\n issueNumber = 2;\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName + '/issues/' + issueNumber;\n fetch(url, {\n method: \"PATCH\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n },\n body: JSON.stringify(reopenIssueJson)\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n displayIssue(repoName, issueNumber) {\n repoName = 'stack_route_prj7';\n issueNumber = 2;\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName + '/issues/' + issueNumber;\n var issues = '';\n fetch(url, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n }\n }).then(function (response) {\n response.json().then(function (body) {\n issues = body;\n console.log(issues);\n return issues;\n });\n }).catch(error => console.error('Fetch Error =\\n', error));\n return issues;\n }\n\n addIssueComment(commentBodyJson, repoName, issueNumber) {\n repoName = \"stack_route_prj7\";\n issueNumber = 2;\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName + '/issues/' + issueNumber + \"/comments\";\n fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n },\n body: JSON.stringify(commentBodyJson)\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n displayLastComment(repoName, issueNumber) {\n repoName = \"stack_route_prj7\";\n issueNumber = 2;\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName + '/issues/' + issueNumber + \"/comments\";\n var comments = [];\n var latestComment = \"\";\n fetch(url, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n }\n }).then(function (response) {\n response.json().then(function (body) {\n comments = body;\n latestComment = githubHelper.getLatestComment(comments);\n console.log(comments);\n console.log(latestComment);\n return latestComment;\n });\n }).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n displayIssuesForUser() {\n let url = 'https://api.github.com/user/issues';\n fetch(url, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n }\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n displayIssuesOnRepo() {\n repoName = 'stack_route_prj7';\n issueNumber = 2;\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName + '/issues/';\n fetch(url, {\n method: \"PATCH\",\n headers: {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Authorization\": this.authorizationToken\n },\n body: JSON.stringify(updateIssueJson)\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n addCollaborator(repoName, collaborator) {\n repoName = 'stack_route_prj7';\n collaborator = 'swat1508';\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName + '/collaborators/' + collaborator;\n fetch(url, {\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Authorization\": this.authorizationToken\n }\n }).then(function (response) {\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n removeCollaborator(repoName, collaborator) {\n repoName = 'stack_route_prj7';\n collaborator = 'swat1508';\n let url = 'https://api.github.com/repos/mohiit1502/' + repoName + '/collaborators/' + collaborator;\n fetch(url, {\n method: \"DELETE\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Authorization\": this.authorizationToken\n }\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n createUser(newuserJson) {}\n\n updateUser(updateUserJson) {}\n\n deleteUser(userId) {}\n};\n\n//# sourceURL=webpack:///./src/js/github-ops.js?"); +eval("const config = __webpack_require__(/*! ./config.js */ \"./src/js/config.js\");\nconst GithubHelper = __webpack_require__(/*! ./helper.js */ \"./src/js/helper.js\");\n\nconst githubHelper = new GithubHelper();\nconst DomManipulator = __webpack_require__(/*! ./dom-ops.js */ \"./src/js/dom-ops.js\");\n\nconst dom = new DomManipulator();\nconst PersistentOps = __webpack_require__(/*! ./persistent-ops.js */ \"./src/js/persistent-ops.js\");\n\nconst persistentOps = new PersistentOps();\n\nmodule.exports = class Github {\n constructor() {\n this.authorizationToken = `token ${config.gitToken}`;\n }\n\n getToken(code) {\n let token = '';\n self = this;\n $.getJSON(`http://localhost:9999/authenticate/${code}`, data => {\n console.log(data.token);\n token = data.token;\n // set cookie here\n persistentOps.setCookie('gitToken', token, 30);\n // self.authorizationToken = \"token \" + persistentOps.getCookie('gitToken');\n dom.concealCodeInUrl();\n });\n return token;\n }\n\n getCurrentUser() {\n let repositories = '';\n const url = 'https://api.github.com/user/';\n fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8'\n }\n }).then(response => {\n response.json().then(body => {\n repositories = body;\n console.log(repositories);\n return repositories;\n });\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n return repositories;\n }\n\n authenticate() {}\n\n viewRepositories() {\n const repositories = '';\n const url = 'https://api.github.com/user/repos';\n fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n }\n }).then(response => {\n // response.json().then(function(body){\n // repositories = body;\n // console.log(repositories);\n // return repositories;\n // });\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n return repositories;\n }\n\n createRepository(newRepoJson) {\n const url = 'https://api.github.com/user/repos';\n const responsePromise = '';\n fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n },\n body: JSON.stringify(newRepoJson)\n }).then(response => {\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n updateRepository(updateRepoJson, repoName) {\n repoName = 'Hello-World3';\n const url = `https://api.github.com/repos/mohiit1502/${repoName}`;\n fetch(url, {\n method: 'PATCH',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n },\n body: JSON.stringify(updateRepoJson)\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n deleteRepository(repoName) {\n repoName = 'Hello-World2';\n const url = `https://api.github.com/repos/mohiit1502/${repoName}`;\n fetch(url, {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n }\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n createIssue(newIssueJson, repoName) {\n const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues`;\n fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n },\n body: JSON.stringify(newIssueJson)\n }).then(response => {\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n updateIssue(updateIssueJson, repoName, issueNumber) {\n repoName = 'stack_route_prj7';\n issueNumber = 2;\n const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;\n fetch(url, {\n method: 'PATCH',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n },\n body: JSON.stringify(updateIssueJson)\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n closeIssue(closeIssueJson, repoName, issueNumber) {\n const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;\n fetch(url, {\n method: 'PATCH',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n },\n body: JSON.stringify(closeIssueJson)\n }).then(response => {\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n reopenIssue(reopenIssueJson, repoName, issueNumber) {\n repoName = 'stack_route_prj7';\n issueNumber = 2;\n const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;\n fetch(url, {\n method: 'PATCH',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n },\n body: JSON.stringify(reopenIssueJson)\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n displayIssue(repoName, issueNumber) {\n repoName = 'stack_route_prj7';\n issueNumber = 2;\n const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}`;\n let issues = '';\n fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n }\n }).then(response => {\n response.json().then(body => {\n issues = body;\n console.log(issues);\n return issues;\n });\n }).catch(error => console.error('Fetch Error =\\n', error));\n return issues;\n }\n\n addIssueComment(commentBodyJson, repoName, issueId) {\n const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueId}/comments`;\n fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n },\n body: JSON.stringify(commentBodyJson)\n }).then(response => {\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n displayLastComment(repoName, issueNumber) {\n const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/${issueNumber}/comments`;\n const comments = [];\n const latestComment = '';\n fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n }\n }).then(response => {\n dom.toggleModals(response);\n // response.json().then(function(body){\n // comments = body;\n // latestComment = githubHelper.getLatestComment(comments);\n // console.log(comments);\n // console.log(latestComment);\n // });\n }).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n displayIssuesForUser() {\n const url = 'https://api.github.com/user/issues';\n fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n }\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n displayIssuesOnRepo() {\n repoName = 'stack_route_prj7';\n issueNumber = 2;\n const url = `https://api.github.com/repos/mohiit1502/${repoName}/issues/`;\n fetch(url, {\n method: 'PATCH',\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n Authorization: this.authorizationToken\n },\n body: JSON.stringify(updateIssueJson)\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n addCollaborator(repoName, collaborator) {\n repoName = 'stack_route_prj7';\n collaborator = 'swat1508';\n const url = `https://api.github.com/repos/mohiit1502/${repoName}/collaborators/${collaborator}`;\n fetch(url, {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: this.authorizationToken\n }\n }).then(response => {\n dom.toggleModals(response);\n }).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n removeCollaborator(repoName, collaborator) {\n repoName = 'stack_route_prj7';\n collaborator = 'swat1508';\n const url = `https://api.github.com/repos/mohiit1502/${repoName}/collaborators/${collaborator}`;\n fetch(url, {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: this.authorizationToken\n }\n }).then(response => response.json()).catch(error => console.error('Fetch Error =\\n', error));\n }\n\n createUser(newuserJson) {}\n\n updateUser(updateUserJson) {}\n\n deleteUser(userId) {}\n};\n\n//# sourceURL=webpack:///./src/js/github-ops.js?"); /***/ }), @@ -226,7 +226,7 @@ eval("const config = __webpack_require__(/*! ./config.js */ \"./src/js/config.js /*! no static exports found */ /***/ (function(module, exports) { -eval("module.exports = class GithubHelper {\n getLatestComment(comments) {\n if (comments && comments.length > 0) return comments[comments.length - 1]['body'];\n }\n};\n\n//# sourceURL=webpack:///./src/js/helper.js?"); +eval("module.exports = class GithubHelper {\n getLatestComment(comments) {\n if (comments && comments.length > 0) {\n return comments[comments.length - 1].body;\n }\n }\n};\n\n//# sourceURL=webpack:///./src/js/helper.js?"); /***/ }), @@ -237,7 +237,18 @@ eval("module.exports = class GithubHelper {\n getLatestComment(comments) {\n /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const Github = __webpack_require__(/*! ./github-ops.js */ \"./src/js/github-ops.js\");\nconst $github = new Github();\n\nmodule.exports = class Microbot {\n\n constructor(clientId, clientSecret) {\n // TODO move to config or env variables\n this.clientId = 'f6f649a1fe2dfea082ba';\n this.clientSecret = '7e9a33d05ffdb36b4a498140bb9bb06d62de4f0e';\n }\n\n getToken(code) {\n $github.getToken(code);\n }\n\n getCurrentUser() {\n $github.getCurrentUser();\n }\n\n viewRepositories() {\n return $github.viewRepositories();\n }\n\n createRepository(requestData) {\n var requestJson = requestData.request;\n $github.createRepository(requestJson);\n // $github.createRepository({\n // \"name\": \"new-test-js-git-api-repo\",\n // \"description\": \"This is your first repository\",\n // \"homepage\": \"https://github.com\",\n // \"private\": false,\n // \"has_issues\": true,\n // \"has_wiki\": true\n // })\n }\n\n updateRepository(repoName, repoType) {\n $github.authenticate();\n $github.updateRepository({\n \"name\": \"Hello-World4\",\n \"description\": \"This is your test description\",\n \"homepage\": \"https://github.com\",\n \"private\": false,\n \"has_issues\": true,\n \"has_projects\": true,\n \"has_wiki\": true\n });\n }\n\n deleteRepository() {\n $github.deleteRepository();\n }\n\n createIssue(requestData) {\n var requestJson = requestData.request;\n var repoName = requestData.urlParams.repoName;\n $github.createIssue(requestJson, repoName);\n }\n\n updateIssue() {\n $github.updateIssue({\n \"title\": \"Found a bug - title updated\",\n \"body\": \"This is the updated problem description.\",\n \"assignees\": [\"mohiit1502\"],\n \"milestone\": 1,\n \"state\": \"open\",\n \"labels\": [\"bug\", \"issue\"]\n });\n }\n\n closeIssue() {\n $github.closeIssue({\n \"milestone\": 1,\n \"state\": \"close\"\n });\n }\n\n displayIssue() {\n return $github.displayIssue();\n }\n\n reopenIssue() {\n $github.reopenIssue({\n \"milestone\": 1,\n \"state\": \"open\"\n });\n }\n\n addIssueComment() {\n $github.addIssueComment({\n \"body\": \"This is another test issue comment\"\n });\n }\n\n displayLastComment() {\n return $github.displayLastComment();\n }\n\n addCollaborator(requestData) {\n var repoName = requestData.urlParams.repoName;\n var collaborator = requestData.urlParams.collaborator;\n $github.addCollaborator(repoName, collaborator);\n }\n\n removeCollaborator() {\n $github.removeCollaborator();\n }\n\n callAppropriate(intent) {}\n};\n\n//# sourceURL=webpack:///./src/js/microbot-ops.js?"); +eval("const Github = __webpack_require__(/*! ./github-ops.js */ \"./src/js/github-ops.js\");\n\nconst $github = new Github();\nconst PersistentOps = __webpack_require__(/*! ./persistent-ops.js */ \"./src/js/persistent-ops.js\");\n\nconst persistentOps = new PersistentOps();\n\nmodule.exports = class Microbot {\n constructor(clientId, clientSecret) {\n // TODO move to config or env variables\n this.clientId = 'f6f649a1fe2dfea082ba';\n this.clientSecret = '7e9a33d05ffdb36b4a498140bb9bb06d62de4f0e';\n }\n\n getToken(code) {\n $github.getToken(code);\n }\n\n setToken() {\n $github.authorizationToken = `token ${persistentOps.getCookie('gitToken')}`;\n }\n\n getCurrentUser() {\n $github.getCurrentUser();\n }\n\n viewRepositories() {\n return $github.viewRepositories();\n }\n\n createRepository(requestData) {\n const requestJson = requestData.request;\n $github.createRepository(requestJson);\n // $github.createRepository({\n // \"name\": \"new-test-js-git-api-repo\",\n // \"description\": \"This is your first repository\",\n // \"homepage\": \"https://github.com\",\n // \"private\": false,\n // \"has_issues\": true,\n // \"has_wiki\": true\n // })\n }\n\n updateRepository(repoName, repoType) {\n $github.authenticate();\n $github.updateRepository({\n name: 'Hello-World4',\n description: 'This is your test description',\n homepage: 'https://github.com',\n private: false,\n has_issues: true,\n has_projects: true,\n has_wiki: true\n });\n }\n\n deleteRepository() {\n $github.deleteRepository();\n }\n\n createIssue(requestData) {\n const requestJson = requestData.request;\n const repoName = requestData.urlParams.repoName;\n $github.createIssue(requestJson, repoName);\n }\n\n updateIssue() {\n $github.updateIssue({\n title: 'Found a bug - title updated',\n body: 'This is the updated problem description.',\n assignees: ['mohiit1502'],\n milestone: 1,\n state: 'open',\n labels: ['bug', 'issue']\n });\n }\n\n closeIssue(requestData) {\n const repoName = requestData.urlParams.repoName;\n const issueId = requestData.urlParams.issueId;\n $github.closeIssue({\n state: 'close'\n }, repoName, issueId);\n }\n\n displayIssue() {\n return $github.displayIssue();\n }\n\n reopenIssue() {\n $github.reopenIssue({\n milestone: 1,\n state: 'open'\n });\n }\n\n addIssueComment(requestData) {\n const requestJson = requestData.request;\n const repoName = requestData.urlParams.repoName;\n const issueId = requestData.urlParams.issueId;\n $github.addIssueComment(requestJson, repoName, issueId);\n }\n\n displayLastComment(requestData) {\n const repoName = requestData.urlParams.repoName;\n const issueId = requestData.urlParams.issueId;\n return $github.displayLastComment(repoName, issueId);\n }\n\n addCollaborator(requestData) {\n const repoName = requestData.urlParams.repoName;\n const collaborator = requestData.urlParams.collaborator;\n $github.addCollaborator(repoName, collaborator);\n }\n\n removeCollaborator() {\n $github.removeCollaborator();\n }\n\n callAppropriate(intent) {}\n};\n\n//# sourceURL=webpack:///./src/js/microbot-ops.js?"); + +/***/ }), + +/***/ "./src/js/persistent-ops.js": +/*!**********************************!*\ + !*** ./src/js/persistent-ops.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("module.exports = class PersistentOps {\n getLatestComment(comments) {\n if (comments && comments.length > 0) {\n return comments[comments.length - 1].body;\n }\n }\n\n setCookie(cname, cvalue, exdays) {\n const d = new Date();\n d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);\n const expires = `expires=${d.toUTCString()}`;\n document.cookie = `${cname}=${cvalue};${expires};path=/`;\n }\n\n getCookie(cname) {\n const name = `${cname}=`;\n const decodedCookie = decodeURIComponent(document.cookie);\n const ca = decodedCookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) == ' ') {\n c = c.substring(1);\n }\n if (c.indexOf(name) == 0) {\n return c.substring(name.length, c.length);\n }\n }\n return '';\n }\n};\n\n//# sourceURL=webpack:///./src/js/persistent-ops.js?"); /***/ }), diff --git a/dist/index.html b/dist/index.html index cfdcafa..7c99e9c 100644 --- a/dist/index.html +++ b/dist/index.html @@ -139,7 +139,7 @@
View Repositories for the user mohiit1502?