Skip to content

Commit

Permalink
fix dhcp scope usage calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
BeryJu committed Nov 22, 2024
1 parent 460a434 commit b713808
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 12 deletions.
5 changes: 0 additions & 5 deletions web/src/elements/CodeMirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ export class CodeMirrorTextarea extends AKElement {
case "yaml":
textValue = YAML.stringify(v);
break;
case "javascript":
textValue = JSON.stringify(v);
break;
default:
textValue = v.toString();
break;
Expand All @@ -71,8 +68,6 @@ export class CodeMirrorTextarea extends AKElement {
switch (this.mode.toLowerCase()) {
case "yaml":
return YAML.parse(this.getInnerValue());
case "javascript":
return JSON.parse(this.getInnerValue());
default:
return this.getInnerValue();
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/dhcp/DHCPScopesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class DHCPScopesPage extends TablePage<DhcpAPIScope> {
}

row(item: DhcpAPIScope): TemplateResult[] {
const usage = Math.round(item.statistics.used / (100 / item.statistics.usable));
const usage = Math.round((item.statistics.used * 100) / item.statistics.usable);
return [
html`<a href=${`#/dhcp/scopes/${item.scope}`}>${item.scope}</a>`,
html`<pre>${item.subnetCidr}</pre>`,
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/overview/charts/DHCPUsageChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class DHCPUsageChart extends AKChart<DhcpAPIScopesGetOutput> {
return {
labels: (data.scopes || []).map((scope) => scope.scope),
datasets: (data.scopes || []).map((d) => {
const usage = Math.round(d.statistics.used / (100 / d.statistics.usable));
const usage = Math.round((d.statistics.used * 100) / d.statistics.usable);
return {
backgroundColor: [getColorFromString(d.scope).toString(), "rgba(0,0,0,0)"],
borderColor: "rgba(0,0,0,0)",
Expand Down
5 changes: 0 additions & 5 deletions web/src/pages/tftp/TFTPFileForm.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { RolesTftpApi, TftpAPIFilesPutInput } from "gravity-api";



import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators.js";



import { DEFAULT_CONFIG } from "../../api/Config";
import "../../elements/forms/HorizontalFormElement";
import { ModelForm } from "../../elements/forms/ModelForm";


@customElement("gravity-tftp-file-form")
export class TFTPFileForm extends ModelForm<TftpAPIFilesPutInput, string> {
loadInstance(): Promise<TftpAPIFilesPutInput> {
Expand Down

0 comments on commit b713808

Please sign in to comment.