Commit 5821d982 authored by Qianwen's avatar Qianwen
Browse files

refine

parent 381e1401
Pipeline #504805 passed with stages
in 3 minutes and 19 seconds
......@@ -3,7 +3,7 @@
<div class="nav">
<div class="nav-item" *ngFor="let id of MASID, index as i" routerLinkActive="is-active" [ngClass]="id === selectedMASID ? 'active' : ''">
<a class="list-text" [routerLink]="['/ams', id]" >
<p > MAS {{ i }}</p>
<p > MAS {{ id }}</p>
</a>
</div>
</div>
......
......@@ -79,9 +79,6 @@
.inputs {
padding-top: 30px;
padding-bottom: 40px;
display: flex;
justify-content: center;
align-items: center;
}
.input {
color: var(--primary-color);
......
......@@ -4,7 +4,7 @@
<div class="nav">
<div class="nav-item" *ngFor="let id of MASID, index as i" routerLinkActive="is-active" [ngClass]="id === selectedMASID ? 'active' : ''">
<a class="list-text" [routerLink]="['/df', id]" >
<p > MAS {{ i }}</p>
<p > MAS {{ id }}</p>
</a>
</div>
</div>
......@@ -25,7 +25,7 @@
</ul>
<div class="content" *ngIf="curr_state === 'list'">
<div class="inputs">
<div class="inputs d-flex justify-content-center align-items-center">
<input #desc type="text" class="input" id="searchDesc" placeholder="Enter the description"/>
<input #nodeid type="text" class="input" id="searchNode" placeholder="Enter the node ID"/>
<input #dist type="text" class="input" id="searchDist" placeholder="Enter the distance"/>
......
......@@ -4,7 +4,7 @@
<div class="nav">
<div class="nav-item" *ngFor="let id of MASID, index as i" routerLinkActive="is-active" [ngClass]="id === selectedMASID ? 'active' : ''">
<a class="list-text" [routerLink]="['/logger', id]" >
<p > MAS {{ i }}</p>
<p > MAS {{ id }}</p>
</a>
</div>
</div>
......
......@@ -127,6 +127,19 @@
background:var(--light-primary-color);
}
.delete-spinner {
width: 4rem;
height: 4rem;
color: var(--primary-color);
}
.delete-text {
color: var(--primary-color);
text-align: center;
font-size: 30px;
font-weight: 100;
}
......
......@@ -5,7 +5,7 @@
<div class="nav">
<div class="nav-item" *ngFor="let id of MASID, index as i" routerLinkActive="is-active">
<a class="list-text" [routerLink]="['/ams', id]" >
<p >MAS {{ i }}</p>
<p >MAS {{ id }}</p>
</a>
</div>
</div>
......@@ -39,6 +39,30 @@
</div>
</ng-template>
<!--modal for waiting the deletion of the agency-->
<ng-template #deleting let-modal>
<div class="modal-body d-flex flex-column justify-content-center align-items-center">
<div class="spinner-border delete-spinner" role="status">
<span class="sr-only">deleting...</span>
</div>
<p class="mt-4 delete-text">deleting</p>
</div>
</ng-template>
<!--modal for waiting the deletion of the agency-->
<ng-template #deleted let-modal>
<div class="modal-body">
<div class="d-flex flex-column justify-content-center align-items-center">
<p class="mt-4 delete-text">deleted</p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn my-btn" (click)="closeModal()">OK</button>
</div>
</ng-template>
<div *ngIf="MASID.length !== 0" class="content-container col-md-11 col-sm-8 d-flex flex-column justify-content-start align-items-center">
<div class="title">
<div class="title-name" >Overview</div>
......@@ -50,8 +74,8 @@
<div class="col-lg-4 col-md-6 col-sm-12 my-row" *ngFor="let MAS of MASsDisplay | paginate: { itemsPerPage: 6, currentPage: q }; index as i">
<div class="card">
<div class="card-header d-flex justify-content-between">
<h3 (click)="onOpenMAS(MAS.id)">MAS {{i}}</h3>
<button class="btn btn-delete" (click)="onDeleteMAS(MAS.id)">
<h3 (click)="onOpenMAS(MAS.id)">MAS {{MAS.id}}</h3>
<button class="btn btn-delete" (click)="onDeleteMAS(MAS.id, deleting, deleted)">
<div class="icon">
<i class="fas fa-trash"></i>
</div>
......
import { Component, OnInit } from '@angular/core';
import { MasService } from 'src/app/services/mas.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, NgbModalConfig } from '@ng-bootstrap/ng-bootstrap';
import { Router, ActivatedRouteSnapshot } from '@angular/router'
@Component({
......@@ -18,22 +18,30 @@ export class OverviewComponent implements OnInit {
filename: string = "Choose a file...";
status: string ="Connecting......";
constructor(
config: NgbModalConfig,
private masService: MasService,
private modalService: NgbModal,
private router: Router
) {}
) {
config.backdrop = "static";
}
ngOnInit() {
this.updateMAS();
}
/******************** create new MAS *************************/
/******************** create new MAS *************************/
openLg(content) {
this.modalService.open(content, { size: 'lg', centered: true });
}
closeModal() {
this.modalService.dismissAll();
this.updateMAS();
}
handleFileInput(files: FileList) {
if (files.length <= 0) {
return false;
......@@ -71,10 +79,10 @@ export class OverviewComponent implements OnInit {
this.MASsDisplay = [];
if (MASs !== null) {
for (let MAS of MASs) {
// if the MAS is not deleted
if (MAS.status.code != 5) {
this.MASsDisplay.push(MAS)
}
console.log(MAS);
}
this.MASID = this.MASsDisplay.map(MAS => MAS.id);
if (this.MASsDisplay.length === 0) {
......@@ -90,14 +98,17 @@ export class OverviewComponent implements OnInit {
});
}
onDeleteMAS(id: string) {
console.log(id);
/******************** delete the MAS *************************/
onDeleteMAS(id: string, deleting, deleted) {
this.modalService.open(deleting, { size: 'sm', centered: true });
this.masService.deleteMASById(id).subscribe(
(res: any) => {
console.log(res);
this.router.navigate['/overview']
},
this.router.navigate['/overview'];
},
(err) => {
this.modalService.dismissAll();
this.modalService.open(deleted, { size: 'sm', centered: true });
console.log(typeof(deleted));
console.log(err);
}
);
......
import { TestBed } from '@angular/core/testing';
import { AgencyService } from './agency.service';
describe('AgencyService', () => {
let service: AgencyService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AgencyService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import { WebRequestService} from './web-request.service'
@Injectable({
providedIn: 'root'
})
export class AgencyService {
constructor(private webReqService: WebRequestService) { }
getAgency() {
return this.webReqService.get('/api/agency');
}
createAgent(payload: object) {
return this.webReqService.post('./api/agency/agents', payload);
}
createMsgs(payload: object) {
return this.webReqService.post('/api/agency/msgs', payload);
}
createMsgsUndeliv(payload: object) {
return this.webReqService.post('/api/agency/msgundeliv', payload);
}
deleteAgent(agentid: number) {
return this.webReqService.delete(`/api/agency/agents/${agentid}`);
}
getAgentStatus(agentid: number) {
return this.webReqService.get(`/api/agency/agents/${agentid}/status`);
}
updateAgentStatus(agentid: number, payload: object) {
return this.webReqService.patch(`/api/agency/agents/${agentid}/custom`, payload);
}
}
......@@ -44,9 +44,5 @@ export class DfService {
return this.webReqService.get(`api/df/${masid}/svc/id/${svcid}`);
}
deleteSvcById(masid:string, svcid: string) {
return this.webReqService.delete(`api/df/${masid}/svc/id/${svcid}`);
}
}
......@@ -12,14 +12,6 @@ export class LoggerService {
return this.webReqService.get('api/pf/modules')
}
createLoggerWithType(masid:string, agentid: string, topic: string, payload: object) {
return this.webReqService.post(`api/logging/${masid}/${agentid}/${topic}`, payload);
}
createLogger(masid:string, payload: object) {
return this.webReqService.post(`api/logging/${masid}/list`, payload);
}
getNLatestLogs(masid: string, agentid: string, topic:string, num: string) {
return this.webReqService.get(`api/logging/${masid}/${agentid}/${topic}/latest/${num}`);
}
......@@ -43,12 +35,4 @@ export class LoggerService {
getBehavior(masid:string, agentid: string, behtype: string, start: string, end: string) {
return this.webReqService.get(`api/logging/stats/${masid}/${agentid}/${behtype}/${start}/${end}`)
}
updateAgentState(masid: string, agentid: string, payload: object) {
return this.webReqService.patch(`api/state/${masid}/${agentid}`, payload);
}
updateAgentStates(masid: string, payload: object) {
return this.webReqService.patch(`api/state/${masid}/list`, payload);
}
}
......@@ -12,10 +12,6 @@ export class MasService {
return this.webReqService.get('api/alive');
}
getams() {
return this.webReqService.get('api/ams');
}
getMAS() {
return this.webReqService.get('api/ams/mas');
}
......@@ -31,51 +27,6 @@ export class MasService {
deleteMASById(masid: string) {
return this.webReqService.delete(`api/ams/mas/${masid}`);
}
getAgents(masid: string) {
return this.webReqService.get(`api/ams/mas/${masid}/agents`);
}
addAgents(masid: string, payload: object) {
return this.webReqService.post(`api/ams/mas/${masid}/agents`, payload );
}
getAgentById(masid:string, agentid: string) {
return this.webReqService.get(`api/ams/mas/${masid}/agents/${agentid}`);
}
deleteAgentById(masid:string, agentid: string) {
return this.webReqService.delete(`api/ams/mas/${masid}/agents/${agentid}`);
}
getAgentAdress(masid:string, agentid: string) {
return this.webReqService.get(`api/ams/mas/${masid}/agents/${agentid}/address`);
}
updateAgentAddress(masid: string, agentid:string, payload: object) {
return this.webReqService.post(`api/ams/mas/${masid}/agents/${agentid}/address`, payload);
}
customUpdateAgentAddress(masid: string, agentid: string, payload: object) {
return this.webReqService.post(`api/ams/mas/${masid}/agents/${agentid}/address`, payload);
}
getAgentbyName(masid:string, name: string) {
return this.webReqService.get(`api/ams/mas/${masid}/agents/name/${name}`);
}
getAllAgencies(masid: string) {
return this.webReqService.get(`api/ams/mas/${masid}/agencies`);
}
getAgencyInformation(masid: string, imid: string, agencyid: string) {
return this.webReqService.get(`api/ams/mas/${masid}/imgroup/${imid}/agencies/${agencyid}`);
}
}
......
......@@ -6,20 +6,10 @@ import { environment } from 'src/environments/environment.prod'
})
export class WebRequestService {
readonly ROOT_URL = environment.gateway;
readonly headerDict = {
'Content-Type': 'application/json',
/* 'responseType': 'text/plain' */
};
constructor(private http: HttpClient) {
}
get(uri: string) {
return this.http.get(`${this.ROOT_URL}/${uri}`);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment