v1.0.13 (#46)
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| <script context="module" lang="ts"> | ||||
| 	import { publicPages } from '$lib/consts'; | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
| 	/** | ||||
| 	 * @type {import('@sveltejs/kit').Load} | ||||
| 	 */ | ||||
|   | ||||
| @@ -1,42 +0,0 @@ | ||||
| import type { Request } from '@sveltejs/kit'; | ||||
|  | ||||
| // export async function api(request: Request, resource: string, data?: {}) { | ||||
| //     const base = 'https://github.com/'; | ||||
| //     if (!request.context.isLoggedIn) { | ||||
| //         return { status: 401, body: 'Unauthorized' }; | ||||
| //     } | ||||
|  | ||||
| //     const res = await fetch(`${base}${resource}`, { | ||||
| //         method: request.method, | ||||
| //         headers: { | ||||
| //             'content-type': 'application/json' | ||||
| //         }, | ||||
| //         body: data && JSON.stringify(data) | ||||
| //     }); | ||||
| //     return { | ||||
| //         status: res.status, | ||||
| //         body: await res.json() | ||||
| //     }; | ||||
| // } | ||||
|  | ||||
| export async function githubAPI( | ||||
| 	request: Request, | ||||
| 	resource: string, | ||||
| 	token?: string, | ||||
| 	data?: Record<string, unknown> | ||||
| ) { | ||||
| 	const base = 'https://api.github.com'; | ||||
| 	const res = await fetch(`${base}${resource}`, { | ||||
| 		method: request.method, | ||||
| 		headers: { | ||||
| 			'content-type': 'application/json', | ||||
| 			accept: 'application/json', | ||||
| 			authorization: token ? `token ${token}` : '' | ||||
| 		}, | ||||
| 		body: data && JSON.stringify(data) | ||||
| 	}); | ||||
| 	return { | ||||
| 		status: res.status, | ||||
| 		body: await res.json() | ||||
| 	}; | ||||
| } | ||||
| @@ -44,7 +44,7 @@ export async function post(request: Request) { | ||||
| 		return { | ||||
| 			status: 500, | ||||
| 			body: { | ||||
| 				error | ||||
| 				error: error.message || error | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
|   | ||||
| @@ -1,9 +1,25 @@ | ||||
| import { docker } from '$lib/api/docker'; | ||||
| import Configuration from '$models/Configuration'; | ||||
| import type { Request } from '@sveltejs/kit'; | ||||
|  | ||||
| export async function post(request: Request) { | ||||
| 	const { name, organization, branch }: any = request.body || {}; | ||||
| 	if (name && organization && branch) { | ||||
| 		const configurationFound = await Configuration.findOne({ | ||||
| 			'repository.name': name, | ||||
| 			'repository.organization': organization, | ||||
| 			'repository.branch': branch, | ||||
| 		}).lean() | ||||
| 		if (configurationFound) { | ||||
| 			return { | ||||
| 				status: 200, | ||||
| 				body: { | ||||
| 					success: true, | ||||
| 					...configurationFound | ||||
| 				} | ||||
| 			}; | ||||
| 		} | ||||
|  | ||||
| 		const services = await docker.engine.listServices(); | ||||
| 		const applications = services.filter( | ||||
| 			(r) => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application' | ||||
| @@ -38,13 +54,12 @@ export async function post(request: Request) { | ||||
| 					...JSON.parse(found.Spec.Labels.configuration) | ||||
| 				} | ||||
| 			}; | ||||
| 		} else { | ||||
| 			return { | ||||
| 				status: 500, | ||||
| 				body: { | ||||
| 					error: 'No configuration found.' | ||||
| 				} | ||||
| 			}; | ||||
| 		} | ||||
| 		return { | ||||
| 			status: 500, | ||||
| 			body: { | ||||
| 				error: 'No configuration found.' | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,10 +1,11 @@ | ||||
| import type { Request } from '@sveltejs/kit'; | ||||
| import Deployment from '$models/Logs/Deployment'; | ||||
| import Deployment from '$models/Deployment'; | ||||
| import { docker } from '$lib/api/docker'; | ||||
| import { precheckDeployment, setDefaultConfiguration } from '$lib/api/applications/configuration'; | ||||
| import cloneRepository from '$lib/api/applications/cloneRepository'; | ||||
| import { cleanupTmp } from '$lib/api/common'; | ||||
| import queueAndBuild from '$lib/api/applications/queueAndBuild'; | ||||
| import Configuration from '$models/Configuration'; | ||||
| export async function post(request: Request) { | ||||
| 	let configuration; | ||||
| 	try { | ||||
| @@ -53,6 +54,27 @@ export async function post(request: Request) { | ||||
| 				} | ||||
| 			}; | ||||
| 		} | ||||
| 		const { id, organization, name, branch } = configuration.repository; | ||||
| 		const { domain } = configuration.publish; | ||||
| 		const { deployId, nickname } = configuration.general; | ||||
| 		await new Deployment({ | ||||
| 			repoId: id, | ||||
| 			branch, | ||||
| 			deployId, | ||||
| 			domain, | ||||
| 			organization, | ||||
| 			name, | ||||
| 			nickname | ||||
| 		}).save(); | ||||
| 		await Configuration.findOneAndUpdate({ | ||||
| 			'repository.id': id, | ||||
| 			'repository.organization': organization, | ||||
| 			'repository.name': name, | ||||
| 			'repository.branch': branch, | ||||
| 		}, | ||||
| 			{ ...configuration }, | ||||
| 			{ upsert: true, new: true }) | ||||
|  | ||||
| 		queueAndBuild(configuration, imageChanged); | ||||
| 		return { | ||||
| 			status: 200, | ||||
| @@ -70,20 +92,21 @@ export async function post(request: Request) { | ||||
| 				branch: configuration.repository.branch, | ||||
| 				organization: configuration.repository.organization, | ||||
| 				name: configuration.repository.name, | ||||
| 				domain: configuration.publish.domain, | ||||
| 				domain: configuration.publish.domain | ||||
| 			}, | ||||
| 			{ | ||||
| 				repoId: configuration.repository.id, | ||||
| 				branch: configuration.repository.branch, | ||||
| 				organization: configuration.repository.organization, | ||||
| 				name: configuration.repository.name, | ||||
| 				domain: configuration.publish.domain, progress: 'failed' | ||||
| 				domain: configuration.publish.domain, | ||||
| 				progress: 'failed' | ||||
| 			} | ||||
| 		); | ||||
| 		return { | ||||
| 			status: 500, | ||||
| 			body: { | ||||
| 				error | ||||
| 				error: error.message || error | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import type { Request } from '@sveltejs/kit'; | ||||
| import ApplicationLog from '$models/Logs/Application'; | ||||
| import Deployment from '$models/Logs/Deployment'; | ||||
| import ApplicationLog from '$models/ApplicationLog'; | ||||
| import Deployment from '$models/Deployment'; | ||||
| import dayjs from 'dayjs'; | ||||
|  | ||||
| export async function get(request: Request) { | ||||
| @@ -24,11 +24,11 @@ export async function get(request: Request) { | ||||
| 				...finalLogs | ||||
| 			} | ||||
| 		}; | ||||
| 	} catch (e) { | ||||
| 	} catch (error) { | ||||
| 		return { | ||||
| 			status: 500, | ||||
| 			body: { | ||||
| 				error: e | ||||
| 				error: error.message || error | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
|   | ||||
| @@ -2,7 +2,7 @@ import type { Request } from '@sveltejs/kit'; | ||||
| import dayjs from 'dayjs'; | ||||
| import utc from 'dayjs/plugin/utc.js'; | ||||
| import relativeTime from 'dayjs/plugin/relativeTime.js'; | ||||
| import Deployment from '$models/Logs/Deployment'; | ||||
| import Deployment from '$models/Deployment'; | ||||
| dayjs.extend(utc); | ||||
| dayjs.extend(relativeTime); | ||||
| export async function get(request: Request) { | ||||
| @@ -10,7 +10,6 @@ export async function get(request: Request) { | ||||
| 		const repoId = request.query.get('repoId'); | ||||
| 		const branch = request.query.get('branch'); | ||||
| 		const page = request.query.get('page'); | ||||
|  | ||||
| 		const onePage = 5; | ||||
| 		const show = Number(page) * onePage || 5; | ||||
| 		const deploy: any = await Deployment.find({ repoId, branch }) | ||||
| @@ -20,12 +19,9 @@ export async function get(request: Request) { | ||||
|  | ||||
| 		const finalLogs = deploy.map((d) => { | ||||
| 			const finalLogs = { ...d._doc }; | ||||
|  | ||||
| 			const updatedAt = dayjs(d.updatedAt).utc(); | ||||
|  | ||||
| 			finalLogs.took = updatedAt.diff(dayjs(d.createdAt)) / 1000; | ||||
| 			finalLogs.since = updatedAt.fromNow(); | ||||
|  | ||||
| 			return finalLogs; | ||||
| 		}); | ||||
| 		return { | ||||
| @@ -36,11 +32,10 @@ export async function get(request: Request) { | ||||
| 			} | ||||
| 		}; | ||||
| 	} catch (error) { | ||||
| 		console.log(error); | ||||
| 		return { | ||||
| 			status: 500, | ||||
| 			body: { | ||||
| 				error | ||||
| 				error: error.message || error | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
|   | ||||
| @@ -16,11 +16,12 @@ export async function get(request: Request) { | ||||
| 			body: { success: true, logs } | ||||
| 		}; | ||||
| 	} catch (error) { | ||||
| 		console.log(error) | ||||
| 		await saveServerLog(error); | ||||
| 		return { | ||||
| 			status: 500, | ||||
| 			body: { | ||||
| 				error | ||||
| 				error: 'No such service. Is it under deployment?' | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
|   | ||||
| @@ -1,8 +1,9 @@ | ||||
| import { purgeImagesContainers } from '$lib/api/applications/cleanup'; | ||||
| import { docker } from '$lib/api/docker'; | ||||
| import Deployment from '$models/Logs/Deployment'; | ||||
| import ApplicationLog from '$models/Logs/Application'; | ||||
| import Deployment from '$models/Deployment'; | ||||
| import ApplicationLog from '$models/ApplicationLog'; | ||||
| import { delay, execShellAsync } from '$lib/api/common'; | ||||
| import Configuration from '$models/Configuration'; | ||||
|  | ||||
| async function call(found) { | ||||
| 	await delay(10000); | ||||
| @@ -26,6 +27,11 @@ export async function post(request: Request) { | ||||
| 				return null; | ||||
| 			}); | ||||
| 		if (found) { | ||||
| 			await Configuration.findOneAndRemove({ | ||||
| 				'repository.name': name, | ||||
| 				'repository.organization': organization, | ||||
| 				'repository.branch': branch, | ||||
| 			}) | ||||
| 			const deploys = await Deployment.find({ organization, branch, name }); | ||||
| 			for (const deploy of deploys) { | ||||
| 				await ApplicationLog.deleteMany({ deployId: deploy.deployId }); | ||||
|   | ||||
| @@ -1,9 +1,7 @@ | ||||
| import { docker } from '$lib/api/docker'; | ||||
| import LogsServer from '$models/Logs/Server'; | ||||
| import type { Request } from '@sveltejs/kit'; | ||||
| 
 | ||||
| export async function get(request: Request) { | ||||
| 	const serverLogs = await LogsServer.find(); | ||||
| 	const dockerServices = await docker.engine.listServices(); | ||||
| 	let applications: any = dockerServices.filter( | ||||
| 		(r) => | ||||
| @@ -61,7 +59,6 @@ export async function get(request: Request) { | ||||
| 		status: 200, | ||||
| 		body: { | ||||
| 			success: true, | ||||
| 			serverLogs, | ||||
| 			applications: { | ||||
| 				deployed: applications | ||||
| 			}, | ||||
| @@ -100,6 +100,31 @@ export async function post(request: Request) { | ||||
| 					body: fs.readFileSync(`${fullfilename}`) | ||||
| 				}; | ||||
| 			} | ||||
| 		} else if (type === 'redis') { | ||||
| 			if (databaseService) { | ||||
| 				const password = configuration.database.passwords[0]; | ||||
| 				const databaseName = configuration.database.defaultDatabaseName; | ||||
| 				const filename = `${databaseName}_${now.getTime()}.rdb`; | ||||
| 				const fullfilename = `${tmpdir}/${filename}`; | ||||
| 				await execShellAsync( | ||||
| 					`docker exec -i ${containerID} /bin/bash -c "redis-cli --pass ${password} save"` | ||||
| 				); | ||||
| 				await execShellAsync( | ||||
| 					`docker cp ${containerID}:/bitnami/redis/data/dump.rdb ${fullfilename}` | ||||
| 				); | ||||
| 				await execShellAsync( | ||||
| 					`docker exec -i ${containerID} /bin/bash -c "rm -f /bitnami/redis/data/dump.rdb"` | ||||
| 				); | ||||
| 				return { | ||||
| 					status: 200, | ||||
| 					headers: { | ||||
| 						'Content-Type': 'application/octet-stream', | ||||
| 						'Content-Transfer-Encoding': 'binary', | ||||
| 						'Content-Disposition': `attachment; filename=${filename}` | ||||
| 					}, | ||||
| 					body: fs.readFileSync(`${fullfilename}`) | ||||
| 				}; | ||||
| 			} | ||||
| 		} | ||||
| 		return { | ||||
| 			status: 501, | ||||
| @@ -108,12 +133,11 @@ export async function post(request: Request) { | ||||
| 			} | ||||
| 		}; | ||||
| 	} catch (error) { | ||||
| 		console.log(error); | ||||
| 		await saveServerLog(error); | ||||
| 		return { | ||||
| 			status: 500, | ||||
| 			body: { | ||||
| 				error | ||||
| 				error: error.message || error | ||||
| 			} | ||||
| 		}; | ||||
| 	} finally { | ||||
|   | ||||
| @@ -96,6 +96,12 @@ export async function post(request: Request) { | ||||
| 					hard: 262144 | ||||
| 				} | ||||
| 			}; | ||||
| 		} else if (type === 'redis') { | ||||
| 			image = 'bitnami/redis'; | ||||
| 			volume = `${configuration.general.deployId}-${type}-data:/bitnami/redis/data`; | ||||
| 			generateEnvs = { | ||||
| 				REDIS_PASSWORD: passwords[0] | ||||
| 			}; | ||||
| 		} | ||||
|  | ||||
| 		const stack = { | ||||
|   | ||||
| @@ -1,10 +1,10 @@ | ||||
| import { githubAPI } from '$api'; | ||||
| import type { Request } from '@sveltejs/kit'; | ||||
| import mongoose from 'mongoose'; | ||||
| import User from '$models/User'; | ||||
| import Settings from '$models/Settings'; | ||||
| import cuid from 'cuid'; | ||||
| import jsonwebtoken from 'jsonwebtoken'; | ||||
| import { githubAPI } from '$lib/api/github'; | ||||
|  | ||||
| export async function get(request: Request) { | ||||
| 	const code = request.query.get('code'); | ||||
| @@ -17,7 +17,7 @@ export async function get(request: Request) { | ||||
| 				{ headers: { accept: 'application/json' } } | ||||
| 			) | ||||
| 		).json(); | ||||
| 		const { avatar_url, id } = await (await githubAPI(request, '/user', access_token)).body; | ||||
| 		const { avatar_url } = await (await githubAPI(request, '/user', access_token)).body; | ||||
| 		const email = (await githubAPI(request, '/user/emails', access_token)).body.filter( | ||||
| 			(e) => e.primary | ||||
| 		)[0].email; | ||||
| @@ -41,11 +41,10 @@ export async function get(request: Request) { | ||||
| 				try { | ||||
| 					await newUser.save(); | ||||
| 					await defaultSettings.save(); | ||||
| 				} catch (e) { | ||||
| 					console.log(e); | ||||
| 				} catch (error) { | ||||
| 					return { | ||||
| 						status: 500, | ||||
| 						body: e | ||||
| 						error: error.message || error | ||||
| 					}; | ||||
| 				} | ||||
| 			} else { | ||||
| @@ -73,12 +72,11 @@ export async function get(request: Request) { | ||||
| 						}); | ||||
| 						try { | ||||
| 							await newUser.save(); | ||||
| 						} catch (e) { | ||||
| 							console.log(e); | ||||
| 						} catch (error) { | ||||
| 							return { | ||||
| 								status: 500, | ||||
| 								body: { | ||||
| 									error: e | ||||
| 									error: error.message || error | ||||
| 								} | ||||
| 							}; | ||||
| 						} | ||||
| @@ -103,8 +101,6 @@ export async function get(request: Request) { | ||||
| 			} | ||||
| 		}; | ||||
| 	} catch (error) { | ||||
| 		console.log('error happened'); | ||||
| 		console.log(error); | ||||
| 		return { status: 500, body: { ...error } }; | ||||
| 		return { status: 500, body: { error: error.message || error } }; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -34,12 +34,11 @@ export async function get(request: Request) { | ||||
| 			}; | ||||
| 		} | ||||
| 	} catch (error) { | ||||
| 		console.log(error); | ||||
| 		return { | ||||
| 			status: 500, | ||||
| 			body: { | ||||
| 				success: false, | ||||
| 				error | ||||
| 				error: error.message || error | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
|   | ||||
| @@ -22,7 +22,7 @@ export async function get(request: Request) { | ||||
| 		return { | ||||
| 			status: 500, | ||||
| 			body: { | ||||
| 				error | ||||
| 				error: error.message || error | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
| @@ -45,7 +45,7 @@ export async function post(request: Request) { | ||||
| 		return { | ||||
| 			status: 500, | ||||
| 			body: { | ||||
| 				error | ||||
| 				error: error.message || error | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
| @@ -10,7 +10,6 @@ export async function get(request: Request) { | ||||
| 	execShellAsync( | ||||
| 		'docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -u root coolify bash -c "$(curl -fsSL https://get.coollabs.io/coolify/upgrade-p2.sh)"' | ||||
| 	); | ||||
| 	// saveServerLog({ message: upgradeP2, type: 'UPGRADE-P-2' })
 | ||||
| 	return { | ||||
| 		status: 200, | ||||
| 		body: { | ||||
| @@ -1,24 +0,0 @@ | ||||
| // import { deleteCookies } from '$lib/api/common'; | ||||
| // import { verifyUserId } from '$lib/api/common'; | ||||
| // import type { Request } from '@sveltejs/kit'; | ||||
| // import * as cookie from 'cookie'; | ||||
|  | ||||
| // export async function post(request: Request) { | ||||
| // 	const { coolToken } = cookie.parse(request.headers.cookie || ''); | ||||
| // 	try { | ||||
| // 		await verifyUserId(coolToken); | ||||
| // 		return { | ||||
| // 			status: 200, | ||||
| // 			body: { success: true } | ||||
| // 		}; | ||||
| // 	} catch (error) { | ||||
| // 		return { | ||||
| // 			status: 301, | ||||
| // 			headers: { | ||||
| // 				location: '/', | ||||
| // 				'set-cookie': [...deleteCookies] | ||||
| // 			}, | ||||
| // 			body: { error: 'Unauthorized' } | ||||
| // 		}; | ||||
| // 	} | ||||
| // } | ||||
| @@ -1,6 +1,6 @@ | ||||
| import type { Request } from '@sveltejs/kit'; | ||||
| import crypto from 'crypto'; | ||||
| import Deployment from '$models/Logs/Deployment'; | ||||
| import Deployment from '$models/Deployment'; | ||||
| import { docker } from '$lib/api/docker'; | ||||
| import { precheckDeployment, setDefaultConfiguration } from '$lib/api/applications/configuration'; | ||||
| import cloneRepository from '$lib/api/applications/cloneRepository'; | ||||
| @@ -106,7 +106,7 @@ export async function post(request: Request) { | ||||
| 		return { | ||||
| 			status: 500, | ||||
| 			body: { | ||||
| 				error | ||||
| 				error: error.message || error | ||||
| 			} | ||||
| 		}; | ||||
| 	} | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
| 	import { onDestroy, onMount } from 'svelte'; | ||||
| 	import { fade } from 'svelte/transition'; | ||||
| 	import Loading from '$components/Loading.svelte'; | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
| 	import { page, session } from '$app/stores'; | ||||
| 	import { goto } from '$app/navigation'; | ||||
| 	import { browser } from '$app/env'; | ||||
|   | ||||
| @@ -5,7 +5,7 @@ | ||||
| 	import { onDestroy, onMount } from 'svelte'; | ||||
|  | ||||
| 	import Loading from '$components/Loading.svelte'; | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
| 	import { session } from '$app/stores'; | ||||
| 	import { goto } from '$app/navigation'; | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
| 	import { page, session } from '$app/stores'; | ||||
| 	import { goto } from '$app/navigation'; | ||||
| 	import { browser } from '$app/env'; | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
|  | ||||
| 	$application.repository.organization = $page.params.organization; | ||||
| 	$application.repository.name = $page.params.name; | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| <script context="module" lang="ts"> | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
| 	/** | ||||
| 	 * @type {import('@sveltejs/kit').Load} | ||||
| 	 */ | ||||
|   | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -7,6 +7,8 @@ | ||||
| 	import Mysql from '$components/Database/SVGs/Mysql.svelte'; | ||||
| 	import { dashboard } from '$store'; | ||||
| 	import { fade } from 'svelte/transition'; | ||||
| 	import Redis from '$components/Database/SVGs/Redis.svelte'; | ||||
|  | ||||
| </script> | ||||
|  | ||||
| <div class="py-5 text-left px-6 text-3xl tracking-tight font-bold flex items-center"> | ||||
| @@ -56,6 +58,10 @@ | ||||
| 									<CouchDb | ||||
| 										customClass="w-10 h-10 fill-current text-red-600 absolute top-0 left-0 -m-4" | ||||
| 									/> | ||||
| 								{:else if database.configuration.general.type == 'redis'} | ||||
| 									<Redis | ||||
| 										customClass="w-10 h-10  absolute top-0 left-0 -m-4" | ||||
| 									/> | ||||
| 								{:else if database.configuration.general.type == 'clickhouse'} | ||||
| 									<Clickhouse | ||||
| 										customClass="w-10 h-10 fill-current text-red-600 absolute top-0 left-0 -m-4" | ||||
| @@ -79,4 +85,3 @@ | ||||
| 		<div class="text-2xl font-bold text-center">No databases found</div> | ||||
| 	{/if} | ||||
| </div> | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| <script> | ||||
| 	import { database } from '$store'; | ||||
| 	import { page, session } from '$app/stores'; | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
| 	import { fade } from 'svelte/transition'; | ||||
| 	import { goto } from '$app/navigation'; | ||||
| 	import MongoDb from '$components/Database/SVGs/MongoDb.svelte'; | ||||
| @@ -12,10 +12,11 @@ | ||||
| 	import PasswordField from '$components/PasswordField.svelte'; | ||||
| 	import { browser } from '$app/env'; | ||||
| 	import { toast } from '@zerodevx/svelte-toast'; | ||||
| 	import Redis from '$components/Database/SVGs/Redis.svelte'; | ||||
|  | ||||
| 	async function backup() { | ||||
| 		try { | ||||
| 			await request(`/api/v1/databases/${$page.params.name}/backup`, $session, {body: {}}); | ||||
| 			await request(`/api/v1/databases/${$page.params.name}/backup`, $session, { body: {} }); | ||||
|  | ||||
| 			browser && toast.push(`Successfully created backup.`); | ||||
| 		} catch (error) { | ||||
| @@ -56,6 +57,8 @@ | ||||
| 					<Mysql customClass="w-8 h-8" /> | ||||
| 				{:else if $database.config.general.type === 'couchdb'} | ||||
| 					<CouchDb customClass="w-8 h-8 fill-current text-red-600" /> | ||||
| 				{:else if $database.config.general.type === 'redis'} | ||||
| 					<Redis customClass="w-8 h-8" /> | ||||
| 				{/if} | ||||
| 			</div> | ||||
| 		</div> | ||||
| @@ -64,7 +67,9 @@ | ||||
| 		<div class="pb-2 pt-5 space-y-4"> | ||||
| 			<div class="text-2xl font-bold border-gradient w-32">Database</div> | ||||
| 			<div class="flex items-center pt-4"> | ||||
| 				<div class="font-bold w-64 text-warmGray-400">Connection string</div> | ||||
| 				{#if $database.config.general.type !== 'redis'} | ||||
| 					<div class="font-bold w-64 text-warmGray-400">Connection string</div> | ||||
| 				{/if} | ||||
| 				{#if $database.config.general.type === 'mongodb'} | ||||
| 					<PasswordField | ||||
| 						value={`mongodb://${$database.envs.MONGODB_USERNAME}:${$database.envs.MONGODB_PASSWORD}@${$database.config.general.deployId}:27017/${$database.envs.MONGODB_DATABASE}`} | ||||
| @@ -97,6 +102,12 @@ | ||||
| 				<PasswordField value={$database.envs.MONGODB_ROOT_PASSWORD} /> | ||||
| 			</div> | ||||
| 		{/if} | ||||
| 		{#if $database.config.general.type === 'redis'} | ||||
| 			<div class="flex items-center"> | ||||
| 				<div class="font-bold w-64 text-warmGray-400">Redis password</div> | ||||
| 				<PasswordField value={$database.envs.REDIS_PASSWORD} /> | ||||
| 			</div> | ||||
| 		{/if} | ||||
| 		<div class="pb-2 pt-5 space-y-4"> | ||||
| 			<div class="text-2xl font-bold border-gradient w-32">Backup</div> | ||||
| 			<div class="pt-4"> | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
| 	import { goto } from '$app/navigation'; | ||||
| 	import { page, session } from '$app/stores'; | ||||
| 	import Tooltip from '$components/Tooltip.svelte'; | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
| 	import { database, initialDatabase } from '$store'; | ||||
| 	import { toast } from '@zerodevx/svelte-toast'; | ||||
| 	import { onDestroy } from 'svelte'; | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
|  | ||||
| 	import { goto } from '$app/navigation'; | ||||
| 	import { session } from '$app/stores'; | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
|  | ||||
| 	async function login() { | ||||
| 		const left = screen.width / 2 - 1020 / 2; | ||||
|   | ||||
| @@ -5,7 +5,7 @@ | ||||
|  | ||||
| 	import { page, session } from '$app/stores'; | ||||
| 	import Tooltip from '$components/Tooltip.svelte'; | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
|  | ||||
| 	import { toast } from '@zerodevx/svelte-toast'; | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| 	import { toast } from '@zerodevx/svelte-toast'; | ||||
|  | ||||
| 	import { page, session } from '$app/stores'; | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
| 	import { goto } from '$app/navigation'; | ||||
| 	import Loading from '$components/Loading.svelte'; | ||||
| 	import Plausible from '$components/Service/Plausible.svelte'; | ||||
|   | ||||
| @@ -5,7 +5,7 @@ | ||||
|  | ||||
| 	import { page, session } from '$app/stores'; | ||||
| 	import Loading from '$components/Loading.svelte'; | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
| 	import { initialNewService, newService } from '$store'; | ||||
|  | ||||
| 	import { toast } from '@zerodevx/svelte-toast'; | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
| 	import { toast } from '@zerodevx/svelte-toast'; | ||||
| 	import { newService } from '$store'; | ||||
| 	import { page, session } from '$app/stores'; | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
| 	import { goto } from '$app/navigation'; | ||||
| 	import Loading from '$components/Loading.svelte'; | ||||
| 	import TooltipInfo from '$components/TooltipInfo.svelte'; | ||||
|   | ||||
| @@ -29,7 +29,7 @@ | ||||
| 	import { browser } from '$app/env'; | ||||
| 	import { session } from '$app/stores'; | ||||
|  | ||||
| 	import { request } from '$lib/api/request'; | ||||
| 	import { request } from '$lib/request'; | ||||
| 	import { toast } from '@zerodevx/svelte-toast'; | ||||
| 	import { fade } from 'svelte/transition'; | ||||
| 	let settings = { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Andras Bacsai
					Andras Bacsai