2024-04-20 12:21:41 +02:00
|
|
|
import { commitinfo } from '../00_commitinfo_data.js';
|
|
|
|
|
import * as plugins from '../plugins.js';
|
|
|
|
|
|
|
|
|
|
import * as appstate from '../appstate.js';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
DeesElement,
|
|
|
|
|
css,
|
|
|
|
|
cssManager,
|
|
|
|
|
customElement,
|
|
|
|
|
html,
|
|
|
|
|
state
|
|
|
|
|
} from '@design.estate/dees-element';
|
2025-09-14 17:28:21 +00:00
|
|
|
import { CloudlyViewBackups } from './views/backups/index.js';
|
2026-05-07 17:44:31 +00:00
|
|
|
import { CloudlyViewBaseOs } from './views/baseos/index.js';
|
2025-09-14 17:28:21 +00:00
|
|
|
import { CloudlyViewClusters } from './views/clusters/index.js';
|
|
|
|
|
import { CloudlyViewDbs } from './views/dbs/index.js';
|
|
|
|
|
import { CloudlyViewDeployments } from './views/deployments/index.js';
|
|
|
|
|
import { CloudlyViewDns } from './views/dns/index.js';
|
|
|
|
|
import { CloudlyViewDomains } from './views/domains/index.js';
|
|
|
|
|
import { CloudlyViewImages } from './views/images/index.js';
|
|
|
|
|
import { CloudlyViewLogs } from './views/logs/index.js';
|
|
|
|
|
import { CloudlyViewMails } from './views/mails/index.js';
|
|
|
|
|
import { CloudlyViewOverview } from './views/overview/index.js';
|
|
|
|
|
import { CloudlyViewS3 } from './views/s3/index.js';
|
|
|
|
|
import { CloudlyViewSecretBundles } from './views/secretbundles/index.js';
|
|
|
|
|
import { CloudlyViewSecretGroups } from './views/secretgroups/index.js';
|
|
|
|
|
import { CloudlyViewServices } from './views/services/index.js';
|
|
|
|
|
import { CloudlyViewExternalRegistries } from './views/externalregistries/index.js';
|
|
|
|
|
import { CloudlyViewSettings } from './views/settings/index.js';
|
|
|
|
|
import { CloudlyViewTasks } from './views/tasks/index.js';
|
2024-04-20 12:21:41 +02:00
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
|
interface HTMLElementTagNameMap {
|
|
|
|
|
'cvault-dashboard': CloudlyDashboard;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@customElement('cloudly-dashboard')
|
|
|
|
|
export class CloudlyDashboard extends DeesElement {
|
2026-05-08 13:56:20 +00:00
|
|
|
@state() private accessor identity: plugins.interfaces.data.IIdentity | null = null;
|
|
|
|
|
@state() private accessor data: appstate.IDataState = {
|
2024-04-20 12:21:41 +02:00
|
|
|
secretGroups: [],
|
|
|
|
|
secretBundles: [],
|
|
|
|
|
clusters: [],
|
|
|
|
|
};
|
|
|
|
|
|
2025-09-10 17:04:18 +00:00
|
|
|
// Keep view tabs stable across renders to preserve active selection
|
|
|
|
|
private readonly viewTabs: plugins.deesCatalog.IView[] = [
|
|
|
|
|
{
|
|
|
|
|
name: 'Overview',
|
|
|
|
|
iconName: 'lucide:LayoutDashboard',
|
|
|
|
|
element: CloudlyViewOverview,
|
|
|
|
|
},
|
|
|
|
|
{
|
2026-05-21 11:18:06 +00:00
|
|
|
name: 'Platform',
|
2025-09-10 17:04:18 +00:00
|
|
|
iconName: 'lucide:Settings',
|
2026-05-21 11:18:06 +00:00
|
|
|
subViews: [
|
|
|
|
|
{ name: 'Settings', iconName: 'lucide:Settings', element: CloudlyViewSettings },
|
|
|
|
|
{ name: 'BaseOS', iconName: 'lucide:HardDriveDownload', element: CloudlyViewBaseOs },
|
|
|
|
|
{ name: 'Fleet', iconName: 'lucide:Truck', element: CloudlyViewBackups },
|
|
|
|
|
],
|
2025-09-10 17:04:18 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-05-21 11:18:06 +00:00
|
|
|
name: 'Runtime',
|
2025-09-10 17:04:18 +00:00
|
|
|
iconName: 'lucide:Network',
|
2026-05-21 11:18:06 +00:00
|
|
|
subViews: [
|
|
|
|
|
{ name: 'Clusters', iconName: 'lucide:Network', element: CloudlyViewClusters },
|
|
|
|
|
{ name: 'Services', iconName: 'lucide:Layers', element: CloudlyViewServices },
|
|
|
|
|
{ name: 'Images', iconName: 'lucide:Image', element: CloudlyViewImages },
|
|
|
|
|
{ name: 'Deployments', iconName: 'lucide:Rocket', element: CloudlyViewDeployments },
|
|
|
|
|
{ name: 'Tasks', iconName: 'lucide:ListChecks', element: CloudlyViewTasks },
|
|
|
|
|
],
|
2025-09-10 17:04:18 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-05-21 11:18:06 +00:00
|
|
|
name: 'Registry & Build',
|
2025-09-10 17:04:18 +00:00
|
|
|
iconName: 'lucide:Package',
|
2026-05-21 11:18:06 +00:00
|
|
|
subViews: [
|
|
|
|
|
{ name: 'ExternalRegistries', iconName: 'lucide:Package', element: CloudlyViewExternalRegistries },
|
|
|
|
|
{ name: 'Testing & Building', iconName: 'lucide:HardHat', element: CloudlyViewServices },
|
|
|
|
|
],
|
2025-09-10 17:04:18 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-05-21 11:18:06 +00:00
|
|
|
name: 'Secrets',
|
|
|
|
|
iconName: 'lucide:ShieldCheck',
|
|
|
|
|
subViews: [
|
|
|
|
|
{ name: 'SecretGroups', iconName: 'lucide:ShieldCheck', element: CloudlyViewSecretGroups },
|
|
|
|
|
{ name: 'SecretBundles', iconName: 'lucide:LockKeyhole', element: CloudlyViewSecretBundles },
|
|
|
|
|
],
|
2025-09-10 17:04:18 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-05-21 11:18:06 +00:00
|
|
|
name: 'Domains & Messaging',
|
2025-09-10 17:04:18 +00:00
|
|
|
iconName: 'lucide:Globe2',
|
2026-05-21 11:18:06 +00:00
|
|
|
subViews: [
|
|
|
|
|
{ name: 'Domains', iconName: 'lucide:Globe2', element: CloudlyViewDomains },
|
|
|
|
|
{ name: 'DNS', iconName: 'lucide:Globe', element: CloudlyViewDns },
|
|
|
|
|
{ name: 'Mails', iconName: 'lucide:Mail', element: CloudlyViewMails },
|
|
|
|
|
],
|
2025-09-10 17:04:18 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-05-21 11:18:06 +00:00
|
|
|
name: 'Storage',
|
|
|
|
|
iconName: 'lucide:Database',
|
|
|
|
|
subViews: [
|
|
|
|
|
{ name: 's3', iconName: 'lucide:Cloud', element: CloudlyViewS3 },
|
|
|
|
|
{ name: 'DBs', iconName: 'lucide:Database', element: CloudlyViewDbs },
|
|
|
|
|
{ name: 'Backups', iconName: 'lucide:Save', element: CloudlyViewBackups },
|
|
|
|
|
],
|
2025-09-10 17:04:18 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Logs',
|
|
|
|
|
iconName: 'lucide:FileText',
|
|
|
|
|
element: CloudlyViewLogs,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2024-04-20 12:21:41 +02:00
|
|
|
constructor() {
|
|
|
|
|
super();
|
2024-06-01 05:48:57 +02:00
|
|
|
document.title = `cloudly v${commitinfo.version}`;
|
2024-04-20 12:21:41 +02:00
|
|
|
const subcription = appstate.dataState
|
|
|
|
|
.select((stateArg) => stateArg)
|
|
|
|
|
.subscribe((dataArg) => {
|
|
|
|
|
this.data = dataArg;
|
|
|
|
|
});
|
|
|
|
|
this.rxSubscriptions.push(subcription);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static styles = [
|
|
|
|
|
cssManager.defaultStyles,
|
|
|
|
|
css`
|
|
|
|
|
.maincontainer {
|
|
|
|
|
position: relative;
|
|
|
|
|
width: 100vw;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
font-family: 'Cal Sans';
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
];
|
|
|
|
|
public render() {
|
|
|
|
|
return html`
|
|
|
|
|
<div class="maincontainer">
|
|
|
|
|
<dees-simple-login name="cloudly v${commitinfo.version}">
|
|
|
|
|
<dees-simple-appdash name="cloudly v${commitinfo.version}"
|
2025-09-10 17:04:18 +00:00
|
|
|
.viewTabs=${this.viewTabs}
|
2024-04-20 12:21:41 +02:00
|
|
|
></dees-simple-appdash>
|
|
|
|
|
</dees-simple-login>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
public async firstUpdated() {
|
2026-05-08 13:56:20 +00:00
|
|
|
const simpleLogin = this.shadowRoot!.querySelector('dees-simple-login') as any;
|
|
|
|
|
simpleLogin.addEventListener('login', (eventArg: Event) => {
|
|
|
|
|
const loginEvent = eventArg as CustomEvent;
|
|
|
|
|
console.log(loginEvent.detail);
|
|
|
|
|
this.login(loginEvent.detail.data.username, loginEvent.detail.data.password);
|
2024-04-20 12:21:41 +02:00
|
|
|
});
|
|
|
|
|
this.addEventListener('contextmenu', (eventArg) => {
|
|
|
|
|
plugins.deesCatalog.DeesContextmenu.openContextMenuWithOptions(eventArg, [
|
|
|
|
|
{
|
|
|
|
|
name: 'About',
|
|
|
|
|
iconName: 'mugHot',
|
|
|
|
|
action: async () => {
|
|
|
|
|
await plugins.deesCatalog.DeesModal.createAndShow({
|
|
|
|
|
heading: 'About',
|
2024-06-01 05:48:57 +02:00
|
|
|
content: html`cloudly ${commitinfo.version}`,
|
2024-04-20 12:21:41 +02:00
|
|
|
menuOptions: [
|
|
|
|
|
{
|
|
|
|
|
name: 'close',
|
2026-05-08 13:56:20 +00:00
|
|
|
iconName: undefined,
|
|
|
|
|
action: async (modalArg: any) => {
|
2024-04-20 12:21:41 +02:00
|
|
|
await modalArg.destroy();
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// lets deal with initial state
|
|
|
|
|
const domtools = await this.domtoolsPromise;
|
|
|
|
|
const loginState = appstate.loginStatePart.getState();
|
|
|
|
|
console.log(loginState);
|
2026-05-08 13:56:20 +00:00
|
|
|
if (loginState?.identity) {
|
2024-08-25 14:29:26 +02:00
|
|
|
this.identity = loginState.identity;
|
2025-09-10 19:06:16 +00:00
|
|
|
try {
|
|
|
|
|
appstate.apiClient.identity = loginState.identity;
|
|
|
|
|
if (!appstate.apiClient['typedsocketClient']) {
|
|
|
|
|
await appstate.apiClient.start();
|
|
|
|
|
}
|
2026-05-08 13:56:20 +00:00
|
|
|
try { await appstate.apiClient.typedsocketClient.setTag('identity', appstate.apiClient.identity); } catch {}
|
2025-09-10 19:06:16 +00:00
|
|
|
} catch (e) { console.warn('Failed to initialize API client WS', e); }
|
2024-04-20 12:21:41 +02:00
|
|
|
await simpleLogin.switchToSlottedContent();
|
2024-06-01 05:48:57 +02:00
|
|
|
await appstate.dataState.dispatchAction(appstate.getAllDataAction, null);
|
2024-04-20 12:21:41 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async login(username: string, password: string) {
|
|
|
|
|
const domtools = await this.domtoolsPromise;
|
|
|
|
|
console.log(`attempting to login...`);
|
2026-05-08 13:56:20 +00:00
|
|
|
const simpleLogin = this.shadowRoot!.querySelector('dees-simple-login') as any;
|
|
|
|
|
const form = simpleLogin.shadowRoot.querySelector('dees-form') as any;
|
2024-04-20 12:21:41 +02:00
|
|
|
form.setStatus('pending', 'Logging in...');
|
|
|
|
|
const state = await appstate.loginStatePart.dispatchAction(appstate.loginAction, {
|
|
|
|
|
username,
|
|
|
|
|
password,
|
|
|
|
|
});
|
2026-05-08 13:56:20 +00:00
|
|
|
if (state?.identity) {
|
2024-04-20 12:21:41 +02:00
|
|
|
console.log('got jwt');
|
2024-08-25 14:29:26 +02:00
|
|
|
this.identity = state.identity;
|
2024-04-20 12:21:41 +02:00
|
|
|
form.setStatus('success', 'Logged in!');
|
|
|
|
|
await simpleLogin.switchToSlottedContent();
|
2024-06-01 05:48:57 +02:00
|
|
|
await appstate.dataState.dispatchAction(appstate.getAllDataAction, null);
|
2024-04-20 12:21:41 +02:00
|
|
|
} else {
|
|
|
|
|
form.setStatus('error', 'Login failed!');
|
|
|
|
|
await domtools.convenience.smartdelay.delayFor(2000);
|
|
|
|
|
form.reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async logout() {}
|
|
|
|
|
}
|