mirror of https://github.com/bitwarden/web.git
16 changed files with 172 additions and 62 deletions
@ -1 +1 @@
@@ -1 +1 @@
|
||||
Subproject commit ff8c1dfea9a3a6e42e2191dd3816889ce43045e0 |
||||
Subproject commit 278b4402da94ab36b4def76f520599a23308f7f1 |
||||
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
<ng-container *ngIf="vault"> |
||||
<p *ngIf="!loaded" class="text-muted"> |
||||
<i class="fa fa-spinner fa-spin"></i> |
||||
</p> |
||||
<ng-container *ngIf="loaded"> |
||||
<ul class="fa-ul card-ul carets" *ngIf="organizations && organizations.length"> |
||||
<li *ngFor="let o of organizations"> |
||||
<a [routerLink]="['/organizations', o.id]" class="text-body"> |
||||
<i class="fa-li fa fa-caret-right"></i> {{o.name}} |
||||
</a> |
||||
</li> |
||||
</ul> |
||||
<p *ngIf="!organizations || !organizations.length">{{'noOrganizationsList' | i18n}}</p> |
||||
</ng-container> |
||||
<a href="#" routerLink="/settings/create-organization" class="btn btn-block btn-outline-primary"> |
||||
<i class="fa fa-plus fa-fw"></i> |
||||
{{'newOrganization' | i18n}} |
||||
</a> |
||||
</ng-container> |
||||
<ng-container *ngIf="!vault"> |
||||
<div class="page-header d-flex"> |
||||
<h1> |
||||
{{'organizations' | i18n}} |
||||
<small [appApiAction]="actionPromise" #action> |
||||
<i class="fa fa-spinner fa-spin text-muted" *ngIf="action.loading"></i> |
||||
</small> |
||||
</h1> |
||||
<a href="#" routerLink="/settings/create-organization" class="btn btn-sm btn-outline-primary ml-auto"> |
||||
<i class="fa fa-plus fa-fw"></i> |
||||
{{'newOrganization' | i18n}} |
||||
</a> |
||||
</div> |
||||
<i class="fa fa-spinner fa-spin text-muted" *ngIf="!loaded"></i> |
||||
<ng-container *ngIf="loaded"> |
||||
<p *ngIf="!organizations || !organizations.length">{{'noOrganizationsList' | i18n}}</p> |
||||
<table class="table table-hover table-list" *ngIf="organizations && organizations.length"> |
||||
<tbody> |
||||
<tr *ngFor="let o of organizations"> |
||||
<td width="30"> |
||||
<app-avatar [data]="o.name" width="25" height="25" [circle]="true" [fontSize]="14"></app-avatar> |
||||
</td> |
||||
<td> |
||||
<a href="#" [routerLink]="['/organizations', o.id]">{{o.name}}</a> |
||||
</td> |
||||
<td class="table-list-options"> |
||||
<div class="dropdown" appListDropdown> |
||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
||||
<i class="fa fa-cog fa-lg"></i> |
||||
</button> |
||||
<div class="dropdown-menu dropdown-menu-right"> |
||||
<a class="dropdown-item text-danger" href="#" appStopClick (click)="leave(o)"> |
||||
<i class="fa fa-fw fa-sign-out"></i> |
||||
{{'leave' | i18n}} |
||||
</a> |
||||
</div> |
||||
</div> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
</table> |
||||
</ng-container> |
||||
</ng-container> |
||||
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
import { |
||||
Component, |
||||
Input, |
||||
OnInit, |
||||
} from '@angular/core'; |
||||
|
||||
import { ToasterService } from 'angular2-toaster'; |
||||
import { Angulartics2 } from 'angulartics2'; |
||||
|
||||
import { ApiService } from 'jslib/abstractions/api.service'; |
||||
import { I18nService } from 'jslib/abstractions/i18n.service'; |
||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; |
||||
import { SyncService } from 'jslib/abstractions/sync.service'; |
||||
import { UserService } from 'jslib/abstractions/user.service'; |
||||
|
||||
import { Organization } from 'jslib/models/domain/organization'; |
||||
|
||||
@Component({ |
||||
selector: 'app-organizations', |
||||
templateUrl: 'organizations.component.html', |
||||
}) |
||||
export class OrganizationsComponent implements OnInit { |
||||
@Input() vault = false; |
||||
|
||||
organizations: Organization[]; |
||||
loaded: boolean = false; |
||||
actionPromise: Promise<any>; |
||||
|
||||
constructor(private userService: UserService, private platformUtilsService: PlatformUtilsService, |
||||
private i18nService: I18nService, private apiService: ApiService, |
||||
private analytics: Angulartics2, private toasterService: ToasterService, |
||||
private syncService: SyncService) { } |
||||
|
||||
async ngOnInit() { |
||||
await this.load(); |
||||
} |
||||
|
||||
async load() { |
||||
this.organizations = await this.userService.getAllOrganizations(); |
||||
this.loaded = true; |
||||
} |
||||
|
||||
async leave(org: Organization) { |
||||
const confirmed = await this.platformUtilsService.showDialog( |
||||
this.i18nService.t('leaveOrganizationConfirmation'), org.name, |
||||
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning'); |
||||
if (!confirmed) { |
||||
return false; |
||||
} |
||||
|
||||
try { |
||||
this.actionPromise = this.apiService.postLeaveOrganization(org.id).then(() => { |
||||
return this.syncService.fullSync(true); |
||||
}); |
||||
await this.actionPromise; |
||||
this.analytics.eventTrack.next({ action: 'Left Organization' }); |
||||
this.toasterService.popAsync('success', null, this.i18nService.t('leftOrganization')); |
||||
await this.load(); |
||||
} catch { } |
||||
} |
||||
} |
||||
@ -1,17 +0,0 @@
@@ -1,17 +0,0 @@
|
||||
<p *ngIf="!loaded" class="text-muted"> |
||||
<i class="fa fa-spinner fa-spin"></i> |
||||
</p> |
||||
<ng-container *ngIf="loaded"> |
||||
<ul class="fa-ul card-ul carets" *ngIf="organizations && organizations.length"> |
||||
<li *ngFor="let o of organizations"> |
||||
<a [routerLink]="['/organizations', o.id]" class="text-body"> |
||||
<i class="fa-li fa fa-caret-right"></i> {{o.name}} |
||||
</a> |
||||
</li> |
||||
</ul> |
||||
<p *ngIf="!organizations || !organizations.length">{{'noOrganizationsList' | i18n}}</p> |
||||
</ng-container> |
||||
<a href="#" routerLink="/settings/create-organization" class="btn btn-block btn-outline-primary"> |
||||
<i class="fa fa-plus fa-fw"></i> |
||||
{{'newOrganization' | i18n}} |
||||
</a> |
||||
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
import { |
||||
Component, |
||||
OnInit, |
||||
} from '@angular/core'; |
||||
|
||||
import { UserService } from 'jslib/abstractions/user.service'; |
||||
|
||||
import { Organization } from 'jslib/models/domain/organization'; |
||||
|
||||
@Component({ |
||||
selector: 'app-vault-organizations', |
||||
templateUrl: 'organizations.component.html', |
||||
}) |
||||
export class OrganizationsComponent implements OnInit { |
||||
organizations: Organization[]; |
||||
loaded: boolean = false; |
||||
|
||||
constructor(private userService: UserService) { } |
||||
|
||||
async ngOnInit() { |
||||
await this.load(); |
||||
} |
||||
|
||||
async load() { |
||||
this.organizations = await this.userService.getAllOrganizations(); |
||||
this.loaded = true; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue