summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/models/permissions.ts
blob: 3f2c87ed1a0fe109602775e1ff4f8c920674e7f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
export class Permission {
  read: boolean;
  create: boolean;
  update: boolean;
  delete: boolean;

  constructor(serverPermission: Array<string> = []) {
    ['read', 'create', 'update', 'delete'].forEach(
      (permission) => (this[permission] = serverPermission.includes(permission))
    );
  }
}

export class Permissions {
  hosts: Permission;
  configOpt: Permission;
  pool: Permission;
  osd: Permission;
  monitor: Permission;
  rbdImage: Permission;
  iscsi: Permission;
  rbdMirroring: Permission;
  rgw: Permission;
  cephfs: Permission;
  manager: Permission;
  log: Permission;
  user: Permission;
  grafana: Permission;
  prometheus: Permission;
  nfs: Permission;

  constructor(serverPermissions: any) {
    this.hosts = new Permission(serverPermissions['hosts']);
    this.configOpt = new Permission(serverPermissions['config-opt']);
    this.pool = new Permission(serverPermissions['pool']);
    this.osd = new Permission(serverPermissions['osd']);
    this.monitor = new Permission(serverPermissions['monitor']);
    this.rbdImage = new Permission(serverPermissions['rbd-image']);
    this.iscsi = new Permission(serverPermissions['iscsi']);
    this.rbdMirroring = new Permission(serverPermissions['rbd-mirroring']);
    this.rgw = new Permission(serverPermissions['rgw']);
    this.cephfs = new Permission(serverPermissions['cephfs']);
    this.manager = new Permission(serverPermissions['manager']);
    this.log = new Permission(serverPermissions['log']);
    this.user = new Permission(serverPermissions['user']);
    this.grafana = new Permission(serverPermissions['grafana']);
    this.prometheus = new Permission(serverPermissions['prometheus']);
    this.nfs = new Permission(serverPermissions['nfs-ganesha']);
  }
}