Skip to content

Commit 37b8eb2

Browse files
authored
Merge pull request #20 from kotl/main
Terraform and layout optimizations
2 parents 6eb5c8a + 414825e commit 37b8eb2

25 files changed

Lines changed: 196 additions & 82 deletions

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ to store the to-do list items.
2929
3030
## Explore the app's codebase
3131

32-
- In `src/environments/environments.ts`, you can find important configuration values:
32+
- In `src/bootstrap.js`, you can find important configuration values:
3333

3434
- Within `firebase`, find the values needed to connect your app to Firebase
3535
(most importantly `apiKey`, `projectId`, and `appId`).
36-
- Find your Gemini API key (`gemini_api_key`).
36+
- Find your Gemini API key (`geminiApiKey`).
3737

3838
Note that if you
3939
[run the sample app in IDX](https://github.com/FirebaseExtended/make-it-so-angular/main/README.md#set-up-and-run-the-app),
@@ -105,12 +105,12 @@ to complete some manual setup steps.
105105
c. Create a new Firebase web app in your new project.
106106
You can skip setting up Firebase Hosting.
107107
d. Copy your Firebase config object, and replace the placeholder values in the
108-
`src/environments/environments.ts` file of the sample app.
108+
`src/bootstrap.js` file of the sample app.
109109

110110
2. Set up the Gemini API:
111111
a. [Get a Gemini API key](https://aistudio.google.com/app/apikey) in Google AI Studio.
112112
Use the Firebase project you just created.
113-
b. Add your Gemini API key into the `src/environments/environments.ts` file of the sample app.
113+
b. Add your Gemini API key into the `src/bootstrap.js` file of the sample app.
114114

115115
3. Run `npm install` to install the app's dependencies.
116116

@@ -173,7 +173,7 @@ your Firebase project (as described below).
173173
view and delete your Gemini API key.
174174
- In the sample app's codebase, delete references to the Gemini API key in the following places:
175175
- `google_apikeys_key` resource entry in `main.tf`
176-
- `gemini_api_key` in both `src/environments/environments.ts` and `src/environments/environments.ts.tmpl`
176+
- `geminiApiKey` in both `src/bootstrap.js` and `src/bootstrap.js.tmpl`
177177

178178
- If you're no longer using the Google AI Gemini API, then disable it in your project
179179
and delete references to it in your sample app's codebase:

angular.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@
3434
}
3535
],
3636
"styles": ["src/styles.scss"],
37-
"scripts": []
37+
"scripts": [
38+
{
39+
"input": "src/bootstrap.js",
40+
"inject": false
41+
}
42+
]
3843
},
3944
"configurations": {
4045
"production": {

idx-template.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
"name": "Firebase Project ID",
1515
"type": "string",
1616
"required": true
17+
},
18+
{
19+
"id": "bootstrapJs",
20+
"name": "Sample App Bootstrap",
21+
"type": "string",
22+
"required": false
1723
}
1824
]
1925
}

idx-template.nix

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
{ pkgs, projectId, ... }:
1+
{ pkgs, projectId, bootstrapJs, ... }:
22
{
33
bootstrap = ''
44
cp -rf ${./.} "$out/"
55
chmod -R +w "$out"
6-
6+
echo 'bootstrapJs was set to: ${bootstrapJs}'
77
# Apply project ID to configs
8-
sed -e 's/<project-id>/${projectId}/' ${.idx/dev.nix} > "$out/.idx/dev.nix"
9-
8+
if [ -z '${bootstrapJs}' ] || [ '${bootstrapJs}' = 'false' ]
9+
then
10+
sed -e 's/<project-id>/${projectId}/' ${.idx/dev.nix} > "$out/.idx/dev.nix"
11+
else
12+
sed -e 's/<project-id>/${projectId}/' ${.idx/dev.nix} | sed -e 's/terraform init/# terraform init/' | sed -e 's/terraform apply/# terraform apply/' > "$out/.idx/dev.nix"
13+
echo '${bootstrapJs}' > "$out/src/bootstrap.js"
14+
echo '{"projects":{"default":"${projectId}"}}' > "$out/.firebaserc"
15+
fi
1016
# Remove the template files themselves and any connection to the template's
1117
# Git repository
1218
rm -rf "$out/.git" "$out/idx-template".{nix,json} "$out/node_modules"

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ resource "google_apikeys_key" "generativelanguage" {
7171
project = var.project
7272

7373
name = "gemini-api-key"
74-
display_name = "Gemini API Key"
74+
display_name = "Generative language Gemini API Key"
7575

7676
restrictions {
7777
api_targets {
@@ -118,7 +118,7 @@ resource "google_firebaserules_release" "firestore" {
118118
resource "google_firebase_web_app" "example" {
119119
project = var.project
120120

121-
display_name = "Make It So AI!"
121+
display_name = "Sample Firebase AI App"
122122
}
123123

124124
data "google_firebase_web_app_config" "example" {
@@ -144,13 +144,13 @@ resource "local_file" "firebaserc" {
144144
}
145145

146146
resource "local_file" "environment_ts" {
147-
content = templatefile("${path.module}/src/environments/environments.ts.tmpl", merge(
147+
content = templatefile("${path.module}/src/bootstrap.js.tmpl", merge(
148148
data.google_firebase_web_app_config.example,
149149
{
150150
project_id = data.google_project.project.project_id,
151151
gemini_api_key = google_apikeys_key.generativelanguage.key_string,
152152
debug_token = "" # Use local.uuid4 in when using Vertex AI in Firebase
153153
}
154154
))
155-
filename = "${path.module}/src/environments/environments.ts"
155+
filename = "${path.module}/src/bootstrap.js"
156156
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@angular/platform-browser": "^18.1.0",
2222
"@angular/platform-browser-dynamic": "^18.1.0",
2323
"@google/generative-ai": "^0.19.0",
24+
"backoff-rxjs": "^7.0.0",
2425
"firebase": "^10.13.0",
2526
"rxjs": "~7.8.0",
2627
"tslib": "^2.3.0",

pnpm-lock.yaml

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/app.component.html

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
Copyright 2024 Google LLC
2+
Copyright 2025 Google LLC
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -16,19 +16,29 @@
1616
<div class="site-layout h-screen overflow-scroll">
1717
<div class="w-full py-4 flex flex-col lg:px-12 mb-8">
1818
<!-- Icon and Title Section -->
19-
<div class="flex items-center p-8 pl-[10%] justify-start">
19+
@if (viewCodeLink) {
20+
<div
21+
class="w-full mr-8 flex items-center justify-center ">
22+
<div class="pl-[10%] pr-[10%] banner font-light flex flex-col sm:flex-row items-center">
23+
<img src="assets/link.svg" class="link">
24+
<span>{{viewCodeMessage}}</span>
25+
<a mat-button class="m-1" [href]="viewCodeLink" target="_blank" rel="noopener">Create Workspace</a>
26+
</div>
27+
</div>
28+
}
29+
<div class="flex items-center p-6 pb-0 pl-[10%] justify-start">
2030
<img
21-
src="../assets/Spark_Gradient.png"
31+
src="../assets/gemini_logo.svg"
2232
alt="Icon"
2333
class="w-12 h-12 mr-4"
2434
/>
25-
<h1 class="text-3xl" style="font-family: 'Helvetica Neue', sans-serif">
35+
<h1 class="text-2xl md:text-3xl">
2636
Planning with the Gemini API
2737
</h1>
2838
</div>
2939

3040
<div
31-
class="w-full p-4 flex flex-col lg:items-start lg:flex-row lg:gap-6 justify-between items-center mx-auto"
41+
class="w-full p-4 py-0 flex flex-col lg:items-start lg:flex-row lg:gap-6 justify-between items-center mx-auto"
3242
>
3343
<!-- Task Generation -->
3444
<div
@@ -37,7 +47,7 @@ <h1 class="text-3xl" style="font-family: 'Helvetica Neue', sans-serif">
3747
<div class="flex-grow flex flex-col justify-between overflow-scroll">
3848
<div>
3949
<!-- Checkbox Images Section -->
40-
<div class="w-[90%] flex gap-12 justify-center mx-auto">
50+
<div class="w-full flex gap-12 mb-4 p-4 justify-center mx-auto">
4151
<app-checkboximage
4252
#location
4353
[src]="'/assets/location.png'"
@@ -55,7 +65,7 @@ <h1 class="text-3xl" style="font-family: 'Helvetica Neue', sans-serif">
5565
<!-- Prompt Input Section -->
5666
<form>
5767
<div class="w-full flex flex-col justify-between gap-4 mb-4 p-4 lg:flex-row xl:flex-row">
58-
<mat-form-field class="w-11/12 mb-8" appearance="outline">
68+
<mat-form-field class="w-full mb-8" appearance="outline">
5969
<mat-label>Add a prompt</mat-label>
6070
<textarea
6171
[formControl]="formControls.prompt"
@@ -80,15 +90,15 @@ <h1 class="text-3xl" style="font-family: 'Helvetica Neue', sans-serif">
8090
</mat-form-field>
8191
<button
8292
mat-button
83-
class="mt-6 flex items-center gap-2 pr-4"
93+
class="mt-6 flex items-center gap-2 pr-4 with-bg"
8494
(click)="onGoClick()"
8595
[disabled]="!formControls.prompt.value"
8696
>
8797
<span class="flex items-center">
8898
<img
8999
src="../assets/spark_icon_24.svg"
90100
alt="Gemini Icon"
91-
class="w-6 h-6"
101+
class="w-12 h-6"
92102
/>
93103
<span class="p-2">Go</span>
94104
</span>
@@ -118,8 +128,8 @@ <h1 class="text-3xl" style="font-family: 'Helvetica Neue', sans-serif">
118128
<div class="flex flex-row gap-4 w-full justify-end">
119129
<button
120130
mat-button
121-
[disabled]="!generatedTask"
122-
class="w-36 text-md"
131+
[disabled]="!generatedTask || !(firestoreReady | async)"
132+
class="w-36 text-md with-bg"
123133
(click)="onSave()"
124134
>
125135
Save

src/app/app.component.scss

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2024 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,11 +21,29 @@
2121
}
2222

2323
.mat-mdc-button {
24-
background-color: #bbdefb;
24+
--mdc-text-button-label-text-color: #0B57D0;
2525
height: 48px;
26-
border-radius: 0.75rem
26+
border-radius: 0.75rem;
27+
}
28+
29+
.with-bg {
30+
--mdc-text-button-label-text-color: 181C20;
31+
background-color: #bbdefb;
2732
}
2833

2934
::ng-deep .mdc-notched-outline__notch {
3035
border-right: none;
3136
}
37+
38+
.banner {
39+
border-radius: 24px;
40+
border-color: #0B57D0;
41+
border-width: 1px;
42+
font-family: 'Google Sans Text';
43+
font-size: 14px;
44+
}
45+
46+
.link {
47+
float:left;
48+
margin: 12px;
49+
}

src/app/app.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2024 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)