mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-11 02:33:51 +00:00
composition: some more components
This commit is contained in:
parent
b272c73e89
commit
fe3075e6d3
|
@ -99,29 +99,25 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue, Prop } from 'vue-property-decorator';
|
|
||||||
import { formatPercent, formatPriceCurrency, formatPrice, timestampms } from '@/shared/formatters';
|
import { formatPercent, formatPriceCurrency, formatPrice, timestampms } from '@/shared/formatters';
|
||||||
import ValuePair from '@/components/general/ValuePair.vue';
|
import ValuePair from '@/components/general/ValuePair.vue';
|
||||||
import TradeProfit from '@/components/ftbot/TradeProfit.vue';
|
import TradeProfit from '@/components/ftbot/TradeProfit.vue';
|
||||||
import DateTimeTZ from '@/components/general/DateTimeTZ.vue';
|
import DateTimeTZ from '@/components/general/DateTimeTZ.vue';
|
||||||
import { Trade } from '@/types';
|
import { Trade } from '@/types';
|
||||||
|
|
||||||
@Component({
|
import { defineComponent } from '@vue/composition-api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'TradeDetail',
|
||||||
components: { ValuePair, TradeProfit, DateTimeTZ },
|
components: { ValuePair, TradeProfit, DateTimeTZ },
|
||||||
})
|
props: {
|
||||||
export default class TradeDetail extends Vue {
|
trade: { required: true, type: Object as () => Trade },
|
||||||
@Prop({ type: Object, required: true }) trade!: Trade;
|
stakeCurrency: { required: true, type: String },
|
||||||
|
},
|
||||||
@Prop({ type: String, required: true }) stakeCurrency!: string;
|
setup() {
|
||||||
|
return { timestampms, formatPercent, formatPrice, formatPriceCurrency };
|
||||||
timestampms = timestampms;
|
},
|
||||||
|
});
|
||||||
formatPercent = formatPercent;
|
|
||||||
|
|
||||||
formatPrice = formatPrice;
|
|
||||||
|
|
||||||
formatPriceCurrency = formatPriceCurrency;
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.detail-header {
|
.detail-header {
|
||||||
|
|
|
@ -4,38 +4,39 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { timestampms, timestampmsWithTimezone, timestampToDateString } from '@/shared/formatters';
|
import { timestampms, timestampmsWithTimezone, timestampToDateString } from '@/shared/formatters';
|
||||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
|
||||||
|
|
||||||
@Component({})
|
import { defineComponent, computed } from '@vue/composition-api';
|
||||||
export default class DateTimeTZ extends Vue {
|
|
||||||
@Prop({ required: true, type: Number }) date!: number;
|
|
||||||
|
|
||||||
@Prop({ required: false, type: Boolean, default: false }) showTimezone!: boolean;
|
export default defineComponent({
|
||||||
|
name: 'DateTimeTZ',
|
||||||
|
props: {
|
||||||
|
date: { required: true, type: Number },
|
||||||
|
showTimezone: { required: false, type: Boolean, default: false },
|
||||||
|
dateOnly: { required: false, type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const formattedDate = computed((): string => {
|
||||||
|
if (props.dateOnly) {
|
||||||
|
return timestampToDateString(props.date);
|
||||||
|
}
|
||||||
|
if (props.showTimezone) {
|
||||||
|
return timestampmsWithTimezone(props.date);
|
||||||
|
}
|
||||||
|
return timestampms(props.date);
|
||||||
|
});
|
||||||
|
|
||||||
@Prop({ required: false, type: Boolean, default: false }) dateOnly!: boolean;
|
const timezoneTooltip = computed((): string => {
|
||||||
|
const time1 = timestampmsWithTimezone(props.date);
|
||||||
|
const timeUTC = timestampmsWithTimezone(props.date, 'UTC');
|
||||||
|
if (time1 === timeUTC) {
|
||||||
|
return timeUTC;
|
||||||
|
}
|
||||||
|
|
||||||
timestampms = timestampms;
|
return `${time1}\n${timeUTC}`;
|
||||||
|
});
|
||||||
get formattedDate(): string {
|
return { formattedDate, timezoneTooltip };
|
||||||
if (this.dateOnly) {
|
},
|
||||||
return timestampToDateString(this.date);
|
});
|
||||||
}
|
|
||||||
if (this.showTimezone) {
|
|
||||||
return timestampmsWithTimezone(this.date);
|
|
||||||
}
|
|
||||||
return timestampms(this.date);
|
|
||||||
}
|
|
||||||
|
|
||||||
get timezoneTooltip(): string {
|
|
||||||
const time1 = timestampmsWithTimezone(this.date);
|
|
||||||
const timeUTC = timestampmsWithTimezone(this.date, 'UTC');
|
|
||||||
if (time1 === timeUTC) {
|
|
||||||
return timeUTC;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${time1}\n${timeUTC}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|
|
@ -20,41 +20,38 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { formatPercent, formatPrice, timestampms } from '@/shared/formatters';
|
import { formatPercent, formatPrice } from '@/shared/formatters';
|
||||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
|
||||||
|
|
||||||
import ProfitSymbol from '@/components/general/ProfitSymbol.vue';
|
import ProfitSymbol from '@/components/general/ProfitSymbol.vue';
|
||||||
|
|
||||||
@Component({ components: { ProfitSymbol } })
|
import { defineComponent, computed } from '@vue/composition-api';
|
||||||
export default class ProfitPill extends Vue {
|
|
||||||
@Prop({ required: false, default: undefined, type: Number }) profitRatio?: number;
|
|
||||||
|
|
||||||
@Prop({ required: false, default: undefined, type: Number }) profitAbs?: number;
|
export default defineComponent({
|
||||||
|
name: 'ProfitPill',
|
||||||
|
components: { ProfitSymbol },
|
||||||
|
props: {
|
||||||
|
profitRatio: { required: false, default: undefined, type: Number },
|
||||||
|
profitAbs: { required: false, default: undefined, type: Number },
|
||||||
|
stakeCurrency: { required: true, type: String },
|
||||||
|
profitDesc: { required: false, default: '', type: String },
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const isProfitable = computed(() => {
|
||||||
|
return (
|
||||||
|
(props.profitRatio !== undefined && props.profitRatio > 0) ||
|
||||||
|
(props.profitRatio === undefined && props.profitAbs !== undefined && props.profitAbs > 0)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
@Prop({ required: true, type: String }) stakeCurrency!: string;
|
const profitString = computed((): string => {
|
||||||
|
if (props.profitRatio !== undefined && props.profitAbs !== undefined) {
|
||||||
@Prop({ required: false, default: '', type: String }) profitDesc!: string;
|
return `(${formatPrice(props.profitAbs, 3)})`;
|
||||||
|
}
|
||||||
formatPercent = formatPercent;
|
return '';
|
||||||
|
});
|
||||||
timestampms = timestampms;
|
return { profitString, isProfitable, formatPercent };
|
||||||
|
},
|
||||||
formatPrice = formatPrice;
|
});
|
||||||
|
|
||||||
get isProfitable() {
|
|
||||||
return (
|
|
||||||
(this.profitRatio !== undefined && this.profitRatio > 0) ||
|
|
||||||
(this.profitRatio === undefined && this.profitAbs !== undefined && this.profitAbs > 0)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
get profitString(): string {
|
|
||||||
if (this.profitRatio !== undefined && this.profitAbs !== undefined) {
|
|
||||||
return `(${formatPrice(this.profitAbs, 3)})`;
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user