app.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var SAMLChrome = angular.module('SAMLChrome', [])
  2. .directive('prettyPrint', function ($parse) {
  3. return {
  4. restrict: 'E',
  5. replace: true,
  6. transclude: false,
  7. scope: { data: '=data' },
  8. link: function (scope, element, attrs) {
  9. let data = scope.data;
  10. if (data === true) {
  11. data = '<i>true</i>';
  12. } else if (data === false) {
  13. data = '<i>false</i>';
  14. } else if (data === undefined) {
  15. data = '<i>undefined</i>';
  16. } else if (data === null) {
  17. data = '<i>null</i>';
  18. } else if (typeof data !== 'number') {
  19. data = $('<div>').text(data).html();
  20. }
  21. let $el = $('<div></div>');
  22. $el.html(data);
  23. element.replaceWith($el);
  24. }
  25. };
  26. })
  27. .directive('resizableColumns', function ($parse) {
  28. return {
  29. link: function (scope, element, attrs) {
  30. const options = {minWidth: 5};
  31. if ($(element).data('resizable-columns-sync')) {
  32. var $target = $($(element).data('resizable-columns-sync'));
  33. $(element).on('column:resize', function(event, resizable, $leftColumn, $rightColumn, widthLeft, widthRight)
  34. {
  35. var leftColumnIndex = resizable.$table.find('.rc-column-resizing').parent().find('td, th').index($leftColumn);
  36. var $targetFirstRow = $target.find('tr:first');
  37. $($targetFirstRow.find('td, th').get(leftColumnIndex)).css('width', widthLeft + '%');
  38. $($targetFirstRow.find('td, th').get(leftColumnIndex + 1)).css('width', widthRight + '%');
  39. $target.data('resizableColumns').syncHandleWidths();
  40. $target.data('resizableColumns').saveColumnWidths();
  41. });
  42. }
  43. $(element).resizableColumns(options);
  44. }
  45. };
  46. })
  47. .directive('scrollToNew', function ($parse) {
  48. return function(scope, element, attrs) {
  49. if (scope.showIncomingRequests && scope.$last) {
  50. const $container = $(element).parents('.data-container').first();
  51. const $parent = $(element).parent();
  52. $container.scrollTop($parent.height());
  53. }
  54. };
  55. });