-
Notifications
You must be signed in to change notification settings - Fork 3
Data Storage
JavaScript provides a few different means to store data local to the user's browser. These are Cookies, Web Storage, and IndexedDB. Cookies are the simplest but not necessarily straight forward to use and very limited in size. IndexedDB is the most complex and while it may be most appropriate for storing something like scouting results, it is complicated to setup and tricky to transport. Web Storage is the happy compromise in the middle. It stores strings in key-value pairs. There are 2 kinds of Web Storage, sessionStorage and localStorage. sessionStorage is volatile, meaning it is cleared when the browser/tab is closed. localStorage does not get automatically cleared, but does only provided 10 MB of storage so it should still be managed carefully. In Chromium-based browsers the content of localStorage can be viewed in the "Application" tab of the developer tools. WildRank uses localStorage for the following JSON data.
Data imported from The Blue Alliance is stored in localStorage for offline use. This includes teams, matches, rankings, and avatars. This data is stored exactly from TBA. These are stored as [type]-[eventId].
Avatars are stored as base64 strings as avatar-[year]-[teamNum].
Both WildRank configurations and scouting configurations are stored in localStorage. Top level keys from the config/config.json file are stored as config-[key]. Scouting configs from each object in each year list in config/scout-config.json are stored as config-[year]-[type].
All results are stored in localStorage, this includes match, pit, and note results.
Match results are stored using the name match-[eventId]-[matchNum]-[teamNum]. Results contain an object with input IDs as keys and the inputs results as values. There are also additional "meta" keys for event_id, match, position, scout_mode, scout_time, scouter_id, scouting_duration, and team.
Pit results are stored using the name pit-[eventId]-[teamNum]. Results contain an object with input IDs as keys and the inputs results as values. There are also additional "meta" keys for event_id, position, scout_mode, scout_time, scouter_id, scouting_duration, and team.
Notes are stored using the name note-[eventId]-[matchNum]-[teamNum]. Notes are stored under the key "notes". There are also additional "meta" keys for event_id, match, position, scout_mode, scout_time, scouter_id, scouting_duration, and team.
Picklists are stored in localStorage using the name picklists-[eventId]. Lists are stored in an object whose keys are the list names and values are lists of the picklists' team numbers. Picklists can be created in the picklist and ranker pages, plus any pages that feature mini picklists.
Low resolution versions of images captured in pit scouting are stored as base64 string in image-[eventId]-[teamNum]. These will be the first to go in an effort to reduce storage size.