Пример #1
0
 def create_confirm_form(self):
     confirm_form = CustomForm('/trendmanager')
     confirm_form.submit = HTMLgen.Span(**{"class":"savespan"})
     confirm_form.submit.append(
         CustomInput(type='hidden', name='trend',
                     value=self.confirmupdate.encoded_name)
         )
     confirm_form.submit.append(
         CustomInput(type='submit', name='confirmupdate', value='Commit')
         )
     confirm_form.submit.append(
         CustomInput(type='submit', name='cancelupdate', value='Cancel')
         )
     return confirm_form
Пример #2
0
 def create_document_structure(self):
     self.document = HTMLgen.SimpleDocument(
         title='trendMANAGER',
         stylesheet='/omega/trendmanager/styles.css',
         script=[HTMLgen.Script(src="/webapi/js/ColorPicker2.js"),
                 HTMLgen.Script(code="""
                 window.ColorPicker_targetButton = null;
                 function pickColor(color) {
                     ColorPicker_targetInput.value = color;
                     ColorPicker_targetButton.style.backgroundColor = color;
                     return;
                 }
                 var cp = new ColorPicker('window');
                 function open_color_selector(input_id, button_id) {
                     var input = document.getElementById(input_id);
                     var button = document.getElementById(button_id);
                     window.ColorPicker_targetButton = button;
                     cp.select(input, input_id);
                     return;
                 }
                 function change_button_color(input_id, button_id) {
                     var input = document.getElementById(input_id);
                     var button = document.getElementById(button_id);
                     var color = input.value;
                     button.style.backgroundColor = color;
                     return;
                 }
                 """)
                 ]
         )
     # Hack-around to set the class on the BODY for HTMLGen
     self.document.append(
         HTMLgen.Script(code="""
           document.body.className = 'manager';
           """)
         )
     page_heading = HTMLgen.Heading(2, "Trend Preferences",
                                    id="editorlabel")
     self.document.append(page_heading)
     section = HTMLgen.Div(**{'class':'section'})
     form = CustomForm('/trendmanager')
     #
     # Also, create methods in request handler to extract the values
     # to make changing the form easier.
     #
     self.generalpreferencescontainer = HTMLgen.Div(
         **{'id':'generalpreferencescontainer'}
         )
     form.append(self.generalpreferencescontainer)
     self.pointpreferencescontainer = HTMLgen.Div(
         **{'id':'pointpreferencescontainer'}
         )
     form.append(self.pointpreferencescontainer)
     self.axespreferencescontainer = HTMLgen.Div(
         **{'id':'axespreferencescontainer'}
         )
     form.append(self.axespreferencescontainer)
     form.submit = HTMLgen.Span(**{"class":"savespan"})
     form.submit.append(
         CustomInput(type='hidden', name='trend', value=self.encoded_name)
         )
     form.submit.append(
         CustomInput(type='submit', name='commitpreferences',
                     value='Commit')
         )
     form.submit.append(
         CustomInput(type='submit', name='cancelpreferences',
                     value='Cancel')
         )
     form.submit.append(
         CustomInput(type='submit', name='reloadpreferences',
                     value='Reload')
         )
     section.append(form)
     self.document.append(section)
     return
Пример #3
0
 def create_document_structure(self):
     self.document = HTMLgen.SimpleDocument(
         title='trendMANAGER',
         stylesheet='/omega/trendmanager/styles.css',
         script=[
             HTMLgen.Script(src="/webapi/js/ColorPicker2.js"),
             HTMLgen.Script(code="""
                 window.ColorPicker_targetButton = null;
                 function pickColor(color) {
                     ColorPicker_targetInput.value = color;
                     ColorPicker_targetButton.style.backgroundColor = color;
                     return;
                 }
                 var cp = new ColorPicker('window');
                 function open_color_selector(input_id, button_id) {
                     var input = document.getElementById(input_id);
                     var button = document.getElementById(button_id);
                     window.ColorPicker_targetButton = button;
                     cp.select(input, input_id);
                     return;
                 }
                 function change_button_color(input_id, button_id) {
                     var input = document.getElementById(input_id);
                     var button = document.getElementById(button_id);
                     var color = input.value;
                     button.style.backgroundColor = color;
                     return;
                 }
                 """)
         ])
     # Hack-around to set the class on the BODY for HTMLGen
     self.document.append(
         HTMLgen.Script(code="""
           document.body.className = 'manager';
           """))
     page_heading = HTMLgen.Heading(2,
                                    "Trend Preferences",
                                    id="editorlabel")
     self.document.append(page_heading)
     section = HTMLgen.Div(**{'class': 'section'})
     form = CustomForm('/trendmanager')
     #
     # Also, create methods in request handler to extract the values
     # to make changing the form easier.
     #
     self.generalpreferencescontainer = HTMLgen.Div(
         **{'id': 'generalpreferencescontainer'})
     form.append(self.generalpreferencescontainer)
     self.pointpreferencescontainer = HTMLgen.Div(
         **{'id': 'pointpreferencescontainer'})
     form.append(self.pointpreferencescontainer)
     self.axespreferencescontainer = HTMLgen.Div(
         **{'id': 'axespreferencescontainer'})
     form.append(self.axespreferencescontainer)
     form.submit = HTMLgen.Span(**{"class": "savespan"})
     form.submit.append(
         CustomInput(type='hidden', name='trend', value=self.encoded_name))
     form.submit.append(
         CustomInput(type='submit',
                     name='commitpreferences',
                     value='Commit'))
     form.submit.append(
         CustomInput(type='submit',
                     name='cancelpreferences',
                     value='Cancel'))
     form.submit.append(
         CustomInput(type='submit',
                     name='reloadpreferences',
                     value='Reload'))
     section.append(form)
     self.document.append(section)
     return
Пример #4
0
    def render(self):
        # @todo Restructure like preferences, point_form -> form...
        self.trend_configuration = self.trend.configuration()
        document = HTMLgen.SimpleDocument(
            title='trendMANAGER',
            stylesheet='/omega/trendmanager/styles.css',
            script=[HTMLgen.Script(code=nodeselectscript),
                    HTMLgen.Script(code=updatenamescript),]
            )
        # Hack-around to set the class on the BODY for HTMLGen
        document.append(
            HTMLgen.Script(code="""
              document.body.className = 'manager';
              """)
            )
        page_heading = HTMLgen.Heading(2, "Trend Point Configuration",
                                       id="editorlabel")
        document.append(page_heading)
        section = HTMLgen.Div(**{'class':'section'})
        point_form = CustomForm('/trendmanager')

        self.globalsettingscontainer = HTMLgen.Div(
            **{'id':'globalsettingscontainer'}
            )
        point_form.append(self.globalsettingscontainer)
        self.add_global_settings()
        point_section = HTMLgen.Div(**{'class':'section'})
        point_table = HTMLgen.TableLite(**{'class':'nodeEditTable'})
        point_header = HTMLgen.TR(**{'class':'trend_table_headers'})
        for header in ['Point Name', 'Node Path']:
            header_id = "%sheader" % header.replace(' ','').lower()
            headcell = HTMLgen.TH(header, scope="col", abbr=header,
                                  id=header_id)
            point_header.append(headcell)
        point_table.append(point_header)
        rowclasses = ['light', 'dark']
        cd_points = self.trend_configuration['points']
        for point_position in xrange(1,10):
            point_row = HTMLgen.TR(**{'class':rowclasses[point_position % 2]})
            point_name_value = ""
            point_node_value = ""
            if len(cd_points) >= point_position:
                point_cfg = cd_points[point_position-1]
                point_name_value = point_cfg['name']
                point_node_value = point_cfg['node']
            point_name_id = "point%d" % point_position
            name_input = DojoInput(**{
                'value':point_name_value,
                'name':point_name_id,
                'id':point_name_id,
                })
            name_column = HTMLgen.TD(**{"nowrap":True})
            name_column.append(name_input)
            point_row.append(name_column)
            point_node_id = "node%d" % point_position
            node_input = DojoInput(**{
                'value':point_node_value,
                'name':point_node_id,
                'id':point_node_id,
                })
            # @fixme Cool idea, need to swap order of node and name and
            #        adding +/- capability would be extremely helpful in
            #        user experience.
            #node_input.onChange = "update_point_name('%s','%s');" % (
            #    point_node_id,
            #    point_name_id
            #    )
            node_column = HTMLgen.TD(**{"class":"configuration",
                                        "nowrap":True})
            node_column.append(node_input)
            browse_node_id = "browse%d" % point_position
            node_browse = CustomInput(**{
                'type':'button',
                'name':browse_node_id,
                'value':'...',
                })
            node_browse.onClick = "open_node_selector('%s');" % point_node_id
            button_column = HTMLgen.TD(**{"nowrap":True})
            button_column.append(node_browse)
            point_row.append(node_column)
            point_row.append(button_column)
            point_table.append(point_row)
        point_table.append(
            CustomInput(type='hidden', name='commitpoints', value='Commit')
            )
        point_form.append(point_table)
        point_form.submit = HTMLgen.Span(**{"class":"savespan"})
        point_form.submit.append(
            CustomInput(type='hidden', name='trend', value=self.encoded_name)
            )
        point_form.submit.append(
            CustomInput(type='submit', name='commitpoints', value='Commit')
            )
        point_form.submit.append(
            CustomInput(type='submit', name='cancelpoints', value='Cancel')
            )
        point_form.submit.append(
            CustomInput(type='submit', name='reloadpoints', value='Reload')
            )        
        section.append(point_form)
        document.append(section)
        return str(document)
Пример #5
0
    def render(self):
        # @todo Restructure like preferences, point_form -> form...
        self.trend_configuration = self.trend.configuration()
        document = HTMLgen.SimpleDocument(
            title='trendMANAGER',
            stylesheet='/omega/trendmanager/styles.css',
            script=[
                HTMLgen.Script(code=nodeselectscript),
                HTMLgen.Script(code=updatenamescript),
            ])
        # Hack-around to set the class on the BODY for HTMLGen
        document.append(
            HTMLgen.Script(code="""
              document.body.className = 'manager';
              """))
        page_heading = HTMLgen.Heading(2,
                                       "Trend Point Configuration",
                                       id="editorlabel")
        document.append(page_heading)
        section = HTMLgen.Div(**{'class': 'section'})
        point_form = CustomForm('/trendmanager')

        self.globalsettingscontainer = HTMLgen.Div(
            **{'id': 'globalsettingscontainer'})
        point_form.append(self.globalsettingscontainer)
        self.add_global_settings()
        point_section = HTMLgen.Div(**{'class': 'section'})
        point_table = HTMLgen.TableLite(**{'class': 'nodeEditTable'})
        point_header = HTMLgen.TR(**{'class': 'trend_table_headers'})
        for header in ['Point Name', 'Node Path']:
            header_id = "%sheader" % header.replace(' ', '').lower()
            headcell = HTMLgen.TH(header,
                                  scope="col",
                                  abbr=header,
                                  id=header_id)
            point_header.append(headcell)
        point_table.append(point_header)
        rowclasses = ['light', 'dark']
        cd_points = self.trend_configuration['points']
        for point_position in xrange(1, 10):
            point_row = HTMLgen.TR(**{'class': rowclasses[point_position % 2]})
            point_name_value = ""
            point_node_value = ""
            if len(cd_points) >= point_position:
                point_cfg = cd_points[point_position - 1]
                point_name_value = point_cfg['name']
                point_node_value = point_cfg['node']
            point_name_id = "point%d" % point_position
            name_input = DojoInput(
                **{
                    'value': point_name_value,
                    'name': point_name_id,
                    'id': point_name_id,
                })
            name_column = HTMLgen.TD(**{"nowrap": True})
            name_column.append(name_input)
            point_row.append(name_column)
            point_node_id = "node%d" % point_position
            node_input = DojoInput(
                **{
                    'value': point_node_value,
                    'name': point_node_id,
                    'id': point_node_id,
                })
            # @fixme Cool idea, need to swap order of node and name and
            #        adding +/- capability would be extremely helpful in
            #        user experience.
            #node_input.onChange = "update_point_name('%s','%s');" % (
            #    point_node_id,
            #    point_name_id
            #    )
            node_column = HTMLgen.TD(**{
                "class": "configuration",
                "nowrap": True
            })
            node_column.append(node_input)
            browse_node_id = "browse%d" % point_position
            node_browse = CustomInput(**{
                'type': 'button',
                'name': browse_node_id,
                'value': '...',
            })
            node_browse.onClick = "open_node_selector('%s');" % point_node_id
            button_column = HTMLgen.TD(**{"nowrap": True})
            button_column.append(node_browse)
            point_row.append(node_column)
            point_row.append(button_column)
            point_table.append(point_row)
        point_table.append(
            CustomInput(type='hidden', name='commitpoints', value='Commit'))
        point_form.append(point_table)
        point_form.submit = HTMLgen.Span(**{"class": "savespan"})
        point_form.submit.append(
            CustomInput(type='hidden', name='trend', value=self.encoded_name))
        point_form.submit.append(
            CustomInput(type='submit', name='commitpoints', value='Commit'))
        point_form.submit.append(
            CustomInput(type='submit', name='cancelpoints', value='Cancel'))
        point_form.submit.append(
            CustomInput(type='submit', name='reloadpoints', value='Reload'))
        section.append(point_form)
        document.append(section)
        return str(document)