mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
* refactor(editor): move $getExecutionError from showMessages mixin to pushConnection (it is used there only) * refactor(editor): resolve showMessage mixin methods * fix(editor): use composable instead of mixin * fix(editor): resolve conflicts * fix(editor): replace clearAllStickyNotifications * fix(editor): replace confirmMessage * fix(editor): replace confirmMessage * fix(editor): replace confirmMessage * fix(editor): remove last confirmMessage usage * fix(editor): remove $prompt usage * fix(editor): remove $show methods * fix(editor): lint fix * fix(editor): lint fix * fix(editor): fixes after review
91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
import { defineComponent } from 'vue';
|
|
import dateformat from 'dateformat';
|
|
|
|
import { VIEWS } from '@/constants';
|
|
import { useToast } from '@/composables';
|
|
|
|
export const genericHelpers = defineComponent({
|
|
setup() {
|
|
return {
|
|
...useToast(),
|
|
};
|
|
},
|
|
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(fullDate: Date | string | number): { date: string; time: string } {
|
|
const mask = `d mmm${
|
|
new Date(fullDate).getFullYear() === new Date().getFullYear() ? '' : ', yyyy'
|
|
}#HH:MM:ss`;
|
|
const formattedDate = dateformat(fullDate, mask);
|
|
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;
|
|
}
|
|
},
|
|
},
|
|
});
|