Skip to content
Snippets Groups Projects
Commit 31d8538f authored by kbeyro's avatar kbeyro
Browse files

Update token view for delete option

parent 83f1daa3
No related branches found
No related tags found
2 merge requests!108Develop,!71Update token view for delete option
...@@ -17,10 +17,14 @@ ...@@ -17,10 +17,14 @@
<td>{{token.name}}</td> <td>{{token.name}}</td>
<td>{{token.tokenValue}}</td> <td>{{token.tokenValue}}</td>
<td>{{token.valid}}</td> <td>{{token.valid}}</td>
<td> <td *ngIf="token.valid">
<button type="button" class="btn btn-danger" <button type="button" class="btn btn-danger"
(click)="invalidate(token.id)">{{'TOKENS.BUTTON_INVALIDATE' | translate}}</button> (click)="invalidate(token.id)">{{'TOKENS.BUTTON_INVALIDATE' | translate}}</button>
</td> </td>
<td *ngIf="!token.valid">
<button type="button" class="btn btn-danger"
(click)="deleteToken(token.id)">{{'TOKENS.BUTTON_DELETE' | translate}}</button>
</td>
</tr> </tr>
<tr *ngIf="tokensList.length === 0"> <tr *ngIf="tokensList.length === 0">
<td colspan="3" style="text-align: center">{{'TOKENS.NO_TOKENS' | translate}}</td> <td colspan="3" style="text-align: center">{{'TOKENS.NO_TOKENS' | translate}}</td>
......
...@@ -51,6 +51,13 @@ export class AccessTokensComponent implements OnInit { ...@@ -51,6 +51,13 @@ export class AccessTokensComponent implements OnInit {
); );
} }
deleteToken(id: number) {
this.tokenService.deleteToken(id).subscribe(
(_) => this.getData(),
error => console.error(error)
);
}
public createNewToken() { public createNewToken() {
this.tokenService.createToken(this.requestForm.value.name.trim()).subscribe({ this.tokenService.createToken(this.requestForm.value.name.trim()).subscribe({
next: val => { next: val => {
......
...@@ -22,6 +22,10 @@ export class AccessTokenService extends GenericDataService { ...@@ -22,6 +22,10 @@ export class AccessTokenService extends GenericDataService {
return this.http.put<void>(`${this.getUrl()}/${id}`, '') return this.http.put<void>(`${this.getUrl()}/${id}`, '')
} }
public deleteToken(id: number): Observable<void> {
return this.http.put<void>(`${this.getUrl()}/delete/${id}`, '')
}
public createToken(tokenName: string): Observable<AccessToken> { public createToken(tokenName: string): Observable<AccessToken> {
return this.http.post<AccessToken>(this.getUrl(), tokenName) return this.http.post<AccessToken>(this.getUrl(), tokenName)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment