feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
import * as plugins from '../plugins.js';
|
|
|
|
import * as appstate from '../appstate.js';
|
|
|
|
|
2025-06-01 19:46:10 +00:00
|
|
|
import {
|
|
|
|
DeesElement,
|
|
|
|
css,
|
|
|
|
cssManager,
|
|
|
|
customElement,
|
|
|
|
html,
|
|
|
|
state,
|
|
|
|
type TemplateResult
|
|
|
|
} from '@design.estate/dees-element';
|
|
|
|
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
// Import view components
|
|
|
|
import { OpsViewOverview } from './ops-view-overview.js';
|
|
|
|
import { OpsViewStats } from './ops-view-stats.js';
|
|
|
|
import { OpsViewLogs } from './ops-view-logs.js';
|
|
|
|
import { OpsViewConfig } from './ops-view-config.js';
|
|
|
|
import { OpsViewSecurity } from './ops-view-security.js';
|
|
|
|
|
2025-06-01 19:46:10 +00:00
|
|
|
@customElement('ops-dashboard')
|
|
|
|
export class OpsDashboard extends DeesElement {
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
@state() private loginState: appstate.ILoginState = {
|
|
|
|
identity: null,
|
|
|
|
isLoggedIn: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
@state() private uiState: appstate.IUiState = {
|
|
|
|
activeView: 'dashboard',
|
|
|
|
sidebarCollapsed: false,
|
|
|
|
autoRefresh: true,
|
|
|
|
refreshInterval: 30000,
|
|
|
|
theme: 'light',
|
|
|
|
};
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
document.title = 'DCRouter OpsServer';
|
|
|
|
|
|
|
|
// Subscribe to login state
|
|
|
|
const loginSubscription = appstate.loginStatePart
|
|
|
|
.select((stateArg) => stateArg)
|
|
|
|
.subscribe((loginState) => {
|
|
|
|
this.loginState = loginState;
|
|
|
|
// Trigger data fetch when logged in
|
|
|
|
if (loginState.isLoggedIn) {
|
|
|
|
appstate.statsStatePart.dispatchAction(appstate.fetchAllStatsAction, null);
|
|
|
|
appstate.configStatePart.dispatchAction(appstate.fetchConfigurationAction, null);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.rxSubscriptions.push(loginSubscription);
|
|
|
|
|
|
|
|
// Subscribe to UI state
|
|
|
|
const uiSubscription = appstate.uiStatePart
|
|
|
|
.select((stateArg) => stateArg)
|
|
|
|
.subscribe((uiState) => {
|
|
|
|
this.uiState = uiState;
|
|
|
|
});
|
|
|
|
this.rxSubscriptions.push(uiSubscription);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static styles = [
|
|
|
|
cssManager.defaultStyles,
|
|
|
|
css`
|
|
|
|
.maincontainer {
|
|
|
|
position: relative;
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
];
|
|
|
|
|
2025-06-01 19:46:10 +00:00
|
|
|
public render(): TemplateResult {
|
|
|
|
return html`
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
<div class="maincontainer">
|
|
|
|
<dees-simple-login
|
|
|
|
name="DCRouter OpsServer"
|
|
|
|
>
|
|
|
|
<dees-simple-appdash
|
|
|
|
name="DCRouter OpsServer"
|
|
|
|
.viewTabs=${[
|
|
|
|
{
|
|
|
|
name: 'Overview',
|
|
|
|
element: OpsViewOverview,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Statistics',
|
|
|
|
element: OpsViewStats,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Logs',
|
|
|
|
element: OpsViewLogs,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Configuration',
|
|
|
|
element: OpsViewConfig,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Security',
|
|
|
|
element: OpsViewSecurity,
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
.userMenuItems=${[
|
|
|
|
{
|
|
|
|
name: 'Logout',
|
|
|
|
action: async () => {
|
|
|
|
await appstate.loginStatePart.dispatchAction(appstate.logoutAction, null);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
</dees-simple-appdash>
|
|
|
|
</dees-simple-login>
|
|
|
|
</div>
|
2025-06-01 19:46:10 +00:00
|
|
|
`;
|
|
|
|
}
|
2025-06-08 12:51:48 +00:00
|
|
|
|
|
|
|
public async firstUpdated() {
|
|
|
|
const simpleLogin = this.shadowRoot.querySelector('dees-simple-login');
|
|
|
|
simpleLogin.addEventListener('login', (e: CustomEvent) => {
|
|
|
|
console.log(e.detail);
|
|
|
|
this.login(e.detail.data.username, e.detail.data.password);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Handle initial state
|
|
|
|
const loginState = appstate.loginStatePart.getState();
|
|
|
|
console.log('Initial login state:', loginState);
|
|
|
|
if (loginState.identity) {
|
|
|
|
this.loginState = loginState;
|
|
|
|
await simpleLogin.switchToSlottedContent();
|
|
|
|
await appstate.statsStatePart.dispatchAction(appstate.fetchAllStatsAction, null);
|
|
|
|
await appstate.configStatePart.dispatchAction(appstate.fetchConfigurationAction, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private async login(username: string, password: string) {
|
|
|
|
const domtools = await this.domtoolsPromise;
|
|
|
|
console.log(`Attempting to login...`);
|
|
|
|
const simpleLogin = this.shadowRoot.querySelector('dees-simple-login');
|
|
|
|
const form = simpleLogin.shadowRoot.querySelector('dees-form');
|
|
|
|
form.setStatus('pending', 'Logging in...');
|
|
|
|
|
|
|
|
const state = await appstate.loginStatePart.dispatchAction(appstate.loginAction, {
|
|
|
|
username,
|
|
|
|
password,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (state.identity) {
|
|
|
|
console.log('Login successful');
|
|
|
|
this.loginState = state;
|
|
|
|
form.setStatus('success', 'Logged in!');
|
|
|
|
await simpleLogin.switchToSlottedContent();
|
|
|
|
await appstate.statsStatePart.dispatchAction(appstate.fetchAllStatsAction, null);
|
|
|
|
await appstate.configStatePart.dispatchAction(appstate.fetchConfigurationAction, null);
|
|
|
|
} else {
|
|
|
|
form.setStatus('error', 'Login failed!');
|
|
|
|
await domtools.convenience.smartdelay.delayFor(2000);
|
|
|
|
form.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private async logout() {
|
|
|
|
await appstate.loginStatePart.dispatchAction(appstate.logoutAction, null);
|
|
|
|
}
|
2025-06-01 19:46:10 +00:00
|
|
|
}
|