Hi, I have been recently googling around looking for some Angular directives to include in my app where came across [https://material.angularjs.org/latest/]) and thought that it would be helpful if is included to the project by default ;)
Thats it :)
that did not work!
Hi, I have got a service in Angular as below:
(function () {
angular.module('app').factory('workType', ['abp.services.app.workType',
function (workTypeService) {
var workType = this;
workType.loadWorkTypes = function () {
abp.ui.setBusy(
null,
workTypeService.getWorkTypeList()
.success(function (data)
return data.workTypes;
})
.error(function (message) {
abp.notify.error(message);
})
);
};
return workType;
}
]);
})();
and a controller as
(function () {
var controllerId = 'app.views.configuration.advertisementFields';
angular.module('app').controller(controllerId, ['workType',
function (workTypeService) {
var vm = this;
vm.loadWorkTypes = function () {
var data = workTypeService.loadWorkTypes();
}
}
]);
})();
Here is my web API code:
public GetWorkTypeListOutput GetWorkTypeList()
{
var workTypes = _workTypeRepository.GetAll().ToList();
var workTypeList = new GetWorkTypeListOutput()
{
WorkTypes = Mapper.Map<List<WorkTypeDto>>(workTypes)
};
return workTypeList;
}
When I call the web api through the angular service defined above, the returned data is undefined! I can see that it hit the web API though. I am pretty sure I am making a mistake in line below within the controller, but do not know how to fix it:
var data = workTypeService.loadWorkTypes();
If I call the Web API directly from the controller it will work fine. but I need to call it through a service/factory.
Hi, I have defined two permissions as bellow:
var advertisement = context.CreatePermission(PermissionNames.Advertisement);
advertisement.CreateChildPermission(PermissionNames.Advertisement_CreateAd, L("Advertisement.CreateAd"));
advertisement.CreateChildPermission(PermissionNames.Advertisement_ViewAd, L("Advertisement.ViewAd"));
I am not quite sure how they work though! I am wondering if a role with Advertisement Permission would be able to Create and View ads or I have to grant all three permissions to a role specifically?
Generally, I am wonder how I can grant all defined permissions to an Admin Role efficiently.
Hi, I have got a DTO class defined as:
[AutoMapFrom(typeof(WorkType))]
public class WorkTypeDto : EntityDto
{
public string DisplayName { get; set; }
public bool IsDeleted { get; set; }
public int OrderNumber { get; set; }
public User CreatorUser { get; set; }
}
[AbpAuthorize("Advertisement")]
public GetWorkTypeListOutput GetWorkTypeList()
{
var workTypes = _workTypeRepository.GetAll().ToList();
var workTypeList = new GetWorkTypeListOutput()
{
WorkTypes = Mapper.Map<List<WorkTypeDto>>(workTypes)
};
return workTypeList;
}
and my Angular code is:
vm.loadWorkTypes = function () {
abp.ui.setBusy(
null,
workTypeService.getWorkTypeList()
.success(function (data) {
vm.gridOptions.data = data.workTypes;
})
.error(function (message) {
alert(message);
})
);
};
it is properly populate the DTO to be passed to the Angular, but for some reason it fails without showing any descriptive error message as: [object obeject] and Internal error occurred!
I narrowed down the issue and found out that the CreatorUser property is causing it. If I change its type from User class to string that will work. Any thought?
Hi Thanks for your solution and sorry for the late response. Actually, I have replied but not sure where it has gone! I have got 2 questions followed by a request regarding your approach:
Thanks
Hi, I have just created a template through the aspnetboilerplate website and right after I have updated all libraries via Nuget update. In the created template the Configuration class extended ISupportSeedMode which seems was removed from the updated version of Abp.Zero.EntityFramework.
Regards,
Hi, Does anyone know that if its feasible to upload files using Dtos in the Application layer? If yes, can I have a sample code which shows how to define properties in DTO classes and how to call the service from AngularJS?
Thanks,
Hi Ibrahim, Thanks again for your advice. Now I have got another question: I am using [https://github.com/danialfarid/ng-file-upload]) to upload files via Angular. I am using the code below to send userId as a form data multipart along with the uploaded file to create a folder as per its value and then save the uploaded file:
file.upload = Upload.upload({
url: '/api/File/Upload',
data: {userId: appSession.user.id, file: file}
});
For the whole past day I have been struggling to fetch the form-data and get the posted userId so I could create a folder prior saving the file. Do you have any advice on:
I really appreciate your advice and thanks in advance... ;)
Hi, I have created an uploading WebApi in the WebApi project. I am using the Api from the Web project to upload files via AngularJS. I have also created a directory and named it as "Document". Here are my wonders:
Where should I define the Document folder (in the WebApi project or the Web one)? I assume it should be in the Web project where the client-side code resides. If my guess is true, then do not know how to point to a folder in the Web project from the WebApi project to save the file in?!
Thanks for your tips and advice in advance ... ;)