viewConfigMetadata.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. $('.ui.search').search({
  2. type: 'message',
  3. searchDelay: 500,
  4. silent: true,
  5. apiSettings: {
  6. silent: true,
  7. cache: false,
  8. url: urls.search,
  9. onResponse: function (casResp) {
  10. var response = {
  11. results: {}
  12. };
  13. for (var key in casResp) {
  14. if (casResp.hasOwnProperty(key)) {
  15. var prop = casResp[key];
  16. var group = prop.group;
  17. if (response.results[group] === undefined) {
  18. response.results[group] = {
  19. name: group,
  20. results: []
  21. };
  22. }
  23. response.results[group].results.push({
  24. title: prop.id,
  25. description: prop.description,
  26. defaultValue: prop.defaultValue,
  27. type: prop.type,
  28. deprecated: prop.deprecated,
  29. requiredProperty: prop.requiredProperty,
  30. requiredModule: prop.requiredModule,
  31. requiredModuleAutomated: prop.requiredModuleAutomated
  32. });
  33. }
  34. }
  35. return response;
  36. },
  37. },
  38. minCharacters: 3,
  39. templates: {
  40. message: function (response, type) {
  41. var html = '';
  42. $('#accordion').empty();
  43. if (type === 'empty') {
  44. html += '<h3><i class=\'fa fa-search\' />&nbsp;<strong>No Results</strong></h3>';
  45. html += '<div class=\'alert alert-warning\'>';
  46. html += '<i class=\'fa fa-exclamation-circle\'/>&nbsp;';
  47. html += 'No search results could be found based on the provided query.';
  48. html += '</div>';
  49. }
  50. for (var group in response.results) {
  51. var modules = new Set();
  52. html += '<h2><i class=\'fa fa-users\' />&nbsp;<strong>Group: </strong>' + group + '</h2>';
  53. var props = response.results[group].results;
  54. html += '<div>';
  55. for (var i = 0; i < props.length; i++) {
  56. html += '<p>';
  57. var prop = props[i];
  58. html += '<i class=\'fa fa-cogs\'/>&nbsp;';
  59. html += 'Property: <code>' + prop.title + '=' + prop.defaultValue + '</code><br/>';
  60. if (prop.deprecated) {
  61. html += '<p/><div class=\'alert alert-warning\'>';
  62. html += '<i class=\'fa fa-exclamation-circle\'/>&nbsp;';
  63. html += 'This property is deprecated and will be removed in future CAS versions.';
  64. html += '</div>';
  65. }
  66. if (prop.requiredProperty) {
  67. html += '<p/><div class=\'alert alert-success\'>';
  68. html += '<i class=\'fa fa-check-square\'/>&nbsp;';
  69. html += 'This property is required.';
  70. html += '</div>';
  71. }
  72. html += '<i class=\'fab fa-codepen\' />&nbsp;Type: <code>' + prop.type + '</code><br/>';
  73. if (prop.description != null) {
  74. html += '<p>' + prop.description + '</p>';
  75. }
  76. if (prop.requiredModule != null) {
  77. modules.add(prop.requiredModule);
  78. }
  79. html += '<hr>';
  80. }
  81. if (modules.size > 0) {
  82. html += '<div>';
  83. html += '<p><i class=\'fa fa-gear\' />&nbsp;Required Modules</p>';
  84. html += '<ul class=\'nav nav-pills\'>';
  85. html += '<li class=\'active\'><a href=\'#1\' data-toggle=\'tab\'>Maven</a></li>';
  86. html += '<li><a href=\'#2\' data-toggle=\'tab\'>Gradle</a></li>';
  87. html += '</ul>';
  88. for (let moduleString of modules) {
  89. html += '<div class=\'tab-content\'>';
  90. var moduleArr = moduleString.split('|');
  91. var module = moduleArr[0];
  92. var maven = '&lt;dependency&gt;\n';
  93. maven += '\t&lt;groupId&gt;org.apereo.cas&lt;/groupId&gt;\n';
  94. maven += '\t&lt;artifactId&gt;' + module + '&lt;/artifactId&gt;\n';
  95. maven += '\t&lt;cas.version&gt;${cas.version}&lt;/cas.version&gt;\n';
  96. maven += '&lt;/dependency&gt;\n';
  97. html += '<div class=\'tab-pane active\' id=\'1\'><pre>' + maven + '</pre></div>';
  98. var gradle = 'compile \'org.apereo.cas:' + module + ':${project.\'cas.version\'}\'\n';
  99. html += '<div class=\'tab-pane\' id=\'2\'><pre>' + gradle + '</pre></div>';
  100. html += '</div>';
  101. }
  102. html += '</div>';
  103. }
  104. html += '</div>';
  105. }
  106. html += '</div>';
  107. $('#accordion').html(html);
  108. $('#accordion').accordion({
  109. heightStyle: 'content'
  110. });
  111. $('#accordion').accordion('refresh');
  112. return '';
  113. }
  114. }
  115. });