2023-01-28 13:13:04 +00:00
|
|
|
<template>
|
2023-08-21 08:23:16 +00:00
|
|
|
<Settings :title="$t('admin.settings.agents.agents')" :desc="$t('admin.settings.agents.desc')">
|
|
|
|
<template #titleActions>
|
2023-01-28 13:13:04 +00:00
|
|
|
<Button
|
|
|
|
v-if="selectedAgent"
|
|
|
|
:text="$t('admin.settings.agents.show')"
|
|
|
|
start-icon="back"
|
|
|
|
@click="selectedAgent = undefined"
|
|
|
|
/>
|
2023-08-21 08:23:16 +00:00
|
|
|
<Button v-else :text="$t('admin.settings.agents.add')" start-icon="plus" @click="showAddAgent" />
|
|
|
|
</template>
|
2023-01-28 13:13:04 +00:00
|
|
|
|
Use consistent woodpecker color scheme (#2003)
Fixes: https://github.com/woodpecker-ci/woodpecker/issues/1079
What do you think about using a consistent `woodpecker` color scheme?
Right now, the `lime` color scheme from windicss is used that does not
really fit the primary color used for the documentation website. I have
used the primary color `#4CAF50` from the docs and created a color
palette with https://palettte.app/:
<details>
<summary>JSON source</summary>
```Json
[
{
"paletteName": "New Palette",
"swatches": [
{
"name": "New Swatch",
"color": "166E30"
},
{
"name": "New Swatch",
"color": "248438"
},
{
"name": "New Swatch",
"color": "369943"
},
{
"name": "New Swatch",
"color": "4CAF50"
},
{
"name": "New Swatch",
"color": "68C464"
},
{
"name": "New Swatch",
"color": "8AD97F"
}
]
}
]
```
</details>
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/a254f1e0-ce17-43a9-9e8b-72252296fd6f)
I have added this color scheme to the windicss config and replaced the
use of `lime` in the UI. While `woodpecker-300` would be the primary
color that is used for the docs, I currently use `woodpecke-400` as
primary color for the UI to fix some contrast issues.
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/7bf751e1-f2a6-481c-bee7-a27d27cf8adb)
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/e5673dc7-81c1-4fd4-bef9-14494bc5aa27)
What do you think? If you would like to stay with the current colors,
that's fine for me, I can just use the custom CSS feature in this case.
---------
Co-authored-by: 6543 <6543@obermui.de>
2023-08-02 07:09:12 +00:00
|
|
|
<div v-if="!selectedAgent" class="space-y-4 text-wp-text-100">
|
|
|
|
<ListItem
|
|
|
|
v-for="agent in agents"
|
|
|
|
:key="agent.id"
|
|
|
|
class="items-center !bg-wp-background-200 !dark:bg-wp-background-100"
|
|
|
|
>
|
2023-01-28 13:13:04 +00:00
|
|
|
<span>{{ agent.name || `Agent ${agent.id}` }}</span>
|
2023-01-30 20:53:59 +00:00
|
|
|
<span class="ml-auto">
|
|
|
|
<span class="hidden md:inline-block space-x-2">
|
2023-08-07 11:19:51 +00:00
|
|
|
<Badge v-if="agent.platform" :label="$t('admin.settings.agents.platform.badge')" :value="agent.platform" />
|
|
|
|
<Badge v-if="agent.backend" :label="$t('admin.settings.agents.backend.badge')" :value="agent.backend" />
|
|
|
|
<Badge v-if="agent.capacity" :label="$t('admin.settings.agents.capacity.badge')" :value="agent.capacity" />
|
2023-01-30 20:53:59 +00:00
|
|
|
</span>
|
2023-08-07 12:01:44 +00:00
|
|
|
<span class="ml-2">{{
|
2023-12-04 11:46:24 +00:00
|
|
|
agent.last_contact ? date.timeAgo(agent.last_contact * 1000) : $t('admin.settings.agents.never')
|
2023-08-07 12:01:44 +00:00
|
|
|
}}</span>
|
2023-01-30 20:53:59 +00:00
|
|
|
</span>
|
2023-03-21 13:10:43 +00:00
|
|
|
<IconButton
|
|
|
|
icon="edit"
|
|
|
|
:title="$t('admin.settings.agents.edit_agent')"
|
|
|
|
class="ml-2 w-8 h-8"
|
|
|
|
@click="editAgent(agent)"
|
|
|
|
/>
|
2023-01-28 13:13:04 +00:00
|
|
|
<IconButton
|
|
|
|
icon="trash"
|
2023-03-21 13:10:43 +00:00
|
|
|
:title="$t('admin.settings.agents.delete_agent')"
|
Use consistent woodpecker color scheme (#2003)
Fixes: https://github.com/woodpecker-ci/woodpecker/issues/1079
What do you think about using a consistent `woodpecker` color scheme?
Right now, the `lime` color scheme from windicss is used that does not
really fit the primary color used for the documentation website. I have
used the primary color `#4CAF50` from the docs and created a color
palette with https://palettte.app/:
<details>
<summary>JSON source</summary>
```Json
[
{
"paletteName": "New Palette",
"swatches": [
{
"name": "New Swatch",
"color": "166E30"
},
{
"name": "New Swatch",
"color": "248438"
},
{
"name": "New Swatch",
"color": "369943"
},
{
"name": "New Swatch",
"color": "4CAF50"
},
{
"name": "New Swatch",
"color": "68C464"
},
{
"name": "New Swatch",
"color": "8AD97F"
}
]
}
]
```
</details>
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/a254f1e0-ce17-43a9-9e8b-72252296fd6f)
I have added this color scheme to the windicss config and replaced the
use of `lime` in the UI. While `woodpecker-300` would be the primary
color that is used for the docs, I currently use `woodpecke-400` as
primary color for the UI to fix some contrast issues.
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/7bf751e1-f2a6-481c-bee7-a27d27cf8adb)
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/e5673dc7-81c1-4fd4-bef9-14494bc5aa27)
What do you think? If you would like to stay with the current colors,
that's fine for me, I can just use the custom CSS feature in this case.
---------
Co-authored-by: 6543 <6543@obermui.de>
2023-08-02 07:09:12 +00:00
|
|
|
class="ml-2 w-8 h-8 hover:text-wp-control-error-100"
|
2023-01-28 13:13:04 +00:00
|
|
|
:is-loading="isDeleting"
|
|
|
|
@click="deleteAgent(agent)"
|
|
|
|
/>
|
|
|
|
</ListItem>
|
|
|
|
|
|
|
|
<div v-if="agents?.length === 0" class="ml-2">{{ $t('admin.settings.agents.none') }}</div>
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
|
|
|
<form @submit.prevent="saveAgent">
|
2023-12-19 20:32:35 +00:00
|
|
|
<InputField v-slot="{ id }" :label="$t('admin.settings.agents.name.name')">
|
2023-01-28 13:13:04 +00:00
|
|
|
<TextField
|
2023-12-19 20:32:35 +00:00
|
|
|
:id="id"
|
2023-01-28 13:13:04 +00:00
|
|
|
v-model="selectedAgent.name"
|
|
|
|
:placeholder="$t('admin.settings.agents.name.placeholder')"
|
|
|
|
required
|
|
|
|
/>
|
|
|
|
</InputField>
|
|
|
|
|
2023-01-30 19:18:48 +00:00
|
|
|
<InputField :label="$t('admin.settings.agents.no_schedule.name')">
|
|
|
|
<Checkbox
|
|
|
|
:model-value="selectedAgent.no_schedule || false"
|
|
|
|
:label="$t('admin.settings.agents.no_schedule.placeholder')"
|
|
|
|
@update:model-value="selectedAgent!.no_schedule = $event"
|
|
|
|
/>
|
|
|
|
</InputField>
|
|
|
|
|
2023-01-28 13:13:04 +00:00
|
|
|
<template v-if="isEditingAgent">
|
2023-12-19 20:32:35 +00:00
|
|
|
<InputField v-slot="{ id }" :label="$t('admin.settings.agents.token')">
|
|
|
|
<TextField
|
|
|
|
:id="id"
|
|
|
|
v-model="selectedAgent.token"
|
|
|
|
:placeholder="$t('admin.settings.agents.token')"
|
|
|
|
disabled
|
|
|
|
/>
|
2023-01-28 13:13:04 +00:00
|
|
|
</InputField>
|
|
|
|
|
2023-12-19 20:32:35 +00:00
|
|
|
<InputField v-slot="{ id }" :label="$t('admin.settings.agents.id')">
|
|
|
|
<TextField :id="id" :model-value="selectedAgent.id?.toString()" disabled />
|
2023-07-02 15:22:05 +00:00
|
|
|
</InputField>
|
|
|
|
|
2023-01-30 20:53:59 +00:00
|
|
|
<InputField
|
2023-12-19 20:32:35 +00:00
|
|
|
v-slot="{ id }"
|
2023-01-30 20:53:59 +00:00
|
|
|
:label="$t('admin.settings.agents.backend.backend')"
|
|
|
|
docs-url="docs/next/administration/backends/docker"
|
|
|
|
>
|
2023-12-19 20:32:35 +00:00
|
|
|
<TextField :id="id" v-model="selectedAgent.backend" disabled />
|
2023-01-28 13:13:04 +00:00
|
|
|
</InputField>
|
|
|
|
|
2023-12-19 20:32:35 +00:00
|
|
|
<InputField v-slot="{ id }" :label="$t('admin.settings.agents.platform.platform')">
|
|
|
|
<TextField :id="id" v-model="selectedAgent.platform" disabled />
|
2023-01-28 13:13:04 +00:00
|
|
|
</InputField>
|
|
|
|
|
|
|
|
<InputField
|
2023-12-19 20:32:35 +00:00
|
|
|
v-slot="{ id }"
|
2023-01-30 20:53:59 +00:00
|
|
|
:label="$t('admin.settings.agents.capacity.capacity')"
|
2024-01-27 20:15:10 +00:00
|
|
|
docs-url="docs/next/administration/agent-config#woodpecker_max_workflows"
|
2023-01-28 13:13:04 +00:00
|
|
|
>
|
Use consistent woodpecker color scheme (#2003)
Fixes: https://github.com/woodpecker-ci/woodpecker/issues/1079
What do you think about using a consistent `woodpecker` color scheme?
Right now, the `lime` color scheme from windicss is used that does not
really fit the primary color used for the documentation website. I have
used the primary color `#4CAF50` from the docs and created a color
palette with https://palettte.app/:
<details>
<summary>JSON source</summary>
```Json
[
{
"paletteName": "New Palette",
"swatches": [
{
"name": "New Swatch",
"color": "166E30"
},
{
"name": "New Swatch",
"color": "248438"
},
{
"name": "New Swatch",
"color": "369943"
},
{
"name": "New Swatch",
"color": "4CAF50"
},
{
"name": "New Swatch",
"color": "68C464"
},
{
"name": "New Swatch",
"color": "8AD97F"
}
]
}
]
```
</details>
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/a254f1e0-ce17-43a9-9e8b-72252296fd6f)
I have added this color scheme to the windicss config and replaced the
use of `lime` in the UI. While `woodpecker-300` would be the primary
color that is used for the docs, I currently use `woodpecke-400` as
primary color for the UI to fix some contrast issues.
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/7bf751e1-f2a6-481c-bee7-a27d27cf8adb)
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/e5673dc7-81c1-4fd4-bef9-14494bc5aa27)
What do you think? If you would like to stay with the current colors,
that's fine for me, I can just use the custom CSS feature in this case.
---------
Co-authored-by: 6543 <6543@obermui.de>
2023-08-02 07:09:12 +00:00
|
|
|
<span class="text-wp-text-alt-100">{{ $t('admin.settings.agents.capacity.desc') }}</span>
|
2023-12-19 20:32:35 +00:00
|
|
|
<TextField :id="id" :model-value="selectedAgent.capacity?.toString()" disabled />
|
2023-01-28 13:13:04 +00:00
|
|
|
</InputField>
|
|
|
|
|
2023-12-19 20:32:35 +00:00
|
|
|
<InputField v-slot="{ id }" :label="$t('admin.settings.agents.version')">
|
|
|
|
<TextField :id="id" :model-value="selectedAgent.version" disabled />
|
2023-01-28 13:13:04 +00:00
|
|
|
</InputField>
|
|
|
|
|
2023-12-19 20:32:35 +00:00
|
|
|
<InputField v-slot="{ id }" :label="$t('admin.settings.agents.last_contact')">
|
2023-01-28 13:13:04 +00:00
|
|
|
<TextField
|
2023-12-19 20:32:35 +00:00
|
|
|
:id="id"
|
2023-01-28 13:13:04 +00:00
|
|
|
:model-value="
|
|
|
|
selectedAgent.last_contact
|
2023-12-04 11:46:24 +00:00
|
|
|
? date.timeAgo(selectedAgent.last_contact * 1000)
|
2023-01-28 13:13:04 +00:00
|
|
|
: $t('admin.settings.agents.never')
|
|
|
|
"
|
|
|
|
disabled
|
|
|
|
/>
|
|
|
|
</InputField>
|
|
|
|
</template>
|
|
|
|
|
2023-03-19 12:52:58 +00:00
|
|
|
<div class="flex gap-2">
|
|
|
|
<Button type="button" color="gray" :text="$t('cancel')" @click="selectedAgent = undefined" />
|
|
|
|
<Button
|
|
|
|
:is-loading="isSaving"
|
|
|
|
type="submit"
|
|
|
|
color="green"
|
|
|
|
:text="isEditingAgent ? $t('admin.settings.agents.save') : $t('admin.settings.agents.add')"
|
|
|
|
/>
|
|
|
|
</div>
|
2023-01-28 13:13:04 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
2023-08-21 08:23:16 +00:00
|
|
|
</Settings>
|
2023-01-28 13:13:04 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { cloneDeep } from 'lodash';
|
2023-04-30 01:40:13 +00:00
|
|
|
import { computed, ref } from 'vue';
|
2023-01-28 13:13:04 +00:00
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
|
2023-01-30 20:53:59 +00:00
|
|
|
import Badge from '~/components/atomic/Badge.vue';
|
2023-01-28 13:13:04 +00:00
|
|
|
import Button from '~/components/atomic/Button.vue';
|
2023-03-21 13:10:43 +00:00
|
|
|
import IconButton from '~/components/atomic/IconButton.vue';
|
2023-01-28 13:13:04 +00:00
|
|
|
import ListItem from '~/components/atomic/ListItem.vue';
|
2023-01-30 19:18:48 +00:00
|
|
|
import Checkbox from '~/components/form/Checkbox.vue';
|
2023-01-28 13:13:04 +00:00
|
|
|
import InputField from '~/components/form/InputField.vue';
|
|
|
|
import TextField from '~/components/form/TextField.vue';
|
2023-08-21 08:23:16 +00:00
|
|
|
import Settings from '~/components/layout/Settings.vue';
|
2023-01-28 13:13:04 +00:00
|
|
|
import useApiClient from '~/compositions/useApiClient';
|
|
|
|
import { useAsyncAction } from '~/compositions/useAsyncAction';
|
2023-12-04 11:46:24 +00:00
|
|
|
import { useDate } from '~/compositions/useDate';
|
2023-01-28 13:13:04 +00:00
|
|
|
import useNotifications from '~/compositions/useNotifications';
|
2023-04-30 01:40:13 +00:00
|
|
|
import { usePagination } from '~/compositions/usePaginate';
|
2023-01-28 13:13:04 +00:00
|
|
|
import { Agent } from '~/lib/api/types';
|
|
|
|
|
|
|
|
const apiClient = useApiClient();
|
|
|
|
const notifications = useNotifications();
|
2023-12-04 11:46:24 +00:00
|
|
|
const date = useDate();
|
2023-03-21 13:10:43 +00:00
|
|
|
const { t } = useI18n();
|
2023-01-28 13:13:04 +00:00
|
|
|
|
|
|
|
const selectedAgent = ref<Partial<Agent>>();
|
|
|
|
const isEditingAgent = computed(() => !!selectedAgent.value?.id);
|
|
|
|
|
2023-04-30 01:40:13 +00:00
|
|
|
async function loadAgents(page: number): Promise<Agent[] | null> {
|
|
|
|
return apiClient.getAgents(page);
|
2023-01-28 13:13:04 +00:00
|
|
|
}
|
|
|
|
|
2023-04-30 01:40:13 +00:00
|
|
|
const { resetPage, data: agents } = usePagination(loadAgents, () => !selectedAgent.value);
|
|
|
|
|
2023-01-28 13:13:04 +00:00
|
|
|
const { doSubmit: saveAgent, isLoading: isSaving } = useAsyncAction(async () => {
|
|
|
|
if (!selectedAgent.value) {
|
|
|
|
throw new Error("Unexpected: Can't get agent");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isEditingAgent.value) {
|
|
|
|
await apiClient.updateAgent(selectedAgent.value);
|
|
|
|
selectedAgent.value = undefined;
|
|
|
|
} else {
|
|
|
|
selectedAgent.value = await apiClient.createAgent(selectedAgent.value);
|
|
|
|
}
|
|
|
|
notifications.notify({
|
2023-03-21 13:10:43 +00:00
|
|
|
title: t(isEditingAgent.value ? 'admin.settings.agents.saved' : 'admin.settings.agents.created'),
|
2023-01-28 13:13:04 +00:00
|
|
|
type: 'success',
|
|
|
|
});
|
2023-04-30 01:40:13 +00:00
|
|
|
resetPage();
|
2023-01-28 13:13:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const { doSubmit: deleteAgent, isLoading: isDeleting } = useAsyncAction(async (_agent: Agent) => {
|
|
|
|
// eslint-disable-next-line no-restricted-globals, no-alert
|
2023-03-21 13:10:43 +00:00
|
|
|
if (!confirm(t('admin.settings.agents.delete_confirm'))) {
|
2023-01-28 13:13:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
await apiClient.deleteAgent(_agent);
|
2023-03-21 13:10:43 +00:00
|
|
|
notifications.notify({ title: t('admin.settings.agents.deleted'), type: 'success' });
|
2023-04-30 01:40:13 +00:00
|
|
|
resetPage();
|
2023-01-28 13:13:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function editAgent(agent: Agent) {
|
|
|
|
selectedAgent.value = cloneDeep(agent);
|
|
|
|
}
|
|
|
|
|
|
|
|
function showAddAgent() {
|
|
|
|
selectedAgent.value = cloneDeep({ name: '' });
|
|
|
|
}
|
|
|
|
</script>
|