-
Notifications
You must be signed in to change notification settings - Fork 1
/
src_app_custom-elements_announcement-bar_announcement-bar_module_ts.240790ec3c19d525.js.map
1 lines (1 loc) · 4.8 KB
/
src_app_custom-elements_announcement-bar_announcement-bar_module_ts.240790ec3c19d525.js.map
1
{"version":3,"mappings":"qTA8CEA,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,KAAKF,KAAKI,IAAoBR,GAC3BS,MACCC,OAAWC,IACTL,KAAKD,OAAOM,MAAM,IAAIC,MAAM,GAAGZ,qBAAqCW,EAAME,YACnE,QAETC,KAAIC,GAAiBT,KAAKU,wBAAwBD,KAClDL,OAAWC,IACTL,KAAKD,OAAOM,MAAM,IAAIC,MAAM,GAAGZ,4BAA4CW,EAAME,YAC1E,MAGVI,UAAUC,GAAgBZ,KAAKY,aAAeA,GAM3CF,wBAAwBD,GAC9B,OAAOA,EACJI,OAAOD,GAAgB,IAAIE,KAAKF,EAAaG,WAAWC,UAAYF,KAAKG,OACzEJ,OAAOD,GAAgB,IAAIE,KAAKF,EAAaM,SAASF,UAAYF,KAAKG,OACvE,iDA5BMrB,GAAwBH,iDAAxBG,EAAwBuB,0OARnC1B,4BAAiCA,kEAQtBG,GAAb,GC3CawB,EAAb,MAAM,QAJNvB,cAKEG,4BAAoCJ,gDADzBwB,4DAHF,CAAEC,KAAcC,IAAcC,SAG5BH,GAAb","names":["i0","announcementsPath","CONTENT_URL_PREFIX","AnnouncementBarComponent","constructor","http","logger","this","ngOnInit","get","pipe","catchError","error","Error","message","map","announcements","findCurrentAnnouncement","subscribe","announcement","filter","Date","startDate","valueOf","now","endDate","selectors","AnnouncementBarModule","CommonModule","SharedModule","HttpClientModule"],"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})\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.240790ec3c19d525.js"}