-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfig.js
61 lines (51 loc) · 1.55 KB
/
config.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
/* eslint-disable no-undef */
app.controller('HerokuController', [
'$scope',
'$element',
function ($scope) {
$scope.saving = false;
$scope.$watch('userConfigs.heroku', function (value) {
if (!value) return;
$scope.userConfig = value;
if (!$scope.account && value.accounts && value.accounts.length > 0) {
$scope.account = value.accounts[0];
}
});
$scope.$watch('configs[branch.name].heroku.config', function (value) {
$scope.config = value;
if (value && value.app && $scope.userConfig.accounts) {
for (var i = 0; i < $scope.userConfig.accounts.length; i++) {
if ($scope.userConfig.accounts[i].id === value.app.account) {
$scope.account = $scope.userConfig.accounts[i];
break;
}
}
}
});
$scope.save = function () {
$scope.saving = true;
$scope.pluginConfig('heroku', $scope.config, function () {
$scope.saving = false;
});
};
$scope.getApps = function () {
if (!$scope.account) {
return console.warn('tried to getApps but no account');
}
$.ajax('/ext/heroku/apps/' + $scope.account.id, {
type: 'GET',
success: function (body) {
$scope.account.cache = body;
$scope.success('Got accounts list for ' + $scope.account.email, true);
},
error: function () {
$scope.error(
'Failed to get accounts list for ' + $scope.account.email,
true
);
},
});
};
},
]);