Skip to content

Commit add28b4

Browse files
authored
Merge branch 'main' into web_socket
2 parents 46d3522 + d0a1d9e commit add28b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3618
-42
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ You can contribute to the project in any or all of the following ways:
1111
- Add documentation
1212
- Add a new feature, resolve an existing issue or add a new test to the project. (Goto [Code Contribution Guidelines](#code-contribution-guidelines)).
1313

14-
### I have not contributed to any open source project before. Will I get any guidance?
14+
## Resources for New Contributors
1515

16-
In case you are new to the open source ecosystem, we would be more than happy to guide you through the entire process. Just join our [Discord server](https://bit.ly/heyfoss) and drop a message in the **#foss** channel.
16+
- API Dash Code Walkthrough - [Video](https://www.youtube.com/live/rIlwCTKNz-A?si=iMxTxzkpY_ySo4Ow&t=339)
17+
- Getting Started with Flutter - [Video](https://www.youtube.com/watch?v=8K2gV1P6ZHI)
18+
- API Dash Developer Guide - [Read](https://github.com/foss42/apidash/blob/main/doc/dev_guide/README.md)
1719

1820
## Code Contribution Guidelines
1921

22+
### I have not contributed to any open source project before. Will I get any guidance?
23+
24+
In case you are new to the open source ecosystem, we would be more than happy to guide you through the entire process. Just join our [Discord server](https://bit.ly/heyfoss) and drop a message in the **#foss** channel.
25+
2026
### Some things to keep in mind before opening a PR
2127

2228
> PRs with precise changes (like adding a new test, resolving a bug/issue, adding a new feature) are always preferred over a single PR with a ton of file changes as they are easier to review and merge.

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,15 @@ Just click on the [Issue tab](https://github.com/foss42/apidash/issues) to raise
254254

255255
Please find the Roadmap for API Dash [here](https://github.com/foss42/apidash/blob/main/ROADMAP.md).
256256

257-
## Documentation
257+
## Documentation (User Guide & Developer Guide)
258258

259259
All docs are currently available in the [doc](https://github.com/foss42/apidash/blob/main/doc/) folder.
260260

261+
## Resources for New Contributors
262+
263+
- Developer Guide - [Read](https://github.com/foss42/apidash/blob/main/doc/dev_guide/README.md)
264+
- Code Walkthrough - [Video](https://www.youtube.com/live/rIlwCTKNz-A?si=iMxTxzkpY_ySo4Ow&t=339)
265+
261266
## Contribute to API Dash
262267

263268
You can contribute to API Dash in any or all of the following ways:

doc/dev_guide/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@
88
6. [Packaging API Dash](https://github.com/foss42/apidash/blob/main/doc/dev_guide/packaging.md)
99
7. Other Topics
1010
- [Flutter Rust Bridge Experiment for Parsing Hurl](https://github.com/foss42/apidash/blob/main/doc/dev_guide/flutter_rust_bridge_experiment.md)
11+
12+
## Code Walkthrough for New Contributors
13+
14+
[Video](https://www.youtube.com/live/rIlwCTKNz-A?t=339)
56.9 KB
Loading
99.7 KB
Loading
86.9 KB
Loading
86.8 KB
Loading

doc/dev_guide/packaging.md

Lines changed: 172 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Packaging API Dash
22

3+
- [Windows](#windows)
4+
- [macOS](#macos)
5+
- [Linux Debian (.deb) & RPM (.rpm)](#linux-debian-deb--rpm-rpm)
6+
- [Arch Linux (PKGBUILD)](#arch-linux-pkgbuild)
7+
- [FlatHub (Flatpak)](#flathub-flatpak)
8+
- [Homebrew](#homebrew)
9+
- [Chocolatey](#chocolatey)
10+
- [WinGet](#winget)
11+
312
## Windows
413

514
[Packaging and Distributing Flutter Desktop Apps : Creating Windows .exe installer](https://medium.com/@fluttergems/packaging-and-distributing-flutter-desktop-apps-the-missing-guide-for-open-source-indie-0b468d5e9e70)
@@ -22,11 +31,172 @@ TODO Instructions
2231

2332
## Homebrew
2433

25-
TODO Instructions
34+
Homebrew Formula Submission
35+
36+
### 1. Prepare Tap Repository
37+
38+
```
39+
# Create Homebrew tap
40+
gh repo create homebrew-tap --public --clone
41+
mkdir -p homebrew-tap/Formula
42+
cd homebrew-tap
43+
```
44+
45+
### 2. Package apidash
46+
47+
```
48+
# Build macOS bundle
49+
flutter build macos
50+
51+
# Create versioned tarball
52+
tar -czvf apidash-v1.0.0.tar.gz \
53+
-C build/macos/Build/Products/Release/ \
54+
Apidash.app
55+
56+
# Generate SHA256 checksum
57+
shasum -a 256 apidash-v1.0.0.tar.gz
58+
```
59+
60+
### 3. Create Formula File
61+
62+
`Formula/apidash.rb`:
63+
64+
```
65+
class Apidash < Formula
66+
desc "Modern API dashboard for developers"
67+
homepage "https://apidash.dev"
68+
url "https://github.com/<user>/<repo>/releases/download/v1.0.0/apidash-v1.0.0.tar.gz"
69+
sha256 "PASTE_YOUR_SHA256_HERE"
70+
71+
def install
72+
prefix.install "Apidash.app"
73+
bin.write_exec_script prefix/"Apidash.app/Contents/MacOS/Apidash"
74+
end
75+
76+
test do
77+
system "#{bin}/Apidash", "--version"
78+
end
79+
end
80+
```
81+
82+
### 4. Local Validation
83+
84+
```
85+
# Check formula syntax
86+
brew audit --strict Formula/apidash.rb
87+
88+
# Test installation
89+
brew install --build-from-source Formula/apidash.rb
90+
91+
# Verify execution
92+
brew test apidash
93+
```
94+
95+
### 5. Custom Tap Submission
96+
97+
```
98+
# Commit formula to your tap repo
99+
git add Formula/Apidash.rb
100+
git commit -m "added apidash formula"
101+
git push
102+
103+
# Create release for tarball
104+
gh release create v1.0.0 apidash-v1.0.0.tar.gz
105+
```
106+
107+
### 6. Installation
108+
109+
```
110+
brew tap homebrew-tap/Formula
111+
brew install apidash
112+
```
26113

27114
## Chocolatey
28115

29-
TODO Instructions
116+
### Step 1: Setup Skeleton
117+
118+
First step towards making a choco package is initializing a base.
119+
120+
The command `choco new -h` can teach you more about the `new` command, its usage, options, switches, and exit codes.
121+
122+
Run the following command to setup the base
123+
124+
```powershell
125+
choco new --name="apidash" --version="0.3.0" maintainername="foss42" maintainerrepo="https://github.com/foss42/apidash" --built-in-template
126+
```
127+
128+
![choco folder structure](images/choco_create_structure.png)
129+
130+
This creates the following folder structure
131+
132+
```
133+
apidash
134+
├── ReadMe.md
135+
├── _TODO.txt
136+
├── apidash.nuspec
137+
└── tools
138+
├── chocolateybeforemodify.ps1
139+
├── chocolateyinstall.ps1
140+
├── chocolateyuninstall.ps1
141+
├── LICENSE.txt
142+
└── VERIFICATION.txt
143+
```
144+
145+
The files `ReadMe.md` and `_TODO.md` can be deleted before pushing.
146+
147+
The files of our main interest are `chocolateyinstall.ps1` and `apidash.nuspec`.
148+
149+
### Step 2: Editing `chocolateyinstall.ps1`
150+
151+
Take a look at `chocolateyinstall.ps1` file. There are many comments stating the use case of each line itself.
152+
![chocolatelyinstall.ps1](images/choco_chocolateyinstall_ps1.png)
153+
154+
Comments can bre remoed using the following command.
155+
```powershell
156+
$f='apidash\tools\chocolateyinstall.ps1'
157+
gc $f | ? {$_ -notmatch "^\s*#"} | % {$_ -replace '(^.*?)\s*? [^``]#.*','$1'} | Out-File $f+".~" -en utf8; mv -fo $f+".~" $f
158+
```
159+
160+
Now our `chocolateyinstall.ps1` file is ready.
161+
162+
### Step 3: Editing `apidash.nuspec`
163+
164+
![final apidash.nuspec](images/choco_nuspec.png)
165+
166+
### Step 4: Build the package
167+
168+
All our files are ready, we just need to pack out files in a choco package with the extension `.nupkg`.
169+
170+
Run the following command from the root of your directory:
171+
```powershell
172+
choco pack
173+
```
174+
This command generates the `apidash.0.3.0.nupkg` file.
175+
176+
### Step 5: Test the Package Locally
177+
178+
Install the package locally using Chocolatey:
179+
```powershell
180+
choco install apidash -s .
181+
```
182+
Ensure the application installs correctly.
183+
184+
![Shell output](images/choco_shell_output.png)
185+
186+
### Step 6: Pre-Publishing - Update `LICENSE.txt` & `VERIFICATION.txt`
187+
188+
Update `LICENSE.txt` with the actual **LICENSE **and `VERIFICATION.txt` accordingly.
189+
190+
### Step 7: Publish the Package (Optional)
191+
192+
To share the package, you can push it to a Chocolatey repository. For the official Chocolatey Community Repository, follow these steps:
193+
194+
1. Create an account on the Chocolatey Community.
195+
2. Get an API key by navigating to your profile.
196+
3. Use the following command to push your package:
197+
```powershell
198+
choco push apidash.0.3.0.nupkg --source="https://push.chocolatey.org/" --api-key="YOUR_API_KEY"
199+
```
30200

31201
## WinGet
32202

lib/consts.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ const kLabelSend = "Send";
434434
const kLabelSending = "Sending..";
435435
const kLabelBusy = "Busy";
436436
const kLabelCopy = "Copy";
437+
const kLabelShare = "Share";
437438
const kLabelSave = "Save";
438439
const kLabelDownload = "Download";
439440
const kLabelSaving = "Saving";
@@ -490,3 +491,10 @@ const kMsgNoContent = "No content";
490491
const kMsgUnknowContentType = "Unknown Response Content-Type";
491492
// Workspace Selector
492493
const kMsgSelectWorkspace = "Create your workspace";
494+
// History Page
495+
const kTitleClearHistory = 'Clear History';
496+
const kMsgClearHistory =
497+
'Clearing History is permanent. Do you want to continue?';
498+
const kMsgClearHistorySuccess = 'History cleared successfully';
499+
const kMsgClearHistoryError = 'Error clearing history';
500+
const kMsgShareError = "Unable to share";

lib/providers/collection_providers.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ final requestSequenceProvider = StateProvider<List<String>>((ref) {
2525
return ids ?? [];
2626
});
2727

28-
final httpClientManager = HttpClientManager();
28+
2929
final WebSocketManager webSocketManager = WebSocketManager();
3030

3131
final StateNotifierProvider<CollectionStateNotifier, Map<String, RequestModel>?>
3232
collectionStateNotifierProvider =
3333
StateNotifierProvider((ref) => CollectionStateNotifier(
3434
ref,
3535
hiveHandler,
36-
httpClientManager,
3736
webSocketManager
3837
));
3938

@@ -42,7 +41,6 @@ class CollectionStateNotifier
4241
CollectionStateNotifier(
4342
this.ref,
4443
this.hiveHandler,
45-
this.httpClientManager,
4644
this.webSocketManager
4745
) : super(null) {
4846
var status = loadData();
@@ -60,10 +58,8 @@ class CollectionStateNotifier
6058
final Ref ref;
6159
final HiveHandler hiveHandler;
6260
final baseHttpResponseModel = const HttpResponseModel();
63-
final HttpClientManager httpClientManager;
6461
final WebSocketManager webSocketManager;
6562

66-
6763
bool hasId(String id) => state?.keys.contains(id) ?? false;
6864

6965
RequestModel? getRequestModel(String id) {
@@ -123,6 +119,7 @@ class CollectionStateNotifier
123119
final rId = id ?? ref.read(selectedIdStateProvider);
124120
var itemIds = ref.read(requestSequenceProvider);
125121
int idx = itemIds.indexOf(rId!);
122+
cancelHttpRequest(rId);
126123
itemIds.remove(rId);
127124
ref.read(requestSequenceProvider.notifier).state = [...itemIds];
128125

@@ -327,7 +324,7 @@ class CollectionStateNotifier
327324
state = map;
328325

329326
bool noSSL = ref.read(settingsProvider).isSSLDisabled;
330-
(HttpResponse?, Duration?, String?)? responseRec = await request(
327+
var responseRec = await sendHttpRequest(
331328
requestId,
332329
apiType,
333330
substitutedHttpRequestModel,
@@ -385,7 +382,7 @@ class CollectionStateNotifier
385382

386383
void cancelRequest() {
387384
final id = ref.read(selectedIdStateProvider);
388-
httpClientManager.cancelRequest(id);
385+
cancelHttpRequest(id);
389386
unsave();
390387
}
391388

0 commit comments

Comments
 (0)