Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Add FileStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldieeins committed Aug 7, 2024
1 parent 5ebad9f commit 6759a69
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Download(UUID uuid, String name, URL downloadUrl, Path path) {
public boolean start() {
if(state == DownloadManager.DownloadState.WAITING) {
state = DownloadManager.DownloadState.RUNNING;
startTime = Instant.now(); // Record the start time
startTime = Instant.now();
Instant lastTimeCheck = startTime;

try (BufferedInputStream in = new BufferedInputStream(url.openStream());
Expand Down Expand Up @@ -185,7 +185,6 @@ private void setPercent(double percent) {
this.percent = percent;
if(percent>100) {
setFinished(true);
percent = 100;
} else if(percent<0) {
percent = 0;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.zyneonstudios.application.utils;

import live.nerotv.shademebaby.file.Config;

public class FileStorage implements Storage {

private final Config config;

public FileStorage(String path) {
this.config = new Config(path);
}

@Override
public Object get(String path) {
return config.get(path);
}

@Override
public boolean getBool(String path) {
return config.getBool(path);
}

@Override
public Boolean getBoolean(String path) {
return config.getBoolean(path);
}

@Override
public double getDoub(String path) {
return config.getDoub(path);
}

@Override
public Double getDouble(String path) {
return config.getDouble(path);
}

@Override
public int getInt(String path) {
return config.getInt(path);
}

@Override
public Integer getInteger(String path) {
return config.getInteger(path);
}

@Override
public String getString(String path) {
return config.getString(path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
height: calc(100% - 2rem);
max-height: calc(100% - 2rem);
overflow: hidden;

.group.template {
display: none;
}
}

/*Initializing default card width*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,42 @@ function initSettings() {
} else {
setContent(id,hid);
}
}

function addSettingsGroup(title,page,id) {
if(title&&page) {
const template = document.getElementById(page+"-group-template");
const group = template.cloneNode(true);
if(id) {
group.id = id;
} else {
group.id = (page+"-"+title).replaceAll(" ", "-").replace(/[^a-z0-9-_]/gi, '').toLowerCase();
}
group.querySelector("h4").innerText = title;
group.classList.remove("template");
template.parentNode.insertBefore(group,template);
}
}

function addSelectToGroup(title,group,id,options,onchangeRequest) {
if(title&&group) {
const g = document.getElementById(group);
let i = (group+"-"+title).replaceAll(" ", "-").replace(/[^a-z0-9-_]/gi, '').toLowerCase();
if(id) {
i = id;
}
g.innerHTML += "<h3>"+title+" <span class='select'><label><select id='"+i+"'></select></label></span></h3>";
if(options) {
document.getElementById(i).innerHTML = options;
}
if(onchangeRequest) {
document.getElementById(i).onchange = function () {
connector(onchangeRequest+"."+document.getElementById(i).value);
}
} else {
document.getElementById(i).onchange = function () {
connector(i+"."+document.getElementById(i).value);
}
}
}
}
20 changes: 16 additions & 4 deletions application-ui/content/de/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script src="../assets/cronos/javascript/app-menu.js"></script>
<script src="../assets/application/javascript/app-shared.js"></script>
<script src="../assets/application/javascript/app-settings.js"></script>
<script>init();</script>
<script>init(); connector("sync.settings.init");</script>
</head>
<body>
<div class="flex full">
Expand Down Expand Up @@ -220,20 +220,32 @@ <h3 id="linux-settings-custom-frame">
</span>
</h3>
</div>
<div class="group template" id="general-group-template">
<h4>Gruppentitel Vorlage</h4>
</div>
</div>
<div id="settings-global">

<div class="group template" id="global-group-template">
<h4>Gruppentitel Vorlage</h4>
</div>
</div>
<div id="settings-indexes">

<div class="group template" id="indexes-group-template">
<h4>Gruppentitel Vorlage</h4>
</div>
</div>
<div id="settings-modules">

<div class="group template" id="modules-group-template">
<h4>Gruppentitel Vorlage</h4>
</div>
</div>
<div id="settings-about">
<div class="card">
<span id="settings-global-application-version">${application.version}</span>
</div>
<div class="group template" id="about-group-template">
<h4>Gruppentitel Vorlage</h4>
</div>
</div>
<!--TODO: Add other setting pages-->
<div id="settings-custom">
Expand Down
18 changes: 17 additions & 1 deletion application-ui/content/en/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script src="../assets/cronos/javascript/app-menu.js"></script>
<script src="../assets/application/javascript/app-shared.js"></script>
<script src="../assets/application/javascript/app-settings.js"></script>
<script>init();</script>
<script>init(); connector("sync.settings.init");</script>
</head>
<body>
<div class="flex full">
Expand Down Expand Up @@ -220,20 +220,36 @@ <h3 id="linux-settings-custom-frame">
</span>
</h3>
</div>
<div class="group template" id="general-group-template">
<h4>group template title</h4>
</div>
</div>
<div id="settings-global">

<div class="group template" id="global-group-template">
<h4>group template title</h4>
</div>
</div>
<div id="settings-indexes">

<div class="group template" id="indexes-group-template">
<h4>group template title</h4>
</div>
</div>
<div id="settings-modules">

<div class="group template" id="modules-group-template">
<h4>group template title</h4>
</div>
</div>
<div id="settings-about">
<div class="card">
<span id="settings-global-application-version">${application.version}</span>
</div>

<div class="group template" id="about-group-template">
<h4>group template title</h4>
</div>
</div>
<!--TODO: Add other setting pages-->
<div id="settings-custom">
Expand Down

0 comments on commit 6759a69

Please sign in to comment.