applications.py 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # coding=utf-8
  2. import typing
  3. class Application(object):
  4. """
  5. Application class with data needed for frontend
  6. """
  7. def __init__(
  8. self,
  9. label: str,
  10. slug: str,
  11. fa_icon: str,
  12. hexcolor: str,
  13. is_active: bool,
  14. config: typing.Dict[str, str],
  15. main_route: str,
  16. ) -> None:
  17. """
  18. @param label: public label of application
  19. @param slug: identifier of application
  20. @param icon: font awesome icon class
  21. @param hexcolor: hexa color of application main color
  22. @param is_active: True if application enable, False if inactive
  23. @param config: a dict with eventual application config
  24. @param main_route: the route of the frontend "home" screen of
  25. the application. For exemple, if you have an application
  26. called "calendar", the main route will be something
  27. like /#/workspace/{wid}/calendar.
  28. """
  29. self.label = label
  30. self.slug = slug
  31. self.fa_icon = fa_icon
  32. self.hexcolor = hexcolor
  33. self.is_active = is_active
  34. self.config = config
  35. self.main_route = main_route
  36. # TODO - G.M - 2018-08-07 - Refactor slug coherence issue like this one.
  37. # we probably should not have 2 kind of slug
  38. @property
  39. def minislug(self):
  40. return self.slug.replace('contents/', '')
  41. # default apps
  42. calendar = Application(
  43. label='Calendar',
  44. slug='calendar',
  45. fa_icon='calendar',
  46. hexcolor='#757575',
  47. is_active=True,
  48. config={},
  49. main_route='/#/workspaces/{workspace_id}/calendar',
  50. )
  51. thread = Application(
  52. label='Threads',
  53. slug='contents/thread',
  54. fa_icon='comments-o',
  55. hexcolor='#ad4cf9',
  56. is_active=True,
  57. config={},
  58. main_route='/#/workspaces/{workspace_id}/contents?type=thread',
  59. )
  60. folder = Application(
  61. label='Folder',
  62. slug='contents/folder',
  63. fa_icon='folder-open-o',
  64. hexcolor='#252525',
  65. is_active=True,
  66. config={},
  67. main_route='',
  68. )
  69. _file = Application(
  70. label='Files',
  71. slug='contents/file',
  72. fa_icon='paperclip',
  73. hexcolor='#FF9900',
  74. is_active=True,
  75. config={},
  76. main_route='/#/workspaces/{workspace_id}/contents?type=file',
  77. )
  78. markdownpluspage = Application(
  79. label='Markdown Plus Documents', # TODO - G.M - 24-05-2018 - Check label
  80. slug='contents/markdownpluspage',
  81. fa_icon='file-code-o',
  82. hexcolor='#f12d2d',
  83. is_active=True,
  84. config={},
  85. main_route='/#/workspaces/{workspace_id}/contents?type=markdownpluspage',
  86. )
  87. html_documents = Application(
  88. label='Text Documents', # TODO - G.M - 24-05-2018 - Check label
  89. slug='contents/html-document',
  90. fa_icon='file-text-o',
  91. hexcolor='#3f52e3',
  92. is_active=True,
  93. config={},
  94. main_route='/#/workspaces/{workspace_id}/contents?type=html-document',
  95. )
  96. # TODO - G.M - 08-06-2018 - This is hardcoded lists of app, make this dynamic.
  97. # List of applications
  98. applications = [
  99. html_documents,
  100. # TODO - G.M - 2018-08-02 - Restore markdownpage app
  101. # markdownpluspage,
  102. _file,
  103. thread,
  104. folder,
  105. # calendar,
  106. ]