Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ng-admin custom page, loading before how we can check login or not ? #10

Open
banandam opened this issue May 6, 2016 · 2 comments
Open

Comments

@banandam
Copy link

banandam commented May 6, 2016

Hi,

Dashboard custom page login after reload the page, dashboard related api url called but token not set.

How we can handle this ?

@akagadovskiy
Copy link
Owner

Hi. Please provide more details.

@banandam
Copy link
Author

banandam commented May 9, 2016

Thanks for reply

Dashboard page, i implemented by directive.

  1. After login we refresh the page, token not yet set in api request. so unable to get data. how we can set token in api request ?
  2. Token payload not set as user "Role". So i need to get another one request for user detail. How can i change it ?

Sample code :

Menu

admin.menu(nga.menu()
.addChild(nga.menu().title("dashboard").icon('').link('/dashboard'))

Template

var dashboardTpl = '

' +
'

Dashboard

' +
'';
admin.dashboard(nga.dashboard()
.template(dashboardTpl)
);

Directive

ngapp.directive('dashboardSummary', ['$location', '$state', '$http', function ($location, $state, $http) {
return {
restrict: 'E',
scope: {
entity: "&",
entityName: "@",
entry: "&",
size: "@",
label: "@",
revenueDetails: "&"
},
templateUrl: '../ag-admin/tpl/dashboardSummary.tpl.html',
link: function (scope) {
scope.rangeVal = [{
"key": "lastDays",
"value": "Last 7 Days"
}, {
"key": "lastWeeks",
"value": "Last 4 Weeks"
}, {
"key": "lastMonths",
"value": "Last 3 Months"
}, {
"key": "lastYears",
"value": "Last 3 Years"
}];
if (scope.rangeText === undefined) {
scope.rangeText = "Last 7 Days";
}
scope.selectedRangeItem = function (rangeVal, rangeText) {
$http.get(admin_api_url + '/api/admin/stats', {
params: {
filter: rangeVal
}
}).success(function (response) {
scope.adminstats = response;
scope.rangeText = rangeText;
});
};
$http.get(admin_api_url + '/api/admin/stats').success(function (response) {
scope.adminstats = response;
});
$http.get(admin_api_url + '/api/admin/activities').success(function (response) {
scope.adminactivities = response;
});
$http.get(admin_api_url + '/api/admin/settings/site.version/show').success(function (response) {
scope.siteversion = response.settings[0];
});
}
};
}]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants