Skip to content

Commit

Permalink
Merge pull request #721 from adshares/develop
Browse files Browse the repository at this point in the history
v1.4.1
  • Loading branch information
m-pilarczyk authored Nov 22, 2019
2 parents 848cbf9 + d776a13 commit a343112
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.4.1] - 2019-11-22
### Improved
- Fill site name with domain
### Fixed
- Hide direct-link ad type

## [1.4.0] - 2019-11-22
### Added
- Conversions definition
Expand Down Expand Up @@ -142,7 +148,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Advertiser features (Campaigns & Ads)
- Publisher features (Sites & AdUnits)

[Unreleased]: https://github.com/adshares/adpanel/compare/v1.4.0...develop
[Unreleased]: https://github.com/adshares/adpanel/compare/v1.4.1...develop
[1.4.1]: https://github.com/adshares/adpanel/compare/v1.4.0...v1.4.1
[1.4.0]: https://github.com/adshares/adpanel/compare/v1.2.5...v1.4.0
[1.2.5]: https://github.com/adshares/adpanel/compare/v1.2.4...v1.2.5
[1.2.4]: https://github.com/adshares/adpanel/compare/v1.2.1...v1.2.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface UploadingFile {
})
export class EditCampaignCreateAdsComponent extends HandleSubscription implements OnInit {
adForms: FormGroup[] = [];
adTypes: string[] = enumToArray(adTypesEnum);
adTypes: string[] = ['image', 'html'];
adSizes: string[] = enumToArray(adSizesEnum);
adStatusesEnum = adStatusesEnum;
ads: Ad[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
dwmth-form-input
dwmth-form-input--full"
type="text"
(blur)="extractDomain()"
(focus)="onDomainFocus()"
(blur)="onDomainBlur()"
data-test="publisher-edit-site-basic-information-form-domain"
>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class EditSiteBasicInformationComponent extends HandleSubscription implem
changesSaved: boolean = false;
websiteNameLengthMax = EditSiteBasicInformationComponent.WEBSITE_NAME_LENGTH_MAX;
websiteDomainLengthMax = EditSiteBasicInformationComponent.WEBSITE_DOMAIN_LENGTH_MAX;
private overwriteNameByDomain = false;

constructor(
private router: Router,
Expand Down Expand Up @@ -116,16 +117,19 @@ export class EditSiteBasicInformationComponent extends HandleSubscription implem
};
}

extractDomain(): void {
const url = this.siteBasicInfoForm.get('domain').value;

let domain = url.toLowerCase();
//remove protocol, user info and www subdomain
domain = domain.replace(/^(?:[a-z0-9+.-]+:\/\/)?(?:\/\/)?(?:.*@)?(?:www\.)?/i, "");
// remove port number, path, query string and fragment
domain = domain.replace(/(?::.*)?(?:\/.*)?(?:\?.*)?(?:#.*)?$/i, "");
onDomainFocus(): void {
const domain = this.siteBasicInfoForm.get('domain').value;
const name = this.siteBasicInfoForm.get('name').value;
this.overwriteNameByDomain = name.length == 0 || name == domain;
}

onDomainBlur(): void {
const domain = this.extractDomain(this.siteBasicInfoForm.get('domain').value);
this.siteBasicInfoForm.get('domain').setValue(domain);
if (this.overwriteNameByDomain) {
this.siteBasicInfoForm.get('name').setValue(domain);
}
this.overwriteNameByDomain = false;
}

updateSite(): void {
Expand Down Expand Up @@ -187,4 +191,14 @@ export class EditSiteBasicInformationComponent extends HandleSubscription implem
const filterValue = val.toLowerCase();
return this.languages.filter(option => option.name.toLowerCase().includes(filterValue) || option.code.toLowerCase().includes(filterValue))
}

extractDomain(url: string): string {
let domain = url.toLowerCase();
//remove protocol, user info and www subdomain
domain = domain.replace(/^(?:[a-z0-9+.-]+:\/\/)?(?:\/\/)?(?:.*@)?(?:www\.)?/i, "");
// remove port number, path, query string and fragment
domain = domain.replace(/(?::.*)?(?:\/.*)?(?:\?.*)?(?:#.*)?$/i, "");

return domain;
}
}

0 comments on commit a343112

Please sign in to comment.