Работает создание коммитов и перенос в новый enviroment

This commit is contained in:
2026-01-23 13:57:44 +03:00
parent e9d3f3c827
commit 07ec2d9797
37 changed files with 3227 additions and 252 deletions

View File

@@ -23,6 +23,8 @@
console.log(`[Dashboard][Action] Selecting plugin: ${plugin.id}`);
if (plugin.id === 'superset-migration') {
goto('/migration');
} else if (plugin.id === 'git-integration') {
goto('/git');
} else {
selectedPlugin.set(plugin);
}

View File

@@ -0,0 +1,86 @@
<!-- [DEF:GitDashboardPage:Component] -->
<script lang="ts">
import { onMount } from 'svelte';
import DashboardGrid from '../../components/DashboardGrid.svelte';
import { addToast as toast } from '../../lib/toasts.js';
import type { DashboardMetadata } from '../../types/dashboard';
let environments: any[] = [];
let selectedEnvId = "";
let dashboards: DashboardMetadata[] = [];
let loading = true;
let fetchingDashboards = false;
async function fetchEnvironments() {
try {
const response = await fetch('/api/environments');
if (!response.ok) throw new Error('Failed to fetch environments');
environments = await response.json();
if (environments.length > 0) {
selectedEnvId = environments[0].id;
}
} catch (e) {
toast(e.message, 'error');
} finally {
loading = false;
}
}
async function fetchDashboards(envId: string) {
if (!envId) return;
fetchingDashboards = true;
try {
const response = await fetch(`/api/environments/${envId}/dashboards`);
if (!response.ok) throw new Error('Failed to fetch dashboards');
dashboards = await response.json();
} catch (e) {
toast(e.message, 'error');
dashboards = [];
} finally {
fetchingDashboards = false;
}
}
onMount(fetchEnvironments);
$: if (selectedEnvId) {
fetchDashboards(selectedEnvId);
localStorage.setItem('selected_env_id', selectedEnvId);
}
</script>
<div class="max-w-6xl mx-auto p-6">
<div class="flex justify-between items-center mb-6">
<h1 class="text-2xl font-bold text-gray-800">Git Dashboard Management</h1>
<div class="flex items-center space-x-4">
<label for="env-select" class="text-sm font-medium text-gray-700">Environment:</label>
<select
id="env-select"
bind:value={selectedEnvId}
class="border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 p-2 border bg-white"
>
{#each environments as env}
<option value={env.id}>{env.name}</option>
{/each}
</select>
</div>
</div>
{#if loading}
<div class="flex justify-center py-12">
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
</div>
{:else}
<div class="bg-white rounded-lg shadow p-6">
<h2 class="text-lg font-medium mb-4">Select Dashboard to Manage</h2>
{#if fetchingDashboards}
<p class="text-gray-500">Loading dashboards...</p>
{:else if dashboards.length > 0}
<DashboardGrid {dashboards} />
{:else}
<p class="text-gray-500 italic">No dashboards found in this environment.</p>
{/if}
</div>
{/if}
</div>
<!-- [/DEF:GitDashboardPage:Component] -->

View File

@@ -0,0 +1,40 @@
<script>
import { onMount } from 'svelte';
import { gitService } from '../../../services/gitService';
import { addToast as toast } from '../../../lib/toasts.js';
let environments = [];
onMount(async () => {
try {
environments = await gitService.getEnvironments();
} catch (e) {
toast(e.message, 'error');
}
});
</script>
<div class="p-6">
<h1 class="text-2xl font-bold mb-6">Deployment Environments</h1>
<div class="bg-white p-6 rounded shadow">
<h2 class="text-xl font-semibold mb-4">Target Environments</h2>
{#if environments.length === 0}
<p class="text-gray-500">No deployment environments configured.</p>
{:else}
<ul class="divide-y">
{#each environments as env}
<li class="py-3 flex justify-between items-center">
<div>
<span class="font-medium">{env.name}</span>
<div class="text-xs text-gray-400">{env.superset_url}</div>
</div>
<span class="px-2 py-1 text-xs rounded {env.is_active ? 'bg-green-100 text-green-800' : 'bg-gray-100 text-gray-800'}">
{env.is_active ? 'Active' : 'Inactive'}
</span>
</li>
{/each}
</ul>
{/if}
</div>
</div>

View File

@@ -0,0 +1,136 @@
<script>
import { onMount } from 'svelte';
import { gitService } from '../../../services/gitService';
import { addToast as toast } from '../../../lib/toasts.js';
let configs = [];
let newConfig = {
name: '',
provider: 'GITHUB',
url: 'https://github.com',
pat: '',
default_repository: ''
};
let testing = false;
onMount(async () => {
try {
configs = await gitService.getConfigs();
} catch (e) {
toast(e.message, 'error');
}
});
async function handleTest() {
testing = true;
try {
const result = await gitService.testConnection(newConfig);
if (result.status === 'success') {
toast('Connection successful', 'success');
} else {
toast(result.message || 'Connection failed', 'error');
}
} catch (e) {
toast('Connection failed', 'error');
} finally {
testing = false;
}
}
async function handleSave() {
try {
const saved = await gitService.createConfig(newConfig);
configs = [...configs, saved];
toast('Configuration saved', 'success');
newConfig = { name: '', provider: 'GITHUB', url: 'https://github.com', pat: '', default_repository: '' };
} catch (e) {
toast(e.message, 'error');
}
}
async function handleDelete(id) {
if (!confirm('Are you sure you want to delete this Git configuration?')) return;
try {
await gitService.deleteConfig(id);
configs = configs.filter(c => c.id !== id);
toast('Configuration deleted', 'success');
} catch (e) {
toast(e.message, 'error');
}
}
</script>
<div class="p-6">
<h1 class="text-2xl font-bold mb-6">Git Integration Settings</h1>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<!-- List of Configs -->
<div class="bg-white p-6 rounded shadow">
<h2 class="text-xl font-semibold mb-4">Configured Servers</h2>
{#if configs.length === 0}
<p class="text-gray-500">No Git servers configured.</p>
{:else}
<ul class="divide-y">
{#each configs as config}
<li class="py-3 flex justify-between items-center">
<div>
<span class="font-medium">{config.name}</span>
<span class="text-sm text-gray-500 ml-2">({config.provider})</span>
<div class="text-xs text-gray-400">{config.url}</div>
</div>
<div class="flex items-center space-x-4">
<span class="px-2 py-1 text-xs rounded {config.status === 'CONNECTED' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'}">
{config.status}
</span>
<button on:click={() => handleDelete(config.id)} class="text-red-600 hover:text-red-800 p-1" title="Delete">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
</svg>
</button>
</div>
</li>
{/each}
</ul>
{/if}
</div>
<!-- Add New Config -->
<div class="bg-white p-6 rounded shadow">
<h2 class="text-xl font-semibold mb-4">Add Git Server</h2>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700">Display Name</label>
<input type="text" bind:value={newConfig.name} class="mt-1 block w-full border rounded p-2" placeholder="e.g. My GitHub" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Provider</label>
<select bind:value={newConfig.provider} class="mt-1 block w-full border rounded p-2">
<option value="GITHUB">GitHub</option>
<option value="GITLAB">GitLab</option>
<option value="GITEA">Gitea</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Server URL</label>
<input type="text" bind:value={newConfig.url} class="mt-1 block w-full border rounded p-2" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Personal Access Token (PAT)</label>
<input type="password" bind:value={newConfig.pat} class="mt-1 block w-full border rounded p-2" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Default Repository (Optional)</label>
<input type="text" bind:value={newConfig.default_repository} class="mt-1 block w-full border rounded p-2" placeholder="org/repo" />
</div>
<div class="flex space-x-4 pt-4">
<button on:click={handleTest} disabled={testing} class="bg-gray-200 px-4 py-2 rounded hover:bg-gray-300 disabled:opacity-50">
{testing ? 'Testing...' : 'Test Connection'}
</button>
<button on:click={handleSave} class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
Save Configuration
</button>
</div>
</div>
</div>
</div>
</div>