Commit db150081 authored by jonasled's avatar jonasled

Merge branch 'develop'

parents 5ca735a0 7a9f0df4
......@@ -18,6 +18,9 @@
</value>
</option>
</JetCodeStyleSettings>
<MarkdownNavigatorCodeStyleSettings>
<option name="RIGHT_MARGIN" value="72" />
</MarkdownNavigatorCodeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
......
......@@ -17,7 +17,6 @@
</PreviewSettings>
<ParserSettings gitHubSyntaxChange="false" correctedInvalidSettings="false" emojiShortcuts="1" emojiImages="0">
<PegdownExtensions>
<option name="ANCHORLINKS" value="true" />
<option name="ATXHEADERSPACE" value="true" />
<option name="FENCED_CODE_BLOCKS" value="true" />
<option name="INTELLIJ_DUMMY_IDENTIFIER" value="true" />
......@@ -34,7 +33,7 @@
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
</ParserOptions>
</ParserSettings>
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" addPageHeader="false" imageUriSerials="false" addDocTypeHtml="true" noParaTags="false" plantUmlConversion="0">
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" addPageHeader="false" addAnchorLinks="true" anchorLinksWrapText="false" imageUriSerials="false" addDocTypeHtml="true" noParaTags="false" defaultUrlTitle="false" migratedPlantUml="true" migratedAnchorLinks="true" plantUmlConversion="0">
<GeneratorProvider>
<provider providerId="com.vladsch.md.nav.editor.text.html.generator" providerName="Unmodified HTML Generator" />
</GeneratorProvider>
......@@ -42,6 +41,23 @@
<headerBottom />
<bodyTop />
<bodyBottom />
<fencedCodeConversions>
<option name="c4plantuml" value="NONE" />
<option name="ditaa" value="NONE" />
<option name="erd" value="NONE" />
<option name="graphviz" value="NONE" />
<option name="latex" value="KATEX" />
<option name="math" value="KATEX" />
<option name="mermaid" value="NONE" />
<option name="nomnoml" value="NONE" />
<option name="plantuml" value="NONE" />
<option name="puml" value="NONE" />
<option name="svgbob" value="NONE" />
<option name="umlet" value="NONE" />
<option name="vega" value="NONE" />
<option name="vegalite" value="NONE" />
<option name="wavedrom" value="NONE" />
</fencedCodeConversions>
</HtmlSettings>
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="true" isCssTextEnabled="false" isDynamicPageWidth="true">
<StylesheetProvider>
......
......@@ -15,18 +15,19 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:label,android:theme">
<activity android:name=".tasksActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".backupCreateActivity"
android:theme="@style/AppTheme.NoActionBar"></activity>
<activity android:name=".backupActivity" />
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".backupActivity"
android:theme="@style/AppTheme.NoActionBar"/>
<activity android:name=".debugActivity" />
<activity
android:name=".StorageControlActivity"
android:label="@string/title_activity_server_control"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".NodeControlActivity"
android:label="@string/title_activity_server_control"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".startActivity">
<intent-filter>
......
......@@ -18,9 +18,12 @@ import androidx.appcompat.widget.Toolbar;
import androidx.preference.PreferenceManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
import org.json.JSONArray;
import org.json.JSONException;
......@@ -150,6 +153,33 @@ public class ClusterActivity extends AppCompatActivity {
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.cluster_tasks_button, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.open_tasks) {
Intent intent = new Intent(getApplicationContext(), tasksActivity.class); //start the Server control activity with some parameters
intent.putExtra("ticket", ticket); //the authentication ticket
intent.putExtra("CSRFPreventionToken", CSRFPreventionToken);
intent.putExtra("url", urlString);//the base url
startActivity(intent);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onResume() {
if (updateRequired) {
......
package de.jonasled.proxdroid;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import androidx.appcompat.widget.Toolbar;
import com.google.common.primitives.Ints;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import javax.net.ssl.HttpsURLConnection;
public class tasksActivity extends AppCompatActivity {
String ticket;
String CSRFPreventionToken;
String urlString;
ListView listView;
ArrayList<String> tasks = new ArrayList<>();
ArrayList<Integer> tasksIcon = new ArrayList<>();
ArrayList<Integer> usage = new ArrayList<>();
de.jonasled.proxdroid.ClusterListAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(startActivity.theme == 3) setTheme(R.style.Theme_App_black);
setContentView(R.layout.activity_tasks);
Toolbar toolbar = findViewById(R.id.toolbar3);
setSupportActionBar(toolbar);
setTitle(getResources().getString(R.string.app_name) + " - " + getResources().getString(R.string.tasks));
listView = findViewById(R.id.listView);
ticket = getIntent().getStringExtra("ticket");
CSRFPreventionToken = getIntent().getStringExtra("CSRFPreventionToken");
urlString = getIntent().getStringExtra("url");
new getConfig().execute();
}
private class getConfig extends AsyncTask<String, String, String> {
private ProgressDialog pd;
@Override
protected void onPreExecute() {
HelperFunctions.buildKeystore();
pd = ProgressDialog.show(tasksActivity.this, "", getResources().getString(R.string.loading), true,//open a loading dialog
false);
tasks = new ArrayList<>();
tasksIcon = new ArrayList<>();
usage = new ArrayList<>();
}
@Override
protected String doInBackground(String... strings) {
try {
URL url = new URL( urlString + "api2/json/cluster/tasks");
HttpsURLConnection conn2 = (HttpsURLConnection) url.openConnection();
conn2.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn2.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
conn2.setRequestProperty("CSRFPreventionToken", CSRFPreventionToken);
BufferedReader reader = new BufferedReader(new InputStreamReader(conn2.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
// Append server response in string
sb.append(line + "\n");
}
JSONArray resourcesJSON = (JSONArray) (new JSONObject(sb.toString())).get("data");
for(int i=0; i < resourcesJSON.length(); i++){
JSONObject temp = resourcesJSON.getJSONObject(i);
try {
usage.add(-1);
if(temp.getString("status").equals("OK")){
tasksIcon.add(R.drawable.icons8_ok_240);
} else {
tasksIcon.add(R.drawable.icons8_cancel_480);
}
String type = temp.getString("type");
String user = temp.getString("user");
String id = temp.getString("id");
if(type.equals("vncproxy") || type.equals("spiceproxy")){
tasks.add(getResources().getString(R.string.console) + ": " + id + " (" + user + ")");
} else if(type.equals("qmstart") || type.equals("vzstart")){
tasks.add(getResources().getString(R.string.start) + ": " + id + " (" + user + ")");
} else if(type.equals("qmshutdown") || type.equals("vzshutdown")){
tasks.add(getResources().getString(R.string.shutdown) + ": " + id + " (" + user + ")");
} else if(type.equals("vzdump")){
tasks.add(getResources().getString(R.string.backup) + ": " + id + " (" + user + ")");
} else if(type.equals("aptupdate")){
tasks.add(getResources().getString(R.string.aptUpdate));
} else {
tasks.add(temp.getString("upid"));
}
} catch (Exception e) {e.printStackTrace();}
}
} catch (IOException e){
e.printStackTrace();
return "failedIO";
} catch (JSONException e){
e.printStackTrace();
return "failedJSON";
}
return "";
}
@Override
protected void onPostExecute(String result) {
int[] iconInt = Ints.toArray(tasksIcon);
int[] usageInt = Ints.toArray(usage);
String[] taskArray = tasks.toArray(new String[0]);//convert the List to array and show the listView
adapter = new de.jonasled.proxdroid.ClusterListAdapter(tasksActivity.this, taskArray, iconInt, usageInt);
listView.setAdapter(adapter);
pd.dismiss();
}
}
}
\ 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
* Storage usage will be shown in cluster overview
* Added task viewer
\ No newline at end of file
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M4,6L2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6zM20,2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM19,11L9,11L9,9h10v2zM15,15L9,15v-2h6v2zM19,7L9,7L9,5h10v2z"/>
</vector>
......@@ -7,6 +7,7 @@
tools:context=".ClusterActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".tasksActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar3"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:popupTheme="@style/AppTheme.PopupOverlay" />
<ListView
android:id="@+id/listView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.6"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar3" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".ClusterActivity">
<item
android:id="@+id/open_tasks"
android:orderInCategory="300"
android:icon="@drawable/ic_baseline_library_books_24"
android:title="Item"
app:showAsAction="ifRoom"
/>
</menu>
\ No newline at end of file
......@@ -188,4 +188,7 @@
<item>@string/zstdCompression</item>
</string-array>
<string name="backupStarted">Backup was started.</string>
<string name="tasks">Tasks</string>
<string name="log">Log</string>
<string name="aptUpdate">Apt update</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