mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-04-18 07:50:05 +00:00
upgraded
This commit is contained in:
parent
93c73bb3c2
commit
5796255f06
@ -363,7 +363,7 @@ async def open_code_in_vs_code(vs_code_data: VSCodeData):
|
||||
f.write(code)
|
||||
|
||||
# Use subprocess.Popen to safely open the file
|
||||
subprocess.Popen(["code", str(tmp_file)], shell=True)
|
||||
os.system(f'code -n "{tmp_file}"')
|
||||
|
||||
return {"status": True, "execution_time": 0}
|
||||
except Exception as ex:
|
||||
|
@ -1,4 +1,5 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
from fastapi.responses import FileResponse
|
||||
from lollms_webui import LOLLMSWebUI
|
||||
from pydantic import BaseModel
|
||||
@ -8,7 +9,7 @@ import uuid
|
||||
import os
|
||||
import requests
|
||||
import yaml
|
||||
from lollms.security import check_access
|
||||
from lollms.security import check_access, sanitize_path
|
||||
import os
|
||||
import subprocess
|
||||
import yaml
|
||||
@ -71,6 +72,27 @@ async def list_apps():
|
||||
|
||||
return apps
|
||||
|
||||
class OpenFolderRequest(BaseModel):
|
||||
client_id: str = Field(...)
|
||||
app_name: str = Field(...)
|
||||
|
||||
@router.post("/open_app_in_vscode")
|
||||
async def open_folder_in_vscode(request: OpenFolderRequest):
|
||||
check_access(lollmsElfServer, request.client_id)
|
||||
sanitize_path(request.app_name)
|
||||
# Construct the folder path
|
||||
folder_path = lollmsElfServer.lollms_paths.apps_zoo_path/ request.app_name
|
||||
|
||||
# Check if the folder exists
|
||||
if not folder_path.exists():
|
||||
raise HTTPException(status_code=404, detail="Folder not found")
|
||||
|
||||
# Open the folder in VSCode
|
||||
try:
|
||||
os.system(f'code -n "{folder_path}"') # This assumes 'code' is in the PATH
|
||||
return {"message": f"Opened {folder_path} in VSCode."}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Failed to open folder: {str(e)}")
|
||||
|
||||
@router.post("/apps/{app_name}/code")
|
||||
async def get_app_code(app_name: str, auth: AuthRequest):
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 10ea733d4354e9cb3b293d7c6393c60e7dfb3504
|
||||
Subproject commit 3f3d29c82bcfc823ea7f6fbc6fb9ff02c049bdbf
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
web/dist/index.html
vendored
4
web/dist/index.html
vendored
@ -6,8 +6,8 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>LoLLMS WebUI</title>
|
||||
<script type="module" crossorigin src="/assets/index-ff2ab172.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-77eb38a4.css">
|
||||
<script type="module" crossorigin src="/assets/index-7503ebfe.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-ce1d34a8.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -23,12 +23,12 @@
|
||||
<button v-if="app.installed" @click.stop="uninstallApp(app.name)" class="bg-red-500 text-white px-2 py-1 rounded">Uninstall</button>
|
||||
<button v-else-if="app.existsInFolder" @click.stop="deleteApp(app.name)" class="bg-yellow-500 text-white px-2 py-1 rounded">Delete</button>
|
||||
<button v-else @click.stop="installApp(app.name)" class="bg-blue-500 text-white px-2 py-1 rounded">Install</button>
|
||||
<button v-if="app.installed" @click.stop="editApp(app)" class="bg-purple-500 text-white px-2 py-1 rounded">Edit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="selectedApp" class="app-render fixed inset-0 bg-white z-50 flex flex-col items-center justify-center">
|
||||
<button @click="backToZoo" class="absolute top-4 right-4 bg-gray-300 px-2 py-1 rounded">Back</button>
|
||||
<h2 class="text-2xl font-bold mb-4">Rendering: {{ selectedApp.name }}</h2>
|
||||
<iframe v-if="appCode" :srcdoc="appCode" class="app-frame w-full h-full border-none"></iframe>
|
||||
<p v-else class="text-center text-red-500">Please install this app to view its code.</p>
|
||||
</div>
|
||||
@ -148,6 +148,21 @@ export default {
|
||||
this.fetchApps(); // Refresh the app list
|
||||
}
|
||||
},
|
||||
async editApp(app) {
|
||||
this.loading = true;
|
||||
console.log("editing app", app.name)
|
||||
try {
|
||||
const response = await axios.post('/open_app_in_vscode', {
|
||||
client_id: this.$store.state.client_id,
|
||||
app_name: app.name,
|
||||
});
|
||||
this.showMessage(response.data.message, true);
|
||||
} catch (error) {
|
||||
this.showMessage('Failed to open folder in VSCode.', false);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
showMessage(msg, success) {
|
||||
this.message = msg;
|
||||
this.successMessage = success;
|
||||
|
Loading…
x
Reference in New Issue
Block a user