Skip to content

Commit 14998de

Browse files
committed
added changing branch sequences values
1 parent 9016806 commit 14998de

11 files changed

+239
-61
lines changed

server/kraken/server/management.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,32 @@ def get_branch_sequences(branch_id, token_info=None):
279279
return {'items': seqs, 'total': len(seqs)}, 200
280280

281281

282+
def update_branch_sequence(seq_id, body, token_info=None):
283+
seq = BranchSequence.query.filter_by(id=seq_id).one_or_none()
284+
if seq is None:
285+
abort(404, "Branch sequence not found")
286+
287+
access.check(token_info, seq.branch.project_id, 'pwrusr',
288+
'only superadmin, project admin and project power user roles can get branch sequences')
289+
290+
value = body.get('value', None)
291+
if value is None:
292+
abort(400, "Missing value")
293+
294+
try:
295+
value = int(value)
296+
except Exception:
297+
abort(400, "Incorrect value")
298+
299+
if value < -1:
300+
abort(400, "Incorrect negative value")
301+
302+
seq.value = value
303+
db.session.commit()
304+
305+
return seq.get_json(), 200
306+
307+
282308
def move_branch(branch_id, body, token_info=None):
283309
branch = Branch.query.filter_by(id=branch_id).one_or_none()
284310
if branch is None:

server/kraken/server/swagger.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,43 @@ paths:
556556
application/json:
557557
schema:
558558
$ref: '#/components/schemas/ApiError'
559+
/sequences/{seq_id}:
560+
put:
561+
tags:
562+
- Management
563+
summary: Set branch sequence value
564+
operationId: update_branch_sequence
565+
parameters:
566+
- name: seq_id
567+
in: path
568+
description: ID of sequence
569+
required: true
570+
schema:
571+
type: integer
572+
format: int64
573+
requestBody:
574+
description: Value
575+
content:
576+
application/json:
577+
schema:
578+
type: object
579+
properties:
580+
value:
581+
type: integer
582+
format: int64
583+
responses:
584+
200:
585+
description: An array of branch sequences
586+
content:
587+
application/json:
588+
schema:
589+
$ref: '#/components/schemas/BranchSequence'
590+
default:
591+
description: unexpected error
592+
content:
593+
application/json:
594+
schema:
595+
$ref: '#/components/schemas/ApiError'
559596
/branches/{branch_id}/stats:
560597
get:
561598
tags:

ui/src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ import { ToolsPageComponent } from './tools-page/tools-page.component'
104104
import { UsersPageComponent } from './users-page/users-page.component'
105105
import { ChangePasswdDlgComponent } from './change-passwd-dlg/change-passwd-dlg.component'
106106
import { LogsPanelComponent } from './logs-panel/logs-panel.component';
107-
import { SimpleLogsPanelComponent } from './simple-logs-panel/simple-logs-panel.component'
107+
import { SimpleLogsPanelComponent } from './simple-logs-panel/simple-logs-panel.component';
108+
import { SequencesPanelComponent } from './sequences-panel/sequences-panel.component'
108109
Chart.register(zoomPlugin)
109110

110111
@NgModule({
@@ -142,6 +143,7 @@ Chart.register(zoomPlugin)
142143
ChangePasswdDlgComponent,
143144
LogsPanelComponent,
144145
SimpleLogsPanelComponent,
146+
SequencesPanelComponent,
145147
],
146148
imports: [
147149
BrowserModule,

ui/src/app/branch-mgmt/branch-mgmt.component.html

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -407,29 +407,12 @@ <h3>Generated Step Code</h3>
407407

408408
<!-- Stats & Charts TAB -->
409409
<app-tabbed-page-tab label="Stats & Charts">
410-
<app-branch-stats [branch_id]="branchId"></app-branch-stats>
410+
<app-branch-stats [branchId]="branchId"></app-branch-stats>
411411
</app-tabbed-page-tab>
412412

413413
<!-- Sequences TAB -->
414414
<app-tabbed-page-tab label="Sequences">
415-
<table class="seqs-table">
416-
<tr>
417-
<th>Sequence Type</th>
418-
<th>Stage</th>
419-
<th>Value</th>
420-
</tr>
421-
<tr *ngFor="let s of sequences">
422-
<td style="text-align: right;">
423-
{{ getSeqTypeName(s) }}
424-
</td>
425-
<td>
426-
{{ s.stage_name ? s.stage_name : '' }}
427-
</td>
428-
<td style="text-align: right;">
429-
{{ s.value }}
430-
</td>
431-
</tr>
432-
</table>
415+
<app-sequences-panel [branchId]="branchId"></app-sequences-panel>
433416
</app-tabbed-page-tab>
434417

435418
<!--

ui/src/app/branch-mgmt/branch-mgmt.component.sass

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,6 @@
8686
color: #fff
8787

8888

89-
// sequences table
90-
table.seqs-table
91-
border-collapse: collapse
92-
93-
94-
.seqs-table table, th, td
95-
border: 1px solid black
96-
97-
.seqs-table th, td
98-
padding: 7px 15px
99-
10089
// step fields table
10190
.step-help-table
10291
border-collapse: collapse

ui/src/app/branch-mgmt/branch-mgmt.component.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ export class BranchMgmtComponent implements OnInit, OnDestroy {
9999
git_clone_params: new UntypedFormControl(''),
100100
})
101101

102-
sequences = []
103-
104102
retentionPolicyForm = this.fb.group({
105103
ci_logs: [''],
106104
dev_logs: [''],
@@ -241,14 +239,6 @@ export class BranchMgmtComponent implements OnInit, OnDestroy {
241239
this.breadcrumbService.setCrumbs(crumbs)
242240
})
243241
)
244-
245-
this.subs.add(
246-
this.managementService
247-
.getBranchSequences(this.branchId)
248-
.subscribe((data) => {
249-
this.sequences = data.items
250-
})
251-
)
252242
}
253243

254244
selectStage(stage) {
@@ -603,24 +593,6 @@ export class BranchMgmtComponent implements OnInit, OnDestroy {
603593
)
604594
}
605595

606-
getSeqTypeName(seq) {
607-
switch (seq.kind) {
608-
case 0:
609-
return 'flow'
610-
case 1:
611-
return 'CI flow'
612-
case 2:
613-
return 'DEV flow'
614-
case 3:
615-
return 'run'
616-
case 4:
617-
return 'CI run'
618-
case 5:
619-
return 'DEV run'
620-
}
621-
return 'unknown'
622-
}
623-
624596
deleteBranch() {
625597
this.subs.add(
626598
this.managementService.deleteBranch(this.branchId).subscribe(

ui/src/app/branch-stats/branch-stats.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ManagementService } from '../backend/api/management.service'
1313
styleUrls: ['./branch-stats.component.sass'],
1414
})
1515
export class BranchStatsComponent implements OnInit, OnDestroy {
16-
@Input() branch_id: number
16+
@Input() branchId: number
1717

1818
stats: any = null
1919

@@ -30,7 +30,7 @@ export class BranchStatsComponent implements OnInit, OnDestroy {
3030
ngOnInit(): void {
3131
this.subs.add(
3232
this.managementService
33-
.getBranchStats(this.branch_id)
33+
.getBranchStats(this.branchId)
3434
.subscribe((data) => {
3535
this.stats = data
3636

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!-- change branch names dialog -->
2+
<p-dialog header="Change sequence value" [(visible)]="changeSeqDlgVisible" [style]="{width: '30rem'}">
3+
<div class="field grid" *ngIf="selectedSeq">
4+
<label for="sequenceVal" class="col-fixed" style="width: 10rem;">New Value</label>
5+
<div class="col">
6+
<p-inputNumber inputId="sequenceVal" [(ngModel)]="selectedSeq.value" mode="decimal" [min]="-1">
7+
</p-inputNumber>
8+
</div>
9+
</div>
10+
11+
<p-footer>
12+
<button type="button" (click)="cancelChangeSeqValue()" pButton icon="pi pi-times" label="Cancel" class="p-button-outlined p-button-secondary"></button>
13+
<button type="button" (click)="changeSeqValue()" pButton icon="pi pi-check" label="Set"></button>
14+
</p-footer>
15+
</p-dialog>
16+
17+
<div>
18+
<table class="seqs-table">
19+
<tr>
20+
<th>Sequence Type</th>
21+
<th>Stage</th>
22+
<th>Value</th>
23+
<th>Change</th>
24+
</tr>
25+
<tr *ngFor="let s of sequences">
26+
<td style="text-align: right;">
27+
{{ getSeqTypeName(s) }}
28+
</td>
29+
<td>
30+
{{ s.stage_name ? s.stage_name : '' }}
31+
</td>
32+
<td style="text-align: right;">
33+
{{ s.value }}
34+
</td>
35+
<td>
36+
<button pButton type="button" icon="pi pi-pencil" class="p-button-sm" (click)="showSeqChangeDlg(s)"></button>
37+
</td>
38+
</tr>
39+
</table>
40+
</div>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// sequences table
2+
table.seqs-table
3+
border-collapse: collapse
4+
5+
6+
.seqs-table table, th, td
7+
border: 1px solid black
8+
9+
.seqs-table th, td
10+
padding: 7px 15px
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { SequencesPanelComponent } from './sequences-panel.component';
4+
5+
describe('SequencesPanelComponent', () => {
6+
let component: SequencesPanelComponent;
7+
let fixture: ComponentFixture<SequencesPanelComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ SequencesPanelComponent ]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(SequencesPanelComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});

0 commit comments

Comments
 (0)