-
Notifications
You must be signed in to change notification settings - Fork 1
/
src_app_custom-elements_announcement-bar_announcement-bar_module_ts.b72ac8f808c1cd8b.js.map
1 lines (1 loc) · 4.72 KB
/
src_app_custom-elements_announcement-bar_announcement-bar_module_ts.b72ac8f808c1cd8b.js.map
1
{"version":3,"mappings":"kUA8CEA,iBACEA,iBACEA,iBACAA,eACAA,eAAgDA,sBAAUA,QAC5DA,QACFA,8BAJSA,oDACFA,yDACeA,qDA7CxB,MAAMC,EAAoBC,KAAqB,qBAiDxC,IAAMC,EAAb,MAAM,QAGJC,YAAoBC,EAA0BC,GAA1BC,YAA0BA,cAE9CC,WACED,KAAKE,KAAKC,IAAoBT,GAC3BU,MACC,OAAWN,IACTE,KAAKK,OAAOC,MAAM,IAAIC,MAAM,GAAGb,qBAAqCI,EAAMU,YACnE,QAETC,KAAIX,GAAiBE,KAAKU,wBAAwBZ,KAClD,OAAWA,IACTE,KAAKK,OAAOC,MAAM,IAAIC,MAAM,GAAGb,4BAA4CI,EAAMU,YAC1E,MAGVG,UAAUb,GAAgBE,KAAKY,aAAed,GAM3CY,wBAAwBZ,GAC9B,OAAOA,EACJe,OAAOd,GAAgB,IAAIe,KAAKf,EAAagB,WAAWC,UAAYF,KAAKG,OACzEJ,OAAOd,GAAgB,IAAIe,KAAKf,EAAamB,SAASF,UAAYF,KAAKG,OACvE,iDA5BME,GAAwB1B,iDAAxB0B,EAAwBC,0OARnC3B,4BAAiCA,kEAQtB0B,GAAb,GC1CaE,EAAb,MAAM,QALNxB,cAMEG,4BAAoCJ,gDADzBuB,4DAJF,CAAEG,KAAcC,IAAcC,SAI5BL,GAAb","names":["n","c","g","h","constructor","e","r","this","ngOnInit","http","get","pipe","logger","error","Error","message","d","findCurrentAnnouncement","subscribe","announcement","filter","Date","startDate","valueOf","now","endDate","t","selectors","v","m","l","u"],"sources":["./src/app/custom-elements/announcement-bar/announcement-bar.component.ts","./src/app/custom-elements/announcement-bar/announcement-bar.module.ts"],"sourcesContent":["import { Component, OnInit } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { catchError, map } from 'rxjs/operators';\nimport { Logger } from 'app/shared/logger.service';\nimport { CONTENT_URL_PREFIX } from 'app/documents/document.service';\nconst announcementsPath = CONTENT_URL_PREFIX + 'announcements.json';\n\nexport interface Announcement {\n imageUrl: string;\n message: string;\n linkUrl: string;\n startDate: string;\n endDate: string;\n}\n\n/**\n * Display the latest live announcement. This is used on the homepage.\n *\n * The data for the announcements is kept in `aio/content/marketing/announcements.json`.\n *\n * The format for that data file looks like:\n *\n * ```\n * [\n * {\n * \"startDate\": \"2018-02-01\",\n * \"endDate\": \"2018-03-01\",\n * \"message\": \"This is an <b>important</b> announcement\",\n * \"imageUrl\": \"url/to/image\",\n * \"linkUrl\": \"url/to/website\"\n * },\n * ...\n * ]\n * ```\n *\n * Only one announcement will be shown at any time. This is determined as the first \"live\"\n * announcement in the file, where \"live\" means that its start date is before today, and its\n * end date is after today.\n *\n * **Security Note:**\n * The `message` field can contain unsanitized HTML but this field should only updated by\n * verified members of the Angular team.\n */\n@Component({\n selector: 'aio-announcement-bar',\n template: `\n <div class=\"homepage-container\" *ngIf=\"announcement\">\n <div class=\"announcement-bar\">\n <img [src]=\"announcement.imageUrl\" alt=\"\">\n <p [innerHTML]=\"announcement.message\"></p>\n <a class=\"button\" [href]=\"announcement.linkUrl\">Learn More</a>\n </div>\n </div>`\n})\nexport class AnnouncementBarComponent implements OnInit {\n announcement: Announcement;\n\n constructor(private http: HttpClient, private logger: Logger) {}\n\n ngOnInit() {\n this.http.get<Announcement[]>(announcementsPath)\n .pipe(\n catchError(error => {\n this.logger.error(new Error(`${announcementsPath} request failed: ${error.message}`));\n return [];\n }),\n map(announcements => this.findCurrentAnnouncement(announcements)),\n catchError(error => {\n this.logger.error(new Error(`${announcementsPath} contains invalid data: ${error.message}`));\n return [];\n }),\n )\n .subscribe(announcement => this.announcement = announcement);\n }\n\n /**\n * Get the first date in the list that is \"live\" now\n */\n private findCurrentAnnouncement(announcements: Announcement[]) {\n return announcements\n .filter(announcement => new Date(announcement.startDate).valueOf() < Date.now())\n .filter(announcement => new Date(announcement.endDate).valueOf() > Date.now())\n [0];\n }\n}\n","import { NgModule, Type } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { HttpClientModule } from '@angular/common/http';\nimport { SharedModule } from '../../shared/shared.module';\nimport { AnnouncementBarComponent } from './announcement-bar.component';\nimport { WithCustomElementComponent } from '../element-registry';\n\n@NgModule({\n imports: [ CommonModule, SharedModule, HttpClientModule ],\n declarations: [ AnnouncementBarComponent ],\n entryComponents: [ AnnouncementBarComponent ],\n})\nexport class AnnouncementBarModule implements WithCustomElementComponent {\n customElementComponent: Type<any> = AnnouncementBarComponent;\n}\n"],"sourceRoot":"webpack:///","file":"src_app_custom-elements_announcement-bar_announcement-bar_module_ts.b72ac8f808c1cd8b.js"}