Closed andrewpros closed 2 years ago
"normal" is a very stretchable term :-) The whole admin area is built with angularjs and APIs, so yes. Use angularjs and apis. But if you need to manipulate data like CRUD / GRID View with edits buttons that's what LUYA Admin is very strong, use ngrest to generate those views within seconds and add custom buttons (active buttons), modals (active windows) for the CRUD.
So maybe you give us a little bit more of what you are trying to do.
https://luya.io/guide/lesson-admin-custom-angular-view yes, this explains how to create a view, and fetch data from the rest api.
Well by normal i meant the classic html forms get/post/response without any js, so my bad, didn't check the docs thoroughly before using the project as the answer is then, no, it doesn't supports it.
I dont need the CRUD, it will all be manual functions.
But ok, maybe i will somehow manage, i dont need much of UI, but the provided sample also don't work.
There is no return value, it is again docs issue?
Something missing here?
<div ng-if="dataResponse">
The time is:
</div>
Also when i change $http.get to .post it gives me an error
"Bad Request","message":"Unable to verify your data submission." i had it before when i tried to do the classic yii forms due to csrf. Not sure it is the same here.
I think the luya.io docs removed the angular part ... wow, was not aware of that:
For post requests just disable Yii2 Framework csrf check in the controller. Should not be a problem in the admin anyhow.
public $enableCsrfValidation = false;
Thx, for now i will keep this open.
What is the recommended way to add an admin page with GET parameter and generate link to it?
I have a admin module page with offers list, it is under a url
http://localhost:8080/admin#!/default/6/importeradmin/importer/offers
What would be a link to offer detail here with GET param, is this correct? (its after hash so no real GET here anyway)
http://localhost:8080/admin#!/default/6/importeradmin/importer/offer?nr=56089
nr is the offer id
But how to generate that page for the offers page, seems like no way server side? I mean i can just copy paste to check, but it is # so no GET params at all, how to deal with this, any ideas?
The goal is here also to be able to directly go to offer details page without the need to go to offer list first.
i would need to test my self, but aslong as you use the angularjs router ui-sref
you should also be able to read the data in angularjs (https://github.com/luyadev/luya/blob/master/docs/guide/app-admin-module-dashboardobjects.md#links-with-ui-sref). but you can also access the admin controllers with http://localhost:8080/importeradmin/importer/offers?id=X
then you can resolve the query params.
Yeah i found the data in the link u provided in the src when i was looking for anything how it works.
But still not sure how to setup this.
I can call http://localhost:8080/importeradmin/importer/offers?id=X but then its not loading the theme at all, its just blank page with data, but it works for now.
I just dont know angular and i didn't know i would need it, i can build everything, but if i only knew it requires angular :-), just most universal frameworks like this dont assume any client framework knowledge and stick to classic mvc.
Also im not sure, but it uses angularjs that lost support? Are the any plans to upgrade to something else? Even if i had time to learn it now, what the point if angularjs 1.x will be obsolete soon.
I wish there was more docs or example integrations, like this one, two controllers, master detail, how to connect this all so it just works.
We have started working on LUYA in year 2015, its 7 years ago. Concept was born 2014, when angularjs was the new kid in the block :-)
No need to learn it anymore indeed, even certain things are close to vue (which would be my preferred technology nowadays).
I will check if i can make a small example, for you and put on luya.io
I wish there was more docs or example integrations
yes i totally agree with you. We have answered so many questions to so many different people using LUYA, but people never come back and send a PR with an example or tutorial for guide. Also we don't. Because if you understood how it works, there is no need to make a step backwards :-)
Here is an example of how you could try to read the state params, but unless you register your self an asset which injects a new state (route) you have to extract the params by yourself:
<script>
zaa.bootstrap.register('MyController', ['$scope', '$state', function($scope, $state) {
$scope.resolver = false
$scope.getState = function() {
$scope.resolver = $state.params
};
$scope.getState();
}]);
</script>
<div ng-controller="MyController">
<a ui-sref="custom({ templateId: 'foobaradmin/finder/index?foo=1'})">Click Ui SREF</a>
<button type="button" ng-click="getState()">Resolve Current</button>
<hr />
{{ resolver | json }}
</div>
The "custom" ui-sref is not working.
This almost works ui-sref="default.route.detail({moduleId: 5, moduleRouteId:'importeradmin', controllerId:'importer', actionId:'offer', id: '<?= $offer['nr']; ?>'})"
But it is still not loading the data and it cannot as it is after #, so its client only, i will need to wire it thru api call one way or another, well angularjs this is how it works, i can get the params in the ng-click, not sure what's with the direct link with param already, im getting js error a.currentItem is undefined.
I will tinker with it more, for now i will just stick to the blank page with data if i need.
This is the kind of ingratiation would be nice to have some docs. I dont believe no one haven't done it. It a classic master detail, but with angularjs in the mix.
Not saying u should upgrade to vue, i meant the old one is angularjs, the current supported iteration is just "angular", so i guess if there are plans to upgrade, this is the best way, upgrade to angular.
Yeah and i know what u mean with the PR and examples, its hard, its just the docs are good, but have like minor inconsistencies here and there, small things, but u need to tinker a while to discover what it should be, just not up to date with the latest LUYA code i guess, some small things missing or not exact the commands u need, but very close, yeah and the little lack of some basic examples like that master/detail thing.
Even now i already have issues to remembering all the small things i discovered, i regret i didn't note everything i found, now it will be harder for me to backtrack it. But i will try when the time comes.
Not saying u should upgrade to vue, i meant the old one is angularjs, the current supported iteration is just "angular", so i guess if there are plans to upgrade, this is the best way, upgrade to angular.
The "problem" is that they have fully changed the approach on how things work. It seems rather hard to mix angular with html/php like we do with angularjs or it would be possible view VUE. So Angular is completely different to angularjs, no way to upgrade. Sadly ....
Maybe we i could put your example into the guide, so there would be more example code. Any, absolute any, small improvement to the guide is very welcome. We know there are some things missing, but we don't know where :-) So please send a PR with any, even very small, improvements. So you have documented all your things directly in the official guide. We could even make a new guide page where you can put your full example if you like.
Didn't know it's that of a big of difference and there no docs about the architecture, how it connects yii2 with angularjs internally. Also some things are connected the the fact im using it with docker and wsl2. The last thing i found out was that the deployer code in kickstarter4 was outdated, the 2.0 deployer is better, things like that. I will try to do something later, but now im busy with work.
Well ok, i can only check and find things.
I can technically use the ngRest CRUD build in functionality, but it needs to be exactly how it wants things and its not possible to change anything i want or just make a simple master detail without it.
Normally it is needed to use an api with angularjs for both, the list and list item detail, thats fine.
What i found out to this day
Thanks for the report.
ngRest cannot be created from the admin/create command if i use different database than the main one, and i use a secondary one, workaround is to just create it with some of the main tables and then edit it
True, we should make a --db option
ngRest is already using the master detail with angularjs, there is a Detail button already there, all wired up to angularjs, have not seen docs about it, it works as it is already in the stateProvider states with the detail route
We also have Active Windows, there is a default detail viewer for rows, but not sure this is what you need. https://luya.io/api/luya-admin-aws-DetailViewActiveWindow
There is no access to the states as it turns out admin module is using very old 0.4
I will check to updated to 1.0.30 (https://github.com/angular-ui/ui-router) thanks!
There is no docs for AdminToastService
Im just not sure the ui-router can be updated to a more recent version without any breaking changes to the admin module, but yes, the later versions do expose $stateProvider out of the box.
Also i probably need to explain what i mean by saying "there is no docs".
Im not saying there is no docs in the code, cuz most of the times it is, there is just no mention in the guide for this things, so to know they even exist u need to stumble upon them in the luya code when u look for how it works internally.
For example there is no mention of AdminToastService in the guide and it cannot be found by using the search, but u will not search for it if u dont know it exists, i only found it out by reading the internal js code.
FYI: I did a quick test with latest angularjs router today and its really almost impossible to upgrade. It seems there are routing annotations which have changed and this would break all luya modules using this annotation (especially the cms module).
Yeah, this is what i was expecting more or less, well maybe not that bad, i will check things myself too, the ui-router has pretty good migration docs, not sure about what "annotations" we are talking about.
But as i said, the easy fix if all fails or is to much work to do is to just expose some things into the zaa module like $controllerProvider.
Finally i did find something, i didn't use cms module as i don't need it, i didn't even read much about it, but when u mentioned it, i did check it and it turns out, it is doing basically what i want to be able to do more or less, the code of the cms module seems to be the best guide for this kind of things as it is using in fact the admin module and it connects to the angularjs functionality, u have must known this, why didn't u told me this, i wish i know sooner.
I did some tests before like calling the zaa config again, it didn't work, but it was in the script tag in the view just like the angular controller code, but in the cms module it is in a separate js file and this way it just works, don't know why it makes a difference, but it does and its probably the way angular works.
The cms code helps a lot, im still not there to do it "the right way", but im close.
I am going to close this issue because:
If you think this is still important or there are more/new informations. Please reopen the issue and let us know.
If this is a problem or a feature you like to discuss, join our discussion: LUYA discussions. We try to keep our issue tracker as clean as possible in order to focus on active issues.
Yeah ok, i still plan to address it, but had no time.
@andrewpros feel free to reopen the issue, or let me know if i can help. We currently have a similar problem: no time :-)
Is there any guide to just use classic MVC style controller flow in and admin module or a im forced to use the angular way, with mandatory ajax and all of that? Just Post/Redirect/Get
I wanted just a simple Debug button in the admin panel to trigger some code tests, but trying to do this i realised there is no real docs about it.
Sample view
https://i.imgur.com/GXWeRyS.png
Seems the only docs i found is this https://luya.io/guide/lesson-admin-custom-angular-view but its not the standard MVC