Creating a Quick Dashboard Widget

Steve Jones, 2018-11-08

I read Carlos Robles blog on creating an Azure Data Studio (ADS) insight widget and decided to try this for myself. I decided to try and get a list of object types and a count of each. Following instructions, here’s what I did.

First, I wrote a query that would gather the types of objects and counts from sys.objects.

2018-10-20 16_41_15-UserObjectCount.sql - Azure Data Studio

I saved this as a file under my Documents folder. Once I had this, I ran the query and in the results, I clicked on the Chart item to the right of the results.

2018-10-20 17_01_52-UserObjectCount.sql - Azure Data Studio

This displays a bar chart, which is useful at times, but that’s not what I want.

2018-10-20 17_02_02-UserObjectCount.sql - Azure Data Studio

Instead of this, I’ll expand the Chart Type drop down. This gives me a list of a number of items I can choose. For this insight, I’ll use the table type.

2018-10-20 16_41_30-UserObjectCount.sql - Azure Data Studio

Once this is done, I’ll see the results I want. There is a “Create Insight” button above the chart. I’ll click this to get the JSON code that creates this.

2018-10-20 16_41_23-UserObjectCount.sql - Azure Data Studio

A new editor tab opens with the JSON code in it. This is just one long line of code, which isn’t as helpful or easy to work with.

2018-10-20 16_50_48-Untitled-2 - Azure Data Studio

CTRL+Shift+P opens the command palette. Type “format” and you’ll see the Format Document command. Once you format the code, it will be easier to read.

2018-10-20 16_51_06-? Untitled-2 - Azure Data Studio

The next step is to open the user settings. This is also in the command palette.

2018-10-20 16_49_47-2017Sandbox_sandbox - Azure Data Studio

In my ADS, I get the settings list. I can search for dashboard and I’ll find the one I want.

2018-10-20 16_50_07-settings.json - Azure Data Studio

If I put the cursor in the upper left, I’ll get an edit item. I can pick this and I’ll get one of two items. If I’ve never customized anything, I’ll get the “copy to user settings” option. If I have, I get the “Replace in settings” item.

2018-10-20 16_50_15-settings.json - Azure Data Studio

Once I’ve done this, I want to modify some code. I don’t love the search box, so I’ll delete that json widget. Then I paste in my widget code. Be sure you put this in the right place, with a comma between the widgets braces. I changed the name from “my-widget” to “User Object Count”.

2018-10-20 17_11_36-settings.json - Azure Data Studio

Once I do this, I save it and close it. Then I double click one of my server connections and I see my widget on the dashboard.

2018-10-20 16_57_11-SimpleTalk Dev 2014_SimpleTalk_1_Dev - Azure Data Studio

Pretty easy to get a query to appear on your dashboard as a chart if you want to get some insights. Any query could be used, with the results returned when you open the server connection. You can also leave the dashboard open and refresh it when convenient.

Rate

Share

Share

Rate

Related content

Database Mirroring FAQ: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup?

Question: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? This question was sent to me via email. My reply follows. Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? Databases to be mirrored are currently running on 2005 SQL instances but will be upgraded to 2008 SQL in the near future.

Robert Davis

2009-02-23

1,567 reads

Networking – Part 4

You may want to read Part 1 , Part 2 , and Part 3 before continuing. This time around I’d like to talk about social networking. We’ll start with social networking. Facebook, MySpace, and Twitter are all good examples of using technology to let…

Andy Warren

2009-02-17

1,530 reads

Speaking at Community Events – More Thoughts

Last week I posted Speaking at Community Events – Time to Raise the Bar?, a first cut at talking about to what degree we should require experience for speakers at events like SQLSaturday as well as when it might be appropriate to add additional focus/limitations on the presentations that are accepted. I’ve got a few more thoughts on the topic this week, and I look forward to your comments.

Andy Warren

2009-02-13

360 reads