Skip to content

Commit

Permalink
Merge pull request #58 from owncloud/multiple-imports-2
Browse files Browse the repository at this point in the history
Multiple imports without jQuery foo
  • Loading branch information
Raghu Nayyar committed Nov 28, 2015
2 parents 94c0382 + a7b9c7f commit 4b25d56
Show file tree
Hide file tree
Showing 46 changed files with 148 additions and 7,170 deletions.
104 changes: 58 additions & 46 deletions css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,83 @@
*/

#app-settings .settings-fieldset .settings-fieldset-interior input {
width: 90%;
width: 90%;
}
#app-settings .settings-fieldset .settings-fieldset-interior select {
width: 40%;
width: 40%;
}
#app-settings .settings-fieldset .settings-upload {
position: absolute;
top: 12.5px;
width: 100%;
display: block;
height: 25.88235px;
font-weight: 300;
font-size: 14px;
cursor: pointer;
z-index: 10;
padding: 7.33333px 0 0 0 !important;
text-align: center;
border: 1px solid rgba(190, 190, 190, 0.9);
background-position: 5%;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;
border-radius: 3px;
position: absolute;
top: 12.5px;
width: 100%;
display: block;
height: 25.88235px;
font-weight: 300;
font-size: 14px;
cursor: pointer;
z-index: 10;
padding: 7.33333px 0 0 0 !important;
text-align: center;
border: 1px solid rgba(190, 190, 190, 0.9);
background-position: 5%;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;
border-radius: 3px;
}
#app-settings .settings-fieldset .settings-fieldset-interior-item:hover {
background: transparent;
background: transparent;
}
#app-settings .settings-fieldset .settings-fieldset-interior-upload {
width: 95%;
height: 55px;
width: 95%;
height: 55px;
}
#app-settings .settings-fieldset .settings-fieldset-interior-upload input {
position: absolute;
top: 18px;
position: absolute;
top: 18px;
}
#app-settings .settings-fieldset .settings-fieldset-interior input[type="file"] {
top: 12.5px;
position: absolute;
width: 100%;
height: 33.21569px;
padding: 0;
font-size: 16px;
margin-left: 0px;
overflow: hidden;
z-index: 20;
opacity: 0;
top: 12.5px;
position: absolute;
width: 100%;
height: 33.21569px;
padding: 0;
font-size: 16px;
margin-left: 0px;
overflow: hidden;
z-index: 20;
opacity: 0;
}

.dialog .table {
width: 100%;
-webkit-transition: 0.05s ease-out 0.05s;
-moz-transition: 0.05s ease-out 0.05s;
-ms-transition: 0.05s ease-out 0.05s;
transition: 0.05s ease-out 0.05s;
width: 100%;
-webkit-transition: 0.05s ease-out 0.05s;
-moz-transition: 0.05s ease-out 0.05s;
-ms-transition: 0.05s ease-out 0.05s;
transition: 0.05s ease-out 0.05s;
}
.dialog .table .name {
padding-left: 20px;
padding-left: 20px;
}
.dialog .table .dialog-select {
width: 100%;
width: 100%;
}
.dialog .table:hover {
background: #ddd;
-webkit-transition: 0.05s ease-out 0.05s;
-moz-transition: 0.05s ease-out 0.05s;
-ms-transition: 0.05s ease-out 0.05s;
transition: 0.05s ease-out 0.05s;
background: #ddd;
-webkit-transition: 0.05s ease-out 0.05s;
-moz-transition: 0.05s ease-out 0.05s;
-ms-transition: 0.05s ease-out 0.05s;
transition: 0.05s ease-out 0.05s;
}

#importdialog .buttongroup button {
padding: 10px;
}

#importdialog .loading {
background-position: 2px;
}

#importdialog .loading.disabled {
background-color: #6c8fc0;
}
72 changes: 30 additions & 42 deletions js/app/controllers/settingscontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,64 +22,52 @@
*/

/**
* Controller: SettingController
* Description: Takes care of the Calendar Settings.
*/
* Controller: SettingController
* Description: Takes care of the Calendar Settings.
*/

app.controller('SettingsController', ['$scope', '$rootScope', 'Restangular', 'CalendarModel','UploadModel', 'DialogModel',
function ($scope, $rootScope, Restangular, CalendarModel, UploadModel, DialogModel) {
'use strict';
$scope.files = [];

$scope.settingsCalDavLink = OC.linkToRemote('caldav') + '/';
$scope.settingsCalDavPrincipalLink = OC.linkToRemote('caldav') + '/principals/' + escapeHTML(encodeURIComponent(oc_current_user)) + '/';

// have to use the native HTML call for filereader to work efficiently
var importinput = document.getElementById('import');
var reader = new FileReader();

$scope.upload = function () {
UploadModel.upload();
$scope.files = [];
};
var reader = new FileReader();

$rootScope.$on('fileAdded', function (e, call) {
$scope.files.push(call);
$scope.$apply();
if ($scope.files.length > 0) {
var file = importinput.files[0];
reader.onload = function(e) {
$scope.filescontent = reader.result;
};
reader.readAsText(file);
DialogModel.initsmall('#importdialog');
DialogModel.open('#importdialog');
}
$scope.$digest(); // TODO : Shouldn't digest reset scope for it to be implemented again and again?
$('#import').on('change', function () {
$scope.calendarAdded(this);
});

$scope.importcalendar = function (id) {
$scope.calendarid = id;
$scope.calendarAdded = function (elem) {
$scope.files = elem.files;
$scope.$apply();
DialogModel.initsmall('#importdialog');
DialogModel.open('#importdialog');
};

$scope.pushcalendar = function (id, index) {
Restangular.one('calendars', $scope.calendarid).withHttpConfig({transformRequest: angular.identity}).customPOST(
$scope.filescontent,
'import',
undefined,
{
'Content-Type': 'text/calendar'
}
).then( function () {
$scope.files.splice(index,1);
DialogModel.close('#importdialog');
}, function (response) {
OC.Notification.show(t('calendar', response.data.message));
});
};
$scope.import = function (file) {
var reader = new FileReader();
file.isImporting = true;

reader.onload = function() {
Restangular.one('calendars', file.importToCalendar).withHttpConfig({transformRequest: angular.identity}).customPOST(
reader.result,
'import',
undefined,
{
'Content-Type': 'text/calendar'
}
).then( function () {
file.done = true;
}, function (response) {
OC.Notification.show(t('calendar', response.data.message));
});
};

$scope.removecalendar = function (index) {
$scope.files.splice(index,1);
reader.readAsText(file);
};

//to send a patch to add a hidden event again
Expand Down
44 changes: 0 additions & 44 deletions js/app/filters/uploadDirective.js

This file was deleted.

94 changes: 30 additions & 64 deletions js/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1033,64 +1033,52 @@ app.controller('EventsModalController', ['$scope', '$templateCache','$rootScope'
]);

/**
* Controller: SettingController
* Description: Takes care of the Calendar Settings.
*/
* Controller: SettingController
* Description: Takes care of the Calendar Settings.
*/

app.controller('SettingsController', ['$scope', '$rootScope', 'Restangular', 'CalendarModel','UploadModel', 'DialogModel',
function ($scope, $rootScope, Restangular, CalendarModel, UploadModel, DialogModel) {
'use strict';
$scope.files = [];

$scope.settingsCalDavLink = OC.linkToRemote('caldav') + '/';
$scope.settingsCalDavPrincipalLink = OC.linkToRemote('caldav') + '/principals/' + escapeHTML(encodeURIComponent(oc_current_user)) + '/';

// have to use the native HTML call for filereader to work efficiently
var importinput = document.getElementById('import');
var reader = new FileReader();

$scope.upload = function () {
UploadModel.upload();
$scope.files = [];
};
var reader = new FileReader();

$rootScope.$on('fileAdded', function (e, call) {
$scope.files.push(call);
$scope.$apply();
if ($scope.files.length > 0) {
var file = importinput.files[0];
reader.onload = function(e) {
$scope.filescontent = reader.result;
};
reader.readAsText(file);
DialogModel.initsmall('#importdialog');
DialogModel.open('#importdialog');
}
$scope.$digest(); // TODO : Shouldn't digest reset scope for it to be implemented again and again?
$('#import').on('change', function () {
$scope.calendarAdded(this);
});

$scope.importcalendar = function (id) {
$scope.calendarid = id;
$scope.calendarAdded = function (elem) {
$scope.files = elem.files;
$scope.$apply();
DialogModel.initsmall('#importdialog');
DialogModel.open('#importdialog');
};

$scope.pushcalendar = function (id, index) {
Restangular.one('calendars', $scope.calendarid).withHttpConfig({transformRequest: angular.identity}).customPOST(
$scope.filescontent,
'import',
undefined,
{
'Content-Type': 'text/calendar'
}
).then( function () {
$scope.files.splice(index,1);
DialogModel.close('#importdialog');
}, function (response) {
OC.Notification.show(t('calendar', response.data.message));
});
};
$scope.import = function (file) {
var reader = new FileReader();
file.isImporting = true;

reader.onload = function() {
Restangular.one('calendars', file.importToCalendar).withHttpConfig({transformRequest: angular.identity}).customPOST(
reader.result,
'import',
undefined,
{
'Content-Type': 'text/calendar'
}
).then( function () {
file.done = true;
}, function (response) {
OC.Notification.show(t('calendar', response.data.message));
});
};

$scope.removecalendar = function (index) {
$scope.files.splice(index,1);
reader.readAsText(file);
};

//to send a patch to add a hidden event again
Expand Down Expand Up @@ -1363,28 +1351,6 @@ app.filter('subscriptionFilter',
}
]);

app.directive('upload', ['UploadModel', function factory(UploadModel) {
'use strict';
return {
restrict: 'A',
link: function (scope, element, attrs) {
$(element).fileupload({
dataType: 'text',
add: function (e, data) {
UploadModel.add(data);
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
UploadModel.setProgress(progress);
},
done: function (e, data) {
UploadModel.setProgress(0);
}
});
}
};
}]);

/**
* Model:
* Description: Generates a random uid.
Expand Down
Loading

0 comments on commit 4b25d56

Please sign in to comment.