dateRangeInput() is not aligned in shinydashboard when we use it with uiOutput() - shinydashboard

I need to set the input date dynamicallly in my app and therefore I need to use uiOutpot/renderUI for dataRangeInput. However when I put it directly in "ui" as in this simple example:
library(shiny)
library(bs4Dash)
shinyApp(
ui = dashboardPage(
title = "Basic Dashboard",
header = dashboardHeader(),
sidebar = dashboardSidebar(
dateRangeInput(
"startEndDate", "Date Range",
start = "2022-01-01",
end = "2022-01-30",
min = "2021-01-01",
max = "2022-01-30",
format = "yyyy-mm-dd"
)
),
controlbar = dashboardControlbar(),
footer = dashboardFooter(),
body = dashboardBody()
),
server = function(input, output) {
}
)
it comes up clean and aligned, as it is shown in this picture:
But when I wrap it inside renderUI as in this code:
library(shiny)
library(bs4Dash)
shinyApp(
ui = dashboardPage(
title = "Basic Dashboard",
header = dashboardHeader(),
sidebar = dashboardSidebar(
uiOutput("dateRange")
),
controlbar = dashboardControlbar(),
footer = dashboardFooter(),
body = dashboardBody()
),
server = function(input, output) {
output$dateRange <- renderUI({
dateRangeInput(
"startEndDate", "Date Range",
start = "2022-01-01",
end = "2022-01-30",
min = "2021-01-01",
max = "2022-01-30",
format = "yyyy-mm-dd"
)
})
}
)
it will be misaligned and ugly as in this picture:
Any help with aligning the dates input boxes with the "to" box would be appreciated.

I was able to figure this out:
library(shiny)
library(bs4Dash)
shinyApp(
ui = dashboardPage(
title = "Basic Dashboard",
header = dashboardHeader(),
sidebar = dashboardSidebar(
tags$style(".form-control, .input-group-addon {padding-top: 0px !important;}"),
uiOutput("dateRange")
),
controlbar = dashboardControlbar(),
footer = dashboardFooter(),
body = dashboardBody()
),
server = function(input, output) {
output$dateRange <- renderUI({
dateRangeInput(
"startEndDate", "Date Range",
start = "2022-01-01",
end = "2022-01-30",
min = "2021-01-01",
max = "2022-01-30",
format = "yyyy-mm-dd"
)
})
}
)

Related

Exporting events from Google calendar to Google Sheets without the formatting found in the text as in

Exporting events from Google calendar to Google Sheets without the formatting found in the text as in the image. How do I download it?\
function getEvents2022() {//חודש 0122var ss = SpreadsheetApp.getActiveSpreadsheet();var sheet = ss.getSheetByName("0122");
var start_time = sheet.getRange("A2").getValue();var end_time = sheet.getRange("B2").getValue();var id_cal = sheet.getRange("C2").getValue();
var cal = CalendarApp.getCalendarById("AAA#gmail.com");
var events = cal.getEvents(new Date("01/01/2022 12:00 AM"), new Date("01/31/2022 11:59 PM"));
for (var i = 0;i\<events.length;i++){
var title = events[i].getTitle();
var start_time = events[i].getStartTime();
var end_time = events[i].getEndTime();
var loc = events[i].getLocation();
var des = events[i].getDescription();
var vis = events[i].getVisibility();
sheet.getRange(i+2,1).setValue(title);
sheet.getRange(i+2,2).setValue(start_time);
sheet.getRange(i+2,3).setValue(end_time);
sheet.getRange(i+2,4).setValue(loc);
sheet.getRange(i+2,5).setValue(des);
sheet.getRange(i+2,6).setValue(vis);
}
I'm not sure if this is exactly what you want but try it.
let events = calendar.getEvents(start,end);
let desc = [];
events.forEach( event => {
let text = event.getDescription();
text = text.replace(/<.+?>/gm,"");
console.log(text);
}
);
Reference
RegExr

'NoneType' object is not subscriptable pymongo

So i am trying make it to where it checks the database and if they are in the database it sends a embed that say "User is already whitelisted" and if they aren't in the database then it adds them to the database. I keep getting the error NoneType' object is not subscriptable and i am lost at this point, any help will be useful.
#client.command(aliases=['wl'])
#commands.has_role("Database")
async def Whitelist(ctx, member: discord.Member):
member_id = member.id
result = Collection.find_one({"User Id": member_id },{ "_id": 0, "Key": 1})
KeyAdd = random.randint(23525623, 23623423426)
displayname = member.display_name
role = discord.utils.get(member.guild.roles, name="Whitelisted")
remove_role = discord.utils.get(member.guild.roles, name="Blacklisted")
AddWhitelist = {"User Id":member_id, "Display Name": displayname, "Key": f"Zelly_{KeyAdd}"}
embed2 = discord.Embed(
title = f"Whitelist Error",
color = discord.Colour(color)
)
embed2.add_field(name = "Content", value = f"{member.mention} is already whitelisted", inline = False)
embed2.set_footer(text = f'{bot_name}')
embed2.timestamp = datetime.datetime.utcnow()
embed = discord.Embed(
title = f"Whitelist Successful",
color = discord.Colour(color)
)
embed.add_field(name = "Content", value = f"Successfully whitelisted {member.mention}", inline = False)
embed.set_footer(text = f'{bot_name}')
embed.timestamp = datetime.datetime.utcnow()
embed1 = discord.Embed(
title = f"Whitelist",
color = discord.Colour(color)
)
embed1.add_field(name = "Content", value = f"You have been whitelisted for Zelly", inline = False)
embed1.add_field(name = "Key", value = result["Key"], inline = False)
embed1.set_footer(text = f'{bot_name}')
embed1.timestamp = datetime.datetime.utcnow()
if Collection.find_one({"User Id": member_id },{ "_id": 0, "Key": 1}) == None:
Added = Collection.insert_one(AddWhitelist)
await ctx.send(embed = embed)
elif Collection:
await ctx.send(embed = embed2)

BotFramework Carousel CardAction Button Doesn't OpenUrl

I have a carousel, but it is not opening the URL when the CardAction button is clicked in Skype. It is working in Emulator though. Is there a reason for this?
foreach(var botAmazonItem in botAmazonItems)
{
List<CardImage> cardImages = new List<CardImage>();
cardImages.Add(new CardImage(url: $"{botAmazonItem.imageUrl}"));
List<CardAction> cardButtons = new List<CardAction>();
CardAction plButton = new CardAction()
{
Value = botAmazonItem.detailsPageUrl,
Type = ActionTypes.OpenUrl,
Title = botAmazonItem.title
};
cardButtons.Add(plButton);
HeroCard plCard = new HeroCard()
{
Title = $"{botAmazonItem.title}",
Subtitle = $"{botAmazonItem.formattedPrice}",
Images = cardImages,
Buttons = cardButtons
};
Attachment plAttachment = plCard.ToAttachment();
replyToConversation.Attachments.Add(plAttachment);
}
Try changing your "value" links to https:// rather than http://. Skype requires all external links to be https://
The following code (based on yours) works:
var botAmazonItems = new List<AmazonBotItem>();
botAmazonItems.Add(new AmazonBotItem() { imageUrl = "http://placekitten.com/200/300", title = "Microsoft", formattedPrice = "$8.95", detailsPageUrl = "https://www.microsoft.com" });
botAmazonItems.Add(new AmazonBotItem() { imageUrl = "http://placekitten.com/300/300", title = "Bot Framework", formattedPrice = "$2.95", detailsPageUrl = "https://www.botframework.com" });
var reply = activity.CreateReply();
reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
reply.Attachments = new List<Attachment>();
foreach (var botAmazonItem in botAmazonItems)
{
List<CardImage> cardImages = new List<CardImage>();
cardImages.Add(new CardImage(url: $"{botAmazonItem.imageUrl}"));
List<CardAction> cardButtons = new List<CardAction>();
CardAction plButton = new CardAction()
{
Value = botAmazonItem.detailsPageUrl,
Type = ActionTypes.OpenUrl,
Title = botAmazonItem.title
};
cardButtons.Add(plButton);
HeroCard plCard = new HeroCard()
{
Title = $"{botAmazonItem.title}",
Subtitle = $"{botAmazonItem.formattedPrice}",
Images = cardImages,
Buttons = cardButtons
};
Attachment plAttachment = plCard.ToAttachment();
reply.Attachments.Add(plAttachment);
}

Parsing callback response from Tumblr

How can I parse the tumblr response in order to retrieve items such as the photo link, title etc. According to Tumblr API, it's in JSON format but I can't seem to understand how to code it. Here a snippet of the response:
{
"blog_name" = myBlogName;
"can_reply" = 0;
caption = "<p>pending again</p>";
date = "2014-01-19 15:54:22 GMT";
followed = 0;
format = html;
highlighted = ();
id = 73836876344;
"image_permalink" = "http://bantaybayan.tumblr.com/image/73836876344";
liked = 0;
"note_count" = 0;
photos = (
{
"alt_sizes" = (
{
height = 558;
url = "http://24.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_1280.jpg";
width = 740;
},
{
height = 377;
url = "http://31.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_500.jpg";
width = 500;
},
{
height = 302;
url = "http://24.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_400.jpg";
width = 400;
},
{
height = 189;
url = "http://25.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_250.jpg";
width = 250;
},
{
height = 75;
url = "http://31.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_100.jpg";
width = 100;
},
{
height = 75;
url = "http://31.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_75sq.jpg";
width = 75;
}
);
caption = "";
"original_size" = {
height = 558;
url = "http://24.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_1280.jpg";
width = 740;
};
}
);
"post_url" = "http://bantaybayan.tumblr.com/post/73836876344/pending-again";
"reblog_key" = LUOtTeAe;
"short_url" = "http://tmblr.co/Z89Zxo14n1L8u";
slug = "pending-again";
state = published;
tags = (
);
timestamp = 1390146862;
type = photo;
}
Thanks in advance
First of all, this doesn't look like JSON. Check it with a validator like JSONLint
It's easier if you use an editor for JSON data. There a lots of free online services http://jsoneditoronline.org/
For Objective-C, this SO question might help you out: Parsing JSON using Objective-C

is it possible to to apply mouse/touch events to masks with EaselJs?

Is it possible to add mouse events to a shape mask? I have the mask working, and have animated it in other tests. But now I want to know if masks can be clicked and dragged.
You can see the example here: http://www.webnamehere.com/mask/mask.html
And although Easeljs never never seems to work in jsFiddle, you can also see the code here: http://jsfiddle.net/8kbu3/1/
var circle = new createjs.Shape();
var Galaxy;
$(document).ready(function() {
canvasWidth = "1024px";
canvasHeight = "768px";
stage = new createjs.Stage('demoCanvas');
createjs.Touch.enable(stage);
$("#demoCanvas").attr({width:canvasWidth, height:canvasHeight});
Galaxy = new Image();
Galaxy.src = "images/galaxy.jpg";
Galaxy.onload = handleImageLoad;
function handleImageLoad() {
GalaxyBitmap = new createjs.Bitmap(Galaxy);
GalaxyBitmap.x = 0;
GalaxyBitmap.y = 0;
containerGalaxy = new createjs.Container();
containerGalaxy.addChild(GalaxyBitmap);
containerGalaxy.x = 0;
containerGalaxy.y = 0;
circle = new createjs.Shape();
circle.graphics.beginFill('blue').drawCircle(80,80,50).endFill();
containerGalaxy.mask = circle;
stage.addChild(containerGalaxy);
stage.update();
}
circle.onClick = function(evt){
alert('what the F?');
}
circle.onPress = function(evt){
var offset = {x:circle.x-evt.stageX, y:circle.y-evt.stageY};
evt.onMouseMove = function(ev) {
circle.x = ev.stageX+offset.x;
circle.y = ev.stageY+offset.y;
console.log("circle X: " + circle.x + " | Y: " + circle.y);
stage.update();
}
}
Thanks guys
To receive an click-event you have to add the circle to the stage (stage.addChild(circle)) or to a child of the stage, even if it acts as a mask - in your case it might be better to take a transparent dummy-object as the click-listener.