Skip to content

Commit

Permalink
Merge pull request #479 from vyulabs/update-angular
Browse files Browse the repository at this point in the history
Update angularjs/angular-ui to last version
  • Loading branch information
twhiston committed Mar 11, 2018
2 parents 8cd859f + 02ab874 commit 4916435
Show file tree
Hide file tree
Showing 28 changed files with 232 additions and 221 deletions.
5 changes: 2 additions & 3 deletions public/html/projects/templates/add.pug
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@

hr
.form-group
label.control-label.col-sm-4 Extra CLI Arguments (*MUST* be a JSON array!)
label.control-label.col-sm-4(uib-tooltip='*MUST* be a JSON array! Each argument must be an element of the array, for example: ["-i", "@myinventory.sh", "--private-key=/there/id_rsa", "-vvvv"]') Extra CLI Arguments
.col-sm-6
div(ui-ace="{mode: 'json', workerPath: '/public/js/ace/'}" style="height: 100px" class="form-control" ng-model="task.environment")
.form-group
.col-sm-6.col-sm-offset-4
.checkbox: label
.checkbox(uib-tooltip="Usually semaphore prepends arguments like `--private-key=/location/id_rsa` to make sure everything goes smoothly. This option is for special needs, where semaphore conflicts with one of your arguments."): label
input(type="checkbox" ng-model="user.admin")
| Override semaphore arguments
p.help-block Usually semaphore prepends arguments like `--private-key=/location/id_rsa` to make sure everything goes smoothly. This option is for special needs, where semaphore conflicts with one of your arguments.
.modal-footer
button.btn.btn-default.pull-left(ng-click="$dismiss()") Dismiss
button.btn.btn-danger(ng-if="tpl.id" ng-click="$close({ remove: true })") remove
Expand Down
6 changes: 3 additions & 3 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ app.run(['$rootScope', '$window', '$couchPotato', '$injector', '$state', '$http'
$rootScope.refreshInfo = function (cb) {
if (typeof cb != 'function') cb = function () { }

$http.get('/info').success(function (info) {
$rootScope.semaphore = info;
$http.get('/info').then(function (info) {
$rootScope.semaphore = info.data;
cb();
}).error(function () {
}).catch(function () {
cb(true);
});
}
Expand Down
7 changes: 4 additions & 3 deletions public/js/controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ define(function () {
}

$scope.checkUpdate = function () {
$http.get('/upgrade').success(function (upgrade) {
$http.get('/upgrade').then(function (response) {
var upgrade = response.data;
if (!upgrade) return;

if (upgrade.updateBody) {
Expand All @@ -25,10 +26,10 @@ define(function () {
scope: $scope
});

$http.post('/upgrade').success(function () {
$http.post('/upgrade').then(function () {
$scope.upgraded = true;
$scope.pollUpgrade(upgradeModal, 0);
}).error(function () {
}).catch(function () {
swal('Error upgrading', arguments, 'error');
});
}
Expand Down
20 changes: 10 additions & 10 deletions public/js/controllers/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ define(['controllers/projects/edit'], function () {
$scope.projects = [];

$scope.refresh = function ($lastEvents=true) {
$http.get('/projects').success(function (projects) {
$scope.projects = projects;
$http.get('/projects').then(function (response) {
$scope.projects = response.data;
});

if ($lastEvents == true) {
$eventsURL = '/events/last'
$eventsURL = '/events/last';
} else {
$eventsURL = '/events'
$eventsURL = '/events';
}

$http.get($eventsURL).success(function (events) {
$scope.events = events;
$http.get($eventsURL).then(function (response) {
$scope.events = response.data;
});
}

Expand All @@ -23,12 +23,12 @@ define(['controllers/projects/edit'], function () {
templateUrl: '/tpl/projects/add.html'
}).result.then(function (project) {
$http.post('/projects', project)
.success(function () {
.then(function () {
$scope.refresh();
}).error(function (data, status) {
swal('Error', 'Could not create project: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Could not create project: ' + response.status, 'error');
});
});
}, function () {});
}

$scope.refresh();
Expand Down
14 changes: 7 additions & 7 deletions public/js/controllers/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ define(function () {
$http.post('/auth/login', {
auth: user.auth,
password: pwd
}).success(function (data, status) {
}).then(function (response) {
$scope.status = "Login Successful";
window.location = document.baseURI;
}).error(function (data, status) {
if (status == 400) {
}).catch(function (response) {
if (response.status === 400) {
// Login Failed
$scope.status = data.message;
if (!data.message) {
$scope.status = "Invalid login"
$scope.status = response.data.message;
if (!response.data.message) {
$scope.status = "Invalid login";
}

return;
}

$scope.status = status + ' Request Failed. Try again later.';
$scope.status = response.status + ' Request Failed. Try again later.';
});
}
}]);
Expand Down
26 changes: 13 additions & 13 deletions public/js/controllers/projects/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@ define(['controllers/projects/taskRunner'], function() {
app.registerController('ProjectDashboardCtrl', ['$scope', '$http', 'Project', '$uibModal', '$rootScope', function($scope, $http, Project, $modal, $rootScope) {

$scope.refreshEvents = function($lastEvents=true) {

var $eventsURL;
if ($lastEvents == true) {
$eventsURL = '/events/last'
$eventsURL = '/events/last';
} else {
$eventsURL = '/events'
$eventsURL = '/events';
}

$http.get(Project.getURL() + $eventsURL).success(function(events) {
$scope.events = events;
$http.get(Project.getURL() + $eventsURL).then(function(events) {
$scope.events = events.data;

events.forEach(function(evt) {
events.data.forEach(function(evt) {
evt.createdFormatted = moment(evt.created).format('DD/M/YY HH:mm')
})
});
});

}

$scope.reload = function($lastEvents=true) {

var $tasksURL;
if ($lastEvents == true) {
$tasksURL = '/tasks/last'
$tasksURL = '/tasks/last';
} else {
$tasksURL = '/tasks'
$tasksURL = '/tasks';
}

$http.get(Project.getURL() + $tasksURL).success(function(tasks) {
$scope.tasks = tasks;
$http.get(Project.getURL() + $tasksURL).then(function(tasks) {
$scope.tasks = tasks.data;

$scope.tasks.forEach(function(t) {
if (t.created) {
Expand Down Expand Up @@ -64,7 +64,7 @@ define(['controllers/projects/taskRunner'], function() {
size: 'lg'
}).result.then(function() {
$scope.reload();
});
}, function () {});
}
}]);
});
8 changes: 4 additions & 4 deletions public/js/controllers/projects/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ define(function () {
$scope.alert_chat = Project.alert_chat;

$scope.save = function (name, alert, alert_chat) {
$http.put(Project.getURL(), { name: name, alert: alert, alert_chat: alert_chat}).success(function () {
$http.put(Project.getURL(), { name: name, alert: alert, alert_chat: alert_chat}).then(function () {
swal('Saved', 'Project settings saved.', 'success');
}).error(function () {
}).catch(function () {
swal('Error', 'Project settings were not saved', 'error');
});
}
Expand All @@ -21,9 +21,9 @@ define(function () {
confirmButtonColor: "#DD6B55",
confirmButtonText: 'Yes, DELETE'
}, function () {
$http.delete(Project.getURL()).success(function () {
$http.delete(Project.getURL()).then(function () {
$state.go('dashboard');
}).error(function () {
}).catch(function () {
swal('error', 'could not delete project!', 'error');
});
});
Expand Down
29 changes: 15 additions & 14 deletions public/js/controllers/projects/environment.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
define(function () {
app.registerController('ProjectEnvironmentCtrl', ['$scope', '$http', '$uibModal', 'Project', '$rootScope', function ($scope, $http, $modal, Project, $rootScope) {
$scope.reload = function () {
$http.get(Project.getURL() + '/environment?sort=name&order=asc').success(function (environment) {
$scope.environment = environment;
$http.get(Project.getURL() + '/environment?sort=name&order=asc').then(function (environment) {
$scope.environment = environment.data;
});
}

$scope.remove = function (environment) {
$http.delete(Project.getURL() + '/environment/' + environment.id).success(function () {
$http.delete(Project.getURL() + '/environment/' + environment.id).then(function () {
$scope.reload();
}).error(function (d) {
}).catch(function (response) {
var d = response.data;
if (!(d && d.inUse)) {
swal('error', 'could not delete environment..', 'error');
return;
Expand All @@ -23,9 +24,9 @@ define(function () {
confirmButtonColor: "#DD6B55",
confirmButtonText: 'Mark as removed'
}, function () {
$http.delete(Project.getURL() + '/environment/' + environment.id + '?setRemoved=1').success(function () {
$http.delete(Project.getURL() + '/environment/' + environment.id + '?setRemoved=1').then(function () {
$scope.reload();
}).error(function () {
}).catch(function () {
swal('error', 'could not delete environment..', 'error');
});
});
Expand All @@ -43,12 +44,12 @@ define(function () {
scope: scope
}).result.then(function (env) {
$http.post(Project.getURL() + '/environment', env.environment)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Environment not added: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Environment not added: ' + response.status, 'error');
});
});
}, function () {});
}

$scope.editEnvironment = function (env) {
Expand All @@ -64,12 +65,12 @@ define(function () {
}

$http.put(Project.getURL() + '/environment/' + env.id, opts.environment)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Environment not updated: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Environment not updated: ' + response.status, 'error');
});
});
}, function () {});
}

$scope.reload();
Expand Down
41 changes: 21 additions & 20 deletions public/js/controllers/projects/inventory.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
define(function () {
app.registerController('ProjectInventoryCtrl', ['$scope', '$http', '$uibModal', 'Project', '$rootScope', function ($scope, $http, $modal, Project, $rootScope) {
$scope.reload = function () {
$http.get(Project.getURL() + '/inventory?sort=name&order=asc').success(function (inventory) {
$scope.inventory = inventory;
$http.get(Project.getURL() + '/inventory?sort=name&order=asc').then(function (inventory) {
$scope.inventory = inventory.data;
});
}

$scope.remove = function (inventory) {
$http.delete(Project.getURL() + '/inventory/' + inventory.id).success(function () {
$http.delete(Project.getURL() + '/inventory/' + inventory.id).then(function () {
$scope.reload();
}).error(function (d) {
}).catch(function (response) {
var d = response.data;
if (!(d && d.inUse)) {
swal('error', 'could not delete inventory..', 'error');
return;
Expand All @@ -23,9 +24,9 @@ define(function () {
confirmButtonColor: "#DD6B55",
confirmButtonText: 'Mark as removed'
}, function () {
$http.delete(Project.getURL() + '/inventory/' + inventory.id + '?setRemoved=1').success(function () {
$http.delete(Project.getURL() + '/inventory/' + inventory.id + '?setRemoved=1').then(function () {
$scope.reload();
}).error(function () {
}).catch(function () {
swal('error', 'could not delete inventory..', 'error');
});
});
Expand All @@ -42,12 +43,12 @@ define(function () {
scope: scope
}).result.then(function (inventory) {
$http.post(Project.getURL() + '/inventory', inventory.inventory)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Inventory not added: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Inventory not added: ' + response.status, 'error');
});
});
}, function () {});
});
}

Expand All @@ -67,12 +68,12 @@ define(function () {
}

$http.put(Project.getURL() + '/inventory/' + inventory.id, opts.inventory)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Inventory not updated: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Inventory not updated: ' + response.status, 'error');
});
});
}, function () {});
});
}

Expand All @@ -86,19 +87,19 @@ define(function () {
}).result.then(function (v) {
inventory.inventory = v;
$http.put(Project.getURL() + '/inventory/' + inventory.id, inventory)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Inventory not updated: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Inventory not updated: ' + response.status, 'error');
});
});
}, function () {});
}

$scope.getKeys = function (cb) {
if (typeof cb != 'function') cb = function () {}

$http.get(Project.getURL() + '/keys?type=ssh').success(function (keys) {
cb(keys);
$http.get(Project.getURL() + '/keys?type=ssh').then(function (keys) {
cb(keys.data);
});
}

Expand Down

0 comments on commit 4916435

Please sign in to comment.