Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@
{{ currentLanguageSet?.common?.report }}
</button>
</li>
<li class="nav-item" *ngIf="isLast && isMMUOfflineQRCode">
<button class="nav-btn" mat-button routerLink="/nikshay-sync" routerLinkActive="active">
Nikshay Sync
</button>
</li>
</ul>
</div>
</nav>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class AppHeaderComponent implements OnInit {
isAuthenticated!: boolean;
roles: any;
helpURL: string = environment.licenseURL;
isMMUOfflineQRCode = environment.isMMUOfflineQRCode;
filteredNavigation: any;
isConnected = true;
status!: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,23 @@ export class DataSyncLoginComponent implements OnInit, DoCheck {

//added get datasync data on login to a new method
getDataSyncMMU(res: any) {
const sessionUserID = this.sessionstorage.getItem('userID');
const dataSyncUserID = res.data.userID;

if (
sessionUserID &&
dataSyncUserID &&
String(dataSyncUserID) !== String(sessionUserID)
) {
this.showProgressBar = false;
sessionStorage.removeItem('serverKey');
this.confirmationService.alert(
'Sync user is not valid. Please login with the correct credentials.',
'error'
);
return;
}

const mmuService = res.data.previlegeObj.filter((item: any) => {
return item.serviceName === 'MMU';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
min-width: 420px;
}

.nikshay-tab-content {
padding-top: 12px;
}

.qr-subtitle {
font-size: 13px;
color: #555;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,72 +28,78 @@
</div>

<mat-dialog-content class="qr-dialog-content">
<p class="qr-subtitle">Scan with the Stop TB Mobile app to connect over Wi-Fi.</p>
<mat-tab-group>
<mat-tab label="Pair Mobile App">
<div class="nikshay-tab-content">
<p class="qr-subtitle">Scan with the Stop TB Mobile app to connect over Wi-Fi.</p>

<!-- Auto-detection status -->
<div *ngIf="isDetecting" class="detect-row">
<mat-spinner diameter="20"></mat-spinner>
<span class="detect-text">Fetching Camp Hub server info&hellip;</span>
</div>
<!-- Auto-detection status -->
<div *ngIf="isDetecting" class="detect-row">
<mat-spinner diameter="20"></mat-spinner>
<span class="detect-text">Fetching Camp Hub server info&hellip;</span>
</div>

<div *ngIf="!isDetecting && detectionFailed" class="detect-row warn">
<span class="material-icons" style="font-size: 18px; color: #f9a825">info</span>
<span class="detect-text">
Camp Hub server unreachable &mdash; enter the server URL manually below.
</span>
<button mat-icon-button (click)="autoDetect()" matTooltip="Retry" style="margin-left: 4px">
<span class="material-icons" style="font-size: 18px">refresh</span>
</button>
</div>
<div *ngIf="!isDetecting && detectionFailed" class="detect-row warn">
<span class="material-icons" style="font-size: 18px; color: #f9a825">info</span>
<span class="detect-text">
Camp Hub server unreachable &mdash; enter the server URL manually below.
</span>
<button mat-icon-button (click)="autoDetect()" matTooltip="Retry" style="margin-left: 4px">
<span class="material-icons" style="font-size: 18px">refresh</span>
</button>
</div>

<div *ngIf="!isDetecting && !detectionFailed && urlForm.controls.campHubUrl.value" class="detect-row ok">
<span class="material-icons" style="font-size: 18px; color: #388e3c">check_circle</span>
<span class="detect-text">Server URL fetched &mdash; review below and click Generate.</span>
</div>
<div *ngIf="!isDetecting && !detectionFailed && urlForm.controls.campHubUrl.value" class="detect-row ok">
<span class="material-icons" style="font-size: 18px; color: #388e3c">check_circle</span>
<span class="detect-text">Server URL fetched &mdash; review below and click Generate.</span>
</div>

<!-- URL input + manual generate (shown only when auto-detect failed) -->
<form [formGroup]="urlForm" (ngSubmit)="generate()" style="margin-top: 16px">
<mat-form-field style="width: 100%">
<mat-label>Camp Hub Server URL</mat-label>
<input
matInput
formControlName="campHubUrl"
placeholder="http://192.168.137.1:8083/"
autocomplete="off" />
<mat-hint>Format: http://&lt;network-ip&gt;:&lt;port&gt;/</mat-hint>
<mat-error *ngIf="urlForm.controls.campHubUrl.hasError('required')">
URL is required
</mat-error>
<mat-error *ngIf="urlForm.controls.campHubUrl.hasError('pattern')">
Must start with http:// or https://
</mat-error>
</mat-form-field>
<!-- URL input + manual generate (shown only when auto-detect failed) -->
<form [formGroup]="urlForm" (ngSubmit)="generate()" style="margin-top: 16px">
<mat-form-field style="width: 100%">
<mat-label>Camp Hub Server URL</mat-label>
<input
matInput
formControlName="campHubUrl"
placeholder="http://192.168.137.1:8083/"
autocomplete="off" />
<mat-hint>Format: http://&lt;network-ip&gt;:&lt;port&gt;/</mat-hint>
<mat-error *ngIf="urlForm.controls.campHubUrl.hasError('required')">
URL is required
</mat-error>
<mat-error *ngIf="urlForm.controls.campHubUrl.hasError('pattern')">
Must start with http:// or https://
</mat-error>
</mat-form-field>

<div *ngIf="detectionFailed" style="margin-top: 20px; text-align: center">
<button
mat-raised-button
color="primary"
class="mat_blue"
type="submit"
[disabled]="urlForm.invalid || isGenerating">
<span class="material-icons btn-icon">qr_code</span>
Generate QR Code
</button>
</div>
</form>
<div *ngIf="detectionFailed" style="margin-top: 20px; text-align: center">
<button
mat-raised-button
color="primary"
class="mat_blue"
type="submit"
[disabled]="urlForm.invalid || isGenerating">
<span class="material-icons btn-icon">qr_code</span>
Generate QR Code
</button>
</div>
</form>

<!-- QR result -->
<div *ngIf="qrDataUrl" class="qr-result">
<div class="url-chip">
<span class="material-icons url-icon">wifi</span>
<span class="url-text">{{ generatedUrl }}</span>
</div>
<!-- QR result -->
<div *ngIf="qrDataUrl" class="qr-result">
<div class="url-chip">
<span class="material-icons url-icon">wifi</span>
<span class="url-text">{{ generatedUrl }}</span>
</div>

<img [src]="qrDataUrl" alt="Camp Hub QR Code" class="qr-image" />
<img [src]="qrDataUrl" alt="Camp Hub QR Code" class="qr-image" />

<button mat-raised-button color="primary" class="mat_blue" (click)="downloadQR()">
<span class="material-icons btn-icon">download</span>
Download
</button>
</div>
<button mat-raised-button color="primary" class="mat_blue" (click)="downloadQR()">
<span class="material-icons btn-icon">download</span>
Download
</button>
</div>
</div>
</mat-tab>
</mat-tab-group>
</mat-dialog-content>
38 changes: 38 additions & 0 deletions src/app/app-modules/nikshay-sync/nikshay-sync-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* AMRIT – Accessible Medical Records via Integrated Technology
* Integrated EHR (Electronic Health Records) Solution
*
* Copyright (C) "Piramal Swasthya Management and Research Institute"
*
* This file is part of AMRIT.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { NikshaySyncComponent } from './nikshay-sync.component';

const routes: Routes = [
{
path: '',
component: NikshaySyncComponent,
},
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class NikshaySyncRoutingModule {}
82 changes: 82 additions & 0 deletions src/app/app-modules/nikshay-sync/nikshay-sync.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.nikshay-sync-page {
max-width: 640px;
margin: 32px auto;
padding: 24px 32px 16px;
background: #fff;
border-radius: 8px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.page-title {
font-size: 20px;
font-weight: 500;
color: #01579b;
margin-bottom: 16px;
}

.nikshay-tab-content {
padding-top: 12px;
}

.camp-info-chip {
display: inline-flex;
align-items: center;
gap: 6px;
background: #e3f2fd;
border-radius: 20px;
padding: 6px 16px;
font-size: 13px;
font-weight: 500;
color: #0b69b2;
margin-bottom: 8px;
}

.qr-subtitle {
font-size: 13px;
color: #555;
margin-bottom: 8px;
}

.detect-row {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
border-radius: 4px;
font-size: 13px;
color: #555;
margin-bottom: 4px;
}

.detect-row.warn {
background: #fff8e1;
color: #6d4c00;
}

.detect-text {
flex: 1;
line-height: 1.4;
}

.qr-result {
display: flex;
flex-direction: column;
align-items: center;
padding: 24px 0 8px;
gap: 16px;
}

.url-icon {
font-size: 18px;
flex-shrink: 0;
}

.url-text {
font-family: monospace;
}

.btn-icon {
vertical-align: middle;
font-size: 18px;
margin-right: 4px;
}
Loading