Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aidmi
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
aidmi
Commits
ca25fe37
Commit
ca25fe37
authored
Sep 24, 2024
by
Mike Feranda
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3476570
by mferanda: Temporary disable button on click and change icon to loader
parent
10c686f4
No related branches found
No related tags found
No related merge requests found
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
icons/aidmi_loading.svg
+21
-0
21 additions, 0 deletions
icons/aidmi_loading.svg
js/build/aidmiPlugin.js
+1
-1
1 addition, 1 deletion
js/build/aidmiPlugin.js
js/ckeditor5_plugins/aidmiPlugin/src/aidmiui.js
+18
-1
18 additions, 1 deletion
js/ckeditor5_plugins/aidmiPlugin/src/aidmiui.js
with
40 additions
and
2 deletions
icons/aidmi_loading.svg
0 → 100644
+
21
−
0
View file @
ca25fe37
<svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"20"
height=
"20"
viewBox=
"0 0 20 20"
style=
"color:#1C2033"
class=
"h-full w-full"
>
<rect
width=
"20"
height=
"20"
x=
"0"
y=
"0"
rx=
"0"
fill=
"transparent"
stroke=
"transparent"
stroke-width=
"0"
stroke-opacity=
"0%"
paint-order=
"stroke"
/><svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"20px"
height=
"20px"
viewBox=
"0 0 20 20"
fill=
"#1C2033"
x=
"0"
y=
"0"
role=
"img"
style=
"display:inline-block;vertical-align:middle"
>
<g
fill=
"#1C2033"
>
<rect
width=
"6"
height=
"14"
x=
"1"
y=
"4"
fill=
"currentColor"
>
<animate
id=
"svgSpinnersBarsScaleFade0"
fill=
"freeze"
attributeName=
"y"
begin=
"0;svgSpinnersBarsScaleFade1.end-0.25s"
dur=
"0.75s"
values=
"1;5"
/>
<animate
fill=
"freeze"
attributeName=
"height"
begin=
"0;svgSpinnersBarsScaleFade1.end-0.25s"
dur=
"0.75s"
values=
"22;14"
/>
<animate
fill=
"freeze"
attributeName=
"opacity"
begin=
"0;svgSpinnersBarsScaleFade1.end-0.25s"
dur=
"0.75s"
values=
"1;.2"
/>
</rect>
<rect
width=
"6"
height=
"14"
x=
"9"
y=
"4"
fill=
"currentColor"
opacity=
".4"
>
<animate
fill=
"freeze"
attributeName=
"y"
begin=
"svgSpinnersBarsScaleFade0.begin+0.15s"
dur=
"0.75s"
values=
"1;5"
/>
<animate
fill=
"freeze"
attributeName=
"height"
begin=
"svgSpinnersBarsScaleFade0.begin+0.15s"
dur=
"0.75s"
values=
"22;14"
/>
<animate
fill=
"freeze"
attributeName=
"opacity"
begin=
"svgSpinnersBarsScaleFade0.begin+0.15s"
dur=
"0.75s"
values=
"1;.2"
/>
</rect>
<rect
width=
"6"
height=
"14"
x=
"17"
y=
"4"
fill=
"currentColor"
opacity=
".3"
>
<animate
id=
"svgSpinnersBarsScaleFade1"
fill=
"freeze"
attributeName=
"y"
begin=
"svgSpinnersBarsScaleFade0.begin+0.3s"
dur=
"0.75s"
values=
"1;5"
/>
<animate
fill=
"freeze"
attributeName=
"height"
begin=
"svgSpinnersBarsScaleFade0.begin+0.3s"
dur=
"0.75s"
values=
"22;14"
/>
<animate
fill=
"freeze"
attributeName=
"opacity"
begin=
"svgSpinnersBarsScaleFade0.begin+0.3s"
dur=
"0.75s"
values=
"1;.2"
/>
</rect>
</g>
</svg>
</svg>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/build/aidmiPlugin.js
+
1
−
1
View file @
ca25fe37
This diff is collapsed.
Click to expand it.
js/ckeditor5_plugins/aidmiPlugin/src/aidmiui.js
+
18
−
1
View file @
ca25fe37
...
...
@@ -12,6 +12,7 @@ import {
}
from
'
ckeditor5/src/ui
'
;
import
iconAidmi
from
'
../../../../icons/aidmi.svg
'
;
import
iconAidmiLoading
from
'
../../../../icons/aidmi_loading.svg
'
;
export
default
class
AIDmiUI
extends
Plugin
{
init
()
{
...
...
@@ -34,6 +35,13 @@ export default class AIDmiUI extends Plugin {
this
.
listenTo
(
button
,
'
execute
'
,
async
()
=>
{
try
{
// Show loading state
button
.
label
=
'
Processing...
'
;
button
.
isEnabled
=
false
;
// Disable the button
// Change to loading icon.
button
.
icon
=
iconAidmiLoading
;
let
output
=
null
;
let
parsedOutput
=
null
;
let
imagesJSON
=
this
.
_aidmiJSONImages
(
editor
.
getData
());
...
...
@@ -44,9 +52,18 @@ export default class AIDmiUI extends Plugin {
parsedOutput
=
JSON
.
parse
(
output
);
this
.
_openDialog
(
editor
,
parsedOutput
,
imagesJSON
);
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
"
Error:
"
,
error
);
}
finally
{
// Restore button state after processing is done
button
.
label
=
'
AI, describe my image!
'
;
button
.
icon
=
iconAidmi
;
// Restore the original icon
button
.
isEnabled
=
true
;
// Re-enable the button
}
});
// Add a listener to enable or disable the button based on content changes.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment