in ui/lib/modules/workstations/my_workstations.dart [124:275]
Widget _buildWorkstationRows(List<Workstation> wrkList, WidgetRef ref,
String projectId, String region) {
final user = ref.read(authRepositoryProvider).currentUser()!;
final ldap = user.email.toString().split('@')[0];
List<TableRow> rows = [];
wrkList.map(
(workstation) {
if (workstation.name.contains(ldap)) {
rows.add(
TableRow(
children: [
CloudTableCell(
child: CloudTableCellText(text: workstation.displayName)),
TextButton(
style: TextButton.styleFrom(
minimumSize: Size.zero,
padding: EdgeInsets.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: () async {
launchUrl(Uri.parse("https://80-${workstation.host}"));
},
child: Text(
workstation.host,
style: AppText.linkFontStyle,
),
),
// CloudTableCell(
// child: CloudTableCellText(text: workstation.host),
// ),
CloudTableCell(
child: workstation.state == "STATE_RUNNING" ? Tooltip(
message: workstation.state,
child: Icon(
Icons.check_circle,
color: Colors.green,
),
) : Tooltip(
message: workstation.state,
child: Icon(
Icons.stop_circle,
color: Colors.black,
),
)),
CloudTableCell(
child: TextButton(
onPressed: () async {
launchUrl(Uri.parse("https://80-${workstation.host}"));
},
child: Text(
"LAUNCH",
style: AppText.linkFontStyle,
),
),
),
CloudTableCell(
child: TextButton(
onPressed: () async {
ref
.watch(cloudWorkstationsRepositoryProvider)
.startInstance(
projectId,
workstation.clusterName,
workstation.configName,
workstation.displayName,
region);
ref.invalidate(allWorkstationsProvider);
},
child: Text(
"Start",
style: AppText.linkFontStyle,
),
),
),
CloudTableCell(
child: TextButton(
onPressed: () async {
ref
.watch(cloudWorkstationsRepositoryProvider)
.stopInstance(
projectId,
workstation.clusterName,
workstation.configName,
workstation.displayName,
region);
ref.invalidate(allWorkstationsProvider);
},
child: Text(
"Stop",
style: AppText.linkFontStyle,
),
),
),
CloudTableCell(
child: TextButton(
onPressed: () async {
ref
.watch(cloudWorkstationsRepositoryProvider)
.deleteInstance(
projectId,
workstation.clusterName,
workstation.configName,
workstation.displayName,
region);
ref.invalidate(allWorkstationsProvider);
},
child: Text(
"Delete",
style: AppText.linkFontStyle,
),
),
),
CloudTableCell(
child: CloudTableCellText(text: workstation.configName)),
],
),
);
}
},
).toList();
rows.insert(
0,
TableRow(
decoration: BoxDecoration(
color: Color.fromRGBO(0, 0, 0, 0.04),
),
children: [
CloudTableCell(child: CloudTableCellText(text: "Name")),
CloudTableCell(child: CloudTableCellText(text: "Host")),
CloudTableCell(child: CloudTableCellText(text: "State")),
CloudTableCell(child: CloudTableCellText(text: "Action")),
CloudTableCell(child: CloudTableCellText(text: "")),
CloudTableCell(child: CloudTableCellText(text: "")),
CloudTableCell(child: CloudTableCellText(text: "")),
CloudTableCell(child: CloudTableCellText(text: "Config")),
],
),
);
return CloudTable(
columnWidths: const {
0: FlexColumnWidth(1),
1: FlexColumnWidth(7),
},
children: rows,
);
}