parent
							
								
									72b85fc09f
								
							
						
					
					
						commit
						5e0eda9526
					
				
					 7 changed files with 65 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -40,6 +40,7 @@
 | 
			
		|||
					<span>{{ $t('latest-request-received-at') }}</span>
 | 
			
		||||
				</ui-input>
 | 
			
		||||
				<ui-switch v-model="instance.isBlocked" @change="updateInstance()">{{ $t('block') }}</ui-switch>
 | 
			
		||||
				<ui-switch v-model="instance.isMarkedAsClosed" @change="updateInstance()">{{ $t('marked-as-closed') }}</ui-switch>
 | 
			
		||||
				<details>
 | 
			
		||||
					<summary>{{ $t('charts') }}</summary>
 | 
			
		||||
					<ui-horizon-group inputs>
 | 
			
		||||
| 
						 | 
				
			
			@ -80,6 +81,8 @@
 | 
			
		|||
					<span slot="label">{{ $t('sort') }}</span>
 | 
			
		||||
					<option value="-caughtAt">{{ $t('sorts.caughtAtAsc') }}</option>
 | 
			
		||||
					<option value="+caughtAt">{{ $t('sorts.caughtAtDesc') }}</option>
 | 
			
		||||
					<option value="-lastCommunicatedAt">{{ $t('sorts.lastCommunicatedAtAsc') }}</option>
 | 
			
		||||
					<option value="+lastCommunicatedAt">{{ $t('sorts.lastCommunicatedAtDesc') }}</option>
 | 
			
		||||
					<option value="-notes">{{ $t('sorts.notesAsc') }}</option>
 | 
			
		||||
					<option value="+notes">{{ $t('sorts.notesDesc') }}</option>
 | 
			
		||||
					<option value="-users">{{ $t('sorts.usersAsc') }}</option>
 | 
			
		||||
| 
						 | 
				
			
			@ -97,6 +100,8 @@
 | 
			
		|||
					<span slot="label">{{ $t('state') }}</span>
 | 
			
		||||
					<option value="all">{{ $t('states.all') }}</option>
 | 
			
		||||
					<option value="blocked">{{ $t('states.blocked') }}</option>
 | 
			
		||||
					<option value="notResponding">{{ $t('states.not-responding') }}</option>
 | 
			
		||||
					<option value="markedAsClosed">{{ $t('states.marked-as-closed') }}</option>
 | 
			
		||||
				</ui-select>
 | 
			
		||||
			</ui-horizon-group>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -247,7 +252,9 @@ export default Vue.extend({
 | 
			
		|||
		fetchInstances() {
 | 
			
		||||
			this.instances = [];
 | 
			
		||||
			this.$root.api('federation/instances', {
 | 
			
		||||
				state: this.state,
 | 
			
		||||
				blocked: this.state === 'blocked' ? true : null,
 | 
			
		||||
				notResponding: this.state === 'notResponding' ? true : null,
 | 
			
		||||
				markedAsClosed: this.state === 'markedAsClosed' ? true : null,
 | 
			
		||||
				sort: this.sort,
 | 
			
		||||
				limit: this.limit
 | 
			
		||||
			}).then(instances => {
 | 
			
		||||
| 
						 | 
				
			
			@ -269,7 +276,8 @@ export default Vue.extend({
 | 
			
		|||
		updateInstance() {
 | 
			
		||||
			this.$root.api('admin/federation/update-instance', {
 | 
			
		||||
				host: this.instance.host,
 | 
			
		||||
				isBlocked: this.instance.isBlocked,
 | 
			
		||||
				isBlocked: this.instance.isBlocked || false,
 | 
			
		||||
				isClosed: this.instance.isMarkedAsClosed || false
 | 
			
		||||
			});
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -68,8 +68,23 @@ export interface IInstance {
 | 
			
		|||
	 */
 | 
			
		||||
	latestRequestReceivedAt?: Date;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * このインスタンスと不通かどうか
 | 
			
		||||
	 */
 | 
			
		||||
	isNotResponding: boolean;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * このインスタンスと最後にやり取りした日時
 | 
			
		||||
	 */
 | 
			
		||||
	lastCommunicatedAt: Date;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * このインスタンスをブロックしているか
 | 
			
		||||
	 */
 | 
			
		||||
	isBlocked: boolean;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * このインスタンスが閉鎖済みとしてマークされているか
 | 
			
		||||
	 */
 | 
			
		||||
	isMarkedAsClosed: boolean;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,9 @@ export default async (job: bq.Job, done: any): Promise<void> => {
 | 
			
		|||
			Instance.update({ _id: i._id }, {
 | 
			
		||||
				$set: {
 | 
			
		||||
					latestRequestSentAt: new Date(),
 | 
			
		||||
					latestStatus: 200
 | 
			
		||||
					latestStatus: 200,
 | 
			
		||||
					lastCommunicatedAt: new Date(),
 | 
			
		||||
					isNotResponding: false
 | 
			
		||||
				}
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +33,8 @@ export default async (job: bq.Job, done: any): Promise<void> => {
 | 
			
		|||
			Instance.update({ _id: i._id }, {
 | 
			
		||||
				$set: {
 | 
			
		||||
					latestRequestSentAt: new Date(),
 | 
			
		||||
					latestStatus: res != null && res.hasOwnProperty('statusCode') ? res.statusCode : null
 | 
			
		||||
					latestStatus: res != null && res.hasOwnProperty('statusCode') ? res.statusCode : null,
 | 
			
		||||
					isNotResponding: true
 | 
			
		||||
				}
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -126,7 +126,9 @@ export default async (job: bq.Job, done: any): Promise<void> => {
 | 
			
		|||
	registerOrFetchInstanceDoc(user.host).then(i => {
 | 
			
		||||
		Instance.update({ _id: i._id }, {
 | 
			
		||||
			$set: {
 | 
			
		||||
				latestRequestReceivedAt: new Date()
 | 
			
		||||
				latestRequestReceivedAt: new Date(),
 | 
			
		||||
				lastCommunicatedAt: new Date(),
 | 
			
		||||
				isNotResponding: false
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,6 +14,10 @@ export const meta = {
 | 
			
		|||
		isBlocked: {
 | 
			
		||||
			validator: $.bool
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		isClosed: {
 | 
			
		||||
			validator: $.bool
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +30,8 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
 | 
			
		|||
 | 
			
		||||
	Instance.update({ host: ps.host }, {
 | 
			
		||||
		$set: {
 | 
			
		||||
			isBlocked: ps.isBlocked
 | 
			
		||||
			isBlocked: ps.isBlocked,
 | 
			
		||||
			isMarkedAsClosed: ps.isClosed
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,8 +6,16 @@ export const meta = {
 | 
			
		|||
	requireCredential: false,
 | 
			
		||||
 | 
			
		||||
	params: {
 | 
			
		||||
		state: {
 | 
			
		||||
			validator: $.str.optional,
 | 
			
		||||
		blocked: {
 | 
			
		||||
			validator: $.bool.optional.nullable,
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		notResponding: {
 | 
			
		||||
			validator: $.bool.optional.nullable,
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		markedAsClosed: {
 | 
			
		||||
			validator: $.bool.optional.nullable,
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		limit: {
 | 
			
		||||
| 
						 | 
				
			
			@ -70,6 +78,14 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
 | 
			
		|||
			sort = {
 | 
			
		||||
				caughtAt: 1
 | 
			
		||||
			};
 | 
			
		||||
		} else if (ps.sort == '+lastCommunicatedAt') {
 | 
			
		||||
			sort = {
 | 
			
		||||
				lastCommunicatedAt: -1
 | 
			
		||||
			};
 | 
			
		||||
		} else if (ps.sort == '-lastCommunicatedAt') {
 | 
			
		||||
			sort = {
 | 
			
		||||
				lastCommunicatedAt: 1
 | 
			
		||||
			};
 | 
			
		||||
		} else if (ps.sort == '+driveUsage') {
 | 
			
		||||
			sort = {
 | 
			
		||||
				driveUsage: -1
 | 
			
		||||
| 
						 | 
				
			
			@ -95,9 +111,9 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
 | 
			
		|||
 | 
			
		||||
	const q = {} as any;
 | 
			
		||||
 | 
			
		||||
	if (ps.state === 'blocked') {
 | 
			
		||||
		q.isBlocked = true;
 | 
			
		||||
	}
 | 
			
		||||
	if (typeof ps.blocked === 'boolean') q.isBlocked = ps.blocked;
 | 
			
		||||
	if (typeof ps.notResponding === 'boolean') q.isNotResponding = ps.notResponding;
 | 
			
		||||
	if (typeof ps.markedAsClosed === 'boolean') q.isMarkedAsClosed = ps.markedAsClosed;
 | 
			
		||||
 | 
			
		||||
	const instances = await Instance
 | 
			
		||||
		.find(q, {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue