panel_meta.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. class PanelMeta {
  2. description: any;
  3. fullscreen: any;
  4. editIcon: any;
  5. panelName: any;
  6. menu: any;
  7. editorTabs: any;
  8. extendedMenu: any;
  9. constructor(options : any) {
  10. this.description = options.description;
  11. this.fullscreen = options.fullscreen;
  12. this.editIcon = options.editIcon;
  13. this.panelName = options.panelName;
  14. this.menu = [];
  15. this.editorTabs = [];
  16. this.extendedMenu = [];
  17. if (options.fullscreen) {
  18. this.addMenuItem('View', 'icon-eye-open', 'toggleFullscreen(false); dismiss();');
  19. }
  20. this.addMenuItem('Edit', 'icon-cog', 'editPanel(); dismiss();', 'Editor');
  21. this.addMenuItem('Duplicate', 'icon-copy', 'duplicatePanel()', 'Editor');
  22. this.addMenuItem('Share', 'icon-share', 'sharePanel(); dismiss();');
  23. this.addEditorTab('General', 'app/partials/panelgeneral.html');
  24. if (options.metricsEditor) {
  25. this.addEditorTab('Metrics', 'app/partials/metrics.html');
  26. }
  27. this.addExtendedMenuItem('Panel JSON', '', 'editPanelJson(); dismiss();');
  28. }
  29. addMenuItem (text, icon, click, role?) {
  30. this.menu.push({text: text, icon: icon, click: click, role: role});
  31. }
  32. addExtendedMenuItem (text, icon, click, role?) {
  33. this.extendedMenu.push({text: text, icon: icon, click: click, role: role});
  34. }
  35. addEditorTab (title, src) {
  36. this.editorTabs.push({title: title, src: src});
  37. }
  38. }
  39. export = PanelMeta;