Calendar Input Option for Custom Reports

Hi,

I am currently working on creating custom reports and I am in need of your expertise. Specifically, I am looking to implement a calendar input option for users to select both dates and times.

I have been exploring the Morpheus Git repository in search of sample code that demonstrates how to incorporate a calendar input option, similar to the functionality found in the Cloud Cost report. In that report, users are prompted to select a start date and end date.

image

However, for my custom reports, I require users to be able to choose not only the date but also the time of the month. This additional level of granularity is crucial for the accuracy and specificity of the reports.

I kindly request your assistance in locating any relevant sample code within the Morpheus Git repository or any other resources that can guide me in implementing the desired calendar input option. Your expertise and guidance would be highly appreciated.

Thank you in advance for your support. I look forward to hearing from you soon.

@cbunge @ctaylor Any help on above question?

I would build the custom report using additional text inputs to represent the data you need to filter on for now. Maybe add some help text to the control(s) to outline/guide expected input.

The Plugin framework is getting better by the day, but I don’t think this is available ATM. I’ve no idea if a dateTime picker is on the roadmap, but it would be simple to drop in to improve a working report plugin if it should be.

You should suggest this in the ideas section of this forum too.

i have a custom option list… how can i include that option list in reports code?

Do you have any sample code i can use?

There is an example here:

Line 147 shows a method to getOptionTypes in which a single custom input is registered.
Line 96 shows how the value of the input, is obtained from the report filter modal and used in the SQL query which follows.

@Ollie_Phillips Let me explain in detail about my Question.

  1. I have created a Manual type option list called test1
  2. i have created a select Input called TestA

Now i want to use TestA input in my reports code. Do you have any example on how can i call my input in the reports code?

I can’t say if that is possible. Typically when creating a plugin, the inputs required for the plugin would be coded with the plugin and deployed with the Jar for portability. If the values in the option list are ‘manual’ you could create that control using the approach I linked previously. It appears “select” is supported in the plugin framework.

https://developer.morpheusdata.com/api/com/morpheusdata/model/OptionType.InputType.html

@Ollie_Phillips i think it is possible. if you look at the cloud usage report. it will have cloud select option, the drop down is dynamic, dorop down values comes dynamically, so i want to know how that clouds are dynamically pulled in to report.

image

Also, one more example: if you look at the Run application cost report, this report have Group, Cloud and Environments are select option lists and the values are dynamicalled pulled. if you have source code access to those two reports and tell me how they are pulling the dynamic values then it will solve my problem.

I don’t have any source code access I’m afraid. ATM we have several plugin providers, including the reports provider that expose certain capabilities with which we can interact with Morpheus, but not everything.

Those capabilities are growing, and Morpheus is now using plugins for some integrations which were previously part of the core. Those plugin providers are probably most complete and surface all the pieces needed from the core.

But regarding the core report suite, to my knowledge those have not been written using the plugin SDK, which means (at least for now) the core reports can likely do things via the core SDK, that we can’t yet in the plugin SDK. When/if reports are made modular and form part of a plugin, we’ll likely see parity between what they can do, and what we can achieve in our own reports.

For now, it is possible to script a select input and supply the name/value pairs, which is equivalent to a option list with manual values.

Do you have a sample code for the above?

Hi @rmartha, no, nothing that directly illustrates, but this is a control I have set up in a report I am building. You would want OptionType.InputType.SELECT as the final line, instead, of ...TEXT and there would be other steps to configure the select options I would expect, which you can likely work out from the plugin class reference here

    // end date
    OptionType endDate = new OptionType(
        code: 'end-date',
        name: 'EndDate',
        fieldName: 'endMonth',
        fieldContext: 'config',
        fieldLabel: 'End date',
        displayOrder: 1,
        inputType: OptionType.InputType.TEXT
    )

Incidentally, you should also check out this post - I got some surprising results based on field naming alone. I wonder if this could be a hack for your date and time picker re your original question?

@Ollie_Phillips

Here is what i have added to my custome code and getting below error, i hope you can help me to soleve this error.

i created a file called ReportOptionSourceProvider.groovy

package com.morpheusdata.reports

import com.morpheusdata.core.MorpheusContext
import com.morpheusdata.core.Plugin
import com.morpheusdata.model.*
import groovy.util.logging.Slf4j
import com.morpheusdata.core.OptionSourceProvider

@Slf4j
class ReportOptionSourceProvider implements OptionSourceProvider {

	Plugin plugin
	MorpheusContext morpheusContext

	ReportOptionSourceProvider(Plugin plugin, MorpheusContext context) {
		this.plugin = plugin
		this.morpheusContext = context
	}
	@Override
	List<String> getMethodNames() {
		return new ArrayList<String>(['reportPluginReleaseModes'])
	}
	List reportPluginReleaseModes(args) {
		[
				[name: 'Release', value: 'release'],
				[name: 'Quick Delete', value: 'quick-delete'],
				[name: 'Delete', value: 'delete']
		]
	}
}

When i run the gradle shadowjar i am getting the below error

ReportOptionSourceProvider.groovy: 7: unable to resolve class com.morpheusdata.core.OptionSourceProvider
 @ line 7, column 1.
   import com.morpheusdata.core.OptionSourceProvider
   ^

1 error


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileGroovy'.
> Compilation failed; see the compiler error output for details.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
1 actionable task: 1 executed

I got that code from here Morpheus Plugin Documentation

End Month will give you the only Month and Year(mm/yyyy), i was looking for month/date/year ( mm/dd/yyyy) as well

@Ollie_Phillips Do you know why i am getting the “import com.morpheusdata.core.OptionSourceProvider” error?

Do i need to import anything else to resolve the above import?

@mreed When you get a chance can you look at my post and let me know why i am getting that error? it is really helpful if you can guide me to solve the error from my above post

I think, i resolved the Problem, will update the full code here once i have full code ready!

1 Like