athrainsky 7 hónapja
szülő
commit
7a63bc624d

+ 33 - 215
lib/bug/addcomment.dart

@@ -1,23 +1,16 @@
 import 'package:flutter/material.dart';
 import 'package:namer_app/footer.dart';
 import 'package:namer_app/header.dart';
-
-import '../service/addbug_serv.dart';
+import 'package:namer_app/service/addcomment_serv.dart';
 
 class AddCommentPage extends StatelessWidget {
-  const AddCommentPage({super.key});
+  final int bugId;
+  const AddCommentPage({super.key, required this.bugId});
 
   @override
   Widget build(BuildContext context) {
-    var bugdesc = TextEditingController();
-    var bugqc = TextEditingController();
-    var bugdev = TextEditingController();
-    var bugplatform = TextEditingController();
-    var buggoodday = TextEditingController();
-    var bugimage = TextEditingController();
-    var buglevel = TextEditingController();
-    var bugstatus = TextEditingController();
-    var bugdevStatus = TextEditingController();
+    // var bugId = TextEditingController();
+    var content = TextEditingController();
     return Scaffold(
       appBar: CustomAppbar(),
       backgroundColor: Colors.white,
@@ -38,6 +31,31 @@ class AddCommentPage extends StatelessWidget {
               )),
               Column(
                 children: [
+                  // Padding(
+                  //   padding: const EdgeInsets.all(8.0),
+                  //   child: SizedBox(
+                  //     width: 396,
+                  //     child: TextField(
+                  //       decoration: InputDecoration(
+                  //           border: OutlineInputBorder(),
+                  //           focusedBorder: OutlineInputBorder(
+                  //               borderRadius:
+                  //                   BorderRadius.all(Radius.circular(12)),
+                  //               borderSide: BorderSide(color: Colors.black)),
+                  //           enabledBorder: OutlineInputBorder(
+                  //               borderRadius:
+                  //                   BorderRadius.all(Radius.circular(12)),
+                  //               borderSide: BorderSide(color: Colors.black)),
+                  //           labelText: 'Enter Description',  
+                  //           labelStyle: TextStyle(color: Colors.black),
+                  //           filled: true,
+                  //           fillColor: Colors.white.withOpacity(0.25)),
+                  //       cursorColor: Colors.black,
+                  //       style: TextStyle(color: Colors.black),
+                  //       controller: bugId,
+                  //     ),
+                  //   ),
+                  // ),
                   Padding(
                     padding: const EdgeInsets.all(8.0),
                     child: SizedBox(
@@ -53,213 +71,13 @@ class AddCommentPage extends StatelessWidget {
                                 borderRadius:
                                     BorderRadius.all(Radius.circular(12)),
                                 borderSide: BorderSide(color: Colors.black)),
-                            labelText: 'Enter Description',  
-                            labelStyle: TextStyle(color: Colors.black),
-                            filled: true,
-                            fillColor: Colors.white.withOpacity(0.25)),
-                        cursorColor: Colors.black,
-                        style: TextStyle(color: Colors.black),
-                        controller: bugdesc,
-                      ),
-                    ),
-                  ),
-                  Padding(
-                    padding: const EdgeInsets.all(8.0),
-                    child: SizedBox(
-                      width: 396,
-                      child: TextField(
-                        decoration: InputDecoration(
-                            border: OutlineInputBorder(),
-                            focusedBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            enabledBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            labelText: 'Enter QC', //todo get data
-                            labelStyle: TextStyle(color: Colors.black),
-                            filled: true,
-                            fillColor: Colors.white.withOpacity(0.25)),
-                        cursorColor: Colors.black,
-                        style: TextStyle(color: Colors.black),
-                        controller: bugqc,
-                      ),
-                    ),
-                  ),
-                  Padding(
-                    padding: const EdgeInsets.all(8.0),
-                    child: SizedBox(
-                      width: 396,
-                      child: TextField(
-                        decoration: InputDecoration(
-                            border: OutlineInputBorder(),
-                            focusedBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            enabledBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            labelText: 'Enter Dev', //todo get data
-                            labelStyle: TextStyle(color: Colors.black),
-                            filled: true,
-                            fillColor: Colors.white.withOpacity(0.25)),
-                        cursorColor: Colors.black,
-                        style: TextStyle(color: Colors.black),
-                        controller: bugdev,
-                      ),
-                    ),
-                  ),
-                  Padding(
-                    padding: const EdgeInsets.all(8.0),
-                    child: SizedBox(
-                      width: 396,
-                      child: TextField(
-                        decoration: InputDecoration(
-                            border: OutlineInputBorder(),
-                            focusedBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            enabledBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            labelText: 'Enter Platform', //todo get data
-                            labelStyle: TextStyle(color: Colors.black),
-                            filled: true,
-                            fillColor: Colors.white.withOpacity(0.25)),
-                        cursorColor: Colors.black,
-                        style: TextStyle(color: Colors.black),
-                        controller: bugplatform,
-                      ),
-                    ),
-                  ),
-                  Padding(
-                    padding: const EdgeInsets.all(8.0),
-                    child: SizedBox(
-                      width: 396,
-                      child: TextField(
-                        decoration: InputDecoration(
-                            border: OutlineInputBorder(),
-                            focusedBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            enabledBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            labelText: 'Enter Goodday URL', 
-                            labelStyle: TextStyle(color: Colors.black),
-                            filled: true,
-                            fillColor: Colors.white.withOpacity(0.25)),
-                        cursorColor: Colors.black,
-                        style: TextStyle(color: Colors.black),
-                        controller: buggoodday,
-                      ),
-                    ),
-                  ),
-                  Padding(
-                    padding: const EdgeInsets.all(8.0),
-                    child: SizedBox(
-                      width: 396,
-                      child: TextField(
-                        decoration: InputDecoration(
-                            border: OutlineInputBorder(),
-                            focusedBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            enabledBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            labelText: 'Enter Image URL', 
-                            labelStyle: TextStyle(color: Colors.black),
-                            filled: true,
-                            fillColor: Colors.white.withOpacity(0.25)),
-                        cursorColor: Colors.black,
-                        style: TextStyle(color: Colors.black),
-                        controller: bugimage,
-                      ),
-                    ),
-                  ),
-                  Padding(
-                    padding: const EdgeInsets.all(8.0),
-                    child: SizedBox(
-                      width: 396,
-                      child: TextField(
-                        decoration: InputDecoration(
-                            border: OutlineInputBorder(),
-                            focusedBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            enabledBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            labelText: 'Enter Level', //todo get data
-                            labelStyle: TextStyle(color: Colors.black),
-                            filled: true,
-                            fillColor: Colors.white.withOpacity(0.25)),
-                        cursorColor: Colors.black,
-                        style: TextStyle(color: Colors.black),
-                        controller: buglevel,
-                      ),
-                    ),
-                  ),
-                  Padding(
-                    padding: const EdgeInsets.all(8.0),
-                    child: SizedBox(
-                      width: 396,
-                      child: TextField(
-                        decoration: InputDecoration(
-                            border: OutlineInputBorder(),
-                            focusedBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            enabledBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            labelText: 'Enter Status', //todo get data
-                            labelStyle: TextStyle(color: Colors.black),
-                            filled: true,
-                            fillColor: Colors.white.withOpacity(0.25)),
-                        cursorColor: Colors.black,
-                        style: TextStyle(color: Colors.black),
-                        controller: bugstatus,
-                      ),
-                    ),
-                  ),
-                  Padding(
-                    padding: const EdgeInsets.all(8.0),
-                    child: SizedBox(
-                      width: 396,
-                      child: TextField(
-                        decoration: InputDecoration(
-                            border: OutlineInputBorder(),
-                            focusedBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            enabledBorder: OutlineInputBorder(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(12)),
-                                borderSide: BorderSide(color: Colors.black)),
-                            labelText: 'Enter Dev Status', //todo get data
+                            labelText: 'Enter Content', //todo get data
                             labelStyle: TextStyle(color: Colors.black),
                             filled: true,
                             fillColor: Colors.white.withOpacity(0.25)),
                         cursorColor: Colors.black,
                         style: TextStyle(color: Colors.black),
-                        controller: bugdevStatus,
+                        controller: content,
                       ),
                     ),
                   ),
@@ -269,7 +87,7 @@ class AddCommentPage extends StatelessWidget {
                       width: 396,
                       height: 61,
                       child: ElevatedButton(
-                        onPressed: () => addbug(context, bugdesc.text, bugqc.text, bugdev.text, bugplatform.text, buggoodday.text, bugimage.text, buglevel.text, bugstatus.text, bugdevStatus.text), //todo save edit
+                        onPressed: () => addcomment(context, bugId, content.text), //todo save edit
                         style: ElevatedButton.styleFrom(
                           backgroundColor: Colors.black, 
                           side: BorderSide(color: Colors.white),

+ 2 - 1
lib/bug/listcomment.dart

@@ -4,6 +4,7 @@ import 'package:dio/dio.dart';
 import 'package:flutter/material.dart';
 import 'package:namer_app/footer.dart';
 import 'package:namer_app/header.dart';
+import 'package:namer_app/service/delete_comment.dart';
 
 import '../globals.dart';
 
@@ -106,7 +107,7 @@ class ButtonUser extends StatelessWidget {
       mainAxisSize: MainAxisSize.min,
       children: [
         ElevatedButton(
-          onPressed: null,
+          onPressed: () => delcomment(context, items['id']),
           style: ElevatedButton.styleFrom(
             backgroundColor: Colors.black,
           ),

+ 0 - 24
lib/data/datacomment.dart

@@ -1,24 +0,0 @@
-// ignore_for_file: file_names
-
-final List comments = [
-  {
-    'comment': 'bug ini sedang digarap',
-    'created': '5 apr 2024 13:22:34',
-    'creator': 'Irma',
-  },
-  {
-    'comment': 'sudah kelar',
-    'created': '5 jun 2024 01:22:34',
-    'creator': 'Agus',
-  },
-  {
-    'comment': 'masih kejadian',
-    'created': '17 apr 2024 22:22:34',
-    'creator': 'Mita',
-  },
-  {
-    'comment': 'hi sedang apa',
-    'created': '25 Jun 2024 08:22:34',
-    'creator': 'Arif',
-  },
-];

+ 3 - 3
lib/main.dart

@@ -87,8 +87,8 @@ void main() {
                     builder: (context, state) {
                       // var item = jsonList.firstWhere(
                       //   (element) => element('id') == state.pathParameters['id']);
-                        // return EditUserPage(json: item);
-                        return EditUserPage(json: null);
+                        return EditUserPage(id: state.pathParameters['id']);
+                        // return EditUserPage(json: null);
                     })
                 ])
           ]),
@@ -132,7 +132,7 @@ void main() {
       GoRoute(path: 'changepass',
         builder: (context, state) => ChangepassPage(), ),
       GoRoute(path: 'addcomment',
-        builder: (context, state) => AddCommentPage(/*bugId: 1*/),),
+        builder: (context, state) => AddCommentPage(bugId: 1),),
     ]),
   ],
 ); 

+ 6 - 7
lib/project/listmember.dart

@@ -9,28 +9,27 @@ import '../globals.dart';
 
 class ListMemberPage extends StatefulWidget {
   final int projId;
-  
   const ListMemberPage({super.key, required this.projId});
 
   @override
   State<ListMemberPage> createState() => _ListMemberPageState(
-    id: projId
+    bugId: projId
   );
 }
 
 class _ListMemberPageState extends State<ListMemberPage> {
- int id;
- _ListMemberPageState({required this.id});
+ int bugId;
+ _ListMemberPageState({required this.bugId});
 var members;
 @override
 void initState(){
-  getData(id);
+  getData(bugId);
 }
 
-void getData(int id) async { 
+void getData(int bugId) async { 
     try { 
       var response = await Dio() 
-          .get('http://localhost:8080/api/v1/projects/$id/member',
+          .get('http://localhost:8080/api/v1/projects/$bugId/member',
           options: Options(headers: headers)); 
       if (response.statusCode == 200) { 
         setState(() { 

+ 5 - 5
lib/service/addcomment_serv.dart

@@ -7,12 +7,12 @@ import 'package:flutter/material.dart';
 import 'package:go_router/go_router.dart';
 import '../globals.dart';
 
-Future<void> addcomment(BuildContext context, String desc, String qc, String dev, String platform, String goodday, String image, String level, String status, String devStatus /*Map data*/) async {
+Future<void> addcomment(BuildContext context, int bugId, String content /*Map data*/) async {
     final dio = Dio();
     Response response;
 
     AlertDialog alert2 = AlertDialog(
-      title: Text("Add Bug Gagal"),
+      title: Text("Add Comment Gagal"),
       content: Text("Data Invalid"),
       actions: [
         TextButton( 
@@ -28,14 +28,14 @@ Future<void> addcomment(BuildContext context, String desc, String qc, String dev
           'authorization': auth
       };
     try{
-      response = await dio.post("http://localhost:8080/api/v1/bugs", 
+      response = await dio.post("http://localhost:8080/api/v1/bugs/$bugId/comment", 
                   options: Options(headers: headers),
                   data: 
                   // data 
-                  {'description':desc, 'qc': qc, 'dev': dev, 'platform':platform, 'goodday_url':goodday, 'image_url':image, 'level':level, 'status':status, 'dev_status':devStatus}
+                  {'content':content}
                   );    
       if (response.statusCode == 201){
-          return context.go('/listbug');
+          return context.go('/login/bug/comment');
       } 
     } catch (error){     
       

+ 49 - 0
lib/service/delete_comment.dart

@@ -0,0 +1,49 @@
+
+// ignore_for_file: use_build_context_synchronously
+
+import 'dart:convert';
+import 'package:dio/dio.dart';
+import 'package:flutter/material.dart';
+import '../globals.dart';
+
+Future<void> delcomment(BuildContext context, int id) async{
+  final dio = Dio();
+  Response response;
+    AlertDialog alert = AlertDialog(
+      title: Text("Delete Sukses"),
+      content: Text("Data terhapus"),
+      actions: [
+        TextButton( 
+          child: Text('Ok'),
+          onPressed: () => Navigator.of(context).pop(),
+        ),
+      ],
+    );
+        AlertDialog alert2 = AlertDialog(
+      title: Text("Delete Gagal"),
+      content: Text("Data Invalid"),
+      actions: [
+        TextButton( 
+          child: Text('Ok'),
+          onPressed: () => Navigator.of(context).pop(),
+        ),
+      ],
+    );
+            var auth = 'Basic ${base64Encode(utf8.encode('$USER_LOGIN:$PASS_LOGIN'))}';
+        Map<String, String> headers = {
+          'content-type': 'application/json',
+          'accept': 'application/json',
+          'authorization': auth
+      };
+try {
+  response = await dio.delete("http://localhost:8080/api/v1/comments/$id",
+              options: Options(headers: headers)
+              );
+  if(response.statusCode == 200){
+    showDialog(context: context, builder: (context) => alert);
+    
+  }
+} catch (error){
+  showDialog(context: context, builder: (context) => alert2);
+}
+} 

+ 4 - 2
lib/user/edituser.dart

@@ -9,8 +9,10 @@ import 'package:namer_app/service/edit_user.dart';
 import '../globals.dart';
 
 
+// ignore: must_be_immutable
 class EditUserPage extends StatefulWidget {
-  const EditUserPage({super.key, required json});
+  var id;
+  EditUserPage({super.key, required this.id});
 
 @override
 State<EditUserPage> createState() => _EditUserPageState();
@@ -26,7 +28,7 @@ void initState(){
 void getData() async { 
     try { 
       var response = await Dio() 
-          .get('http://localhost:8080/api/v1/users',
+          .get('http://localhost:8080/api/v1/users/${widget.id}',
           options: Options(headers: headers)); 
       if (response.statusCode == 200) { 
         setState(() {