def render_table(self): bookmarks = Bookmarks.getSharedInstance().getBookmarks() emptyText = """ <tr class="emptytext"><td colspan="4"> No bookmarks in storage. You can add new bookmarks using the buttons below. </td></tr> """ return """ <table class="table" data-modes='{modes}'> <tr> <th>Name</th> <th class="frequency">Frequency</th> <th>Modulation</th> <th>Actions</th> </tr> {bookmarks} </table> """.format( bookmarks="".join(self.render_bookmark(b) for b in bookmarks) if bookmarks else emptyText, modes=json.dumps({m.modulation: m.name for m in Modes.getAvailableModes()}), )
def render_input(self, value, errors): def render_mode(m): return """ <option value={mode}>{name}</option> """.format( mode=m.modulation, name=m.name, ) return """ <input type="hidden" class="{classes}" id="{id}" name="{id}" value="{value}" {disabled}> <div class="inputs" style="display:none;"> <select class="form-control form-control-sm">{options}</select> <input class="form-control form-control-sm" type="number" step="1"> </div> """.format(id=self.id, classes=self.input_classes(errors), value=html.escape(value), options="".join( render_mode(m) for m in Modes.getAvailableModes() if isinstance(m, WsjtMode)), disabled="disabled" if self.disabled else "")
def __init__(self, dict): self.name = dict["name"] self.lower_bound = dict["lower_bound"] self.upper_bound = dict["upper_bound"] self.frequencies = [] if "frequencies" in dict: availableModes = [ mode.modulation for mode in Modes.getAvailableModes() ] for (mode, freqs) in dict["frequencies"].items(): if mode not in availableModes: logger.info( 'Modulation "{mode}" is not available, bandplan bookmark will not be displayed' .format(mode=mode)) continue if not isinstance(freqs, list): freqs = [freqs] for f in freqs: if not self.inBand(f): logger.warning( "Frequency for {mode} on {band} is not within band limits: {frequency}" .format(mode=mode, frequency=f, band=self.name)) continue self.frequencies.append({"mode": mode, "frequency": f})
def __init__(self, id, label): options = [Option(m.modulation, m.name) for m in Modes.getAvailableModes()] super().__init__(id, label, options)