def handle_get_state_select_runhistory(client_state, username): ''' Handles GET /state for Select Sequence (Run history tab) Function expects a client state and a string username. Function returns the Run Hitory tab portion of the sequences screen. Function handles the toggles of the buttons for what order sequences shall be listed in. ''' server_state = get_server_state(username) system_available = (server_state["runstate"]["status"] == "Idle") # Determine the sorting modes sort_descending = True sort_key1 = "" sort_key2 = "" name_sort_mode = "none" if client_state["runhistorysort"]["column"] == "name": sort_key1 = "name" name_sort_mode = client_state["runhistorysort"]["mode"] if name_sort_mode == "down": sort_descending = False comment_sort_mode = "none" if client_state["runhistorysort"]["column"] == "comment": sort_key1 = "comment" comment_sort_mode = client_state["runhistorysort"]["mode"] if comment_sort_mode == "down": sort_descending = False creator_sort_mode = "none" if client_state["runhistorysort"]["column"] == "creator": sort_key1 = "creator" creator_sort_mode = client_state["runhistorysort"]["mode"] if creator_sort_mode == "down": sort_descending = False date_time_sort_mode = "none" if client_state["runhistorysort"]["column"] == "date&time": sort_key1 = "date" sort_key2 = "time" date_time_sort_mode = client_state["runhistorysort"]["mode"] if date_time_sort_mode == "down": sort_descending = False # Format the buttons, tabs and columns return_state = { "buttons": [{ "type": "button", "id": "SEQUENCER", "enabled": True }, { "type": "button", "id": "COPYSEQUENCE", "enabled": True, "selectionrequired": True }, { "type": "button", "id": "VIEWSEQUENCE", "enabled": True, "selectionrequired": True }, { "type": "button", "id": "RUNSEQUENCE", "enabled": system_available, "selectionrequired": True }, { "type": "button", "id": "VIEWRUNLOGS", "enabled": False, "selectionrequired": True }, { "type": "button", "id": "VIEWBATCHRECORD", "enabled": False, "selectionrequired": True }], "tabs": [{ "type": "tab", "text": "SEQUENCE LIST", "id": "SAVEDSEQUENCES" }, { "type": "tab", "text": "RUN HISTORY", "id": "RUNHISTORY" }], "tabid": "RUNHISTORY", "columns": [{ "type": "column", "data": "name", "display": "NAME", "percentwidth": 20, "sortable": True, "sortmode": name_sort_mode }, { "type": "column", "data": "comment", "display": "COMMENT", "percentwidth": 40, "sortable": True, "sortmode": comment_sort_mode }, { "type": "column", "data": "creator", "display": "USER", "percentwidth": 15, "sortable": True, "sortmode": creator_sort_mode }, { "type": "column", "data": "date&time", "display": "DATE", "percentwidth": 25, "sortable": True, "sortmode": date_time_sort_mode }] } # Append the run history list run_history_sequences = db.get_all_sequences("History") if sort_key2 == "": run_history_sequences.sort( key=lambda sequence: map(lower_if_possible, sequence[sort_key1]), reverse=sort_descending) else: run_history_sequences.sort( key=lambda sequence: (map(lower_if_possible, sequence[sort_key1]), map(lower_if_possible, sequence[sort_key2])), reverse=sort_descending) return_state.update({"sequences": run_history_sequences}) return return_state
def handle_get_state_select_runhistory(client_state, username): """ Handles GET /state for Select Sequence (Run history tab) Function expects a client state and a string username. Function returns the Run Hitory tab portion of the sequences screen. Function handles the toggles of the buttons for what order sequences shall be listed in. """ server_state = get_server_state(username) system_available = server_state["runstate"]["status"] == "Idle" # Determine the sorting modes sort_descending = True sort_key1 = "" sort_key2 = "" name_sort_mode = "none" if client_state["runhistorysort"]["column"] == "name": sort_key1 = "name" name_sort_mode = client_state["runhistorysort"]["mode"] if name_sort_mode == "down": sort_descending = False comment_sort_mode = "none" if client_state["runhistorysort"]["column"] == "comment": sort_key1 = "comment" comment_sort_mode = client_state["runhistorysort"]["mode"] if comment_sort_mode == "down": sort_descending = False creator_sort_mode = "none" if client_state["runhistorysort"]["column"] == "creator": sort_key1 = "creator" creator_sort_mode = client_state["runhistorysort"]["mode"] if creator_sort_mode == "down": sort_descending = False date_time_sort_mode = "none" if client_state["runhistorysort"]["column"] == "date&time": sort_key1 = "date" sort_key2 = "time" date_time_sort_mode = client_state["runhistorysort"]["mode"] if date_time_sort_mode == "down": sort_descending = False # Format the buttons, tabs and columns return_state = { "buttons": [ {"type": "button", "id": "SEQUENCER", "enabled": True}, {"type": "button", "id": "COPYSEQUENCE", "enabled": True, "selectionrequired": True}, {"type": "button", "id": "VIEWSEQUENCE", "enabled": True, "selectionrequired": True}, {"type": "button", "id": "RUNSEQUENCE", "enabled": system_available, "selectionrequired": True}, {"type": "button", "id": "VIEWRUNLOGS", "enabled": False, "selectionrequired": True}, {"type": "button", "id": "VIEWBATCHRECORD", "enabled": False, "selectionrequired": True}, ], "tabs": [ {"type": "tab", "text": "SEQUENCE LIST", "id": "SAVEDSEQUENCES"}, {"type": "tab", "text": "RUN HISTORY", "id": "RUNHISTORY"}, ], "tabid": "RUNHISTORY", "columns": [ { "type": "column", "data": "name", "display": "NAME", "percentwidth": 20, "sortable": True, "sortmode": name_sort_mode, }, { "type": "column", "data": "comment", "display": "COMMENT", "percentwidth": 40, "sortable": True, "sortmode": comment_sort_mode, }, { "type": "column", "data": "creator", "display": "USER", "percentwidth": 15, "sortable": True, "sortmode": creator_sort_mode, }, { "type": "column", "data": "date&time", "display": "DATE", "percentwidth": 25, "sortable": True, "sortmode": date_time_sort_mode, }, ], } # Append the run history list run_history_sequences = db.get_all_sequences("History") if sort_key2 == "": run_history_sequences.sort( key=lambda sequence: map(lower_if_possible, sequence[sort_key1]), reverse=sort_descending ) else: run_history_sequences.sort( key=lambda sequence: ( map(lower_if_possible, sequence[sort_key1]), map(lower_if_possible, sequence[sort_key2]), ), reverse=sort_descending, ) return_state.update({"sequences": run_history_sequences}) return return_state
def handle_get_state_select_savedsequences(client_state, username): ''' Handles GET /state for Select Saved Sequence Function expects a client state and a string username. Function returns the select saved sequences screen (the screen that lists all sequences.) ''' # Check if the system is running server_state = get_server_state(username) system_available = (server_state["runstate"]["status"] == "Idle") # Determine the sorting modes sort_descending = True sort_key = "" name_sort_mode = "none" if client_state["selectsequencesort"]["column"] == "name": sort_key = "name" name_sort_mode = client_state["selectsequencesort"]["mode"] if name_sort_mode == "down": sort_descending = False comment_sort_mode = "none" if client_state["selectsequencesort"]["column"] == "comment": sort_key = "comment" comment_sort_mode = client_state["selectsequencesort"]["mode"] if comment_sort_mode == "down": sort_descending = False # Format the buttons, tabs and columns return_state = { "buttons": [{ "type": "button", "id": "SEQUENCER", "enabled": True, "selectionrequired": False }, { "type": "button", "id": "NEWSEQUENCE", "enabled": True, "selectionrequired": False }, { "type": "button", "id": "COPYSEQUENCE", "enabled": True, "selectionrequired": True }, { "type": "button", "id": "VIEWSEQUENCE", "enabled": True, "selectionrequired": True }, { "type": "button", "id": "EDITSEQUENCE", "enabled": True, "selectionrequired": True }, { "type": "button", "id": "RUNSEQUENCE", "enabled": system_available, "selectionrequired": True }, { "type": "button", "id": "DELETESEQUENCE", "enabled": True, "selectionrequired": True }], "tabs": [{ "type": "tab", "text": "SEQUENCE LIST", "id": "SAVEDSEQUENCES" }, { "type": "tab", "text": "RUN HISTORY", "id": "RUNHISTORY" }], "tabid": "SAVEDSEQUENCES", "columns": [{ "type": "column", "data": "name", "display": "NAME", "percentwidth": 35, "sortable": True, "sortmode": name_sort_mode }, { "type": "column", "data": "comment", "display": "COMMENT", "percentwidth": 65, "sortable": True, "sortmode": comment_sort_mode }] } # Append the saved sequence list saved_sequences = db.get_all_sequences("Saved") saved_sequences.sort( key=lambda sequence: map(lower_if_possible, sequence[sort_key]), reverse=sort_descending) return_state.update({"sequences": saved_sequences}) return return_state
def handle_get_state_select_savedsequences(client_state, username): """ Handles GET /state for Select Saved Sequence Function expects a client state and a string username. Function returns the select saved sequences screen (the screen that lists all sequences.) """ # Check if the system is running server_state = get_server_state(username) system_available = server_state["runstate"]["status"] == "Idle" # Determine the sorting modes sort_descending = True sort_key = "" name_sort_mode = "none" if client_state["selectsequencesort"]["column"] == "name": sort_key = "name" name_sort_mode = client_state["selectsequencesort"]["mode"] if name_sort_mode == "down": sort_descending = False comment_sort_mode = "none" if client_state["selectsequencesort"]["column"] == "comment": sort_key = "comment" comment_sort_mode = client_state["selectsequencesort"]["mode"] if comment_sort_mode == "down": sort_descending = False # Format the buttons, tabs and columns return_state = { "buttons": [ {"type": "button", "id": "SEQUENCER", "enabled": True, "selectionrequired": False}, {"type": "button", "id": "NEWSEQUENCE", "enabled": True, "selectionrequired": False}, {"type": "button", "id": "COPYSEQUENCE", "enabled": True, "selectionrequired": True}, {"type": "button", "id": "VIEWSEQUENCE", "enabled": True, "selectionrequired": True}, {"type": "button", "id": "EDITSEQUENCE", "enabled": True, "selectionrequired": True}, {"type": "button", "id": "RUNSEQUENCE", "enabled": system_available, "selectionrequired": True}, {"type": "button", "id": "DELETESEQUENCE", "enabled": True, "selectionrequired": True}, ], "tabs": [ {"type": "tab", "text": "SEQUENCE LIST", "id": "SAVEDSEQUENCES"}, {"type": "tab", "text": "RUN HISTORY", "id": "RUNHISTORY"}, ], "tabid": "SAVEDSEQUENCES", "columns": [ { "type": "column", "data": "name", "display": "NAME", "percentwidth": 35, "sortable": True, "sortmode": name_sort_mode, }, { "type": "column", "data": "comment", "display": "COMMENT", "percentwidth": 65, "sortable": True, "sortmode": comment_sort_mode, }, ], } # Append the saved sequence list saved_sequences = db.get_all_sequences("Saved") saved_sequences.sort(key=lambda sequence: map(lower_if_possible, sequence[sort_key]), reverse=sort_descending) return_state.update({"sequences": saved_sequences}) return return_state