semantic cleanup

This commit is contained in:
2026-01-23 21:58:32 +03:00
parent 343f2e29f5
commit 4ba28cf93e
26 changed files with 8429 additions and 5628 deletions

26
frontend/.gitignore vendored Executable file
View File

@@ -0,0 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
.svelte-kit
build
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@@ -33,6 +33,11 @@
const dispatch = createEventDispatcher();
// [DEF:onMount:Function]
/**
* @purpose Load branches when component is mounted.
* @pre Component is initialized.
* @post loadBranches is called.
*/
onMount(async () => {
await loadBranches();
});
@@ -41,6 +46,7 @@
// [DEF:loadBranches:Function]
/**
* @purpose Загружает список веток для дашборда.
* @pre dashboardId is provided.
* @post branches обновлен.
*/
async function loadBranches() {
@@ -59,6 +65,11 @@
// [/DEF:loadBranches:Function]
// [DEF:handleSelect:Function]
/**
* @purpose Handles branch selection from dropdown.
* @pre event contains branch name.
* @post handleCheckout is called with selected branch.
*/
function handleSelect(event) {
handleCheckout(event.target.value);
}
@@ -88,7 +99,8 @@
// [DEF:handleCreate:Function]
/**
* @purpose Создает новую ветку.
* @post Новая ветка создана и загружена.
* @pre newBranchName is not empty.
* @post Новая ветка создана и загружена; showCreate reset.
*/
async function handleCreate() {
if (!newBranchName) return;

View File

@@ -27,6 +27,8 @@
// [DEF:onMount:Function]
/**
* @purpose Load history when component is mounted.
* @pre Component is initialized with dashboardId.
* @post loadHistory is called.
*/
onMount(async () => {
await loadHistory();
@@ -36,6 +38,7 @@
// [DEF:loadHistory:Function]
/**
* @purpose Fetch commit history from the backend.
* @pre dashboardId is valid.
* @post history state is updated.
*/
async function loadHistory() {

View File

@@ -32,6 +32,7 @@
// [DEF:loadStatus:Watcher]
$: if (show) loadEnvironments();
// [/DEF:loadStatus:Watcher]
// [DEF:loadEnvironments:Function]
/**

View File

@@ -51,6 +51,8 @@
// [DEF:checkStatus:Function]
/**
* @purpose Проверяет, инициализирован ли репозиторий для данного дашборда.
* @pre Component is mounted and has dashboardId.
* @post initialized state is set; configs loaded if not initialized.
*/
async function checkStatus() {
checkingStatus = true;
@@ -72,6 +74,8 @@
// [DEF:handleInit:Function]
/**
* @purpose Инициализирует репозиторий для дашборда.
* @pre selectedConfigId and remoteUrl are provided.
* @post Repository is created on backend; initialized set to true.
*/
async function handleInit() {
if (!selectedConfigId || !remoteUrl) {
@@ -94,6 +98,8 @@
// [DEF:handleSync:Function]
/**
* @purpose Синхронизирует состояние Superset с локальным Git-репозиторием.
* @pre Repository is initialized.
* @post Dashboard YAMLs are exported to Git and staged.
*/
async function handleSync() {
loading = true;
@@ -111,6 +117,11 @@
// [/DEF:handleSync:Function]
// [DEF:handlePush:Function]
/**
* @purpose Pushes local commits to the remote repository.
* @pre Repository is initialized and has commits.
* @post Changes are pushed to origin.
*/
async function handlePush() {
loading = true;
try {
@@ -125,6 +136,11 @@
// [/DEF:handlePush:Function]
// [DEF:handlePull:Function]
/**
* @purpose Pulls changes from the remote repository.
* @pre Repository is initialized.
* @post Local branch is updated with remote changes.
*/
async function handlePull() {
loading = true;
try {

View File

@@ -1,4 +1,9 @@
<!-- [DEF:GitDashboardPage:Component] -->
<!--
@PURPOSE: Dashboard management page for Git integration.
@LAYER: Page
@SEMANTICS: git, dashboard, management, ui
-->
<script lang="ts">
import { onMount } from 'svelte';
import DashboardGrid from '../../components/DashboardGrid.svelte';
@@ -13,6 +18,10 @@
let loading = true;
let fetchingDashboards = false;
// [DEF:fetchEnvironments:Function]
// @PURPOSE: Fetches the list of deployment environments from the API.
// @PRE: Component is mounted.
// @POST: `environments` array is populated with data from /api/environments.
async function fetchEnvironments() {
try {
const response = await fetch('/api/environments');
@@ -27,7 +36,12 @@
loading = false;
}
}
// [/DEF:fetchEnvironments:Function]
// [DEF:fetchDashboards:Function]
// @PURPOSE: Fetches dashboards for a specific environment.
// @PRE: `envId` is a valid environment ID.
// @POST: `dashboards` array is updated with results from the environment.
async function fetchDashboards(envId: string) {
if (!envId) return;
fetchingDashboards = true;
@@ -42,6 +56,7 @@
fetchingDashboards = false;
}
}
// [/DEF:fetchDashboards:Function]
onMount(fetchEnvironments);

View File

@@ -33,6 +33,8 @@
// [DEF:loadConfigs:Function]
/**
* @purpose Fetches existing git configurations.
* @pre Component is mounted.
* @post configs state is populated.
*/
async function loadConfigs() {
try {
@@ -48,6 +50,8 @@
// [DEF:handleTest:Function]
/**
* @purpose Tests connection to a git server with current form data.
* @pre newConfig contains valid provider, url, and pat.
* @post testing state is managed; toast shown with result.
*/
async function handleTest() {
testing = true;
@@ -69,6 +73,8 @@
// [DEF:handleSave:Function]
/**
* @purpose Saves a new git configuration.
* @pre newConfig is valid and tested.
* @post New config is saved to DB and added to configs list.
*/
async function handleSave() {
try {
@@ -86,6 +92,8 @@
/**
* @purpose Deletes a git configuration by ID.
* @param {string} id - Configuration ID.
* @pre id is valid; user confirmed deletion.
* @post Configuration is removed from DB and local state.
*/
async function handleDelete(id) {
if (!confirm('Are you sure you want to delete this Git configuration?')) return;

View File

@@ -1,5 +1,5 @@
// [DEF:GitServiceClient:Module]
/**
* [DEF:GitServiceClient:Module]
* @SEMANTICS: git, service, api, client
* @PURPOSE: API client for Git operations, managing the communication between frontend and backend.
* @LAYER: Service