Browse Source

Fix component definitions to work with minifying

pull/1/head
Jack 6 years ago
parent
commit
2f5156c198
Signed by: foltik <jack@foltz.io> GPG Key ID: 303F88F996E95541
3 changed files with 67 additions and 73 deletions
  1. +10
    -12
      public/js/shimapan/components/LoginComp.js
  2. +11
    -13
      public/js/shimapan/components/RegisterComp.js
  3. +46
    -48
      public/js/shimapan/components/UploadComp.js

+ 10
- 12
public/js/shimapan/components/LoginComp.js View File

@@ -1,15 +1,13 @@
function LoginController($scope, AuthService) {
$scope.login = function() {
AuthService.login({
username: $scope.username,
password: $scope.password
}).then(function() {
alert('Logged In');
});
}
}

angular.module('LoginComp', ['AuthSvc']).component('loginComponent', {
templateUrl: '/views/shimapan/login-form.html',
controller: LoginController
controller: ['$scope', 'AuthService', function ($scope, AuthService) {
$scope.login = function () {
AuthService.login({
username: $scope.username,
password: $scope.password
}).then(function () {
alert('Logged In');
});
}
}]
});

+ 11
- 13
public/js/shimapan/components/RegisterComp.js View File

@@ -1,16 +1,14 @@
function RegisterController($scope, AuthService) {
$scope.register = function() {
AuthService.register({
username: $scope.username,
password: $scope.password,
invite: $scope.invite
}).then(function() {
alert('Registered');
});
};
}

angular.module('RegisterComp', ['AuthSvc']).component('registerComponent', {
templateUrl: '/views/shimapan/register-form.html',
controller: RegisterController
controller: ['$scope', 'AuthService', function ($scope, AuthService) {
$scope.register = function () {
AuthService.register({
username: $scope.username,
password: $scope.password,
invite: $scope.invite
}).then(function () {
alert('Registered');
});
};
}]
});

+ 46
- 48
public/js/shimapan/components/UploadComp.js View File

@@ -1,55 +1,53 @@
function UploadController($scope, Upload, $timeout, AuthService) {
$scope.errToString = function(err) {
if (err === 'maxSize')
return "File too large.";
else
return err;
};
angular.module('UploadComp', ['ngFileUpload', 'AuthSvc']).component('uploadComponent', {
templateUrl: '/views/shimapan/upload-form.html',
controller: ['$scope', 'Upload', '$timeout', 'AuthService', function ($scope, Upload, $timeout, AuthService) {
$scope.errToString = function (err) {
if (err === 'maxSize')
return "File too large.";
else
return err;
};

$scope.uploadFiles = function(files, errorFiles) {
$scope.files = $scope.files ? $scope.files.concat(files) : files;
$scope.errorFiles = $scope.errorFiles ? $scope.errorFiles.concat(errorFiles) : errorFiles;
$scope.uploadFiles = function (files, errorFiles) {
$scope.files = $scope.files ? $scope.files.concat(files) : files;
$scope.errorFiles = $scope.errorFiles ? $scope.errorFiles.concat(errorFiles) : errorFiles;

angular.forEach(files, function (file) {
file.upload = Upload.upload({
url: '/api/upload',
method: 'POST',
headers: {
'Authorization': AuthService.getAuthHeader()
},
file: file
});
angular.forEach(files, function (file) {
file.upload = Upload.upload({
url: '/api/upload',
method: 'POST',
headers: {
'Authorization': AuthService.getAuthHeader()
},
file: file
});

file.upload.then(
function (response) {
$timeout(function () {
file.result = response.data;
});
},
function (response) {
if (response.status !== 200) {
if (response.status === 401) {
file.$error = "Invalid authorization token";
} else if (response.status === 403) {
file.$error = "Forbidden";
} else {
file.$error = "Unknown error " + response.status;
file.upload.then(
function (response) {
$timeout(function () {
file.result = response.data;
});
},
function (response) {
if (response.status !== 200) {
if (response.status === 401) {
file.$error = "Invalid authorization token";
} else if (response.status === 403) {
file.$error = "Forbidden";
} else {
file.$error = "Unknown error " + response.status;
}
var index = $scope.files.indexOf(file);
$scope.errorFiles.push(file);
$scope.files.splice(index, 1);
}
var index = $scope.files.indexOf(file);
$scope.errorFiles.push(file);
$scope.files.splice(index, 1);
},
function (evt) {
file.progress = Math.floor(Math.min(100.0, 100 * evt.loaded / evt.total));
}
},
function (evt) {
file.progress = Math.floor(Math.min(100.0, 100 * evt.loaded / evt.total));
}
);
});
};
}

angular.module('UploadComp', ['ngFileUpload', 'AuthSvc']).component('uploadComponent', {
templateUrl: '/views/shimapan/upload-form.html',
controller: UploadController,
);
});
};
}],
controllerAs: 'vm'
});

Loading…
Cancel
Save