Joaquín Reñé
2026-03-27 4ee50e257b32f6ec0f72907305d1f2b1212808a4
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { Http } from '@angular/http';
import { ToastsManager } from 'ng2-toastr/ng2-toastr';
import { OrganizationsService } from '../resources/organizations';
import { LicenseTypesService } from '../resources/license_types';
import { LocaleService } from '../common/i18n';
import { TdDialogService } from '@covalent/core';
import { Component, AfterViewInit, ViewChild } from '@angular/core';
import { TdMediaService } from '@covalent/core';
import { FormBase, IComboOption } from './base';
import { ActivatedRoute, Router } from '@angular/router';
import { UsersService } from "../resources/users";
var app_example = { 
   code: 'CICS',
  creation_timestamp: 1418384439000,
  description: 'Wellbore integrity analysis software',
  id: 1,
  license_filename: 'config_server.lic',
  name: 'CurisIntegrity',
  metadata: 
   [ { key: 'max_docs',
       value: '250000',
       readonly: true,
       mandatory: true } ] 
}
@Component({
  selector: 'organization-form',
  templateUrl: 'src/app/forms/organization.form.html'
})
export class OrganizationFormComponent extends FormBase {
  parentOrganizations: any[];
  usernames: string[] = [];
  
  constructor(private http: Http,
              private licenseTypes: LicenseTypesService,
              private organizations: OrganizationsService,
              private users: UsersService,
              router: Router,
              toaster: ToastsManager,
              route: ActivatedRoute,              
              $L: LocaleService,
              dialogs: TdDialogService) {
    super($L, router, route, toaster, organizations, $L.get('organization'), dialogs);
  }
  loadCombos() : void {
      this.organizations.get()
        .map(list => list.map((org : any) => <IComboOption>{id: org.id, label: `(${org.code}) ${org.name}`}))
        .subscribe(
          data => this.parentOrganizations = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label)),
          err => console.error('Error loading organizations')
        );
      this.users.get()
        .map(list => list
                      .filter((user : any) => user.username !== '_client')
                      .map((u : any) => u.username))
        .subscribe(
          data => this.usernames = (<string[]>data).sort((u1, u2) => u1.localeCompare(u2)),
          err => console.error('Error loading users')
        );
  }
  goBack(): void {
    this.router.navigate([`organizations`]);
  }
  init() : void {
    this.loadCombos();
    super.setFirstFocus();
    super.reset();
    super.prepareInitialData('organizationId', {users_ids: []});
  }
 
  ngAfterViewInit(): void {
    this.init();
  }
}