-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0db8c4
commit 895bc1e
Showing
8 changed files
with
308 additions
and
56 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
server_manager/www/views/server_view/access_key_data_table/access_key_controls/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright 2025 The Outline Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import {LitElement} from 'lit'; | ||
import {customElement} from 'lit/decorators.js'; | ||
|
||
@customElement('access-key-controls') | ||
export class AccessKeyControls extends LitElement {} |
77 changes: 77 additions & 0 deletions
77
server_manager/www/views/server_view/access_key_data_table/access_key_status/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* Copyright 2025 The Outline Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import {LitElement, html, css, nothing} from 'lit'; | ||
import {customElement, property} from 'lit/decorators.js'; | ||
|
||
@customElement('access-key-status') | ||
export class AccessKeyStatus extends LitElement { | ||
@property({type: String}) name: string; | ||
@property({type: Boolean}) connected: boolean; | ||
|
||
static styles = css` | ||
:host { | ||
--access-key-status-gap: 0.5rem; | ||
--access-key-status-icon-size: 2rem; | ||
--access-key-status-text-color: hsl(0, 0%, 79%); | ||
--access-key-status-font-family: 'Inter', system-ui; | ||
--access-key-status-indicator-size: 0.5rem; | ||
font-family: var(--access-key-status-font-family); | ||
color: var(--access-key-status-text-color); | ||
} | ||
.key { | ||
align-items: center; | ||
display: inline-flex; | ||
gap: var(--access-key-status-gap); | ||
} | ||
.key-icon { | ||
align-items: center; | ||
background: gray; | ||
border-radius: 50%; | ||
display: inline-flex; | ||
height: var(--access-key-status-icon-size); | ||
justify-content: center; | ||
position: relative; | ||
width: var(--access-key-status-icon-size); | ||
} | ||
.key-icon-indicator { | ||
background: green; | ||
border-radius: 50%; | ||
bottom: 0; | ||
display: inline-block; | ||
height: var(--access-key-status-indicator-size); | ||
position: absolute; | ||
right: 0; | ||
width: var(--access-key-status-indicator-size); | ||
} | ||
`; | ||
|
||
render() { | ||
return html`<div class="key"> | ||
<div class="key-icon"> | ||
<mwc-icon>vpn_key</mwc-icon> | ||
${this.connected | ||
? html`<div class="key-icon-indicator"></div>` | ||
: nothing} | ||
</div> | ||
${this.name} | ||
</div>`; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
server_manager/www/views/server_view/access_key_data_table/access_key_status/stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright 2025 The Outline Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import './index'; | ||
|
||
export default { | ||
title: 'Manager/Server View/Access Key Data Table/Access Key Status', | ||
component: 'access-key-status', | ||
argTypes: { | ||
name: {control: 'text'}, | ||
connected: {control: 'boolean'}, | ||
}, | ||
}; | ||
|
||
export const Example = { | ||
args: { | ||
name: 'Key#1', | ||
connected: true, | ||
}, | ||
}; |
93 changes: 93 additions & 0 deletions
93
server_manager/www/views/server_view/access_key_data_table/access_key_usage_meter/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* Copyright 2025 The Outline Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import {LitElement, html, css, nothing} from 'lit'; | ||
import {customElement, property} from 'lit/decorators.js'; | ||
|
||
import {formatBytes} from '../../../../data_formatting'; | ||
|
||
@customElement('access-key-usage-meter') | ||
export class AccessKeyUsageMeter extends LitElement { | ||
@property({type: String}) language: string; | ||
@property({type: Number}) dataUsageBytes: number; | ||
@property({type: Number}) dataLimitBytes: number; | ||
@property({type: Number}) dataLimitWarningThreshold: number = 80; | ||
@property({type: Object}) localize: (messageId: string) => string; | ||
|
||
static styles = css` | ||
:host { | ||
--access-key-usage-meter-font-family: 'Inter', system-ui; | ||
--access-key-usage-meter-gap: 0.5rem; | ||
--access-key-usage-meter-size: 1rem; | ||
--access-key-usage-meter-color: hsla(167, 57%, 61%, 0.88); | ||
--access-key-usage-meter-text-color: hsl(0, 0%, 79%); | ||
--access-key-usage-meter-warning-color: white; | ||
--access-key-usage-meter-warning-text-color: hsla(39, 77%, 53%, 1); | ||
} | ||
label { | ||
color: var(--access-key-usage-meter-text-color); | ||
font-family: var(--access-key-usage-meter-font-family); | ||
} | ||
.warning > label { | ||
color: var(--access-key-usage-meter-warning-text-color); | ||
} | ||
progress { | ||
display: block; | ||
appearance: none; | ||
height: var(--access-key-usage-meter-size); | ||
margin-bottom: var(--access-key-usage-meter-gap); | ||
width: 100%; | ||
} | ||
progress[value]::-webkit-progress-bar { | ||
background: var(--access-key-usage-meter-text-color); | ||
} | ||
progress[value]::-webkit-progress-value { | ||
background: var(--access-key-usage-meter-color); | ||
} | ||
.warning > progress[value]::-webkit-progress-value { | ||
background: var(--access-key-usage-meter-warning-color); | ||
} | ||
`; | ||
|
||
render() { | ||
const isApproachingDataLimit = | ||
(this.dataUsageBytes / this.dataLimitBytes) * 100 >= | ||
this.dataLimitWarningThreshold; | ||
|
||
return html`<div class=${isApproachingDataLimit ? 'warning' : ''}> | ||
<progress | ||
id="progress" | ||
max=${this.dataLimitBytes} | ||
value=${this.dataUsageBytes} | ||
></progress> | ||
<label for="progress"> | ||
${formatBytes(this.dataUsageBytes, this.language)} / | ||
${formatBytes(this.dataLimitBytes, this.language)} | ||
${isApproachingDataLimit | ||
? this.localize('server-view-access-keys-usage-limit') | ||
: nothing} | ||
</label> | ||
</div>`; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
server_manager/www/views/server_view/access_key_data_table/access_key_usage_meter/stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright 2025 The Outline Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import './index'; | ||
|
||
export default { | ||
title: 'Manager/Server View/Access Key Data Table/Access Key Usage Meter', | ||
component: 'access-key-usage-meter', | ||
argTypes: { | ||
dataUsageBytes: {control: 'number'}, | ||
dataLimitBytes: {control: 'number'}, | ||
}, | ||
}; | ||
|
||
export const Example = { | ||
args: { | ||
dataUsageBytes: 1000000, | ||
dataLimitBytes: 10000000, | ||
language: 'en', | ||
localize: () => '(80%+ used)', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.