WEBVTT 00:01.090 --> 00:07.960 So we have this menu for admin users set up and we have references to admin, all Desh sales for all 00:07.960 --> 00:11.850 sales and slash admin, all dash subscriptions for all subscriptions. 00:12.250 --> 00:13.720 And we also have the virtual terminal. 00:13.780 --> 00:16.630 Now, the virtual terminal is there and it works fine. 00:16.900 --> 00:21.510 But of course, we need to set up the routes and handlers and templates for these two links. 00:21.520 --> 00:26.980 And we can also, because I forgot to do it last time, get rid of this, which nobody sees because 00:26.980 --> 00:31.450 it has the class of Denon but is just cluttering up our base layout. 00:31.450 --> 00:32.410 So I'll delete that. 00:33.100 --> 00:36.910 And the other thing I want to take care of, and this has been bothering me for a while and we just 00:36.910 --> 00:42.640 something left over from when I began planning this course is in the render dot go package. 00:43.300 --> 00:49.420 If you get down to the page where we actually render things down here, what we pass the template. 00:50.320 --> 00:51.160 Where is it? 00:51.280 --> 00:51.740 Right here. 00:52.510 --> 00:57.040 So this if statement, OK, and this is in the function render template. 00:57.490 --> 01:04.150 I actually have if app dot config one of equals production and template in map. 01:04.390 --> 01:09.580 And this is because initially when I did this I wasn't using going back, I had my templates in a separate 01:09.580 --> 01:14.440 folder, but then I thought, no, let's take advantage of the new go embed functionality and put our 01:14.440 --> 01:16.600 templates right into a file system. 01:16.600 --> 01:21.010 That's part of the binary that we see when we run this application or we compile this application. 01:21.790 --> 01:25.770 And of course, the go embed gives us a read only file system. 01:25.780 --> 01:28.480 So this check actually doesn't make any sense. 01:28.510 --> 01:32.000 So we can get rid of this part right here and just make it simpler. 01:32.020 --> 01:37.240 Now, if the template is in the map, we use the template from the map, from the app template cache. 01:37.780 --> 01:43.690 Otherwise we pass the template and actually put it in the map a little bit further down, right down 01:43.690 --> 01:45.550 here in the pass template function. 01:45.550 --> 01:48.370 We added to the map right there on line 106 and my code. 01:48.790 --> 01:49.990 So that's just a bit of housecleaning. 01:49.990 --> 01:52.990 And we were going to do some more housekeeping a little bit later on. 01:52.990 --> 01:58.640 But right now, let's get some stub routes and handlers set up for those two pages, all sales and all 01:58.660 --> 01:59.340 subscriptions. 02:00.040 --> 02:02.140 So the first thing to do is create the templates we're going to need. 02:02.230 --> 02:08.160 So in my templates folder, I'll create a new file and I'll call the first one all Desh sales page and 02:08.170 --> 02:09.010 go HTML. 02:10.600 --> 02:15.970 And I call the second one new file, all Dasht subscriptions. 02:17.200 --> 02:18.970 Page Dot Go HTML. 02:21.260 --> 02:28.160 And we'll just put Stobbs in here for right now, so we'll start with all subscriptions and of course, 02:28.160 --> 02:35.480 it's using our template base and we'll be handing data to this and we'll define the title. 02:39.010 --> 02:41.140 And we'll call this all subscriptions. 02:43.510 --> 02:56.650 And that will have some content defined content, and for now I'm just going to say to class equals 02:56.800 --> 03:00.220 empty dash five, all subscriptions. 03:03.430 --> 03:12.300 And close my age to put an HRR in there and close this, and we're also going to have JavaScript. 03:12.490 --> 03:16.400 Saw just out the block right now and leave it empty. 03:18.190 --> 03:24.430 Now, a copy all of this and go to all sales, all their sales page to go with HTML and just change 03:24.430 --> 03:28.660 this to sales just so we can render something and make sure everything is hooked up properly. 03:31.180 --> 03:39.190 Now let's go to our roots in the CMD Web folder and up here where we have the admin part. 03:39.190 --> 03:43.540 And I'm going to delete these now because they've been there long enough, that comment into that line. 03:43.960 --> 03:45.090 I'll create two new routes. 03:45.520 --> 03:51.310 So the first one is going to be a we'll just duplicate that amongst doGet and it's going to go admin, 03:51.340 --> 03:59.290 which again, we get from this line line 15 and it's all dash sales and it will go to a handler that 03:59.290 --> 04:01.420 doesn't exist yet, all sales. 04:02.200 --> 04:05.770 And then I'll duplicate that and change this to subscriptions. 04:15.210 --> 04:18.230 Which I better spell right script shuns there. 04:18.990 --> 04:25.950 Now let's go over to our handlers and I'll just get there by clicking on a virtual terminal and scroll 04:25.950 --> 04:28.830 the very bottom and we'll put two stub handlers in place. 04:29.430 --> 04:30.240 Very simple ones. 04:32.700 --> 04:38.870 So I'll have a function with the receiver of App Pointer to application. 04:39.000 --> 04:42.260 And this one is going to be called All Sales and as a handler. 04:45.870 --> 04:48.180 So it has the response writer and the request. 04:50.940 --> 04:51.990 And I'll copy this. 04:52.020 --> 04:55.560 I shall finish it first or copy this part. 04:55.560 --> 04:56.300 Right. 04:56.310 --> 04:58.920 And we find a render so I can save some time right here. 04:59.370 --> 05:09.870 I copy that one from forgot password and paste it in here and just change this part to all dash sales. 05:11.070 --> 05:14.730 We'll have to modify these in a while, of course, but this will get us running and make sure that 05:14.730 --> 05:15.950 everything is hooked up properly. 05:16.980 --> 05:23.200 Paste that in there and changes to also descriptions and change sales to subscriptions here. 05:24.690 --> 05:27.440 Now, I should be able to run this and see those pages. 05:27.450 --> 05:35.940 So let's make stop make a start and just go back and make sure that everything works as it should. 05:36.150 --> 05:37.500 So back to my Web browser. 05:39.090 --> 05:41.790 I appear to be logged in, but I'm going to log out. 05:41.800 --> 05:42.600 No, I'm not logged in. 05:42.600 --> 05:51.750 So let's log in and go to admin at example, dot com password three and log in. 05:53.460 --> 05:56.790 And there's my admin menu and I should be able to go to all sales. 05:57.090 --> 05:59.550 They're there and all subscriptions. 05:59.820 --> 06:00.480 And there it is. 06:00.930 --> 06:07.740 So next step is to actually write some JavaScript on both of those pages that we'll call the back end 06:08.040 --> 06:12.870 using our authentication token so we can pass muster and show them that we are, in fact authenticated 06:13.350 --> 06:18.330 and request a list of all subscriptions or all sales and display them in tabular format. 06:18.420 --> 06:20.880 And we'll get started on that in the next lecture.