aboutsummaryrefslogtreecommitdiff
path: root/data/assets/js/admin/dialogs/project-edit.js
blob: bfb7334ed1eda73a65732bd4b3889c8152d905e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
jQuery(function($) {
  "use strict";

  var p = '#project-edit-';

  $(p + 'dialog').on('guff.loaded', function(ev) {
    var r = ev.post_data;

    $(p + 'repo').val(r.repo_url);
    $(p + 'tag-prefix').val(r.tag_prefix);
    $(p + 'secret').val(r.hook_secret);
  });

  $(p + 'confirm').click(function() {
    $(p + 'dialog').trigger({
      type: 'guff.save',

      post_data: {
        repo_url:     $(p + 'repo').val(),
        tag_prefix:   $(p + 'tag-prefix').val(),
        hook_secret:  $(p + 'secret').val(),
      },
    });

    // stop event
    return false;
  });

  $('#project-edit-generate-secret').click(function() {
    var me = $(this);

    // disable button
    me.toggleClass('disabled').find('.fa').toggleClass('fa-spin');
    send('project/generate_secret').always(function() {
      // enable button
      me.toggleClass('disabled').find('.fa').toggleClass('fa-spin');
    }).fail(function(r) {
      gripe(r, 'generate secret');
    }).done(function(r) {
      // update secret
      $('#project-edit-secret').val(r.secret);
    });
  });
});