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");
|
||||||
@@ -30,21 +30,21 @@ export class DomManipulator {
|
|||||||
|
|
||||||
showWidget(intent) {
|
showWidget(intent) {
|
||||||
let widget = document.getElementById(intent);
|
let widget = document.getElementById(intent);
|
||||||
if (widget) {
|
if (!widget) {
|
||||||
|
widget = this.getWidget(intent);
|
||||||
|
widgets.prepend(widget);
|
||||||
|
}
|
||||||
if (!this.isVisible(widget)) {
|
if (!this.isVisible(widget)) {
|
||||||
widget.classList.remove("hide");
|
widget.classList.remove("hide");
|
||||||
$("#underWidgetLine").removeClass("hide");
|
$("#underWidgetLine").removeClass("hide");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
getWidget(intent) {
|
||||||
const template = document.createElement("template");
|
const template = document.createElement("template");
|
||||||
template.innerHTML = this.map[intent];
|
template.innerHTML = this.map[intent];
|
||||||
widget = template.content.firstChild;
|
let widget = template.content.firstChild;
|
||||||
if (!this.isVisible(widget)) {
|
return widget;
|
||||||
widget.classList.remove("hide");
|
|
||||||
$("#underWidgetLine").removeClass("hide");
|
|
||||||
}
|
|
||||||
widgets.prepend(template.content.firstElementChild);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
displayIntentBox(intent) {
|
displayIntentBox(intent) {
|
||||||
@@ -314,6 +314,16 @@ export class DomManipulator {
|
|||||||
cardTitle.innerHTML = "Operation Completed!";
|
cardTitle.innerHTML = "Operation Completed!";
|
||||||
cardText.innerHTML = data.command;
|
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 {
|
} else {
|
||||||
cardTitle.innerHTML = "Server Responded As..";
|
cardTitle.innerHTML = "Server Responded As..";
|
||||||
cardText.innerHTML = `Operation failed with status: ${data.status}`;
|
cardText.innerHTML = `Operation failed with status: ${data.status}`;
|
||||||
|
|||||||
@@ -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