ide-repository.snapshot.js Maven / Gradle / Ivy
/*
* Copyright (c) 2010-2019 SAP and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* SAP - initial API and implementation
*/
/*globals angular, $ */
angular
.module('import', ['angularFileUpload'])
.factory('httpRequestInterceptor', function () {
return {
request: function (config) {
config.headers['X-Requested-With'] = 'Fetch';
return config;
}
};
})
.config(['$httpProvider', function($httpProvider) {
$httpProvider.interceptors.push('httpRequestInterceptor');
}])
.factory('$messageHub', [function(){
var messageHub = new FramesMessageHub();
var message = function(evtName, data){
messageHub.post({data: data}, 'properties.' + evtName);
};
var on = function(topic, callback){
messageHub.subscribe(callback, topic);
};
return {
message: message,
on: on
};
}])
.controller('ImportController', ['$scope', '$http', 'FileUploader', '$messageHub', function($scope, $http, FileUploader, $messageHub) {
$scope.TRANSPORT_SNAPSHOT_URL = "../../../../services/v3/transport/snapshot";
// FILE UPLOADER
var uploader = $scope.uploader = new FileUploader({
url: $scope.TRANSPORT_SNAPSHOT_URL
});
uploader.headers['X-Requested-With'] = 'Fetch';
// UPLOADER FILTERS
uploader.filters.push({
name: 'customFilter',
fn: function(item /*{File|FileLikeObject}*/, options) {
return this.queue.length < 100;
}
});
// UPLOADER CALLBACKS
uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/, filter, options) {
// console.info('onWhenAddingFileFailed', item, filter, options);
};
uploader.onAfterAddingFile = function(fileItem) {
};
uploader.onAfterAddingAll = function(addedFileItems) {
// console.info('onAfterAddingAll', addedFileItems);
};
uploader.onBeforeUploadItem = function(item) {
// console.info('onBeforeUploadItem', item);
item.url = $scope.TRANSPORT_SNAPSHOT_URL;
};
uploader.onProgressItem = function(fileItem, progress) {
// console.info('onProgressItem', fileItem, progress);
};
uploader.onProgressAll = function(progress) {
// console.info('onProgressAll', progress);
};
uploader.onSuccessItem = function(fileItem, response, status, headers) {
// console.info('onSuccessItem', fileItem, response, status, headers);
};
uploader.onErrorItem = function(fileItem, response, status, headers) {
// console.info('onErrorItem', fileItem, response, status, headers);
alert(response.err.message);
};
uploader.onCancelItem = function(fileItem, response, status, headers) {
// console.info('onCancelItem', fileItem, response, status, headers);
};
uploader.onCompleteItem = function(fileItem, response, status, headers) {
//refreshFolder();
// console.info('onCompleteItem', fileItem, response, status, headers);
};
uploader.onCompleteAll = function() {
// console.info('onCompleteAll');
};
$messageHub.on('workbench.theme.changed', function(msg){
var themeUrl = msg.data;
$('a[href="../../../../services/v3/core/theme/ide.css"]').remove();
$('').appendTo('head');
$('#theme-stylesheet').remove();
$('').appendTo('head');
}.bind(this));
}]);
© 2015 - 2025 Weber Informatics LLC | Privacy Policy