mirror of
https://github.com/bitwarden/browser
synced 2026-01-05 18:13:26 +00:00
org user apis, sort function utils
This commit is contained in:
@@ -59,6 +59,7 @@ import { IdentityTokenResponse } from '../models/response/identityTokenResponse'
|
||||
import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse';
|
||||
import { ListResponse } from '../models/response/listResponse';
|
||||
import { OrganizationResponse } from '../models/response/organizationResponse';
|
||||
import { OrganizationUserUserDetailsResponse } from '../models/response/organizationUserResponse';
|
||||
import { ProfileResponse } from '../models/response/profileResponse';
|
||||
import { SyncResponse } from '../models/response/syncResponse';
|
||||
import { TwoFactorAuthenticatorResponse } from '../models/response/twoFactorAuthenticatorResponse';
|
||||
@@ -425,6 +426,13 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
return this.send('DELETE', '/groups/' + id, null, true, false);
|
||||
}
|
||||
|
||||
// Organization User APIs
|
||||
|
||||
async getOrganizationUsers(organizationId: string): Promise<ListResponse<OrganizationUserUserDetailsResponse>> {
|
||||
const r = await this.send('GET', '/organizations/' + organizationId + '/users', null, true, true);
|
||||
return new ListResponse(r, OrganizationUserUserDetailsResponse);
|
||||
}
|
||||
|
||||
// Sync APIs
|
||||
|
||||
async getSync(): Promise<SyncResponse> {
|
||||
|
||||
@@ -10,6 +10,8 @@ import { I18nService } from '../abstractions/i18n.service';
|
||||
import { StorageService } from '../abstractions/storage.service';
|
||||
import { UserService } from '../abstractions/user.service';
|
||||
|
||||
import { Utils } from '../misc/utils';
|
||||
|
||||
const Keys = {
|
||||
collectionsPrefix: 'collections_',
|
||||
};
|
||||
@@ -51,7 +53,7 @@ export class CollectionService implements CollectionServiceAbstraction {
|
||||
promises.push(collection.decrypt().then((c) => decCollections.push(c)));
|
||||
});
|
||||
await Promise.all(promises);
|
||||
return decCollections.sort(this.getLocaleSortingFunction());
|
||||
return decCollections.sort(Utils.getSortFunction(this.i18nService, 'name'));
|
||||
}
|
||||
|
||||
async get(id: string): Promise<Collection> {
|
||||
@@ -145,21 +147,4 @@ export class CollectionService implements CollectionServiceAbstraction {
|
||||
await this.storageService.save(Keys.collectionsPrefix + userId, collections);
|
||||
this.decryptedCollectionCache = null;
|
||||
}
|
||||
|
||||
getLocaleSortingFunction(): (a: CollectionView, b: CollectionView) => number {
|
||||
return (a, b) => {
|
||||
if (a.name == null && b.name != null) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name != null && b.name == null) {
|
||||
return 1;
|
||||
}
|
||||
if (a.name == null && b.name == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.i18nService.collator ? this.i18nService.collator.compare(a.name, b.name) :
|
||||
a.name.localeCompare(b.name);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import { StorageService } from '../abstractions/storage.service';
|
||||
import { UserService } from '../abstractions/user.service';
|
||||
import { CipherData } from '../models/data/cipherData';
|
||||
|
||||
import { Utils } from '../misc/utils';
|
||||
|
||||
const Keys = {
|
||||
foldersPrefix: 'folders_',
|
||||
ciphersPrefix: 'ciphers_',
|
||||
@@ -82,7 +84,7 @@ export class FolderService implements FolderServiceAbstraction {
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
decFolders.sort(this.getLocaleSortingFunction());
|
||||
decFolders.sort(Utils.getSortFunction(this.i18nService, 'name'));
|
||||
|
||||
const noneFolder = new FolderView();
|
||||
noneFolder.name = this.i18nService.t('noneFolder');
|
||||
@@ -180,21 +182,4 @@ export class FolderService implements FolderServiceAbstraction {
|
||||
await this.apiService.deleteFolder(id);
|
||||
await this.delete(id);
|
||||
}
|
||||
|
||||
private getLocaleSortingFunction(): (a: FolderView, b: FolderView) => number {
|
||||
return (a, b) => {
|
||||
if (a.name == null && b.name != null) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name != null && b.name == null) {
|
||||
return 1;
|
||||
}
|
||||
if (a.name == null && b.name == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.i18nService.collator ? this.i18nService.collator.compare(a.name, b.name) :
|
||||
a.name.localeCompare(b.name);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user