LdapSyncInfo.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React, { PureComponent } from 'react';
  2. import { dateTimeFormat } from '@grafana/data';
  3. import { Button, Spinner } from '@grafana/ui';
  4. import { SyncInfo } from 'app/types';
  5. interface Props {
  6. ldapSyncInfo: SyncInfo;
  7. }
  8. interface State {
  9. isSyncing: boolean;
  10. }
  11. const format = 'dddd YYYY-MM-DD HH:mm zz';
  12. export class LdapSyncInfo extends PureComponent<Props, State> {
  13. state = {
  14. isSyncing: false,
  15. };
  16. handleSyncClick = () => {
  17. this.setState({ isSyncing: !this.state.isSyncing });
  18. };
  19. render() {
  20. const { ldapSyncInfo } = this.props;
  21. const { isSyncing } = this.state;
  22. const nextSyncTime = dateTimeFormat(ldapSyncInfo.nextSync, { format });
  23. return (
  24. <>
  25. <h3 className="page-heading">
  26. LDAP Synchronisation
  27. <Button className="pull-right" onClick={this.handleSyncClick} hidden>
  28. <span className="btn-title">Bulk-sync now</span>
  29. {isSyncing && <Spinner inline={true} />}
  30. </Button>
  31. </h3>
  32. <div className="gf-form-group">
  33. <div className="gf-form">
  34. <table className="filter-table form-inline">
  35. <tbody>
  36. <tr>
  37. <td>Active synchronisation</td>
  38. <td colSpan={2}>{ldapSyncInfo.enabled ? 'Enabled' : 'Disabled'}</td>
  39. </tr>
  40. <tr>
  41. <td>Scheduled</td>
  42. <td>{ldapSyncInfo.schedule}</td>
  43. </tr>
  44. <tr>
  45. <td>Next scheduled synchronisation</td>
  46. <td>{nextSyncTime}</td>
  47. </tr>
  48. </tbody>
  49. </table>
  50. </div>
  51. </div>
  52. </>
  53. );
  54. }
  55. }