⚡ Fix issues with Dynamic title
This commit is contained in:
@@ -10,14 +10,14 @@ import {
|
||||
|
||||
import { nodeHelpers } from '@/components/mixins/nodeHelpers';
|
||||
import { showMessage } from '@/components/mixins/showMessage';
|
||||
import { titleChange } from '@/components/mixins/titleChange';
|
||||
|
||||
import mixins from 'vue-typed-mixins';
|
||||
import titleChange from './titleChange';
|
||||
|
||||
export const pushConnection = mixins(
|
||||
nodeHelpers,
|
||||
showMessage,
|
||||
titleChange
|
||||
titleChange,
|
||||
)
|
||||
.extend({
|
||||
data () {
|
||||
@@ -149,7 +149,6 @@ export const pushConnection = mixins(
|
||||
*/
|
||||
pushMessageReceived (event: Event, isRetry?: boolean): boolean {
|
||||
const retryAttempts = 5;
|
||||
const workflow = this.getWorkflow();
|
||||
let receivedData: IPushData;
|
||||
try {
|
||||
// @ts-ignore
|
||||
@@ -203,13 +202,19 @@ export const pushConnection = mixins(
|
||||
|
||||
const runDataExecuted = pushData.data;
|
||||
|
||||
console.log('..pushData..');
|
||||
console.log(pushData);
|
||||
|
||||
|
||||
// @ts-ignore
|
||||
const workflow = this.getWorkflow();
|
||||
if (runDataExecuted.finished !== true) {
|
||||
// There was a problem with executing the workflow
|
||||
let errorMessage = 'There was a problem executing the workflow!';
|
||||
if (runDataExecuted.data.resultData.error && runDataExecuted.data.resultData.error.message) {
|
||||
errorMessage = `There was a problem executing the workflow:<br /><strong>"${runDataExecuted.data.resultData.error.message}"</strong>`;
|
||||
}
|
||||
titleChange.set(workflow.name, 'ERROR');
|
||||
this.$titleSet(workflow.name, 'ERROR');
|
||||
this.$showMessage({
|
||||
title: 'Problem executing workflow',
|
||||
message: errorMessage,
|
||||
@@ -217,7 +222,7 @@ export const pushConnection = mixins(
|
||||
});
|
||||
} else {
|
||||
// Workflow did execute without a problem
|
||||
titleChange.set(workflow.name, 'IDLE');
|
||||
this.$titleSet(workflow.name, 'IDLE');
|
||||
this.$showMessage({
|
||||
title: 'Workflow got executed',
|
||||
message: 'Workflow did get executed successfully!',
|
||||
|
||||
@@ -1,25 +1,31 @@
|
||||
type Status = 'EXECUTING' | 'IDLE' | 'ERROR';
|
||||
import Vue from 'vue';
|
||||
|
||||
export default {
|
||||
/**
|
||||
* Change title of n8n tab
|
||||
* @param workflow Name of workflow
|
||||
* @param status Status of workflow
|
||||
*/
|
||||
set (workflow : string, status : Status) {
|
||||
if (status === 'EXECUTING') {
|
||||
window.document.title = `n8n - 🔄 ${workflow}}`;
|
||||
}
|
||||
else if (status === 'IDLE') {
|
||||
window.document.title = `n8n - ▶️ ${workflow}`;
|
||||
}
|
||||
else {
|
||||
window.document.title = `n8n - ⚠️ ${workflow}`;
|
||||
}
|
||||
|
||||
},
|
||||
import {
|
||||
WorkflowTitleStatus,
|
||||
} from '../../Interface';
|
||||
|
||||
reset () {
|
||||
document.title = `n8n - Workflow Automation`;
|
||||
}
|
||||
};
|
||||
export const titleChange = Vue.extend({
|
||||
methods: {
|
||||
/**
|
||||
* Change title of n8n tab
|
||||
*
|
||||
* @param {string} workflow Name of workflow
|
||||
* @param {WorkflowTitleStatus} status Status of workflow
|
||||
*/
|
||||
$titleSet(workflow: string, status: WorkflowTitleStatus) {
|
||||
let icon = '⚠️';
|
||||
if (status === 'EXECUTING') {
|
||||
icon = '🔄';
|
||||
} else if (status === 'IDLE') {
|
||||
icon = '▶️';
|
||||
}
|
||||
|
||||
window.document.title = `n8n - ${icon} ${workflow}`;
|
||||
},
|
||||
|
||||
$titleReset() {
|
||||
document.title = `n8n - Workflow Automation`;
|
||||
},
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
@@ -14,13 +14,12 @@ import { restApi } from '@/components/mixins/restApi';
|
||||
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
||||
|
||||
import mixins from 'vue-typed-mixins';
|
||||
import titleChange from './titleChange';
|
||||
import { title } from 'process';
|
||||
import { titleChange } from './titleChange';
|
||||
|
||||
export const workflowRun = mixins(
|
||||
restApi,
|
||||
workflowHelpers,
|
||||
titleChange
|
||||
titleChange,
|
||||
).extend({
|
||||
methods: {
|
||||
// Starts to executes a workflow on server.
|
||||
@@ -59,8 +58,8 @@ export const workflowRun = mixins(
|
||||
}
|
||||
|
||||
const workflow = this.getWorkflow();
|
||||
titleChange.set(workflow.name, 'EXECUTING');
|
||||
|
||||
this.$titleSet(workflow.name as string, 'EXECUTING');
|
||||
|
||||
try {
|
||||
// Check first if the workflow has any issues before execute it
|
||||
const issuesExist = this.$store.getters.nodesIssuesExist;
|
||||
@@ -83,7 +82,7 @@ export const workflowRun = mixins(
|
||||
type: 'error',
|
||||
duration: 0,
|
||||
});
|
||||
titleChange.set(workflow.name, 'ERROR');
|
||||
this.$titleSet(workflow.name as string, 'ERROR');
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -170,10 +169,10 @@ export const workflowRun = mixins(
|
||||
},
|
||||
};
|
||||
this.$store.commit('setWorkflowExecutionData', executionData);
|
||||
|
||||
|
||||
return await this.runWorkflowApi(startRunData);
|
||||
} catch (error) {
|
||||
titleChange.set(workflow.name, 'ERROR');
|
||||
this.$titleSet(workflow.name as string, 'ERROR');
|
||||
this.$showError(error, 'Problem running workflow', 'There was a problem running the workflow:');
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user