Angular CLI PWA - ngsw-config only caching images referenced in CSS - caching

So this is a bit of a strange issue that I can't seem to find reference to anywhere online. Was hoping someone here could shed some light on the following, as well as a potential fix -
I have and Angular CLI application which is compliant with Google's PWA requirements. Everything works just as expected, however some of the images are not being cached by the service worker.
Here is my ngsw-config.json -
{
"$schema": "./node_modules/#angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/*.css",
"/*.js",
"../assets/signalR/appHub.js",
"../admin/images/**",
"../manifest/manifest.json"
],
"urls": [
"/api/WhoAmI",
"/api/GetApps"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)",
"../admin/images/**"
]
}
}
]
}
Inside the admin/images folder, there are some background images, logos, spinners, icon etc.
However, when I run 'ng-build --prod', the only images that get cached are those which are references in CSS (background-image). Any which are placed onto the page itself are ignored.
This results in an offline page with no logos or icons.
Looking at the generated 'dist' folder, the 'working' image files are copied and given a random suffix.
Inside the generated ngsw.json file, these are the only images referenced, no mention of the missing logos etc.
{
"configVersion": 1,
"timestamp": 1568879436433,
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"updateMode": "prefetch",
"urls": [
"/favicon.ico",
"/index.html",
"/main-es2015.b125878abf05e7d82b63.js",
"/main-es5.6e9e620d3fbd96496f98.js",
"/polyfills-es2015.4d31cca2afc45cfd85b5.js",
"/polyfills-es5.2219c87348e60efc0076.js",
"/runtime-es2015.703a23e48ad83c851e49.js",
"/runtime-es5.465c2333d355155ec5f3.js",
"/scripts.f616c8c0191ed4649bce.js",
"/styles.a4be089a70c69f63e366.css"
],
"patterns": [
"\\/api\\/WhoAmI",
"\\/api\\/GetApps"
]
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"urls": [
"/assets/signalR/appHub.js",
"/bgrounds-geometric-black.8d983f6875c006eda992.png",
"/bgrounds-geometric-red.1484266e3058319624bd.png",
"/block-spinner-dark.20f05a2ddef506c61f4d.gif",
...
}
...
}
Is anyone able to demystify this at all?
Apologies for the long question, but if you've got this far, thank you :)
Any help is appreciated!

Through messing around with a few different things, I found a workaround for this - doesn't explain why it was not working initially though.
It seems that renaming my folder from admin/images to assets/images and updating the relevant resource > files paths got it working.
If anyone stumbled upon some more insight into the cause of this, please let me know.
Thanks,
Rob

I added below line to ngsw-config.json
"/runtime*",
"/main*",
"/style*",
"/polyfill*"
It looks like this afterwards
{
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/runtime*",
"/main*",
"/style*",
"/polyfill*",
"/favicon.ico",
"/index.html",
"/css",
"/js"
]
}
}, {
Then it worked.

Related

Searching for Patient within a Bundle

We use Bundles to contain other resources. I want to search for bundles based on these nested resources. e.g. I have bundles that look like this:
{
"resourceType": "Bundle",
"type": "collection",
"entry": [
{
"resource": {
"resourceType": "Patient",
"identifier": [
{
"type": {
"coding": [
{
"code": "foo"
}
]
},
"value": "12345"
},
{
"type": {
"coding": [
{
"code": "bar"
}
]
},
"value": "abcde"
}
]
}
},
{
"resource": {
"resourceType": "SomeOtherResource"
}
}
]
}
I want to find all bundles which have Patient with "bar" == "abcde". There will be many such bundles and each Patient will have many identifiers other than "bar"
I've looked through https://www.hl7.org/fhir/search.html, but all the examples I find assume that (e.g.) Patient is at the top level and I can search with [base]/Patient?..., but I am looking for Bundles. I've looked through the search parameters here but those don't include any "contained" entries.
I've tried all the combinations of bundle/patient/identifier I can think of with no luck. Is this even supported?
If your Bundle is a FHIR Document or FHIR Message, you can search by chaining through the 'composition' or 'message' search parameter. Otherwise, there's no standard way to search. In general, content within a Bundle is opaque.

FHIR - Contained Resources and Referencing

I am still new to FHIR and trying to connect the dots.
If I have a resource that I want to contain other resources, can I refer to it by element name (#myElementName) or do I need to use the contained resource id? (#myDeviceId).
I've included sample code below. What I would like to accomplish is to have a Basic resource that has two extensions: TestConfiguration(Device) and DigitalSample(ImagingStudy). I would like for both of these resources to be contained.
PS: I generated the code below using custom classes and the .net API.
Thank you much!
{
"resourceType": "TestInput",
"contained": [
{
"resourceType": "TestConfiguration",
"id": "TestConfigurationId",
"contained": [
{
"resourceType": "DeviceDefinition",
"modelNumber": "ABC123"
}
],
"definition": {
"reference": "#definition"
}
},
{
"resourceType": "DigitalSample",
"id": "DigitalSampleId"
}
],
"extension": [
{
"url": "http://MyOrganization.com/fhir/R4/StructureDefinition/Basic-TestConfiguration",
"valueReference": {
"reference": "#testConfiguration"
}
},
{
"url": "http://MyOrganization.com/fhir/R4/StructureDefinition/Basic-DigitalSample",
"valueReference": {
"reference": "#digitalSampleId"
}
}
]
}
Every local reference must point to an id of a contained resource.
In your case it should be:
"reference": "#TestConfigurationId"
"reference":"#DigitalSampleId"
Always check https://www.hl7.org/fhir/ for what you need to do. Always check the FHIR version

Azure IoT event subscription with ARM template

I am trying to deploy Azure IoT device connected event subscription to Azure storage queue using ARM template and PowerShell. I have used the following template for deploying this. Also, I have read a lot of articles on Microsoft. But could not find any solution. Please help me to figure it out.
"resources": [
{
"type": "Microsoft.EventGrid/eventSubscriptions",
"name": "DeviceConnected",
"location": "[resourceGroup().location]",
"apiVersion": "2018-01-01",
"dependsOn": [
"[resourceId('Microsoft.Devices/IotHubs', variables('iotHubName'))]"
],
"properties": {
"destination": {
"endpointType": "storagequeue",
"properties": {
"queueName":"device-connnection-state-queue",
"resourceId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]"
}
},
"filter": {
"includedEventTypes": [
"Microsoft.Devices.DeviceConnected"
]
}
}
}
],
The error is showing like
The error you're seeing is related to the dependsOn property you've specified.
From MS documentation
Resources that must be deployed before this resource is deployed. Resource Manager evaluates the dependencies between resources and deploys them in the correct order. When resources aren't dependent on each other, they're deployed in parallel. The value can be a comma-separated list of a resource names or resource unique identifiers. Only list resources that are deployed in this template. Resources that aren't defined in this template must already exist. Avoid adding unnecessary dependencies as they can slow your deployment and create circular dependencies. For guidance on setting dependencies, see Defining dependencies in Azure Resource Manager templates.
So a resource that is not defined in an ARM template cannot be used in a DependsOn property.
Here is the documentation related to event subscription creation:
Microsoft.EventGrid eventSubscriptions template reference
There are not so much samples on how to create event subscription but you can extract some part of the template from the Azure Portal:
Click + Event Subscription
Fill in the details
Click the Advanced Editor button link on the top right corner
It will show you some of the details you need to create your ARM Template
Here is how a sample ARM template can look likes:
"resources": [
{
"type": "Microsoft.Devices/IotHubs/providers/eventSubscriptions",
"apiVersion": "2019-01-01",
"name": "[concat(parameters('iotHubName'), '/Microsoft.EventGrid/', parameters('eventSubName'))]",
"location": "[resourceGroup().location]",
"properties": {
"topic": "[resourceId('Microsoft.Devices/IotHubs', parameters('iotHubName'))]",
"destination": {
"endpointType": "StorageQueue",
"properties": {
"resourceId": "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]",
"queueName": "[parameters('queueName')]"
}
},
"filter": {
"includedEventTypes": [
"Microsoft.Devices.DeviceConnected"
],
"advancedFilters": []
},
"labels": [],
"eventDeliverySchema": "EventGridSchema"
}
}
]

Missing elements for a Google Cloud Video Annotation request

I am trying to run annotation on a video using the Google Cloud Video Intelligence API. Annotation requests with just one feature request (i.e., one of "LABEL_DETECTION", "SHOT_CHANGE_DETECTION" or "EXPLICIT_CONTENT_DETECTION"), things work fine. However, when I request an annotation with two or more features at the same time, the response does not always return all the request feature fields. For example, here is a request I ran recently using the API explorer:
{
"features": [
"EXPLICIT_CONTENT_DETECTION",
"LABEL_DETECTION",
"SHOT_CHANGE_DETECTION"
],
"inputUri": "gs://gccl_dd_01/Video1"
}
The operation Id I got back is this: "us-east1.11264560501473964275". When I run a GET with this Id, I have the following response:
200
{
"name": "us-east1.11264560501473964275",
"metadata": {
"#type": "type.googleapis.com/google.cloud.videointelligence.v1.AnnotateVideoProgress",
"annotationProgress": [
{
"inputUri": "/gccl_dd_01/Video1",
"progressPercent": 100,
"startTime": "2018-08-06T17:13:58.129978Z",
"updateTime": "2018-08-06T17:18:01.274877Z"
},
{
"inputUri": "/gccl_dd_01/Video1",
"progressPercent": 100,
"startTime": "2018-08-06T17:13:58.129978Z",
"updateTime": "2018-08-06T17:14:39.074505Z"
},
{
"inputUri": "/gccl_dd_01/Video1",
"progressPercent": 100,
"startTime": "2018-08-06T17:13:58.129978Z",
"updateTime": "2018-08-06T17:16:23.230536Z"
}
]
},
"done": true,
"response": {
"#type": "type.googleapis.com/google.cloud.videointelligence.v1.AnnotateVideoResponse",
"annotationResults": [
{
"inputUri": "/gccl_dd_01/Video1",
"segmentLabelAnnotations": [
...
],
"shotLabelAnnotations": [
...
],
"shotAnnotations": [
...
]
}
]
}
}
The done parameter for the response is set to true, but it does not have any field containing the annotations for Explicit Content.
This issue seems to be occurring at random to my novice eyes. The APIs will return a response with all parameters on some occasions and be missing one on others. I am wondering if there is anything I am missing here or something on my end that is causing this?
I did some tests using just LABEL_DETECTION, just EXPLICIT_CONTENT_DETECTION and using the three of them.
As I am not using videos with explicit content, I don't see any specific field when adding just EXPLICIT_CONTENT_DETECTION:
{
"name": "europe-west1.462458490043912485",
"metadata": {
"#type": "type.googleapis.com/google.cloud.videointelligence.v1.AnnotateVideoProgress",
"annotationProgress": [
{
"inputUri": "/cloud-ml-sandbox/video/chicago.mp4",
"startTime": "2018-08-07T14:18:40.086713Z",
"updateTime": "2018-08-07T14:18:40.230351Z"
}
]
}
}
Can you share a specific video sample, the request.json used and two different outputs, please?

FHIR DSTU2: What is the correct way to represent an extension value as a collection?

I'm currently looking into creating a FHIR DSTU2 extension. I need the extension to return a collection of values. What is the correct way to represent this in FHIR DSTU2?
Should it be a list of extensions within an extension:
"resource": {
"resourceType": "Medication",
"extension": [
{
"url": "http://www.myextension.com/strengths",
"extension": [
{
"url": "http://www.myextension.com/strength",
"valueStrength": "5mg"
},
{
"url": "http://www.myextension.com/strength",
"valueStrength": "20mg"
}
]
}
],
}
Or should it be one extension with a collection on the value?
"resource": {
"resourceType": "Medication",
"extension": [
{
"url": "http://www.emis-online.com/strengths",
"valueStrengths": [
"5mg",
"20mg"
],
}
],
}
Thanks.
It would actually look like this:
"resource": {
"resourceType": "Medication",
"extension": [
{
"url": "http://www.myextension.com/strength",
"valueString": "5mg"
},
{
"url": "http://www.myextension.com/strength",
"valueString": "20mg"
}
]}
As well, it'd be better to use valueQuantity than valueString - to split the value and the unit.
That said, there's no reason to use an extension for drug strengths at all. Medication.product.ingredient.amount is strength - if the ingredient is an active ingredient. (I see that the resource doesn't currently allow distinguishing active from excipient ingredients, so I'd encourage raising a change request on that.)

Resources