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

Migrate groups fetch to ocs api #9296

Merged
merged 2 commits into from
Apr 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions apps/workflowengine/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,21 @@
}
var self = this;
$.ajax({
url: OC.generateUrl('settings/users/groups'),
url: OC.linkToOCS('cloud/groups', 2) + 'details',
dataType: 'json',
quietMillis: 100,
}).success(function(response) {
// add admin groups
$.each(response.data.adminGroups, function(id, group) {
self.groups.push({ id: group.id, displayname: group.name });
});
// add groups
$.each(response.data.groups, function(id, group) {
self.groups.push({ id: group.id, displayname: group.name });
});
if (data.ocs.data.groups && data.ocs.data.groups.length > 0) {

data.ocs.data.groups.forEach(function(group) {
self.groups.push({ id: group.id, displayname: group.displayname });
})
self.render();

} else {
OC.Notification.error(t('workflowengine', 'Group list is empty'), { type: 'error' });
console.log(data);
}
}).error(function(data) {
OC.Notification.error(t('workflowengine', 'Unable to retrieve the group list'), { type: 'error' });
console.log(data);
Expand Down Expand Up @@ -368,9 +370,11 @@
});
}

this.collection.fetch({data: {
this.collection.fetch({
data: {
'class': classname
}});
}
});
this.collection.once('sync', this.render, this);
},
add: function() {
Expand Down
21 changes: 12 additions & 9 deletions settings/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,19 @@ OC.Settings = _.extend(OC.Settings, {
if ($elements.length > 0) {
// Let's load the data and THEN init our select
$.ajax({
url: OC.generateUrl('/settings/users/groups'),
url: OC.linkToOCS('cloud/groups', 2) + 'details',
dataType: 'json',
success: function(data) {
var results = [];

// add groups
if (!options.excludeAdmins) {
$.each(data.data.adminGroups, function(i, group) {
results.push({id:group.id, displayname:group.name});
});
if (data.ocs.data.groups && data.ocs.data.groups.length > 0) {

data.ocs.data.groups.forEach(function(group) {
if (!options.excludeAdmins || group.id !== 'admin') {
results.push({ id: group.id, displayname: group.displayname });
}
$.each(data.data.groups, function(i, group) {
results.push({id:group.id, displayname:group.name});
});
})

// note: settings are saved through a "change" event registered
// on all input fields
$elements.select2(_.extend({
Expand Down Expand Up @@ -80,6 +79,10 @@ OC.Settings = _.extend(OC.Settings, {
return m;
}
}, extraOptions || {}));
} else {
OC.Notification.show(t('settings', 'Group list is empty'), { type: 'error' });
console.log(data);
}
},
error: function(data) {
OC.Notification.show(t('settings', 'Unable to retrieve the group list'), { type: 'error' });
Expand Down