|
@@ -46,9 +46,10 @@ import javax.inject.Inject
|
|
class EtmBackgroundJobsFragment : EtmBaseFragment(), Injectable {
|
|
class EtmBackgroundJobsFragment : EtmBaseFragment(), Injectable {
|
|
|
|
|
|
@Inject
|
|
@Inject
|
|
- lateinit var preferences : AppPreferences
|
|
|
|
|
|
+ lateinit var preferences: AppPreferences
|
|
|
|
|
|
- class Adapter(private val inflater: LayoutInflater, private val preferences: AppPreferences) : RecyclerView.Adapter<Adapter.ViewHolder>(){
|
|
|
|
|
|
+ class Adapter(private val inflater: LayoutInflater, private val preferences: AppPreferences) :
|
|
|
|
+ RecyclerView.Adapter<Adapter.ViewHolder>() {
|
|
|
|
|
|
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|
val uuid = view.findViewById<TextView>(R.id.etm_background_job_uuid)
|
|
val uuid = view.findViewById<TextView>(R.id.etm_background_job_uuid)
|
|
@@ -88,7 +89,6 @@ class EtmBackgroundJobsFragment : EtmBaseFragment(), Injectable {
|
|
View.GONE
|
|
View.GONE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:MM:ssZ", Locale.getDefault())
|
|
private val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:MM:ssZ", Locale.getDefault())
|
|
@@ -128,31 +128,33 @@ class EtmBackgroundJobsFragment : EtmBaseFragment(), Injectable {
|
|
vh.progressEnabled = false
|
|
vh.progressEnabled = false
|
|
}
|
|
}
|
|
|
|
|
|
- val logs = preferences.readLogEntry()
|
|
|
|
- val logsForThisWorker = logs.filter { BackgroundJobManagerImpl.parseTag(it.workerClass)?.second == info.workerClass }
|
|
|
|
- if(logsForThisWorker.isNotEmpty()) {
|
|
|
|
|
|
+ val logs = preferences.readLogEntry()
|
|
|
|
+ val logsForThisWorker =
|
|
|
|
+ logs.filter { BackgroundJobManagerImpl.parseTag(it.workerClass)?.second == info.workerClass }
|
|
|
|
+ if (logsForThisWorker.isNotEmpty()) {
|
|
vh.executionTimesRow.visibility = View.VISIBLE
|
|
vh.executionTimesRow.visibility = View.VISIBLE
|
|
- vh.executionCount.text = logsForThisWorker.filter { it.started != null }.size.toString() + " (${logsForThisWorker.filter { it.finished != null }.size})"
|
|
|
|
|
|
+ vh.executionCount.text =
|
|
|
|
+ "${logsForThisWorker.filter { it.started != null }.size} " +
|
|
|
|
+ "(${logsForThisWorker.filter { it.finished != null }.size})"
|
|
var logText = "Worker Logs\n\n" +
|
|
var logText = "Worker Logs\n\n" +
|
|
- "*** Does NOT differentiate between imitate or periodic kinds of Work! ***\n"+
|
|
|
|
|
|
+ "*** Does NOT differentiate between imitate or periodic kinds of Work! ***\n" +
|
|
"*** Times run in 48h: Times started (Times finished) ***\n"
|
|
"*** Times run in 48h: Times started (Times finished) ***\n"
|
|
- logsForThisWorker.forEach{
|
|
|
|
|
|
+ logsForThisWorker.forEach {
|
|
logText += "----------------------\n"
|
|
logText += "----------------------\n"
|
|
logText += "Worker ${BackgroundJobManagerImpl.parseTag(it.workerClass)?.second}\n"
|
|
logText += "Worker ${BackgroundJobManagerImpl.parseTag(it.workerClass)?.second}\n"
|
|
- logText += if (it.started == null){
|
|
|
|
|
|
+ logText += if (it.started == null) {
|
|
"ENDED at\n${it.finished}\nWith result: ${it.result}\n"
|
|
"ENDED at\n${it.finished}\nWith result: ${it.result}\n"
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
"STARTED at\n${it.started}\n"
|
|
"STARTED at\n${it.started}\n"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
vh.executionLog.text = logText
|
|
vh.executionLog.text = logText
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
vh.executionLog.text = "Worker Logs\n\n" +
|
|
vh.executionLog.text = "Worker Logs\n\n" +
|
|
"No Entries -> Maybe logging is not implemented for Worker or it has not run yet."
|
|
"No Entries -> Maybe logging is not implemented for Worker or it has not run yet."
|
|
vh.executionCount.text = "0"
|
|
vh.executionCount.text = "0"
|
|
vh.executionTimesRow.visibility = View.GONE
|
|
vh.executionTimesRow.visibility = View.GONE
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -186,22 +188,27 @@ class EtmBackgroundJobsFragment : EtmBaseFragment(), Injectable {
|
|
vm.cancelAllJobs()
|
|
vm.cancelAllJobs()
|
|
true
|
|
true
|
|
}
|
|
}
|
|
|
|
+
|
|
R.id.etm_background_jobs_prune -> {
|
|
R.id.etm_background_jobs_prune -> {
|
|
vm.pruneJobs()
|
|
vm.pruneJobs()
|
|
true
|
|
true
|
|
}
|
|
}
|
|
|
|
+
|
|
R.id.etm_background_jobs_start_test -> {
|
|
R.id.etm_background_jobs_start_test -> {
|
|
vm.startTestJob(periodic = false)
|
|
vm.startTestJob(periodic = false)
|
|
true
|
|
true
|
|
}
|
|
}
|
|
|
|
+
|
|
R.id.etm_background_jobs_schedule_test -> {
|
|
R.id.etm_background_jobs_schedule_test -> {
|
|
vm.startTestJob(periodic = true)
|
|
vm.startTestJob(periodic = true)
|
|
true
|
|
true
|
|
}
|
|
}
|
|
|
|
+
|
|
R.id.etm_background_jobs_cancel_test -> {
|
|
R.id.etm_background_jobs_cancel_test -> {
|
|
vm.cancelTestJob()
|
|
vm.cancelTestJob()
|
|
true
|
|
true
|
|
}
|
|
}
|
|
|
|
+
|
|
else -> super.onOptionsItemSelected(item)
|
|
else -> super.onOptionsItemSelected(item)
|
|
}
|
|
}
|
|
}
|
|
}
|