mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
* fix(editor): Create executions page * fix(editor): lint fix * fix(editor): Reuse execution list in both modal and page * fix(editor): fix ts issues * fix(editor): Reorganizing exec list components for easier redesign (everything is in its new place now) * fix(editor): Exec list item restyling * fix(editor): Exec list add back stripes * fix(editor): Exec list formatting dates and times * fix(editor): Exec list revert accidental searc and replace * fix(editor): Exec list translations and execution IDs * fix(editor): Exec list playing with table cell sizing * fix(editor): Exec list playing with table cell sizing * fix(editor): Exec list drop Element UI Table * fix(editor): Exec list adding sticky header and View button on row hover * fix(editor): Exec list open execution in new tab, add ellipsis menu to all rows with Delete action * fix(editor): Global exec list update translations snd fix tabindex * fix(editor): Global exec list redesign selection * fix(editor): Global exec list fix scrolling container * fix(editor): Global exec list fix running status * fix(editor): Global exec list fix waiting status
83 lines
2.2 KiB
TypeScript
83 lines
2.2 KiB
TypeScript
import mixins from 'vue-typed-mixins';
|
|
import dateformat from 'dateformat';
|
|
|
|
import { VIEWS } from '@/constants';
|
|
import { showMessage } from '@/mixins/showMessage';
|
|
|
|
export const genericHelpers = mixins(showMessage).extend({
|
|
data() {
|
|
return {
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
loadingService: null as any | null,
|
|
};
|
|
},
|
|
computed: {
|
|
isReadOnly(): boolean {
|
|
return ![VIEWS.WORKFLOW, VIEWS.NEW_WORKFLOW, VIEWS.LOG_STREAMING_SETTINGS].includes(
|
|
this.$route.name as VIEWS,
|
|
);
|
|
},
|
|
},
|
|
methods: {
|
|
displayTimer(msPassed: number, showMs = false): string {
|
|
if (msPassed < 60000) {
|
|
if (!showMs) {
|
|
return `${Math.floor(msPassed / 1000)}${this.$locale.baseText(
|
|
'genericHelpers.secShort',
|
|
)}`;
|
|
}
|
|
|
|
return `${msPassed / 1000}${this.$locale.baseText('genericHelpers.secShort')}`;
|
|
}
|
|
|
|
const secondsPassed = Math.floor(msPassed / 1000);
|
|
const minutesPassed = Math.floor(secondsPassed / 60);
|
|
const secondsLeft = (secondsPassed - minutesPassed * 60).toString().padStart(2, '0');
|
|
|
|
return `${minutesPassed}:${secondsLeft}${this.$locale.baseText('genericHelpers.minShort')}`;
|
|
},
|
|
convertToDisplayDate(epochTime: number): { date: string; time: string } {
|
|
const formattedDate = dateformat(epochTime, 'd mmm, yyyy#HH:MM:ss');
|
|
const [date, time] = formattedDate.split('#');
|
|
return { date, time };
|
|
},
|
|
editAllowedCheck(): boolean {
|
|
if (this.isReadOnly) {
|
|
this.$showMessage({
|
|
// title: 'Workflow can not be changed!',
|
|
title: this.$locale.baseText('genericHelpers.showMessage.title'),
|
|
message: this.$locale.baseText('genericHelpers.showMessage.message'),
|
|
type: 'info',
|
|
duration: 0,
|
|
});
|
|
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
|
|
startLoading(text?: string) {
|
|
if (this.loadingService !== null) {
|
|
return;
|
|
}
|
|
|
|
// @ts-ignore
|
|
this.loadingService = this.$loading({
|
|
lock: true,
|
|
text: text || this.$locale.baseText('genericHelpers.loading'),
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(255, 255, 255, 0.8)',
|
|
});
|
|
},
|
|
setLoadingText(text: string) {
|
|
this.loadingService.text = text;
|
|
},
|
|
stopLoading() {
|
|
if (this.loadingService !== null) {
|
|
this.loadingService.close();
|
|
this.loadingService = null;
|
|
}
|
|
},
|
|
},
|
|
});
|