Clean up
This commit is contained in:
@@ -6,6 +6,8 @@ import * as microbotOps from './services/microbot-ops';
|
|||||||
|
|
||||||
import { Helper } from './helpers/helper';
|
import { Helper } from './helpers/helper';
|
||||||
|
|
||||||
|
import { store } from "./services/persistent-ops.js";
|
||||||
|
|
||||||
const recastclient = new recastOps.Recast();
|
const recastclient = new recastOps.Recast();
|
||||||
const dom = new domManipulator.DomManipulator();
|
const dom = new domManipulator.DomManipulator();
|
||||||
const app = new microbotOps.Microbot();
|
const app = new microbotOps.Microbot();
|
||||||
@@ -71,7 +73,9 @@ $(document).ready(() => {
|
|||||||
const intent = $(`#${$config.constants.hiddenIntentFieldId}`).val();
|
const intent = $(`#${$config.constants.hiddenIntentFieldId}`).val();
|
||||||
if (intent) {
|
if (intent) {
|
||||||
data.intent = intent;
|
data.intent = intent;
|
||||||
// store.dispatch($)
|
var action = $config.intentSlugToOperations[intent].action;
|
||||||
|
action.payload = data;
|
||||||
|
store.dispatch(action);
|
||||||
const operation = $config.intentSlugToOperations[intent].githubOperation;
|
const operation = $config.intentSlugToOperations[intent].githubOperation;
|
||||||
app[operation](data);
|
app[operation](data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { createissue } from "../views/createissue.js";
|
|||||||
import { createrepo } from "../views/createrepo.js";
|
import { createrepo } from "../views/createrepo.js";
|
||||||
import { displaylastcomment } from "../views/displaylastcomment.js";
|
import { displaylastcomment } from "../views/displaylastcomment.js";
|
||||||
import { viewrepos } from "../views/viewrepos.js";
|
import { viewrepos } from "../views/viewrepos.js";
|
||||||
import { PersistentOps } from "./persistent-ops.js";
|
// import { PersistentOps } from "./persistent-ops.js";
|
||||||
import { store } from "./persistent-ops.js";
|
import { store } from "./persistent-ops.js";
|
||||||
|
|
||||||
const $config = require("../config.js");
|
const $config = require("../config.js");
|
||||||
@@ -14,490 +14,500 @@ const $config = require("../config.js");
|
|||||||
const helper = new helperOps.Helper();
|
const helper = new helperOps.Helper();
|
||||||
|
|
||||||
export class DomManipulator {
|
export class DomManipulator {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.createRepoWidgetCreated = false;
|
this.createRepoWidgetCreated = false;
|
||||||
this.commandCardCounter = 1;
|
this.commandCardCounter = 1;
|
||||||
this.map = {
|
this.map = {
|
||||||
addcollab,
|
addcollab,
|
||||||
addissuecomment,
|
addissuecomment,
|
||||||
closeissue,
|
closeissue,
|
||||||
createissue,
|
createissue,
|
||||||
createrepo,
|
createrepo,
|
||||||
displaylastcomment,
|
displaylastcomment,
|
||||||
viewrepos,
|
viewrepos,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
showWidget(intent) {
|
showWidget(intent) {
|
||||||
let widget = document.getElementById(intent);
|
let widget = document.getElementById(intent);
|
||||||
if (widget) {
|
if (!widget) {
|
||||||
if (!this.isVisible(widget)) {
|
widget = this.getWidget(intent);
|
||||||
widget.classList.remove("hide");
|
widgets.prepend(widget);
|
||||||
$("#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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!this.isVisible(widget)) {
|
||||||
displayIntentBox(intent) {
|
widget.classList.remove("hide");
|
||||||
const intentBox = document.getElementById("intentBox");
|
$("#underWidgetLine").removeClass("hide");
|
||||||
if (!this.isVisible(intentBox)) {
|
|
||||||
intentBox.classList.remove("hide");
|
|
||||||
}
|
|
||||||
$("#intentName").text(`${$config.intentSlugToOperations[intent].intentMessage} [slug: ${intent}].`);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
showEmptyCommandMessage(message) {
|
getWidget(intent) {
|
||||||
$("#randomModal").text(message);
|
const template = document.createElement("template");
|
||||||
$("#emptyCommandMsgDisplayer").click();
|
template.innerHTML = this.map[intent];
|
||||||
|
let widget = template.content.firstChild;
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
displayIntentBox(intent) {
|
||||||
|
const intentBox = document.getElementById("intentBox");
|
||||||
|
if (!this.isVisible(intentBox)) {
|
||||||
|
intentBox.classList.remove("hide");
|
||||||
}
|
}
|
||||||
|
$("#intentName").text(`${$config.intentSlugToOperations[intent].intentMessage} [slug: ${intent}].`);
|
||||||
|
}
|
||||||
|
|
||||||
populateRecastData(widgetName, recastResponse) {
|
showEmptyCommandMessage(message) {
|
||||||
|
$("#randomModal").text(message);
|
||||||
|
$("#emptyCommandMsgDisplayer").click();
|
||||||
|
}
|
||||||
|
|
||||||
|
populateRecastData(widgetName, recastResponse) {
|
||||||
// var requestMethod = $config.intentSlugToOperations[widgetName]['requestMethod'];
|
// var requestMethod = $config.intentSlugToOperations[widgetName]['requestMethod'];
|
||||||
const operation = $config.intentSlugToOperations[widgetName].populateDataOperation;
|
const operation = $config.intentSlugToOperations[widgetName].populateDataOperation;
|
||||||
if (typeof this[operation] === "function") {
|
if (typeof this[operation] === "function") {
|
||||||
this[operation](recastResponse);
|
this[operation](recastResponse);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
populateCreateRepoData(recastResponse) {
|
populateCreateRepoData(recastResponse) {
|
||||||
const repoNameTextField = document.getElementById("repositoryName");
|
const repoNameTextField = document.getElementById("repositoryName");
|
||||||
if (repoNameTextField && recastResponse && recastResponse.entities["git-repository"] && recastResponse.entities["git-repository"].length > 0
|
if (repoNameTextField && recastResponse && recastResponse.entities["git-repository"] && recastResponse.entities["git-repository"].length > 0
|
||||||
&& recastResponse.entities["git-repository"]["0"].value) {
|
&& recastResponse.entities["git-repository"]["0"].value) {
|
||||||
const repoName = recastResponse.entities["git-repository"]["0"].value;
|
const repoName = recastResponse.entities["git-repository"]["0"].value;
|
||||||
repoNameTextField.value = repoName;
|
repoNameTextField.value = repoName;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
populateCreateIssueData(recastResponse) {
|
populateCreateIssueData(recastResponse) {
|
||||||
const issueTitleTextField = document.getElementById("issueTitle");
|
const issueTitleTextField = document.getElementById("issueTitle");
|
||||||
const issueRepositoryTextField = document.getElementById("issueRepository");
|
const issueRepositoryTextField = document.getElementById("issueRepository");
|
||||||
if (issueTitleTextField && recastResponse && recastResponse.entities.issue_title && recastResponse.entities.issue_title.length > 0
|
if (issueTitleTextField && recastResponse && recastResponse.entities.issue_title && recastResponse.entities.issue_title.length > 0
|
||||||
&& recastResponse.entities.issue_title["0"].value) {
|
&& recastResponse.entities.issue_title["0"].value) {
|
||||||
const issueTitle = recastResponse.entities.issue_title["0"].value;
|
const issueTitle = recastResponse.entities.issue_title["0"].value;
|
||||||
issueTitleTextField.value = issueTitle;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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) {
|
populateCloseIssueData(recastResponse) {
|
||||||
const issueNumberTextField = document.getElementById("issueNumerToClose");
|
const issueNumberTextField = document.getElementById("issueNumerToClose");
|
||||||
const issueRepositoryTextField = document.getElementById("repoForIssueClose");
|
const issueRepositoryTextField = document.getElementById("repoForIssueClose");
|
||||||
if (issueNumberTextField && recastResponse && recastResponse.entities.issue_id && recastResponse.entities.issue_id.length > 0
|
if (issueNumberTextField && recastResponse && recastResponse.entities.issue_id && recastResponse.entities.issue_id.length > 0
|
||||||
&& recastResponse.entities.issue_id["0"].value) {
|
&& recastResponse.entities.issue_id["0"].value) {
|
||||||
const issueNumber = recastResponse.entities.issue_id["0"].value;
|
const issueNumber = recastResponse.entities.issue_id["0"].value;
|
||||||
issueNumberTextField.value = issueNumber;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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) {
|
populateAddCollaboratorData(recastResponse) {
|
||||||
const collaboratorNameTextField = document.getElementById("collaboratorName");
|
const collaboratorNameTextField = document.getElementById("collaboratorName");
|
||||||
const repoForCollabTextField = document.getElementById("repoForCollab");
|
const repoForCollabTextField = document.getElementById("repoForCollab");
|
||||||
if (collaboratorNameTextField && recastResponse && recastResponse.entities.git_collaborator && recastResponse.entities.git_collaborator.length > 0
|
if (collaboratorNameTextField && recastResponse && recastResponse.entities.git_collaborator && recastResponse.entities.git_collaborator.length > 0
|
||||||
&& recastResponse.entities.git_collaborator["0"].value) {
|
&& recastResponse.entities.git_collaborator["0"].value) {
|
||||||
const collaboratorName = recastResponse.entities.git_collaborator["0"].value;
|
const collaboratorName = recastResponse.entities.git_collaborator["0"].value;
|
||||||
collaboratorNameTextField.value = collaboratorName;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (repoForCollabTextField && recastResponse && recastResponse.entities["git-repository"] && recastResponse.entities["git-repository"].length > 0
|
||||||
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) {
|
&& recastResponse.entities["git-repository"]["0"].value) {
|
||||||
const repoForIssueComment = recastResponse.entities["git-repository"]["0"].value;
|
const repoName = recastResponse.entities["git-repository"]["0"].value;
|
||||||
repoForIssueCommentTextField.value = repoForIssueComment;
|
repoForCollabTextField.value = repoName;
|
||||||
}
|
}
|
||||||
if (issueNumberTextField && recastResponse && recastResponse.entities.issue_id && recastResponse.entities.issue_id.length > 0
|
}
|
||||||
|
|
||||||
|
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) {
|
&& recastResponse.entities.issue_id["0"].value) {
|
||||||
const issueNumber = recastResponse.entities.issue_id["0"].value;
|
const issueNumber = recastResponse.entities.issue_id["0"].value;
|
||||||
issueNumberTextField.value = issueNumber;
|
issueNumberTextField.value = issueNumber;
|
||||||
}
|
}
|
||||||
if (issueCommentTextArea && recastResponse && recastResponse.entities.issue_comment && recastResponse.entities.issue_comment.length > 0
|
if (issueCommentTextArea && recastResponse && recastResponse.entities.issue_comment && recastResponse.entities.issue_comment.length > 0
|
||||||
&& recastResponse.entities.issue_comment["0"].value) {
|
&& recastResponse.entities.issue_comment["0"].value) {
|
||||||
const issueComment = recastResponse.entities.issue_comment["0"].value;
|
const issueComment = recastResponse.entities.issue_comment["0"].value;
|
||||||
issueCommentTextArea.value = issueComment;
|
issueCommentTextArea.value = issueComment;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
populateDisplayCommentData(recastResponse) {
|
populateDisplayCommentData(recastResponse) {
|
||||||
const issueNumberTextField = document.getElementById("issueNumberForCommentView");
|
const issueNumberTextField = document.getElementById("issueNumberForCommentView");
|
||||||
const issueRepositoryTextField = document.getElementById("repoForCommentView");
|
const issueRepositoryTextField = document.getElementById("repoForCommentView");
|
||||||
if (issueNumberTextField && recastResponse && recastResponse.entities.issue_id && recastResponse.entities.issue_id.length > 0
|
if (issueNumberTextField && recastResponse && recastResponse.entities.issue_id && recastResponse.entities.issue_id.length > 0
|
||||||
&& recastResponse.entities.issue_id["0"].value) {
|
&& recastResponse.entities.issue_id["0"].value) {
|
||||||
const issueNumber = recastResponse.entities.issue_id["0"].value;
|
const issueNumber = recastResponse.entities.issue_id["0"].value;
|
||||||
issueNumberTextField.value = issueNumber;
|
issueNumberTextField.value = issueNumber;
|
||||||
}
|
}
|
||||||
if (issueRepositoryTextField && recastResponse && recastResponse.entities["git-repository"] && recastResponse.entities["git-repository"].length > 0
|
if (issueRepositoryTextField && recastResponse && recastResponse.entities["git-repository"] && recastResponse.entities["git-repository"].length > 0
|
||||||
&& recastResponse.entities["git-repository"]["0"].value) {
|
&& recastResponse.entities["git-repository"]["0"].value) {
|
||||||
const repoName = recastResponse.entities["git-repository"]["0"].value;
|
const repoName = recastResponse.entities["git-repository"]["0"].value;
|
||||||
issueRepositoryTextField.value = repoName;
|
issueRepositoryTextField.value = repoName;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isVisible(element) {
|
isVisible(element) {
|
||||||
return element ? !element.classList.contains("hide") : false;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
getDataFromFormAsJSON() {
|
getCreateRepoJson() {
|
||||||
let data = {};
|
const data = {};
|
||||||
const intent = $(`#${$config.constants.hiddenIntentFieldId}`).val();
|
const request = {};
|
||||||
const requestMethod = $config.intentSlugToOperations[intent].requestMethod;
|
if (this.isVisible(document.getElementById("createrepo"))) {
|
||||||
if (intent) {
|
request.name = document.getElementById("repositoryName").value;
|
||||||
const operation = $config.intentSlugToOperations[intent].getDataOperation;
|
request.description = document.getElementById("description").value;
|
||||||
if (typeof this[operation] === "function") {
|
request.homepage = document.getElementById("homePageURL").value;
|
||||||
data = this[operation]();
|
request.private = document.getElementById("privateRepoChk").checked;
|
||||||
}
|
request.has_issues = document.getElementById("issuesChk").checked;
|
||||||
}
|
request.has_wiki = document.getElementById("wikiChk").checked;
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
data.request = request;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
getCreateRepoJson() {
|
getCreateIssueJson() {
|
||||||
const data = {};
|
const data = {};
|
||||||
const request = {};
|
data.urlParams = {};
|
||||||
if (this.isVisible(document.getElementById("createrepo"))) {
|
const request = {};
|
||||||
request.name = document.getElementById("repositoryName").value;
|
if (this.isVisible(document.getElementById("createissue"))) {
|
||||||
request.description = document.getElementById("description").value;
|
request.title = document.getElementById("issueTitle").value;
|
||||||
request.homepage = document.getElementById("homePageURL").value;
|
request.body = document.getElementById("description").value;
|
||||||
request.private = document.getElementById("privateRepoChk").checked;
|
request.assignees = document.getElementById("assignees").value ? document.getElementById("assignees").value.split(",") : [];
|
||||||
request.has_issues = document.getElementById("issuesChk").checked;
|
request.labels = document.getElementById("labels").value ? document.getElementById("labels").value.split(",") : [];
|
||||||
request.has_wiki = document.getElementById("wikiChk").checked;
|
data.urlParams.repoName = document.getElementById("issueRepository").value;
|
||||||
}
|
|
||||||
data.request = request;
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
data.request = request;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
getCreateIssueJson() {
|
getCloseIssueJson() {
|
||||||
const data = {};
|
const data = {};
|
||||||
data.urlParams = {};
|
data.urlParams = {};
|
||||||
const request = {};
|
if (this.isVisible(document.getElementById("closeissue"))) {
|
||||||
if (this.isVisible(document.getElementById("createissue"))) {
|
data.urlParams.issueId = document.getElementById("issueNumerToClose").value;
|
||||||
request.title = document.getElementById("issueTitle").value;
|
data.urlParams.repoName = document.getElementById("repoForIssueClose").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;
|
|
||||||
}
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
getCloseIssueJson() {
|
getAddCollaboratorJson() {
|
||||||
const data = {};
|
const data = {};
|
||||||
data.urlParams = {};
|
data.urlParams = {};
|
||||||
if (this.isVisible(document.getElementById("closeissue"))) {
|
if (this.isVisible(document.getElementById("addcollab"))) {
|
||||||
data.urlParams.issueId = document.getElementById("issueNumerToClose").value;
|
data.urlParams.collaborator = document.getElementById("collaboratorName").value;
|
||||||
data.urlParams.repoName = document.getElementById("repoForIssueClose").value;
|
data.urlParams.repoName = document.getElementById("repoForCollab").value;
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
getAddCollaboratorJson() {
|
getAddCommentJson() {
|
||||||
const data = {};
|
const data = {};
|
||||||
data.urlParams = {};
|
data.urlParams = {};
|
||||||
if (this.isVisible(document.getElementById("addcollab"))) {
|
const request = {};
|
||||||
data.urlParams.collaborator = document.getElementById("collaboratorName").value;
|
if (this.isVisible(document.getElementById("addissuecomment"))) {
|
||||||
data.urlParams.repoName = document.getElementById("repoForCollab").value;
|
request.body = document.getElementById("issueComment").value;
|
||||||
}
|
data.urlParams.issueId = document.getElementById("issueNumber").value;
|
||||||
return data;
|
data.urlParams.repoName = document.getElementById("repoForIssueComment").value;
|
||||||
}
|
}
|
||||||
|
data.request = request;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
getAddCommentJson() {
|
getDisplayCommentJson() {
|
||||||
const data = {};
|
const data = {};
|
||||||
data.urlParams = {};
|
data.urlParams = {};
|
||||||
const request = {};
|
if (this.isVisible(document.getElementById("displaylastcomment"))) {
|
||||||
if (this.isVisible(document.getElementById("addissuecomment"))) {
|
data.urlParams.issueId = document.getElementById("issueNumberForCommentView").value;
|
||||||
request.body = document.getElementById("issueComment").value;
|
data.urlParams.repoName = document.getElementById("repoForCommentView").value;
|
||||||
data.urlParams.issueId = document.getElementById("issueNumber").value;
|
|
||||||
data.urlParams.repoName = document.getElementById("repoForIssueComment").value;
|
|
||||||
}
|
|
||||||
data.request = request;
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
getDisplayCommentJson() {
|
addGitOperationHistory(data) {
|
||||||
const data = {};
|
const intent = data.intent;
|
||||||
data.urlParams = {};
|
let requestMethod = "";
|
||||||
if (this.isVisible(document.getElementById("displaylastcomment"))) {
|
if (intent) {
|
||||||
data.urlParams.issueId = document.getElementById("issueNumberForCommentView").value;
|
requestMethod = $config.intentSlugToOperations[intent].requestMethod;
|
||||||
data.urlParams.repoName = document.getElementById("repoForCommentView").value;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
const conversations = document.getElementById("conversations");
|
||||||
addGitOperationHistory(data) {
|
let table;
|
||||||
const intent = data.intent;
|
let comment;
|
||||||
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}<a class='repoLink' href='${data[$config.intentSlugToOperations[intent].cardDataUrl]}'>${this.getVariable(data, $config.intentSlugToOperations[intent].cardDataName)}</a>`;
|
|
||||||
} else if (requestMethod == "get") {
|
|
||||||
cardText.innerHTML = $config.intentSlugToOperations[intent].cardMsg;
|
|
||||||
if (data && data.length && data.length > 0) {
|
|
||||||
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
|
// Create Elements
|
||||||
const table = document.createElement("table");
|
const card = document.createElement("div");
|
||||||
const thead = document.createElement("thead");
|
const cardBody = document.createElement("div");
|
||||||
const tr_head = document.createElement("tr");
|
const cardTitle = document.createElement("h5");
|
||||||
const th_1 = document.createElement("th");
|
const closeAnchor = document.createElement("a");
|
||||||
const th_2 = document.createElement("th");
|
const closeHeader = document.createElement("h6");
|
||||||
const th_3 = document.createElement("th");
|
const cardText = document.createElement("p");
|
||||||
const th_4 = document.createElement("th");
|
const cardFooter = document.createElement("div");
|
||||||
const th_5 = document.createElement("th");
|
const textMuted = document.createElement("small");
|
||||||
const th_6 = document.createElement("th");
|
const underCardLine = document.createElement("div");
|
||||||
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 Inner HTML
|
|
||||||
th_1.innerHTML = "#";
|
|
||||||
th_2.innerHTML = "Repository Name";
|
|
||||||
th_3.innerHTML = "Repository ID";
|
|
||||||
th_4.innerHTML = "Created On";
|
|
||||||
th_5.innerHTML = "Created By";
|
|
||||||
th_6.innerHTML = "View Raw";
|
|
||||||
th_7.innerHTML = "Delete Repository";
|
|
||||||
|
|
||||||
// Associations
|
|
||||||
tr_head.appendChild(th_1);
|
|
||||||
tr_head.appendChild(th_2);
|
|
||||||
tr_head.appendChild(th_3);
|
|
||||||
tr_head.appendChild(th_4);
|
|
||||||
tr_head.appendChild(th_5);
|
|
||||||
tr_head.appendChild(th_6);
|
|
||||||
tr_head.appendChild(th_7);
|
|
||||||
thead.appendChild(tr_head);
|
|
||||||
table.appendChild(thead);
|
|
||||||
|
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
// Add Attributes
|
||||||
const currentRepo = data[i];
|
card.classList.add("card");
|
||||||
// Create Elements
|
cardBody.classList.add("card-body");
|
||||||
const tbody = document.createElement("tbody");
|
cardTitle.classList.add("card-title");
|
||||||
const tr_body = document.createElement("tr");
|
closeAnchor.classList.add("close");
|
||||||
const th_vertical = document.createElement("th");
|
// closeAnchor.setAttribute('href', '#');
|
||||||
const td_1 = document.createElement("td");
|
cardText.classList.add("card-text");
|
||||||
const td_2 = document.createElement("td");
|
cardFooter.classList.add("card-footer");
|
||||||
const td_3 = document.createElement("td");
|
textMuted.classList.add("text-muted");
|
||||||
const td_4 = document.createElement("td");
|
underCardLine.classList.add("line");
|
||||||
const td_5 = document.createElement("td");
|
|
||||||
const td_6 = document.createElement("td");
|
|
||||||
|
|
||||||
// Add Attributes
|
// Add content
|
||||||
th_vertical.setAttribute("scope", "row");
|
closeHeader.innerHTML = "x";
|
||||||
tr_body.setAttribute("id", `repoRow${i}`);
|
|
||||||
|
|
||||||
// Add Inner HTML
|
const x = this.display_ct(0, textMuted);
|
||||||
th_vertical.innerHTML = i + 1;
|
if (data.type === "command") {
|
||||||
td_1.innerHTML = currentRepo.name;
|
// Add content
|
||||||
td_2.innerHTML = `<a href='${currentRepo.html_url}' class='repoLink'>${currentRepo.id}</a>`;
|
cardTitle.innerHTML = "You Said";
|
||||||
td_3.innerHTML = currentRepo.created_at;
|
cardText.innerHTML = data.command;
|
||||||
td_4.innerHTML = `<a href='${currentRepo.owner.html_url}' class='btn btn-info'>${currentRepo.owner.login}</a>`;
|
card.classList.add("light-red");
|
||||||
td_5.innerHTML = `<a href='${currentRepo.url}' class='btn btn-info'>View</a>`;
|
const repeat = document.createElement("a");
|
||||||
td_6.innerHTML = `<a href='${currentRepo.owner.html_url}' class='btn btn-danger'>Delete</a>`;
|
repeat.classList.add("btn", "btn-info", "float-right");
|
||||||
|
repeat.setAttribute("role", "button");
|
||||||
// Associations
|
repeat.setAttribute("href", "#");
|
||||||
tr_body.appendChild(th_vertical);
|
repeat.setAttribute("id", `btnRepeatCommand${data.insertionCounter}`);
|
||||||
tr_body.appendChild(td_1);
|
repeat.innerHTML = "Repeat";
|
||||||
tr_body.appendChild(td_2);
|
cardText.appendChild(repeat);
|
||||||
tr_body.appendChild(td_3);
|
} else if (data.type === "response") {
|
||||||
tr_body.appendChild(td_4);
|
// Add content
|
||||||
tr_body.appendChild(td_5);
|
cardTitle.innerHTML = "Server Responded As..";
|
||||||
tr_body.appendChild(td_6);
|
if (requestMethod == "post") {
|
||||||
tbody.appendChild(tr_body);
|
cardText.innerHTML = `${$config.intentSlugToOperations[intent].cardMsg}<a class='repoLink' href='${data[$config.intentSlugToOperations[intent].cardDataUrl]}'>${this.getVariable(data, $config.intentSlugToOperations[intent].cardDataName)}</a>`;
|
||||||
table.appendChild(tbody);
|
} 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") {
|
||||||
return table;
|
cardTitle.innerHTML = "Operation Completed!";
|
||||||
|
cardText.innerHTML = data.command;
|
||||||
|
}
|
||||||
|
} else if (data.type = 'widget') {
|
||||||
|
cardTitle.innerHTML = "Operation recorded with below data, click submit to repeat.";
|
||||||
|
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 {
|
||||||
|
cardTitle.innerHTML = "Server Responded As..";
|
||||||
|
cardText.innerHTML = `Operation failed with status: ${data.status}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadConversations(historyAll) {
|
// Associations
|
||||||
if (historyAll) {
|
closeAnchor.appendChild(closeHeader);
|
||||||
historyAll.forEach((element) => {
|
cardTitle.appendChild(closeAnchor);
|
||||||
this.addGitOperationHistory(element);
|
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");
|
||||||
|
|
||||||
|
// Add Attributes
|
||||||
|
table.classList.add("table", "tabled-bordered", "table-striped", "table-hover");
|
||||||
|
thead.classList.add("thead-dark");
|
||||||
|
th_1.setAttribute("scope", "col");
|
||||||
|
th_2.setAttribute("scope", "col");
|
||||||
|
th_3.setAttribute("scope", "col");
|
||||||
|
th_4.setAttribute("scope", "col");
|
||||||
|
th_5.setAttribute("scope", "col");
|
||||||
|
th_6.setAttribute("scope", "col");
|
||||||
|
th_7.setAttribute("scope", "col");
|
||||||
|
|
||||||
|
// Add Inner HTML
|
||||||
|
th_1.innerHTML = "#";
|
||||||
|
th_2.innerHTML = "Repository Name";
|
||||||
|
th_3.innerHTML = "Repository ID";
|
||||||
|
th_4.innerHTML = "Created On";
|
||||||
|
th_5.innerHTML = "Created By";
|
||||||
|
th_6.innerHTML = "View Raw";
|
||||||
|
th_7.innerHTML = "Delete Repository";
|
||||||
|
|
||||||
|
// Associations
|
||||||
|
tr_head.appendChild(th_1);
|
||||||
|
tr_head.appendChild(th_2);
|
||||||
|
tr_head.appendChild(th_3);
|
||||||
|
tr_head.appendChild(th_4);
|
||||||
|
tr_head.appendChild(th_5);
|
||||||
|
tr_head.appendChild(th_6);
|
||||||
|
tr_head.appendChild(th_7);
|
||||||
|
thead.appendChild(tr_head);
|
||||||
|
table.appendChild(thead);
|
||||||
|
|
||||||
|
|
||||||
|
for (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 Inner HTML
|
||||||
|
th_vertical.innerHTML = i + 1;
|
||||||
|
td_1.innerHTML = currentRepo.name;
|
||||||
|
td_2.innerHTML = `<a href='${currentRepo.html_url}' class='repoLink'>${currentRepo.id}</a>`;
|
||||||
|
td_3.innerHTML = currentRepo.created_at;
|
||||||
|
td_4.innerHTML = `<a href='${currentRepo.owner.html_url}' class='btn btn-info'>${currentRepo.owner.login}</a>`;
|
||||||
|
td_5.innerHTML = `<a href='${currentRepo.url}' class='btn btn-info'>View</a>`;
|
||||||
|
td_6.innerHTML = `<a href='${currentRepo.owner.html_url}' class='btn btn-danger'>Delete</a>`;
|
||||||
|
|
||||||
|
// Associations
|
||||||
|
tr_body.appendChild(th_vertical);
|
||||||
|
tr_body.appendChild(td_1);
|
||||||
|
tr_body.appendChild(td_2);
|
||||||
|
tr_body.appendChild(td_3);
|
||||||
|
tr_body.appendChild(td_4);
|
||||||
|
tr_body.appendChild(td_5);
|
||||||
|
tr_body.appendChild(td_6);
|
||||||
|
tbody.appendChild(tr_body);
|
||||||
|
table.appendChild(tbody);
|
||||||
}
|
}
|
||||||
|
|
||||||
createCommentBody(data) {
|
return table;
|
||||||
const commentPara = document.createElement("p");
|
}
|
||||||
const lastComment = helper.getLatestComment(data);
|
|
||||||
commentPara.classList.add("card-text");
|
|
||||||
commentPara.innerHTML = `<strong style='color:black'>COMMENT:</strong> <i>${lastComment}</i>`;
|
|
||||||
return commentPara;
|
|
||||||
}
|
|
||||||
|
|
||||||
concealCodeInUrl() {
|
loadConversations(historyAll) {
|
||||||
window.location = "http://localhost:8080";
|
if (historyAll) {
|
||||||
|
historyAll.forEach((element) => {
|
||||||
|
this.addGitOperationHistory(element);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleModals(response) {
|
createCommentBody(data) {
|
||||||
const self = this;
|
const commentPara = document.createElement("p");
|
||||||
const promise = response.json();
|
const lastComment = helper.getLatestComment(data);
|
||||||
const intent = $(`#${$config.constants.hiddenIntentFieldId}`).val();
|
commentPara.classList.add("card-text");
|
||||||
$("#submitConfirm").addClass("hide");
|
commentPara.innerHTML = `<strong style='color:black'>COMMENT:</strong> <i>${lastComment}</i>`;
|
||||||
$("#btnCancelConfirm").click();
|
return commentPara;
|
||||||
$(".modal-backdrop").removeClass("modal-backdrop");
|
}
|
||||||
$("#underWidgetLine").addClass("hide");
|
|
||||||
$("#intentBox").addClass("hide");
|
concealCodeInUrl() {
|
||||||
$("#widgets").children().addClass("hide");
|
window.location = "http://localhost:8080";
|
||||||
if (response && response.status && (response.status === 201 || response.status === 200 || response.status === 204)) {
|
}
|
||||||
$("#successAlert").removeClass("hide");
|
|
||||||
promise.then((body) => {
|
toggleModals(response) {
|
||||||
$("#op-msg").text($config.intentSlugToOperations[intent].successMessage);
|
const self = this;
|
||||||
$("#successAlert").removeClass("hide");
|
const promise = response.json();
|
||||||
const action = $config.intentSlugToOperations[intent].response_action;
|
const intent = $(`#${$config.constants.hiddenIntentFieldId}`).val();
|
||||||
body.intent = intent;
|
$("#submitConfirm").addClass("hide");
|
||||||
action.payload = body;
|
$("#btnCancelConfirm").click();
|
||||||
store.dispatch(action);
|
$(".modal-backdrop").removeClass("modal-backdrop");
|
||||||
// self.addGitOperationHistory(body, 'response');
|
$("#underWidgetLine").addClass("hide");
|
||||||
});
|
$("#intentBox").addClass("hide");
|
||||||
} else {
|
$("#widgets").children().addClass("hide");
|
||||||
$("#dangerAlert").removeClass("hide");
|
if (response && response.status && (response.status === 201 || response.status === 200 || response.status === 204)) {
|
||||||
// self.addGitOperationHistory(response.status);
|
$("#successAlert").removeClass("hide");
|
||||||
}
|
promise.then((body) => {
|
||||||
// clear intent
|
$("#op-msg").text($config.intentSlugToOperations[intent].successMessage);
|
||||||
$(`#${$config.constants.hiddenIntentFieldId}`).val("");
|
$("#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.constants.hiddenIntentFieldId}`).val("");
|
||||||
|
}
|
||||||
|
|
||||||
display_ct(start, element) {
|
display_ct(start, element) {
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.element = element;
|
this.element = element;
|
||||||
const days = Math.floor(this.start / 86400);
|
const days = Math.floor(this.start / 86400);
|
||||||
const hours = Math.floor((this.start - (days * 86400)) / 3600);
|
const hours = Math.floor((this.start - (days * 86400)) / 3600);
|
||||||
const minutes = Math.floor((this.start - (days * 86400) - (hours * 3600)) / 60);
|
const minutes = Math.floor((this.start - (days * 86400) - (hours * 3600)) / 60);
|
||||||
const secs = Math.floor((this.start - (days * 86400) - (hours * 3600) - (minutes * 60)));
|
const secs = Math.floor((this.start - (days * 86400) - (hours * 3600) - (minutes * 60)));
|
||||||
let x = "";
|
let x = "";
|
||||||
if (days != 0) {
|
if (days != 0) {
|
||||||
x = `${x + days} days`;
|
x = `${x + days} days`;
|
||||||
}
|
}
|
||||||
if (hours != 0) {
|
if (hours != 0) {
|
||||||
x = `${x + hours} hours`;
|
x = `${x + hours} hours`;
|
||||||
}
|
}
|
||||||
if (minutes != 0) {
|
if (minutes != 0) {
|
||||||
x = `${x + minutes} minutes`;
|
x = `${x + minutes} minutes`;
|
||||||
}
|
}
|
||||||
x = `${x + secs} seconds ago`;
|
x = `${x + secs} seconds ago`;
|
||||||
element.innerHTML = x;
|
element.innerHTML = x;
|
||||||
this.start = this.start + 1;
|
this.start = this.start + 1;
|
||||||
// setTimeout(this['display_ct](this.start, this.element)', 1000 )
|
// setTimeout(this['display_ct](this.start, this.element)', 1000 )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,19 +138,21 @@ function mbReducer(currentState, action) {
|
|||||||
return nextState;
|
return nextState;
|
||||||
break;
|
break;
|
||||||
case "ADD_REPO":
|
case "ADD_REPO":
|
||||||
// let command = document.getElementById('command').value;
|
response = action.payload;
|
||||||
// nextState = window.localStorage.getItem('currentState') ? JSON.parse(window.localStorage.getItem('currentState')) : currentState;
|
nextState = window.localStorage.getItem('currentState') ? JSON.parse(window.localStorage.getItem('currentState')) : currentState;
|
||||||
// newHistory.command = command;
|
newHistory = response;
|
||||||
// newHistory.type = 'command';
|
newHistory.type = 'widget';
|
||||||
// // newHistory.intent = 'commandbot'
|
newHistory.insertionCounter = ++nextState.insertionCounter;
|
||||||
// newHistory.insertionCounter = ++nextState.insertionCounter;
|
if(response.intent) {
|
||||||
// if(nextState.queries) {
|
let intent = response.intent;
|
||||||
// nextState.queries = [ ...nextState.queries, newHistory ];
|
if(nextState[intent]) {
|
||||||
// } else {
|
nextState[intent] = [ ...nextState[intent], newHistory ];
|
||||||
// nextState.queries = [ newHistory ];
|
} else {
|
||||||
// }
|
nextState[intent] = [ newHistory ];
|
||||||
// window.localStorage.setItem('currentState', JSON.stringify(nextState));
|
}
|
||||||
// return nextState;
|
}
|
||||||
|
window.localStorage.setItem('currentState', JSON.stringify(nextState));
|
||||||
|
return nextState;
|
||||||
break;
|
break;
|
||||||
case "ADD_COLLAB":
|
case "ADD_COLLAB":
|
||||||
// let command = document.getElementById('command').value;
|
// let command = document.getElementById('command').value;
|
||||||
|
|||||||
Reference in New Issue
Block a user