#3527 fix - Added applications forms and metadata component
1 files deleted
25 files modified
| .. | .. |
|---|
| 33 | 33 | // For dev. using JS in different server |
|---|
| 34 | 34 | res.addHeader("Access-Control-Allow-Origin", "*"); |
|---|
| 35 | 35 | //res.addHeader("Access-Control-Request-Headers", "*"); |
|---|
| 36 | | - res.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, OPTIONS"); |
|---|
| 36 | + res.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); |
|---|
| 37 | 37 | res.addHeader("Access-Control-Allow-Headers", "X-SECURIS-TOKEN, Content-Type"); |
|---|
| 38 | 38 | res.addHeader("Access-Control-Expose-Headers", "X-SECURIS-ERROR-MSG, X-SECURIS-ERROR-CODE, Content-Type"); |
|---|
| 39 | 39 | |
|---|
| .. | .. |
|---|
| 17 | 17 | |
|---|
| 18 | 18 | import com.fasterxml.jackson.annotation.JsonAutoDetect; |
|---|
| 19 | 19 | import com.fasterxml.jackson.annotation.JsonBackReference; |
|---|
| 20 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|---|
| 20 | 21 | import com.fasterxml.jackson.annotation.JsonInclude; |
|---|
| 21 | 22 | import com.fasterxml.jackson.annotation.JsonInclude.Include; |
|---|
| 22 | 23 | import com.fasterxml.jackson.annotation.JsonProperty; |
|---|
| .. | .. |
|---|
| 29 | 30 | @JsonInclude(Include.NON_NULL) |
|---|
| 30 | 31 | @Entity |
|---|
| 31 | 32 | @Table(name = "application_metadata") |
|---|
| 32 | | -@NamedQueries({ |
|---|
| 33 | | - @NamedQuery(name = "list-application-metadata", query = "SELECT a FROM ApplicationMetadata a where a.application.id = :applicationId") |
|---|
| 34 | | -}) |
|---|
| 33 | +@JsonIgnoreProperties(value = { "readonly" }) |
|---|
| 34 | +@NamedQueries({ @NamedQuery(name = "list-application-metadata", query = "SELECT a FROM ApplicationMetadata a where a.application.id = :applicationId") }) |
|---|
| 35 | 35 | public class ApplicationMetadata implements Serializable { |
|---|
| 36 | 36 | |
|---|
| 37 | | - private static final Logger LOG = LogManager.getLogger(ApplicationMetadata.class); |
|---|
| 37 | + private static final Logger LOG = LogManager.getLogger(ApplicationMetadata.class); |
|---|
| 38 | 38 | |
|---|
| 39 | | - private static final long serialVersionUID = 1L; |
|---|
| 39 | + private static final long serialVersionUID = 1L; |
|---|
| 40 | 40 | |
|---|
| 41 | | - @Id |
|---|
| 42 | | - @ManyToOne |
|---|
| 43 | | - @JoinColumn(name = "application_id") |
|---|
| 44 | | - @JsonBackReference |
|---|
| 45 | | - private Application application; |
|---|
| 41 | + @Id |
|---|
| 42 | + @ManyToOne |
|---|
| 43 | + @JoinColumn(name = "application_id") |
|---|
| 44 | + @JsonBackReference |
|---|
| 45 | + private Application application; |
|---|
| 46 | 46 | |
|---|
| 47 | | - @Id |
|---|
| 48 | | - @Column(name = "\"key\"") |
|---|
| 49 | | - private String key; |
|---|
| 47 | + @Id |
|---|
| 48 | + @Column(name = "\"key\"") |
|---|
| 49 | + private String key; |
|---|
| 50 | 50 | |
|---|
| 51 | | - private String value; |
|---|
| 51 | + private String value; |
|---|
| 52 | 52 | |
|---|
| 53 | | - private boolean mandatory; |
|---|
| 53 | + private boolean mandatory; |
|---|
| 54 | 54 | |
|---|
| 55 | | - @Column(name = "creation_timestamp") |
|---|
| 56 | | - @JsonProperty("creation_timestamp") |
|---|
| 57 | | - private Date creationTimestamp; |
|---|
| 55 | + @Column(name = "creation_timestamp") |
|---|
| 56 | + @JsonProperty("creation_timestamp") |
|---|
| 57 | + private Date creationTimestamp; |
|---|
| 58 | 58 | |
|---|
| 59 | | - public String getKey() { |
|---|
| 60 | | - return key; |
|---|
| 61 | | - } |
|---|
| 59 | + public String getKey() { |
|---|
| 60 | + return key; |
|---|
| 61 | + } |
|---|
| 62 | 62 | |
|---|
| 63 | | - public void setKey(String key) { |
|---|
| 64 | | - this.key = key; |
|---|
| 65 | | - } |
|---|
| 63 | + public void setKey(String key) { |
|---|
| 64 | + this.key = key; |
|---|
| 65 | + } |
|---|
| 66 | 66 | |
|---|
| 67 | | - public Application getApplication() { |
|---|
| 68 | | - LOG.info("Getting application from app metadata: {}", application); |
|---|
| 69 | | - return application; |
|---|
| 70 | | - } |
|---|
| 67 | + public Application getApplication() { |
|---|
| 68 | + LOG.info("Getting application from app metadata: {}", application); |
|---|
| 69 | + return application; |
|---|
| 70 | + } |
|---|
| 71 | 71 | |
|---|
| 72 | | - public void setApplication(Application application) { |
|---|
| 73 | | - this.application = application; |
|---|
| 74 | | - } |
|---|
| 72 | + public void setApplication(Application application) { |
|---|
| 73 | + this.application = application; |
|---|
| 74 | + } |
|---|
| 75 | 75 | |
|---|
| 76 | | - public Date getCreationTimestamp() { |
|---|
| 77 | | - return creationTimestamp; |
|---|
| 78 | | - } |
|---|
| 76 | + public Date getCreationTimestamp() { |
|---|
| 77 | + return creationTimestamp; |
|---|
| 78 | + } |
|---|
| 79 | 79 | |
|---|
| 80 | | - public void setCreationTimestamp(Date creationTimestamp) { |
|---|
| 81 | | - this.creationTimestamp = creationTimestamp; |
|---|
| 82 | | - } |
|---|
| 80 | + public void setCreationTimestamp(Date creationTimestamp) { |
|---|
| 81 | + this.creationTimestamp = creationTimestamp; |
|---|
| 82 | + } |
|---|
| 83 | 83 | |
|---|
| 84 | | - public String getValue() { |
|---|
| 85 | | - return value; |
|---|
| 86 | | - } |
|---|
| 84 | + public String getValue() { |
|---|
| 85 | + return value; |
|---|
| 86 | + } |
|---|
| 87 | 87 | |
|---|
| 88 | | - public void setValue(String value) { |
|---|
| 89 | | - this.value = value; |
|---|
| 90 | | - } |
|---|
| 88 | + public void setValue(String value) { |
|---|
| 89 | + this.value = value; |
|---|
| 90 | + } |
|---|
| 91 | 91 | |
|---|
| 92 | | - public boolean isMandatory() { |
|---|
| 93 | | - return mandatory; |
|---|
| 94 | | - } |
|---|
| 92 | + public boolean isMandatory() { |
|---|
| 93 | + return mandatory; |
|---|
| 94 | + } |
|---|
| 95 | 95 | |
|---|
| 96 | | - public void setMandatory(boolean mandatory) { |
|---|
| 97 | | - this.mandatory = mandatory; |
|---|
| 98 | | - } |
|---|
| 96 | + public void setMandatory(boolean mandatory) { |
|---|
| 97 | + this.mandatory = mandatory; |
|---|
| 98 | + } |
|---|
| 99 | 99 | |
|---|
| 100 | | - @Override |
|---|
| 101 | | - public String toString() { |
|---|
| 100 | + @Override |
|---|
| 101 | + public String toString() { |
|---|
| 102 | 102 | |
|---|
| 103 | | - return String.format("ApplicationMetadata (%s)", this.key); |
|---|
| 104 | | - } |
|---|
| 103 | + return String.format("ApplicationMetadata (%s)", this.key); |
|---|
| 104 | + } |
|---|
| 105 | 105 | |
|---|
| 106 | 106 | } |
|---|
| .. | .. |
|---|
| 13 | 13 | |
|---|
| 14 | 14 | import com.fasterxml.jackson.annotation.JsonAutoDetect; |
|---|
| 15 | 15 | import com.fasterxml.jackson.annotation.JsonBackReference; |
|---|
| 16 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|---|
| 16 | 17 | import com.fasterxml.jackson.annotation.JsonInclude; |
|---|
| 17 | 18 | import com.fasterxml.jackson.annotation.JsonInclude.Include; |
|---|
| 18 | 19 | |
|---|
| .. | .. |
|---|
| 24 | 25 | @JsonInclude(Include.NON_NULL) |
|---|
| 25 | 26 | @Entity |
|---|
| 26 | 27 | @Table(name = "licensetype_metadata") |
|---|
| 27 | | -@NamedQueries({ |
|---|
| 28 | | - @NamedQuery(name = "list-licensetype-metadata", query = "SELECT a FROM LicenseTypeMetadata a where a.licenseType.id = :licenseTypeId") |
|---|
| 29 | | -}) |
|---|
| 28 | +@JsonIgnoreProperties(value = { "readonly" }) |
|---|
| 29 | +@NamedQueries({ @NamedQuery(name = "list-licensetype-metadata", query = "SELECT a FROM LicenseTypeMetadata a where a.licenseType.id = :licenseTypeId") }) |
|---|
| 30 | 30 | public class LicenseTypeMetadata implements Serializable { |
|---|
| 31 | 31 | |
|---|
| 32 | | - private static final long serialVersionUID = 1L; |
|---|
| 32 | + private static final long serialVersionUID = 1L; |
|---|
| 33 | 33 | |
|---|
| 34 | | - @Id |
|---|
| 35 | | - @ManyToOne |
|---|
| 36 | | - @JsonBackReference |
|---|
| 37 | | - @JoinColumn(name = "license_type_id") |
|---|
| 38 | | - private LicenseType licenseType; |
|---|
| 34 | + @Id |
|---|
| 35 | + @ManyToOne |
|---|
| 36 | + @JsonBackReference |
|---|
| 37 | + @JoinColumn(name = "license_type_id") |
|---|
| 38 | + private LicenseType licenseType; |
|---|
| 39 | 39 | |
|---|
| 40 | | - @Id |
|---|
| 41 | | - @Column(name = "\"key\"") |
|---|
| 42 | | - private String key; |
|---|
| 40 | + @Id |
|---|
| 41 | + @Column(name = "\"key\"") |
|---|
| 42 | + private String key; |
|---|
| 43 | 43 | |
|---|
| 44 | | - private String value; |
|---|
| 44 | + private String value; |
|---|
| 45 | 45 | |
|---|
| 46 | | - private boolean mandatory; |
|---|
| 46 | + private boolean mandatory; |
|---|
| 47 | 47 | |
|---|
| 48 | | - public LicenseType getLicenseType() { |
|---|
| 49 | | - return licenseType; |
|---|
| 50 | | - } |
|---|
| 48 | + public LicenseType getLicenseType() { |
|---|
| 49 | + return licenseType; |
|---|
| 50 | + } |
|---|
| 51 | 51 | |
|---|
| 52 | | - public void setLicenseType(LicenseType licenseType) { |
|---|
| 53 | | - this.licenseType = licenseType; |
|---|
| 54 | | - } |
|---|
| 52 | + public void setLicenseType(LicenseType licenseType) { |
|---|
| 53 | + this.licenseType = licenseType; |
|---|
| 54 | + } |
|---|
| 55 | 55 | |
|---|
| 56 | | - public String getValue() { |
|---|
| 57 | | - return value; |
|---|
| 58 | | - } |
|---|
| 56 | + public String getValue() { |
|---|
| 57 | + return value; |
|---|
| 58 | + } |
|---|
| 59 | 59 | |
|---|
| 60 | | - public void setValue(String value) { |
|---|
| 61 | | - this.value = value; |
|---|
| 62 | | - } |
|---|
| 60 | + public void setValue(String value) { |
|---|
| 61 | + this.value = value; |
|---|
| 62 | + } |
|---|
| 63 | 63 | |
|---|
| 64 | | - public String getKey() { |
|---|
| 65 | | - return key; |
|---|
| 66 | | - } |
|---|
| 64 | + public String getKey() { |
|---|
| 65 | + return key; |
|---|
| 66 | + } |
|---|
| 67 | 67 | |
|---|
| 68 | | - public void setKey(String key) { |
|---|
| 69 | | - this.key = key; |
|---|
| 70 | | - } |
|---|
| 68 | + public void setKey(String key) { |
|---|
| 69 | + this.key = key; |
|---|
| 70 | + } |
|---|
| 71 | 71 | |
|---|
| 72 | | - public boolean isMandatory() { |
|---|
| 73 | | - return mandatory; |
|---|
| 74 | | - } |
|---|
| 72 | + public boolean isMandatory() { |
|---|
| 73 | + return mandatory; |
|---|
| 74 | + } |
|---|
| 75 | 75 | |
|---|
| 76 | | - public void setMandatory(boolean mandatory) { |
|---|
| 77 | | - this.mandatory = mandatory; |
|---|
| 78 | | - } |
|---|
| 76 | + public void setMandatory(boolean mandatory) { |
|---|
| 77 | + this.mandatory = mandatory; |
|---|
| 78 | + } |
|---|
| 79 | 79 | } |
|---|
| .. | .. |
|---|
| 13 | 13 | |
|---|
| 14 | 14 | import com.fasterxml.jackson.annotation.JsonAutoDetect; |
|---|
| 15 | 15 | import com.fasterxml.jackson.annotation.JsonIgnore; |
|---|
| 16 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|---|
| 16 | 17 | import com.fasterxml.jackson.annotation.JsonInclude; |
|---|
| 17 | 18 | import com.fasterxml.jackson.annotation.JsonInclude.Include; |
|---|
| 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; |
|---|
| .. | .. |
|---|
| 25 | 26 | @JsonInclude(Include.NON_NULL) |
|---|
| 26 | 27 | @Entity |
|---|
| 27 | 28 | @Table(name = "pack_metadata") |
|---|
| 28 | | -@NamedQueries({ |
|---|
| 29 | | - @NamedQuery(name = "list-pack-metadata", query = "SELECT a FROM PackMetadata a where a.pack.id = :packId") |
|---|
| 30 | | -}) |
|---|
| 29 | +@JsonIgnoreProperties(value = { "readonly" }) |
|---|
| 30 | +@NamedQueries({ @NamedQuery(name = "list-pack-metadata", query = "SELECT a FROM PackMetadata a where a.pack.id = :packId") }) |
|---|
| 31 | 31 | public class PackMetadata implements Serializable { |
|---|
| 32 | 32 | |
|---|
| 33 | | - private static final long serialVersionUID = 1L; |
|---|
| 33 | + private static final long serialVersionUID = 1L; |
|---|
| 34 | 34 | |
|---|
| 35 | | - @Id |
|---|
| 36 | | - @JsonIgnore |
|---|
| 37 | | - @ManyToOne |
|---|
| 38 | | - @JoinColumn(name = "pack_id") |
|---|
| 39 | | - private Pack pack; |
|---|
| 35 | + @Id |
|---|
| 36 | + @JsonIgnore |
|---|
| 37 | + @ManyToOne |
|---|
| 38 | + @JoinColumn(name = "pack_id") |
|---|
| 39 | + private Pack pack; |
|---|
| 40 | 40 | |
|---|
| 41 | | - @Id |
|---|
| 42 | | - @Column(name = "\"key\"") |
|---|
| 43 | | - private String key; |
|---|
| 41 | + @Id |
|---|
| 42 | + @Column(name = "\"key\"") |
|---|
| 43 | + private String key; |
|---|
| 44 | 44 | |
|---|
| 45 | | - private String value; |
|---|
| 45 | + private String value; |
|---|
| 46 | 46 | |
|---|
| 47 | | - private boolean readonly; |
|---|
| 47 | + private boolean readonly; |
|---|
| 48 | 48 | |
|---|
| 49 | | - private boolean mandatory; |
|---|
| 49 | + private boolean mandatory; |
|---|
| 50 | 50 | |
|---|
| 51 | | - @JsonProperty("pack_id") |
|---|
| 52 | | - public Integer getPackId() { |
|---|
| 53 | | - return pack == null ? null : pack.getId(); |
|---|
| 54 | | - } |
|---|
| 51 | + @JsonProperty("pack_id") |
|---|
| 52 | + public Integer getPackId() { |
|---|
| 53 | + return pack == null ? null : pack.getId(); |
|---|
| 54 | + } |
|---|
| 55 | 55 | |
|---|
| 56 | | - @JsonProperty("pack_id") |
|---|
| 57 | | - public void setLicenseTypeId(Integer idPack) { |
|---|
| 58 | | - if (idPack == null) { |
|---|
| 59 | | - pack = null; |
|---|
| 60 | | - } else { |
|---|
| 61 | | - pack = new Pack(); |
|---|
| 62 | | - pack.setId(idPack); |
|---|
| 63 | | - } |
|---|
| 64 | | - } |
|---|
| 56 | + @JsonProperty("pack_id") |
|---|
| 57 | + public void setLicenseTypeId(Integer idPack) { |
|---|
| 58 | + if (idPack == null) { |
|---|
| 59 | + pack = null; |
|---|
| 60 | + } else { |
|---|
| 61 | + pack = new Pack(); |
|---|
| 62 | + pack.setId(idPack); |
|---|
| 63 | + } |
|---|
| 64 | + } |
|---|
| 65 | 65 | |
|---|
| 66 | | - public Pack getPack() { |
|---|
| 67 | | - return pack; |
|---|
| 68 | | - } |
|---|
| 66 | + public Pack getPack() { |
|---|
| 67 | + return pack; |
|---|
| 68 | + } |
|---|
| 69 | 69 | |
|---|
| 70 | | - public void setPack(Pack pack) { |
|---|
| 71 | | - this.pack = pack; |
|---|
| 72 | | - } |
|---|
| 70 | + public void setPack(Pack pack) { |
|---|
| 71 | + this.pack = pack; |
|---|
| 72 | + } |
|---|
| 73 | 73 | |
|---|
| 74 | | - public String getValue() { |
|---|
| 75 | | - return value; |
|---|
| 76 | | - } |
|---|
| 74 | + public String getValue() { |
|---|
| 75 | + return value; |
|---|
| 76 | + } |
|---|
| 77 | 77 | |
|---|
| 78 | | - public void setValue(String value) { |
|---|
| 79 | | - this.value = value; |
|---|
| 80 | | - } |
|---|
| 78 | + public void setValue(String value) { |
|---|
| 79 | + this.value = value; |
|---|
| 80 | + } |
|---|
| 81 | 81 | |
|---|
| 82 | | - public String getKey() { |
|---|
| 83 | | - return key; |
|---|
| 84 | | - } |
|---|
| 82 | + public String getKey() { |
|---|
| 83 | + return key; |
|---|
| 84 | + } |
|---|
| 85 | 85 | |
|---|
| 86 | | - public void setKey(String key) { |
|---|
| 87 | | - this.key = key; |
|---|
| 88 | | - } |
|---|
| 86 | + public void setKey(String key) { |
|---|
| 87 | + this.key = key; |
|---|
| 88 | + } |
|---|
| 89 | 89 | |
|---|
| 90 | | - public boolean isReadonly() { |
|---|
| 91 | | - return readonly; |
|---|
| 92 | | - } |
|---|
| 90 | + public boolean isReadonly() { |
|---|
| 91 | + return readonly; |
|---|
| 92 | + } |
|---|
| 93 | 93 | |
|---|
| 94 | | - public void setReadonly(boolean readonly) { |
|---|
| 95 | | - this.readonly = readonly; |
|---|
| 96 | | - } |
|---|
| 94 | + public void setReadonly(boolean readonly) { |
|---|
| 95 | + this.readonly = readonly; |
|---|
| 96 | + } |
|---|
| 97 | 97 | |
|---|
| 98 | | - public boolean isMandatory() { |
|---|
| 99 | | - return mandatory; |
|---|
| 100 | | - } |
|---|
| 98 | + public boolean isMandatory() { |
|---|
| 99 | + return mandatory; |
|---|
| 100 | + } |
|---|
| 101 | 101 | |
|---|
| 102 | | - public void setMandatory(boolean mandatory) { |
|---|
| 103 | | - this.mandatory = mandatory; |
|---|
| 104 | | - } |
|---|
| 102 | + public void setMandatory(boolean mandatory) { |
|---|
| 103 | + this.mandatory = mandatory; |
|---|
| 104 | + } |
|---|
| 105 | 105 | |
|---|
| 106 | 106 | } |
|---|
| .. | .. |
|---|
| 1 | | -import { ErrorCheckerComponent } from './common/error.checker'; |
|---|
| 2 | 1 | import { NgModule } from '@angular/core'; |
|---|
| 3 | 2 | import { BrowserModule } from '@angular/platform-browser'; |
|---|
| 4 | 3 | import { CommonModule } from '@angular/common'; |
|---|
| .. | .. |
|---|
| 13 | 12 | |
|---|
| 14 | 13 | import { HomeComponent } from './home.component'; |
|---|
| 15 | 14 | import { I18nDirective } from './common/i18n'; |
|---|
| 15 | +import { MetadataManagerComponent } from './forms/base'; |
|---|
| 16 | +import { FieldReadonlyComponent } from './forms/base'; |
|---|
| 17 | +import { ErrorCheckerComponent } from './forms/base'; |
|---|
| 18 | + |
|---|
| 16 | 19 | import { UserService } from './user.service'; |
|---|
| 17 | 20 | import { PacksService } from './resources/packs'; |
|---|
| 18 | 21 | import { LicenseTypesService } from './resources/license_types'; |
|---|
| .. | .. |
|---|
| 23 | 26 | import { MenuComponent } from './menu.component'; |
|---|
| 24 | 27 | import { NoMenuComponent } from './nomenu.component'; |
|---|
| 25 | 28 | import { FooterComponent } from './footer.component'; |
|---|
| 26 | | -import { FieldReadonlyComponent } from './common/utils'; |
|---|
| 27 | 29 | import { LicenseListComponent } from './listing/license.list.component'; |
|---|
| 28 | 30 | import { PackListComponent } from './listing/pack.list.component'; |
|---|
| 29 | 31 | import { LoginFormComponent } from './forms/login.form.component'; |
|---|
| .. | .. |
|---|
| 68 | 70 | MenuComponent, |
|---|
| 69 | 71 | NoMenuComponent, |
|---|
| 70 | 72 | FieldReadonlyComponent, |
|---|
| 71 | | - FooterComponent |
|---|
| 73 | + FooterComponent, |
|---|
| 74 | + MetadataManagerComponent |
|---|
| 72 | 75 | ], |
|---|
| 73 | 76 | bootstrap: [ HomeComponent ], |
|---|
| 74 | 77 | entryComponents: [ ], |
|---|
deleted file mode 100644| .. | .. |
|---|
| 1 | | -import { Http } from '@angular/http'; |
|---|
| 2 | | -import { PacksService } from '../resources/packs'; |
|---|
| 3 | | -import { LocaleService } from '../common/i18n'; |
|---|
| 4 | | -import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core'; |
|---|
| 5 | | -import { IPageChangeEvent } from '@covalent/core'; |
|---|
| 6 | | -import { Component, Input, AfterViewInit } from '@angular/core'; |
|---|
| 7 | | -import { TdMediaService } from '@covalent/core'; |
|---|
| 8 | | - |
|---|
| 9 | | -@Component({ |
|---|
| 10 | | - selector: 'error-checker', |
|---|
| 11 | | - template: ` |
|---|
| 12 | | - <div *ngIf="formField?.touched && formField.invalid" layout="column"> |
|---|
| 13 | | - <span *ngFor="let err of getFieldErrors()" align="end">{{err}}</span> |
|---|
| 14 | | - </div>` |
|---|
| 15 | | -}) |
|---|
| 16 | | -export class ErrorCheckerComponent { |
|---|
| 17 | | - |
|---|
| 18 | | - @Input() formField: any; |
|---|
| 19 | | - @Input() fieldName: string; |
|---|
| 20 | | - |
|---|
| 21 | | - constructor(private $L: LocaleService) { |
|---|
| 22 | | - } |
|---|
| 23 | | - |
|---|
| 24 | | - getFieldErrors() : string[] { |
|---|
| 25 | | - if (this.formField.valid) { |
|---|
| 26 | | - return [] |
|---|
| 27 | | - } else { |
|---|
| 28 | | - return (<string[]>Object.keys(this.formField.errors)).map((err:string) => this.getErrorMsg(err)); |
|---|
| 29 | | - } |
|---|
| 30 | | - } |
|---|
| 31 | | - |
|---|
| 32 | | - private updateFieldErrors() { |
|---|
| 33 | | - } |
|---|
| 34 | | - |
|---|
| 35 | | - private getErrorMsg(err: string) : string{ |
|---|
| 36 | | - switch(err) { |
|---|
| 37 | | - case 'required': { |
|---|
| 38 | | - return this.fieldName + ' '+ this.$L.get('is required'); |
|---|
| 39 | | - } |
|---|
| 40 | | - case 'number': { |
|---|
| 41 | | - return this.fieldName + ' '+ this.$L.get('should be a number'); |
|---|
| 42 | | - } |
|---|
| 43 | | - default: { |
|---|
| 44 | | - return this.fieldName + ' '+ this.$L.get('unknown error') + ' ' + err; |
|---|
| 45 | | - } |
|---|
| 46 | | - } |
|---|
| 47 | | - } |
|---|
| 48 | | - |
|---|
| 49 | | - log(obj: any) { |
|---|
| 50 | | - console.log(obj) |
|---|
| 51 | | - } |
|---|
| 52 | | - |
|---|
| 53 | | -} |
|---|
| 54 | | - |
|---|
| .. | .. |
|---|
| 93 | 93 | * $L.get('hello'); // This returns "hola" |
|---|
| 94 | 94 | * $L.get('Hello {0}!!', 'John'); // This returns: "Hola John!!" if language is spanish |
|---|
| 95 | 95 | */ |
|---|
| 96 | | - get(msg: string, ...params: string[] ) : string { |
|---|
| 96 | + get(msg: string, ...params: any[] ) : string { |
|---|
| 97 | 97 | if (msg == null) { |
|---|
| 98 | 98 | return ''; |
|---|
| 99 | 99 | } |
|---|
| .. | .. |
|---|
| 1 | 1 | |
|---|
| 2 | | -import {Component, Input} from '@angular/core'; |
|---|
| 2 | +import { Component, Injectable, Input } from '@angular/core'; |
|---|
| 3 | 3 | import {LocaleService} from './i18n'; |
|---|
| 4 | +import { Observable } from 'rxjs/Observable'; |
|---|
| 4 | 5 | |
|---|
| 5 | | -@Component({ |
|---|
| 6 | | - selector: 'field-readonly', |
|---|
| 7 | | - template: ` |
|---|
| 8 | | - <div layout="column" class="mat-input-container readonly" > |
|---|
| 9 | | - <div class="mat-input-wrapper"> |
|---|
| 10 | | - <div class="mat-input-table"> |
|---|
| 11 | | - <div class="mat-input-prefix"></div> |
|---|
| 12 | | - <div class="mat-input-infix"> |
|---|
| 13 | | - <div class="label-value mat-input-element">{{value}}</div> |
|---|
| 14 | | - <span class="mat-input-placeholder-wrapper" > |
|---|
| 15 | | - <label class="mat-input-placeholder mat-float"> |
|---|
| 16 | | - <span class="placeholder">{{label}}</span> |
|---|
| 17 | | - </label> |
|---|
| 18 | | - </span> |
|---|
| 19 | | - </div> |
|---|
| 20 | | - <div class="mat-input-suffix"></div> |
|---|
| 21 | | - </div> |
|---|
| 22 | | - <div class="mat-input-underline"></div> |
|---|
| 23 | | - </div> |
|---|
| 24 | | - </div>`, |
|---|
| 25 | | - styles: [`.readonly .mat-input-element { |
|---|
| 26 | | - margin-top: 0px !important; |
|---|
| 27 | | - color: rgba(0, 0, 0, 0.50); |
|---|
| 28 | | - }`, |
|---|
| 29 | | - `.readonly .mat-input-element { |
|---|
| 30 | | - margin-top: 0px; |
|---|
| 31 | | - color: rgba(0, 0, 0, 0.50); |
|---|
| 32 | | - }`, |
|---|
| 33 | | - `.readonly.mat-input-container { |
|---|
| 34 | | - width: 100%; |
|---|
| 35 | | - }`] |
|---|
| 36 | | -}) |
|---|
| 37 | | -export class FieldReadonlyComponent { |
|---|
| 38 | | - @Input('value') value: any; |
|---|
| 39 | 6 | |
|---|
| 40 | | - private _label : string; |
|---|
| 41 | | - @Input('label') |
|---|
| 42 | | - set label(txt: string) { |
|---|
| 43 | | - this._label = this.$L.get(txt); |
|---|
| 44 | | - } |
|---|
| 45 | | - get label(): string { return this._label; } |
|---|
| 46 | 7 | |
|---|
| 47 | | - constructor(private $L : LocaleService) { |
|---|
| 8 | +export interface IError { |
|---|
| 9 | + code: string | number, |
|---|
| 10 | + message: string, |
|---|
| 11 | + httpCode?: number |
|---|
| 12 | +} |
|---|
| 48 | 13 | |
|---|
| 49 | | - } |
|---|
| 14 | +export const DEFAULT_APP_ERROR_STATUS_CODE = 418; |
|---|
| 15 | +export const ERROR_MESSAGE_HEADER = "X-SECURIS-ERROR-MSG"; |
|---|
| 16 | +export const ERROR_CODE_MESSAGE_HEADER = "X-SECURIS-ERROR-CODE"; |
|---|
| 17 | + |
|---|
| 18 | +export class ErrorCodes { |
|---|
| 19 | + public static UNEXPECTED_ERROR = 1000; |
|---|
| 20 | + public static INVALID_CREDENTIALS = 1001; |
|---|
| 21 | + public static UNAUTHORIZED_ACCESS = 1002; |
|---|
| 22 | + public static NOT_FOUND = 1003; |
|---|
| 23 | + public static INVALID_FORMAT = 1004; |
|---|
| 24 | + public static WRONG_STATUS = 1005; |
|---|
| 25 | + |
|---|
| 26 | + public static INVALID_LICENSE_REQUEST_DATA = 1100; |
|---|
| 27 | + public static LICENSE_NOT_READY_FOR_RENEW = 1101; |
|---|
| 28 | + public static LICENSE_DATA_IS_NOT_VALID = 1102; |
|---|
| 29 | + public static LICENSE_IS_EXPIRED = 1103; |
|---|
| 30 | + |
|---|
| 31 | + public static INVALID_REQUEST_DATA = 1201; |
|---|
| 32 | + public static INVALID_REQUEST_DATA_FORMAT = 1202; |
|---|
| 33 | + public static BLOCKED_REQUEST_DATA = 1203; |
|---|
| 34 | + public static DUPLICATED_REQUEST_DATA = 1204; |
|---|
| 35 | + public static NO_AVAILABLE_LICENSES = 1205; |
|---|
| 36 | + |
|---|
| 37 | + public static INVALID_DATA = 1301; |
|---|
| 38 | +} |
|---|
| 39 | + |
|---|
| 40 | +@Injectable() |
|---|
| 41 | +export class BasicService { |
|---|
| 42 | + |
|---|
| 43 | + constructor(protected $L: LocaleService) {} |
|---|
| 44 | + |
|---|
| 45 | + public processErrorResponse(errorResponse: Response | any) { |
|---|
| 46 | + // In a real world app, we might use a remote logging infrastructure |
|---|
| 47 | + var error: IError = <IError>{}; |
|---|
| 48 | + if (errorResponse instanceof Response) { |
|---|
| 49 | + error.httpCode = errorResponse.status; |
|---|
| 50 | + } |
|---|
| 51 | + |
|---|
| 52 | + error.code = errorResponse.headers.get(ERROR_CODE_MESSAGE_HEADER) || error.httpCode; |
|---|
| 53 | + |
|---|
| 54 | + if (errorResponse.status === 403 /* forbidden */ || errorResponse.status === 401 /* unauthorized */) { |
|---|
| 55 | + error.message = this.$L.get('Invalid credentials'); |
|---|
| 56 | + error.code = ErrorCodes.INVALID_CREDENTIALS; |
|---|
| 57 | + } else if (errorResponse.status === 418 /* Teapot */) { |
|---|
| 58 | + error.message = errorResponse.headers.get(ERROR_MESSAGE_HEADER) || errorResponse.statusText || this.$L.get('Unknown'); |
|---|
| 59 | + } else { |
|---|
| 60 | + error.message = this.$L.get(`Unexpected error HTTP (${error.httpCode}) accessing to server. Contact with the administrator.`); |
|---|
| 61 | + } |
|---|
| 62 | + |
|---|
| 63 | + return Observable.throw(error); |
|---|
| 64 | + } |
|---|
| 50 | 65 | } |
|---|
| .. | .. |
|---|
| 4 | 4 | import { ApplicationsService } from '../resources/applications'; |
|---|
| 5 | 5 | import { LicenseTypesService } from '../resources/license_types'; |
|---|
| 6 | 6 | import { LocaleService } from '../common/i18n'; |
|---|
| 7 | | -import { IPageChangeEvent } from '@covalent/core'; |
|---|
| 7 | +import { TdDialogService } from '@covalent/core'; |
|---|
| 8 | 8 | import { Component, AfterViewInit } from '@angular/core'; |
|---|
| 9 | 9 | import { TdMediaService } from '@covalent/core'; |
|---|
| 10 | 10 | import { FormBase, IComboOption } from './base'; |
|---|
| .. | .. |
|---|
| 30 | 30 | }) |
|---|
| 31 | 31 | export class ApplicationFormComponent extends FormBase { |
|---|
| 32 | 32 | |
|---|
| 33 | | - fields: any = { |
|---|
| 34 | | - 'id': '', |
|---|
| 35 | | - 'code': '', |
|---|
| 36 | | - 'name': '', |
|---|
| 37 | | - 'creation_timestamp': '', |
|---|
| 38 | | - 'license_filename': '', |
|---|
| 39 | | - 'description': '', |
|---|
| 40 | | - 'metadata': '', |
|---|
| 41 | | - 'key': '', |
|---|
| 42 | | - 'value': '', |
|---|
| 43 | | - } |
|---|
| 44 | 33 | constructor(private http: Http, |
|---|
| 45 | 34 | private licenseTypes: LicenseTypesService, |
|---|
| 46 | 35 | private router: Router, |
|---|
| 47 | 36 | private applications: ApplicationsService, |
|---|
| 48 | 37 | toaster: ToastsManager, |
|---|
| 49 | 38 | route: ActivatedRoute, |
|---|
| 50 | | - $L: LocaleService) { |
|---|
| 51 | | - super($L, route, toaster, applications, $L.get('application')); |
|---|
| 39 | + $L: LocaleService, |
|---|
| 40 | + dialogs: TdDialogService) { |
|---|
| 41 | + super($L, route, toaster, applications, $L.get('application'), dialogs); |
|---|
| 52 | 42 | } |
|---|
| 53 | 43 | |
|---|
| 54 | 44 | |
|---|
| .. | .. |
|---|
| 58 | 48 | |
|---|
| 59 | 49 | |
|---|
| 60 | 50 | ngAfterViewInit(): void { |
|---|
| 61 | | - super.prepareData('applicationId'); |
|---|
| 51 | + super.prepareInitialData('applicationId', { |
|---|
| 52 | + metadata: [] |
|---|
| 53 | + }); |
|---|
| 62 | 54 | } |
|---|
| 63 | 55 | } |
|---|
| 64 | 56 | |
|---|
| .. | .. |
|---|
| 7 | 7 | <span flex></span> |
|---|
| 8 | 8 | <button md-icon-button (click)="save()"><md-icon>save</md-icon></button> |
|---|
| 9 | 9 | </md-toolbar> |
|---|
| 10 | + <!-- |
|---|
| 11 | + code: 'CICS', |
|---|
| 12 | + creation_timestamp: 1418384439000, |
|---|
| 13 | + description: 'Wellbore integrity analysis software', |
|---|
| 14 | + id: 1, |
|---|
| 15 | + license_filename: 'config_server.lic', |
|---|
| 16 | + name: 'CurisIntegrity', |
|---|
| 17 | + metadata: |
|---|
| 18 | + [ { key: 'max_docs', |
|---|
| 19 | + value: '250000', |
|---|
| 20 | + readonly: true, |
|---|
| 21 | + mandatory: true } ] |
|---|
| 22 | +} |
|---|
| 23 | + --> |
|---|
| 10 | 24 | <div class="margin" layout-align-gt-xs="center start" layout-fill="" layout-gt-xs="row"> |
|---|
| 11 | 25 | <md-card flex="70"> |
|---|
| 12 | 26 | <md-card-title> |
|---|
| .. | .. |
|---|
| 27 | 41 | </md-input-container> |
|---|
| 28 | 42 | <error-checker [fieldName]="getFieldName('code')" [formField]="applicationForm.controls.code"></error-checker> |
|---|
| 29 | 43 | </div> |
|---|
| 44 | + </div> |
|---|
| 45 | + <div layout="row" layout-fill layout-padding> |
|---|
| 30 | 46 | <div layout="column" layout-fill flex> |
|---|
| 31 | | - <md-input-container> |
|---|
| 32 | | - <input mdInput type="number" [(ngModel)]="data.num_licenses" name="num_licenses" required /> |
|---|
| 47 | + <md-input-container flex> |
|---|
| 48 | + <input mdInput type="text" [(ngModel)]="data.name" name="name" required /> |
|---|
| 33 | 49 | <md-placeholder> |
|---|
| 34 | | - <span i18n="field.num_licenses"></span> |
|---|
| 50 | + <span i18n="field.name"></span> |
|---|
| 35 | 51 | </md-placeholder> |
|---|
| 36 | 52 | </md-input-container> |
|---|
| 37 | | - <error-checker [fieldName]="getFieldName('num_licenses')" [formField]="applicationForm.controls.num_licenses"></error-checker> |
|---|
| 53 | + <error-checker [fieldName]="getFieldName('name')" [formField]="applicationForm.controls.name"></error-checker> |
|---|
| 54 | + </div> |
|---|
| 55 | + <div layout="column" layout-fill flex> |
|---|
| 56 | + <md-input-container flex> |
|---|
| 57 | + <input mdInput type="text" [(ngModel)]="data.license_filename" name="license_filename" required /> |
|---|
| 58 | + <md-placeholder> |
|---|
| 59 | + <span i18n="field.license_filename"></span> |
|---|
| 60 | + </md-placeholder> |
|---|
| 61 | + </md-input-container> |
|---|
| 62 | + <error-checker [fieldName]="getFieldName('license_filename')" [formField]="applicationForm.controls.license_filename"></error-checker> |
|---|
| 38 | 63 | </div> |
|---|
| 39 | 64 | </div> |
|---|
| 40 | 65 | <div layout="row" layout-fill layout-padding> |
|---|
| 41 | 66 | <div layout="column" layout-fill flex> |
|---|
| 42 | 67 | <md-input-container flex> |
|---|
| 43 | | - <input mdInput type="date" [(ngModel)]="data.init_valid_date" name="init_valid_date" required /> |
|---|
| 68 | + <textarea mdInput type="text" type="text" [(ngModel)]="data.description" name="description" maxlength="1024"></textarea> |
|---|
| 44 | 69 | <md-placeholder> |
|---|
| 45 | | - <span i18n="field.end_valid_date"></span> |
|---|
| 46 | | - </md-placeholder> |
|---|
| 47 | | - </md-input-container> |
|---|
| 48 | | - <error-checker [fieldName]="getFieldName('init_valid_date')" [formField]="applicationForm.controls.init_valid_date"></error-checker> |
|---|
| 49 | | - </div> |
|---|
| 50 | | - <div layout="column" layout-fill flex> |
|---|
| 51 | | - <md-input-container flex> |
|---|
| 52 | | - <input mdInput type="date" [(ngModel)]="data.end_valid_date" name="end_valid_date" required /> |
|---|
| 53 | | - <md-placeholder> |
|---|
| 54 | | - <span i18n="field.end_valid_date"></span> |
|---|
| 55 | | - </md-placeholder> |
|---|
| 56 | | - </md-input-container> |
|---|
| 57 | | - <error-checker [fieldName]="getFieldName('end_valid_date')" [formField]="applicationForm.controls.end_valid_date"></error-checker> |
|---|
| 58 | | - </div> |
|---|
| 59 | | - </div> |
|---|
| 60 | | - <div layout="row" layout-fill layout-padding *ngIf="isNew"> |
|---|
| 61 | | - <div layout="column" layout-fill flex> |
|---|
| 62 | | - <md-select [placeholder]="getFieldName('organization_id')" flex [(ngModel)]="data.organization_id" name="organization_id" |
|---|
| 63 | | - (change)="changeOrg($event)"> |
|---|
| 64 | | - <md-option *ngFor="let org of organizations" [value]="org.id"> |
|---|
| 65 | | - {{org.label}} |
|---|
| 66 | | - </md-option> |
|---|
| 67 | | - </md-select> |
|---|
| 68 | | - <error-checker [fieldName]="getFieldName('organization_id')" [formField]="applicationForm.controls.organization_id"></error-checker> |
|---|
| 69 | | - </div> |
|---|
| 70 | | - <div layout="column" layout-fill flex> |
|---|
| 71 | | - <md-select flex [placeholder]="getFieldName('license_type_id')" [(ngModel)]="data.license_type_id" name="license_type_id" |
|---|
| 72 | | - (change)="changeLicType($event)"> |
|---|
| 73 | | - <md-option *ngFor="let lt of licensetypes" [value]="lt.id"> |
|---|
| 74 | | - {{lt.label}} |
|---|
| 75 | | - </md-option> |
|---|
| 76 | | - </md-select> |
|---|
| 77 | | - <error-checker [fieldName]="getFieldName('license_type_id')" [formField]="applicationForm.controls.license_type_id"></error-checker> |
|---|
| 78 | | - </div> |
|---|
| 79 | | - </div> |
|---|
| 80 | | - <div layout="row" layout-fill layout-padding *ngIf="!isNew"> |
|---|
| 81 | | - <field-readonly [value]="data.organization_name" label="field.organization_id" flex></field-readonly> |
|---|
| 82 | | - <field-readonly [value]="data.licensetype_code" label="field.license_type_id" flex></field-readonly> |
|---|
| 83 | | - </div> |
|---|
| 84 | | - <div layout="row" layout-fill layout-padding> |
|---|
| 85 | | - <div layout="column" layout-fill flex> |
|---|
| 86 | | - <md-input-container flex> |
|---|
| 87 | | - <input mdInput type="number" [(ngModel)]="data.preactivation_valid_period" name="preactivation_valid_period" required /> |
|---|
| 88 | | - <md-placeholder> |
|---|
| 89 | | - <span i18n="field.preactivation_valid_period"></span> |
|---|
| 90 | | - </md-placeholder> |
|---|
| 91 | | - <md-hint align="end">days</md-hint> |
|---|
| 92 | | - </md-input-container> |
|---|
| 93 | | - <error-checker [fieldName]="getFieldName('preactivation_valid_period')" [formField]="applicationForm.controls.preactivation_valid_period"></error-checker> |
|---|
| 94 | | - </div> |
|---|
| 95 | | - <div layout="column" layout-fill flex> |
|---|
| 96 | | - <md-input-container flex> |
|---|
| 97 | | - <input mdInput type="number" [(ngModel)]="data.renew_valid_period" name="renew_valid_period" required /> |
|---|
| 98 | | - <md-placeholder> |
|---|
| 99 | | - <span i18n="field.renew_valid_period"></span> |
|---|
| 100 | | - </md-placeholder> |
|---|
| 101 | | - <md-hint align="end">days</md-hint> |
|---|
| 102 | | - </md-input-container> |
|---|
| 103 | | - <error-checker [fieldName]="getFieldName('renew_valid_period')" [formField]="applicationForm.controls.renew_valid_period"></error-checker> |
|---|
| 104 | | - </div> |
|---|
| 105 | | - </div> |
|---|
| 106 | | - <div layout="row" layout-fill layout-padding> |
|---|
| 107 | | - <div layout="column" layout-fill flex> |
|---|
| 108 | | - <md-input-container flex> |
|---|
| 109 | | - <textarea mdInput type="text" type="text" [(ngModel)]="data.comments" name="comments" maxlength="1024"></textarea> |
|---|
| 110 | | - <md-placeholder> |
|---|
| 111 | | - <span i18n="field.comments"></span> |
|---|
| 70 | + <span i18n="field.description"></span> |
|---|
| 112 | 71 | </md-placeholder> |
|---|
| 113 | 72 | <md-hint align="end">(max 1024)</md-hint> |
|---|
| 114 | 73 | </md-input-container> |
|---|
| 115 | 74 | </div> |
|---|
| 116 | 75 | </div> |
|---|
| 117 | 76 | <div layout="row" layout-fill layout-padding *ngIf="!isNew"> |
|---|
| 118 | | - <field-readonly [value]="data.created_by_name" label="field.created_by" flex></field-readonly> |
|---|
| 119 | 77 | <field-readonly [value]="data.creation_timestamp | date: 'medium'" label="field.creation_timestamp" flex></field-readonly> |
|---|
| 120 | 78 | </div> |
|---|
| 121 | | - <div layout="column" layout-fill> |
|---|
| 122 | | - <span class="md-title" i18n>License metadata</span> |
|---|
| 123 | | - <div layout="row" layout-fill layout-padding *ngFor="let pair of data.metadata"> |
|---|
| 124 | | - <md-input-container flex="40"> |
|---|
| 125 | | - <input mdInput type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="pair.key" readonly /> |
|---|
| 126 | | - <md-placeholder> |
|---|
| 127 | | - <span i18n="field.key"></span> |
|---|
| 128 | | - </md-placeholder> |
|---|
| 129 | | - </md-input-container> |
|---|
| 130 | | - <md-input-container flex> |
|---|
| 131 | | - <input mdInput type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="pair.value" [readonly]="pair.readonly" [required]="pair.required" |
|---|
| 132 | | - /> |
|---|
| 133 | | - <md-placeholder> |
|---|
| 134 | | - <span i18n="field.value"></span> |
|---|
| 135 | | - </md-placeholder> |
|---|
| 136 | | - </md-input-container> |
|---|
| 137 | | - </div> |
|---|
| 138 | | - </div> |
|---|
| 79 | + <metadata-manager addOrDelete="true" editKeys="true" [metadata]="data.metadata" ></metadata-manager> |
|---|
| 139 | 80 | </div> |
|---|
| 140 | 81 | </form> |
|---|
| 141 | 82 | </md-card-content> |
|---|
| 142 | 83 | <md-divider></md-divider> |
|---|
| 143 | 84 | <md-card-actions> |
|---|
| 144 | 85 | <div layout="row" layout-align="start center" class="margin"> |
|---|
| 86 | + <button *ngIf="!isNew" md-raised-button color="warn" (click)="delete(data.id)">Delete</button> |
|---|
| 145 | 87 | <span flex></span> |
|---|
| 146 | 88 | <button [disabled]="!applicationForm.form.valid" md-raised-button color="primary" (click)="save()">Save</button> |
|---|
| 147 | 89 | <button md-button (click)="goBack()">Cancel</button> |
|---|
| .. | .. |
|---|
| 1 | 1 | import { Http } from '@angular/http'; |
|---|
| 2 | 2 | import { ActivatedRoute } from '@angular/router'; |
|---|
| 3 | +import { TdDialogService } from '@covalent/core'; |
|---|
| 3 | 4 | import { ToastsManager } from 'ng2-toastr/ng2-toastr'; |
|---|
| 4 | 5 | |
|---|
| 5 | 6 | import { LocaleService } from '../common/i18n'; |
|---|
| 7 | +import { BasicService } from '../common/utils'; |
|---|
| 6 | 8 | import { SeCurisResourceServices } from '../resources/base'; |
|---|
| 7 | 9 | |
|---|
| 8 | | -import { AfterViewInit } from '@angular/core'; |
|---|
| 10 | +import { AfterViewInit, Component, Input } from '@angular/core'; |
|---|
| 9 | 11 | |
|---|
| 10 | 12 | |
|---|
| 11 | 13 | export interface IComboOption { |
|---|
| .. | .. |
|---|
| 14 | 16 | } |
|---|
| 15 | 17 | |
|---|
| 16 | 18 | |
|---|
| 17 | | -export class FormBase { |
|---|
| 19 | +export class FormBase extends BasicService { |
|---|
| 18 | 20 | protected form_title: string = ''; |
|---|
| 19 | 21 | protected form_subtitle: string = ''; |
|---|
| 20 | 22 | protected data: any = {}; |
|---|
| 21 | 23 | protected isNew : boolean = true; |
|---|
| 22 | 24 | |
|---|
| 23 | | - constructor(protected $L: LocaleService, |
|---|
| 25 | + constructor($L: LocaleService, |
|---|
| 24 | 26 | protected route: ActivatedRoute, |
|---|
| 25 | 27 | protected toaster: ToastsManager, |
|---|
| 26 | 28 | protected resourceServices: SeCurisResourceServices, |
|---|
| 27 | | - protected resourceName: string ) { |
|---|
| 29 | + protected resourceName: string, |
|---|
| 30 | + protected dialogs : TdDialogService ) { |
|---|
| 31 | + super($L); |
|---|
| 28 | 32 | } |
|---|
| 29 | 33 | |
|---|
| 30 | 34 | public getFieldName(fieldId: string) : string { |
|---|
| .. | .. |
|---|
| 36 | 40 | save() { |
|---|
| 37 | 41 | var command = this.isNew ? this.resourceServices.create(this.data) : this.resourceServices.modify(this.data.id, this.data); |
|---|
| 38 | 42 | command.subscribe( |
|---|
| 39 | | - data => this.toaster.success(this.$L.get('{} saved sucessfully', this.$L.get(this.resourceName).capitalize())), |
|---|
| 40 | | - err => { |
|---|
| 41 | | - console.error(err); |
|---|
| 42 | | - this.toaster.success(this.$L.get('Error saving {}', this.$L.get(this.resourceName))); |
|---|
| 43 | | - } |
|---|
| 44 | | - ); |
|---|
| 43 | + data => this.toaster.success(this.$L.get('{} saved sucessfully', this.resourceName.capitalize())), |
|---|
| 44 | + err => this.toaster.error(err.message, this.$L.get('Error saving {}', this.resourceName)) |
|---|
| 45 | + ); |
|---|
| 45 | 46 | } |
|---|
| 46 | 47 | |
|---|
| 47 | | - protected prepareData(idparam: string, default_values: any = {}) : void { |
|---|
| 48 | + delete(eleId: number | string) : void { |
|---|
| 49 | + this.dialogs.openConfirm({ |
|---|
| 50 | + message: this.$L.get('The {} with ID {} will be deleted. Do you want to continue ?', this.resourceName, eleId), |
|---|
| 51 | + disableClose: false, // defaults to false |
|---|
| 52 | + title: this.$L.get('Delete {}', this.resourceName), |
|---|
| 53 | + cancelButton: this.$L.get('Cancel'), |
|---|
| 54 | + acceptButton: this.$L.get('Yes, delete') |
|---|
| 55 | + }).afterClosed().subscribe((accept: boolean) => { |
|---|
| 56 | + if (accept) { |
|---|
| 57 | + this.resourceServices.remove(eleId) |
|---|
| 58 | + .subscribe( |
|---|
| 59 | + responseData => this.toaster.success(this.$L.get('{} was sucessfully deleted', this.resourceName.capitalize())), |
|---|
| 60 | + err => this.toaster.success(err.message, this.$L.get('Error deleting the {}', this.resourceName)) |
|---|
| 61 | + ); |
|---|
| 62 | + } |
|---|
| 63 | + }); |
|---|
| 64 | + } |
|---|
| 65 | + |
|---|
| 66 | + protected prepareInitialData(idparam: string, default_values: any = {}) : void { |
|---|
| 48 | 67 | this.form_title = this.$L.get('{} data', this.resourceName.capitalize()); |
|---|
| 49 | 68 | this.isNew = true; |
|---|
| 50 | 69 | !!this.route && this.route.params.subscribe(params => { |
|---|
| .. | .. |
|---|
| 61 | 80 | }); |
|---|
| 62 | 81 | } |
|---|
| 63 | 82 | |
|---|
| 64 | | -} |
|---|
| 83 | +} |
|---|
| 84 | + |
|---|
| 85 | +@Component({ |
|---|
| 86 | + selector: 'error-checker', |
|---|
| 87 | + template: ` |
|---|
| 88 | + <div *ngIf="formField?.touched && formField.invalid" layout="column"> |
|---|
| 89 | + <span class="error-msg" *ngFor="let err of getFieldErrors()" align="end">{{err}}</span> |
|---|
| 90 | + </div>`, |
|---|
| 91 | + styles: [ |
|---|
| 92 | + ':host {margin-top: -10px;}', |
|---|
| 93 | + `.error-msg { |
|---|
| 94 | + color: darkred; |
|---|
| 95 | + font-size: 0.8em; |
|---|
| 96 | + }` |
|---|
| 97 | + ] |
|---|
| 98 | +}) |
|---|
| 99 | +export class ErrorCheckerComponent { |
|---|
| 100 | + |
|---|
| 101 | + @Input() formField: any; |
|---|
| 102 | + @Input() fieldName: string; |
|---|
| 103 | + |
|---|
| 104 | + constructor(private $L: LocaleService) { |
|---|
| 105 | + } |
|---|
| 106 | + |
|---|
| 107 | + getFieldErrors() : string[] { |
|---|
| 108 | + if (this.formField.valid) { |
|---|
| 109 | + return [] |
|---|
| 110 | + } else { |
|---|
| 111 | + return (<string[]>Object.keys(this.formField.errors)).map((err:string) => this.getErrorMsg(err)); |
|---|
| 112 | + } |
|---|
| 113 | + } |
|---|
| 114 | + |
|---|
| 115 | + private updateFieldErrors() { |
|---|
| 116 | + } |
|---|
| 117 | + |
|---|
| 118 | + private getErrorMsg(err: string) : string{ |
|---|
| 119 | + switch(err) { |
|---|
| 120 | + case 'required': { |
|---|
| 121 | + return this.fieldName + ' '+ this.$L.get('is required'); |
|---|
| 122 | + } |
|---|
| 123 | + case 'number': { |
|---|
| 124 | + return this.fieldName + ' '+ this.$L.get('should be a number'); |
|---|
| 125 | + } |
|---|
| 126 | + default: { |
|---|
| 127 | + return this.fieldName + ' '+ this.$L.get('unknown error') + ' ' + err; |
|---|
| 128 | + } |
|---|
| 129 | + } |
|---|
| 130 | + } |
|---|
| 131 | + |
|---|
| 132 | + log(obj: any) { |
|---|
| 133 | + console.log(obj) |
|---|
| 134 | + } |
|---|
| 135 | + |
|---|
| 136 | +} |
|---|
| 137 | + |
|---|
| 138 | + |
|---|
| 139 | +@Component({ |
|---|
| 140 | + selector: 'field-readonly', |
|---|
| 141 | + template: ` |
|---|
| 142 | + <div layout="column" class="mat-input-container readonly" > |
|---|
| 143 | + <div class="mat-input-wrapper"> |
|---|
| 144 | + <div class="mat-input-table"> |
|---|
| 145 | + <div class="mat-input-prefix"></div> |
|---|
| 146 | + <div class="mat-input-infix"> |
|---|
| 147 | + <div class="label-value mat-input-element">{{value}}</div> |
|---|
| 148 | + <span class="mat-input-placeholder-wrapper" > |
|---|
| 149 | + <label class="mat-input-placeholder mat-float"> |
|---|
| 150 | + <span class="placeholder">{{label}}</span> |
|---|
| 151 | + </label> |
|---|
| 152 | + </span> |
|---|
| 153 | + </div> |
|---|
| 154 | + <div class="mat-input-suffix"></div> |
|---|
| 155 | + </div> |
|---|
| 156 | + <div class="mat-input-underline"></div> |
|---|
| 157 | + </div> |
|---|
| 158 | + </div>`, |
|---|
| 159 | + styles: [`.readonly .mat-input-element { |
|---|
| 160 | + margin-top: 0px !important; |
|---|
| 161 | + color: rgba(0, 0, 0, 0.50); |
|---|
| 162 | + }`, |
|---|
| 163 | + `.readonly .mat-input-element { |
|---|
| 164 | + margin-top: 0px; |
|---|
| 165 | + color: rgba(0, 0, 0, 0.50); |
|---|
| 166 | + }`, |
|---|
| 167 | + `.readonly.mat-input-container { |
|---|
| 168 | + width: 100%; |
|---|
| 169 | + }`] |
|---|
| 170 | +}) |
|---|
| 171 | +export class FieldReadonlyComponent { |
|---|
| 172 | + @Input('value') value: any; |
|---|
| 173 | + |
|---|
| 174 | + private _label : string; |
|---|
| 175 | + @Input('label') |
|---|
| 176 | + set label(txt: string) { |
|---|
| 177 | + this._label = this.$L.get(txt); |
|---|
| 178 | + } |
|---|
| 179 | + get label(): string { return this._label; } |
|---|
| 180 | + |
|---|
| 181 | + constructor(private $L : LocaleService) { |
|---|
| 182 | + |
|---|
| 183 | + } |
|---|
| 184 | +} |
|---|
| 185 | + |
|---|
| 186 | +interface MetadataPair { |
|---|
| 187 | + key: string, |
|---|
| 188 | + value: string, |
|---|
| 189 | + readonly: boolean, |
|---|
| 190 | + mandatory: boolean |
|---|
| 191 | +} |
|---|
| 192 | + |
|---|
| 193 | +@Component({ |
|---|
| 194 | + selector: 'metadata-manager', |
|---|
| 195 | + template: ` |
|---|
| 196 | + <div layout="column" layout-fill flex> |
|---|
| 197 | + <div layout="row" layout-align="start center"> |
|---|
| 198 | + <span class="md-title">{{title}}</span> |
|---|
| 199 | + <span flex></span> |
|---|
| 200 | + <button *ngIf="addOrDelete" type="button" md-icon-button color="primary" (click)="newMetadata()"><md-icon>add</md-icon></button> |
|---|
| 201 | + </div> |
|---|
| 202 | + <div layout="row" layout-align="start center" *ngFor="let pair of metadata" class="values"> |
|---|
| 203 | + <md-input-container flex="35" > |
|---|
| 204 | + <input mdInput type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="pair.key" [readonly]="!editKeys" [mdTooltip]="pair.key" /> |
|---|
| 205 | + <md-placeholder> |
|---|
| 206 | + <span i18n="field.key"></span> |
|---|
| 207 | + </md-placeholder> |
|---|
| 208 | + </md-input-container> |
|---|
| 209 | + <md-input-container flex > |
|---|
| 210 | + <input mdInput type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="pair.value" [readonly]="pair.readonly" [required]="pair.mandatory" |
|---|
| 211 | + [mdTooltip]="pair.value" /> |
|---|
| 212 | + <md-placeholder> |
|---|
| 213 | + <span i18n="field.value"></span> |
|---|
| 214 | + </md-placeholder> |
|---|
| 215 | + </md-input-container> |
|---|
| 216 | + <md-checkbox *ngIf="addOrDelete" [ngModelOptions]="{standalone: true}" [(ngModel)]="pair.mandatory" name="mandatory" [mdTooltip]="$L.get('field.mandatory')"> |
|---|
| 217 | + </md-checkbox> |
|---|
| 218 | + <button *ngIf="addOrDelete" type="button" md-icon-button color="warn" (click)="deleteMetadata(pair)"><md-icon>delete</md-icon></button> |
|---|
| 219 | + </div> |
|---|
| 220 | + </div>`, |
|---|
| 221 | + styles: [ |
|---|
| 222 | + ':host { width:100%; }', |
|---|
| 223 | + `.values > * { |
|---|
| 224 | + margin-left: 5px; |
|---|
| 225 | + margin-right: 5px; |
|---|
| 226 | + }` |
|---|
| 227 | + ] |
|---|
| 228 | +}) |
|---|
| 229 | +export class MetadataManagerComponent { |
|---|
| 230 | + @Input('metadata') metadata: MetadataPair[]; |
|---|
| 231 | + @Input('addOrDelete') addOrDelete: boolean = false; |
|---|
| 232 | + @Input('editKeys') editKeys: boolean = false; |
|---|
| 233 | + @Input('title') title: string; |
|---|
| 234 | + |
|---|
| 235 | + constructor(private $L : LocaleService) { |
|---|
| 236 | + this.title = $L.get('License metadata'); |
|---|
| 237 | + } |
|---|
| 238 | + |
|---|
| 239 | + newMetadata() : void{ |
|---|
| 240 | + this.metadata.push(<MetadataPair>{ |
|---|
| 241 | + mandatory: false, |
|---|
| 242 | + readonly: false |
|---|
| 243 | + }); |
|---|
| 244 | + } |
|---|
| 245 | + |
|---|
| 246 | + deleteMetadata(pair: MetadataPair) : void { |
|---|
| 247 | + let indexToRemove = this.metadata.findIndex(ele => ele.key === pair.key); |
|---|
| 248 | + if (indexToRemove !== -1) { |
|---|
| 249 | + this.metadata.splice(indexToRemove, 1); |
|---|
| 250 | + } |
|---|
| 251 | + } |
|---|
| 252 | +} |
|---|
| .. | .. |
|---|
| 7 | 7 | import { AfterViewInit, Component, ViewChild } from '@angular/core'; |
|---|
| 8 | 8 | import { ActivatedRoute, Router } from '@angular/router'; |
|---|
| 9 | 9 | |
|---|
| 10 | | -import { TdMediaService, TdFileInputComponent } from '@covalent/core'; |
|---|
| 10 | +import { TdMediaService, TdFileInputComponent, TdDialogService } from '@covalent/core'; |
|---|
| 11 | 11 | import { FormBase, IComboOption } from './base'; |
|---|
| 12 | 12 | import { ToastsManager } from "ng2-toastr/ng2-toastr"; |
|---|
| 13 | 13 | |
|---|
| .. | .. |
|---|
| 20 | 20 | export class LicenseFormComponent extends FormBase { |
|---|
| 21 | 21 | |
|---|
| 22 | 22 | @ViewChild('requestFileUploader') requestFileUploader : TdFileInputComponent; |
|---|
| 23 | | - form_title: string = ''; |
|---|
| 24 | | - form_subtitle: string = ''; |
|---|
| 25 | | - data: any = {}; |
|---|
| 26 | 23 | pack: any = null; |
|---|
| 27 | | - isNew : boolean = true; |
|---|
| 28 | 24 | |
|---|
| 29 | 25 | constructor(private http: Http, |
|---|
| 30 | 26 | private licenses: LicensesService, |
|---|
| .. | .. |
|---|
| 32 | 28 | private packs: PacksService, |
|---|
| 33 | 29 | toaster: ToastsManager, |
|---|
| 34 | 30 | route: ActivatedRoute, |
|---|
| 35 | | - $L: LocaleService) { |
|---|
| 36 | | - super($L, route, toaster, licenses, $L.get('license')); |
|---|
| 31 | + $L: LocaleService, |
|---|
| 32 | + dialogs: TdDialogService) { |
|---|
| 33 | + super($L, route, toaster, licenses, $L.get('license'), dialogs); |
|---|
| 37 | 34 | } |
|---|
| 38 | 35 | |
|---|
| 39 | 36 | requestFileSelected(file: File) : void { |
|---|
| .. | .. |
|---|
| 41 | 38 | console.log(this.requestFileUploader); |
|---|
| 42 | 39 | if (!window.FileReader) { // Browser is not |
|---|
| 43 | 40 | // compatible |
|---|
| 44 | | - console.log(this.$L.get("Open your .req file with a text editor and copy&paste the content in the form text field?")); |
|---|
| 41 | + console.log(this.$L.get("Open your .req file with a text editor and copy&paste the content in the form text field")); |
|---|
| 45 | 42 | return; |
|---|
| 46 | 43 | } |
|---|
| 47 | 44 | var reader = new FileReader(); |
|---|
| .. | .. |
|---|
| 54 | 51 | this.requestFileUploader.clear(); |
|---|
| 55 | 52 | } |
|---|
| 56 | 53 | |
|---|
| 54 | + |
|---|
| 57 | 55 | requestFileUploaded(file: File) : void { |
|---|
| 58 | 56 | console.log(file); |
|---|
| 59 | 57 | } |
|---|
| .. | .. |
|---|
| 82 | 80 | |
|---|
| 83 | 81 | this.route.params.subscribe(params => { |
|---|
| 84 | 82 | var packId = +params['packId']; // (+) converts string 'id' to a number |
|---|
| 85 | | - super.prepareData('licenseId', { |
|---|
| 83 | + super.prepareInitialData('licenseId', { |
|---|
| 86 | 84 | pack_id: packId, |
|---|
| 87 | 85 | activation_code: this.createActivationCode() |
|---|
| 88 | 86 | }); |
|---|
| 87 | + this.packs.get(packId).subscribe( |
|---|
| 88 | + packData => { |
|---|
| 89 | + this.pack = packData; |
|---|
| 90 | + }, |
|---|
| 91 | + err => console.error(err) |
|---|
| 92 | + ); |
|---|
| 89 | 93 | }); |
|---|
| 90 | 94 | } |
|---|
| 91 | 95 | } |
|---|
| .. | .. |
|---|
| 3 | 3 | <button md-icon-button (click)="goBack()" color="accent"> |
|---|
| 4 | 4 | <md-icon>arrow_back</md-icon> |
|---|
| 5 | 5 | </button> |
|---|
| 6 | | - <span>{{form_title}}</span> |
|---|
| 6 | + <span [innerText]="form_title"></span> |
|---|
| 7 | 7 | <span flex></span> |
|---|
| 8 | 8 | <button md-icon-button (click)="save()"><md-icon>save</md-icon></button> |
|---|
| 9 | 9 | <md-toolbar-row class="inner-padding" *ngIf="!!pack" > |
|---|
| .. | .. |
|---|
| 91 | 91 | <field-readonly [value]="data.created_by_id" label="field.created_by" flex></field-readonly> |
|---|
| 92 | 92 | <field-readonly [value]="data.creation_date | date: 'medium'" label="field.creation_date" flex></field-readonly> |
|---|
| 93 | 93 | </div> |
|---|
| 94 | | - <div layout="column" layout-fill> |
|---|
| 95 | | - <span class="md-title" i18n>License metadata</span> |
|---|
| 96 | | - <div layout="row" layout-fill layout-padding *ngFor="let pair of pack?.metadata"> |
|---|
| 97 | | - <md-input-container flex="40"> |
|---|
| 98 | | - <input mdInput type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="pair.key" readonly /> |
|---|
| 99 | | - <md-placeholder> |
|---|
| 100 | | - <span i18n="field.key"></span> |
|---|
| 101 | | - </md-placeholder> |
|---|
| 102 | | - </md-input-container> |
|---|
| 103 | | - <md-input-container flex> |
|---|
| 104 | | - <input mdInput type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="pair.value" readonly /> |
|---|
| 105 | | - <md-placeholder> |
|---|
| 106 | | - <span i18n="field.value"></span> |
|---|
| 107 | | - </md-placeholder> |
|---|
| 108 | | - </md-input-container> |
|---|
| 109 | | - </div> |
|---|
| 110 | | - </div> |
|---|
| 94 | + <metadata-manager [addOrDelete]="false" [editKeys]="false" [metadata]="data.metadata" ></metadata-manager> |
|---|
| 95 | + |
|---|
| 111 | 96 | </div> |
|---|
| 112 | 97 | </form> |
|---|
| 113 | 98 | </md-card-content> |
|---|
| .. | .. |
|---|
| 5 | 5 | import { LicenseTypesService } from '../resources/license_types'; |
|---|
| 6 | 6 | import { LocaleService } from '../common/i18n'; |
|---|
| 7 | 7 | import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core'; |
|---|
| 8 | | -import { IPageChangeEvent } from '@covalent/core'; |
|---|
| 8 | +import { TdDialogService } from '@covalent/core'; |
|---|
| 9 | 9 | import { Component, AfterViewInit } from '@angular/core'; |
|---|
| 10 | 10 | import { TdMediaService } from '@covalent/core'; |
|---|
| 11 | 11 | import { IComboOption, FormBase } from './base'; |
|---|
| .. | .. |
|---|
| 21 | 21 | |
|---|
| 22 | 22 | organizations : IComboOption[]; |
|---|
| 23 | 23 | licensetypes : IComboOption[]; |
|---|
| 24 | | - data: any = {}; |
|---|
| 25 | | - isNew : boolean = true; |
|---|
| 26 | | - fields: any = { |
|---|
| 27 | | - 'code': '', |
|---|
| 28 | | - 'num_licenses': '', |
|---|
| 29 | | - 'init_valid_date': '', |
|---|
| 30 | | - 'end_valid_date': '', |
|---|
| 31 | | - 'license_preactivation': '', |
|---|
| 32 | | - 'license_type_id': '', |
|---|
| 33 | | - 'organization_id': '', |
|---|
| 34 | | - 'licensetype_code': '', |
|---|
| 35 | | - 'organization_name': '', |
|---|
| 36 | | - 'preactivation_valid_period': '', |
|---|
| 37 | | - 'renew_valid_period': '', |
|---|
| 38 | | - 'application_name': '', |
|---|
| 39 | | - 'status': '', |
|---|
| 40 | | - 'metadata': '', |
|---|
| 41 | | - 'comments': '', |
|---|
| 42 | | - 'key': '', |
|---|
| 43 | | - 'value': '', |
|---|
| 44 | | - } |
|---|
| 24 | + |
|---|
| 45 | 25 | constructor(private http: Http, |
|---|
| 46 | | - toaster: ToastsManager, |
|---|
| 47 | 26 | private licenseTypes: LicenseTypesService, |
|---|
| 48 | | - route: ActivatedRoute, |
|---|
| 49 | 27 | private router: Router, |
|---|
| 50 | 28 | private packs: PacksService, |
|---|
| 51 | | - $L: LocaleService) { |
|---|
| 52 | | - super($L, route, toaster, packs, $L.get('pack')); |
|---|
| 53 | | - } |
|---|
| 54 | | - |
|---|
| 55 | | - public getFieldName(fieldId: string) : string { |
|---|
| 56 | | - return this.fields[fieldId]; |
|---|
| 29 | + toaster: ToastsManager, |
|---|
| 30 | + route: ActivatedRoute, |
|---|
| 31 | + $L: LocaleService, |
|---|
| 32 | + dialogs: TdDialogService) { |
|---|
| 33 | + super($L, route, toaster, packs, $L.get('pack'), dialogs); |
|---|
| 57 | 34 | } |
|---|
| 58 | 35 | |
|---|
| 59 | 36 | loadCombos(): void { |
|---|
| .. | .. |
|---|
| 93 | 70 | console.log(this.data.organization_id); |
|---|
| 94 | 71 | } |
|---|
| 95 | 72 | |
|---|
| 96 | | - ngOnInit(): void { |
|---|
| 97 | | - |
|---|
| 98 | | - } |
|---|
| 99 | | - |
|---|
| 100 | 73 | |
|---|
| 101 | 74 | ngAfterViewInit(): void { |
|---|
| 102 | 75 | this.loadCombos(); |
|---|
| 103 | | - super.prepareData('packId', { |
|---|
| 76 | + super.prepareInitialData('packId', { |
|---|
| 104 | 77 | status: PACK_STATUS.CREATED |
|---|
| 105 | 78 | }); |
|---|
| 106 | 79 | } |
|---|
| .. | .. |
|---|
| 3 | 3 | <button md-icon-button (click)="goBack()" color="accent"> |
|---|
| 4 | 4 | <md-icon>arrow_back</md-icon> |
|---|
| 5 | 5 | </button> |
|---|
| 6 | | - <span class="md-title" i18n>{{form_title}}</span> |
|---|
| 6 | + <span class="md-title" [innerText]="form_title"></span> |
|---|
| 7 | 7 | <span flex></span> |
|---|
| 8 | 8 | <button md-icon-button (click)="save()"><md-icon>save</md-icon></button> |
|---|
| 9 | 9 | </md-toolbar> |
|---|
| .. | .. |
|---|
| 126 | 126 | <field-readonly [value]="data.created_by_name" label="field.created_by" flex></field-readonly> |
|---|
| 127 | 127 | <field-readonly [value]="data.creation_timestamp | date: 'medium'" label="field.creation_timestamp" flex></field-readonly> |
|---|
| 128 | 128 | </div> |
|---|
| 129 | | - <div layout="column" layout-fill> |
|---|
| 130 | | - <span class="md-title" i18n>License metadata</span> |
|---|
| 131 | | - <div layout="row" layout-fill layout-padding *ngFor="let pair of data.metadata"> |
|---|
| 132 | | - <md-input-container flex="40"> |
|---|
| 133 | | - <input mdInput type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="pair.key" readonly /> |
|---|
| 134 | | - <md-placeholder> |
|---|
| 135 | | - <span i18n="field.key"></span> |
|---|
| 136 | | - </md-placeholder> |
|---|
| 137 | | - </md-input-container> |
|---|
| 138 | | - <md-input-container flex> |
|---|
| 139 | | - <input mdInput type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="pair.value" [readonly]="pair.readonly" [required]="pair.required" |
|---|
| 140 | | - /> |
|---|
| 141 | | - <md-placeholder> |
|---|
| 142 | | - <span i18n="field.value"></span> |
|---|
| 143 | | - </md-placeholder> |
|---|
| 144 | | - </md-input-container> |
|---|
| 145 | | - </div> |
|---|
| 146 | | - </div> |
|---|
| 129 | + <metadata-manager [addOrDelete]="false" [editKeys]="false" [metadata]="data.metadata" ></metadata-manager> |
|---|
| 147 | 130 | </div> |
|---|
| 148 | 131 | </form> |
|---|
| 149 | 132 | </md-card-content> |
|---|
| .. | .. |
|---|
| 26 | 26 | <template tdDataTableTemplate="menu" let-row="row" let-index="index"> |
|---|
| 27 | 27 | <div layout="row" layout-align="end center"> |
|---|
| 28 | 28 | <button md-icon-button (click)="edit(row.id)" color="primary"><md-icon>edit</md-icon></button> |
|---|
| 29 | | - <button md-icon-button (click)="delete(row)" color="warn"><md-icon>delete</md-icon></button> |
|---|
| 30 | 29 | </div> |
|---|
| 31 | 30 | </template> |
|---|
| 32 | 31 | </td-data-table> |
|---|
| .. | .. |
|---|
| 104 | 104 | this.router.navigate([`create`], {relativeTo: this.route}); |
|---|
| 105 | 105 | } |
|---|
| 106 | 106 | |
|---|
| 107 | | - edit(pack: any) : void { |
|---|
| 108 | | - this.router.navigate([`edit/${pack.id}`], {relativeTo: this.route}); |
|---|
| 107 | + edit(packId: number) : void { |
|---|
| 108 | + this.router.navigate([`edit/${packId}`], {relativeTo: this.route}); |
|---|
| 109 | 109 | } |
|---|
| 110 | 110 | |
|---|
| 111 | 111 | sort(sortEvent: ITdDataTableSortChangeEvent): void { |
|---|
| .. | .. |
|---|
| 2 | 2 | import { Injectable } from '@angular/core'; |
|---|
| 3 | 3 | import { Http, RequestOptions } from '@angular/http'; |
|---|
| 4 | 4 | import { SeCurisResourceServices } from './base'; |
|---|
| 5 | +import { LocaleService } from '../common/i18n'; |
|---|
| 5 | 6 | |
|---|
| 6 | 7 | var app_example = { code: 'CICS', |
|---|
| 7 | 8 | creation_timestamp: 1418384439000, |
|---|
| .. | .. |
|---|
| 17 | 18 | |
|---|
| 18 | 19 | @Injectable() |
|---|
| 19 | 20 | export class ApplicationsService extends SeCurisResourceServices { |
|---|
| 20 | | - constructor(http: Http) { |
|---|
| 21 | | - super(http, 'application'); |
|---|
| 21 | + constructor(http: Http, $L: LocaleService) { |
|---|
| 22 | + super($L, http, 'application'); |
|---|
| 22 | 23 | } |
|---|
| 23 | 24 | |
|---|
| 24 | 25 | |
|---|
| .. | .. |
|---|
| 1 | +import { LocaleService } from '../common/i18n'; |
|---|
| 2 | +import { BasicService } from '../common/utils'; |
|---|
| 1 | 3 | import { Observable } from 'rxjs/Observable'; |
|---|
| 2 | 4 | import { Http, RequestOptionsArgs, URLSearchParams } from '@angular/http'; |
|---|
| 3 | 5 | |
|---|
| .. | .. |
|---|
| 8 | 10 | } |
|---|
| 9 | 11 | } |
|---|
| 10 | 12 | |
|---|
| 11 | | -export class SeCurisResourceServices { |
|---|
| 12 | | - constructor(protected http: Http, |
|---|
| 13 | +export class SeCurisResourceServices extends BasicService { |
|---|
| 14 | + constructor($L: LocaleService, |
|---|
| 15 | + protected http: Http, |
|---|
| 13 | 16 | protected resource: string) { |
|---|
| 17 | + super($L); |
|---|
| 14 | 18 | } |
|---|
| 15 | 19 | |
|---|
| 16 | 20 | public get(id?: any) : Observable<any> { |
|---|
| 17 | 21 | let url = `${this.resource}/${id || ''}`; |
|---|
| 18 | | - return this.http.get(url).map(response => response.json()); |
|---|
| 22 | + return this.http.get(url).map(response => response.json()).catch(err => super.processErrorResponse(err)); |
|---|
| 19 | 23 | } |
|---|
| 20 | 24 | |
|---|
| 21 | 25 | public create(data: any) : Observable<any> { |
|---|
| 22 | 26 | let url = `${this.resource}`; |
|---|
| 23 | | - return this.http.post(url, JSON.stringify(data)).map(response => response.json()); |
|---|
| 27 | + return this.http.post(url, JSON.stringify(data)).map(response => response.json()).catch(err => super.processErrorResponse(err)); |
|---|
| 24 | 28 | } |
|---|
| 25 | 29 | |
|---|
| 26 | 30 | public modify(id: any, data: any) : Observable<any> { |
|---|
| 27 | 31 | let url = `${this.resource}/${id}`; |
|---|
| 28 | | - return this.http.post(url, JSON.stringify(data)).map(response => response.json()); |
|---|
| 32 | + return this.http.post(url, JSON.stringify(data)).map(response => response.json()).catch(err => super.processErrorResponse(err)); |
|---|
| 29 | 33 | } |
|---|
| 30 | 34 | |
|---|
| 31 | 35 | public remove(id: any) : Observable<any> { |
|---|
| 32 | 36 | let url = `${this.resource}/${id}`; |
|---|
| 33 | | - return this.http.delete(url).map(response => response.json()); |
|---|
| 37 | + return this.http.delete(url).map(response => response.json()).catch(err => super.processErrorResponse(err)); |
|---|
| 34 | 38 | } |
|---|
| 35 | 39 | |
|---|
| 36 | 40 | public action(id: any, action: string, method = 'POST') : Observable<any> { |
|---|
| .. | .. |
|---|
| 44 | 48 | search: (method == 'GET') && new MySearchParams(params) || undefined, |
|---|
| 45 | 49 | body: (method == 'POST') && JSON.stringify(params) || undefined |
|---|
| 46 | 50 | }; |
|---|
| 47 | | - return this.http.request(url, options).map(response => response.json()); |
|---|
| 51 | + return this.http.request(url, options).map(response => response.json()).catch(err => super.processErrorResponse(err)); |
|---|
| 48 | 52 | } |
|---|
| 53 | + |
|---|
| 54 | + |
|---|
| 49 | 55 | } |
|---|
| .. | .. |
|---|
| 2 | 2 | import { Injectable } from '@angular/core'; |
|---|
| 3 | 3 | import { Http, RequestOptions } from '@angular/http'; |
|---|
| 4 | 4 | import { SeCurisResourceServices } from './base'; |
|---|
| 5 | +import { LocaleService } from '../common/i18n'; |
|---|
| 5 | 6 | |
|---|
| 6 | 7 | var lictype_example = { application_name: 'CurisIntegrity', |
|---|
| 7 | 8 | code: 'CIA2', |
|---|
| .. | .. |
|---|
| 14 | 15 | |
|---|
| 15 | 16 | @Injectable() |
|---|
| 16 | 17 | export class LicenseTypesService extends SeCurisResourceServices { |
|---|
| 17 | | - constructor(http: Http) { |
|---|
| 18 | | - super(http, 'licensetype'); |
|---|
| 18 | + constructor(http: Http, $L: LocaleService) { |
|---|
| 19 | + super($L, http, 'licensetype'); |
|---|
| 19 | 20 | } |
|---|
| 20 | 21 | |
|---|
| 21 | 22 | |
|---|
| .. | .. |
|---|
| 60 | 60 | @Injectable() |
|---|
| 61 | 61 | export class LicensesService extends SeCurisResourceServices { |
|---|
| 62 | 62 | constructor(http: Http, |
|---|
| 63 | | - private $L: LocaleService) { |
|---|
| 64 | | - super(http, 'license'); |
|---|
| 63 | + $L: LocaleService) { |
|---|
| 64 | + super($L, http, 'license'); |
|---|
| 65 | 65 | } |
|---|
| 66 | 66 | |
|---|
| 67 | 67 | public getByPack(packId: number) { |
|---|
| .. | .. |
|---|
| 2 | 2 | import { Injectable } from '@angular/core'; |
|---|
| 3 | 3 | import { Http, RequestOptions } from '@angular/http'; |
|---|
| 4 | 4 | import { SeCurisResourceServices } from './base'; |
|---|
| 5 | +import { LocaleService } from '../common/i18n'; |
|---|
| 5 | 6 | |
|---|
| 6 | 7 | var org_example = { code: 'NPS', |
|---|
| 7 | 8 | creation_timestamp: 1488269722000, |
|---|
| .. | .. |
|---|
| 11 | 12 | |
|---|
| 12 | 13 | @Injectable() |
|---|
| 13 | 14 | export class OrganizationsService extends SeCurisResourceServices { |
|---|
| 14 | | - constructor(http: Http) { |
|---|
| 15 | | - super(http, 'organization'); |
|---|
| 15 | + constructor(http: Http, $L: LocaleService) { |
|---|
| 16 | + super($L, http, 'organization'); |
|---|
| 16 | 17 | } |
|---|
| 17 | 18 | |
|---|
| 18 | 19 | |
|---|
| .. | .. |
|---|
| 60 | 60 | |
|---|
| 61 | 61 | @Injectable() |
|---|
| 62 | 62 | export class PacksService extends SeCurisResourceServices { |
|---|
| 63 | | - constructor(http: Http, private $L: LocaleService) { |
|---|
| 64 | | - super(http, 'pack'); |
|---|
| 63 | + constructor(http: Http, $L: LocaleService) { |
|---|
| 64 | + super($L, http, 'pack'); |
|---|
| 65 | 65 | } |
|---|
| 66 | 66 | |
|---|
| 67 | 67 | public activate(id: number) { |
|---|
| .. | .. |
|---|
| 2 | 2 | import { Injectable } from '@angular/core'; |
|---|
| 3 | 3 | import { Http, RequestOptions } from '@angular/http'; |
|---|
| 4 | 4 | import { SeCurisResourceServices } from './base'; |
|---|
| 5 | +import { LocaleService } from '../common/i18n'; |
|---|
| 5 | 6 | |
|---|
| 6 | 7 | var user_example = { |
|---|
| 7 | 8 | creation_timestamp: 1479898458000, |
|---|
| .. | .. |
|---|
| 17 | 18 | |
|---|
| 18 | 19 | @Injectable() |
|---|
| 19 | 20 | export class UsersService extends SeCurisResourceServices { |
|---|
| 20 | | - constructor(http: Http) { |
|---|
| 21 | | - super(http, 'user'); |
|---|
| 21 | + constructor(http: Http, $L: LocaleService) { |
|---|
| 22 | + super($L, http, 'user'); |
|---|
| 22 | 23 | } |
|---|
| 23 | 24 | |
|---|
| 24 | 25 | |
|---|
| .. | .. |
|---|
| 1 | 1 | import { LocaleService } from './common/i18n'; |
|---|
| 2 | +import { BasicService } from './common/utils'; |
|---|
| 2 | 3 | import { Injectable } from '@angular/core'; |
|---|
| 3 | 4 | import { Router } from '@angular/router'; |
|---|
| 4 | 5 | import { Location } from '@angular/common'; |
|---|
| .. | .. |
|---|
| 10 | 11 | const SECURIS_TOKEN = "X-SECURIS-TOKEN"; |
|---|
| 11 | 12 | |
|---|
| 12 | 13 | @Injectable() |
|---|
| 13 | | -export class UserService { |
|---|
| 14 | +export class UserService extends BasicService { |
|---|
| 14 | 15 | |
|---|
| 15 | 16 | count : number = 0; |
|---|
| 16 | 17 | |
|---|
| 17 | | - constructor(private $L: LocaleService, |
|---|
| 18 | + constructor($L: LocaleService, |
|---|
| 18 | 19 | private router: Router, |
|---|
| 19 | 20 | private store: LocalStorageService, |
|---|
| 20 | 21 | private http: Http) { |
|---|
| 21 | | - |
|---|
| 22 | + super($L); |
|---|
| 22 | 23 | } |
|---|
| 23 | 24 | |
|---|
| 24 | 25 | public login(username: string, password: string) : Observable<string> { |
|---|
| .. | .. |
|---|
| 28 | 29 | let options = new RequestOptions({ headers: new Headers({ "Content-Type": "application/x-www-form-urlencoded" })}); |
|---|
| 29 | 30 | return this.http.post('user/login', params.toString(), options) |
|---|
| 30 | 31 | .map((resp) => this.mapLogin(resp)) |
|---|
| 31 | | - .catch((err) => this.handleError(err)); |
|---|
| 32 | + .catch((err) => super.processErrorResponse(err)); |
|---|
| 32 | 33 | } |
|---|
| 33 | 34 | |
|---|
| 34 | 35 | private mapLogin(res : Response) : string { |
|---|
| .. | .. |
|---|
| 36 | 37 | this.store.set('user_full_name', data.full_name); |
|---|
| 37 | 38 | this.store.set('username', data.username); |
|---|
| 38 | 39 | this.store.set('token', data.token); |
|---|
| 40 | + console.log('New login token: ' + data.token); |
|---|
| 39 | 41 | return <string>data.token; |
|---|
| 40 | 42 | } |
|---|
| 41 | 43 | |
|---|
| .. | .. |
|---|
| 47 | 49 | let option = new RequestOptions({ headers: new Headers({ 'X-SECURIS-TOKEN': token }) }); |
|---|
| 48 | 50 | return this.http.get('check', option) |
|---|
| 49 | 51 | .map((resp) => this.mapCheck(resp)) |
|---|
| 50 | | - .catch((err) => this.handleError(err)); |
|---|
| 52 | + .catch((err) => super.processErrorResponse(err)); |
|---|
| 51 | 53 | } |
|---|
| 52 | 54 | |
|---|
| 53 | 55 | private mapCheck(res : Response) : boolean { |
|---|
| .. | .. |
|---|
| 67 | 69 | this.router.navigate(['public/login']); |
|---|
| 68 | 70 | } |
|---|
| 69 | 71 | |
|---|
| 70 | | - |
|---|
| 71 | | - private handleError (error: Response | any) { |
|---|
| 72 | | - // In a real world app, we might use a remote logging infrastructure |
|---|
| 73 | | - let errMsg: string; |
|---|
| 74 | | - if (error instanceof Response) { |
|---|
| 75 | | - const err = JSON.stringify(error); |
|---|
| 76 | | - errMsg = `${error.status} - ${error.statusText || ''} ${err}`; |
|---|
| 77 | | - } else { |
|---|
| 78 | | - errMsg = error.message ? error.message : error.toString(); |
|---|
| 79 | | - } |
|---|
| 80 | | - |
|---|
| 81 | | - if (error.status === 403 /* forbidden */ || error.status === 401 /* unauthorized */) { |
|---|
| 82 | | - errMsg = this.$L.get('Invalid credentials'); |
|---|
| 83 | | - } else if (error.status === 418 /* Teapot */) { |
|---|
| 84 | | - errMsg = this.$L.get(error.headers.get('X-SECURIS-ERROR-MSG')); |
|---|
| 85 | | - } else { |
|---|
| 86 | | - console.error(error); |
|---|
| 87 | | - errMsg = this.$L.get(`Unexpected error HTTP (${error.status}) accessing to server. Contact with the administrator.`); |
|---|
| 88 | | - } |
|---|
| 89 | | - |
|---|
| 90 | | - console.error(errMsg); |
|---|
| 91 | | - return Observable.throw(errMsg); |
|---|
| 92 | | - } |
|---|
| 93 | 72 | |
|---|
| 94 | 73 | } |
|---|
| 95 | 74 | |
|---|
| .. | .. |
|---|
| 26 | 26 | "field.email": "Email", |
|---|
| 27 | 27 | "field.creation_timestamp": "Creation timestamp", |
|---|
| 28 | 28 | "field.comments": "Comments", |
|---|
| 29 | + "field.mandatory": "Required", |
|---|
| 30 | + "field.name": "Name", |
|---|
| 31 | + "field.license_filename": "License filename", |
|---|
| 32 | + "field.description": "Description", |
|---|
| 29 | 33 | "pack.status.CR": "Created", |
|---|
| 30 | 34 | "pack.status.AC": "Active", |
|---|
| 31 | 35 | "pack.status.OH": "On Hold", |
|---|