Commit a1369def authored by Servan42's avatar Servan42
Browse files

Cleared some code, logs are still there, WIP.

parent 4d48183b
......@@ -32,6 +32,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
filesCtrl.selectedDelivrable = null;
filesCtrl.showFileUploadWindow = function(val){
console.log("filesCtrl.showFileUploadWindow called", val);
filesCtrl.selectedDelivrable = null;
filesCtrl.showFileUpload = val;
filesCtrl.currentScreen='fileUpload' ;
......@@ -41,6 +42,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.initStandardUploader = function(){
console.log("filesCtrl.initStandardUploader called");
if($scope.uploaderReady) return;
$scope.uploaderReady = true;
$.getScript("https://apis.google.com/js/api.js");
......@@ -60,6 +62,8 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
init: {
PostInit: function() {
console.log("filesCtrl.initStandardUploader.PostInit called");
//alert("init");
$("#integrations").detach().appendTo(".plupload_buttons");
......@@ -67,10 +71,12 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
$(".plupload_start").hide();
},
FilesAdded: function(up, files, info) {
console.log("filesCtrl.initStandardUploader.FilesAdded called", up, files, info);
up.start();
},
FileUploaded: function(up, file, info) {
console.log("filesCtrl.initStandardUploader.FileUploaded called", up, file, info);
if (JSON.parse(info.response).error) {
file.status = plupload.FILE_SIZE_ERROR;
}
......@@ -83,6 +89,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
},
Error: function(up, args) {
console.log("filesCtrl.initStandardUploader.Error called", up, args);
// Called when error occurs
if (args.code==-600) $alertFactory.processAlert("error", 400533, "uploadFile");
else $alertFactory.processAlert("error", 400, "uploadFile");
......@@ -91,6 +98,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
},
ChunkUploaded: function(up, file, info) {
console.log("filesCtrl.initStandardUploader.ChunkUploaded called", up, file, info);
console.log('[ChunkUploaded] File:', JSON.stringify(file), "Info:", JSON.stringify(info));
}
}
......@@ -102,6 +110,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
filesCtrl.initCloudUploader = function(){
console.log("filesCtrl.initCloudUploader called");
if(filesCtrl.uploaderReady) return;
filesCtrl.uploaderReady = true;
$.getScript("https://apis.google.com/js/api.js");
......@@ -119,6 +128,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
init: {
PostInit: function() {
console.log("filesCtrl.initCloudUploader.PostInit called");
//alert("init");
$("#integrations").detach().appendTo(".plupload_buttons");
......@@ -126,13 +136,16 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
$(".plupload_start").hide();
},
FilesAdded: function(up, file, info) {
console.log("filesCtrl.initCloudUploader.FilesAdded called", up, file, info);
$fileFactory.getUploadUrl($scope._getProject(),function(data){
$("#pluploadUploader").pluploadQueue().settings.url = data.details;
up.start();
})
},
FileUploaded: function(up, file, info) {
console.log("filesCtrl.initCloudUploader.FileUploaded called", up, file, info);
if (JSON.parse(info.response).error) {
file.status = plupload.FILE_SIZE_ERROR;
}
......@@ -144,6 +157,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
},
ChunkUploaded: function(up, file, info) {
console.log("filesCtrl.initCloudUploader.ChunkUploaded called", up, file, info);
// Called when file chunk has finished uploading
console.log('[ChunkUploaded] File:', JSON.stringify(file), "Info:", JSON.stringify(info));
}
......@@ -155,6 +169,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.initUploader = function(){
console.log("filesCtrl.initUploader called");
$fileFactory.getMaxUploadSize(function(data) {
if (data.status == "success") {
filesCtrl.maxFileSize = data.details;
......@@ -175,15 +190,17 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
filesCtrl.browseFile = function(deliverable){
console.log("filesCtrl.browseFile called", deliverable);
console.log("clic");
}
filesCtrl.pickDrive = function(deliverable){
console.log("filesCtrl.pickDrive called", deliverable);
console.log("click")
$integrationsFactory.checkStatus($scope,$http,{apiScope:["drive"],provider:"GOOGLE"});
}
filesCtrl.onFileUploaded = function(file,list){
console.log("filesCtrl.onFileUploaded called", file, list);
var data = {};
if(file.origin=="GOOGLE"){
$("#pluploadForm").hide();
......@@ -206,6 +223,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.addFolder = function(folder,list){
console.log("filesCtrl.addFolder called", folder, list);
var data = {};
if(folder=="." || folder=="..") return false;
data.file = {target_name:$scope._hashCode((new Date()).getTime()+folder),name:folder,size:"0",lastModifiedDate:(new Date()).getTime(),type:"folder"};
......@@ -221,6 +239,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
filesCtrl.formatFiles = function(data,list,params){
console.log("filesCtrl.formatFiles called", data, list, params);
var fileNames = [];
data.details.sort(function(a,b){
......@@ -257,7 +276,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.getFiles = function(folderId,list){
console.log("getFiles called", folderId, list);
console.log("filesCtrl.getFiles called", folderId, list);
//filesCtrl.currentScreen='fileList'
filesCtrl.refreshQuota();
list = [];
......@@ -280,31 +299,10 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
$scope._showAlert({status:3,message:$languageFactory._labels.alerts_loadingFilesFailure});
}
})
// The code right under is not a good solution to display the inherited files in the children project
// because inherited files are already dislayed in the children project, marked with a special icon,
// if and only if there is already at least one file in the children project.
// Getting the files from the parent project
/*
if($scope._getProjectParent()){
$fileFactory.get_file_getFiles($scope._getProjectParent().id,folderId,false,function(data){
if(data.status == "success"){
filesCtrl.parentFolder = null;
filesCtrl.currentFile.id = folderId;
filesCtrl.formatFiles(data,list,{});
}
else{
$scope._showAlert({status:3,message:$languageFactory._labels.alerts_loadingFilesFailure});
}
})
}
*/
}
filesCtrl.selectFile = function(file){
console.log("selectFile called", file);
console.log("filesCtrl.selectFile called", file);
if(filesCtrl.selectedFile!=file){
if(!file){
$rightMenuFactory.openRightMenu(filesCtrl.listDelivrables, 'deliverables')
......@@ -335,7 +333,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
file.actions=actions;
file.factory=$fileFactory;
console.log(file.factory);
console.log("file.factory", file.factory);
filesCtrl.selectedFile=file;
$rightMenuFactory.openRightMenu(file, 'details');
}
......@@ -347,10 +345,11 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.getFileInfos = function(file){
console.log("filesCtrl.getFileInfos called", file);
console.log("on récup les infos");
if(!file.id || file.id=="0") return filesCtrl.getFile(file);
$fileFactory.get_file_details($scope._getProject(), file.id, function(data){
console.log(data);
console.log("data", data);
filesCtrl.getFile(data.details[0]);
if(file.type=="folder") filesCtrl.selectedFile = null;
});
......@@ -358,6 +357,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.previewFile = function(file,showThumbnail){
console.log("filesCtrl.previewFile called", file, showThumbnail);
if(filesCtrl.loading) return;
filesCtrl.loading = true;
$fileFactory.get_file_previewFile($scope._getProject(),file.name, file.id, file.fileName,showThumbnail,function(data){
......@@ -375,6 +375,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.downloadFile=function(file,url){
console.log("filesCtrl.downloadFile called", file, url);
if(url){
window.prompt("Url du fichier", $scope._urls.server+"download.php?fileName="+file.fileName+"&name="+file.name);
}
......@@ -385,7 +386,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
filesCtrl.getFile = function(file,url){
console.log("getFile called");
console.log("filesCtrl.getFile called", file, url);
if(file.type=="folder"){
//filesCtrl.currentScreen='fileList';
if(file.name==".."){
......@@ -398,7 +399,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
filesCtrl.filePath.push(file)
filesCtrl.currentFolder += "/"+file.name;
}
console.log(filesCtrl.currentScreen);
console.log("filesCtrl.currentScreen", filesCtrl.currentScreen);
}
filesCtrl.getFiles(file.id,[]);
......@@ -424,6 +425,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.refreshQuota = function (){
console.log("filesCtrl.refreshQuota called");
$projectFactory.getProjectQuotas($scope._getProject(), function(data){
if(data.status == "success"){
filesCtrl.quotas= data.details[0];
......@@ -432,14 +434,14 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.deleteFile = function(file){
console.log("Calling filesCtrl.deleteFile with the following parameter:", file);
console.log("filesCtrl.deleteFile called", file);
filesCtrl.fileToDelete=file;
filesCtrl.confirmDeletion=true;
}
filesCtrl.delete=function(){
console.log("Calling filesCtrl.delete");
console.log("filesCtrl.delete called");
if(filesCtrl.fileToDelete){
var file=filesCtrl.fileToDelete;
$scope._showAlert({status:2,message:$languageFactory._labels.alerts_deleteFile});
......@@ -462,6 +464,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.postComment = function(data,file){
console.log("filesCtrl.postComment called", data, file);
$fileFactory.post_file_addFileComment($scope._getProject(), file.id, filesCtrl.comment.content,function(data){
if(data.status == "success"){
filesCtrl.getComments(file);
......@@ -474,6 +477,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.getComments = function(file){
console.log("filesCtrl.getComments called", file);
$fileFactory.get_file_getFileComments($scope._getProject(), file.id, function(data){
if(data.status == "success"){
file.comments = data.details;
......@@ -491,6 +495,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
filesCtrl.renameFilePrompt = function(){
console.log("filesCtrl.renameFilePrompt called");
var name="";
filesCtrl.stopEvent=true;
var index = filesCtrl.selectedFile.name.lastIndexOf(".");
......@@ -504,6 +509,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.copyFilePrompt = function(){
console.log("filesCtrl.copyFilePrompt called");
var name = filesCtrl.selectedFile.name
var index = name.lastIndexOf(".");
name = name.substring(0,index)+"_copy"+name.substring(index);
......@@ -525,6 +531,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.openFoldersTree = function(callback){
console.log("filesCtrl.openFoldersTree called", callback);
$fileFactory.get_folder_tree($scope._getProject(),function(data){
if(data.status == "success"){
filesCtrl.foldersTree = data.details;
......@@ -536,6 +543,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.moveFilePrompt = function(){
console.log("filesCtrl.moveFilePrompt called");
filesCtrl.openFoldersTree(filesCtrl.moveFile);
}
......@@ -563,6 +571,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
});
filesCtrl.renameFile = function(newName){
console.log("filesCtrl.renameFile called", newName);
$fileFactory.post_file_renameFile($scope._getProject(),filesCtrl.selectedFile.id, newName,function(data){
if(data.status == "success"){
var id;
......@@ -574,6 +583,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.moveFile = function(fileId,newParentId){
console.log("filesCtrl.moveFile called", fileId, newParentId);
var session = $scope._getSession();
if(!fileId) fileId = filesCtrl.selectedFile.id;
if(!newParentId) newParentId = filesCtrl.foldersTreeSelectedElement.id;
......@@ -588,38 +598,45 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.backToFileList = function(){
console.log("filesCtrl.backToFileList called");
//filesCtrl.currentScreen='fileList';
filesCtrl.selectedFile = null;
filesCtrl.showFileUpload=false;
}
filesCtrl.selectFolderTree = function(element){
console.log("filesCtrl.selectFolderTree called", element);
filesCtrl.foldersTreeSelectedElement = element;
if(element.open) element.open = false;
else element.open = true;
}
filesCtrl.submitFolderTree = function(){
console.log("filesCtrl.submitFolderTree called");
filesCtrl.selectFolderTreeCallback();
$("#foldersTree").hide();
}
filesCtrl.cancelFolderTree = function(){
console.log("filesCtrl.cancelFolderTree called");
filesCtrl.selectFolderTreeCallback = null;
filesCtrl.foldersTreeSelectedElement = null;
$("#foldersTree").hide();
}
filesCtrl.closeModalPreview = function(){
console.log("filesCtrl.closeModalPreview called");
filesCtrl.getFiles(filesCtrl.currentFile.id,[]);
filesCtrl.previewUrls = null;
}
filesCtrl.showNewFolder = function(mode){
console.log("filesCtrl.showNewFolder called", mode);
filesCtrl.showPopup=true;
filesCtrl.popupMode=mode;
}
filesCtrl.cancelManager=function(){
console.log("filesCtrl.cancelManager called");
filesCtrl.showPopup=false;
filesCtrl.confirmDeletion=false;
}
......@@ -630,12 +647,13 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
filesCtrl.getDeliverables = function(){
console.log("filesCtrl.getDeliverables called");
var session = $scope._getSession();
//get_deliverable_getDeliverableRequestsByProject
//
$deliverableFactory.get_deliverable_getDeliverableRequestsByProject($scope._getProject(),function(data){
console.log(data.details);
console.log("data.details", data.details);
//filesCtrl.listDelivrables = data.details[0].map(function(a){a.type="deliverable";return a});
if($scope._userGroups[$scope._getSession().group]=='STUDENT'){
filesCtrl.listDelivrables=$deliverableFactory.formatAllDeliverablesRequests(data.details,"student");
......@@ -646,16 +664,18 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
console.log(filesCtrl.listDelivrables);
console.log("filesCtrl.listDelivrables", filesCtrl.listDelivrables);
$rightMenuFactory.openRightMenu(filesCtrl.listDelivrables, 'deliverables');
});
}
filesCtrl.init = function(){
console.log("filesCtrl.init called");
/*var h = $(window).height();
$("#fileList").css("height", h-200)*/
$("#fileList").css("height", h-200)*/
$integrationsFactory.onStatusReceived($scope,"GOOGLE",function(result){
......@@ -694,7 +714,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
};
filesCtrl.isSelected=function(file){
console.log("filesCtrl.isSelected called", file);
if(filesCtrl.selectedFile && (file.id==filesCtrl.selectedFile.id)){
return "selected";
}
......@@ -705,6 +725,7 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}
filesCtrl.setScreen=function(screen){
console.log("filesCtrl.setScreen called", screen);
filesCtrl.currentScreen=screen;
}
/*if($scope._getProject()) filesCtrl.init("");
......@@ -717,7 +738,6 @@ root.controller('FileOverviewCtrl', ['$scope', '$stateParams','$http','$dropList
}])
function getSize(value){
value = parseInt(value);
......@@ -731,10 +751,6 @@ function getSize(value){
}
root.filter("getSize", function() { // register new filter
return getSize;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment