2015-07-09 23:01:43 +01:00
|
|
|
export class FilesController {
|
2015-08-08 20:37:49 +01:00
|
|
|
constructor($scope, UserService, EventService, files) {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.$root.user = UserService.get();
|
2015-08-23 22:12:32 +01:00
|
|
|
files.$promise.then(() => {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.$root.loadingView = false;
|
|
|
|
});
|
|
|
|
$scope.header = 'full';
|
|
|
|
if (!$scope.$root.files) {
|
|
|
|
$scope.$root.files = files;
|
|
|
|
}
|
2015-08-23 22:12:32 +01:00
|
|
|
$scope.remove = (file) => {
|
|
|
|
$scope.$root.files.some((existingFile, index) => {
|
2015-07-09 23:01:43 +01:00
|
|
|
if (file.id === existingFile.id) {
|
2015-08-23 22:12:32 +01:00
|
|
|
file.$remove(() => {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.$root.showDropdown = false;
|
|
|
|
$scope.$root.files.splice(index, 1);
|
|
|
|
});
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2015-08-08 20:37:49 +01:00
|
|
|
FilesController.$inject = ['$scope', 'UserService', 'EventService', 'files'];
|
2015-07-09 23:01:43 +01:00
|
|
|
|
|
|
|
export class FileController {
|
2015-08-23 22:12:32 +01:00
|
|
|
constructor($scope, $rootScope, $routeParams, ReconnectingWebSocket, file) {
|
|
|
|
file.$promise.then(() => {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.$root.loadingView = false;
|
|
|
|
$scope.header = 'small';
|
|
|
|
$scope.file = file;
|
|
|
|
$scope.direct = '/file/' + file.id + '/' + file.name;
|
|
|
|
$rootScope.pageTitle = ' - ' + file.name;
|
|
|
|
if (file.status === 'uploading') {
|
|
|
|
file.percent = 0;
|
2015-08-23 22:12:32 +01:00
|
|
|
const ws = new ReconnectingWebSocket(window.settings.apiURL.replace(/^http/, 'ws') + '/file/' + file.id);
|
|
|
|
ws.onmessage = (msg) => {
|
|
|
|
const evt = JSON.parse(msg.data);
|
2015-07-09 23:01:43 +01:00
|
|
|
$rootScope.$broadcast(evt.type, evt.data);
|
|
|
|
};
|
2015-08-23 22:12:32 +01:00
|
|
|
ws.onopen = () => {
|
2015-07-09 23:01:43 +01:00
|
|
|
ws.send(JSON.stringify({authorization: window.user.token}));
|
|
|
|
};
|
2015-08-23 22:12:32 +01:00
|
|
|
$rootScope.$on('file-progress', (evt, data) => {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.file.percent = data.complete;
|
|
|
|
});
|
2015-08-23 22:12:32 +01:00
|
|
|
$rootScope.$on('file-added', (evt, data) => {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.file = data;
|
|
|
|
});
|
2015-08-23 22:12:32 +01:00
|
|
|
$rootScope.$on('file-accepted', (evt, data) => {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.file = data;
|
|
|
|
});
|
|
|
|
}
|
2015-08-23 22:12:32 +01:00
|
|
|
}, () => {
|
2015-07-09 23:01:43 +01:00
|
|
|
$rootScope.navError = true;
|
|
|
|
$scope.$root.loadingView = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FileController.$inject = ['$scope', '$rootScope', '$routeParams', 'WebSocket', 'file'];
|
|
|
|
|
|
|
|
export class ProController {
|
2015-08-23 22:12:32 +01:00
|
|
|
constructor($scope, $http, UserService) {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.$root.loadingView = false;
|
|
|
|
$scope.user = UserService.get();
|
|
|
|
$scope.header = 'full';
|
2015-08-23 22:12:32 +01:00
|
|
|
$scope.cancel = () => {
|
2016-08-07 14:38:05 +01:00
|
|
|
$http.delete(window.settings.apiURL + '/user/pro').success(() => {
|
2015-07-09 23:01:43 +01:00
|
|
|
window.location.reload(true);
|
2015-08-23 22:12:32 +01:00
|
|
|
}).error((data) => {
|
|
|
|
console.error(new Error(data));
|
2015-07-09 23:01:43 +01:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ProController.$inject = ['$scope', '$http', 'UserService'];
|
|
|
|
|
|
|
|
export class AccountController {
|
2015-08-23 22:12:32 +01:00
|
|
|
constructor($scope, UserService, SettingService) {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.$root.loadingView = false;
|
|
|
|
$scope.$root.user = UserService.get();
|
2015-08-23 22:12:32 +01:00
|
|
|
$scope.submit = (form) => {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.updated = false;
|
|
|
|
$scope.error = false;
|
2015-08-23 22:12:32 +01:00
|
|
|
SettingService.update(form).then(() => {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.updated = true;
|
|
|
|
delete $scope.user.new_password;
|
|
|
|
delete $scope.user.current_password;
|
2015-08-23 22:12:32 +01:00
|
|
|
}, (response) => {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.error = response.data.error.message;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AccountController.$inject = ['$scope', 'UserService', 'SettingService'];
|
|
|
|
|
|
|
|
export class BillingController {
|
2015-08-23 22:12:32 +01:00
|
|
|
constructor($scope, UserService, TransactionService) {
|
2015-07-09 23:01:43 +01:00
|
|
|
$scope.$root.loadingView = false;
|
|
|
|
$scope.$root.user = UserService.get();
|
|
|
|
$scope.transactions = TransactionService.query();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BillingController.$inject = ['$scope', 'UserService', 'TransactionService'];
|