Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/local/bin/python 

2# encoding: utf-8 

3""" 

4*The HTML template module for the `templates_resource_stats.py` resource* 

5 

6:Author: 

7 David Young 

8""" 

9from builtins import range 

10from builtins import object 

11import sys 

12import os 

13import khufu 

14from marshall_webapp.templates.commonelements.pagetemplates import defaultpagetemplate 

15 

16class templates_resource_stats(object): 

17 """ 

18 The worker class for the templates_resource_stats module 

19 

20 **Key Arguments** 

21 

22 - ``log`` -- logger 

23 - ``request`` -- request 

24 - ``elementId`` -- elementId 

25  

26 """ 

27 

28 def __init__( 

29 self, 

30 log, 

31 request, 

32 elementId="SSDR1" 

33 ): 

34 self.log = log 

35 log.debug("instansiating a new 'templates_resource_stats' object") 

36 self.request = request 

37 self.elementId = elementId 

38 # xt-self-arg-tmpx 

39 

40 return None 

41 

42 def get(self): 

43 """get the templates_resource_stats object 

44 

45 **Return** 

46 

47 - ``webpage`` -- the webpage HTML 

48  

49 """ 

50 self.log.debug('starting the ``get`` method') 

51 

52 from marshall_webapp.templates.commonelements.stats.esophaseIII import plot_wells, ssdr_stats_table 

53 

54 # GET THE IMAGE WELLS FOR THE PLOTS 

55 sofiImagingPlots = plot_wells( 

56 log=self.log, 

57 request=self.request, 

58 releaseVersion=self.elementId 

59 ) 

60 

61 # GET THE SSDR1 STATS TABLE 

62 ssdr1Table = ssdr_stats_table( 

63 log=self.log, 

64 request=self.request, 

65 releaseVersion=self.elementId 

66 ) 

67 

68 # # d3 practice 

69 # d3plot = self.generate_d3_plot() 

70 # d3plot = "" 

71 

72 # CRAFT THE CONTENT OF THE PAGE 

73 mainContent = khufu.grid_column( 

74 span=12, # 1-12 

75 offset=0, # 1-12 

76 content="""%(sofiImagingPlots)s %(ssdr1Table)s""" % locals( 

77 ), 

78 pull=False, # ["right", "left", "center"] 

79 htmlId=False, 

80 htmlClass="statspagecontent", 

81 onPhone=True, 

82 onTablet=True, 

83 onDesktop=True 

84 ) 

85 

86 webpage = defaultpagetemplate( 

87 log=self.log, 

88 request=self.request, 

89 bodyId=False, 

90 pageTitle="ePESSTO+ Marshall", 

91 topNavBar=False, 

92 sideBar="stats", 

93 mainContent=mainContent, 

94 relativePathFromDocRoot=False, 

95 thisPageName="PESSTO Stats" 

96 ) 

97 

98 self.log.debug('completed the ``get`` method') 

99 return webpage 

100 

101 def generate_d3_plot( 

102 self): 

103 """generate d3 plot 

104 """ 

105 self.log.debug('starting the ``generate_d3_plot`` method') 

106 

107 htmlContent = "" 

108 for i in range(1, 26): 

109 htmlClass = "example%(i)02d" % locals() 

110 htmlContent += khufu.pageHeader( 

111 headline=htmlClass, 

112 tagline='' 

113 ) 

114 

115 if i == 4: 

116 htmlContent += """ 

117 <p> 

118 <label for="nHeight" 

119 style="display: inline-block; width: 240px; text-align: right"> 

120 height = <span id="nHeight-value">…</span> 

121 </label> 

122 <input type="range" min="1" max="280" id="nHeight"> 

123 </p> 

124 

125 <p> 

126 <label for="nWidth" 

127 style="display: inline-block; width: 240px; text-align: right"> 

128 width = <span id="nWidth-value">…</span> 

129 </label> 

130 <input type="range" min="1" max="400" id="nWidth"> 

131 </p>""" 

132 

133 if i == 5: 

134 htmlContent += """ 

135 <p> 

136 <label for="nValue" 

137 style="display: inline-block; width: 240px; text-align: right"> 

138 angle = <span id="nValue-value"></span> 

139 </label> 

140 <input type="number" min="0" max="360" step="5" value="0" id="nValue"> 

141 </p>""" 

142 

143 if i == 6: 

144 htmlContent += """ 

145 <p> 

146 <label for="nRadius" 

147 style="display: inline-block; width: 240px; text-align: right"> 

148 radius = <span id="nRadius-value">…</span> 

149 </label> 

150 <input type="range" min="1" max="150" id="nRadius"> 

151 </p> 

152 """ 

153 

154 if i == 7: 

155 htmlContent += """ 

156 <p> 

157 <label for="nAngle" 

158 style="display: inline-block; width: 240px; text-align: right"> 

159 angle = <span id="nAngle-value">…</span> 

160 </label> 

161 <input type="range" min="0" max="360" id="nAngle"> 

162 </p> 

163 """ 

164 

165 if i == 8: 

166 htmlContent += """ 

167 <p> 

168 <label for="nAngle02" 

169 style="display: inline-block; width: 240px; text-align: right"> 

170 angle = <span id="nAngle02-value">…</span> 

171 </label> 

172 <input type="range" min="0" max="360" id="nAngle02"> 

173 </p> 

174 """ 

175 

176 if i == 9: 

177 htmlContent += """ 

178 """ 

179 

180 if i == 10: 

181 htmlContent += """ 

182 <div id="map" style="width: 600px; height: 400px"></div> 

183 """ 

184 

185 if i == 11: 

186 htmlContent += """ 

187 <div id="map02" style="width: 600px; height: 400px"></div> 

188 """ 

189 

190 if i == 12: 

191 htmlContent += """ 

192 """ 

193 

194 if i == 13: 

195 htmlContent += """ 

196 """ 

197 

198 if i == 14: 

199 htmlContent += """ 

200 """ 

201 

202 if i == 24: 

203 htmlContent += """ 

204 <div id="new_input"> 

205 &nbsp &nbsp 

206 Stock: <input type="text" name="stock" id="stock" value="GOOG" 

207 style="width: 70px;"> 

208 &nbsp &nbsp 

209 Start: <input type="text" name="start" id="start" value="2013-08-10" 

210 style="width: 80px;"> 

211 &nbsp &nbsp 

212 End: <input type="text" name="end" id="end" value="2014-03-10" 

213 style="width: 80px;"> 

214 &nbsp &nbsp 

215 <input name="updateButton" 

216 type="button" 

217 value="Update" 

218 onclick="updateData()" /> 

219 </div> 

220 """ 

221 

222 htmlContent += khufu.plots.svg.svg( 

223 htmlClass=htmlClass, 

224 csvUrl=False, 

225 disable=False, 

226 htmlId=False, 

227 chartType="" 

228 ) 

229 htmlContent += "<hr>" 

230 

231 self.log.debug('completed the ``generate_d3_plot`` method') 

232 return htmlContent.decode('utf-8') 

233 

234 # xt-class-method