Commit 13f4d7c8 authored by jonasled's avatar jonasled

Merge branch 'develop'

parents 880a6d56 6b07e7df
......@@ -53,6 +53,7 @@ public class ClusterActivity extends AppCompatActivity {
ArrayList<String> nodes = new ArrayList<>();
ArrayList<String> label = new ArrayList<>();
ArrayList<Integer> icon = new ArrayList<>();
ArrayList<Integer> storageUsage = new ArrayList<>();
de.jonasled.proxdroid.ClusterListAdapter adapter;
ListView listView;
List sortedKeys;
......@@ -322,6 +323,7 @@ public class ClusterActivity extends AppCompatActivity {
temp.add(resource.getString("node"));//add the node name
temp.add("storage");//add the type
temp.add(resource.getString("status"));//add the curent status (online, offline)
temp.add("" + Math.round(resource.getDouble("disk") / resource.getDouble("maxdisk") * 100));
vmctList.put(resource.getString("id"), temp);//add this array to the vm dict withe the id and the node as key
}
}
......@@ -503,18 +505,21 @@ public class ClusterActivity extends AppCompatActivity {
label.add(vmctList.get(key.toString()).get(0) + " (" + key + ")");//add the label for the VM to the label array
if (vmctList.get(key.toString()).get(3) == "lxc") {//check if vm is qemu or LXC and if online or not
storageUsage.add(-1);
if (vmctList.get(key.toString()).get(4).equals("running")) {
icon.add(R.drawable.lxc_running);//lxc normal color
} else {
icon.add(R.drawable.lxc_offline);//lxc grey and white
}
} else if (vmctList.get(key.toString()).get(3) == "qemu") {
storageUsage.add(-1);
if (vmctList.get(key.toString()).get(4).equals("running")) {
icon.add(R.drawable.qemu_running);//qemu color
} else {
icon.add(R.drawable.qemu_offline);//qemu grey and white
}
} else if (vmctList.get(key.toString()).get(3) == "node") {
storageUsage.add(-1);
label.set(label.size() - 1, vmctList.get(key.toString()).get(0));
if (vmctList.get(key.toString()).get(4).equals("online")) {
icon.add(R.drawable.server_online);//qemu color
......@@ -522,6 +527,7 @@ public class ClusterActivity extends AppCompatActivity {
icon.add(R.drawable.server_offline);//qemu grey and white
}
} else if (vmctList.get(key.toString()).get(3) == "storage") {
storageUsage.add((int) Integer.parseInt(vmctList.get(key.toString()).get(5)));
label.set(label.size() - 1,vmctList.get(key.toString()).get(0) + " (" + vmctList.get(key.toString()).get(2) + ")");
if (vmctList.get(key.toString()).get(4).equals("available")) {
icon.add(R.drawable.storage_online);//qemu color
......@@ -533,8 +539,9 @@ public class ClusterActivity extends AppCompatActivity {
vmctList = temp;
int[] iconsInt = Ints.toArray(icon);
int[] usageInt = Ints.toArray(storageUsage);
String[] labelArray = label.toArray(new String[0]);//convert the List to array and show the listView
adapter = new de.jonasled.proxdroid.ClusterListAdapter(ClusterActivity.this, labelArray, iconsInt);
adapter = new de.jonasled.proxdroid.ClusterListAdapter(ClusterActivity.this, labelArray, iconsInt, usageInt);
listView.setAdapter(adapter);
}
}
......
......@@ -10,21 +10,28 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.core.content.res.TypedArrayUtils;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
import javax.annotation.Nullable;
public class ClusterListAdapter extends BaseAdapter { //This is used to make the list of your VMs and Container
private String title[];
private int image[];
private int usage[];
Context context;
LayoutInflater inflter;
public ClusterListAdapter(Context applicationContext, String[] title, int[] image) {
public ClusterListAdapter(Context applicationContext, String[] title, int[] image, int[] usage) {
this.title = title;
this.image = image;
this.usage = usage;
inflter = (LayoutInflater.from(applicationContext));
context = applicationContext;
}
......@@ -47,9 +54,19 @@ public class ClusterListAdapter extends BaseAdapter { //This is used to make the
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
int size = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString("textSize", "30"));//get the text size
view = inflter.inflate(R.layout.activity_listview, null); //set the view to a new entry
TextView titleTV = view.findViewById(R.id.title);//find the textView
ImageView imageIV = view.findViewById(R.id.image);//find the ImageView
ProgressBar storageUsage = view.findViewById(R.id.usageBar);
System.out.println(usage[i]);
if (usage[i] == -1) {
storageUsage.setVisibility(View.GONE);
} else {
storageUsage.setProgress(usage[i]);
}
titleTV.setText(title[i]);//set the title
try{
imageIV.setImageResource(image[i]);//set the image (Proxmox or LXC logo)
......
......@@ -6,16 +6,20 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.preference.PreferenceManager;
import javax.annotation.Nullable;
public class ServerListAdapter extends BaseAdapter {
private String title[];
private int image;
private LayoutInflater layoutInflater;
private Context context;
public ServerListAdapter(Context applicationContext, String[] title, int image) {
this.title = title;
this.image = image;
......@@ -25,7 +29,11 @@ public class ServerListAdapter extends BaseAdapter {
@Override
public int getCount() {
return title.length;
try{
return title.length;
}catch (Exception e){
return 0;
}
}
@Override
......@@ -43,10 +51,14 @@ public class ServerListAdapter extends BaseAdapter {
public View getView(int i, View view, ViewGroup viewGroup) {
int size = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString("textSize", "30")); //get the text size
view = layoutInflater.inflate(R.layout.activity_listview, null);
TextView titleTV = view.findViewById(R.id.title);
ImageView imageIV = view.findViewById(R.id.image);
titleTV.setText(title[i]);
imageIV.setImageResource(image);
ProgressBar storageUsage = view.findViewById(R.id.usageBar);
storageUsage.setVisibility(View.GONE);
titleTV.setTextSize(size);//set the text size
imageIV.getLayoutParams().width = (int) (size * context.getResources().getDisplayMetrics().density);//set the image size, according to the text size
......
......@@ -286,8 +286,10 @@ public class StorageControlActivity extends AppCompatActivity {
ArrayList<String> label = new ArrayList<>();
ArrayList<Integer> icon = new ArrayList<>();
ArrayList<Integer> usage = new ArrayList<>();
for (Object key : sortedKeys.toArray()) {//parse the sorted key list
usage.add(-1);
ArrayList<String> currentObject = storageContent.get(key);
label.add(currentObject.get(0));
if(currentObject.get(1).equals("backup")) icon.add(R.drawable.backup);
......@@ -297,8 +299,9 @@ public class StorageControlActivity extends AppCompatActivity {
if(currentObject.get(1).equals("images")) icon.add(R.drawable.lxc_running);
int[] iconsInt = Ints.toArray(icon);
int[] usageInt = Ints.toArray(usage);
String[] labelArray = label.toArray(new String[0]);//convert the List to array and show the listView
adapter = new de.jonasled.proxdroid.ClusterListAdapter(StorageControlActivity.this, labelArray, iconsInt);
adapter = new de.jonasled.proxdroid.ClusterListAdapter(StorageControlActivity.this, labelArray, iconsInt, usageInt);
storageList.setAdapter(adapter);
}
HelperFunctions.formatGraph(usageGraph, usageGraphSeries);
......
......@@ -154,16 +154,19 @@ public class backupActivity extends AppCompatActivity {
ArrayList<String> label = new ArrayList<>();
ArrayList<Integer> icon = new ArrayList<>();
ArrayList<Integer> usage = new ArrayList<>();
for (Object key : sortedKeys.toArray()) {//parse the sorted key list
label.add(key.toString());
icon.add(R.drawable.backup);
int[] iconsInt = Ints.toArray(icon);
String[] labelArray = label.toArray(new String[0]);//convert the List to array and show the listView
adapter = new de.jonasled.proxdroid.ClusterListAdapter(backupActivity.this, labelArray, iconsInt);
backupListView.setAdapter(adapter);
usage.add(-1);
}
int[] iconsInt = Ints.toArray(icon);
int[] usageInt = Ints.toArray(usage);
String[] labelArray = label.toArray(new String[0]);//convert the List to array and show the listView
adapter = new de.jonasled.proxdroid.ClusterListAdapter(backupActivity.this, labelArray, iconsInt, usageInt);
backupListView.setAdapter(adapter);
pd.dismiss();
}
......
Neue Funktionen:
* Backups können nun in der App erstellt werden
\ No newline at end of file
New Features:
* Creation of backups directly in the app
* Storage usage will be shown in cluster overview.
\ No newline at end of file
......@@ -20,12 +20,26 @@
android:text=" "
android:textSize="36sp" />
<TextView
android:id="@+id/title"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="fill_vertical"
android:text="TITLE"
android:textSize="36sp" />
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="fill_vertical"
android:text="TITLE"
android:textSize="36sp" />
<ProgressBar
android:id="@+id/usageBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -125,4 +125,16 @@
<string name="maximum">Maximum</string>
<string name="average">Durchschnitt</string>
<string name="reset">Zurücksetzen</string>
<string name="backupStarted">Backup wurde gestartet.</string>
<string name="zstdCompression">ZSTD (schnell und gut)</string>
<string name="lzoCompression">LZO (schnell)</string>
<string name="gzipCompression">GZIP (gut)</string>
<string name="none">Keine</string>
<string name="suspend">Suspend</string>
<string name="snapshot">Snapshot</string>
<string name="emailTo">Sende Email an</string>
<string name="compression">Kompression</string>
<string name="mode">Modus</string>
<string name="storage">Speicher</string>
<string name="backup">Backup</string>
</resources>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment