2025-01-09 13:46:31 +01:00
|
|
|
import {
|
|
|
|
DeesElement,
|
|
|
|
property,
|
|
|
|
html,
|
|
|
|
customElement,
|
|
|
|
type TemplateResult,
|
|
|
|
cssManager,
|
|
|
|
css,
|
|
|
|
} from '@design.estate/dees-element';
|
2023-10-06 17:42:41 +02:00
|
|
|
|
2024-06-26 21:12:11 +02:00
|
|
|
import { DeesWindowLayer } from '@design.estate/dees-catalog';
|
2020-09-19 15:51:50 +00:00
|
|
|
|
2021-03-09 20:47:00 +00:00
|
|
|
declare global {
|
|
|
|
interface HTMLElementTagNameMap {
|
|
|
|
'uptimelink-webwidget': UptimelinkWebwidget;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-19 15:51:50 +00:00
|
|
|
@customElement('uptimelink-webwidget')
|
2020-11-29 02:11:28 +00:00
|
|
|
export class UptimelinkWebwidget extends DeesElement {
|
2020-09-19 15:51:50 +00:00
|
|
|
public static demo = () => html`
|
|
|
|
<uptimelink-webwidget projectSlug="uptime.link"></uptimelink-webwidget>
|
|
|
|
`;
|
|
|
|
|
2023-10-06 17:42:41 +02:00
|
|
|
@property({
|
2025-01-09 03:22:30 +01:00
|
|
|
type: Boolean,
|
2025-01-09 13:46:31 +01:00
|
|
|
reflect: true,
|
2023-10-06 17:42:41 +02:00
|
|
|
})
|
|
|
|
isOnTop = false;
|
|
|
|
|
2020-09-19 15:51:50 +00:00
|
|
|
@property()
|
|
|
|
public projectSlug: string;
|
|
|
|
|
2021-03-08 23:11:56 +00:00
|
|
|
@property()
|
|
|
|
public isFocused = false;
|
|
|
|
|
2021-03-09 13:41:16 +00:00
|
|
|
@property()
|
|
|
|
public isElevated = false;
|
|
|
|
|
2025-01-09 03:22:30 +01:00
|
|
|
@property({
|
|
|
|
type: Boolean,
|
2025-01-09 13:46:31 +01:00
|
|
|
reflect: true,
|
2025-01-09 03:22:30 +01:00
|
|
|
})
|
2021-03-08 23:11:56 +00:00
|
|
|
public showExpanded: boolean = false;
|
|
|
|
|
2025-01-09 03:22:30 +01:00
|
|
|
public parentWebwidget: UptimelinkWebwidget;
|
|
|
|
|
2020-09-19 15:51:50 +00:00
|
|
|
constructor() {
|
|
|
|
super();
|
2021-03-08 23:11:56 +00:00
|
|
|
this.setupEventing();
|
2020-09-19 15:51:50 +00:00
|
|
|
}
|
|
|
|
|
2023-10-06 17:42:41 +02:00
|
|
|
public static styles = [
|
|
|
|
cssManager.defaultStyles,
|
2025-01-09 13:46:31 +01:00
|
|
|
css`
|
|
|
|
:host {
|
|
|
|
position: relative;
|
|
|
|
display: block;
|
|
|
|
height: 30px;
|
|
|
|
}
|
|
|
|
.mainbox {
|
|
|
|
position: relative;
|
|
|
|
line-height: 1em;
|
|
|
|
margin: auto;
|
|
|
|
font-family: Roboto;
|
|
|
|
font-weight: 540;
|
|
|
|
font-size: 12px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
width: 150px;
|
|
|
|
border-radius: 15px;
|
|
|
|
height: 30px;
|
|
|
|
background: ${cssManager.bdTheme('#ffffff', '#000000')};
|
|
|
|
box-shadow: ${cssManager.bdTheme('0px 0px 5px rgba(0,0,0,0.1)', '')};
|
|
|
|
border: 1px solid ${cssManager.bdTheme('#ffffff', '#333333')};
|
|
|
|
padding: 4px;
|
|
|
|
color: ${cssManager.bdTheme('#333', '#CCC')};
|
|
|
|
cursor: pointer;
|
|
|
|
transition: all 0.2s, background 0.1s;
|
|
|
|
overflow: hidden;
|
|
|
|
will-change: transform;
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
.mainbox.hidden {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
2023-10-06 17:42:41 +02:00
|
|
|
|
2025-01-09 13:46:31 +01:00
|
|
|
.firstLine {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 26px auto;
|
|
|
|
}
|
2021-03-08 23:11:56 +00:00
|
|
|
|
2025-01-09 13:46:31 +01:00
|
|
|
.mainbox.focused {
|
|
|
|
width: 182px;
|
|
|
|
height: 117px;
|
|
|
|
transform: translateX(-16px);
|
|
|
|
background: ${cssManager.bdTheme('#ffffff', '#222222')} !important;
|
|
|
|
box-shadow: ${cssManager.bdTheme('0px 0px 5px rgba(0,0,0,0.1)', '')} !important;
|
|
|
|
}
|
2021-03-08 23:11:56 +00:00
|
|
|
|
2025-01-09 13:46:31 +01:00
|
|
|
.statusindicator {
|
|
|
|
transform: translate(4px, 4px);
|
|
|
|
height: 12px;
|
|
|
|
width: 12px;
|
|
|
|
background: #66bb6a;
|
|
|
|
border-radius: 10px;
|
|
|
|
}
|
|
|
|
.statustext {
|
|
|
|
line-height: 20px;
|
|
|
|
}
|
2021-03-08 23:11:56 +00:00
|
|
|
|
2025-01-09 13:46:31 +01:00
|
|
|
.expanded {
|
|
|
|
opacity: 0;
|
|
|
|
transition: opacity 0.1s;
|
|
|
|
}
|
2021-03-08 23:11:56 +00:00
|
|
|
|
2025-01-09 13:46:31 +01:00
|
|
|
.miniHeading {
|
|
|
|
position: absolute;
|
|
|
|
width: 190px;
|
|
|
|
top: 25px;
|
|
|
|
left: 5px;
|
|
|
|
margin-top: 10px;
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
2021-03-08 23:11:56 +00:00
|
|
|
|
2025-01-09 13:46:31 +01:00
|
|
|
.miniOverview24h {
|
|
|
|
position: absolute;
|
|
|
|
top: 55px;
|
|
|
|
left: 5px;
|
|
|
|
background: ${cssManager.bdTheme('rgba(0,0,0,0.07)', 'rgba(255,255,255,0.07)')};
|
|
|
|
border-radius: 3px;
|
|
|
|
width: 172px;
|
|
|
|
height: 30px;
|
|
|
|
display: grid;
|
|
|
|
padding: 3px 3px;
|
|
|
|
grid-template-columns: repeat(30, 4px);
|
|
|
|
grid-column-gap: 3px;
|
|
|
|
}
|
2021-03-08 23:11:56 +00:00
|
|
|
|
2025-01-09 13:46:31 +01:00
|
|
|
.miniOverview24h .statusBar {
|
|
|
|
background: ${cssManager.bdTheme('rgba(0,0,0,0.15)', 'rgba(255,255,255,0.15)')};
|
|
|
|
border-radius: 10px;
|
|
|
|
}
|
2021-03-08 23:11:56 +00:00
|
|
|
|
2025-01-09 13:46:31 +01:00
|
|
|
.miniOverview24h .statusBar.ok {
|
|
|
|
background: #66bb6a;
|
|
|
|
}
|
2021-03-08 23:11:56 +00:00
|
|
|
|
2025-01-09 13:46:31 +01:00
|
|
|
.viewStatuspage {
|
|
|
|
position: absolute;
|
|
|
|
width: 172px;
|
|
|
|
top: 80px;
|
|
|
|
left: 5px;
|
|
|
|
text-align: center;
|
|
|
|
background: ${cssManager.bdTheme('rgba(0,0,0,0.07)', 'rgba(255,255,255,0.07)')};
|
|
|
|
border-radius: 3px 3px 10px 10px;
|
|
|
|
padding: 5px;
|
|
|
|
margin-top: 10px;
|
|
|
|
transition: background 0.1s;
|
|
|
|
}
|
2021-03-08 23:11:56 +00:00
|
|
|
|
2025-01-09 13:46:31 +01:00
|
|
|
.viewStatuspage:hover {
|
|
|
|
background: ${cssManager.bdTheme('rgba(0,0,0,0.1)', 'rgba(255,255,255,0.1)')};
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
];
|
2021-03-09 13:54:01 +00:00
|
|
|
|
2025-01-09 13:46:31 +01:00
|
|
|
public render(): TemplateResult {
|
|
|
|
return html`
|
|
|
|
<style>
|
|
|
|
:host {
|
|
|
|
z-index: ${this.isElevated || this.isOnTop ? '1000' : 'auto'};
|
|
|
|
}
|
2020-09-19 15:51:50 +00:00
|
|
|
</style>
|
2021-03-08 23:11:56 +00:00
|
|
|
<div class="mainbox ${this.isFocused ? 'focused' : null}">
|
|
|
|
<div class="firstLine">
|
|
|
|
<div class="statusindicator"></div>
|
|
|
|
<div class="statustext">All systems are up!</div>
|
|
|
|
</div>
|
2025-01-09 13:46:31 +01:00
|
|
|
${this.showExpanded
|
|
|
|
? html`
|
|
|
|
<div class="expanded">
|
|
|
|
<div class="miniHeading">last 24 hours:</div>
|
|
|
|
<div class="miniOverview24h">
|
|
|
|
${(() => {
|
|
|
|
let counter = 0;
|
|
|
|
const returnArray = [];
|
|
|
|
while (counter < 24) {
|
|
|
|
returnArray.push(html`<div class="statusBar ok"></div>`);
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
return returnArray;
|
|
|
|
})()}
|
|
|
|
</div>
|
|
|
|
<div class="viewStatuspage">View full Statuspage ...</div>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
: null}
|
2020-09-19 15:51:50 +00:00
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
}
|
2021-03-08 23:11:56 +00:00
|
|
|
|
2024-06-26 21:12:11 +02:00
|
|
|
public windowLayer: DeesWindowLayer;
|
2021-03-08 23:11:56 +00:00
|
|
|
private async setupEventing() {
|
2023-10-06 17:42:41 +02:00
|
|
|
const domtools = await this.domtoolsPromise;
|
2021-03-08 23:11:56 +00:00
|
|
|
await this.updateComplete;
|
|
|
|
const mainbox: HTMLDivElement = this.shadowRoot.querySelector('.mainbox');
|
|
|
|
mainbox.onmouseenter = async () => {
|
2023-10-06 17:42:41 +02:00
|
|
|
if (!this.isOnTop) {
|
|
|
|
const mainbox = this.shadowRoot.querySelector('.mainbox') as HTMLElement;
|
|
|
|
const rect = mainbox.getBoundingClientRect();
|
|
|
|
const uptimelinkWidget = new UptimelinkWebwidget();
|
2025-01-09 03:22:30 +01:00
|
|
|
uptimelinkWidget.parentWebwidget = this;
|
2023-10-06 17:42:41 +02:00
|
|
|
uptimelinkWidget.isOnTop = true;
|
|
|
|
uptimelinkWidget.style.position = 'fixed';
|
|
|
|
uptimelinkWidget.style.top = `${rect.top}px`;
|
|
|
|
uptimelinkWidget.style.left = `${rect.left}px`;
|
|
|
|
document.body.append(uptimelinkWidget);
|
2025-01-09 03:22:30 +01:00
|
|
|
mainbox.classList.add('hidden');
|
2023-10-06 17:42:41 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-03-09 13:41:16 +00:00
|
|
|
this.isElevated = true;
|
2021-03-08 23:11:56 +00:00
|
|
|
this.isFocused = true;
|
2024-06-26 21:12:11 +02:00
|
|
|
this.windowLayer = await DeesWindowLayer.createAndShow({
|
2024-06-28 14:38:08 +02:00
|
|
|
blur: false,
|
2023-10-06 17:42:41 +02:00
|
|
|
});
|
|
|
|
await domtools.convenience.smartdelay.delayFor(200);
|
2021-03-08 23:11:56 +00:00
|
|
|
if (!this.isFocused) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.showExpanded = true;
|
|
|
|
await this.performUpdate();
|
2024-06-27 01:52:35 +02:00
|
|
|
await domtools.convenience.smartdelay.delayFor(0);
|
2021-03-08 23:11:56 +00:00
|
|
|
const expandedDiv = this.shadowRoot.querySelector('.expanded') as HTMLElement;
|
|
|
|
expandedDiv.style.opacity = '1';
|
|
|
|
};
|
|
|
|
mainbox.onmouseleave = async () => {
|
2023-10-06 17:42:41 +02:00
|
|
|
if (!this.isOnTop) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.windowLayer.destroy();
|
2025-01-09 13:46:31 +01:00
|
|
|
this.parentWebwidget.shadowRoot.querySelector('.mainbox').classList.remove('hidden');
|
|
|
|
domtools.convenience.smartdelay.delayFor(200).then(async () => {
|
2021-03-09 13:41:16 +00:00
|
|
|
if (!this.isFocused) {
|
|
|
|
this.isElevated = false;
|
2023-10-06 17:42:41 +02:00
|
|
|
this.remove();
|
2021-03-09 13:41:16 +00:00
|
|
|
}
|
|
|
|
});
|
2021-03-08 23:11:56 +00:00
|
|
|
if (!this.showExpanded) {
|
|
|
|
this.isFocused = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.showExpanded = false;
|
2023-10-06 17:42:41 +02:00
|
|
|
await domtools.convenience.smartdelay.delayFor(50);
|
2021-03-08 23:11:56 +00:00
|
|
|
this.isFocused = false;
|
2025-01-09 13:46:31 +01:00
|
|
|
};
|
2021-03-08 23:11:56 +00:00
|
|
|
}
|
2020-09-19 15:51:50 +00:00
|
|
|
}
|