selfprivacy.org.app/lib/logic/models/job.dart

95 lines
2.1 KiB
Dart
Raw Normal View History

import 'package:easy_localization/easy_localization.dart';
2021-05-25 21:53:54 +00:00
import 'package:equatable/equatable.dart';
2021-06-08 18:52:44 +00:00
import 'package:flutter/material.dart';
2021-08-18 10:44:46 +00:00
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
2021-08-18 09:36:40 +00:00
import 'package:selfprivacy/utils/password_generator.dart';
2021-05-25 21:53:54 +00:00
2021-08-29 15:02:51 +00:00
import 'user.dart';
2021-06-08 18:52:44 +00:00
@immutable
2021-05-25 21:53:54 +00:00
class Job extends Equatable {
Job({
String? id,
required this.title,
2021-08-18 09:36:40 +00:00
}) : id = id ?? StringGenerators.simpleId();
2021-05-25 21:53:54 +00:00
final String title;
final String id;
@override
List<Object> get props => [id, title];
}
2021-06-08 18:52:44 +00:00
class CreateUserJob extends Job {
CreateUserJob({
required this.user,
2021-08-18 10:44:46 +00:00
}) : super(title: '${"jobs.createUser".tr()} ${user.login}');
2021-06-08 18:52:44 +00:00
final User user;
@override
2021-08-29 15:02:51 +00:00
List<Object> get props => [id, title, user];
2021-06-08 18:52:44 +00:00
}
2021-08-18 10:44:46 +00:00
2021-12-20 15:25:31 +00:00
class DeleteUserJob extends Job {
DeleteUserJob({
required this.user,
}) : super(title: '${"jobs.deleteUser".tr()} ${user.login}');
final User user;
@override
List<Object> get props => [id, title, user];
}
2022-01-25 17:00:47 +00:00
class ToggleJob extends Job {
ToggleJob({
2021-08-18 10:44:46 +00:00
required this.type,
2022-01-25 17:00:47 +00:00
required String title,
}) : super(title: title);
final dynamic type;
@override
List<Object> get props => [...super.props, type];
}
class ServiceToggleJob extends ToggleJob {
ServiceToggleJob({
required ServiceTypes type,
2021-08-18 10:44:46 +00:00
required this.needToTurnOn,
2021-08-29 15:02:51 +00:00
}) : super(
2022-01-25 17:00:47 +00:00
title:
'${needToTurnOn ? "jobs.serviceTurnOn".tr() : "jobs.serviceTurnOff".tr()} ${type.title}',
type: type,
);
2021-08-18 10:44:46 +00:00
final bool needToTurnOn;
}
2021-09-02 19:32:07 +00:00
class CreateSSHKeyJob extends Job {
CreateSSHKeyJob({
required this.user,
required this.publicKey,
}) : super(title: '${"jobs.create_ssh_key".tr(args: [user.login])}');
final User user;
final String publicKey;
2021-09-02 19:32:07 +00:00
@override
List<Object> get props => [id, title, user, publicKey];
}
class DeleteSSHKeyJob extends Job {
DeleteSSHKeyJob({
required this.user,
required this.publicKey,
}) : super(title: '${"jobs.delete_ssh_key".tr(args: [user.login])}');
final User user;
final String publicKey;
@override
List<Object> get props => [id, title, user, publicKey];
2021-09-02 19:32:07 +00:00
}