mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
2012-06-11 Santiago Munin <burning1@gmail.com>
* res/values/arrays.xml: Removed some entries. * res/values/strings.xml: Added one entry. * res/layout/create_incident.xml: Removed form fields. * res/layout/item_list_event_extended.xml: Added a button to create an incident from the event. * src/pandroid_event_viewer/pandorafms/EventList.java: Added crate incident button logic. * src/pandroid_event_viewer/pandorafms/CreateIncidentActivity.java: Removed fields logic. * src/pandroid_event_viewer/pandorafms/Main.java, src/pandroid_event_viewer/pandorafms/EventList.java, res/menu/options_menu.xml, res/menu/options_menu_list_events.xml: Removed create incident (menu entry) git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6494 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
76f33356e3
commit
c255c14b97
@ -1,3 +1,16 @@
|
|||||||
|
2012-06-11 Santiago Munín <burning1@gmail.com>
|
||||||
|
|
||||||
|
* res/values/arrays.xml: Removed some entries.
|
||||||
|
* res/values/strings.xml: Added one entry.
|
||||||
|
* res/layout/create_incident.xml: Removed form fields.
|
||||||
|
* res/layout/item_list_event_extended.xml: Added a button to create an incident from the event.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/EventList.java: Added crate incident button logic.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/CreateIncidentActivity.java: Removed fields logic.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/Main.java,
|
||||||
|
src/pandroid_event_viewer/pandorafms/EventList.java,
|
||||||
|
res/menu/options_menu.xml,
|
||||||
|
res/menu/options_menu_list_events.xml: Removed create incident (menu entry)
|
||||||
|
|
||||||
2012-06-11 Santiago Munín <burning1@gmail.com>
|
2012-06-11 Santiago Munín <burning1@gmail.com>
|
||||||
|
|
||||||
* src/pandroid_event_viewer/pandorafms/Main.java,
|
* src/pandroid_event_viewer/pandorafms/Main.java,
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
<!--
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -143,6 +143,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
-->
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -131,7 +131,9 @@
|
|||||||
android:textColor="#000" />
|
android:textColor="#000" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow android:gravity="right" >
|
<TableRow
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:gravity="right" >
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/validate_button_extended"
|
android:id="@+id/validate_button_extended"
|
||||||
@ -145,6 +147,12 @@
|
|||||||
android:textColor="#000"
|
android:textColor="#000"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/create_incident_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/create_incident" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
@ -14,20 +14,15 @@
|
|||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
-->
|
-->
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/options_button_menu_options"
|
android:id="@+id/options_button_menu_options"
|
||||||
android:title="@string/options_label_str"
|
|
||||||
android:icon="@drawable/config"
|
android:icon="@drawable/config"
|
||||||
/>
|
android:title="@string/options_label_str"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/about_button_menu_options"
|
android:id="@+id/about_button_menu_options"
|
||||||
android:title="@string/about_label_str"
|
|
||||||
android:icon="@drawable/about"
|
android:icon="@drawable/about"
|
||||||
/>
|
android:title="@string/about_label_str"/>
|
||||||
<item
|
|
||||||
android:id="@+id/incidents_button_menu_options"
|
|
||||||
android:icon="@drawable/incident"
|
|
||||||
android:title="@string/incidents_label_str"/>
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
@ -28,9 +28,5 @@
|
|||||||
android:id="@+id/about_button_menu_options"
|
android:id="@+id/about_button_menu_options"
|
||||||
android:icon="@drawable/about"
|
android:icon="@drawable/about"
|
||||||
android:title="@string/about_label_str"/>
|
android:title="@string/about_label_str"/>
|
||||||
<item
|
|
||||||
android:id="@+id/incidents_button_menu_options"
|
|
||||||
android:icon="@drawable/incident"
|
|
||||||
android:title="@string/incidents_label_str"/>
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
@ -82,6 +82,7 @@
|
|||||||
<item>2 weeks</item>
|
<item>2 weeks</item>
|
||||||
<item>1 month</item>
|
<item>1 month</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<!--
|
||||||
<string-array name="incident_priority">
|
<string-array name="incident_priority">
|
||||||
<item>Informative</item>
|
<item>Informative</item>
|
||||||
<item>Low</item>
|
<item>Low</item>
|
||||||
@ -108,5 +109,6 @@
|
|||||||
<item>Expired incidents</item>
|
<item>Expired incidents</item>
|
||||||
<item>Closed incidents</item>
|
<item>Closed incidents</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
-->
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -115,5 +115,7 @@
|
|||||||
<string name="incident_created">Incident created</string>
|
<string name="incident_created">Incident created</string>
|
||||||
<string name="title_empty">Sorry, you must provide a title</string>
|
<string name="title_empty">Sorry, you must provide a title</string>
|
||||||
<string name="creating_incident">Creating new incident…</string>
|
<string name="creating_incident">Creating new incident…</string>
|
||||||
|
<string name="create_incident">Create incident</string>
|
||||||
|
<string name="create_incident_group_error">There was an error creating the incident: unrecognized event group. Please, contact administrator.</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -1,9 +1,7 @@
|
|||||||
package pandroid_event_viewer.pandorafms;
|
package pandroid_event_viewer.pandorafms;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.http.NameValuePair;
|
||||||
@ -16,13 +14,8 @@ import android.os.Bundle;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,16 +26,22 @@ import android.widget.Toast;
|
|||||||
*/
|
*/
|
||||||
public class CreateIncidentActivity extends Activity {
|
public class CreateIncidentActivity extends Activity {
|
||||||
private static String TAG = "CreateIncidentActivity";
|
private static String TAG = "CreateIncidentActivity";
|
||||||
EditText title, description;
|
private static int DEFAULT_STATUS_CODE = 0;
|
||||||
Spinner source, priority, group, status;
|
private static int DEFAULT_PRIORITY_CODE = 0;
|
||||||
int priority_code, status_code;
|
private static String DEFAULT_SOURCE = "Pandora FMS Event";
|
||||||
Map<Integer, String> groups;
|
private EditText title, description;
|
||||||
ProgressBar groupLoadingStatus;
|
private ProgressDialog dialog;
|
||||||
ProgressDialog dialog;
|
private String eventTitle, eventDescription, eventGroup;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Bundle extras = getIntent().getExtras();
|
||||||
|
if (extras != null) {
|
||||||
|
eventTitle = extras.getString("title");
|
||||||
|
eventDescription = extras.getString("description");
|
||||||
|
eventGroup = extras.getString("group");
|
||||||
|
}
|
||||||
setContentView(R.layout.create_incident);
|
setContentView(R.layout.create_incident);
|
||||||
initializeViews();
|
initializeViews();
|
||||||
resetViews();
|
resetViews();
|
||||||
@ -54,41 +53,7 @@ public class CreateIncidentActivity extends Activity {
|
|||||||
private void initializeViews() {
|
private void initializeViews() {
|
||||||
title = (EditText) findViewById(R.id.incident_title);
|
title = (EditText) findViewById(R.id.incident_title);
|
||||||
description = (EditText) findViewById(R.id.incident_description);
|
description = (EditText) findViewById(R.id.incident_description);
|
||||||
priority = (Spinner) findViewById(R.id.incident_priority);
|
|
||||||
group = (Spinner) findViewById(R.id.incident_group);
|
|
||||||
source = (Spinner) findViewById(R.id.incident_source);
|
|
||||||
status = (Spinner) findViewById(R.id.incident_status);
|
|
||||||
groupLoadingStatus = (ProgressBar) findViewById(R.id.loading_group);
|
|
||||||
priority.setOnItemSelectedListener(new OnItemSelectedListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemSelected(AdapterView<?> arg0, View arg1,
|
|
||||||
int arg2, long arg3) {
|
|
||||||
priority_code = arg0.getSelectedItemPosition();
|
|
||||||
if (priority_code == 5) {
|
|
||||||
priority_code = 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNothingSelected(AdapterView<?> arg0) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
status.setOnItemSelectedListener(new OnItemSelectedListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemSelected(AdapterView<?> arg0, View arg1,
|
|
||||||
int arg2, long arg3) {
|
|
||||||
status_code = arg0.getSelectedItemPosition();
|
|
||||||
if (status_code == 4) {
|
|
||||||
status_code = 13;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNothingSelected(AdapterView<?> arg0) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
((Button) findViewById(R.id.incident_create_button))
|
((Button) findViewById(R.id.incident_create_button))
|
||||||
.setOnClickListener(new OnClickListener() {
|
.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
@ -115,13 +80,8 @@ public class CreateIncidentActivity extends Activity {
|
|||||||
*/
|
*/
|
||||||
private void resetViews() {
|
private void resetViews() {
|
||||||
|
|
||||||
title.setText("");
|
title.setText(eventTitle);
|
||||||
description.setText("");
|
description.setText(eventDescription);
|
||||||
source.setSelection(0);
|
|
||||||
priority.setSelection(0);
|
|
||||||
group.setSelection(0);
|
|
||||||
status.setSelection(0);
|
|
||||||
new GetGroupsAsyncTask().execute((Void) null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,45 +97,27 @@ public class CreateIncidentActivity extends Activity {
|
|||||||
String incidentParams[] = new String[6];
|
String incidentParams[] = new String[6];
|
||||||
incidentParams[0] = title.getText().toString();
|
incidentParams[0] = title.getText().toString();
|
||||||
incidentParams[1] = description.getText().toString();
|
incidentParams[1] = description.getText().toString();
|
||||||
incidentParams[2] = String.valueOf(source.getSelectedItem().toString());
|
incidentParams[2] = String.valueOf(DEFAULT_SOURCE);
|
||||||
incidentParams[3] = String.valueOf(priority_code);
|
incidentParams[3] = String.valueOf(DEFAULT_PRIORITY_CODE);
|
||||||
incidentParams[4] = String.valueOf(status_code);
|
incidentParams[4] = String.valueOf(DEFAULT_STATUS_CODE);
|
||||||
incidentParams[5] = String.valueOf(groups.get(group
|
int groupCode = -1;
|
||||||
.getSelectedItemPosition()));
|
for (Entry<Integer, String> entry : Core.getGroups(
|
||||||
|
getApplicationContext()).entrySet()) {
|
||||||
|
if (entry.getValue().equals(eventGroup)) {
|
||||||
|
groupCode = entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (groupCode >= 0) {
|
||||||
|
incidentParams[5] = String.valueOf(groupCode);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(getApplicationContext(),
|
||||||
|
R.string.create_incident_group_error, Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
parameters.add(new BasicNameValuePair("other", Core
|
parameters.add(new BasicNameValuePair("other", Core
|
||||||
.serializeParams2Api(incidentParams)));
|
.serializeParams2Api(incidentParams)));
|
||||||
Core.httpGet(getApplicationContext(), parameters);
|
Core.httpGet(getApplicationContext(), parameters);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Async task which get groups.
|
|
||||||
*
|
|
||||||
* @author Santiago Munín González
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private class GetGroupsAsyncTask extends
|
|
||||||
AsyncTask<Void, Void, Map<Integer, String>> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Map<Integer, String> doInBackground(Void... params) {
|
|
||||||
return Core.getGroups(getApplicationContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(Map<Integer, String> result) {
|
|
||||||
groups = result;
|
|
||||||
List<String> list = new LinkedList<String>();
|
|
||||||
for (Entry<Integer, String> entry : result.entrySet()) {
|
|
||||||
list.add(entry.getValue());
|
|
||||||
}
|
|
||||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(
|
|
||||||
getApplicationContext(),
|
|
||||||
android.R.layout.simple_spinner_item, list);
|
|
||||||
group.setAdapter(spinnerArrayAdapter);
|
|
||||||
group.setSelection(0);
|
|
||||||
groupLoadingStatus.setVisibility(ProgressBar.GONE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,9 +177,6 @@ public class EventList extends ListActivity {
|
|||||||
i = new Intent(this, About.class);
|
i = new Intent(this, About.class);
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
break;
|
break;
|
||||||
case R.id.incidents_button_menu_options:
|
|
||||||
startActivity(new Intent(this, CreateIncidentActivity.class));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -349,7 +346,7 @@ public class EventList extends ListActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EventListItem item = this.object.eventList.get(position);
|
final EventListItem item = this.object.eventList.get(position);
|
||||||
|
|
||||||
switch (item.criticity) {
|
switch (item.criticity) {
|
||||||
|
|
||||||
@ -514,10 +511,27 @@ public class EventList extends ListActivity {
|
|||||||
OnClickListenerButtonValidate clickListener = new OnClickListenerButtonValidate();
|
OnClickListenerButtonValidate clickListener = new OnClickListenerButtonValidate();
|
||||||
clickListener.id_event = item.id_event;
|
clickListener.id_event = item.id_event;
|
||||||
button.setOnClickListener(clickListener);
|
button.setOnClickListener(clickListener);
|
||||||
|
|
||||||
text = (TextView) viewEventExtended
|
text = (TextView) viewEventExtended
|
||||||
.findViewById(R.id.validate_event_label);
|
.findViewById(R.id.validate_event_label);
|
||||||
text.setVisibility(TextView.GONE);
|
text.setVisibility(TextView.GONE);
|
||||||
|
((Button) viewEventExtended
|
||||||
|
.findViewById(R.id.create_incident_button))
|
||||||
|
.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
// TODO
|
||||||
|
Intent intent = new Intent(
|
||||||
|
getBaseContext(),
|
||||||
|
CreateIncidentActivity.class);
|
||||||
|
intent.putExtra("group",
|
||||||
|
item.group_name);
|
||||||
|
intent.putExtra("title", item.event);
|
||||||
|
intent.putExtra("description",
|
||||||
|
item.description_event);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
button.setVisibility(Button.GONE);
|
button.setVisibility(Button.GONE);
|
||||||
text = (TextView) viewEventExtended
|
text = (TextView) viewEventExtended
|
||||||
|
@ -387,10 +387,6 @@ public class Main extends Activity {
|
|||||||
i = new Intent(this, About.class);
|
i = new Intent(this, About.class);
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.incidents_button_menu_options:
|
|
||||||
startActivity(new Intent(this, CreateIncidentActivity.class));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user