Commit c0d4a8b3 authored by Manuel Herold's avatar Manuel Herold

Merge remote-tracking branch 'origin/feature/dashboard' into feature/dashboard

parents e0c01938 eabf542a
# This is a generated file; do not edit or check into version control.
integration_test=D:\\Libs\\flutter\\packages\\integration_test\\
path_provider=D:\\Libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider-1.6.27\\
path_provider_linux=D:\\Libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_linux-0.0.1+2\\
path_provider_macos=D:\\Libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_macos-0.0.4+8\\
path_provider_windows=D:\\Libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_windows-0.0.5\\
integration_test=C:\\Users\\Luca\\Documents\\flutter\\flutter_windows_1.22.5-stable\\flutter\\packages\\integration_test\\
path_provider=C:\\Users\\Luca\\Documents\\flutter\\flutter_windows_1.22.5-stable\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider-1.6.27\\
path_provider_linux=C:\\Users\\Luca\\Documents\\flutter\\flutter_windows_1.22.5-stable\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_linux-0.0.1+2\\
path_provider_macos=C:\\Users\\Luca\\Documents\\flutter\\flutter_windows_1.22.5-stable\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_macos-0.0.4+8\\
path_provider_windows=C:\\Users\\Luca\\Documents\\flutter\\flutter_windows_1.22.5-stable\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_windows-0.0.5\\
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"D:\\\\Libs\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.27\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"D:\\\\Libs\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.27\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4+8\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"D:\\\\Libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-0.0.1+2\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"D:\\\\Libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-0.0.5\\\\","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-03-15 23:28:51.019776","version":"2.0.0"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\Users\\\\Luca\\\\Documents\\\\flutter\\\\flutter_windows_1.22.5-stable\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\Luca\\\\Documents\\\\flutter\\\\flutter_windows_1.22.5-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.27\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\Users\\\\Luca\\\\Documents\\\\flutter\\\\flutter_windows_1.22.5-stable\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\Luca\\\\Documents\\\\flutter\\\\flutter_windows_1.22.5-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.27\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\Users\\\\Luca\\\\Documents\\\\flutter\\\\flutter_windows_1.22.5-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4+8\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\Luca\\\\Documents\\\\flutter\\\\flutter_windows_1.22.5-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-0.0.1+2\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\Luca\\\\Documents\\\\flutter\\\\flutter_windows_1.22.5-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-0.0.5\\\\","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-03-16 15:27:54.226361","version":"2.0.1"}
\ No newline at end of file
This diff is collapsed.
import 'package:dashboard/data/post.dart';
import 'package:logger/logger.dart';
class Cluster {
final String label;
final int id;
final String layerName;
List<Post> nodes;
Cluster(this.label, this.id, this.layerName, this.nodes);
String getDisplayLabel() {
if (label == "noise") return label;
switch (layerName) {
case "Upvotes_Layer":
return "${label.substring(1, label.indexOf("."))} Upvotes";
break;
case "Percentage_Layer":
String trust = label.substring(0, label.indexOf(" "));
if (trust == "1.0")
trust = "100";
else
trust = trust.substring(2);
return "$trust% Trust";
break;
case "Engagement_Layer":
return "${label.substring(0, label.indexOf("."))} comments";
break;
case "Time_Layer":
int timestamp = int.parse(label.substring(0, label.indexOf(".")));
String date =
DateTime.fromMillisecondsSinceEpoch(timestamp * 1000).toString();
date = date.substring(0, date.indexOf(" "));
return "$date";
break;
default:
return "?";
break;
}
}
}
import 'package:dashboard/graphing/usergraph.dart';
import 'package:dashboard/ui/graphs/community/index.dart';
import 'package:dashboard/ui/graphs/community/community_graph_view_page.dart';
import 'package:flutter/material.dart';
import '../data/post.dart';
import 'trustcolorcalculator.dart';
......
......@@ -9,6 +9,6 @@ class TrustColorCalculator {
else if (trustValue <= 0.75)
return Colors.lime;
else
return Colors.lightGreen;
return Colors.lightGreen[200];
}
}
import 'package:circlegraph/circlegraph.dart';
import 'package:dashboard/loading.dart';
import 'package:dashboard/querying/datagetter.dart';
import 'package:dashboard/ui/theme/color_holder.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart';
......@@ -6,6 +7,7 @@ import 'package:enhanced_future_builder/enhanced_future_builder.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import '../data/post.dart';
import '../data/userGraphNodeData.dart';
import 'usernode.dart';
......@@ -38,17 +40,16 @@ class _UserGraphState extends State<UserGraph> {
return Container(
//constraints: BoxConstraints.expand(),
child: InteractiveViewer(
constrained: true,
boundaryMargin: EdgeInsets.all(100),
minScale: 0.01,
maxScale: 5.6,
child: SingleChildScrollView(
child: Center(
child: CircleGraph(
root: _getUserNode(user),
children: [for (Post post in nodes) _getPostNode(post)],
edgeColor: Colors.black,
backgroundColor: Colors.white,
)),
backgroundColor: ColorHolder.color3,
),
),
),
);
}
......@@ -80,22 +81,37 @@ class UserGraphViewPage extends StatelessWidget {
return Scaffold(
backgroundColor: ColorHolder.color3,
appBar: LoggedInAppBar("User: $username"),
body: Container(
constraints: BoxConstraints.expand(),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
EnhancedFutureBuilder<User>(
future: DataGetter.getUser(username),
// future: DataGetter.getJson(
// "http://live.nope-api.systems:81/users/" +
// username.toString()),
rememberFutureResult: false,
whenDone: (result) => UserGraph(result),
whenNotDone: Container(
alignment: Alignment.center, child: Text("loading..."))),
],
),
body: Column(
mainAxisSize: MainAxisSize.max,
children: [
EnhancedFutureBuilder<User>(
future: DataGetter.getUser(username),
// future: DataGetter.getJson(
// "http://live.nope-api.systems:81/users/" +
// username.toString()),
rememberFutureResult: false,
whenDone: (result) => UserGraph(result),
whenNotDone: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SpinKitRotatingCircle(
color: ColorHolder.color2,
size: 200.0,
),
SizedBox(height: 16),
Text(
"Loading",
style: TextStyle(
color: ColorHolder.color2,
fontSize: 22,
),
),
],
),
),
),
],
));
}
}
import 'package:dashboard/exceptions/login_exception.dart';
import 'package:dashboard/loading.dart';
import 'package:dashboard/ui/graphs/community_meta/cluster_view_page.dart';
import 'package:dashboard/ui/graphs/community_meta/index.dart';
import 'package:dashboard/ui/sign_in/loginpage.dart';
import 'package:dashboard/util/loginhelper.dart';
......@@ -36,7 +37,7 @@ class _ArticonfDashboardDemoState extends State<ArticonfDashboardDemo> {
rememberFutureResult: false,
whenDone: (BackendUser snapshotData) {
if (snapshotData == null) return LoginPage();
return CommunityMetaGraphViewPage();
return ClusterViewPage();
},
),
);
......
import 'package:dashboard/data/cluster.dart';
import 'package:dashboard/data/community.dart';
import 'package:dashboard/data/post.dart';
import 'package:dashboard/querying/datagetter.dart';
......@@ -7,6 +8,7 @@ import 'package:logger/logger.dart';
class ClusterGetter {
Map<String, List<Community>> clusterMap;
Future<List<Community>> getNodesfromLayer(String layerName) async {
String url =
"https://articonf1.itec.aau.at:30101/api/use-cases/reddit/tables/reddit/layers/$layerName/nodes";
......@@ -16,13 +18,13 @@ class ClusterGetter {
Map<String, dynamic> headers = {"Authorization": "Bearer $token"};
List<dynamic> nodesList =
List<dynamic> nodeList =
await DataGetter.getJsonList(url, headers: headers);
Map<String, List<Post>> resultMap = {};
List<Community> communityList = [];
for (Map<String, dynamic> entry in nodesList) {
for (Map<String, dynamic> entry in nodeList) {
bool communityExists = false;
Community community;
for (Community tmpCommunity in communityList) {
......@@ -65,4 +67,46 @@ class ClusterGetter {
Logger().i(clusterMap.toString());
return clusterMap;
}
Future<List<Cluster>> getClustersFromLayer(String layerName) async {
String url =
"https://articonf1.itec.aau.at:30103/api/use-cases/reddit/tables/reddit/layers/$layerName/clusters";
BackendUser user = await LoginHelper().loggedInUser;
String token = user.token;
Map<String, dynamic> headers = {"Authorization": "Bearer $token"};
List<dynamic> clusterMapList =
await DataGetter.getJsonList(url, headers: headers);
List<Cluster> clusterList = [];
for (Map<String, dynamic> clusterMap in clusterMapList) {
Cluster cluster = Cluster(clusterMap["label"],
clusterMap["cluster_label"], clusterMap["layer_name"], []);
for (Map<String, dynamic> nodeMap in clusterMap["nodes"]) {
cluster.nodes.add(Post(
nodeMap["title"],
nodeMap["content"],
nodeMap["user_id"],
nodeMap["subreddit"],
nodeMap["percentage_upvoted"],
nodeMap["n_comments"]));
}
clusterList.add(cluster);
}
return clusterList;
}
Future<Cluster> getSpecificClusterFromLayer(String layerName, int id) async {
List<Cluster> clusterList = await getClustersFromLayer(layerName);
for (Cluster cluster in clusterList) {
if (cluster.label == id) return cluster;
}
return null;
}
}
......@@ -118,8 +118,7 @@ class DataGetter {
for (Map<String, dynamic> postMap in postMapList) {
Post post = Post(
postMap[
"content"], // i think title and content got mixed up in the backend
postMap["content"],
postMap["title"],
postMap["user_id"],
postMap["subreddit"],
......
......@@ -5,6 +5,7 @@ import 'package:dashboard/loading.dart';
import 'package:dashboard/querying/datagetter.dart';
import 'package:dashboard/ui/graphs/community/circle/communitygraph.dart';
import 'package:dashboard/ui/graphs/community/list/community_list.dart';
import 'package:dashboard/ui/graphs/community_meta/cluster_view_page.dart';
import 'package:dashboard/ui/graphs/community_meta/index.dart';
import 'package:flutter/material.dart';
......@@ -74,7 +75,7 @@ class _CommunityGraphViewPageState extends State<CommunityGraphViewPage> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CommunityMetaGraphViewPage(),
builder: (context) => ClusterViewPage(),
));
}
}
import 'dart:html';
import 'dart:math';
import 'package:dashboard/data/cluster.dart';
import 'package:dashboard/data/community.dart';
import 'package:dashboard/ui/graphs/community/list/post_view.dart';
import 'package:dashboard/ui/theme/color_holder.dart';
import 'package:dashboard/ui/util/left_to_right_transition%20copy.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart';
import 'package:dashboard/ui/util/right_to_left_transition.dart';
import 'package:dashboard/ui/util/scrolldetector.dart';
import 'package:flutter/material.dart';
class ClusterList extends StatefulWidget {
@override
_ClusterListState createState() => _ClusterListState();
final int offset;
final Cluster cluster;
final int nodesPerPage = 3;
ClusterList(this.cluster, this.offset);
}
class _ClusterListState extends State<ClusterList> {
void _previous() {
int nextOffset = max(
0,
widget.offset - widget.nodesPerPage,
);
if (nextOffset != widget.offset)
Navigator.of(context).pushReplacement(
LeftToRightTransition(
widget: ClusterList(
widget.cluster,
nextOffset,
),
),
);
}
void _next() {
int nextOffset = min(
widget.cluster.nodes.length - widget.nodesPerPage,
widget.offset + widget.nodesPerPage,
);
if (nextOffset != widget.offset)
Navigator.of(context).pushReplacement(
RightToLeftTransition(
widget: ClusterList(
widget.cluster,
nextOffset,
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: LoggedInAppBar("Cluster: ${widget.cluster.getDisplayLabel()}"),
body: ScrollDetector(
onPointerScroll: (event) =>
event.scrollDelta.dy < 0 ? _previous() : _next(),
child: Stack(
children: [
Center(
child: Container(
constraints: BoxConstraints.expand(),
color: ColorHolder.color3,
child: Stack(
children: [
Align(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
for (int i = widget.offset;
i <
min(widget.cluster.nodes.length,
widget.offset + widget.nodesPerPage);
i++)
PostView(
widget.cluster.nodes[i],
index: i + 1,
withExplanation: i == widget.offset,
),
],
),
),
],
),
),
)
],
),
),
);
}
}
import 'dart:math';
import 'package:circlegraph/bubble/bubblegraph.dart';
import 'package:circlegraph/circlegraph.dart';
import 'package:dashboard/data/cluster.dart';
import 'package:dashboard/data/community.dart';
import 'package:dashboard/graphing/trustcolorcalculator.dart';
import 'package:dashboard/loading.dart';
import 'package:dashboard/querying/clustergetter.dart';
import 'package:dashboard/querying/datagetter.dart';
import 'package:dashboard/ui/graphs/community/community_graph_view_page.dart';
import 'package:dashboard/ui/graphs/community/list/cluster_list.dart';
import 'package:dashboard/ui/theme/color_holder.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart';
import 'package:flutter/material.dart';
import 'package:enhanced_future_builder/enhanced_future_builder.dart';
class ClusterGraph extends StatefulWidget {
final List<Cluster> clusters;
ClusterGraph(this.clusters);
_ClusterGraphState createState() => _ClusterGraphState(this.clusters);
}
class _ClusterGraphState extends State<ClusterGraph> {
final List<Cluster> clusters;
int postNodeCount = 10; // Nr of postNodes displayed
_ClusterGraphState(this.clusters);
Widget build(BuildContext context) {
return SingleChildScrollView(
scrollDirection: Axis.vertical,
child: BubbleGraph(
clusters
.map(
(Cluster cluster) => CircleGraph(
root: TreeNodeData(
onNodeClick: (node, data) => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ClusterList(data, 0),
),
),
data: cluster,
backgroundColor: ColorHolder.color1,
child: Container(
constraints: BoxConstraints.expand(),
child: Stack(
children: [
Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.only(top: 32.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.group_work,
color: ColorHolder.color2,
),
Text(
"${cluster.getDisplayLabel()}",
style: TextStyle(
color: ColorHolder.color2,
),
),
],
),
),
),
],
),
),
height: 160,
width: 160,
),
circlify: true,
backgroundColor: ColorHolder.color1,
),
)
.toList(),
),
);
// return SingleChildScrollView(
// child: Wrap(
// children: [
// for (Community community in communities)
// getCommunityNodeWidget(community)
// ],
// ),
// );
}
}
import 'package:dashboard/querying/clustergetter.dart';
import 'package:dashboard/querying/datagetter.dart';
import 'package:dashboard/ui/theme/color_holder.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart';
import 'package:enhanced_future_builder/enhanced_future_builder.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../loading.dart';
import 'cluster_graph.dart';
import 'index.dart';
class ClusterViewPage extends StatelessWidget {
Widget build(BuildContext context) {
return DefaultTabController(
length: 5,
child: Scaffold(
appBar: LoggedInAppBar(
"Cluster View",
bottom: TabBar(
tabs: [
Text("Communities"),
Text("Upvotes"),
Text("Trust"),
Text("Engagement"),
Text("Time")
],
),
),
backgroundColor: ColorHolder.color3,
body: TabBarView(
children: [
Container(
padding: EdgeInsets.all(12),
constraints: BoxConstraints.expand(),
child: EnhancedFutureBuilder(
future: DataGetter.getCommunities(),
rememberFutureResult: false,
whenDone: (communities) => CommunityMetaGraph(communities),
whenNotDone: Container(
alignment: Alignment.center,
child: LoadingScreen(
message: "Fetching Data...",
),
),
),
),
Container(
padding: EdgeInsets.all(12),
constraints: BoxConstraints.expand(),
child: EnhancedFutureBuilder(
future: ClusterGetter().getClustersFromLayer("Upvotes_Layer"),
rememberFutureResult: false,
whenDone: (clusters) => ClusterGraph(clusters),
whenNotDone: Container(
alignment: Alignment.center,
child: LoadingScreen(
message: "Fetching Data...",
),
),
),
),
Container(
padding: EdgeInsets.all(12),
constraints: BoxConstraints.expand(),
child: EnhancedFutureBuilder(
future:
ClusterGetter().getClustersFromLayer("Percentage_Layer"),
rememberFutureResult: false,
whenDone: (clusters) => ClusterGraph(clusters),
whenNotDone: Container(
alignment: Alignment.center,
child: LoadingScreen(
message: "Fetching Data...",
),
),
),
),
Container(
padding: EdgeInsets.all(12),
constraints: BoxConstraints.expand(),
child: EnhancedFutureBuilder(
future:
ClusterGetter().getClustersFromLayer("Engagement_Layer"),
rememberFutureResult: false,
whenDone: (clusters) => ClusterGraph(clusters),
whenNotDone: Container(
alignment: Alignment.center,
child: LoadingScreen(
message: "Fetching Data...",
),
),
),
),
Container(
padding: EdgeInsets.all(12),
constraints: BoxConstraints.expand(),
child: EnhancedFutureBuilder(
future: ClusterGetter().getClustersFromLayer("Time_Layer"),
rememberFutureResult: false,
whenDone: (clusters) => ClusterGraph(clusters),
whenNotDone: Container(
alignment: Alignment.center,
child: LoadingScreen(
message: "Fetching Data...",
),
),
),
),
],
),
),
);
}
}
......@@ -5,9 +5,9 @@ import 'package:circlegraph/circlegraph.dart';
import 'package:dashboard/data/community.dart';
import 'package:dashboard/graphing/trustcolorcalculator.dart';
import 'package:dashboard/loading.dart';
import 'package:dashboard/querying/cluster.dart';
import 'package:dashboard/querying/clustergetter.dart';
import 'package:dashboard/querying/datagetter.dart';
import 'package:dashboard/ui/graphs/community/index.dart';
import 'package:dashboard/ui/graphs/community/community_graph_view_page.dart';
import 'package:dashboard/ui/theme/color_holder.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart';
import 'package:flutter/material.dart';
......@@ -150,28 +150,3 @@ class _CommunityMetaGraphState extends State<CommunityMetaGraph> {
));
}
}
class CommunityMetaGraphViewPage extends StatelessWidget {
Widget build(BuildContext context) {
ClusterGetter().getNodesfromLayer("Upvotes_Layer");
return Scaffold(
appBar: LoggedInAppBar("Communities"),
backgroundColor: ColorHolder.color3,
body: Container(
padding: EdgeInsets.all(12),
constraints: BoxConstraints.expand(),
child: EnhancedFutureBuilder(
future: DataGetter.getCommunities(),
rememberFutureResult: false,
whenDone: (communities) => CommunityMetaGraph(communities),
whenNotDone: Container(
alignment: Alignment.center,
child: LoadingScreen(
message: "Fetching Data...",
),
),
),
),
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment