dashboard: bug fix and refactoring of JS into multiple files