Commit 9f51b022 authored by Manuel Herold's avatar Manuel Herold

communitygraph

parent 78f45865
2021/03/15-17:09:04.000 282c Reusing MANIFEST C:\Users\Luca\AppData\Local\Temp\flutter_tools.feb939e7\flutter_tools_chrome_device.d8bc148a\Default\AutofillStrikeDatabase/MANIFEST-000001
2021/03/15-17:09:04.000 282c Recovering log #3
2021/03/15-17:09:04.000 282c Reusing old log C:\Users\Luca\AppData\Local\Temp\flutter_tools.feb939e7\flutter_tools_chrome_device.d8bc148a\Default\AutofillStrikeDatabase/000003.log
2021/03/15-17:09:03.997 1d00 Reusing MANIFEST C:\Users\Luca\AppData\Local\Temp\flutter_tools.feb939e7\flutter_tools_chrome_device.d8bc148a\Default\BudgetDatabase/MANIFEST-000001
2021/03/15-17:09:03.997 1d00 Recovering log #3
2021/03/15-17:09:03.997 1d00 Reusing old log C:\Users\Luca\AppData\Local\Temp\flutter_tools.feb939e7\flutter_tools_chrome_device.d8bc148a\Default\BudgetDatabase/000003.log
This source diff could not be displayed because it is too large. You can view the blob instead.
{"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-15 17:08:16.625001","version":"2.0.1"} {"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 \ No newline at end of file
This diff is collapsed.
import 'package:intl/intl.dart';
import 'post.dart'; import 'post.dart';
class Community { class Community {
...@@ -5,4 +7,10 @@ class Community { ...@@ -5,4 +7,10 @@ class Community {
final String name; final String name;
final double trust; final double trust;
List<Post> posts; List<Post> posts;
String get formattedTrustScore {
NumberFormat format = NumberFormat("###.00");
return format.format(trust*100)+"%";
}
} }
...@@ -21,12 +21,6 @@ class Post { ...@@ -21,12 +21,6 @@ class Post {
return title; return title;
} }
String get effectiveContent {
if (content != null && content.isNotEmpty) return content;
return title;
}
String get formattedTrustScore { String get formattedTrustScore {
NumberFormat format = NumberFormat("###.00"); NumberFormat format = NumberFormat("###.00");
......
import 'package:dashboard/ui/theme/color_holder.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
...@@ -9,16 +10,23 @@ class LoadingScreen extends StatelessWidget { ...@@ -9,16 +10,23 @@ class LoadingScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: ColorHolder.color3,
body: Center( body: Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
SpinKitRotatingCircle( SpinKitRotatingCircle(
color: Theme.of(context).primaryColor, color: ColorHolder.color2,
size: 150.0, size: 200.0,
), ),
SizedBox(height: 16), SizedBox(height: 16),
Text(message), Text(
message,
style: TextStyle(
color: ColorHolder.color2,
fontSize: 22,
),
),
], ],
), ),
), ),
......
import 'package:dashboard/exceptions/login_exception.dart'; import 'package:dashboard/exceptions/login_exception.dart';
import 'package:dashboard/loading.dart'; import 'package:dashboard/loading.dart';
import 'package:dashboard/querying/cluster.dart'; import 'package:dashboard/ui/graphs/community_meta/index.dart';
import 'package:dashboard/ui/graphs/community/index.dart';
import 'package:dashboard/ui/sign_in/loginpage.dart'; import 'package:dashboard/ui/sign_in/loginpage.dart';
import 'package:dashboard/util/loginhelper.dart'; import 'package:dashboard/util/loginhelper.dart';
import 'package:dashboard/util/user.dart'; import 'package:dashboard/util/user.dart';
import 'package:enhanced_future_builder/enhanced_future_builder.dart'; import 'package:enhanced_future_builder/enhanced_future_builder.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'graphing/communitymetagraph.dart';
void main() { void main() {
runApp(MyApp()); runApp(ArticonfDashboardDemo());
} }
class MyApp extends StatefulWidget { class ArticonfDashboardDemo extends StatefulWidget {
@override @override
_MyAppState createState() => _MyAppState(); _ArticonfDashboardDemoState createState() => _ArticonfDashboardDemoState();
} }
class _MyAppState extends State<MyApp> { class _ArticonfDashboardDemoState extends State<ArticonfDashboardDemo> {
Future<BackendUser> _checkLoginStuff() async { Future<BackendUser> _checkLoginStuff() async {
try { try {
return await LoginHelper().loggedInUser; return await LoginHelper().loggedInUser;
...@@ -30,7 +27,8 @@ class _MyAppState extends State<MyApp> { ...@@ -30,7 +27,8 @@ class _MyAppState extends State<MyApp> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ClusterGetter().getClusters(); // ClusterGetter().getClusters();
return MaterialApp( return MaterialApp(
home: EnhancedFutureBuilder<BackendUser>( home: EnhancedFutureBuilder<BackendUser>(
future: _checkLoginStuff(), future: _checkLoginStuff(),
......
...@@ -10,17 +10,15 @@ class ClusterGetter { ...@@ -10,17 +10,15 @@ class ClusterGetter {
Future<List<Community>> getNodesfromLayer(String layerName) async { Future<List<Community>> getNodesfromLayer(String layerName) async {
String url = String url =
"https://articonf1.itec.aau.at:30101/api/use-cases/reddit/tables/reddit/layers/$layerName/nodes"; "https://articonf1.itec.aau.at:30101/api/use-cases/reddit/tables/reddit/layers/$layerName/nodes";
Logger().i(url);
BackendUser user = await LoginHelper().loggedInUser; BackendUser user = await LoginHelper().loggedInUser;
String token = user.token; String token = user.token;
Logger().i(token);
Map<String, dynamic> headers = {"Authorization": "Bearer $token"}; Map<String, dynamic> headers = {"Authorization": "Bearer $token"};
List<dynamic> nodesList = List<dynamic> nodesList =
await DataGetter.getJsonList(url, headers: headers); await DataGetter.getJsonList(url, headers: headers);
Logger().i(nodesList.toString());
Map<String, List<Post>> resultMap = {}; Map<String, List<Post>> resultMap = {};
List<Community> communityList = []; List<Community> communityList = [];
...@@ -47,8 +45,6 @@ class ClusterGetter { ...@@ -47,8 +45,6 @@ class ClusterGetter {
entry["subreddit"], entry["subreddit"],
entry["percentage_upvoted"], entry["percentage_upvoted"],
entry["n_comments"])); entry["n_comments"]));
Logger().i(community.posts.toString());
} }
return communityList; return communityList;
......
...@@ -136,8 +136,6 @@ class DataGetter { ...@@ -136,8 +136,6 @@ class DataGetter {
Map<String, dynamic> communities = Map<String, dynamic> communities =
await DataGetter.getJson("http://live.nope-api.systems:81/communities"); await DataGetter.getJson("http://live.nope-api.systems:81/communities");
Logger().i(communities.toString());
List<Community> communityList = []; List<Community> communityList = [];
for (var entry in communities.entries) { for (var entry in communities.entries) {
......
import 'dart:math'; import 'dart:math';
import 'package:dashboard/data/community.dart'; import 'package:dashboard/data/community.dart';
import 'package:dashboard/graphing/communitymetagraph.dart';
import 'package:dashboard/loading.dart'; import 'package:dashboard/loading.dart';
import 'package:dashboard/querying/datagetter.dart'; import 'package:dashboard/querying/datagetter.dart';
import 'package:dashboard/ui/graphs/community/circle/communitygraph.dart'; import 'package:dashboard/ui/graphs/community/circle/communitygraph.dart';
import 'package:dashboard/ui/graphs/community/cloud/communitycloud.dart';
import 'package:dashboard/ui/graphs/community/list/community_list.dart'; import 'package:dashboard/ui/graphs/community/list/community_list.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart'; import 'package:dashboard/ui/graphs/community_meta/index.dart';
import 'package:enhanced_future_builder/enhanced_future_builder.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class CommunityGraphViewPage extends StatefulWidget { class CommunityGraphViewPage extends StatefulWidget {
...@@ -71,88 +68,6 @@ class _CommunityGraphViewPageState extends State<CommunityGraphViewPage> { ...@@ -71,88 +68,6 @@ class _CommunityGraphViewPageState extends State<CommunityGraphViewPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return LoadingScreen(message: "Fetching posts..."); return LoadingScreen(message: "Fetching posts...");
// return Scaffold(
// appBar: LoggedInAppBar("Community: ${widget.communityname}"),
// backgroundColor: Colors.white,
// floatingActionButton: Row(
// mainAxisSize: MainAxisSize.min,
// children: [
// Expanded(
// child: Row(
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// SizedBox(width: 32),
// FloatingActionButton(
// onPressed: () => redirectToCommunityMetaGraph(context),
// child: Icon(Icons.zoom_out),
// ),
// SizedBox(width: 8),
// FloatingActionButton(
// onPressed: () => _toggleCloudMode(context),
// child: Icon(
// _inCloudMode ? Icons.circle : Icons.cloud,
// ),
// ),
// ],
// ),
// ),
// FloatingActionButton(
// onPressed: _onPrevious,
// child: Icon(Icons.arrow_left),
// ),
// SizedBox(width: 8),
// Container(
// decoration: BoxDecoration(
// color: Theme.of(context).primaryColor,
// borderRadius: BorderRadius.all(Radius.circular(20)),
// ),
// width: 200,
// height: 60,
// alignment: Alignment.center,
// padding: EdgeInsets.symmetric(horizontal: 16),
// child: Text(
// "Post #${_startIndex + 1} - #${_endIndex + 1}",
// style: TextStyle(
// color: Colors.white,
// fontSize: 18,
// ),
// ),
// ),
// SizedBox(width: 8),
// FloatingActionButton(
// onPressed: _onNext,
// child: Icon(Icons.arrow_right),
// )
// ],
// ),
// body: EnhancedFutureBuilder<Community>(
// future: DataGetter.getCommunity(widget.communityname),
// rememberFutureResult: false,
// whenDone: (result) {
// _data = result;
// return _inCloudMode
// ? CommunityList(
// result,
// _startIndex,
// )
// // ? CommunityCloud(
// // result,
// // _startIndex,
// // )
// : CommunityGraph(
// result,
// offset: _startIndex,
// );
// },
// whenNotDone: Container(
// alignment: Alignment.center,
// child: LoadingScreen(
// message: "Fetching Posts...",
// ),
// ),
// ),
// );
} }
void redirectToCommunityMetaGraph(BuildContext context) { void redirectToCommunityMetaGraph(BuildContext context) {
......
import 'package:dashboard/data/post.dart'; import 'package:dashboard/data/post.dart';
import 'package:dashboard/graphing/postnode.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class PostView extends StatelessWidget { class PostView extends StatelessWidget {
...@@ -13,6 +14,16 @@ class PostView extends StatelessWidget { ...@@ -13,6 +14,16 @@ class PostView extends StatelessWidget {
this.withExplanation = false, this.withExplanation = false,
}); });
void _onPostTap(BuildContext context) {
showDialog(
context: context,
builder: (context) => PostNodeDialog(
post,
Colors.green,
),
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return Row(
...@@ -66,6 +77,8 @@ class PostView extends StatelessWidget { ...@@ -66,6 +77,8 @@ class PostView extends StatelessWidget {
children: [ children: [
Align( Align(
alignment: Alignment.center, alignment: Alignment.center,
child: GestureDetector(
onTap: () => _onPostTap(context),
child: Container( child: Container(
width: 400, width: 400,
child: Card( child: Card(
...@@ -110,6 +123,7 @@ class PostView extends StatelessWidget { ...@@ -110,6 +123,7 @@ class PostView extends StatelessWidget {
), ),
), ),
), ),
),
], ],
), ),
), ),
......
import 'dart:math'; import 'dart:math';
import 'package:circlegraph/bubble/bubblegraph.dart';
import 'package:circlegraph/circlegraph.dart'; import 'package:circlegraph/circlegraph.dart';
import 'package:dashboard/data/communityGraphNodeData.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/cluster.dart';
import 'package:dashboard/querying/datagetter.dart'; import 'package:dashboard/querying/datagetter.dart';
import 'package:dashboard/graphing/postnode.dart';
import 'package:dashboard/ui/graphs/community/index.dart'; import 'package:dashboard/ui/graphs/community/index.dart';
import 'package:dashboard/ui/theme/color_holder.dart'; import 'package:dashboard/ui/theme/color_holder.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart'; import 'package:dashboard/ui/util/logged_in_appbar.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import '../data/community.dart';
import '../data/post.dart';
import 'postnode.dart';
import 'trustcolorcalculator.dart';
import 'package:enhanced_future_builder/enhanced_future_builder.dart'; import 'package:enhanced_future_builder/enhanced_future_builder.dart';
class CommunityMetaGraph extends StatefulWidget { class CommunityMetaGraph extends StatefulWidget {
...@@ -30,36 +27,87 @@ class _CommunityMetaGraphState extends State<CommunityMetaGraph> { ...@@ -30,36 +27,87 @@ class _CommunityMetaGraphState extends State<CommunityMetaGraph> {
_CommunityMetaGraphState(this.communities); _CommunityMetaGraphState(this.communities);
Widget build(BuildContext context) { Widget build(BuildContext context) {
Logger().i(communities.toString());
return SingleChildScrollView( return SingleChildScrollView(
child: Wrap( child: BubbleGraph(
communities
.map(
(Community community) => CircleGraph(
root: TreeNodeData(
onNodeClick: (node, data) => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CommunityGraphViewPage(data.name),
),
),
data: community,
backgroundColor: ColorHolder.color1,
child: Container(
constraints: BoxConstraints.expand(),
child: Stack(
children: [
Align(
alignment: Alignment.topRight,
child: Container(
width: 70,
height: 70,
alignment: Alignment.center,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.blue,
),
child: Text(
community.formattedTrustScore,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.green[800],
fontSize: 14,
),
),
),
),
Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.only(top: 32.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [ children: [
for (Community community in communities) Icon(
getCommunityNodeWidget(community) Icons.group_work,
color: ColorHolder.color2,
),
Text(
"${community.name}",
style: TextStyle(
color: ColorHolder.color2,
),
),
], ],
), ),
),
),
],
),
),
height: 160,
width: 160,
),
circlify: true,
backgroundColor: ColorHolder.color1,
),
)
.toList(),
),
); );
}
TreeNodeData<CommunityGraphNodeData> _getCommunityNode(Community community) {
CommunityGraphNodeData data =
CommunityGraphNodeData.fromCommunity(community);
return TreeNodeData(
child: getCommunityNodeWidget(community),
data: data,
width: 500,
);
}
TreeNodeData<CommunityGraphNodeData> _getPostNode(Post post) {
CommunityGraphNodeData data = CommunityGraphNodeData.fromPost(post);
return TreeNodeData<CommunityGraphNodeData>( // return SingleChildScrollView(
child: PostNode(post), // child: Wrap(
data: data, // children: [
width: 500, // for (Community community in communities)
); // getCommunityNodeWidget(community)
// ],
// ),
// );
} }
Widget getCommunityNodeWidget(Community community) { Widget getCommunityNodeWidget(Community community) {
...@@ -109,27 +157,21 @@ class CommunityMetaGraphViewPage extends StatelessWidget { ...@@ -109,27 +157,21 @@ class CommunityMetaGraphViewPage extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: LoggedInAppBar("Communities"), appBar: LoggedInAppBar("Communities"),
backgroundColor: ColorHolder.color3, backgroundColor: ColorHolder.color3,
//floatingActionButton: FloatingActionButton(
// onPressed: () => print("hoe"),
// child: Icon(Icons.zoom_in),
//),
body: Container( body: Container(
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
constraints: BoxConstraints.expand(), constraints: BoxConstraints.expand(),
child: Column( child: EnhancedFutureBuilder(
mainAxisSize: MainAxisSize.max,
children: [
EnhancedFutureBuilder(
future: DataGetter.getCommunities(), future: DataGetter.getCommunities(),
rememberFutureResult: false, rememberFutureResult: false,
whenDone: (communities) => CommunityMetaGraph(communities), whenDone: (communities) => CommunityMetaGraph(communities),
whenNotDone: Container( whenNotDone: Container(
alignment: Alignment.center, alignment: Alignment.center,
child: Text("Loading..."), child: LoadingScreen(
message: "Fetching Data...",
), ),
), ),
],
), ),
)); ),
);
} }
} }
...@@ -100,7 +100,7 @@ class _LoginPageState extends State<LoginPage> { ...@@ -100,7 +100,7 @@ class _LoginPageState extends State<LoginPage> {
// restart app (should login automatically) // restart app (should login automatically)
Navigator.of(context).pushReplacement( Navigator.of(context).pushReplacement(
MaterialPageRoute( MaterialPageRoute(
builder: (context) => MyApp(), builder: (context) => ArticonfDashboardDemo(),
), ),
); );
} }
......
...@@ -15,7 +15,7 @@ class LoggedInAppBar extends PreferredSize { ...@@ -15,7 +15,7 @@ class LoggedInAppBar extends PreferredSize {
await LoginHelper().logout(); await LoginHelper().logout();
Navigator.of(context).pushReplacement( Navigator.of(context).pushReplacement(
MaterialPageRoute( MaterialPageRoute(
builder: (context) => MyApp(), builder: (context) => ArticonfDashboardDemo(),
), ),
); );
} }
......
...@@ -13,7 +13,7 @@ import 'package:dashboard/main.dart'; ...@@ -13,7 +13,7 @@ import 'package:dashboard/main.dart';
void main() { void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async { testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame. // Build our app and trigger a frame.
await tester.pumpWidget(MyApp()); await tester.pumpWidget(ArticonfDashboardDemo());
// Verify that our counter starts at 0. // Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget); expect(find.text('0'), findsOneWidget);
......
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