mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Lens app source code (#119)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Signed-off-by: Cody Belcher <cody.t.belcher@gmail.com>
This commit is contained in:
1 parent
492ea272d1
commit
d057cb17c6
797 files changed
+73714
-215
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { autobind } from "../../utils";
|
||||
import { CronJob, cronJobApi } from "../../api/endpoints/cron-job.api";
|
||||
import { jobStore } from "../+workloads-jobs/job.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
|
||||
@autobind()
|
||||
export class CronJobStore extends KubeObjectStore<CronJob> {
|
||||
api = cronJobApi
|
||||
|
||||
getStatuses(cronJobs?: CronJob[]) {
|
||||
const status = { failed: 0, running: 0 }
|
||||
cronJobs.forEach(cronJob => {
|
||||
if (cronJob.spec.suspend) {
|
||||
status.failed++
|
||||
}
|
||||
else {
|
||||
status.running++
|
||||
}
|
||||
})
|
||||
return status
|
||||
}
|
||||
|
||||
getActiveJobsNum(cronJob: CronJob) {
|
||||
// Active jobs are jobs without any condition 'Complete' nor 'Failed'
|
||||
const jobs = jobStore.getJobsByOwner(cronJob);
|
||||
if (!jobs.length) return 0;
|
||||
return jobs.filter(job => !job.getCondition()).length;
|
||||
}
|
||||
}
|
||||
|
||||
export const cronJobStore = new CronJobStore();
|
||||
apiManager.registerStore(cronJobApi, cronJobStore);
|
||||
Reference in new issue
Block a user