forked from dimac/test-project-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (34 loc) · 1.57 KB
/
app.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
"use strict";
angular.module('app', ['httpAPIMock'])
.controller('ApiTestController', function ($scope, $http) {
function logExample(title, promise) {
return promise.then(function (response) {
console.log(title, '\n', response.config.method, response.config.url, response.config.data, response.status, '\nResponse:', response.data);
return response;
}).catch(function(response){
console.error(title, '\n', response.config.method, response.config.url, response.config.data, response.status, '\nResponse:', response.data);
})
}
logExample('Rename',
$http.post('/api/files/rename', {from: '/image-2.jpg', to: '/image-3.jpg'})
);
logExample('Rename directory',
$http.post('/api/files/rename', {from: '/my-vacation', to: '/vacation'})
);
logExample('Rename: source file doesn\'t exist',
$http.post('/api/files/rename', {from: '/image-does-not-exist.jpg', to: '/image-2.jpg'})
);
logExample('Rename: Target file already exists',
$http.post('/api/files/rename', {from: '/image-0.jpg', to: '/image-10.jpg'})
);
logExample('List root directory', $http.get('/api/files'))
.then(function (response) {
$scope.files = response.data;
});
logExample('List directory',
$http.get('/api/files?path=/vacation')
);
logExample('List single file',
$http.get('/api/files?path=/image-0.jpg')
);
});