Detailed Notes
Part II of the creation of reports. This focuses on the dynamic display of parameters.
You can view source for today and all prior days by reviewing the tag Day 45 at this GitHub: https://github.com/robbroadhead/develpreneur-pythontutorial
Transcript Text
[Music] welcome back we are continuing to plow through working on our reports and we're going to do is we're going to actually build a sort of like a dynamic report page and so we've started down this path a little bit and now we're going to continue it so if we go to our uh where to go reports page now we have our selector and right now we're just displaying the report id but instead what i want to do is i want to fill out the reports so i'm going to do i'm going to actually call this i'm going to send an id and i'm going to get say display report parameters and what that's going to do uh so let's see blah blah blah that needs to be id so i'm going to do display port parameters id i'm going to put this on top of it just because so now it's going to call this and it's going to just open up the parameters section there and then return so but what we need to do is here i'm going to get let's see this will be rpt parms we're going to call it that i'm going to give it an id for report it's going to get it's going to set this time however our element is actually going to be our parameters actually let's just pull that whole piece out i'm just going to do all of it here so what it's going to do is it's going to get that element we're going to do the display blocks going to be the last thing we do and then what we want to do is is we want to take the response and set it to that so that was uh element dot because we're going to actually build the whole thing here so now what we need to do is we're going to have to actually get the response that we get back from our ajax call so we can actually do something with this uh which did we do that before uh where was that that was it oh we didn't before because we were just doing a fire and forget this time we're going to tweak it and we're going to actually deal with our response three two one now what we have to do here is we have to actually uh we're gonna have to set some stuff up here so this is a little bit uh different from what we've seen in the past we're gonna do an on uh ready state change and so this means um basically when we when this thing comes when some sort of response comes back from this we're going to be working with it and so what we want to do is we want it to be equal to a function and in that function because we're going to do some we're going to do stuff and so if this dot ready state equals four and this.status equals 200. so basically if this thing completes if we get a return we're going to do something and we're gonna do the result that we get back is the response text and then uh actually we're gonna have to within this whoops i gotta do that right and then what we need to do is we're going to have to actually do the update here so it's going to be since we don't have this within we're actually going to have to do this here as well actually yes let's just move all of this in here so we're only going to deal with this once we get back a response and we're gonna have to build this out so it's gonna take us probably again a couple of uh episodes get through this because first okay so let's see so we're gonna come through i'm gonna call report parms i'm gonna give it uh that oh no we want it to be equal to result and then display uh get element by d okay so now we need to go to what we're calling which we called rpt params and we're going to send it an id so let's set that up i called it that so let's see i've got one here i'm just going to steal this just to make it a little easier and that's going to be my here so this is going to be i'm going to call it report parameters and so i'm going to need a report parameters over on this side on my views and i'm going to do something let's just do this steal this guy parameters he's going to have an id and the response i'm going to send back is going to be the parms and farms equals we're going to start with um we'll do it this way yeah it's not going to be an h1 i'll be in h4 um let's see we could say no parameters available and then otherwise we're going to come in we're just going to hard code this right now we could do something a little more complicated but we're going to keep it essentially hard coded in our report parameters and so we're just going to do if id equals 1. we're going to do something if id equals 2 it's going to be something else and if i d3 it's going to be something else and then in each of these because we look at our reports each of these it's by status by roadmap or by timeline so each of these we're going to actually have you're going to select a status a roadmap or a timeline so each of these is going to start with a selector and we're going to do his name is going to be equal to rpt parms parm1 so we're going to start that so each one of these this would be eventually we could have multiple parameters and then uh here this is going to be in the select and then we're going to create some options so we're going to do this for each of these actually and then we're going to create some options and the options are going to be based on something so something is good so first we're going to do is let's like look at what we got we've got uh timeline roadmap at status so let's uh note timeline roadmap status whoops go over here and then this one's going to be timeline roadmap status and so this actually becomes pretty easy because our options is going to be equal to timeline dot objects.all as we've seen a couple places down here like here we're gonna do essentially the same thing except see where we did it here see i'm just going to take that and instead it's going to be timeline it's going to be roadmap and it's going to be a status which we call lkp status okay now what we can do with each of these we could build it here and we're going to we could also build it actually on the other side but it's a little easier just because where we're at we're going to do this so we're going to do for opt and ops and then each of these is going to build a select i'm sorry an option so it's going to be option and then actually what we can do is we're gonna do this in a one-liner and we're gonna do let's see sorry id id equals and we're going to send it we're going to give it the option.id and here we're going to give it the option dot all right we just do option and it's going to probably pick up to string for us so let's try this so you see we could actually do stuff a little uh let's see option id yeah so we should be able to get that let's see how this works out i think let's see in there got that got that got that why are you complaining about timeline time frame i'm sorry and that was going to get us our response we're going to send our spots back so first let's just test this so if we send it here uh what did we call that go to url that was rpt parms so let's just steal that real quick so if we do uh one oh because it doesn't like it it's an id versus so let's uh that's going to actually be string and actually we can take that with each of these we could actually in this case we could simplify it but i'm not going to because we may eventually have different params uh let's see so time frame to string so we do need that so we're going to say um here i think we can do op dot name for each of them except for well we may be able to let's see did i get that i mean we're sort of doing quick okay so now that's if i do it for that one i'm going to get this little selector if i get this one okay so there's unbound local oh i managed to lose my ops there that one sets this one was look up status this one was roadmap okay so that's all my road maps and there we go okay so what i want to do is i'm going to go ahead and with each of these i'm going to actually do a label basically and it's going to be um select timeline select road map select status so now that's what i'm going to get back so now what i can do is uh let's see well did i get that done let's go check real quick if i did my reports i can't remember if i had this set up right so if i do my roadmap oh there we go okay so now what i'm doing is i'm going to give myself the ability to select parameters based on a report and then i'm going to come back next time we're going to actually generate a report so with each of these actually what i'm going to do is because i'm going to need this i'm going to have a button i'm actually going to steal this one because i don't even need the that guy anymore and within the parameters i'm gonna do um i'm gonna do it like this i'm gonna do a row here well let's do it this way i do a row here oh because i'm changing the inner html so what i want to do is that div is i'm gonna have a button and i'm gonna have a row here oops i just totally did something weird on that but now that's oh so i'm going to have to change around a little bit because of that because i'm doing the inner html of this parameters i'm going to have to actually change that up so we're going to tweak this a little bit next time so let's do our button for now we're going to put it here this is going to be uh run report and he's going to be run report and we're going to give it probably an id or may not even have to so that'll be what we're going to pick up next time around so next time around we will run a report for now uh we're getting there and you're gonna see here i get my parameters as needed and we'll clean this up a little bit and generate our reports next time around so until then have yourself a great day a great week and we will talk to you next time you
Transcript Segments
[Music]
welcome back
we are continuing to plow through
working on our reports
and we're going to do is we're going to
actually build a sort of like a dynamic
report page
and so we've started down this path a
little bit and now we're going to
continue it so if we go to
our uh where to go reports page
now we have our selector and
right now we're just displaying the
report id but instead
what i want to do is i want to
fill out the reports so i'm going to do
i'm going to actually call this i'm
going to send an id
and i'm going to get say display
report parameters
and what that's going to do uh so let's
see blah blah blah that needs to be
id so i'm going to do display
port parameters id
i'm going to put this on top of it just
because
so now it's going to call this and it's
going to
just open up the parameters section
there
and then return so but what we need to
do is here i'm going to get
let's see this will be rpt parms we're
going to call it that i'm going to give
it an id for report
it's going to get it's going to set this
time however
our element is actually going to be
our parameters
actually let's just pull that whole
piece out
i'm just going to do all of it here so
what it's going to do is it's going to
get that
element we're going to do the display
blocks going to be the last thing we do
and then what we want to do is
is we want to take the response
and set it to that so that was uh
element
dot because we're going to actually
build the whole
thing here
so now what we need to do is we're going
to have to actually get the response
that we get back
from our ajax call so we can actually do
something with this
uh which did we do that before
uh where was that that was it oh we
didn't before because we were just doing
a fire and forget this time
we're going to tweak it and we're going
to actually deal with our response
three two one now what we have to do
here is we have to actually
uh we're gonna have to set some stuff up
here so this is a little bit
uh different from what we've seen in the
past we're gonna do an on
uh ready state change
and so this means um basically when we
when this thing comes when some sort of
response comes back from this we're
going to be working with it
and so what we want to do is we want it
to be equal to a function
and in that function because we're going
to do some we're going to
do stuff and so if this
dot ready state
equals four and
this.status
equals 200. so basically if this thing
completes if we get a return
we're going to do something and we're
gonna do the result
that we get back is the
response text and then
uh actually we're gonna have to within
this whoops i gotta do that right
and then what we need to do is we're
going to have to actually do the update
here so it's going to be since we don't
have this within
we're actually going to have to do this
here as well
actually yes let's just move all of this
in here
so we're only going to deal with this
once we get back
a response and we're gonna have to build
this out
so it's gonna take us probably again a
couple of
uh episodes get through this because
first okay so let's see so we're gonna
come through
i'm gonna call report parms i'm gonna
give it
uh that oh no we want it to be equal to
result
and then display
uh get element by d okay so now we need
to go to
what we're calling which we called rpt
params and we're going to send it an id
so let's set that up
i called it that so let's see i've got
one here i'm just going to steal this
just to make it a little easier
and that's going to be my here
so this is going to be i'm going to call
it report parameters
and so i'm going to need a report
parameters over on this side
on my views
and i'm going to do something
let's just do this
steal this guy
parameters he's going to have an id
and the response i'm going to send back
is going to be the parms
and farms equals we're going to start
with um
we'll do it this way yeah it's not going
to be an h1 i'll be in h4
um let's see we could say
no parameters available
and then otherwise we're going to come
in we're just going to hard code this
right now we could do something a little
more complicated but we're going to keep
it
essentially hard coded in our report
parameters
and so we're just going to do if id
equals 1. we're going to do something
if id equals 2 it's going to be
something else
and if i d3 it's going to be something
else and then
in each of these because we look at our
reports
each of these it's by status by roadmap
or by timeline so each of these we're
going to actually have
you're going to select a status a
roadmap or a timeline so each of these
is going to start with
a selector
and we're going to do his name is going
to be equal
to rpt parms
parm1 so we're going to start that so
each one of these
this would be eventually we could have
multiple parameters
and then uh
here this is going to be
in the select
and then we're going to create some
options so we're going to do this for
each of these actually
and then we're going to create some
options and the options are going to be
based on something so
something is good so first we're going
to do is let's like look at
what we got we've got uh timeline
roadmap at
status so let's uh note
timeline roadmap status whoops go over
here
and then this one's going to be
timeline
roadmap
status
and so this actually becomes pretty easy
because our options is going to be
equal to timeline
dot objects.all
as we've seen a couple places down here
like here we're gonna do essentially the
same thing
except see where we did it
here see i'm just going to take that and
instead it's going to be
timeline it's going to be roadmap
and it's going to be a status
which we call lkp status okay
now what we can do with each of these we
could build it here and we're going to
we could also build it actually on the
other side
but it's a little easier just because
where we're at we're going to do this so
we're going to do for opt and ops
and then each of these is going to build
a select i'm sorry an option
so it's going to be option
and then actually what we can do is
we're gonna do this in a one-liner
and we're gonna do let's see
sorry id id equals and we're going to
send it
we're going to give it the
option.id and here
we're going to give it the option dot
all right we just do option and it's
going to probably pick up to string
for us so let's try this
so you see we could actually do stuff a
little uh let's see option id yeah so we
should be able to get that let's see how
this works out
i think let's see in there got that got
that got that
why are you complaining about timeline
time frame i'm sorry
and that was going to get us our
response we're going to send our spots
back
so first let's just test this so if we
send it
here
uh what did we call that
go to url that was rpt parms
so let's just steal that real quick
so if we do uh one
oh because it doesn't like it it's an id
versus so let's uh that's going to
actually be
string
and actually we can take that with each
of these we could actually
in this case we could simplify it but
i'm not going to because we may
eventually have different params
uh let's see so time frame
to string
so we do need that so we're going to say
um here
i think we can do op dot name for each
of them
except for well we may be able to let's
see did i get that i mean we're
sort of doing quick okay so now that's
if i do it for that one i'm going to get
this little selector
if i get this one okay so there's
unbound local
oh i managed to lose my
ops there
that one sets this one was
look up status this one was roadmap
okay
so that's all my road maps
and there we go okay so
what i want to do is i'm going to go
ahead and with each of these i'm going
to actually do
a label basically
and it's going to be um
select timeline
select road map
select status
so now that's what i'm going to get back
so now what i can do is
uh let's see well did i get that done
let's go check real quick
if i did my reports
i can't remember if i had this set up
right so if i do my roadmap oh there we
go
okay so now what i'm doing is i'm going
to give myself
the ability to select parameters based
on a report
and then i'm going to come back next
time we're going to actually generate a
report so with each of these
actually what i'm going to do is
because i'm going to need this i'm going
to have a button
i'm actually going to steal this one
because i don't even need the that guy
anymore
and within the parameters
i'm gonna do um i'm gonna do it like
this i'm gonna do a row here
well let's do it this way
i do a row here oh because i'm changing
the inner html
so what i want to do is
that div is
i'm gonna have a button and i'm gonna
have a row
here
oops i just totally did something weird
on that
but now that's oh so i'm going to have
to change around a little bit because
of that because i'm doing the inner html
of this parameters i'm going to have to
actually change that up so we're going
to tweak this a little bit next time so
let's do our button for now
we're going to put it here this is going
to be
uh
run report
and he's going to be run report and
we're going to give it probably an id or
may not even have to so that'll be what
we're going to pick up next time around
so next time around we will run a report
for now
uh we're getting there and you're gonna
see here
i get my parameters as needed and we'll
clean this up a little bit and generate
our reports
next time around so until then have
yourself a great day
a great week and we will talk to you
next time
you