Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 102 additions & 28 deletions dist/doboard-widget-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -8086,6 +8086,9 @@ const spotfixApiCall = async (data, method, accountId = undefined) => {
clearLocalstorageOnLogout();
checkLogInOutButtonsVisible();
}
if (responseBody.data.operation_message === "Access is denied"){
return {operation_message: "Access is denied"}
}
throw new Error(errorMessage);
}

Expand Down Expand Up @@ -8244,7 +8247,7 @@ const logoutUserDoboard = async (projectToken) => {
}
};

const getTasksDoboard = async (projectToken, sessionId, accountId, projectId, userId) => {
const getTasksDoboard = async (projectToken, sessionId, accountId, projectId, userId, taskId) => {
const data = {
session_id: sessionId,
project_token: projectToken,
Expand All @@ -8254,24 +8257,37 @@ const getTasksDoboard = async (projectToken, sessionId, accountId, projectId, us
if ( userId ) {
data.user_id = userId;
}
if ( taskId ) {
data.task_id = taskId;
}
const result = await spotfixApiCall(data, 'task_get', accountId);
const tasks = result.tasks.map((task) => ({
taskId: task.task_id,
taskTitle: task.name,
userId: task.user_id,
task_type: task.task_type,
commentsCount: task.comments_count,
taskLastUpdate: task.updated,
taskCreated: task.created,
taskCreatorTaskUser: task.creator_user_id,
taskMeta: task.meta,
taskStatus: task.status,
viewers: task.comments_viewers,
taskToken: task.token
}));
await spotfixIndexedDB.clearPut(SPOTFIX_TABLE_TASKS, tasks);
storageSaveTasksCount(tasks);
return tasks;

if(result.operation_message === 'Access is denied'){
await spotfixIndexedDB.put(SPOTFIX_TABLE_TASKS, {taskId: taskId, task_type: 'PRIVATE', taskMeta:"{}"});
return null;
} else {
const tasks = result.tasks.map((task) => ({
taskId: task.task_id,
taskTitle: task.name,
userId: task.user_id,
task_type: task.task_type,
commentsCount: task.comments_count,
taskLastUpdate: task.updated,
taskCreated: task.created,
taskCreatorTaskUser: task.creator_user_id,
taskMeta: task.meta,
taskStatus: task.status,
viewers: task.comments_viewers,
taskToken: task.token
}));
if(taskId){
await spotfixIndexedDB.put(SPOTFIX_TABLE_TASKS, tasks);
} else {
await spotfixIndexedDB.clearPut(SPOTFIX_TABLE_TASKS, tasks);
}
storageSaveTasksCount(tasks);
return tasks;
}
};


Expand Down Expand Up @@ -8695,12 +8711,25 @@ async function spotFixConfirmUserEmail(emailConfirmationToken, params) {
return createdTask;
}

async function getTasksFullDetails(params, tasks, currentActiveTaskId, nonRequesting = false) {
async function getTasksFullDetails(params, tasksList, currentActiveTaskId, nonRequesting = false) {
let tasks = tasksList;
if (tasks.length > 0) {
const sessionId = localStorage.getItem('spotfix_session_id');
if (!nonRequesting && currentActiveTaskId && +currentActiveTaskId !== 0) {
await getTasksAttachmenDoboard(sessionId, params.accountId, params.projectToken, currentActiveTaskId);
await getTasksCommentsDoboard(sessionId, params.accountId, params.projectToken, currentActiveTaskId);
const tasksData = await spotfixIndexedDB.getAll(SPOTFIX_TABLE_TASKS);
if (!tasksData.find((item) => +item.taskId === +currentActiveTaskId)) {
await getTasksDoboard(params.projectToken, sessionId, params.accountId, params.projectId, null, +currentActiveTaskId)
.then(async (ans) => {
if (ans) {
await getTasksAttachmenDoboard(sessionId, params.accountId, params.projectToken, currentActiveTaskId);
await getTasksCommentsDoboard(sessionId, params.accountId, params.projectToken, currentActiveTaskId);
}
tasks = await spotfixIndexedDB.getAll(SPOTFIX_TABLE_TASKS);
});
} else {
await getTasksAttachmenDoboard(sessionId, params.accountId, params.projectToken, currentActiveTaskId);
await getTasksCommentsDoboard(sessionId, params.accountId, params.projectToken, currentActiveTaskId);
}
}
const comments = await spotfixIndexedDB.getAll(SPOTFIX_TABLE_COMMENTS);
const attachments = await spotfixIndexedDB.getAll(SPOTFIX_TABLE_ATTACHMENT);
Expand All @@ -8713,6 +8742,7 @@ async function getTasksFullDetails(params, tasks, currentActiveTaskId, nonReques
return {
comments: comments,
users: users,
task_type: foundTask?.task_type,
attachments: attachments,
taskStatus: foundTask?.taskStatus,
taskName: foundTask?.taskTitle,
Expand Down Expand Up @@ -10365,7 +10395,7 @@ class CleanTalkWidgetDoboard {

this.allTasksData = await getAllTasks(this.params, this.nonRequesting);

const tasks = this.allTasksData;
const tasks = this.allTasksData?.length ? this.allTasksData.filter(item => item.task_type !== 'PRIVATE') : [];
tasksFullDetails = await getTasksFullDetails(this.params, tasks, this.currentActiveTaskId, this.nonRequesting);

let spotsToBeHighlighted = [];
Expand Down Expand Up @@ -10839,14 +10869,16 @@ class CleanTalkWidgetDoboard {
tasksFullDetails = await getTasksFullDetails(this.params, this.allTasksData, this.currentActiveTaskId, this.nonRequesting);
const taskDetails = await getTaskFullDetails(tasksFullDetails, this.currentActiveTaskId, this.nonRequesting);

const taskName = taskDetails.task_type === 'PRIVATE' ? '' : tasksFullDetails.taskName || taskDetails?.issueTitle;

const issueTitleElement = document.querySelector('.doboard_task_widget-issue-title');
if (issueTitleElement) {
issueTitleElement.innerText = ksesFilter(tasksFullDetails.taskName || taskDetails?.issueTitle);
issueTitleElement.innerText = ksesFilter(taskName);
}

templateVariables.issueTitle = tasksFullDetails.taskName || taskDetails?.issueTitle;
templateVariables.issueTitle = taskName;
templateVariables.issueComments = taskDetails?.issueComments;
templateVariables.amountOfComments = `${taskDetails?.issueComments.length || 0} messages`;
templateVariables.amountOfComments = taskDetails.task_type === 'PRIVATE' ? '' : `${taskDetails?.issueComments.length || 0} messages`;

let nodePath = null;
const currentTaskData = this.allTasksData.find((element) => String(element.taskId) === String(taskDetails.taskId));
Expand All @@ -10873,7 +10905,7 @@ class CleanTalkWidgetDoboard {
: taskFormattedPageUrl;
}

if (isPageUrlString || issueLinkElement) {
if (meta && (isPageUrlString || issueLinkElement)) {
if (meta.pageURL && meta.pageURL === window.location.href && meta.nodePath && !spotFixRetrieveNodeFromPath(meta.nodePath)) {
templateVariables.taskFormattedPageUrl = `<span>The link to the content has been lost because the content was changed, deleted, or moved to another URL.</span>`;
} else if ((meta.nodePath || meta.selectedText) && meta?.pageURL) {
Expand Down Expand Up @@ -11011,6 +11043,11 @@ class CleanTalkWidgetDoboard {
} else {
issuesCommentsContainer.innerHTML = ksesFilter('No comments');
}
if(taskDetails.task_type === 'PRIVATE'){
issuesCommentsContainer.innerHTML = `<span style="text-align: center">
This Spot is not available for public viewing. To share it publicly, enable public access in doBoard.com →
Project → Board → Task Settings. Once enabled, the Spot will be accessible to anyone on the Internet.</span>`
}

const mainThis = this;
const fileUploader = this.fileUploader;
Expand Down Expand Up @@ -11075,13 +11112,23 @@ class CleanTalkWidgetDoboard {
const container = document.querySelector('.doboard_task_widget-concrete_issues-container');
if (container) {
setTimeout(() => {
container.scrollTo({ top: container.scrollHeight, behavior: 'smooth' });
container.scrollTo({top: container.scrollHeight, behavior: 'smooth'});
}, 50);
}
}

hideContainersSpinner();
this.fileUploader.init();
if(taskDetails.task_type !== 'PRIVATE') this.fileUploader.init();

if (taskDetails.task_type === 'PRIVATE') {
const openSpotMenuButton = document.getElementById('openSpotMenuButton');
if(openSpotMenuButton) openSpotMenuButton.style.display = 'none';
const messageContainer = document.getElementById('spotfix_widget_task_send_message_container');
if (messageContainer) {
messageContainer.style.pointerEvents = 'none';
messageContainer.style.opacity = '0.6';
}
}

this.concreteIssueCache[currentTaskId] = {
timestamp: Date.now(),
Expand Down Expand Up @@ -12257,6 +12304,7 @@ function getTaskFullDetails(tasksDetails, taskId) {
taskId: taskId,
taskAuthorAvatarImgSrc: avatarSrc,
taskAuthorName: authorName,
task_type: tasksDetails.task_type,
lastMessageText: lastComment ? lastComment.commentBody : 'No messages yet',
issueTitle: comments.length > 0 ? comments[0].issueTitle : 'No Title',
issueComments: comments
Expand Down Expand Up @@ -13740,16 +13788,30 @@ class FileUploader {

async makeScreenshot() {
let blob = null;

let bgColor = window.getComputedStyle(document.body).backgroundColor;
if (bgColor === 'rgba(0, 0, 0, 0)' || bgColor === 'transparent') {
bgColor = '#ffffff';
}

try {
const domtoimageLib = await this.loadDomToImage();
if (!domtoimageLib) throw new Error('domtoimageLib failed to load');

blob = await domtoimageLib.toBlob(document.body, {
bgcolor: bgColor,
width: window.innerWidth,
height: window.innerHeight,
style: {
transform: `translate(${-window.scrollX}px, ${-window.scrollY}px)`,
backgroundColor: bgColor
},
filter: (node) => {
if (node.classList && node.classList.contains('doboard_task_widget')) {
return false;
}
return true;
}
});

if (!blob) throw new Error('dom-to-image-more returned an empty result');
Expand All @@ -13767,10 +13829,22 @@ class FileUploader {
allowTaint: true,
logging: false,
scale: window.devicePixelRatio || 1,
backgroundColor: bgColor,
x: window.scrollX,
y: window.scrollY,
width: window.innerWidth,
height: window.innerHeight,
scrollX: 0,
scrollY: 0,
windowWidth: document.documentElement.offsetWidth,
windowHeight: document.documentElement.offsetHeight,

ignoreElements: (element) => {
if (element.classList && element.classList.contains('doboard_task_widget')) {
return true;
}
return false;
}
});

blob = await new Promise(res => canvas.toBlob(res, 'image/png'));
Expand Down
12 changes: 7 additions & 5 deletions dist/doboard-widget-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/doboard-widget-bundle.min.js.map

Large diffs are not rendered by default.

52 changes: 34 additions & 18 deletions js/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ const spotfixApiCall = async (data, method, accountId = undefined) => {
clearLocalstorageOnLogout();
checkLogInOutButtonsVisible();
}
if (responseBody.data.operation_message === "Access is denied"){
return {operation_message: "Access is denied"}
}
Comment thread
veronika-tseleva-cleantalk marked this conversation as resolved.
Comment on lines +82 to +84
throw new Error(errorMessage);
}

Expand Down Expand Up @@ -237,7 +240,7 @@ const logoutUserDoboard = async (projectToken) => {
}
};

const getTasksDoboard = async (projectToken, sessionId, accountId, projectId, userId) => {
const getTasksDoboard = async (projectToken, sessionId, accountId, projectId, userId, taskId) => {
const data = {
session_id: sessionId,
project_token: projectToken,
Expand All @@ -247,24 +250,37 @@ const getTasksDoboard = async (projectToken, sessionId, accountId, projectId, us
if ( userId ) {
data.user_id = userId;
}
if ( taskId ) {
data.task_id = taskId;
}
const result = await spotfixApiCall(data, 'task_get', accountId);
const tasks = result.tasks.map((task) => ({
taskId: task.task_id,
taskTitle: task.name,
userId: task.user_id,
task_type: task.task_type,
commentsCount: task.comments_count,
taskLastUpdate: task.updated,
taskCreated: task.created,
taskCreatorTaskUser: task.creator_user_id,
taskMeta: task.meta,
taskStatus: task.status,
viewers: task.comments_viewers,
taskToken: task.token
}));
await spotfixIndexedDB.clearPut(SPOTFIX_TABLE_TASKS, tasks);
storageSaveTasksCount(tasks);
return tasks;

if(result.operation_message === 'Access is denied'){
await spotfixIndexedDB.put(SPOTFIX_TABLE_TASKS, {taskId: taskId, task_type: 'PRIVATE', taskMeta:"{}"});
return null;
} else {
const tasks = result.tasks.map((task) => ({
taskId: task.task_id,
taskTitle: task.name,
userId: task.user_id,
task_type: task.task_type,
commentsCount: task.comments_count,
taskLastUpdate: task.updated,
taskCreated: task.created,
taskCreatorTaskUser: task.creator_user_id,
taskMeta: task.meta,
taskStatus: task.status,
viewers: task.comments_viewers,
taskToken: task.token
}));
if(taskId){
await spotfixIndexedDB.put(SPOTFIX_TABLE_TASKS, tasks);
} else {
await spotfixIndexedDB.clearPut(SPOTFIX_TABLE_TASKS, tasks);
}
storageSaveTasksCount(tasks);
return tasks;
Comment on lines +276 to +282
}
};


Expand Down
26 changes: 26 additions & 0 deletions js/src/fileuploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,30 @@ class FileUploader {

async makeScreenshot() {
let blob = null;

let bgColor = window.getComputedStyle(document.body).backgroundColor;
if (bgColor === 'rgba(0, 0, 0, 0)' || bgColor === 'transparent') {
bgColor = '#ffffff';
}

try {
const domtoimageLib = await this.loadDomToImage();
if (!domtoimageLib) throw new Error('domtoimageLib failed to load');

blob = await domtoimageLib.toBlob(document.body, {
bgcolor: bgColor,
width: window.innerWidth,
height: window.innerHeight,
style: {
transform: `translate(${-window.scrollX}px, ${-window.scrollY}px)`,
backgroundColor: bgColor
},
filter: (node) => {
if (node.classList && node.classList.contains('doboard_task_widget')) {
return false;
}
return true;
}
});

if (!blob) throw new Error('dom-to-image-more returned an empty result');
Expand All @@ -437,10 +451,22 @@ class FileUploader {
allowTaint: true,
logging: false,
scale: window.devicePixelRatio || 1,
backgroundColor: bgColor,
x: window.scrollX,
y: window.scrollY,
width: window.innerWidth,
height: window.innerHeight,
scrollX: 0,
scrollY: 0,
windowWidth: document.documentElement.offsetWidth,
windowHeight: document.documentElement.offsetHeight,

ignoreElements: (element) => {
if (element.classList && element.classList.contains('doboard_task_widget')) {
return true;
}
return false;
}
});

blob = await new Promise(res => canvas.toBlob(res, 'image/png'));
Expand Down
Loading