2011-09-16 Miguel de Dios <miguel.dedios@artica.es>

* src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java:
	added to use the PandroidEventviewerActivity class in other parts in 
	proyect.
	
	* src/pandroid_event_viewer/pandorafms/Main.java: work in progress in the
	form, now only I need to write the filter call.
	
	* res/values/arrays.xml, res/values/strings.xml, res/values-en/arrays.xml,
	res/values-en/strings.xml, res/values-es/arrays.xml,
	res/values-es/strings.xml, res/layout/main.xml: added more values.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4964 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2011-09-16 11:19:54 +00:00
parent b428ac629b
commit 8f3817d4e3
10 changed files with 350 additions and 6 deletions

View File

@ -1,3 +1,16 @@
2011-09-16 Miguel de Dios <miguel.dedios@artica.es>
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java:
added to use the PandroidEventviewerActivity class in other parts in
proyect.
* src/pandroid_event_viewer/pandorafms/Main.java: work in progress in the
form, now only I need to write the filter call.
* res/values/arrays.xml, res/values/strings.xml, res/values-en/arrays.xml,
res/values-en/strings.xml, res/values-es/arrays.xml,
res/values-es/strings.xml, res/layout/main.xml: added more values.
2011-09-15 Miguel de Dios <miguel.dedios@artica.es>
* res/layout/*: added new layout and some changes in other layout.

View File

@ -1,12 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/main_text"
/>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableRow>
<TextView
android:text="@string/agent_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<EditText
android:id="@+id/agent_name"
android:layout_height="wrap_content"
android:singleLine="true"
android:editable="true"
android:layout_width="0dp"
android:layout_weight="1"
/>
</TableRow>
<TableRow>
<TextView
android:text="@string/group_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<Spinner
android:id="@+id/group_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
<TableRow>
<TextView
android:text="@string/severity_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<Spinner
android:id="@+id/severity_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
</TableLayout>
<TextView
android:text="@string/date_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<TimePicker
android:textSize="10sp"
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<DatePicker
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:text="@string/reset_button_str"
android:id="@+id/button_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<Button
android:text="@string/search_button_str"
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<resources>
<string-array name="severity_array_values">
<!-- You must subtract -1 -->
<item>All</item>
<item>Maintenance</item>
<item>Informational</item>
<item>Normal</item>
<item>Warning</item>
<item>Critical</item>
</string-array>
</resources>

View File

@ -32,4 +32,8 @@
<string name="agent_label_str">Agent name</string>
<string name="type_label_str">Type</string>
<string name="severity_label_str">Severity</string>
<string name="date_label_str">Date</string>
<string name="number_events_label_str">Number Events</string>
<string name="reset_button_str">Reset</string>
<string name="search_button_str">Search</string>
</resources>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<resources>
<string-array name="severity_array_values">
<!-- You must subtract -1 -->
<item>Todos</item>
<item>Mantenimiento</item>
<item>Información</item>
<item>Normal</item>
<item>Alerta</item>
<item>Critico</item>
</string-array>
</resources>

View File

@ -32,4 +32,8 @@
<string name="agent_label_str">Nombre del agente</string>
<string name="type_label_str">Tipo</string>
<string name="severity_label_str">Severidad</string>
<string name="date_label_str">Fecha</string>
<string name="number_events_label_str">Número de eventos</string>
<string name="reset_button_str">Reserteo</string>
<string name="search_button_str">Buscar</string>
</resources>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<resources>
<string-array name="severity_array_values">
<!-- You must subtract -1 -->
<item>All</item>
<item>Maintenance</item>
<item>Informational</item>
<item>Normal</item>
<item>Warning</item>
<item>Critical</item>
</string-array>
</resources>

View File

@ -32,4 +32,8 @@
<string name="agent_label_str">Agent name</string>
<string name="type_label_str">Type</string>
<string name="severity_label_str">Severity</string>
<string name="date_label_str">Date</string>
<string name="number_events_label_str">Number Events</string>
<string name="reset_button_str">Reset</string>
<string name="search_button_str">Search</string>
</resources>

View File

@ -1,13 +1,145 @@
package pandroid_event_viewer.pandorafms;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TimePicker;
public class Main extends Activity {
public PandroidEventviewerActivity object;
public HashMap<Integer, String> pandoraGroups;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent i = getIntent();
this.object = (PandroidEventviewerActivity)i.getSerializableExtra("object");
this.pandoraGroups = new HashMap<Integer, String>();
setContentView(R.layout.main);
Spinner combo = (Spinner) findViewById(R.id.group_combo);
this.setGroups(combo);
combo = (Spinner) findViewById(R.id.severity_combo);
ArrayAdapter adapter = ArrayAdapter.createFromResource(
this, R.array.severity_array_values, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
combo.setAdapter(adapter);
final Button buttonReset = (Button) findViewById(R.id.button_reset);
buttonReset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
reset_form();
}
});
final Button buttonSearch = (Button) findViewById(R.id.button_send);
buttonSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
search_form();
}
});
}
public void search_form() {
}
public void reset_form() {
EditText agentEditText = (EditText)findViewById(R.id.agent_name);
agentEditText.setText("");
Spinner combo = (Spinner) findViewById(R.id.group_combo);
combo.setSelection(0);
combo = (Spinner) findViewById(R.id.severity_combo);
combo.setSelection(0);
Calendar c = Calendar.getInstance();
DatePicker datePicker = (DatePicker)findViewById(R.id.date);
datePicker.updateDate(c.get(Calendar.YEAR),
c.get(Calendar.MONTH),
c.get(Calendar.DAY_OF_MONTH));
TimePicker timePicker = (TimePicker)findViewById(R.id.time);
timePicker.setCurrentHour(c.get(Calendar.HOUR_OF_DAY));
timePicker.setCurrentMinute(c.get(Calendar.MINUTE));
}
public void setGroups(Spinner combo) {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(
"http://192.168.70.112/pandora_console/include/api.php");
List<NameValuePair> parameters = new ArrayList<NameValuePair>(2);
parameters.add(new BasicNameValuePair("user", "admin"));
parameters.add(new BasicNameValuePair("pass", "pandora"));
parameters.add(new BasicNameValuePair("op", "get"));
parameters.add(new BasicNameValuePair("op2", "groups"));
parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|"));
parameters.add(new BasicNameValuePair("return_type", "csv"));
parameters.add(new BasicNameValuePair("other", ";"));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters);
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entityResponse = response.getEntity();
String return_api = this.object.convertStreamToString(entityResponse.getContent());
String[] lines = return_api.split("\n");
ArrayList<String> array = new ArrayList<String>();
for (int i= 0; i < lines.length; i++) {
String[] groups = lines[i].split(";", 21);
this.pandoraGroups.put(new Integer(groups[0]), groups[1]);
array.add(groups[1]);
}
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item,
array);
combo.setAdapter(spinnerArrayAdapter);
}
catch (Exception e) {
Log.e("ERROR THE ", e.getMessage());
return;
}
}
}

View File

@ -53,6 +53,7 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
Intent i_main = new Intent(this, Main.class);
i_main.putExtra("object", this);
tabHost.addTab
(
@ -183,7 +184,7 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
}
}
private String convertStreamToString (InputStream is)
public String convertStreamToString (InputStream is)
{
BufferedReader reader = new BufferedReader(new
InputStreamReader(is), 8*1024);