2020-02-06 00:14:42 +08:00
|
|
|
import Controller from "@ember/controller";
|
2021-11-09 18:18:23 +08:00
|
|
|
import { action } from "@ember/object";
|
2019-11-05 22:10:23 +08:00
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
|
|
|
2023-03-15 17:42:12 +08:00
|
|
|
export default class AdminApiKeysIndexController extends Controller {
|
|
|
|
loading = false;
|
2021-11-09 18:18:23 +08:00
|
|
|
|
|
|
|
@action
|
|
|
|
revokeKey(key) {
|
|
|
|
key.revoke().catch(popupAjaxError);
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
2021-11-09 18:18:23 +08:00
|
|
|
|
|
|
|
@action
|
|
|
|
undoRevokeKey(key) {
|
|
|
|
key.undoRevoke().catch(popupAjaxError);
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
2021-11-09 18:18:23 +08:00
|
|
|
|
|
|
|
@action
|
|
|
|
loadMore() {
|
|
|
|
if (this.loading || this.model.loaded) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const limit = 50;
|
|
|
|
|
|
|
|
this.set("loading", true);
|
|
|
|
this.store
|
|
|
|
.findAll("api-key", { offset: this.model.length, limit })
|
|
|
|
.then((keys) => {
|
|
|
|
this.model.addObjects(keys);
|
|
|
|
if (keys.length < limit) {
|
|
|
|
this.model.set("loaded", true);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.set("loading", false);
|
|
|
|
});
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
|
|
|
}
|