Setting up event's selector
This commit is contained in:
1 parent
58a4fa60d8
commit
b7e885a340
9 files changed
+221
-24
No files matched your search
@@ -3,7 +3,7 @@ function newPlayStopButton() {
|
||||
|
||||
var thisObject = {
|
||||
container: undefined,
|
||||
setDatetime: setDatetime,
|
||||
setDatetime: setDatetime,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize
|
||||
@@ -59,8 +59,7 @@ function newPlayStopButton() {
|
||||
}
|
||||
|
||||
function resize() {
|
||||
|
||||
container.frame.position.x = viewPort.visibleArea.topLeft.x + 150 * 4;
|
||||
container.frame.position.x = viewPort.visibleArea.topLeft.x + 150 * 5;
|
||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
||||
|
||||
}
|
||||
@@ -161,4 +160,4 @@ function newPlayStopButton() {
|
||||
|
||||
browserCanvasContext.drawImage(image, imagePoint.x, imagePoint.y, imageWidth, imageHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -104,6 +104,9 @@
|
||||
<Compile Include="TopSpace\CurrentStartMode.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TopSpace\CurrentEvent.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TopSpace\DevTeam.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -223,4 +226,4 @@
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
</Project>
|
||||
+9
-2
@@ -11,6 +11,7 @@ function newTopSpace() {
|
||||
currentBot: undefined,
|
||||
currentProcess: undefined,
|
||||
currentStartMode: undefined,
|
||||
currentEvent: undefined,
|
||||
login: undefined,
|
||||
initialize: initialize
|
||||
};
|
||||
@@ -29,6 +30,7 @@ function newTopSpace() {
|
||||
|
||||
let sharedStatus = {
|
||||
currentDevTeamIndex: 0,
|
||||
currentEventIndex: 0,
|
||||
currentUserBotIndex: 0,
|
||||
currentProcessIndex: 0,
|
||||
currentBotType: "",
|
||||
@@ -43,6 +45,7 @@ function newTopSpace() {
|
||||
thisObject.currentBot = newCurrentBot();
|
||||
thisObject.currentProcess = newCurrentProcess();
|
||||
thisObject.currentStartMode = newCurrentStartMode();
|
||||
thisObject.currentEvent = newCurrentEvent();
|
||||
thisObject.devTeam = newDevTeam();
|
||||
|
||||
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
|
||||
@@ -54,8 +57,8 @@ function newTopSpace() {
|
||||
thisObject.currentBot.initialize(sharedStatus);
|
||||
thisObject.currentProcess.initialize(sharedStatus);
|
||||
thisObject.currentStartMode.initialize(sharedStatus);
|
||||
thisObject.currentEvent.initialize(sharedStatus);
|
||||
thisObject.devTeam.initialize(sharedStatus);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +94,9 @@ function newTopSpace() {
|
||||
container = thisObject.currentStartMode.getContainer(point);
|
||||
if (container !== undefined) { return container; }
|
||||
|
||||
container = thisObject.currentEvent.getContainer(point);
|
||||
if (container !== undefined) { return container; }
|
||||
|
||||
container = thisObject.login.getContainer(point);
|
||||
if (container !== undefined) { return container; }
|
||||
|
||||
@@ -111,6 +117,7 @@ function newTopSpace() {
|
||||
thisObject.currentBot.draw();
|
||||
thisObject.currentProcess.draw();
|
||||
thisObject.currentStartMode.draw();
|
||||
thisObject.currentEvent.draw();
|
||||
thisObject.login.draw();
|
||||
|
||||
}
|
||||
@@ -129,4 +136,4 @@ function newTopSpace() {
|
||||
browserCanvasContext.fill();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ function newCurrentBot() {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize
|
||||
};
|
||||
|
||||
@@ -153,4 +153,4 @@ function newCurrentBot() {
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
||||
browserCanvasContext.fillText(label, point.x, point.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
function newCurrentEvent() {
|
||||
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize
|
||||
};
|
||||
|
||||
let container = newContainer();
|
||||
container.initialize();
|
||||
thisObject.container = container;
|
||||
|
||||
thisObject.container.frame.width = 150;
|
||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
|
||||
|
||||
resize();
|
||||
|
||||
container.isDraggeable = false;
|
||||
container.isClickeable = true;
|
||||
|
||||
const NOT_FOUND = "Event NOT FOUND";
|
||||
|
||||
let sharedStatus;
|
||||
let storedEvents;
|
||||
let label = "Event -"
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(pSharedStatus) {
|
||||
|
||||
let sessionToken = window.localStorage.getItem('sessionToken');
|
||||
|
||||
if (sessionToken === null || sessionToken === "") {
|
||||
/* not logged in */
|
||||
return;
|
||||
}
|
||||
|
||||
sharedStatus = pSharedStatus;
|
||||
|
||||
storedEvents = window.localStorage.getItem('currentEvents');
|
||||
if (storedEvents === null || storedEvents === "[]" || storedEvents === "") {
|
||||
window.EVENTS = "";
|
||||
window.CURRENT_EVENT_TITLE = "";
|
||||
label = NOT_FOUND;
|
||||
} else {
|
||||
storedEvents = JSON.parse(storedEvents)
|
||||
window.EVENTS = storedEvents;
|
||||
window.CURRENT_EVENT_TITLE = storedEvents[sharedStatus.currentEventIndex].title;
|
||||
label = "Event - " + storedEvents[sharedStatus.currentEventIndex].title;
|
||||
sharedStatus.eventHandler.raiseEvent("Event Changed");
|
||||
}
|
||||
|
||||
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
|
||||
|
||||
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
|
||||
}
|
||||
|
||||
function resize() {
|
||||
|
||||
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 2;
|
||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
||||
|
||||
}
|
||||
|
||||
function onClick() {
|
||||
|
||||
let sessionToken = window.localStorage.getItem('sessionToken');
|
||||
|
||||
if (sessionToken === null || sessionToken === "") {
|
||||
/* not logged in */
|
||||
return;
|
||||
}
|
||||
|
||||
if (sharedStatus.currentEventIndex + 1 === window.EVENTS.length) {
|
||||
|
||||
sharedStatus.currentEventIndex = 0;
|
||||
window.CURRENT_EVENT_TITLE = storedEvents[sharedStatus.currentEventIndex].title;
|
||||
label = "Event - " + storedEvents[sharedStatus.currentEventIndex].title;
|
||||
sharedStatus.eventHandler.raiseEvent("Event Changed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sharedStatus.currentEventIndex + 1 < window.EVENTS.length) {
|
||||
|
||||
sharedStatus.currentEventIndex++;
|
||||
window.CURRENT_EVENT_TITLE = storedEvents[sharedStatus.currentEventIndex].title;
|
||||
label = "Event - " + storedEvents[sharedStatus.currentEventIndex].title;
|
||||
sharedStatus.eventHandler.raiseEvent("Event Changed");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
|
||||
let container;
|
||||
|
||||
/* First we check if this point is inside this object UI. */
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
|
||||
return this.container;
|
||||
|
||||
} else {
|
||||
|
||||
/* This point does not belong to this space. */
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function draw() {
|
||||
|
||||
let sessionToken = window.localStorage.getItem('sessionToken');
|
||||
|
||||
if (sessionToken === null || sessionToken === "") {
|
||||
/* not logged in */
|
||||
return;
|
||||
}
|
||||
|
||||
thisObject.container.frame.draw(false, false);
|
||||
|
||||
let breakpointsHeight = 14;
|
||||
let fontSize = 12;
|
||||
|
||||
let point = {
|
||||
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize / 3,
|
||||
y: thisObject.container.frame.height / 2 + fontSize / 2 + breakpointsHeight
|
||||
};
|
||||
|
||||
point = thisObject.container.frame.frameThisPoint(point);
|
||||
|
||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY;
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
||||
browserCanvasContext.fillText(label, point.x, point.y);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ function newCurrentProcess() {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize
|
||||
};
|
||||
|
||||
@@ -56,7 +56,7 @@ function newCurrentProcess() {
|
||||
|
||||
function resize() {
|
||||
|
||||
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 2;
|
||||
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 3;
|
||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
||||
|
||||
}
|
||||
@@ -71,7 +71,7 @@ function newCurrentProcess() {
|
||||
window.CURRENT_PROCESS = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes[sharedStatus.currentProcessIndex].name;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.CURRENT_PROCESS = NOT_FOUND;
|
||||
@@ -147,4 +147,4 @@ function newCurrentProcess() {
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
||||
browserCanvasContext.fillText(label, point.x, point.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ function newCurrentStartMode() {
|
||||
|
||||
function resize() {
|
||||
|
||||
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 3;
|
||||
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 4;
|
||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
||||
|
||||
}
|
||||
@@ -100,7 +100,7 @@ function newCurrentStartMode() {
|
||||
}
|
||||
|
||||
if (window.CURRENT_BOT_DISPLAY_NAME === "") { return;}
|
||||
|
||||
|
||||
thisObject.container.frame.draw(false, false);
|
||||
|
||||
let breakpointsHeight = 14;
|
||||
@@ -119,4 +119,4 @@ function newCurrentStartMode() {
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
||||
browserCanvasContext.fillText(label, point.x, point.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
|
||||
function newDevTeam() {
|
||||
function newDevTeam() {
|
||||
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
|
||||
+56
-6
@@ -29,7 +29,7 @@ function newLogin() {
|
||||
|
||||
function initialize(callBackFunction) {
|
||||
|
||||
|
||||
|
||||
const accessToken = window.localStorage.getItem("access_token");
|
||||
let user = window.localStorage.getItem("user");
|
||||
|
||||
@@ -90,7 +90,7 @@ function newLogin() {
|
||||
})
|
||||
.then(response => {
|
||||
sessionToken = response.data.users_UserByAuthId.sessionToken;
|
||||
|
||||
|
||||
window.localStorage.setItem('loggedInUser', JSON.stringify(response.data.users_UserByAuthId));
|
||||
resolve({ user: response.data.users_UserByAuthId})
|
||||
})
|
||||
@@ -99,7 +99,7 @@ function newLogin() {
|
||||
reject(error)
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const networkInterfaceTeams = Apollo.lib.createNetworkInterface({
|
||||
uri: window.canvasApp.graphQL.masterAppApiUrl
|
||||
@@ -169,17 +169,67 @@ function newLogin() {
|
||||
})
|
||||
}
|
||||
|
||||
// Gettings events
|
||||
|
||||
|
||||
const networkInterfaceEvents = Apollo.lib.createNetworkInterface({
|
||||
uri: window.canvasApp.graphQL.masterAppApiUrl
|
||||
});
|
||||
|
||||
networkInterfaceEvents.use([{
|
||||
applyMiddleware(req, next) {
|
||||
req.options.headers = {
|
||||
authorization: `Bearer ${accessToken}`
|
||||
};
|
||||
next();
|
||||
}
|
||||
}]);
|
||||
|
||||
const apolloClientEvents = new Apollo.lib.ApolloClient({
|
||||
networkInterface: networkInterfaceEvents,
|
||||
connectToDevTools: true,
|
||||
});
|
||||
|
||||
const EVENTS = Apollo.gql`
|
||||
query events($maxStartDate: Int, $minEndDate: Int){
|
||||
events_Events(maxStartDate: $maxStartDate, minEndDate: $minEndDate){
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const getCurrentEvents = () => {
|
||||
var d = new Date();
|
||||
var nowSeconds = Math.round(d.getTime() / 1000);
|
||||
var twoWeeksAgoSeconds = nowSeconds - 1209600;
|
||||
return new Promise((resolve, reject) => {
|
||||
apolloClientEvents.query({
|
||||
query: EVENTS,
|
||||
variables: { maxStartDate: nowSeconds, minEndDate: twoWeeksAgoSeconds }
|
||||
})
|
||||
.then(response => {
|
||||
window.localStorage.setItem('currentEvents', JSON.stringify(response.data.events_Events));
|
||||
resolve({ currentEvents: response.data.events_Events})
|
||||
})
|
||||
.catch(error => {
|
||||
console.log("apolloClient error getting current events", error)
|
||||
reject (error)
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
// To avoid race conditions, add asynchronous fetches to array
|
||||
let fetchDataPromises = [];
|
||||
|
||||
fetchDataPromises.push(getUser(), getTeamByOwner());
|
||||
fetchDataPromises.push(getUser(), getTeamByOwner(), getCurrentEvents());
|
||||
|
||||
// When all asynchronous fetches resolve, authenticate user or throw error.
|
||||
Promise.all(fetchDataPromises).then(result => {
|
||||
|
||||
/* this is the time to authenticate the user at AAWeb */
|
||||
|
||||
authenticateUser();
|
||||
authenticateUser();
|
||||
|
||||
}, err => {
|
||||
console.error("fetchData error", err)
|
||||
@@ -219,7 +269,7 @@ function newLogin() {
|
||||
|
||||
|
||||
function onClick() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
|
||||
Reference in new issue
Block a user