mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 05:05:53 +00:00
able to remove stickerpacks
This commit is contained in:
parent
852bfe0667
commit
a3b17d1a9f
@ -1,4 +1,4 @@
|
||||
import { Context, GET, Path, PathParam, POST, Security, ServiceContext } from "typescript-rest";
|
||||
import { Context, GET, Path, PathParam, POST, DELETE, Security, ServiceContext } from "typescript-rest";
|
||||
import StickerPack from "../../db/models/StickerPack";
|
||||
import { ApiError } from "../ApiError";
|
||||
import { DimensionStickerService, MemoryStickerPack } from "../dimension/DimensionStickerService";
|
||||
@ -49,6 +49,19 @@ export class AdminStickerService {
|
||||
return {}; // 200 OK
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("packs/:id")
|
||||
@Security([ROLE_ADMIN])
|
||||
public async removePack(@PathParam("id") packId: number): Promise<any> {
|
||||
const pack = await StickerPack.findByPk(packId);
|
||||
if (!pack) throw new ApiError(404, "Sticker pack not found");
|
||||
|
||||
await pack.destroy();
|
||||
Cache.for(CACHE_STICKERS).clear();
|
||||
|
||||
return {}; // 200 OK
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("packs/import/telegram")
|
||||
@Security([ROLE_USER, ROLE_ADMIN])
|
||||
|
@ -52,10 +52,13 @@
|
||||
</span>
|
||||
<ui-switch [checked]="pack.isEnabled" size="small" [disabled]="isUpdating"
|
||||
(change)="toggleEnabled(pack)"></ui-switch>
|
||||
<span *ngIf="!pack.isEnabled && !isUpdating" class="removeButton" title="remove stickerpack" (click)="removePack(pack)">
|
||||
<i class="fa fa-trash"></i>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</my-ibox>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -7,6 +7,11 @@ tr td:last-child {
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
.removeButton {
|
||||
cursor: pointer;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
.telegram-import {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
@ -68,4 +68,23 @@ export class AdminStickerPacksComponent implements OnInit {
|
||||
this.toaster.pop("error", "Error importing sticker pack");
|
||||
});
|
||||
}
|
||||
|
||||
public removePack(pack: FE_StickerPack) {
|
||||
//console.log(this.packs)
|
||||
//console.log(pack)
|
||||
this.isUpdating = true;
|
||||
this.adminStickers.removePack(pack.id).then(() => {
|
||||
for (let i = 0; i < this.packs.length; ++i)
|
||||
if (this.packs[i].id === pack.id) {
|
||||
this.packs.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
this.isUpdating = false;
|
||||
this.toaster.pop("success", "Sticker pack removed");
|
||||
}).catch(err => {
|
||||
console.error(err);
|
||||
this.isUpdating = false;
|
||||
this.toaster.pop("error", "Error removing sticker pack");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -20,4 +20,8 @@ export class AdminStickersApiService extends AuthedApi {
|
||||
public importFromTelegram(packUrl: string): Promise<FE_StickerPack> {
|
||||
return this.authedPost<FE_StickerPack>("/api/v1/dimension/admin/stickers/packs/import/telegram", {packUrl: packUrl}).toPromise();
|
||||
}
|
||||
|
||||
public removePack(packId: number): Promise<any> {
|
||||
return this.authedDelete("/api/v1/dimension/admin/stickers/packs/" + packId).toPromise();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user