pake | PHP automation tool with capabilities | Automation library
kandi X-RAY | pake Summary
Support
Quality
Security
License
Reuse
- Parse a YAML string .
- Performs HTTP request .
- Convert glob to regex
- Renders an exception .
- Create an archive
- Search for files inside a directory
- Executes an option
- Parse a short option
- Parse a mapping .
- Run the config file .
pake Key Features
pake Examples and Code Snippets
Trending Discussions on pake
Trending Discussions on pake
QUESTION
I have done some googling on this error I have an it seems to be an error in the EmployeeController but I cannot see what I have done that is different to my other templates that work. This is the error message
Symfony\Component\Debug\Exception\FatalThrowableError
syntax error,unexpected ':', expecting ')'
This is my EmployeeController@edit
public function edit($id, $jabatan)
{
// gabisa pake findOrFail karena ajax
// return response()->json($employees);
$employees = Employee::find($id);
if ($employees) {
if ((int) $jabatan == 0) {
$jabatan = Sallary::select(['id', 'nama_jabatan'])->get()->toArray();
} else $jabatan = [];
return $this->jsRespond(status: true, message: 'Berhasil ambil', [
'employee' => $employees->toArray(),
'jabatan' => $jabatan
]);
} else {
return $this->jsRespond(status: false, message: 'Data Gagal Diambil');
}
}
private function jsRespond($status, $message, $others = [])
{
return response()->json([
'status' => $status,
'message' => $message,
'others' => $others
]);
}
Can someone help me to find the fault?
ANSWER
Answered 2021-Apr-20 at 05:04status:
and message:
in your ->jsRespond(...)
calls are causing the error. Remove them from the calls:
public function edit($id, $jabatan)
{
// gabisa pake findOrFail karena ajax
// return response()->json($employees);
$employees = Employee::find($id);
if ($employees) {
if ((int) $jabatan == 0) {
$jabatan = Sallary::select(['id', 'nama_jabatan'])->get()->toArray();
} else $jabatan = [];
return $this->jsRespond(true, 'Berhasil ambil', [
'employee' => $employees->toArray(),
'jabatan' => $jabatan
]);
} else {
return $this->jsRespond(false, 'Data Gagal Diambil');
}
}
private function jsRespond($status, $message, $others = [])
{
return response()->json([
'status' => $status,
'message' => $message,
'others' => $others
]);
}
QUESTION
Im writing Integration Test using Flutter Driver for the app that utilizes CoachMark library (https://pub.dev/packages/tutorial_coach_mark)
i want to click the text to close the CoachMark, but when i tried to inspect it using VSCode's widget inspector, the text didn't show up on the widget tree, when i hover the inspector to that text, it points to MaterialApp
root widget (see screenshot)
These are methods i tried to locate them with no luck:
find.byType('Text')
find.text('OKE')
find.byType('RichText')
- and even this nested, confusing finder
return find.descendant(of: find.byType('Align'), matching: find.descendant(of:find.byType('SafeArea'), matching: find.descendant(of:find.byType('AnimatedOpacity'), matching: find.descendant(of:find.byType('InkWell'), matching: find.descendant(of: find.byType('Padding'),matching: find.text('OKE'))))));
The reason why i tried using the 4th method is when i tried to dive into the library code itself, it builds the widget something like this
Widget _buildSkip() {
if (widget.hideSkip) {
return SizedBox.shrink();
}
return Align(
alignment: widget.alignSkip,
child: SafeArea(
child: AnimatedOpacity(
opacity: showContent ? 1 : 0,
duration: Duration(milliseconds: 300),
child: InkWell(
onTap: widget.clickSkip,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Text(
widget.textSkip,
style: widget.textStyleSkip
),
),
),
),
),
);
}
i attached one more screenshot to show what i want to click (the text on the bottom right corner on the screen)
any suggestion?
Edit
this is home screen:
class HomeSearchBarWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BaseWidget(
model: HomeSearchBarViewModel(
Provider.of(context),
Provider.of(context),
),
onModelReady: (model) => model.initModel(),
builder: (context, model, child) {
return Container(
padding: EdgeInsets.only(bottom: 5.0),
margin: EdgeInsets.only(top: 8, left: 16, right: 8),
alignment: Alignment.centerLeft,
width: MediaQuery.of(context).size.width,
child: Column(
children: [
Row(
children: [
ImageHelper.logo,
UIHelper.horzSpace(16),
Expanded(
child: TextFormField(
readOnly: true,
decoration: new InputDecoration(
contentPadding: EdgeInsets.all(14),
labelStyle: PinTextStyles.styleBody2(
PinColorsV2.neutral500,
),
prefixIcon: Icon(
Icons.search,
color: PinColorsV2.neutral500,
),
border: UIHelper.inputBorder,
hintText: "Lokasi atau nama proyek",
hintStyle: PinTextStyles.styleBody2(
PinColorsV2.neutral200,
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: PinColorsV2.neutral200,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: PinColorsV2.neutral200,
),
),
),
onTap: () async {
await model.trackLogEvent(
HomeSearchBarTrackingKeys.clickSearch,
);
Navigator.pushNamed(
context,
RoutePaths.ProjectSearch,
arguments: {
"keyword": "",
},
);
},
),
),
UIHelper.horzSpace(12),
CoachMarkWidget(
targets: model.targets,
keyTarget: model.helpCenterKey,
targetIdentify: "Help-Center",
title: "Punya pertanyaan terkait penggunaan aplikasi?",
description:
"Temukan semua solusinya dengan tap ikon tanda tanya di sudut kanan atas.",
onFinish: () => model.hideCoachMark(),
isVisible: model.coachMark != null && model.coachMark.value,
focusWidget: HelpCenterIconWidget(
page: HelpCenterPage.homePage,
iconColor: PinColorsV2.neutral500,
screenNameFrom: HomeViewTrackingKeys.open,
),
),
],
),
],
),
);
},
);
}
}
class HomeSearchBarTrackingKeys {
static const String clickSearch = "landing_click_search";
}
class CoachMarkWidget extends StatelessWidget {
final List targets;
final GlobalKey keyTarget;
final String targetIdentify;
final String title;
final String description;
final bool isVisible;
final Function() onFinish;
final Widget focusWidget;
CoachMarkWidget({
this.targets,
this.keyTarget,
this.targetIdentify,
this.title,
this.description,
this.isVisible = true,
this.onFinish,
this.focusWidget,
});
void initTargetCoachMark() {
return targets.add(
TargetFocus(
identify: targetIdentify,
keyTarget: keyTarget,
contents: [
ContentTarget(
align: AlignContent.bottom,
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 48,
),
child: Column(
children: [
Text(
title,
style: PinTextStylesV2.styleHeadingXSmall(
color: PinColorsV2.neutralWhite,
).merge(
TextStyle(
height: 1.22,
),
),
),
Padding(
padding: EdgeInsets.only(top: 8),
child: Text(
description,
style: PinTextStylesV2.styleParagraphLarge(
color: PinColorsV2.neutralWhite,
).merge(
TextStyle(
height: 1.5,
),
),
),
),
],
),
),
),
],
),
);
}
showTutorial(
BuildContext context,
) {
return TutorialCoachMark(
context,
targets: targets,
colorShadow: PinColorsV2.blue300,
opacityShadow: 0.85,
textSkip: "OKE",
widgetKey: Key('OKE'),
// key: Key("oke"),
textStyleSkip: PinTextStylesV2.styleActionMedium(
color: PinColorsV2.neutralWhite,
),
onFinish: () async {
await onFinish();
},
onClickTarget: (target) async {
await onFinish();
},
onClickSkip: () async {
await onFinish();
},
)..show();
}
@override
Widget build(BuildContext context) {
initTargetCoachMark();
if (isVisible) {
WidgetsBinding.instance.addPostFrameCallback(
(_) {
showTutorial(context);
},
);
}
return Container(
key: keyTarget,
child: focusWidget,
);
}
}
and here is the custom widget code
class TutorialCoachMark{
final BuildContext _context;
final List targets;
final Function(TargetFocus) onClickTarget;
final Function() onFinish;
final double paddingFocus;
final Function() onClickSkip;
final AlignmentGeometry alignSkip;
final String textSkip;
final TextStyle textStyleSkip;
final bool hideSkip;
final Color colorShadow;
final double opacityShadow;
final GlobalKey _widgetKey = GlobalKey();
final Key widgetKey;
OverlayEntry _overlayEntry;
TutorialCoachMark(
this._context, {
this.targets,
this.colorShadow = Colors.black,
this.onClickTarget,
this.onFinish,
this.paddingFocus = 10,
this.onClickSkip,
this.alignSkip = Alignment.bottomRight,
this.textSkip = "SKIP",
this.textStyleSkip = const TextStyle(color: Colors.white),
this.hideSkip = false,
this.opacityShadow = 0.8,
this.widgetKey
}) : assert(targets != null, opacityShadow >= 0 && opacityShadow <= 1);
OverlayEntry _buildOverlay() {
return OverlayEntry(builder: (context) {
return TutorialCoachMarkWidget(
key: _widgetKey,
// key: widgetKey,
// text: widgetKey,
// dua diatas ini tambahan (key nya tadinya pake yang line atas)
targets: targets,
clickTarget: onClickTarget,
paddingFocus: paddingFocus,
clickSkip: skip,
alignSkip: alignSkip,
textSkip: textSkip,
textStyleSkip: textStyleSkip,
hideSkip: hideSkip,
colorShadow: colorShadow,
opacityShadow: opacityShadow,
finish: finish,
);
});
}
// @override
// Widget build(BuildContext context){
// show();
// }
void show() {
if (_overlayEntry == null) {
_overlayEntry = _buildOverlay();
Overlay.of(_context).insert(_overlayEntry);
}
}
void finish() {
if (onFinish != null) onFinish();
_removeOverlay();
}
void skip() {
if (onClickSkip != null) onClickSkip();
_removeOverlay();
}
void next() => _widgetKey?.currentState?.next();
void previous() => _widgetKey?.currentState?.previous();
void _removeOverlay() {
_overlayEntry?.remove();
_overlayEntry = null;
}
}
and here is the 'OKE' button that i want to click
class TutorialCoachMarkWidget extends StatefulWidget {
const TutorialCoachMarkWidget({
Key key,
// this.key = Key('OKE'),
this.targets,
this.finish,
this.paddingFocus = 10,
this.clickTarget,
this.alignSkip = Alignment.bottomRight,
this.textSkip = "SKIP",
this.clickSkip,
this.colorShadow = Colors.black,
this.opacityShadow = 0.8,
this.textStyleSkip = const TextStyle(color: Colors.white),
this.hideSkip,
}) : super(key: key);
final List targets;
final Function(TargetFocus) clickTarget;
final Function() finish;
final Color colorShadow;
final double opacityShadow;
final double paddingFocus;
final Function() clickSkip;
final AlignmentGeometry alignSkip;
final String textSkip;
final TextStyle textStyleSkip;
final bool hideSkip;
// final Key key; ini diganti sama line 44
@override
TutorialCoachMarkWidgetState createState() => TutorialCoachMarkWidgetState();
}
class TutorialCoachMarkWidgetState extends State {
final GlobalKey _focusLightKey = GlobalKey();
final Key textKey = Key('OKE');
bool showContent = false;
TargetFocus currentTarget;
@override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent,
child: Stack(
children: [
AnimatedFocusLight(
key: _focusLightKey,
targets: widget.targets,
finish: widget.finish,
paddingFocus: widget.paddingFocus,
colorShadow: widget.colorShadow,
opacityShadow: widget.opacityShadow,
clickTarget: (target) {
if (widget.clickTarget != null) widget.clickTarget(target);
},
focus: (target) {
setState(() {
currentTarget = target;
showContent = true;
});
},
removeFocus: () {
setState(() {
showContent = false;
});
},
),
AnimatedOpacity(
opacity: showContent ? 1 : 0,
duration: Duration(milliseconds: 300),
child: _buildContents(),
),
_buildSkip()
],
),
);
}
Widget _buildContents() {
if (currentTarget == null) {
return SizedBox.shrink();
}
List children = List();
TargetPosition target = getTargetCurrent(currentTarget);
var positioned = Offset(
target.offset.dx + target.size.width / 2,
target.offset.dy + target.size.height / 2,
);
double haloWidth;
double haloHeight;
if (currentTarget.shape == ShapeLightFocus.Circle) {
haloWidth = target.size.width > target.size.height
? target.size.width
: target.size.height;
haloHeight = haloWidth;
} else {
haloWidth = target.size.width;
haloHeight = target.size.height;
}
haloWidth = haloWidth * 0.6 + widget.paddingFocus;
haloHeight = haloHeight * 0.6 + widget.paddingFocus;
double weight = 0.0;
double top;
double bottom;
double left;
children = currentTarget.contents.map((i) {
switch (i.align) {
case AlignContent.bottom:
{
weight = MediaQuery.of(context).size.width;
left = 0;
top = positioned.dy + haloHeight;
bottom = null;
}
break;
case AlignContent.top:
{
weight = MediaQuery.of(context).size.width;
left = 0;
top = null;
bottom = haloHeight +
(MediaQuery.of(context).size.height - positioned.dy);
}
break;
case AlignContent.left:
{
weight = positioned.dx - haloWidth;
left = 0;
top = positioned.dy - target.size.height / 2 - haloHeight;
bottom = null;
}
break;
case AlignContent.right:
{
left = positioned.dx + haloWidth;
top = positioned.dy - target.size.height / 2 - haloHeight;
bottom = null;
weight = MediaQuery.of(context).size.width - left;
}
break;
case AlignContent.custom:
{
left = i.customPosition.left;
top = i.customPosition.top;
bottom = i.customPosition.bottom;
weight = MediaQuery.of(context).size.width;
}
break;
}
return Positioned(
top: top,
bottom: bottom,
left: left,
child: Container(
width: weight,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: i.child,
),
),
);
}).toList();
return Stack(
children: children,
);
}
Widget _buildSkip() {
if (widget.hideSkip) {
return SizedBox.shrink();
}
return Align(
alignment: widget.alignSkip,
child: SafeArea(
child: AnimatedOpacity(
opacity: showContent ? 1 : 0,
duration: Duration(milliseconds: 300),
child: InkWell(
onTap: widget.clickSkip,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Text(
widget.textSkip,
style: widget.textStyleSkip,
key: textKey
),
),
),
),
),
);
}
void next() => _focusLightKey?.currentState?.next();
void previous() => _focusLightKey?.currentState?.previous();
}
is it because of the Coach Mark library creates something like full screen overlay so that i can't identify the widgets? if so what could i do?
ANSWER
Answered 2020-Nov-06 at 08:12i found the problem here.. flutter driver itself is frame synchronyzed, so in this COachMark library i have to wait until there are no pending frames..
i changed my code from this
await world.driver.tap(finderHere);
to be something like this (i use runUnsynchronyzed
to make sure that tere are no pending frames)
await world.driver.runUnsynchronized(() async{
await world.driver.tap(finderHere);
});
QUESTION
Im setting my button with :active to move it when clicked with margin-top & left, but everytime i click the button, the heading above is also move to the top, it also effect the scrollbar. How to make just the button that move?
Then, when i add margin-top to my button div, the heading above is also pushed to top, how to get rid of it so just the button who go down?
Thanks
Here's my code: https://jsfiddle.net/arknmaulana/ktuvq9sb/6/
Journal Online
Untuk kamu yang masih pake jurnal analog
GET STARTED
#section01 div:nth-child(2):active{
box-shadow: none;
margin-top: 110px;
margin-left: 10px;}
ANSWER
Answered 2019-Jan-24 at 13:56You can use the CSS transform property to move your button without screwing up your layout:
#section01 div:nth-child(2):active{
box-shadow: none;
transform: translate(10px, 20px);
}
QUESTION
So I have 3 tables given on the codes below I don't know if there's any way to optimize this because I think it's not the proper way to insert data especially if you're dealing with normalization.
string mySqlCon = "Server = localhost; port = 3306; database = rmsdb; Uid = root; pwd=''"; //connection string
private void loginbtn_Click(object sender, EventArgs e)
{
MySqlConnection con = new MySqlConnection(mySqlCon);
MySqlCommand cmd;
try
{
if (firstnametb.Text.Length > 0 && lastnametb.Text.Length > 0 && gendercb.Text.Length > 0 && addresstb.Text.Length > 0 && birthdatetb.Text.Length > 0 && gradelevelcb.Text.Length > 0 && sectioncb.Text.Length > 0 && positioncb.Text.Length > 0 && empstatuscb.Text.Length > 0 && fiutb.Text.Length > 0 && oadtb.Text.Length > 0 && prctb.Text.Length > 0 && gsistb.Text.Length > 0 && csetb.Text.Length > 0 && contacttb.Text.Length > 0 && usernametb.Text.Length > 0 && passwordtb.Text.Length > 0 && questioncb.Text.Length > 0 && answertb.Text.Length > 0)
{
string CmdString = "INSERT INTO TeachersINFO('teachersid',firstname,lastname,gender,address,birthdate,position,empstatus,contactnumber,gradelevel,section,status) values (@teachersid,@firstname,@lastname,@gender,@address,@birthdate,@position,@empstatus,@contactnumber,@gradelevel,@section,@status);" +Environment.NewLine+
"INSERT INTO teacherslogin(teachersid,username,password,secretquestion,answer,status) values (@teachersid2,@username,@password,@secretquestion,@answer,@status2);" +Environment.NewLine+
"INSERT INTO teachersref(teachersid,FIU,oad,PrcNo,GSISBPNo,UMIDNo,TinNo,PhilHealthNo,CivilServiceE) values (@teachersid3,@FIU,@oad,@PrcNo,@GSISBPNo,@UMIDNo,@TinNo,@PhilHealthNo)";
cmd = new MySqlCommand(CmdString, con);
cmd.Parameters.AddWithValue("@teachersid", teacheridtb.Text);
cmd.Parameters.AddWithValue("@firstname", firstnametb.Text);
cmd.Parameters.AddWithValue("@lastname", lastnametb.Text);
cmd.Parameters.AddWithValue("@gender", gendercb.Text);
cmd.Parameters.AddWithValue("@address", addresstb.Text);
cmd.Parameters.AddWithValue("@birthdate", birthdatetb.Text);
cmd.Parameters.AddWithValue("@position", positioncb.Text);
cmd.Parameters.AddWithValue("@empstatus", empstatuscb.Text);
cmd.Parameters.AddWithValue("@contactnumber", contacttb.Text);
cmd.Parameters.AddWithValue("@gradelevel", gradelevelcb.Text);
cmd.Parameters.AddWithValue("@section", sectioncb.Text);
cmd.Parameters.AddWithValue("@status", 1);
//secondtable values p0ta kahit pandurugas to wala kong pake stored procedures parin tawag dito HAHAHA//
cmd.Parameters.AddWithValue("@teachersid2", teacheridtb.Text);
cmd.Parameters.AddWithValue("@username", usernametb.Text);
cmd.Parameters.AddWithValue("@password", passwordtb.Text);
cmd.Parameters.AddWithValue("@secretquestion", questioncb.Text);
cmd.Parameters.AddWithValue("@answer", answertb.Text);
cmd.Parameters.AddWithValue("@status2",1);
//thirdtable values hahaha pota pandaraya so much
con.Open();
int RowsAffected = cmd.ExecuteNonQuery();
if (RowsAffected > 0)
{
MessageBox.Show("Registered Successfully", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
firstnametb.Text = "";
lastnametb.Text = "";
gendercb.SelectedItem = null;
lastnametb.Text = "";
addresstb.Text = "";
gradelevelcb.SelectedItem = null;
sectioncb.SelectedItem = null;
answertb.Text = "";
usernametb.Text = "";
passwordtb.Text = "";
questioncb.Text = "";
empstatuscb.Text = "";
positioncb.Text = "";
fiutb.Text = "";
oadtb.Text = "";
prctb.Text = "";
gsistb.Text = "";
csetb.Text = "";
con.Close();
//clearing textboxes fields.
}
}
else
{
MessageBox.Show("Incomplete Data", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (con.State == ConnectionState.Open)
{
con.Close();
}
}
}
ANSWER
Answered 2017-Nov-16 at 03:30I would advise using a stored procedure that takes in all these parameters and then does the insert.
Using a stored procedure can help optimise the code as the stored procedure has already been compiled before it is called in the C# code. That should help with optimisation.
You can also use something like EntityFramework to help you avoid writing SQL commands by yourself.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pake
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page