Merge pull request #9296 from nextcloud/migrate-groups-fetch-to-ocs-api
Migrate groups fetch to ocs api
This commit is contained in:
commit
5a4a0add3c
|
@ -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);
|
||||
|
@ -368,9 +370,11 @@
|
|||
});
|
||||
}
|
||||
|
||||
this.collection.fetch({data: {
|
||||
this.collection.fetch({
|
||||
data: {
|
||||
'class': classname
|
||||
}});
|
||||
}
|
||||
});
|
||||
this.collection.once('sync', this.render, this);
|
||||
},
|
||||
add: function() {
|
||||
|
|
|
@ -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({
|
||||
|
@ -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' });
|
||||
|
|
Loading…
Reference in New Issue