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

Client upgraded permissions sub super #147

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions app/hardware/server/assign/assign.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
};
assign.client = {
modal: assignClientModal,
subSuperAccess: hasSubSuperAccess, //why doesnt this work?
};
assign.saveNickname = saveNickname;

Expand Down Expand Up @@ -62,5 +63,9 @@
function assignClientModal() {
return ServerAssignModal.client([assign.server], assign.server.access.sub);
}

function hasSubSuperAccess() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is a function, you would need to use assign.client.subSuperAccess() instead of assign.client.subSuperAccess to get the returned value from the function.

We'll need this implemented for real, what's the plan here? We would need to fetch this off of the authenticated user's account details. Since we'd be using this in multiple places, we may need to add another service to get & cache this information, or maybe we can cache it with the user details (like user name)?

return false; //why doesnt this work? putting false in above works but this doesnt.
}
}
})();
2 changes: 1 addition & 1 deletion app/hardware/server/assign/assign.pug
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include /resources/angle/pug/mixins/panel
th.shrink.v-mid(translate="server.assign.SRV_ID")
td(ng-bind="assign.server.srv_id")

tr
tr(ng-if="assign.client.subSuperAccess")
th.shrink.v-mid(translate="server.assign.client.TITLE")
td(ng-init="access = assign.server.access")
a(
Expand Down
20 changes: 20 additions & 0 deletions app/user/user.nav.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(function () {
'use strict';

angular
.module('app.user')
.config(NavConfig)
;

/**
* @ngInject
*/
function NavConfig(NavProvider) {
NavProvider
.group('user', {
translate: "nav.USERS",
sref: "app.account.settings",
icon: "fa fa-user",
});
}
})();
66 changes: 50 additions & 16 deletions app/user/user.sidebar.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,62 @@
(function () {
'use strict';

var MY_ACCOUNT = {
text: "My Account",
sref: "app.account.settings",
};

var SUB_CLIENTS = {
text: "Sub Clients",
sref: "app.user.client.sub.list",
};

var SUPER_CLIENTS = {
text: "Super Clients",
sref: "app.user.client.super.list",
};

angular
.module('app.user')
.config(NavConfig)
.run(UserSidebarShowWithPermissions)
;

/**
* @ngInject
*/
function NavConfig(NavProvider) {
NavProvider.group('user', {
translate: "nav.USERS",
sref: "app.account.settings",
icon: "fa fa-user",
}).item({
text: "My Account",
sref: "app.account.settings",
}).item({
text: "Sub Clients",
sref: "app.user.client.sub.list",
}).item({
text: "Super Clients",
sref: "app.user.client.super.list"
});
function UserSidebarShowWithPermissions(Auth, Select /*, Permission*/) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

permission can't be imported because this is the client side. Clients don't have permissions - only Admins & Integrations do. We need a way of getting this information off of the client account, e.g. GET /client/{authed ID}.

var userSidebar = this;
//Need to import Auth and Permission here. Why doesn't this work? in install.nav.config.js and search.tab.js
//this is used in seemingly the exact same way.
userSidebar.group = Select('group');
// var group = NavProvider.group('user', {
// translate: "nav.USERS",
// sref: "app.account.settings",
// icon: "fa fa-user",
// });

Auth.whileLoggedIn(showPermitted, hide);

// function show() {
// Permission
// .map()
// .then(showPermitted)
// ;
// }

function showPermitted(map) {
group.item(MY_ACCOUNT);

// if (showSubAndSuperClientPages) {
group.item(SUB_CLIENTS);
group.item(SUPER_CLIENTS);
// }
}

function hide() {
group.remove(MY_ACCOUNT);
group.remove(SUB_CLIENTS);
group.remove(SUPER_CLIENTS);
}
}
})();