mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
⚡ Fix issues with Dynamic title
This commit is contained in:
parent
44f7b7a9c2
commit
b78145f2ec
|
@ -417,3 +417,5 @@ export interface ITimeoutHMS {
|
||||||
minutes: number;
|
minutes: number;
|
||||||
seconds: number;
|
seconds: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type WorkflowTitleStatus = 'EXECUTING' | 'IDLE' | 'ERROR';
|
||||||
|
|
|
@ -84,20 +84,20 @@ import { genericHelpers } from '@/components/mixins/genericHelpers';
|
||||||
import { pushConnection } from '@/components/mixins/pushConnection';
|
import { pushConnection } from '@/components/mixins/pushConnection';
|
||||||
import { restApi } from '@/components/mixins/restApi';
|
import { restApi } from '@/components/mixins/restApi';
|
||||||
import { showMessage } from '@/components/mixins/showMessage';
|
import { showMessage } from '@/components/mixins/showMessage';
|
||||||
|
import { titleChange } from '@/components/mixins/titleChange';
|
||||||
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
||||||
|
|
||||||
import { saveAs } from 'file-saver';
|
import { saveAs } from 'file-saver';
|
||||||
|
|
||||||
import mixins from 'vue-typed-mixins';
|
import mixins from 'vue-typed-mixins';
|
||||||
import titleChange from './mixins/titleChange';
|
|
||||||
|
|
||||||
export default mixins(
|
export default mixins(
|
||||||
genericHelpers,
|
genericHelpers,
|
||||||
pushConnection,
|
pushConnection,
|
||||||
restApi,
|
restApi,
|
||||||
showMessage,
|
showMessage,
|
||||||
|
titleChange,
|
||||||
workflowHelpers,
|
workflowHelpers,
|
||||||
titleChange
|
|
||||||
)
|
)
|
||||||
.extend({
|
.extend({
|
||||||
name: 'MainHeader',
|
name: 'MainHeader',
|
||||||
|
@ -157,7 +157,7 @@ export default mixins(
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async openWorkflow (workflowId: string) {
|
async openWorkflow (workflowId: string) {
|
||||||
titleChange.set(workflowId, 'IDLE');
|
this.$titleSet(this.workflowName, 'IDLE');
|
||||||
// Change to other workflow
|
// Change to other workflow
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: 'NodeViewExisting',
|
name: 'NodeViewExisting',
|
||||||
|
|
|
@ -179,6 +179,7 @@ import WorkflowSettings from '@/components/WorkflowSettings.vue';
|
||||||
import { genericHelpers } from '@/components/mixins/genericHelpers';
|
import { genericHelpers } from '@/components/mixins/genericHelpers';
|
||||||
import { restApi } from '@/components/mixins/restApi';
|
import { restApi } from '@/components/mixins/restApi';
|
||||||
import { showMessage } from '@/components/mixins/showMessage';
|
import { showMessage } from '@/components/mixins/showMessage';
|
||||||
|
import { titleChange } from '@/components/mixins/titleChange';
|
||||||
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
||||||
import { workflowSave } from '@/components/mixins/workflowSave';
|
import { workflowSave } from '@/components/mixins/workflowSave';
|
||||||
import { workflowRun } from '@/components/mixins/workflowRun';
|
import { workflowRun } from '@/components/mixins/workflowRun';
|
||||||
|
@ -186,16 +187,15 @@ import { workflowRun } from '@/components/mixins/workflowRun';
|
||||||
import { saveAs } from 'file-saver';
|
import { saveAs } from 'file-saver';
|
||||||
|
|
||||||
import mixins from 'vue-typed-mixins';
|
import mixins from 'vue-typed-mixins';
|
||||||
import titleChange from './mixins/titleChange';
|
|
||||||
|
|
||||||
export default mixins(
|
export default mixins(
|
||||||
genericHelpers,
|
genericHelpers,
|
||||||
restApi,
|
restApi,
|
||||||
showMessage,
|
showMessage,
|
||||||
|
titleChange,
|
||||||
workflowHelpers,
|
workflowHelpers,
|
||||||
workflowRun,
|
workflowRun,
|
||||||
workflowSave,
|
workflowSave,
|
||||||
titleChange
|
|
||||||
)
|
)
|
||||||
.extend({
|
.extend({
|
||||||
name: 'MainHeader',
|
name: 'MainHeader',
|
||||||
|
@ -420,7 +420,7 @@ export default mixins(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Reset tab title since workflow is deleted.
|
// Reset tab title since workflow is deleted.
|
||||||
titleChange.reset();
|
this.$titleReset();
|
||||||
this.$showMessage({
|
this.$showMessage({
|
||||||
title: 'Workflow got deleted',
|
title: 'Workflow got deleted',
|
||||||
message: `The workflow "${this.workflowName}" got deleted!`,
|
message: `The workflow "${this.workflowName}" got deleted!`,
|
||||||
|
|
|
@ -34,16 +34,16 @@ import WorkflowActivator from '@/components/WorkflowActivator.vue';
|
||||||
import { restApi } from '@/components/mixins/restApi';
|
import { restApi } from '@/components/mixins/restApi';
|
||||||
import { genericHelpers } from '@/components/mixins/genericHelpers';
|
import { genericHelpers } from '@/components/mixins/genericHelpers';
|
||||||
import { showMessage } from '@/components/mixins/showMessage';
|
import { showMessage } from '@/components/mixins/showMessage';
|
||||||
|
import { titleChange } from '@/components/mixins/titleChange';
|
||||||
import { IWorkflowShortResponse } from '@/Interface';
|
import { IWorkflowShortResponse } from '@/Interface';
|
||||||
|
|
||||||
import mixins from 'vue-typed-mixins';
|
import mixins from 'vue-typed-mixins';
|
||||||
import titleChange from './mixins/titleChange';
|
|
||||||
|
|
||||||
export default mixins(
|
export default mixins(
|
||||||
genericHelpers,
|
genericHelpers,
|
||||||
restApi,
|
restApi,
|
||||||
showMessage,
|
showMessage,
|
||||||
titleChange
|
titleChange,
|
||||||
).extend({
|
).extend({
|
||||||
name: 'WorkflowOpen',
|
name: 'WorkflowOpen',
|
||||||
props: [
|
props: [
|
||||||
|
@ -91,7 +91,7 @@ export default mixins(
|
||||||
},
|
},
|
||||||
openWorkflow (data: IWorkflowShortResponse, column: any) { // tslint:disable-line:no-any
|
openWorkflow (data: IWorkflowShortResponse, column: any) { // tslint:disable-line:no-any
|
||||||
if (column.label !== 'Active') {
|
if (column.label !== 'Active') {
|
||||||
titleChange.set(data.name, 'IDLE');
|
this.$titleSet(data.name, 'IDLE');
|
||||||
this.$emit('openWorkflow', data.id);
|
this.$emit('openWorkflow', data.id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,14 +10,14 @@ import {
|
||||||
|
|
||||||
import { nodeHelpers } from '@/components/mixins/nodeHelpers';
|
import { nodeHelpers } from '@/components/mixins/nodeHelpers';
|
||||||
import { showMessage } from '@/components/mixins/showMessage';
|
import { showMessage } from '@/components/mixins/showMessage';
|
||||||
|
import { titleChange } from '@/components/mixins/titleChange';
|
||||||
|
|
||||||
import mixins from 'vue-typed-mixins';
|
import mixins from 'vue-typed-mixins';
|
||||||
import titleChange from './titleChange';
|
|
||||||
|
|
||||||
export const pushConnection = mixins(
|
export const pushConnection = mixins(
|
||||||
nodeHelpers,
|
nodeHelpers,
|
||||||
showMessage,
|
showMessage,
|
||||||
titleChange
|
titleChange,
|
||||||
)
|
)
|
||||||
.extend({
|
.extend({
|
||||||
data () {
|
data () {
|
||||||
|
@ -149,7 +149,6 @@ export const pushConnection = mixins(
|
||||||
*/
|
*/
|
||||||
pushMessageReceived (event: Event, isRetry?: boolean): boolean {
|
pushMessageReceived (event: Event, isRetry?: boolean): boolean {
|
||||||
const retryAttempts = 5;
|
const retryAttempts = 5;
|
||||||
const workflow = this.getWorkflow();
|
|
||||||
let receivedData: IPushData;
|
let receivedData: IPushData;
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -203,13 +202,19 @@ export const pushConnection = mixins(
|
||||||
|
|
||||||
const runDataExecuted = pushData.data;
|
const runDataExecuted = pushData.data;
|
||||||
|
|
||||||
|
console.log('..pushData..');
|
||||||
|
console.log(pushData);
|
||||||
|
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
const workflow = this.getWorkflow();
|
||||||
if (runDataExecuted.finished !== true) {
|
if (runDataExecuted.finished !== true) {
|
||||||
// There was a problem with executing the workflow
|
// There was a problem with executing the workflow
|
||||||
let errorMessage = 'There was a problem executing the workflow!';
|
let errorMessage = 'There was a problem executing the workflow!';
|
||||||
if (runDataExecuted.data.resultData.error && runDataExecuted.data.resultData.error.message) {
|
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>`;
|
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({
|
this.$showMessage({
|
||||||
title: 'Problem executing workflow',
|
title: 'Problem executing workflow',
|
||||||
message: errorMessage,
|
message: errorMessage,
|
||||||
|
@ -217,7 +222,7 @@ export const pushConnection = mixins(
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Workflow did execute without a problem
|
// Workflow did execute without a problem
|
||||||
titleChange.set(workflow.name, 'IDLE');
|
this.$titleSet(workflow.name, 'IDLE');
|
||||||
this.$showMessage({
|
this.$showMessage({
|
||||||
title: 'Workflow got executed',
|
title: 'Workflow got executed',
|
||||||
message: 'Workflow did get executed successfully!',
|
message: 'Workflow did get executed successfully!',
|
||||||
|
|
|
@ -1,25 +1,31 @@
|
||||||
type Status = 'EXECUTING' | 'IDLE' | 'ERROR';
|
import Vue from 'vue';
|
||||||
|
|
||||||
export default {
|
import {
|
||||||
/**
|
WorkflowTitleStatus,
|
||||||
* Change title of n8n tab
|
} from '../../Interface';
|
||||||
* @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}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
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 = '▶️';
|
||||||
|
}
|
||||||
|
|
||||||
reset () {
|
window.document.title = `n8n - ${icon} ${workflow}`;
|
||||||
document.title = `n8n - Workflow Automation`;
|
},
|
||||||
}
|
|
||||||
};
|
$titleReset() {
|
||||||
|
document.title = `n8n - Workflow Automation`;
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
|
@ -14,13 +14,12 @@ import { restApi } from '@/components/mixins/restApi';
|
||||||
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
||||||
|
|
||||||
import mixins from 'vue-typed-mixins';
|
import mixins from 'vue-typed-mixins';
|
||||||
import titleChange from './titleChange';
|
import { titleChange } from './titleChange';
|
||||||
import { title } from 'process';
|
|
||||||
|
|
||||||
export const workflowRun = mixins(
|
export const workflowRun = mixins(
|
||||||
restApi,
|
restApi,
|
||||||
workflowHelpers,
|
workflowHelpers,
|
||||||
titleChange
|
titleChange,
|
||||||
).extend({
|
).extend({
|
||||||
methods: {
|
methods: {
|
||||||
// Starts to executes a workflow on server.
|
// Starts to executes a workflow on server.
|
||||||
|
@ -59,7 +58,7 @@ export const workflowRun = mixins(
|
||||||
}
|
}
|
||||||
|
|
||||||
const workflow = this.getWorkflow();
|
const workflow = this.getWorkflow();
|
||||||
titleChange.set(workflow.name, 'EXECUTING');
|
this.$titleSet(workflow.name as string, 'EXECUTING');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check first if the workflow has any issues before execute it
|
// Check first if the workflow has any issues before execute it
|
||||||
|
@ -83,7 +82,7 @@ export const workflowRun = mixins(
|
||||||
type: 'error',
|
type: 'error',
|
||||||
duration: 0,
|
duration: 0,
|
||||||
});
|
});
|
||||||
titleChange.set(workflow.name, 'ERROR');
|
this.$titleSet(workflow.name as string, 'ERROR');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +172,7 @@ export const workflowRun = mixins(
|
||||||
|
|
||||||
return await this.runWorkflowApi(startRunData);
|
return await this.runWorkflowApi(startRunData);
|
||||||
} catch (error) {
|
} 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:');
|
this.$showError(error, 'Problem running workflow', 'There was a problem running the workflow:');
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,6 @@ import './n8n-theme.scss';
|
||||||
import App from '@/App.vue';
|
import App from '@/App.vue';
|
||||||
import router from './router';
|
import router from './router';
|
||||||
|
|
||||||
import titleChange from './components/mixins/titleChange';
|
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core';
|
import { library } from '@fortawesome/fontawesome-svg-core';
|
||||||
import {
|
import {
|
||||||
faAngleDoubleLeft,
|
faAngleDoubleLeft,
|
||||||
|
@ -94,7 +92,6 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||||
|
|
||||||
import { store } from './store';
|
import { store } from './store';
|
||||||
Vue.use(ElementUI, { locale });
|
Vue.use(ElementUI, { locale });
|
||||||
Vue.mixin(titleChange);
|
|
||||||
|
|
||||||
library.add(faAngleDoubleLeft);
|
library.add(faAngleDoubleLeft);
|
||||||
library.add(faAngleDown);
|
library.add(faAngleDown);
|
||||||
|
|
|
@ -115,6 +115,8 @@ import { mouseSelect } from '@/components/mixins/mouseSelect';
|
||||||
import { moveNodeWorkflow } from '@/components/mixins/moveNodeWorkflow';
|
import { moveNodeWorkflow } from '@/components/mixins/moveNodeWorkflow';
|
||||||
import { restApi } from '@/components/mixins/restApi';
|
import { restApi } from '@/components/mixins/restApi';
|
||||||
import { showMessage } from '@/components/mixins/showMessage';
|
import { showMessage } from '@/components/mixins/showMessage';
|
||||||
|
import { titleChange } from '@/components/mixins/titleChange';
|
||||||
|
|
||||||
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
||||||
import { workflowRun } from '@/components/mixins/workflowRun';
|
import { workflowRun } from '@/components/mixins/workflowRun';
|
||||||
|
|
||||||
|
@ -157,7 +159,6 @@ import {
|
||||||
IWorkflowDataUpdate,
|
IWorkflowDataUpdate,
|
||||||
XYPositon,
|
XYPositon,
|
||||||
} from '../Interface';
|
} from '../Interface';
|
||||||
import titleChange from '../components/mixins/titleChange';
|
|
||||||
|
|
||||||
export default mixins(
|
export default mixins(
|
||||||
copyPaste,
|
copyPaste,
|
||||||
|
@ -166,9 +167,9 @@ export default mixins(
|
||||||
moveNodeWorkflow,
|
moveNodeWorkflow,
|
||||||
restApi,
|
restApi,
|
||||||
showMessage,
|
showMessage,
|
||||||
|
titleChange,
|
||||||
workflowHelpers,
|
workflowHelpers,
|
||||||
workflowRun,
|
workflowRun,
|
||||||
titleChange
|
|
||||||
)
|
)
|
||||||
.extend({
|
.extend({
|
||||||
name: 'NodeView',
|
name: 'NodeView',
|
||||||
|
@ -1326,8 +1327,8 @@ export default mixins(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (workflowId !== null) {
|
if (workflowId !== null) {
|
||||||
let workflow = await this.restApi().getWorkflow(workflowId);
|
const workflow = await this.restApi().getWorkflow(workflowId);
|
||||||
titleChange.set(workflow.name, 'IDLE');
|
this.$titleSet(workflow.name, 'IDLE');
|
||||||
// Open existing workflow
|
// Open existing workflow
|
||||||
await this.openWorkflow(workflowId);
|
await this.openWorkflow(workflowId);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue