lollms-webui/web/src/components/ModelEntry.vue

84 lines
2.2 KiB
Vue
Raw Normal View History

2023-05-10 23:33:08 +02:00
<template>
2023-05-11 21:36:52 +02:00
<div class="flex items-center p-4 hover:bg-primary-light rounded-lg mb-2 shadow-lg">
2023-05-11 15:09:35 +02:00
<div class="flex-shrink-0">
<i :class="`fas ${icon} text-xl`"></i>
2023-05-10 23:33:08 +02:00
</div>
2023-05-11 15:09:35 +02:00
<div class="flex-1">
<h3 class="font-bold text-lg">
<input
type="radio"
:checked="selected"
2023-05-11 15:15:09 +02:00
:disabled="!isInstalled"
2023-05-11 15:09:35 +02:00
@change="handleSelection"
/>
{{ title }}
</h3>
<p class="opacity-80">{{ description }}</p>
</div>
<div class="flex-shrink-0">
<button
class="px-4 py-2 rounded-md text-white font-bold transition-colors duration-300"
:class="[isInstalled ? 'bg-red-500 hover:bg-red-600' : 'bg-green-500 hover:bg-green-600']"
2023-05-11 21:36:52 +02:00
:disabled="installing || uninstalling"
2023-05-11 15:09:35 +02:00
@click="toggleInstall"
>
2023-05-11 21:36:52 +02:00
<template v-if="installing">
<div class="flex items-center space-x-2">
<div class="h-2 w-20 bg-gray-300 rounded"></div>
<span>Installing...</span>
</div>
</template>
<template v-else-if="uninstalling">
<div class="flex items-center space-x-2">
<div class="h-2 w-20 bg-gray-300 rounded"></div>
<span>Uninstalling...</span>
</div>
</template>
<template v-else>
{{ isInstalled ? 'Uninstall' : 'Install' }}
</template>
2023-05-11 15:09:35 +02:00
</button>
</div>
</div>
</template>
<script>
2023-05-11 21:36:52 +02:00
import { socket, state } from '@/services/websocket.js'
2023-05-11 15:09:35 +02:00
export default {
props: {
title: String,
icon: String,
path: String,
description: String,
isInstalled: Boolean,
2023-05-11 21:36:52 +02:00
onInstall: Function,
onUninstall: Function,
selected: Boolean
},
data() {
return {
installing: false,
uninstalling: false
};
2023-05-11 15:09:35 +02:00
},
methods: {
toggleInstall() {
2023-05-11 21:36:52 +02:00
if (this.isInstalled) {
this.uninstalling = true;
// Simulate uninstallation delay (replace this with your WebSocket logic)
this.onUninstall(this);
} else {
this.installing = true;
this.onInstall(this);
}
2023-05-10 23:33:08 +02:00
},
2023-05-11 15:09:35 +02:00
handleSelection() {
2023-05-11 21:36:52 +02:00
if (this.isInstalled && !this.selected) {
2023-05-11 15:09:35 +02:00
this.$emit('update:selected', true);
}
}
}
};
</script>